src/hcode/btech/p.artillery.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int artillery_round_flight_time (float fx, float fy, float tx, float ty)
void artillery_shoot (MECH *mech, int targx, int targy, int windex, int wmode, int ishit)
void blast_hit_hexf (MAP *map, int dam, int singlehitsize, int heatdam, float fx, float fy, float tfx, float tfy, char *tomsg, char *otmsg, int table, int safeup, int safedown, int isunderwater)
void blast_hit_hex (MAP *map, int dam, int singlehitsize, int heatdam, int fx, int fy, int tx, int ty, char *tomsg, char *otmsg, int table, int safeup, int safedown, int isunderwater)
void blast_hit_hexesf (MAP *map, int dam, int singlehitsize, int heatdam, float fx, float fy, float ftx, float fty, char *tomsg, char *otmsg, char *tomsg1, char *otmsg1, int table, int safeup, int safedown, int isunderwater, int doneighbors)
void blast_hit_hexes (MAP *map, int dam, int singlehitsize, int heatdam, int tx, int ty, char *tomsg, char *otmsg, char *tomsg1, char *otmsg1, int table, int safeup, int safedown, int isunderwater, int doneighbors)
void artillery_FriendlyAdjustment (dbref mechnum, MAP *map, int x, int y)


Function Documentation

void artillery_FriendlyAdjustment ( dbref  mechnum,
MAP map,
int  x,
int  y 
)

Definition at line 410 of file artillery.c.

References find_mech_in_hex(), getMech(), GetMechToMechID(), artillery_shot_type::map, mech_printf(), MechFireAdjustment, MechSeesHex(), MechSpotter, MECHSTARTED, MechTargX, MechTargY, and Started.

Referenced by artillery_hit().

00411 {
00412         MECH *mech;
00413         MECH *spotter;
00414         MECH *tempMech = NULL;
00415 
00416         if(!(mech = getMech(mechnum)))
00417                 return;
00418         /* Ok.. we've a valid guy */
00419         spotter = getMech(MechSpotter(mech));
00420         if(!((MechTargX(mech) == x && MechTargY(mech) == y)
00421                  || (spotter && (MechTargX(spotter) == x &&
00422                                                  MechTargY(spotter) == y))))
00423                 return;
00424         /* Ok.. we've a valid target to adjust fire on */
00425         /* Now, see if we've any friendlies in LOS.. NOTE: FRIENDLIES ;-) */
00426         if(spotter) {
00427                 if(MechSeesHex(spotter, map, x, y))
00428                         tempMech = spotter;
00429         } else
00430                 tempMech = find_mech_in_hex(mech, map, x, y, 2);
00431         if(!tempMech)
00432                 return;
00433         if(!Started(tempMech) || !Started(mech))
00434                 return;
00435         if(spotter) {
00436                 mech_printf(mech, MECHSTARTED,
00437                                         "%s sent you some trajectory-correction data.",
00438                                         GetMechToMechID(mech, tempMech));
00439                 mech_printf(tempMech, MECHSTARTED,
00440                                         "You provide %s with information about the miss.",
00441                                         GetMechToMechID(tempMech, mech));
00442         }
00443         MechFireAdjustment(mech)++;
00444 }

int artillery_round_flight_time ( float  fx,
float  fy,
float  tx,
float  ty 
)

Definition at line 81 of file artillery.c.

References ARTILLERY_MINIMUM_FLIGHT, ARTY_SPEED, FindHexRange(), and MAX.

Referenced by artillery_shoot(), and mech_snipe_func().

00082 {
00083         int delay = MAX(ARTILLERY_MINIMUM_FLIGHT,
00084                                         (FindHexRange(fx, fy, tx, ty) / ARTY_SPEED));
00085 
00086         /* XXX Different weapons, diff. speed? */
00087         return delay;
00088 }

void artillery_shoot ( MECH mech,
int  targx,
int  targy,
int  windex,
int  wmode,
int  ishit 
)

Definition at line 98 of file artillery.c.

References artillery_direction(), artillery_hit_event(), artillery_round_flight_time(), artillery_type(), Create, EVENT_DHIT, free_shot_list, artillery_shot_type::from_x, artillery_shot_type::from_y, artillery_shot_type::ishit, artillery_shot_type::map, MapCoordToRealCoord(), MECH::mapindex, MechLOSBroadcast(), MechX, MechY, artillery_shot_type::mode, muxevent_add(), MECH::mynum, artillery_shot_type::next, artillery_shot_type::shooter, artillery_shot_type::to_x, artillery_shot_type::to_y, tprintf(), and artillery_shot_type::type.

00100 {
00101         struct artillery_shot_type *s;
00102         float fx, fy, tx, ty;
00103 
00104         if(free_shot_list) {
00105                 s = free_shot_list;
00106                 free_shot_list = free_shot_list->next;
00107         } else
00108                 Create(s, artillery_shot, 1);
00109         s->from_x = MechX(mech);
00110         s->from_y = MechY(mech);
00111         s->to_x = targx;
00112         s->to_y = targy;
00113         s->type = windex;
00114         s->mode = wmode;
00115         s->ishit = ishit;
00116         s->shooter = mech->mynum;
00117         s->map = mech->mapindex;
00118         MechLOSBroadcast(mech, tprintf("shoots %s towards %s!",
00119                                                                    artillery_type(s),
00120                                                                    artillery_direction(s)));
00121         MapCoordToRealCoord(s->from_x, s->from_y, &fx, &fy);
00122         MapCoordToRealCoord(s->to_x, s->to_y, &tx, &ty);
00123         muxevent_add(artillery_round_flight_time(fx, fy, tx, ty), 0, EVENT_DHIT,
00124                                  artillery_hit_event, (void *) s, NULL);
00125 }

void blast_hit_hex ( MAP map,
int  dam,
int  singlehitsize,
int  heatdam,
int  fx,
int  fy,
int  tx,
int  ty,
char *  tomsg,
char *  otmsg,
int  table,
int  safeup,
int  safedown,
int  isunderwater 
)

Definition at line 230 of file artillery.c.

References blast_hit_hexf(), artillery_shot_type::map, and MapCoordToRealCoord().

Referenced by artillery_hit_hex().

00233 {
00234         float ftx, fty;
00235         float ffx, ffy;
00236 
00237         MapCoordToRealCoord(tx, ty, &ftx, &fty);
00238         MapCoordToRealCoord(fx, fy, &ffx, &ffy);
00239         blast_hit_hexf(map, dam, singlehitsize, heatdam, ffx, ffy, ftx, fty,
00240                                    tomsg, otmsg, table, safeup, safedown, isunderwater);
00241 }

void blast_hit_hexes ( MAP map,
int  dam,
int  singlehitsize,
int  heatdam,
int  tx,
int  ty,
char *  tomsg,
char *  otmsg,
char *  tomsg1,
char *  otmsg1,
int  table,
int  safeup,
int  safedown,
int  isunderwater,
int  doneighbors 
)

Definition at line 303 of file artillery.c.

References blast_hit_hexesf(), artillery_shot_type::map, and MapCoordToRealCoord().

Referenced by bomb_hit_hexes(), and mine_damage_mechs().

00307 {
00308         float fx, fy;
00309 
00310         MapCoordToRealCoord(tx, ty, &fx, &fy);
00311         blast_hit_hexesf(map, dam, singlehitsize, heatdam, fx, fy, fx, fy,
00312                                          tomsg, otmsg, tomsg1, otmsg1, table, safeup, safedown,
00313                                          isunderwater, doneighbors);
00314 }

void blast_hit_hexesf ( MAP map,
int  dam,
int  singlehitsize,
int  heatdam,
float  fx,
float  fy,
float  ftx,
float  fty,
char *  tomsg,
char *  otmsg,
char *  tomsg1,
char *  otmsg1,
int  table,
int  safeup,
int  safedown,
int  isunderwater,
int  doneighbors 
)

Definition at line 243 of file artillery.c.

References add_decoration(), blast_hit_hexf(), BOUNDED(), find_decorations(), FindXYRange(), FIRE, FIRE_DURATION, GetRTerrain, HEAVY_FOREST, LIGHT_FOREST, artillery_shot_type::map, MapCoordToRealCoord(), MAX, MyHexDist(), RealCoordToMapCoord(), and TYPE_FIRE.

Referenced by blast_hit_hexes(), DS_BlastNearbyMechsAndTrees(), and reactor_explosion().

00248 {
00249         int x1, y1, x2, y2;
00250         int dm;
00251         short tx, ty;
00252         float hx, hy;
00253         float t = FindXYRange(fx, fy, ftx, fty);
00254 
00255         dm = MAX(1, (int) t + 1);
00256         blast_hit_hexf(map, dam / dm, singlehitsize, heatdam / dm, fx, fy, ftx,
00257                                    fty, tomsg, otmsg, table, safeup, safedown, isunderwater);
00258         if(!doneighbors)
00259                 return;
00260         RealCoordToMapCoord(&tx, &ty, fx, fy);
00261         for(x1 = (tx - doneighbors); x1 <= (tx + doneighbors); x1++)
00262                 for(y1 = (ty - doneighbors); y1 <= (ty + doneighbors); y1++) {
00263                         int spot;
00264 
00265                         if((dm = MyHexDist(tx, ty, x1, y1, 0)) > doneighbors)
00266                                 continue;
00267                         if((tx == x1) && (ty == y1))
00268                                 continue;
00269                         x2 = BOUNDED(0, x1, map->map_width - 1);
00270                         y2 = BOUNDED(0, y1, map->map_height - 1);
00271                         if(x1 != x2 || y1 != y2)
00272                                 continue;
00273                         spot = (x1 == tx && y1 == ty);
00274                         MapCoordToRealCoord(x1, y1, &hx, &hy);
00275                         dm++;
00276                         if(!(dam / dm))
00277                                 continue;
00278                         blast_hit_hexf(map, dam / dm, singlehitsize, heatdam / dm, hx,
00279                                                    hy, ftx, fty, spot ? tomsg : tomsg1,
00280                                                    spot ? otmsg : otmsg1, table, safeup, safedown,
00281                                                    isunderwater);
00282 
00283                         /*
00284                          * Added in burning woods when a mech's engine goes nova
00285                          *
00286                          * -Kipsta
00287                          * 8/4/99
00288                          */
00289 
00290                         switch (GetRTerrain(map, x1, y1)) {
00291                         case LIGHT_FOREST:
00292                         case HEAVY_FOREST:
00293                                 if(!find_decorations(map, x1, y1)) {
00294                                         add_decoration(map, x1, y1, TYPE_FIRE, FIRE,
00295                                                                    FIRE_DURATION);
00296                                 }
00297 
00298                                 break;
00299                         }
00300                 }
00301 }

void blast_hit_hexf ( MAP map,
int  dam,
int  singlehitsize,
int  heatdam,
float  fx,
float  fy,
float  tfx,
float  tfy,
char *  tomsg,
char *  otmsg,
int  table,
int  safeup,
int  safedown,
int  isunderwater 
)

Definition at line 146 of file artillery.c.

References BACK, blast_arcf(), CLASS_MECH, DamageMech(), Elevation, FindHitLocation(), FindKickLocation(), FindObjectsData(), FindPunchLocation(), heat_effect(), artillery_shot_type::map, MAX, mech_notify(), MECHALL, MechLOSBroadcast(), MechType, MechX, MechY, MechZ, RealCoordToMapCoord(), TABLE_KICK, and TABLE_PUNCH.

Referenced by blast_hit_hex(), and blast_hit_hexesf().

00150 {
00151         MECH *tempMech;
00152         int loop;
00153         int isrear = 0, iscritical = 0, hitloc;
00154         int damleft, arc, ndam;
00155         int ground_zero;
00156         short tx, ty;
00157 
00158         /* Not on a map so just return */
00159         if(!map)
00160                 return;
00161 
00162         RealCoordToMapCoord(&tx, &ty, fx, fy);
00163         if(tx < 0 || ty < 0 || tx >= map->map_width || ty >= map->map_height)
00164                 return;
00165         if(!tomsg || !otmsg)
00166                 return;
00167         if(isunderwater)
00168                 ground_zero = Elevation(map, tx, ty);
00169         else
00170                 ground_zero = MAX(0, Elevation(map, tx, ty));
00171 
00172         for(loop = 0; loop < map->first_free; loop++)
00173                 if(map->mechsOnMap[loop] >= 0) {
00174                         tempMech = (MECH *)
00175                                 FindObjectsData(map->mechsOnMap[loop]);
00176                         if(!tempMech)
00177                                 continue;
00178                         if(MechX(tempMech) != tx || MechY(tempMech) != ty)
00179                                 continue;
00180                         /* Far too high.. */
00181                         if(MechZ(tempMech) >= (safeup + ground_zero))
00182                                 continue;
00183                         /* Far too below (underwater, mostly) */
00184                         if(                                     /* MechTerrain(tempMech) == WATER &&  */
00185                                   MechZ(tempMech) <= (ground_zero - safedown))
00186                                 continue;
00187                         MechLOSBroadcast(tempMech, otmsg);
00188                         mech_notify(tempMech, MECHALL, tomsg);
00189                         arc = blast_arcf(tfx, tfy, tempMech);
00190 
00191                         if(arc == BACK)
00192                                 isrear = 1;
00193                         damleft = dam;
00194 
00195                         while (damleft > 0) {
00196                                 if(singlehitsize <= damleft)
00197                                         ndam = singlehitsize;
00198                                 else
00199                                         ndam = damleft;
00200 
00201                                 damleft -= ndam;
00202 
00203                                 switch (table) {
00204                                 case TABLE_PUNCH:
00205                     if (MechType(tempMech) != CLASS_MECH) {
00206                         hitloc = FindHitLocation(tempMech, arc, &iscritical, &isrear);
00207                     } else {
00208                         hitloc = FindPunchLocation(tempMech, arc);
00209                     }
00210                                         break;
00211                                 case TABLE_KICK:
00212                     if (MechType(tempMech) != CLASS_MECH) {
00213                         hitloc = FindHitLocation(tempMech, arc, &iscritical, &isrear);
00214                     } else {
00215                         hitloc = FindKickLocation(tempMech, arc);
00216                     }
00217                                         break;
00218                                 default:
00219                                         hitloc =
00220                                                 FindHitLocation(tempMech, arc, &iscritical, &isrear);
00221                                 }
00222 
00223                                 DamageMech(tempMech, tempMech, 0, -1, hitloc, isrear,
00224                                                    iscritical, ndam, 0, -1, 0, -1, 0, 0);
00225                         }
00226                         heat_effect(NULL, tempMech, heatdam, 0);
00227                 }
00228 }


Generated on Mon May 28 04:25:39 2007 for BattletechMUX by  doxygen 1.4.7