/************************************************************** * Take a good hard look at how much punishment we've taken, * * and get out if it's just too much to take! * **************************************************************/ int Pilot::damage_check() { if (flight->mods.battle_damage > 0) { if (flight->mods.battle_damage >= flight->specs->max_damage) { if (functioning) { broadcast("Ejecting!",6,getAffiliation(),NULL); sound_off("takingfire"); sound_off("takingflak"); sound_off("heavydamage"); sound_on("eject",getAffiliation()); dbg = "EJECT"; functioning = 0; set_target(NULL); SetDeath(1); } return (1); } else { if (flight->mods.battle_damage > new_damage) { new_damage = flight->mods.battle_damage; float d1 = ((float)new_damage) / ((float)flight->specs->max_damage); if (target_obj->who_got_me != NULL && target_obj->who_got_me->getType() == GROUND_UNIT_T) { brdcst(sbrPRIORITY_REGULAR,getAffiliation(),"Taking flak: %3.0f%%%%",d1 * 100.0); sound_on("takingflak",getAffiliation()); } else { if (d1 >= 0.75) { brdcst(sbrPRIORITY_REGULAR,getAffiliation(),"Heavy damage: %3.0f%%%%!",d1 * 100.0); sound_on("heavydamage",getAffiliation()); } else { brdcst(sbrPRIORITY_REGULAR,getAffiliation(),"Taking fire %3.0f%%%%",d1 * 100.0); sound_on("takingfire",getAffiliation()); } } } } } return (0); }
bool set_sound(bool ison) { if(!sound_on() && ison) { preferences::set("sound", true); if(!music_on() && !turn_bell() && !UI_sound_on()) { if(!sound::init_sound()) { preferences::set("sound", false); return false; } } } else if(sound_on() && !ison) { preferences::set("sound", false); sound::stop_sound(); if(!music_on() && !turn_bell() && !UI_sound_on()) sound::close_sound(); } return true; }
bool set_UI_sound(bool ison) { if(!UI_sound_on() && ison) { preferences::set("UI_sound", "yes"); if(!music_on() && !sound_on() && !turn_bell()) { if(!sound::init_sound()) { preferences::set("UI_sound", "no"); return false; } } } else if(UI_sound_on() && !ison) { preferences::set("UI_sound", "no"); sound::stop_UI_sound(); if(!music_on() && !sound_on() && !turn_bell()) sound::close_sound(); } return true; }
bool set_music(bool ison) { if(!music_on() && ison) { preferences::set("music", true); if(!sound_on() && !turn_bell() && !UI_sound_on()) { if(!sound::init_sound()) { preferences::set("music", false); return false; } } else sound::play_music(); } else if(music_on() && !ison) { preferences::set("music", false); if(!sound_on() && !turn_bell() && !UI_sound_on()) sound::close_sound(); else sound::stop_music(); } return true; }
void Pilot::Shoot() { selWeapon(0); if (InShootParams()) { flight->controls.bang_bang = 1; broadcast("Guns! Guns!",1,getAffiliation(),NULL); /* * Don't yack up the "gunsguns" sound too much */ if (gunsGunsSoundTime <= 0.0) { sound_on("gunsguns",getAffiliation()); gunsGunsSoundTime = sRandPer() * GUNSGUNSPAUSE + 0.2; } } }
void Pilot::Broadcast(int idx, int channel, int priority, void *extraInfo) { int priorityValue; int affil; switch (priority) { case commPRIORITY_STANDARD: default: priorityValue = sbrPRIORITY_REGULAR; break; case commPRIORITY_LOW: priorityValue = sbrPRIORITY_LOW; break; case commPRIORITY_HIGH: priorityValue = sbrPRIORITY_HIGH; break; } switch (channel) { case commCHANNEL_AFFILIATION: case commCHANNEL_SQUAD: default: affil = GetAffiliation(); break; case commCHANNEL_ALL: affil = -1; break; } switch (idx) { case commWINGMAN_KILL: { aiPilot *targetPilot = (aiPilot *)extraInfo; if (targetPilot) { brdcst(priorityValue,affil,"Kill on %s @ Angels %d", targetPilot->GetModel(), (int) ANGELS(targetPilot)); Flight *targetFlight = ((Pilot *)targetPilot)->get_flight(); sound_on(buildSoundId("kill",targetFlight),affil); } } break; case commWINGMAN_ENGAGING: { aiPilot *targetPilot = (aiPilot *)extraInfo; if (targetPilot) { brdcst(priorityValue,affil,"Engaging %s @ Angels %d", targetPilot->GetModel(), (int) ANGELS(targetPilot)); Flight *targetFlight = ((Pilot *)targetPilot)->get_flight(); sound_on(buildSoundId("engage",targetFlight),affil); } } break; } }