src/hcode/btech/pcombat.c File Reference

#include "mech.h"

Include dependency graph for pcombat.c:

Go to the source code of this file.

Functions

int pc_to_dam_conversion (MECH *target, int weapindx, int dam)
int dam_to_pc_conversion (MECH *target, int weapindx, int dam)
static int pcombat_hitloc (int loc)
int armor_effect (MECH *wounded, int cause, int hitloc, int intDamage, int id)

Variables

struct {
   char *   name
   int   loc
   int   loci
   int   deft
   int   defmin
   int   defpros
   int   defmax
Armors []


Function Documentation

int armor_effect ( MECH wounded,
int  cause,
int  hitloc,
int  intDamage,
int  id 
)

Definition at line 83 of file pcombat.c.

References Armors, BOUNDED(), CLASS_MW, defmax, defmin, defpros, deft, GetSectArmor, loc, loci, mech_printf(), MECHALL, MechType, MechWeapons, name, Number, PCOMBAT, and pcombat_hitloc().

00084 {
00085         int i;
00086         int block;
00087         int noblock = 0;
00088 
00089         if(id != -2)
00090                 intDamage = (intDamage * Number(75, 125)) / 100;
00091         if(MechType(wounded) != CLASS_MW)
00092                 return intDamage;
00093         hitloc = pcombat_hitloc(hitloc);
00094         if(!GetSectArmor(wounded, hitloc))
00095                 return intDamage;
00096         for(i = 0; Armors[i].name; i++)
00097                 if(Armors[i].loc == hitloc &&
00098                    Armors[i].loci == GetSectArmor(wounded, hitloc))
00099                         break;
00100         if(Number(1, 5) == 1) {
00101                 if(Number(1, 2) == 1)
00102                         intDamage = intDamage * 2;
00103                 else
00104                         noblock = 1;
00105         } else if(Number(1, 10) == 2)
00106                 intDamage = intDamage / 2;
00107         if(!Armors[i].name)
00108                 return intDamage;
00109         if(cause >= 0 &&
00110            !((Armors[i].deft) & (MechWeapons[cause].special & PCOMBAT)) &&
00111            (MechWeapons[cause].special & PCOMBAT))
00112                 return intDamage;
00113         block =
00114                 BOUNDED(Number(1, (Armors[i].defmin / 2)),
00115                                 abs(intDamage * Armors[i].defpros / 100),
00116                                 Armors[i].defmax / 2);
00117         if(noblock)
00118                 block = 0;
00119         if(abs(intDamage) < block) {
00120                 mech_printf(wounded, MECHALL, "Your armor blocks all of the damage!");
00121                 return 0;
00122         }
00123         if(block) {
00124                 mech_printf(wounded, MECHALL,
00125                                         "Armor blocks %d points of the damage!", block);
00126         }
00127         return (abs(intDamage) - block) * intDamage / abs(intDamage);
00128 }

int dam_to_pc_conversion ( MECH target,
int  weapindx,
int  dam 
)

Definition at line 55 of file pcombat.c.

References CLASS_MW, MechType, MechWeapons, Number, and PCOMBAT.

00056 {
00057         int i = 0, j;
00058 
00059         if(weapindx >= 0 && MechWeapons[weapindx].special & PCOMBAT)
00060                 return dam;
00061         if(MechType(target) != CLASS_MW)
00062                 return dam;
00063         /* Target is MW _and_ we have yet to convert damage */
00064         for(j = 0; j < dam; j++)
00065                 i += Number(80, 130);
00066         return i;
00067 }

int pc_to_dam_conversion ( MECH target,
int  weapindx,
int  dam 
)

Definition at line 40 of file pcombat.c.

References CLASS_MW, MechType, MechWeapons, Number, and PCOMBAT.

00041 {
00042         int i = 0;
00043 
00044         if(MechType(target) == CLASS_MW)
00045                 return dam;
00046         if(weapindx < 0 || !(MechWeapons[weapindx].special & PCOMBAT))
00047                 return dam;
00048         i = dam / 100;
00049         dam = dam % 100;
00050         if(Number(1, 100) <= dam)
00051                 i++;
00052         return i;
00053 }

static int pcombat_hitloc ( int  loc  )  [static]

Definition at line 69 of file pcombat.c.

References CTORSO, LARM, LLEG, LTORSO, RARM, RLEG, and RTORSO.

Referenced by armor_effect().

00070 {
00071         switch (loc) {
00072         case LTORSO:
00073         case RTORSO:
00074                 return CTORSO;
00075         case LARM:
00076                 return RARM;
00077         case LLEG:
00078                 return RLEG;
00079         }
00080         return loc;
00081 }


Variable Documentation

struct { ... } Armors[] [static]

Referenced by armor_effect().

int defmax

Definition at line 19 of file pcombat.c.

Referenced by armor_effect().

int defmin

Definition at line 17 of file pcombat.c.

Referenced by armor_effect().

int defpros

Definition at line 18 of file pcombat.c.

Referenced by armor_effect().

int deft

Definition at line 16 of file pcombat.c.

Referenced by armor_effect().

int loc

Definition at line 14 of file pcombat.c.

Referenced by announce_connect(), announce_disconnect(), armor_effect(), can_destroy_exit(), clone_home(), describe_repairs(), destroy_exit(), did_it(), do_clone(), do_drop(), do_enter_internal(), do_examine(), do_leave(), do_look(), do_move(), do_open(), do_pemit(), do_say(), do_teleport(), do_toad(), fun_btaddstores(), fun_next(), match_exit(), match_exit_with_parents(), match_here(), match_neighbor(), mech_dump(), mech_dump_event(), mech_Rfixstuff(), move_exit(), muxevent_tickmech_reload(), muxevent_tickmech_removegun(), muxevent_tickmech_removepart(), muxevent_tickmech_removesection(), muxevent_tickmech_repairarmor(), muxevent_tickmech_repairenhcrit(), muxevent_tickmech_repairgun(), muxevent_tickmech_repairinternal(), muxevent_tickmech_repairpart(), muxevent_tickmech_replacegun(), new_home(), process_dropped_dropto(), process_enter_loc(), process_leave_loc(), tech_check_loc(), tech_check_locpart(), TECHCOMMANDH(), TFUNC_LOC(), TFUNC_LOC_RESEAL(), TFUNC_LOCPOS(), TFUNC_LOCPOS_VAL(), and where_is().

int loci

Definition at line 15 of file pcombat.c.

Referenced by armor_effect().

char* name

Definition at line 13 of file pcombat.c.


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