src/hcode/btech/mech.tag.c File Reference

#include "mech.h"
#include "mech.events.h"
#include "p.mech.tag.h"
#include "p.mech.los.h"
#include "p.mech.utils.h"

Include dependency graph for mech.tag.c:

Go to the source code of this file.

Defines

#define TAGRECYCLE_TICK   30
#define TAG_SHORT   5
#define TAG_MED   10
#define TAG_LONG   15

Functions

static void tag_recycle_event (MUXEVENT *e)
void mech_tag (dbref player, void *data, char *buffer)
int isTAGDestroyed (MECH *mech)
void stopTAG (MECH *mech)
void checkTAG (MECH *mech)


Define Documentation

#define TAG_LONG   15

Definition at line 17 of file mech.tag.c.

Referenced by checkTAG(), and mech_tag().

#define TAG_MED   10

Definition at line 16 of file mech.tag.c.

Referenced by mech_tag().

#define TAG_SHORT   5

Definition at line 15 of file mech.tag.c.

Referenced by mech_tag().

#define TAGRECYCLE_TICK   30

Definition at line 14 of file mech.tag.c.

Referenced by mech_tag(), and stopTAG().


Function Documentation

void checkTAG ( MECH mech  ) 

Definition at line 148 of file mech.tag.c.

References FlMechRange, getMap(), getMech(), InLineOfSight_NB(), MECH::mapindex, MechX, MechY, MECH::mynum, stopTAG(), TAG_LONG, TaggedBy, and TAGTarget.

Referenced by aero_update(), HandleMechCrit(), mech_update(), and update_LOSinfo().

00149 {
00150         MECH *target;
00151         dbref refTarget;
00152         float range;
00153         int LOS = 1;
00154 
00155         refTarget = TAGTarget(mech);
00156 
00157         if(refTarget <= 0)
00158                 return;
00159 
00160         target = getMech(refTarget);
00161 
00162         if(!target) {
00163                 stopTAG(mech);
00164                 return;
00165         }
00166 
00167         if(TaggedBy(target) != mech->mynum) {
00168                 stopTAG(mech);
00169                 return;
00170         }
00171 
00172         range = FlMechRange(getMap(mech->mapindex), mech, target);
00173         LOS = InLineOfSight_NB(mech, target, MechX(target), MechY(target), range);
00174 
00175         if(!LOS || (range > TAG_LONG)) {
00176                 stopTAG(mech);
00177                 return;
00178         }
00179 }

int isTAGDestroyed ( MECH mech  ) 

Definition at line 116 of file mech.tag.c.

References C3_DESTROYED, HasC3m, MechCritStatus, MechSpecials2, TAG_DESTROYED, and TAG_TECH.

Referenced by mech_tag(), PrintWeaponStatus(), and tag_recycle_event().

00117 {
00118         if((MechSpecials2(mech) & TAG_TECH) &&
00119            (MechCritStatus(mech) & TAG_DESTROYED))
00120                 return 1;
00121 
00122         if(HasC3m(mech) && (MechCritStatus(mech) & C3_DESTROYED))
00123                 return 1;
00124 
00125         return 0;
00126 }

void mech_tag ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 46 of file mech.tag.c.

References args, cch, DOCHECK, EVENT_TAG_RECYCLE, FindTargetDBREFFromMapNumber(), FlMechRange, getMap(), getMech(), GetMechToMechID(), HasTAG, InLineOfSight_NB(), isTAGDestroyed(), MECH::mapindex, mech_parseattributes(), mech_printf(), MECH_USUALO, MECHALL, MECHEVENT, MechTeam, MechX, MechY, MECH::mynum, stopTAG(), TAG_LONG, TAG_MED, tag_recycle_event(), TAG_SHORT, TaggedBy, TAGRECYCLE_TICK, TagRecycling, TAGTarget, and tprintf().

00047 {
00048         MECH *mech = (MECH *) data, *target;
00049         MAP *objMap;
00050         char *args[2];
00051         dbref refTarget;
00052         int LOS = 1;
00053         float range = 0.0;
00054 
00055         cch(MECH_USUALO);
00056 
00057         DOCHECK(!HasTAG(mech), "This unit is not equipped with TAG!");
00058         DOCHECK(isTAGDestroyed(mech), "Your TAG system is destroyed!");
00059         DOCHECK(TagRecycling(mech), "Your TAG system is recycling!");
00060         DOCHECK(mech_parseattributes(buffer, args, 2) != 1,
00061                         "Invalid number of arguments to function!");
00062 
00063         objMap = getMap(mech->mapindex);
00064 
00065         /* Clear our TAG */
00066         if(!strcmp(args[0], "-")) {
00067                 refTarget = TAGTarget(mech);
00068 
00069                 DOCHECK(refTarget <= 0, "You are not currently tagging anything!");
00070 
00071                 stopTAG(mech);
00072 
00073                 return;
00074         }
00075 
00076         /* TAG something... anything :) */
00077         refTarget = FindTargetDBREFFromMapNumber(mech, args[0]);
00078         target = getMech(refTarget);
00079 
00080         if(target) {
00081                 range = FlMechRange(objMap, mech, target);
00082 
00083                 LOS =
00084                         InLineOfSight_NB(mech, target, MechX(target), MechY(target),
00085                                                          range);
00086         } else
00087                 refTarget = 0;
00088 
00089         DOCHECK(refTarget < 1 ||
00090                         !LOS, "That is not a valid TAG targetID. Try again.");
00091         DOCHECK(MechTeam(mech) == MechTeam(target),
00092                         "You can't TAG friendly units!");
00093         DOCHECK(mech == target, "You can't TAG yourself!");
00094         DOCHECK(range > TAG_LONG,
00095                         tprintf("Out of range! TAG ranges are %d/%d/%d", TAG_SHORT,
00096                                         TAG_MED, TAG_LONG));
00097 
00098         /*
00099          * This should actually make a roll...
00100          */
00101 
00102         /*
00103            if ( checkAllSections(mech,INARC_HAYWIRE_ATTACHED) )
00104            BTH += 1;
00105          */
00106 
00107         mech_printf(mech, MECHALL, "You light up %s with your TAG.",
00108                                 GetMechToMechID(mech, target));
00109 
00110         TaggedBy(target) = mech->mynum;
00111         TAGTarget(mech) = target->mynum;
00112 
00113         MECHEVENT(mech, EVENT_TAG_RECYCLE, tag_recycle_event, TAGRECYCLE_TICK, 1);
00114 }

void stopTAG ( MECH mech  ) 

Definition at line 128 of file mech.tag.c.

References EVENT_TAG_RECYCLE, getMech(), mech_notify(), MECHALL, MECHEVENT, MECH::mynum, tag_recycle_event(), TaggedBy, TAGRECYCLE_TICK, and TAGTarget.

Referenced by checkTAG(), and mech_tag().

00129 {
00130         MECH *target;
00131 
00132         target = getMech(TAGTarget(mech));
00133 
00134         if(target)
00135                 if(TaggedBy(target) == mech->mynum)
00136                         TaggedBy(target) = 0;
00137 
00138         if(TAGTarget(mech) > 0) {
00139                 TAGTarget(mech) = 0;
00140 
00141                 mech_notify(mech, MECHALL, "Your TAG connection has been broken.");
00142 
00143                 MECHEVENT(mech, EVENT_TAG_RECYCLE, tag_recycle_event,
00144                                   TAGRECYCLE_TICK, 0);
00145         }
00146 }

static void tag_recycle_event ( MUXEVENT e  )  [static]

Definition at line 19 of file mech.tag.c.

References my_event_type::data, my_event_type::data2, getMech(), isTAGDestroyed(), mech_notify(), MECHALL, MECH::mynum, TaggedBy, and TAGTarget.

Referenced by mech_tag(), and stopTAG().

00020 {
00021         MECH *mech = (MECH *) e->data;
00022         int data = (int) e->data2;
00023         MECH *target;
00024 
00025         if(isTAGDestroyed(mech))
00026                 return;
00027 
00028         if(data == 0) {
00029                 mech_notify(mech, MECHALL,
00030                                         "%cgYour TAG system has finished recycling.%cn");
00031                 return;
00032         }
00033 
00034         target = getMech(TAGTarget(mech));
00035 
00036         if(!target)
00037                 return;
00038 
00039         if(TaggedBy(target) != mech->mynum)
00040                 return;
00041 
00042         mech_notify(mech, MECHALL,
00043                                 "%cgYour TAG system has achieved a stable lock.%cn");
00044 }


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