src/hcode/btech/mech.tech.h

Go to the documentation of this file.
00001 
00002 /*
00003  * $Id: mech.tech.h,v 1.5 2005/06/24 04:39:08 av1-op Exp $
00004  *
00005  * Author: Markus Stenberg <fingon@iki.fi>
00006  *
00007  *  Copyright (c) 1996 Markus Stenberg
00008  *  Copyright (c) 1998-2002 Thomas Wouters
00009  *  Copyright (c) 2000-2002 Cord Awtry
00010  *       All rights reserved
00011  *
00012  * Created: Fri Aug 30 15:22:08 1996 fingon
00013  * Last modified: Sat Jun  6 20:49:50 1998 fingon
00014  *
00015  */
00016 
00017 #include "config.h"
00018 
00019 #ifndef MECH_TECH_H
00020 #define MECH_TECH_H
00021 
00022 #include "mech.events.h"
00023 
00024 /* In minutes */
00025 #define MAX_TECHTIME 600
00026 #if 1
00027 #define TECH_TICK     60
00028 #define TECH_UNIT "minute"
00029 #else
00030 #define TECH_TICK      1
00031 #define TECH_UNIT "second"
00032 #endif
00033 
00034 /* Tech skill modifiers ; + = bad, - = good */
00035 #define PARTTYPE_DIFFICULTY(a) (1)
00036 #define WEAPTYPE_DIFFICULTY(a) ((int) (sqrt(MechWeapons[Weapon2I(a)].criticals)*1.5-1.1))
00037 #define REPAIR_DIFFICULTY     0
00038 #define REPLACE_DIFFICULTY     1
00039 #define RELOAD_DIFFICULTY      1
00040 #define FIXARMOR_DIFFICULTY    1
00041 #define FIXINTERNAL_DIFFICULTY 2
00042 #define REATTACH_DIFFICULTY    3
00043 #define REMOVEG_DIFFICULTY     1
00044 #define REMOVEP_DIFFICULTY     0
00045 #define REMOVES_DIFFICULTY     2
00046 #define RESEAL_DIFFICULTY    0  /* Added 8/4/99. Kipsta. */
00047 #define REPLACESUIT_DIFFICULTY    3
00048 #define ENHCRIT_DIFFICULTY    0
00049 
00050 /* Times are in minutes */
00051 #define MOUNT_BOMB_TIME  5
00052 #define UMOUNT_BOMB_TIME 5
00053 #define REPLACEGUN_TIME  60
00054 #define REPLACEPART_TIME 45
00055 #define REPAIRGUN_TIME   20
00056 #define REPAIRENHCRIT_TIME  15
00057 #define REPAIRPART_TIME  15
00058 #define RELOAD_TIME      10
00059 #define FIXARMOR_TIME    3
00060 #define FIXINTERNAL_TIME 9
00061 #define REATTACH_TIME    240
00062 #define REMOVEP_TIME     40
00063 #define REMOVEG_TIME     40
00064 #define REMOVES_TIME     120
00065 #define RESEAL_TIME    60       /* Added 8/4/99. Kipsta. */
00066 #define REPLACESUIT_TIME    120
00067 
00068 #define TECHCOMMANDH(a) \
00069    void a (dbref player, void * data, char * buffer)
00070 #define TECHCOMMANDB \
00071  MECH *mech = (MECH *) data; \
00072  int loc, part, t, full, now, from, to, change, mod=2, isds=0; \
00073  char *c;
00074 
00075 
00076 #define TECHCOMMANDC \
00077 DOCHECK(!(Tech(player)),"Insufficient clearance to access the command."); \
00078 DOCHECK(!mech, "Error has occured in techcommand ; please contact a wiz"); \
00079 isds = DropShip(MechType(mech)); \
00080 DOCHECK(Starting(mech) && !Wiz(player), "The mech's starting up! Please stop the sequence first."); \
00081 DOCHECK(Started(mech) && !Wiz(player), "The mech's started up ; please shut it down first."); \
00082 DOCHECK(!isds && !MechStall(mech) && !Wiz(player), "The 'mech isn't in a repair stall!");
00083 
00084 #define TECHCOMMANDD \
00085 DOCHECK(!(Tech(player)),"Insufficient clearance to access the command."); \
00086 DOCHECK(!mech, "Error has occured in techcommand ; please contact a wiz"); \
00087 isds = DropShip(MechType(mech)); \
00088 DOCHECK(Starting(mech) && !Wiz(player), "The mech's starting up! Please stop the sequence first."); \
00089 DOCHECK(Started(mech) && !Wiz(player), "The mech's started up ; please shut it down first."); \
00090 DOCHECK(mudconf.btech_limitedrepairs && !isds && !MechStall(mech) && !Wiz(player), "The 'mech isn't in a repair stall!");
00091 
00092 #define ETECHCOMMAND(a) \
00093  void a (dbref player, void *data, char *buffer)
00094 
00095 #define LOCMAX 16
00096 #define POSMAX 16
00097 #define EXTMAX 256
00098 #define PLAYERPOS (LOCMAX*POSMAX*EXTMAX)
00099 
00100 #define TECHEVENT(a) \
00101    void a (MUXEVENT *e) \
00102      { MECH *mech = (MECH *) e->data;  \
00103        int earg = (int) (e->data2) % PLAYERPOS;
00104 
00105 #define ETECHEVENT(a) \
00106    extern void a (MUXEVENT *e)
00107 
00108 #define START(a) notify(player, a)
00109 #ifndef BT_FREETECHTIME
00110 #define FIXEVENT(time,d1,d2,fu,type) \
00111      muxevent_add(MAX(1, time), 0, type, fu, (void *) d1, (void *) ((d2) + player * PLAYERPOS))
00112 #else
00113 #define FIXEVENT(time,d1,d2,fu,type) \
00114     muxevent_add((mudconf.btech_freetechtime ? 2 : MAX(2, time)), 0, type, fu, (void *) d1, (void *) ((d2) + player * PLAYERPOS))
00115 #endif
00116 #define REPAIREVENT(time,d1,d2,fu,type) \
00117      FIXEVENT((time)*TECH_TICK,d1,d2,fu,type)
00118 #define STARTREPAIR(time,d1,d2,fu,type) \
00119      FIXEVENT(tech_addtechtime(player, (time * mod) / 2),d1,d2,fu,type)
00120 #define STARTIREPAIR(time,d1,d2,fu,type,amount) \
00121      FIXEVENT((tech_addtechtime(player, (time * mod) / 2) - (amount > 0 ? TECH_TICK * (time * (amount - 1) / (amount)) : 0)), d1, d2, fu, type)
00122 #define FAKEREPAIR(time,type,d1,d2) \
00123      FIXEVENT(tech_addtechtime(player, (time * mod) / 2),d1,d2,very_fake_func,type)
00124 
00125 /* replace gun/part, repair gun/part (loc/pos) */
00126 #define DOTECH_LOCPOS(diff,flunkfunc,succfunc,resourcefunc,time,d1,d2,fu,type,msg,isgun)\
00127    if (resourcefunc(player,mech,loc,part)>=0) { START(msg); \
00128    if ((!isgun && tech_roll(player, mech, diff) < 0) || \
00129        (isgun && tech_weapon_roll(player, mech, diff) < 0)) { mod = 3;  \
00130    if (flunkfunc(player,mech,loc,part)<0) { FAKEREPAIR(time,type,d1,d2); return;}} \
00131     else \
00132      { if (succfunc(player,mech,loc,part)<0) return; } \
00133      STARTREPAIR(time,d1,d2,fu,type); }
00134 
00135 /* reload (loc/pos/amount) */
00136 #define DOTECH_LOCPOS_VAL(diff,flunkfunc,succfunc,resourcefunc,amo,time,d1,d2,fu,type,msg)\
00137    if (resourcefunc(player,mech,loc,part,amo)<0) return; \
00138    START(msg); \
00139    if (tech_roll(player, mech, diff) < 0) { mod = 3; \
00140    if (flunkfunc(player,mech,loc,part,amo)<0) {FAKEREPAIR(time,type,d1,d2);return;}}\
00141      else \
00142    { if (succfunc(player,mech,loc,part,amo)<0) return; } \
00143    STARTREPAIR(time,d1,d2,fu,type)
00144 
00145 
00146 /* fixarmor/internal (loc/amount) */
00147 #define DOTECH_LOC_VAL_S(diff,flunkfunc,succfunc,resourcefunc,amo,time,type,d1,d2,msg) \
00148    if (resourcefunc(player,mech,loc,amo)<0) return; \
00149    START(msg); \
00150    if (tech_roll(player, mech, diff) < 0) { mod = 3; \
00151    if (flunkfunc(player,mech,loc,amo)<0) { FAKEREPAIR(time,type,d1,d2); return; }} \
00152    else \
00153      { if (succfunc(player,mech,loc,amo)<0) return; }
00154 
00155 #define DOTECH_LOC_VAL(diff,flunkfunc,succfunc,resourcefunc,amo,time,d1,d2,fu,type,msg) \
00156    if (resourcefunc(player,mech,loc,amo)<0) return; \
00157    START(msg); \
00158    if (tech_roll(player, mech, diff) < 0) { mod = 3; \
00159    if (flunkfunc(player,mech,loc,amo)<0) { FAKEREPAIR(time,type,d1,d2); return; }} \
00160    else \
00161      { if (succfunc(player,mech,loc,amo)<0) return; } \
00162    STARTREPAIR(time,d1,d2,fu,type)
00163 
00164 /* reattach and reseal (loc) */
00165 #define DOTECH_LOC(diff,flunkfunc,succfunc,resourcefunc,time,d1,d2,fu,type,msg) \
00166    if (resourcefunc(player,mech,loc)<0) return; \
00167    START(msg); \
00168    if (tech_roll(player, mech, diff) < 0) { mod = 3; \
00169    if (flunkfunc(player,mech,loc)<0) { FAKEREPAIR(time,type,d1,d2);return; }} \
00170     else \
00171    { if (succfunc(player,mech,loc)<0) return; } \
00172    STARTREPAIR(time,d1,d2,fu,type)
00173 
00174 #define TFUNC_LOCPOS_VAL(name) \
00175 int name (dbref player,MECH *mech,int loc,int part, int * val)
00176 #define TFUNC_LOC_VAL(name) \
00177 int name (dbref player, MECH *mech, int loc, int * val)
00178 #define TFUNC_LOCPOS(name) \
00179 int name (dbref player, MECH *mech, int loc, int part)
00180 #define TFUNC_LOC(name) \
00181 int name (dbref player, MECH *mech, int loc)
00182 #define TFUNC_LOC_RESEAL(name) int name (dbref player, MECH *mech, int loc)
00183 #define NFUNC(a) a { return 0; }
00184 
00185 
00186 
00187 ETECHCOMMAND(tech_removegun);
00188 ETECHCOMMAND(tech_removepart);
00189 ETECHCOMMAND(tech_removesection);
00190 ETECHCOMMAND(tech_replacegun);
00191 ETECHCOMMAND(tech_repairgun);
00192 ETECHCOMMAND(tech_fixenhcrit);
00193 ETECHCOMMAND(tech_replacepart);
00194 ETECHCOMMAND(tech_repairpart);
00195 ETECHCOMMAND(tech_toggletype);
00196 ETECHCOMMAND(tech_reload);
00197 ETECHCOMMAND(tech_unload);
00198 ETECHCOMMAND(tech_fixarmor);
00199 ETECHCOMMAND(tech_fixinternal);
00200 ETECHCOMMAND(tech_reattach);
00201 ETECHCOMMAND(tech_checkstatus);
00202 ETECHCOMMAND(tech_reseal);
00203 ETECHCOMMAND(tech_replacesuit);
00204 ECMD(show_mechs_damage);
00205 ECMD(tech_fix);
00206 
00207 #define PACK_LOCPOS(loc,pos)          ((loc) + (pos)*LOCMAX)
00208 #define PACK_LOCPOS_E(loc,pos,extra)  ((loc) + (pos)*LOCMAX + (extra)*LOCMAX*POSMAX)
00209 
00210 #define UNPACK_LOCPOS(var,loc,pos)  loc = (var % LOCMAX);pos = (var / LOCMAX) % POSMAX
00211 #define UNPACK_LOCPOS_E(var,loc,pos,extra) UNPACK_LOCPOS(var,loc,pos);extra = var / (LOCMAX * POSMAX)
00212 
00213 #ifndef BT_COMPLEXREPAIRS
00214 #define ProperArmor(mech) \
00215 (Cargo(\
00216        (MechSpecials(mech) & FF_TECH) ? FF_ARMOR : \
00217        (MechSpecials(mech) & HARDA_TECH) ? HD_ARMOR : \
00218        (MechSpecials2(mech) & STEALTH_ARMOR_TECH) ? STH_ARMOR : \
00219        (MechSpecials2(mech) & HVY_FF_ARMOR_TECH) ? HVY_FF_ARMOR : \
00220        (MechSpecials2(mech) & LT_FF_ARMOR_TECH) ? LT_FF_ARMOR : \
00221        (MechInfantrySpecials(mech) & CS_PURIFIER_STEALTH_TECH) ? PURIFIER_ARMOR : \
00222        S_ARMOR))
00223 
00224 #define ProperInternal(mech) \
00225 (Cargo(\
00226        (MechSpecials(mech) & ES_TECH) ? ES_INTERNAL : \
00227        (MechSpecials(mech) & REINFI_TECH) ? RE_INTERNAL : \
00228        (MechSpecials(mech) & COMPI_TECH) ? CO_INTERNAL : \
00229        S_INTERNAL))
00230 #endif
00231 
00232 #define GrabPartsM(m,a,b,c) econ_change_items(IsDS(m) ? AeroBay(m,0) : Location(m->mynum),a,b,0-c)
00233 #define PartAvailM(m,a,b,c) (econ_find_items(IsDS(m) ? AeroBay(m,0) : Location(m->mynum),a,b)>=c)
00234 #ifndef BT_COMPLEXREPAIRS
00235 #define AddPartsM(m,a,b,c) econ_change_items(IsDS(m) ? AeroBay(m,0) : Location(m->mynum), alias_part(m, a) , b, c)
00236 #else
00237 #define AddPartsM(m,l,a,b,c) econ_change_items(IsDS(m) ? AeroBay(m,0) : Location(m->mynum), alias_part(m, a, l) , b, c)
00238 #endif
00239 #define AVCHECKM(m,a,b,c)    DOCHECK1(!PartAvailM(m,a,b,c), tprintf("Not enough %ss in store! You need to have atleast %d.",part_name(a,b),c));
00240 
00241 #ifndef BT_COMPLEXREPAIRS
00242 #define alias_part(m,t) \
00243   (IsActuator(t) ? Cargo(S_ACTUATOR) : \
00244    (t == Special(ENGINE) ? \
00245     ((MechSpecials(m) & XL_TECH) ? Cargo(XL_ENGINE) : \
00246      (MechSpecials(m) & ICE_TECH) ? Cargo(IC_ENGINE) : \
00247      (MechSpecials(m) & XXL_TECH) ? Cargo(XXL_ENGINE) : \
00248      (MechSpecials(m) & CE_TECH) ? Cargo(COMP_ENGINE) : \
00249      (MechSpecials(m) & LE_TECH) ? Cargo(LIGHT_ENGINE) : t) : \
00250    (t == Special(HEAT_SINK) && MechHasDHS(m) ? Cargo(DOUBLE_HEAT_SINK) : t)))
00251 #endif
00252 
00253 ETECHEVENT(muxevent_tickmech_reattach);
00254 ETECHEVENT(muxevent_tickmech_reseal);
00255 ETECHEVENT(muxevent_tickmech_reload);
00256 ETECHEVENT(muxevent_tickmech_removegun);
00257 ETECHEVENT(muxevent_tickmech_removepart);
00258 ETECHEVENT(muxevent_tickmech_removesection);
00259 ETECHEVENT(muxevent_tickmech_repairarmor);
00260 ETECHEVENT(muxevent_tickmech_repairgun);
00261 ETECHEVENT(muxevent_tickmech_repairenhcrit);
00262 ETECHEVENT(muxevent_tickmech_repairinternal);
00263 ETECHEVENT(muxevent_tickmech_repairpart);
00264 ETECHEVENT(muxevent_tickmech_replacegun);
00265 ETECHEVENT(muxevent_tickmech_mountbomb);
00266 ETECHEVENT(muxevent_tickmech_umountbomb);
00267 ETECHEVENT(muxevent_tickmech_replacesuit);
00268 ETECHEVENT(very_fake_func);
00269 
00270 void loadrepairs(FILE * f);
00271 void saverepairs(FILE * f);
00272 int valid_ammo_mode(MECH * mech, int loc, int part, int let);
00273 
00274 #endif                          /* MECH_TECH_H */

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