diff --git a/src/pilot.h b/src/pilot.h index be6ae94..6b46843 100644 --- a/src/pilot.h +++ b/src/pilot.h @@ -6,6 +6,8 @@ #include "faction.h" #include "ship.h" +#define PLAYER_ID 0 + // Aproximation for pilot size. #define PILOT_SIZE_APROX 0.8 #define PILOT_DISABLED 0.2 // Based on armor percentage. diff --git a/src/player.h b/src/player.h index d0e812c..46a517f 100644 --- a/src/player.h +++ b/src/player.h @@ -2,8 +2,6 @@ #include <SDL.h> #include "pilot.h" -#define PLAYER_ID 0 - extern Pilot* pilot; typedef enum { KEYBIND_NULL, KEYBIND_KEYBOARD, KEYBIND_JAXIS, KEYBIND_JBUTTON } KeybindType; diff --git a/src/weapon.c b/src/weapon.c index 0a19ff8..42330f5 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -128,11 +128,12 @@ static void weapon_update(Weapon* w, const double dt, WeaponLayer layer) { CollideSprite(w->outfit->gfx_space, wsx, wsy, &w->solid->pos, pilot_stack[i]->ship->gfx_space, psx, psy, &pilot_stack[i]->solid->pos)) { - if(i != 0) { + if(i != PLAYER_ID) // Inform the ai it has been attacked. Useless if we are player. ai_attacked(pilot_stack[i], w->parent); + if(w->parent == PLAYER_ID) // Make hostile to player. pilot_setFlag(pilot_stack[i], PILOT_HOSTILE); - } + // Inform the ship that it should take some damage. pilot_hit(pilot_stack[i], w->outfit->damage_shield, w->outfit->damage_armor); // No need for the weapon particle anymore.