diff --git a/src/weapon.c b/src/weapon.c index 53973ed..6461dea 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -34,6 +34,7 @@ extern void ai_attacked(Pilot* attacked, const unsigned int attacker); typedef struct Weapon_ { Solid* solid; /* Actually has its own solid. :D */ + unsigned int faction; /* Faction of pilot that shot the weapon. */ unsigned int parent; /* The pilot that just shot at you! */ unsigned int target; /* Target to hit. Only used by seeking stuff. */ const Outfit* outfit; /* Related outfit that fired. */ @@ -279,8 +280,8 @@ static void weapon_update(Weapon* w, const double dt, WeaponLayer layer) { return; } /* Dumb weapons hit anything not of the same faction. */ - else if(!weapon_isSmart(w) && - !areAllies(pilot_get(w->parent)->faction, pilot_stack[i]->faction) && + if(!weapon_isSmart(w) && + !areAllies(w->faction, pilot_stack[i]->faction) && CollideSprite(gfx, wsx, wsy, &w->solid->pos, pilot_stack[i]->ship->gfx_space, psx, psy, &pilot_stack[i]->solid->pos)) { weapon_hit(w, pilot_stack[i], layer); @@ -332,6 +333,7 @@ static Weapon* weapon_create(const Outfit* outfit, const double dir, const Vec2* double mass = 1; /* Presumer lasers have a mass of 1. */ double rdir = dir; /* Real direction (accuracy). */ Weapon* w = MALLOC_L(Weapon); + w->faction = pilot_get(parent)->faction; /*Non-Changeable. */ w->parent = parent; /* Non-Changeable. */ w->target = target; /* Non-Changeable. */ w->outfit = outfit; /* Non-Changeable. */