static void preFireMissile(void) { if (player->missiles && player->target) { if (getDistance(player->x, player->y, player->target->x, player->target->y) <= SCREEN_WIDTH) { fireMissile(player); } else { playSound(SND_GUI_DENIED); addHudMessage(colors.white, _("Target not in range")); } } else if (!player->missiles) { addHudMessage(colors.white, _("Out of missiles")); playSound(SND_NO_MISSILES); } }
void doPlayer(void) { self = player; rechargeBoostECM(); if (game.currentMission->challengeData.isChallenge) { applyRestrictions(); } if (player->alive == ALIVE_ALIVE && player->systemPower > 0) { handleKeyboard(); handleMouse(); handleSuspicionLevel(); if (!player->target || player->target->health <= 0 || player->target->systemPower <= 0 || targetOutOfRange()) { selectTarget(); } } player->angle = ((int)player->angle) % 360; if (player->health <= 0 && battle.status == MS_IN_PROGRESS) { if (game.currentMission->challengeData.isChallenge) { if (!game.currentMission->challengeData.allowPlayerDeath) { updateDeathStats(); failMission(); } } else if (!battle.isEpic) { updateDeathStats(); failMission(); } else if (player->health == -FPS) { updateDeathStats(); updateCondition("PLAYER", TT_DESTROY); if (battle.status == MS_IN_PROGRESS) { initPlayerSelect(); } } } if (battle.status == MS_IN_PROGRESS) { selectMissionTarget(); } if (dev.playerUnlimitedMissiles) { player->missiles = 999; } /* really only used in challenge mode */ if (player->systemPower <= 0 && battle.status == MS_IN_PROGRESS) { if (game.currentMission->challengeData.isChallenge) { addHudMessage(colors.red, _("Challenge Failed!")); failMission(); } } if (battle.boostTimer == (int)BOOST_FINISHED_TIME) { deactivateBoost(); } }
void doFighter(void) { if (self->alive == ALIVE_ALIVE) { if (self != player) { separate(); } if (!(self->flags & EF_DISABLED)) { attachRope(); } if (self->thrust > 0.25) { addEngineEffect(); } if (self->health <= 0) { self->health = 0; self->alive = ALIVE_DYING; self->die(); if (self == battle.missionTarget) { battle.missionTarget = NULL; } } else if (self->systemPower <= 0 || (self->flags & EF_DISABLED)) { self->dx *= 0.99; self->dy *= 0.99; self->thrust = 0; self->shield = self->maxShield = 0; self->action = NULL; if ((self->flags & EF_DISABLED) == 0) { playBattleSound(SND_POWER_DOWN, self->x, self->y); self->flags |= EF_DISABLED; self->flags |= EF_SECONDARY_TARGET; if (self->aiFlags & AIF_SURRENDERING) { self->aiFlags |= AIF_SURRENDERED; self->aiFlags &= ~AIF_SURRENDERING; } battle.stats[STAT_ENEMIES_DISABLED]++; updateObjective(self->name, TT_DISABLE); updateObjective(self->groupName, TT_DISABLE); if (self->side != player->side) { runScriptFunction("ENEMIES_DISABLED %d", battle.stats[STAT_ENEMIES_DISABLED]); } } } if (self->target != NULL && self->target->alive != ALIVE_ALIVE) { self->target = NULL; if (self != player) { self->action = doAI; } } if (self->aiFlags & AIF_SUSPICIOUS) { checkSuspicionLevel(); } if (self->aiFlags & AIF_ZAK_SUSPICIOUS) { checkZackariaSuspicionLevel(); } } if (self->alive == ALIVE_ESCAPED) { if (self == player && !game.currentMission->challengeData.isChallenge) { updateObjective("Player", TT_ESCAPED); completeMission(); } if (self->side != player->side && (!(self->flags & EF_DISABLED))) { addHudMessage(colors.red, _("Mission target has escaped.")); battle.stats[STAT_ENEMIES_ESCAPED]++; } if (strcmp(self->defName, "Civilian") == 0) { battle.stats[STAT_CIVILIANS_RESCUED]++; } /* if you did not escape under your own volition, or with the aid of a friend, you've been stolen */ if (!self->owner || self->side == self->owner->side) { updateObjective(self->name, TT_ESCAPED); updateCondition(self->name, TT_ESCAPED); } else { updateObjective(self->name, TT_STOLEN); updateCondition(self->name, TT_STOLEN); } } if (self->alive == ALIVE_DEAD) { if (player->alive == ALIVE_ALIVE && self != player) { if (self->side != player->side) { if (!(self->flags & EF_NO_KILL_INC)) { battle.stats[STAT_ENEMIES_KILLED]++; runScriptFunction("ENEMIES_KILLED %d", battle.stats[STAT_ENEMIES_KILLED]); } } else { if (strcmp(self->name, "Civilian") == 0) { battle.stats[STAT_CIVILIANS_KILLED]++; if (!battle.isEpic || game.currentMission->challengeData.isChallenge) { addHudMessage(colors.red, _("Civilian has been killed")); } runScriptFunction("CIVILIANS_KILLED %d", battle.stats[STAT_CIVILIANS_KILLED]); } else { battle.stats[STAT_ALLIES_KILLED]++; if (!battle.isEpic && !game.currentMission->challengeData.isChallenge) { addHudMessage(colors.red, _("Ally has been killed")); } runScriptFunction("ALLIES_KILLED %d", battle.stats[STAT_ALLIES_KILLED]); } } updateObjective(self->name, TT_DESTROY); updateObjective(self->groupName, TT_DESTROY); if (battle.isEpic && self->killedBy == player) { updateObjective("EPIC_PLAYER_KILLS", TT_DESTROY); } adjustObjectiveTargetValue(self->name, TT_ESCAPED, -1); updateCondition(self->name, TT_DESTROY); updateCondition(self->groupName, TT_DESTROY); /* don't fire if the opposing side is responsible */ if (self->aiFlags & AIF_SURRENDERED && self->killedBy->side == player->side) { updateCondition("SURRENDERED", TT_DESTROY); } } } }