struct torp *t_find(struct player *me, int status) { struct torp *k = NULL; for (k = firstTorpOf(me); k <= lastTorpOf(me); k++) if (k->t_status == status) break; return k; }
/* fully heal this dude */ void smileon(struct player* j) { register struct torp *t; j->p_speed = 0; j->p_desspeed = 0; j->p_subspeed = 0; j->p_flags = PFSHIELD; j->p_fuel = j->p_ship.s_maxfuel; j->p_shield = j->p_ship.s_maxshield; j->p_damage = 0; j->p_wtemp = 0; j->p_etemp = 0; j->p_ntorp = 0; for (t = firstTorpOf(j); t <= lastTorpOf(j); t++) t->t_status = TFREE; j->p_cloakphase = 0; }
void player_bounce(void) { register int i; register struct player *j; register Track *track; register struct torp *t; Arena* a; /* avoid dead slots, me, other robots (which aren't hostile) */ for (i = 0, j = &players[i], track = &tracks[i]; i < MAXPLAYER; i++, j++, track++) { if ( (j == me) || (j->p_status!=PALIVE) ) continue; /*Don't do this for dead and for puck*/ a = &arenas[(int) track->t_arena]; /* kill torps that might distract guys in other arenas */ for (t = firstTorpOf(j); t <= lastTorpOf(j); t++) if (t->t_x < a->a_left || t->t_x > a->a_right || t->t_y < a->a_top || t->t_y > a->a_bottom) { fprintf(stderr, "here!\n"); t->t_status = TFREE; switch (t->t_type) { case TPHOTON: j->p_ntorp--; break; case TPLASMA: j->p_nplasmatorp--; break; } } p_x_y_box(j, a->a_left, a->a_top, a->a_right, a->a_bottom); } /*end for loop*/ }
/* * If a set of given conditions are met, fire a single torp in direction * course. Use different attributes * * torp->t_fuse is the life of the torpedo. It is set here based on * a random function. Torps currently live two to five seconds. */ void ntorp(u_char course, int attributes) { static LONG last_torp_fired_update = 0; struct torp *k; int c_fuel, c_etemp, c_wtemp; if (status->gameup & GU_CONQUER) return; c_fuel = getAdjTorpCost(course, TORP_ADJ_FUEL); c_etemp = getAdjTorpCost(course, TORP_ADJ_ETEMP); c_wtemp = getAdjTorpCost(course, TORP_ADJ_WTEMP); /* * Prevent player from firing more than one torp per update. */ if (me->p_updates == last_torp_fired_update) return; if (me->p_flags & PFWEP) { new_warning(25, "Torpedo launch tubes have exceeded maximum safe temperature!"); if (!chaosmode) return; } if (me->p_ntorp == MAXTORP) { new_warning(26, "Our computers limit us to having 8 live torpedos at a time captain!"); return; } if (me->p_fuel < c_fuel) { new_warning(27, "We don't have enough fuel to fire photon torpedos!"); return; } if (me->p_flags & PFREPAIR) { new_warning(28, "We cannot fire while our vessel is in repair mode."); return; } if ((me->p_cloakphase) && (me->p_ship.s_type != ATT)) { #ifdef STURGEON if (sturgeon) { if (!me->p_upgradelist[UPG_FIRECLOAK]) { new_warning(UNDEF,"We don't have the proper upgrade to fire while cloaked, captain!"); return; } if (me->p_fuel < myship->s_torpcost * 2) { new_warning(UNDEF,"We don't have enough fuel to fire photon torpedos while cloaked!"); return; } } else #endif { new_warning(29, "We are unable to fire while in cloak, captain!"); return; } } /* * If topgun mode, * Permit firing only if out of the front of the ship */ if (topgun && ((me->p_ship).s_type != STARBASE)) { int delta; if ((delta = ((int) me->p_dir - (int) course)) < 0) delta = -delta; if ((delta > topgun) && (delta < (256 - topgun))) { /* note: 128 = 180 degrees left/right */ new_warning(30, "We only have forward mounted cannons."); return; } } /* can't fire if we're etemp and firing has an etemp cost and an etemp multiplier greater than 1.0 (ASSTORP_ETEMP_MULT) */ if ((me->p_flags & PFENG) && (c_etemp > 0) && (asstorp_etemp_mult > 1.0) && ((myship->s_type != STARBASE) || asstorp_base)) { new_warning(UNDEF,"Engines have overheated rear torpedos tubes."); return; } /* * Find a free torp to use */ for (k = firstTorpOf(me); k <= lastTorpOf(me); k++) if (k->t_status == TFREE) break; #if 0 /* Pseudo code for run-time debugging, if someone wants it. */ if (k > lastTorpOf(me)) error(); #endif last_torp_fired_update = me->p_updates; /* * Change my ship state: less fuel, more weapon temp */ me->p_ntorp++; me->p_fuel -= c_fuel; me->p_wtemp += c_wtemp; me->p_etemp += c_etemp; /* * Initialize torp: */ k->t_status = TMOVE; k->t_type = TPHOTON; k->t_attribute = attributes; k->t_owner = me->p_no; t_x_y_set(k, me->p_x, me->p_y); k->t_turns = myship->s_torpturns; k->t_damage = myship->s_torpdamage; k->t_gspeed = (attributes & TVECTOR) ? torpGetVectorSpeed(me->p_dir, me->p_speed, course, myship->s_torpspeed) : myship->s_torpspeed * WARP1; k->t_fuse = (myship->s_torpfuse + (random() % 20)) * T_FUSE_SCALE; k->t_dir = course; k->t_war = me->p_war; k->t_team = me->p_team; k->t_whodet = NODET; #if 0 k->t_no = i; k->t_speed = k->t_gspeed / WARP1; #endif #ifdef STURGEON k->t_spinspeed = 0; #endif #ifdef LTD_STATS /* At this point, a torpedo was fired */ ltd_update_torp_fired(me); #endif }