/************************************************************** * 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); }
int main (int argc, char **argv) { register int c; int errflg; int function; u_short portnum; #ifndef __MINT__ setlocale (LC_ALL, ""); textdomain (_libc_intl_domainname); #endif function = NONE; portnum = 0; errflg = 0; while ((c = getopt (argc, argv, "ptubdn:")) != -1) { switch (c) { case 'p': if (function != NONE) errflg = 1; else function = PMAPDUMP; break; case 't': if (function != NONE) errflg = 1; else function = TCPPING; break; case 'u': if (function != NONE) errflg = 1; else function = UDPPING; break; case 'b': if (function != NONE) errflg = 1; else function = BRDCST; break; case 'n': portnum = (u_short) atoi (optarg); /* hope we don't get bogus # */ break; case 'd': if (function != NONE) errflg = 1; else function = DELETES; break; case '?': errflg = 1; } } if (errflg || function == NONE) { usage (); return 1; } switch (function) { case PMAPDUMP: if (portnum != 0) { usage (); return 1; } pmapdump (argc - optind, argv + optind); break; case UDPPING: udpping (portnum, argc - optind, argv + optind); break; case TCPPING: tcpping (portnum, argc - optind, argv + optind); break; case BRDCST: if (portnum != 0) { usage (); return 1; } brdcst (argc - optind, argv + optind); break; case DELETES: deletereg (argc - optind, argv + optind); break; } return 0; }
int main (int argc, char **argv) { register int c; int errflg; int function; u_short portnum; static const struct option long_options[] = { { "help", no_argument, NULL, 'H' }, { "version", no_argument, NULL, 'V' }, { NULL, 0, NULL, 0 } }; setlocale (LC_ALL, ""); textdomain (_libc_intl_domainname); function = NONE; portnum = 0; errflg = 0; while ((c = getopt_long (argc, argv, "ptubdn:", long_options, NULL)) != -1) { switch (c) { case 'p': if (function != NONE) errflg = 1; else function = PMAPDUMP; break; case 't': if (function != NONE) errflg = 1; else function = TCPPING; break; case 'u': if (function != NONE) errflg = 1; else function = UDPPING; break; case 'b': if (function != NONE) errflg = 1; else function = BRDCST; break; case 'n': portnum = (u_short) atoi (optarg); /* hope we don't get bogus # */ break; case 'd': if (function != NONE) errflg = 1; else function = DELETES; break; case 'H': usage (stdout); return 0; case 'V': print_version (); return 0; case '?': errflg = 1; } } if (errflg || function == NONE) { usage (stderr); return 1; } switch (function) { case PMAPDUMP: if (portnum != 0) { usage (stderr); return 1; } pmapdump (argc - optind, argv + optind); break; case UDPPING: udpping (portnum, argc - optind, argv + optind); break; case TCPPING: tcpping (portnum, argc - optind, argv + optind); break; case BRDCST: if (portnum != 0) { usage (stderr); return 1; } brdcst (argc - optind, argv + optind); break; case DELETES: deletereg (argc - optind, argv + optind); break; } return 0; }
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; } }
int main(int argc, char **argv) { register int c; extern char *optarg; extern int optind; int errflg; int function; u_short portnum; function = NONE; portnum = 0; errflg = 0; while ((c = getopt(argc, argv, "ptubdn:")) != -1) { switch (c) { case 'p': if (function != NONE) errflg = 1; else function = PMAPDUMP; break; case 't': if (function != NONE) errflg = 1; else function = TCPPING; break; case 'u': if (function != NONE) errflg = 1; else function = UDPPING; break; case 'b': if (function != NONE) errflg = 1; else function = BRDCST; break; case 'n': portnum = (u_short) atoi(optarg); /* hope we don't get bogus # */ break; case 'd': if (function != NONE) errflg = 1; else function = DELETES; break; case '?': errflg = 1; } } if (errflg || function == NONE) { usage(); return (1); } switch (function) { case PMAPDUMP: if (portnum != 0) { usage(); return (1); } pmapdump(argc - optind, argv + optind); break; case UDPPING: udpping(portnum, argc - optind, argv + optind); break; case TCPPING: tcpping(portnum, argc - optind, argv + optind); break; case BRDCST: if (portnum != 0) { usage(); return (1); } brdcst(argc - optind, argv + optind); break; case DELETES: deletereg(argc - optind, argv + optind); break; } return (0); }