2019-12-20 19:06:42 +00:00
|
|
|
// Sets [velocity] to a vector with the given [angle] and a 12-pixel length.
|
|
|
|
//
|
|
|
|
// TH05 also insists on setting shot_t::angle via a ridiculous out-of-bounds
|
|
|
|
// access, and therefore *must* be called with [velocity] pointing inside a
|
|
|
|
// shot_t structure!
|
|
|
|
SPPoint pascal near shot_velocity_set(
|
|
|
|
SPPoint near* velocity, unsigned char angle
|
|
|
|
);
|
|
|
|
|
|
|
|
struct shot_t {
|
|
|
|
char flag;
|
|
|
|
char age;
|
|
|
|
motion_t pos;
|
|
|
|
// The displayed sprite changes between this one and
|
|
|
|
// [patnum_base + 1] every two frames.
|
|
|
|
#if GAME == 5
|
|
|
|
char patnum_base;
|
|
|
|
char type;
|
|
|
|
#else
|
|
|
|
int patnum_base;
|
|
|
|
#endif
|
|
|
|
char damage;
|
|
|
|
char angle; // Unused in TH04
|
|
|
|
|
|
|
|
void from_option_l(float offset = 0.0f) {
|
|
|
|
this->pos.cur.x -= PLAYER_OPTION_DISTANCE + offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void from_option_r(float offset = 0.0f) {
|
|
|
|
this->pos.cur.x += PLAYER_OPTION_DISTANCE + offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_option_sprite() {
|
2020-02-10 20:59:23 +00:00
|
|
|
this->patnum_base = PAT_SHOT_SUB;
|
2019-12-20 19:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void set_option_sprite_and_damage(char damage) {
|
|
|
|
set_option_sprite();
|
|
|
|
this->damage = damage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_random_angle_forwards(char random_range = 15, char offset = 184) {
|
|
|
|
shot_velocity_set(
|
|
|
|
(SPPoint near*)&this->pos.velocity,
|
|
|
|
randring_angle(random_range, offset)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-04-18 12:41:47 +00:00
|
|
|
#if (GAME == 4)
|
|
|
|
# define SHOT_COUNT 68
|
|
|
|
#endif
|
|
|
|
|
2019-12-21 16:23:03 +00:00
|
|
|
extern unsigned char shot_time;
|
2020-04-18 12:41:47 +00:00
|
|
|
extern shot_t near shots[SHOT_COUNT];
|
2019-12-21 16:23:03 +00:00
|
|
|
|
|
|
|
// Points to the next free entry in [shots].
|
|
|
|
extern shot_t near *shot_ptr;
|
|
|
|
// Index of the last valid entry in [shots].
|
|
|
|
extern char shot_last_id;
|
|
|
|
|
2020-04-18 12:41:47 +00:00
|
|
|
// Only used for hit detection in TH04. TH05 also uses it in shots_render().
|
|
|
|
struct shot_alive_t {
|
|
|
|
SPPoint pos;
|
|
|
|
shot_t near *shot;
|
|
|
|
};
|
|
|
|
extern unsigned int shots_alive_count;
|
|
|
|
extern shot_alive_t shots_alive[SHOT_COUNT];
|
|
|
|
|
2019-12-20 19:06:42 +00:00
|
|
|
// Searches and returns the next free shot slot, or NULL if there are no more
|
|
|
|
// free ones.
|
|
|
|
shot_t near* pascal near shots_add(void);
|
2020-04-18 12:41:47 +00:00
|
|
|
// Also renders hitshots in TH05.
|
|
|
|
void pascal near shots_render(void);
|