src/hcode/btech/artillery.c File Reference

#include <math.h>
#include "mech.h"
#include "artillery.h"
#include "mech.events.h"
#include "create.h"
#include "p.artillery.h"
#include "p.mech.fire.h"
#include "p.mech.combat.h"
#include "p.mech.combat.misc.h"
#include "p.mech.damage.h"
#include "p.mech.utils.h"
#include "p.map.obj.h"
#include "p.mech.hitloc.h"
#include "p.mine.h"
#include "spath.h"

Include dependency graph for artillery.c:

Go to the source code of this file.

Defines

#define TABLE_GEN   0
#define TABLE_PUNCH   1
#define TABLE_KICK   2

Functions

static void artillery_hit (artillery_shot *s)
static const char * artillery_type (artillery_shot *s)
static const char * artillery_direction (artillery_shot *s)
int artillery_round_flight_time (float fx, float fy, float tx, float ty)
static void artillery_hit_event (MUXEVENT *e)
void artillery_shoot (MECH *mech, int targx, int targy, int windex, int wmode, int ishit)
static int blast_arcf (float fx, float fy, MECH *mech)
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)
static void artillery_hit_hex (MAP *map, artillery_shot *s, int type, int mode, int dam, int tx, int ty, int isdirect)
static void artillery_hit_neighbors_callback (MAP *map, int x, int y)
static void artillery_hit_neighbors (MAP *map, artillery_shot *s, int type, int mode, int dam, int tx, int ty)
static void artillery_cluster_hit (MAP *map, artillery_shot *s, int type, int mode, int dam, int tx, int ty)
void artillery_FriendlyAdjustment (dbref mechnum, MAP *map, int x, int y)

Variables

artillery_shot_typefree_shot_list = NULL
struct {
   int   dir
   char *   desc
arty_dirs []
static artillery_shothit_neighbors_s
static int hit_neighbors_type
static int hit_neighbors_mode
static int hit_neighbors_dam


Define Documentation

#define TABLE_GEN   0

Definition at line 142 of file artillery.c.

Referenced by artillery_hit_hex().

#define TABLE_KICK   2

Definition at line 144 of file artillery.c.

Referenced by blast_hit_hexf().

#define TABLE_PUNCH   1

Definition at line 143 of file artillery.c.

Referenced by artillery_hit_hex(), and blast_hit_hexf().


Function Documentation

static void artillery_cluster_hit ( MAP map,
artillery_shot s,
int  type,
int  mode,
int  dam,
int  tx,
int  ty 
) [static]

Definition at line 380 of file artillery.c.

References artillery_hit_hex(), artillery_shot_type::map, Number, x, and y.

Referenced by artillery_hit().

00382 {
00383         /* Main idea: Pick <dam/2> bombs of 2pts each, and scatter 'em
00384            over 5x5 area with weighted numbers */
00385         int xd, yd, x, y;
00386         int i;
00387 
00388         int targets[5][5];
00389         int d;
00390 
00391         bzero(targets, sizeof(targets));
00392         for(i = 0; i < dam; i++) {
00393                 do {
00394                         xd = Number(-2, 0) + Number(0, 2);
00395                         yd = Number(-2, 0) + Number(0, 2);
00396                         x = tx + xd;
00397                         y = ty + yd;
00398                 }
00399                 while (x < 0 || x >= map->map_width || y < 0 || y >= map->map_height);
00400                 /* Whee.. it's time to drop a bomb to the hex */
00401                 targets[xd + 2][yd + 2]++;
00402         }
00403         for(xd = 0; xd < 5; xd++)
00404                 for(yd = 0; yd < 5; yd++)
00405                         if((d = targets[xd][yd]))
00406                                 artillery_hit_hex(map, s, type, mode, d * 2, xd + tx - 2,
00407                                                                   yd + ty - 2, 1);
00408 }

static const char* artillery_direction ( artillery_shot s  )  [static]

Definition at line 61 of file artillery.c.

References arty_dirs, dir, FindBearing(), artillery_shot_type::from_x, artillery_shot_type::from_y, MapCoordToRealCoord(), artillery_shot_type::to_x, and artillery_shot_type::to_y.

Referenced by artillery_shoot().

00062 {
00063         float fx, fy, tx, ty;
00064         int b, d, i, best = -1, bestd = 0;
00065 
00066         MapCoordToRealCoord(s->from_x, s->from_y, &fx, &fy);
00067         MapCoordToRealCoord(s->to_x, s->to_y, &tx, &ty);
00068         b = FindBearing(fx, fy, tx, ty);
00069         for(i = 0; arty_dirs[i].desc; i++) {
00070                 d = abs(b - arty_dirs[i].dir);
00071                 if(best < 0 || d < bestd) {
00072                         best = i;
00073                         bestd = d;
00074                 }
00075         }
00076         if(best < 0)
00077                 return "Invalid";
00078         return arty_dirs[best].desc;
00079 }

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 }

static void artillery_hit ( artillery_shot s  )  [static]

Definition at line 446 of file artillery.c.

References artillery_cluster_hit(), artillery_FriendlyAdjustment(), artillery_hit_hex(), artillery_hit_neighbors(), ARTILLERY_MODES, artillery_type(), BOUNDED(), CLUSTER_MODE, weapon_struct::damage, dir, getMap(), HexLOSBroadcast(), artillery_shot_type::ishit, artillery_shot_type::map, MechWeapons, MINE_MODE, artillery_shot_type::mode, name, Number, artillery_shot_type::shooter, SMOKE_MODE, artillery_shot_type::to_x, artillery_shot_type::to_y, tprintf(), TWOPIOVER360, and artillery_shot_type::type.

Referenced by artillery_hit_event().

00447 {
00448         /* First, we figure where it exactly hits. Our first-hand information
00449            is only whether it hits or not, not _where_ it hits */
00450         double dir;
00451         int di;
00452         int dist;
00453         int weight;
00454         MAP *map = getMap(s->map);
00455         int original_x = 0, original_y = 0;
00456         int dam = MechWeapons[s->type].damage;
00457 
00458         if(!map)
00459                 return;
00460         if(!s->ishit) {
00461                 /* Shit! We missed target ;-) */
00462                 /* Time to calculate a new target hex */
00463                 di = Number(0, 359);
00464                 dir = di * TWOPIOVER360;
00465                 dist = Number(2, 7);
00466                 weight = 100 * (dist * 6) / ((dist * 6 + map->windspeed));
00467                 di = (di * weight + map->winddir * (100 - weight)) / 100;
00468                 dist = (dist * weight + (map->windspeed / 6) * (100 - weight)) / 100;
00469                 original_x = s->to_x;
00470                 original_y = s->to_y;
00471                 s->to_x = s->to_x + dist * cos(dir);
00472                 s->to_y = s->to_y + dist * sin(dir);
00473                 s->to_x = BOUNDED(0, s->to_x, map->map_width - 1);
00474                 s->to_y = BOUNDED(0, s->to_y, map->map_height - 1);
00475                 /* Time to calculate if any friendlies have LOS to hex,
00476                    and if so, adjust fire adjustment unless you lack information /
00477                    have changed target */
00478         }
00479         /* It's time to run for your lives, lil' ones ;-) */
00480         if(!(s->mode & ARTILLERY_MODES))
00481                 HexLOSBroadcast(map, s->to_x, s->to_y, tprintf("%s fire hits $H!",
00482                                                                                                            &MechWeapons[s->type].
00483                                                                                                            name[3]));
00484         else if(s->mode & CLUSTER_MODE)
00485                 HexLOSBroadcast(map, s->to_x, s->to_y,
00486                                                 "A rain of small bomblets hits $H's surroundings!");
00487         else if(s->mode & MINE_MODE)
00488                 HexLOSBroadcast(map, s->to_x, s->to_y,
00489                                                 "A rain of small bomblets hits $H!");
00490         else if(s->mode & SMOKE_MODE)
00491                 HexLOSBroadcast(map, s->to_x, s->to_y,
00492                                                 tprintf
00493                                                 ("A %s %s hits $h, and smoke starts to billow!",
00494                                                  &MechWeapons[s->type].name[3],
00495                                                  &(artillery_type(s)[2])));
00496 
00497         /* Basic theory:
00498            - smoke / ordinary rounds are spread with the ordinary functions 
00499            - mines are otherwise ordinary except no hitting of neighbor hexes
00500            - cluster bombs are special 
00501          */
00502         if(!(s->mode & CLUSTER_MODE)) {
00503                 /* Enjoy ourselves in all neighbor hexes, too */
00504                 artillery_hit_hex(map, s, s->type, s->mode, dam, s->to_x, s->to_y, 1);
00505                 if(!(s->mode & MINE_MODE))
00506                         artillery_hit_neighbors(map, s, s->type, s->mode, dam / 2,
00507                                                                         s->to_x, s->to_y);
00508         } else
00509                 artillery_cluster_hit(map, s, s->type, s->mode, dam, s->to_x,
00510                                                           s->to_y);
00511         if(!s->ishit)
00512                 artillery_FriendlyAdjustment(s->shooter, map, original_x, original_y);
00513 }

static void artillery_hit_event ( MUXEVENT e  )  [static]

Definition at line 90 of file artillery.c.

References ADD_TO_LIST_HEAD, artillery_hit(), my_event_type::data, and free_shot_list.

Referenced by artillery_shoot().

00091 {
00092         artillery_shot *s = (artillery_shot *) e->data;
00093 
00094         artillery_hit(s);
00095         ADD_TO_LIST_HEAD(free_shot_list, next, s);
00096 }

static void artillery_hit_hex ( MAP map,
artillery_shot s,
int  type,
int  mode,
int  dam,
int  tx,
int  ty,
int  isdirect 
) [static]

Definition at line 316 of file artillery.c.

References add_decoration(), add_mine(), blast_hit_hex(), CLUSTER_MODE, LBUF_SIZE, artillery_shot_type::map, MINE_MODE, SMOKE, SMOKE_DURATION, SMOKE_MODE, TABLE_GEN, TABLE_PUNCH, and TYPE_SMOKE.

Referenced by artillery_cluster_hit(), artillery_hit(), and artillery_hit_neighbors_callback().

00318 {
00319         char buf[LBUF_SIZE];
00320         char buf1[LBUF_SIZE];
00321         char buf2[LBUF_SIZE];
00322 
00323         /* Safety check -- shouldn't happen */
00324         if(tx < 0 || tx >= map->map_width || ty < 0 || ty >= map->map_height)
00325                 return;
00326 
00327         if((mode & SMOKE_MODE)) {
00328                 /* Add smoke */
00329                 add_decoration(map, tx, ty, TYPE_SMOKE, SMOKE, SMOKE_DURATION);
00330                 return;
00331         }
00332         if(mode & MINE_MODE) {
00333                 add_mine(map, tx, ty, dam);
00334                 return;
00335         }
00336         if(!(mode & CLUSTER_MODE)) {
00337                 if(isdirect)
00338                         sprintf(buf1, "receives a direct hit!");
00339                 else
00340                         sprintf(buf1, "is hit by fragments!");
00341                 if(isdirect)
00342                         sprintf(buf2, "You receive a direct hit!");
00343                 else
00344                         sprintf(buf2, "You are hit by fragments!");
00345         } else {
00346                 if(dam > 2)
00347                         strcpy(buf, "bomblets");
00348                 else
00349                         strcpy(buf, "a bomblet");
00350                 sprintf(buf1, "is hit by %s!", buf);
00351                 sprintf(buf2, "You are hit by %s!", buf);
00352         }
00353         blast_hit_hex(map, dam, (mode & CLUSTER_MODE) ? 2 : 5, 0, tx, ty, tx,
00354                                   ty, buf2, buf1,
00355                                   (mode & CLUSTER_MODE) ? TABLE_PUNCH : TABLE_GEN, 10, 4, 0);
00356 }

static void artillery_hit_neighbors ( MAP map,
artillery_shot s,
int  type,
int  mode,
int  dam,
int  tx,
int  ty 
) [static]

Definition at line 369 of file artillery.c.

References artillery_hit_neighbors_callback(), hit_neighbors_dam, hit_neighbors_mode, hit_neighbors_s, hit_neighbors_type, artillery_shot_type::map, and visit_neighbor_hexes().

Referenced by artillery_hit().

00372 {
00373         hit_neighbors_s = s;
00374         hit_neighbors_type = type;
00375         hit_neighbors_mode = mode;
00376         hit_neighbors_dam = dam;
00377         visit_neighbor_hexes(map, tx, ty, artillery_hit_neighbors_callback);
00378 }

static void artillery_hit_neighbors_callback ( MAP map,
int  x,
int  y 
) [static]

Definition at line 363 of file artillery.c.

References artillery_hit_hex(), hit_neighbors_dam, hit_neighbors_mode, hit_neighbors_s, hit_neighbors_type, and artillery_shot_type::map.

Referenced by artillery_hit_neighbors().

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 }

static const char* artillery_type ( artillery_shot s  )  [static]

Definition at line 38 of file artillery.c.

References CL_ARROW, IS_ARROW, and artillery_shot_type::type.

Referenced by artillery_hit(), and artillery_shoot().

00039 {
00040         if(s->type == CL_ARROW || s->type == IS_ARROW)
00041                 return "a missile";
00042         return "a round";
00043 }

static int blast_arcf ( float  fx,
float  fy,
MECH mech 
) [static]

Definition at line 127 of file artillery.c.

References AcceptableDegree(), BACK, dir, FindBearing(), FRONT, LEFTSIDE, MechFacing, MechFX, MechFY, and RIGHTSIDE.

Referenced by blast_hit_hexf().

00128 {
00129         int b, dir;
00130 
00131         b = FindBearing(MechFX(mech), MechFY(mech), fx, fy);
00132         dir = AcceptableDegree(b - MechFacing(mech));
00133         if(dir > 120 && dir < 240)
00134                 return BACK;
00135         if(dir > 300 || dir < 60)
00136                 return FRONT;
00137         if(dir > 180)
00138                 return LEFTSIDE;
00139         return RIGHTSIDE;
00140 }

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 }


Variable Documentation

struct { ... } arty_dirs[] [static]

Referenced by artillery_direction().

char* desc

Definition at line 47 of file artillery.c.

Referenced by do_malias_create(), network_accept_client(), network_choke_socket(), network_initialize_socket(), and network_release_socket().

int dir

Definition at line 46 of file artillery.c.

Referenced by artillery_direction(), artillery_hit(), blast_arcf(), bomb_drop(), do_charstatus(), do_process_macro(), get_channel_from_alias(), scan_template_dir(), select_user(), and sketch_tac_mechs().

struct artillery_shot_type* free_shot_list = NULL

Definition at line 35 of file artillery.c.

Referenced by artillery_hit_event(), and artillery_shoot().

int hit_neighbors_dam [static]

Definition at line 361 of file artillery.c.

Referenced by artillery_hit_neighbors(), and artillery_hit_neighbors_callback().

int hit_neighbors_mode [static]

Definition at line 360 of file artillery.c.

Referenced by artillery_hit_neighbors(), and artillery_hit_neighbors_callback().

artillery_shot* hit_neighbors_s [static]

Definition at line 358 of file artillery.c.

Referenced by artillery_hit_neighbors(), and artillery_hit_neighbors_callback().

int hit_neighbors_type [static]

Definition at line 359 of file artillery.c.

Referenced by artillery_hit_neighbors(), and artillery_hit_neighbors_callback().


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