src/hcode/btech/p.ds.bay.h File Reference

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

Go to the source code of this file.

Functions

void mech_createbays (dbref player, void *data, char *buffer)
int Find_DS_Bay_Number (MECH *ds, int dir)
int Find_DS_Bay_Dir (MECH *ds, int num)
int Find_DS_Bay_In_MechHex (MECH *seer, MECH *ds, int *bayn)
void mech_enterbay (dbref player, void *data, char *buffer)
int Leave_DS (MAP *map, MECH *mech)


Function Documentation

int Find_DS_Bay_Dir ( MECH ds,
int  num 
)

Definition at line 76 of file ds.bay.c.

References Find_DS_Bay_Number().

Referenced by DS_Bay_Is_Open().

00077 {
00078         int i;
00079 
00080         for(i = 0; i < 6; i++)
00081                 if(Find_DS_Bay_Number(ds, i) == num)
00082                         return i;
00083         return -1;
00084 }

int Find_DS_Bay_In_MechHex ( MECH seer,
MECH ds,
int *  bayn 
)

Definition at line 88 of file ds.bay.c.

References dirs, DSBearMod, Find_DS_Bay_Number(), KLUDGE, MechX, and MechY.

Referenced by Find_Single_DS_In_MechHex(), mech_enterbay(), and mech_enterbay_event().

00089 {
00090         int i;
00091         int t = DSBearMod(ds);
00092 
00093         for(i = t; i < (t + 6); i++) {
00094 
00095                 if(((MechX(ds) + dirs[i % 6][0]) == MechX(seer)) &&
00096                    ((MechY(ds) + dirs[i % 6][1] + KLUDGE(MechX(ds),
00097                                                                                                  MechX(ds) +
00098                                                                                                  dirs[i % 6][0])) ==
00099                         MechY(seer))) {
00100                         if((*bayn = Find_DS_Bay_Number(ds, ((i - t + 6) % 6))) >= 0)
00101                                 return 1;
00102                         return 0;
00103                 }
00104         }
00105         return 0;
00106 }

int Find_DS_Bay_Number ( MECH ds,
int  dir 
)

Definition at line 56 of file ds.bay.c.

References dir2loc, DS_AERODOOR, DS_MECHDOOR, GetPartType, I2Special, and NUM_CRITICALS.

Referenced by Find_DS_Bay_Dir(), Find_DS_Bay_In_MechHex(), and sketch_tac_mechs().

00057 {
00058         int bayn = 0;
00059         int i, j;
00060 
00061         for(i = 0; i <= dir; i++) {
00062                 for(j = 0; j < NUM_CRITICALS; j++)
00063                         if(GetPartType(ds, dir2loc[i % 6],
00064                                                    j) == I2Special(DS_MECHDOOR) ||
00065                            GetPartType(ds, dir2loc[i % 6], j) == I2Special(DS_AERODOOR))
00066                                 break;
00067                 if(j != NUM_CRITICALS) {
00068                         if(i == dir)
00069                                 return bayn;
00070                         bayn++;
00071                 }
00072         }
00073         return -1;
00074 }

int Leave_DS ( MAP map,
MECH mech 
)

Definition at line 356 of file ds.bay.c.

References DOCHECKMA0, DS_Bay_Is_Open(), FlyingT, getMech(), Landed, Leave_DS_Bay(), MECH::mynum, MAP::mynum, MAP::onmap, and Zombie.

Referenced by CheckEdgeOfMap().

00357 {
00358         MECH *car;
00359 
00360         DOCHECKMA0(!(car = getMech(map->onmap)), "Invalid : No parent object?");
00361         DOCHECKMA0(!DS_Bay_Is_Open(mech, car, map->mynum),
00362                            "The door has been jammed!");
00363         DOCHECKMA0(!Landed(car) &&
00364                            !FlyingT(mech), "The 'ship is still airborne!");
00365         DOCHECKMA0(Zombie(car->mynum),
00366                            "You don't feel leaving right now would be prudent..");
00367         return Leave_DS_Bay(map, car, mech, map->mynum);
00368 }

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

Definition at line 25 of file ds.bay.c.

References AeroBay, args, DOCHECK, FindObjectsData(), IsMap(), match_thing(), mech_parseattributes(), MECH::mynum, NOTHING, notify_printf(), NUM_BAYS, MAP::onmap, and tprintf().

00026 {
00027         char *args[NUM_BAYS + 1];
00028         int argc;
00029         dbref it;
00030         int i;
00031         MECH *ds = (MECH *) data;
00032         MAP *map;
00033 
00034         DOCHECK((argc =
00035                          mech_parseattributes(buffer, args,
00036                                                                   NUM_BAYS + 1)) == (NUM_BAYS + 1),
00037                         "Invalid number of arguments!");
00038         for(i = 0; i < argc; i++) {
00039                 it = match_thing(player, args[i]);
00040                 DOCHECK(it == NOTHING, tprintf("Argument %d is invalid.", i + 1));
00041                 DOCHECK(!IsMap(it), tprintf("Argument %d is not a map.", i + 1));
00042                 map = FindObjectsData(it);
00043                 AeroBay(ds, i) = it;
00044                 map->onmap = ds->mynum;
00045         }
00046         for(i = argc; i < NUM_BAYS; i++)
00047                 AeroBay(ds, i) = -1;
00048         notify_printf(player, "%d bay(s) set up!", argc);
00049 }

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

Definition at line 216 of file ds.bay.c.

References A_FAIL, A_LENTER, AeroBay, AeroFuel, args, can_pass_lock, CARRIER_TECH, cch, CLASS_MECH, CLASS_VTOL, DOCHECK, DS_Bay_Is_EnterOK(), DS_Bay_Is_Open(), EnteringHangar, EVENT_ENTER_HANGAR, Fallen, Find_DS_Bay_In_MechHex(), Find_Single_DS_In_MechHex(), FindTargetDBREFFromMapNumber(), getMap(), getMech(), HexLOSBroadcast(), IsDS, IsMechLegLess(), Jumping, mech_enterbay_event(), mech_parseattributes(), MECH_USUAL, MECHEVENT, MechIsQuad, MechSpecials2, MechSpeed, MechType, MechVerticalSpeed, MechX, MechY, MechZ, MP1, notify, OODing, silly_atr_get(), and Standing.

Referenced by auto_com_event().

00217 {
00218         char *args[3];
00219         int argc;
00220         dbref ref = -1, bayn = -1;
00221         MECH *mech = data, *ds;
00222         MAP *map;
00223 
00224         cch(MECH_USUAL);
00225         DOCHECK(MechType(mech) == CLASS_VTOL &&
00226                         AeroFuel(mech) <= 0, "You lack fuel to maneuver in!");
00227         DOCHECK(Jumping(mech), "While in mid-jump? No way.");
00228         DOCHECK(MechType(mech) == CLASS_MECH && (Fallen(mech) ||
00229                                                                                          Standing(mech)),
00230                         "Crawl inside? I think not. Stand first.");
00231         DOCHECK(OODing(mech), "While in mid-flight? No way.");
00232         DOCHECK((argc =
00233                          mech_parseattributes(buffer, args, 2)) == 2,
00234                         "Hmm, invalid number of arguments?");
00235         if(argc > 0)
00236                 DOCHECK((ref =
00237                                  FindTargetDBREFFromMapNumber(mech, args[0])) <= 0,
00238                                 "Invalid target!");
00239         if(ref < 0) {
00240                 DOCHECK(!Find_Single_DS_In_MechHex(mech, &ref, &bayn),
00241                                 "No DS bay found in your hex!");
00242                 DOCHECK(ref < 0,
00243                                 "Multiple enterable things found ; use the id for specifying which you want.");
00244                 DOCHECK(!(ds =
00245                                   getMech(ref)), "You sense wrongness in fabric of space.");
00246         } else {
00247                 DOCHECK(!(ds =
00248                                   getMech(ref)), "You sense wrongness in fabric of space.");
00249                 DOCHECK(!Find_DS_Bay_In_MechHex(mech, ds, &bayn),
00250                                 "You see no bays in your hex.");
00251         }
00252         DOCHECK(IsDS(mech)
00253                         && !(MechSpecials2(mech) & CARRIER_TECH),
00254                         "Your craft can't enter bays.");
00255         DOCHECK(!DS_Bay_Is_Open(mech, ds, AeroBay(ds, bayn)),
00256                         "The door has been jammed!");
00257         DOCHECK(IsDS(mech), "Your unit is a bit too large to fit in there.");
00258         DOCHECK((fabs((float) (MechSpeed(mech) - MechSpeed(ds)))) > MP1,
00259                         "Speed difference's too large to enter!");
00260         DOCHECK(MechZ(ds) != MechZ(mech),
00261                         "Get to same elevation before thinking about entering!");
00262         DOCHECK(abs(MechVerticalSpeed(mech) - MechVerticalSpeed(ds)) > 10,
00263                         "Vertical speed difference is too great to enter safely!");
00264         DOCHECK(MechType(mech) == CLASS_MECH && !MechIsQuad(mech) &&
00265                         (IsMechLegLess(mech)), "Without legs? Are you kidding?");
00266         ref = AeroBay(ds, bayn);
00267         map = getMap(ref);
00268 
00269         DOCHECK(!map, "You sense wrongness in fabric of space.");
00270 
00271         DOCHECK(EnteringHangar(mech), "You are already entering the hangar!");
00272         if(!can_pass_lock(mech->mynum, ref, A_LENTER)) {
00273                 char *msg = silly_atr_get(ref, A_FAIL);
00274                 if(!msg || !*msg)
00275                         msg = "You are unable to enter the bay!";
00276                 notify(player, msg);
00277                 return;
00278         }
00279         DOCHECK(!DS_Bay_Is_EnterOK(mech, ds, AeroBay(ds, bayn)),
00280                         "Someone else is using the door at the moment.");
00281         DOCHECK(!(map =
00282                           getMap(mech->mapindex)),
00283                         "You sense a wrongness in fabric of space.");
00284         HexLOSBroadcast(map, MechX(mech), MechY(mech),
00285                                         "The bay doors at $h start to open..");
00286         MECHEVENT(mech, EVENT_ENTER_HANGAR, mech_enterbay_event, 12, ref);
00287 }


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