[Add] Pilots now keep track of how many weapons are locked onto them.
This commit is contained in:
parent
1f8e6a22fe
commit
f7c10bf329
@ -235,6 +235,15 @@ double outfit_range(const Outfit* o) {
|
||||
return -1.;
|
||||
}
|
||||
|
||||
int outfit_isSeeker(const Outfit* o) {
|
||||
if((o->type == OUTFIT_TYPE_MISSILE_SEEK_AMMO) ||
|
||||
(o->type == OUTFIT_TYPE_MISSILE_SEEK_SMART_AMMO) ||
|
||||
(o->type == OUTFIT_TYPE_MISSILE_SWARM_AMMO) ||
|
||||
(o->type == OUTFIT_TYPE_MISSILE_SWARM_SMART_AMMO))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* outfit_typename[] = {
|
||||
"NULL",
|
||||
"Bolt Cannon",
|
||||
|
@ -146,6 +146,7 @@ DamageType outfit_damageType(const Outfit* o);
|
||||
int outfit_delay(const Outfit* o);
|
||||
double outfit_energy(const Outfit* o);
|
||||
double outfit_range(const Outfit* o);
|
||||
int outfit_isSeeker(const Outfit* o);
|
||||
|
||||
/* Load/free outfit stack. */
|
||||
int outfit_load(void);
|
||||
|
@ -103,8 +103,9 @@ typedef struct Pilot_ {
|
||||
int cargo_free;
|
||||
|
||||
/* Misc. */
|
||||
uint32_t flags; /* Used for AI etc. */
|
||||
uint32_t flags; /* Used for AI etc. */
|
||||
unsigned int ptimer; /* Generic timer for internal pilot use. */
|
||||
int lockons; /* Stores how many seeking weapons are targetting pilot. */
|
||||
|
||||
/* Hook attached to the pilot. */
|
||||
int hook_type;
|
||||
|
14
src/weapon.c
14
src/weapon.c
@ -379,6 +379,11 @@ static Weapon* weapon_create(const Outfit* outfit, const double dir, const Vec2*
|
||||
w->solid->pos.x, w->solid->pos.y,
|
||||
w->solid->vel.x, w->solid->vel.y, w->outfit->u.amm.sound, 0);
|
||||
|
||||
/* If they are seeking a pilot, increment lockon counter. */
|
||||
pilot_target = pilot_get(target);
|
||||
if(pilot_target != NULL)
|
||||
pilot_target->lockons++;
|
||||
|
||||
/* Only diff is AI. */
|
||||
if(outfit->type == OUTFIT_TYPE_MISSILE_SEEK_AMMO)
|
||||
w->think = think_seeker;
|
||||
@ -449,6 +454,15 @@ static void weapon_destroy(Weapon* w, WeaponLayer layer) {
|
||||
int i;
|
||||
Weapon** wlayer;
|
||||
int* nlayer;
|
||||
Pilot* pilot_target;
|
||||
|
||||
/* Decrement target lockons if needed. */
|
||||
if(outfit_isSeeker(w->outfit)) {
|
||||
pilot_target = pilot_get(w->target);
|
||||
if(pilot_target != NULL)
|
||||
pilot_target->lockons--;
|
||||
}
|
||||
|
||||
switch(layer) {
|
||||
case WEAPON_LAYER_BG:
|
||||
wlayer = wbackLayer;
|
||||
|
Loading…
Reference in New Issue
Block a user