src/hcode/btech/eject.c File Reference

#include "config.h"
#include <math.h>
#include "mech.h"
#include "mech.events.h"
#include "p.btechstats.h"
#include "p.mechrep.h"
#include "p.mech.restrict.h"
#include "p.mech.update.h"
#include "p.bsuit.h"
#include "autopilot.h"
#include "p.mech.combat.h"
#include "p.mech.combat.misc.h"
#include "p.mech.utils.h"
#include "p.econ_cmds.h"
#include "p.mech.los.h"
#include "p.mech.ood.h"
#include "p.mech.pickup.h"
#include "p.mech.tag.h"
#include "p.crit.h"
#include "p.mech.tech.h"
#include "p.mech.tech.commands.h"

Include dependency graph for eject.c:

Go to the source code of this file.

Functions

int tele_contents (dbref from, dbref to, int flag)
static void mech_discard_event (MUXEVENT *e)
void discard_mw (MECH *mech)
void enter_mw_bay (MECH *mech, dbref bay)
void pickup_mw (MECH *mech, MECH *target)
static void char_eject (dbref player, MECH *mech)
void mech_eject (dbref player, void *data, char *buffer)
static void char_disembark (dbref player, MECH *mech)
void mech_disembark (dbref player, void *data, char *buffer)
void mech_udisembark (dbref player, void *data, char *buffer)
void mech_embark (dbref player, void *data, char *buffer)
void autoeject (dbref player, MECH *mech, int tIsBSuit)


Function Documentation

void autoeject ( dbref  player,
MECH mech,
int  tIsBSuit 
)

Definition at line 669 of file eject.c.

References A_MECHNAME, A_MWTEMPLATE, A_XTYPE, confdata::btech_ic, create_object, destroy_object, MECH::freq, MECH::freqmodes, FREQS, getMech(), GetMechID(), GOD, handle_xcode(), hush_teleport, In_Character, initialize_pc(), initiate_ood(), Location, MECH::mapindex, mech_loadnew(), mech_Rsetmapindex(), mech_Rsetteam(), mech_Rsetxy(), MechLOSBroadcast(), MechPilot, MechTeam, MechX, MechY, mudconf, MECH::mynum, Name(), notify, random, s_Hardcode, s_In_Character, SendError, silly_atr_get(), silly_atr_set(), and tprintf().

Referenced by reactor_explosion().

00670 {
00671         MECH *m;
00672         dbref suit;
00673         char *d;
00674 
00675         /* If we're not IC, return */
00676         if(!player || !In_Character(mech->mynum) || !mudconf.btech_ic ||
00677            !In_Character(Location(mech->mynum)))
00678                 return;
00679 
00680         /* Create the MW object */
00681         suit = create_object(tprintf("MechWarrior - %s", Name(player)));
00682         silly_atr_set(suit, A_XTYPE, "MECH");
00683         s_Hardcode(suit);
00684         handle_xcode(GOD, suit, 0, 1);
00685         d = silly_atr_get(player, A_MWTEMPLATE);
00686         if(!(m = getMech(suit))) {
00687                 SendError(tprintf
00688                                   ("Unable to create special obj for #%d's ejection.",
00689                                    player));
00690                 destroy_object(suit);
00691                 notify(player,
00692                            "Sorry, something serious went wrong, contact a Wizard (can't create RS object)");
00693                 return;
00694         }
00695         if(!mech_loadnew(GOD, m, (!d || !*d ||
00696                                                           !strcmp(d, "#-1")) ? "MechWarrior" : d)) {
00697                 SendError(tprintf
00698                                   ("Unable to load mechwarrior template for #%d's ejection. (%s)",
00699                                    player, (!d || !*d) ? "Default template" : d));
00700                 destroy_object(suit);
00701                 notify(player,
00702                            "Sorry, something serious went wrong, contact a Wizard (can't load MWTemplate)");
00703                 return;
00704         }
00705         silly_atr_set(suit, A_MECHNAME, "MechWarrior");
00706         MechTeam(m) = MechTeam(mech);
00707         mech_Rsetmapindex(GOD, (void *) m, tprintf("%d", mech->mapindex));
00708         mech_Rsetxy(GOD, (void *) m, tprintf("%d %d", MechX(mech), MechY(mech)));
00709         mech_Rsetteam(GOD, (void *) m, tprintf("%d", MechTeam(mech)));
00710 
00711         /* Tele the MW to the map and player to the MW */
00712         hush_teleport(suit, mech->mapindex);
00713         hush_teleport(player, suit);
00714 
00715         /* Init the sucker */
00716         s_In_Character(suit);
00717         initialize_pc(player, m);
00718         MechPilot(m) = player;
00719         MechTeam(m) = MechTeam(mech);
00720 #ifdef COPY_CHANS_ON_EJECT
00721         memcpy(m->freq, mech->freq, FREQS * sizeof(m->freq[0]));
00722         memcpy(m->freqmodes, mech->freqmodes, FREQS * sizeof(m->freqmodes[0]));
00723 #else
00724 #ifdef RANDOM_CHAN_ON_EJECT
00725         m->freq[0] = random() % 1000000;
00726         notify(player, tprintf("Emergency radio channel set to %d.", m->freq[0]));
00727 #endif
00728 #endif
00729 
00730         if(tIsBSuit) {
00731                 MechLOSBroadcast(m, "climbs out of one of the destroyed suits!");
00732                 notify(player, "You climb out of the unit!");
00733         } else {
00734                 MechLOSBroadcast(m, tprintf("ejected from %s!", GetMechID(mech)));
00735                 initiate_ood(player, m, tprintf("%d %d %d", MechX(m), MechY(m), 150));
00736                 notify(player, "You eject from the unit!");
00737         }
00738 }

static void char_disembark ( dbref  player,
MECH mech 
) [static]

Definition at line 203 of file eject.c.

References A_MECHNAME, A_MWTEMPLATE, A_XTYPE, create_object, destroy_object, Elevation, EVENT_FALL, FALL_TICK, MECH::freq, MECH::freqmodes, FREQS, getMap(), getMech(), GetMechID(), GOD, handle_xcode(), hush_teleport, initialize_pc(), MECH::mapindex, mech_fall_event(), mech_loadnew(), mech_Rsetmapindex(), mech_Rsetteam(), mech_Rsetxy(), MECHEVENT, MechLOSBroadcast(), MechPilot, MechSpeed, MechTeam, MechVerticalSpeed, MechX, MechY, MechZ, MP1, Name(), notify, notify_printf(), random, s_Hardcode, s_In_Character, SendError, silly_atr_get(), silly_atr_set(), and tprintf().

Referenced by mech_disembark().

00204 {
00205         MECH *m;
00206         dbref suit;
00207         char *d;
00208         MAP *mymap;
00209         int initial_speed;
00210 
00211         suit = create_object(tprintf("MechWarrior - %s", Name(player)));
00212         silly_atr_set(suit, A_XTYPE, "MECH");
00213         s_Hardcode(suit);
00214         handle_xcode(GOD, suit, 0, 1);
00215         d = silly_atr_get(player, A_MWTEMPLATE);
00216         if(!(m = getMech(suit))) {
00217                 SendError(tprintf
00218                                   ("Unable to create special obj for #%d's disembarkation.",
00219                                    player));
00220                 destroy_object(suit);
00221                 notify(player,
00222                            "Sorry, something serious went wrong, contact a Wizard (can't create RS object)");
00223                 return;
00224         }
00225         if(!mech_loadnew(GOD, m, (!d || !*d ||
00226                                                           !strcmp(d, "#-1")) ? "MechWarrior" : d)) {
00227                 SendError(tprintf
00228                                   ("Unable to load mechwarrior template for #%d's disembarkation. (%s)",
00229                                    player, (!d || !*d) ? "Default template" : d));
00230                 destroy_object(suit);
00231                 notify(player,
00232                            "Sorry, something serious went wrong, contact a Wizard (can't load MWTemplate)");
00233                 return;
00234         }
00235         silly_atr_set(suit, A_MECHNAME, "MechWarrior");
00236         MechTeam(m) = MechTeam(mech);
00237         mech_Rsetmapindex(GOD, (void *) m, tprintf("%d", mech->mapindex));
00238         mech_Rsetxy(GOD, (void *) m, tprintf("%d %d", MechX(mech), MechY(mech)));
00239         MechZ(m) = MechZ(mech);
00240         mech_Rsetteam(GOD, (void *) m, tprintf("%d", MechTeam(mech)));
00241         hush_teleport(suit, mech->mapindex);
00242         hush_teleport(player, suit);
00243         s_In_Character(suit);
00244         initialize_pc(player, m);
00245         MechPilot(m) = player;
00246         MechTeam(m) = MechTeam(mech);
00247 #ifdef COPY_CHANS_ON_EJECT
00248         memcpy(m->freq, mech->freq, FREQS * sizeof(m->freq[0]));
00249         memcpy(m->freqmodes, mech->freqmodes, FREQS * sizeof(m->freqmodes[0]));
00250 #else
00251 #ifdef RANDOM_CHAN_ON_EJECT
00252         m->freq[0] = random() % 1000000;
00253         notify_printf(player, "Emergency radio channel set to %d.", m->freq[0]);
00254 #endif
00255 #endif
00256         mymap = getMap(m->mapindex);
00257         if((MechZ(m) > (Elevation(mymap, MechX(m), MechY(m)) + 1)) &&
00258            (MechZ(m) > 0)) {
00259                 notify(player,
00260                            "You open the hatch and climb out of the unit. Maybe you should have done this while the thing was closer to the ground...");
00261                 MechLOSBroadcast(m, tprintf("jumps out of %s... in mid air !",
00262                                                                         GetMechID(mech)));
00263                 initial_speed =
00264                         ((MechSpeed(mech) + MechVerticalSpeed(mech)) / MP1) / 2 + 4;
00265                 MECHEVENT(m, EVENT_FALL, mech_fall_event, FALL_TICK, -initial_speed);
00266         } else {
00267                 MechLOSBroadcast(m, tprintf("climbs out of %s!", GetMechID(mech)));
00268                 notify(player, "You climb out of the unit.");
00269         }
00270 }

static void char_eject ( dbref  player,
MECH mech 
) [static]

Definition at line 110 of file eject.c.

References A_MECHNAME, A_MWTEMPLATE, A_XTYPE, CLASS_MECH, create_object, destroy_object, Destroyed, DestroyMech(), DestroyPart, MECH::freq, MECH::freqmodes, FREQS, getMech(), GetMechID(), GOD, handle_xcode(), HEAD, hush_teleport, initialize_pc(), MECH::mapindex, mech_loadnew(), mech_Rsetmapindex(), mech_Rsetteam(), mech_Rsetxy(), MechLOSBroadcast(), MechPilot, MechTeam, MechType, MechX, MechY, Name(), notify, notify_printf(), random, s_Hardcode, s_In_Character, SendError, silly_atr_get(), silly_atr_set(), and tprintf().

Referenced by mech_eject().

00111 {
00112         MECH *m;
00113         dbref suit;
00114         char *d;
00115 
00116         suit = create_object(tprintf("MechWarrior - %s", Name(player)));
00117         silly_atr_set(suit, A_XTYPE, "MECH");
00118         s_Hardcode(suit);
00119         handle_xcode(GOD, suit, 0, 1);
00120         d = silly_atr_get(player, A_MWTEMPLATE);
00121         if(!(m = getMech(suit))) {
00122                 SendError(tprintf
00123                                   ("Unable to create special obj for #%d's ejection.",
00124                                    player));
00125                 destroy_object(suit);
00126                 notify(player,
00127                            "Sorry, something serious went wrong, contact a Wizard (can't create RS object)");
00128                 return;
00129         }
00130         if(!mech_loadnew(GOD, m, (!d || !*d ||
00131                                                           !strcmp(d, "#-1")) ? "MechWarrior" : d)) {
00132                 SendError(tprintf
00133                                   ("Unable to load mechwarrior template for #%d's ejection. (%s)",
00134                                    player, (!d || !*d) ? "Default template" : d));
00135                 destroy_object(suit);
00136                 notify(player,
00137                            "Sorry, something serious went wrong, contact a Wizard (can't load MWTemplate)");
00138                 return;
00139         }
00140         silly_atr_set(suit, A_MECHNAME, "MechWarrior");
00141         MechTeam(m) = MechTeam(mech);
00142         mech_Rsetmapindex(GOD, (void *) m, tprintf("%d", mech->mapindex));
00143         mech_Rsetxy(GOD, (void *) m, tprintf("%d %d", MechX(mech), MechY(mech)));
00144         mech_Rsetteam(GOD, (void *) m, tprintf("%d", MechTeam(mech)));
00145         hush_teleport(suit, mech->mapindex);
00146         hush_teleport(player, suit);
00147         MechLOSBroadcast(m, tprintf("ejected from %s!", GetMechID(mech)));
00148         s_In_Character(suit);
00149         initialize_pc(player, m);
00150         MechPilot(m) = player;
00151         MechTeam(m) = MechTeam(mech);
00152 #ifdef COPY_CHANS_ON_EJECT
00153         memcpy(m->freq, mech->freq, FREQS * sizeof(m->freq[0]));
00154         memcpy(m->freqmodes, mech->freqmodes, FREQS * sizeof(m->freqmodes[0]));
00155 #else
00156 #ifdef RANDOM_CHAN_ON_EJECT
00157         m->freq[0] = random() % 1000000;
00158         notify_printf(player, "Emergency radio channel set to %d.", m->freq[0]);
00159 #endif
00160 #endif
00161         notify(player, "You eject from the unit!");
00162         if(MechType(mech) == CLASS_MECH) {
00163                 DestroyPart(mech, HEAD, 2);
00164         }
00165         if(!Destroyed(mech)) {
00166                 DestroyMech(mech, mech, 0);
00167         }
00168 }

void discard_mw ( MECH mech  ) 

Definition at line 74 of file eject.c.

References EVENT_NUKEMECH, In_Character, mech_discard_event(), MECHEVENT, and MECH::mynum.

Referenced by DestroyMech(), DestroySection(), enter_mw_bay(), explode_unit(), mech_embark(), and pickup_mw().

00075 {
00076         if(In_Character(mech->mynum))
00077                 MECHEVENT(mech, EVENT_NUKEMECH, mech_discard_event, 10, 0);
00078 }

void enter_mw_bay ( MECH mech,
dbref  bay 
)

Definition at line 80 of file eject.c.

References discard_mw(), MECH::mynum, TELE_ALL, and tele_contents().

Referenced by mech_enter_event(), and mech_enterbay_event().

00081 {
00082         tele_contents(mech->mynum, bay, TELE_ALL);      /* Even immortals must get going */
00083         discard_mw(mech);
00084 }

static void mech_discard_event ( MUXEVENT e  )  [static]

Definition at line 61 of file eject.c.

References c_Hardcode, my_event_type::data, GOD, handle_xcode(), hush_teleport, MECH::mynum, s_Dark, s_Going, s_Zombie, and USED_MW_STORE.

Referenced by discard_mw().

00062 {
00063         MECH *mech = (MECH *) e->data;
00064         dbref i = mech->mynum;
00065 
00066         c_Hardcode(i);
00067         handle_xcode(GOD, i, 1, 0);
00068         s_Going(i);
00069         s_Dark(i);
00070         s_Zombie(i);
00071         hush_teleport(i, USED_MW_STORE);
00072 }

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

Handle the disembarking of pilots from units.

Definition at line 275 of file eject.c.

References confdata::btech_ic, cch, char_disembark(), CLASS_MECH, CLASS_VEH_GROUND, CLASS_VTOL, DOCHECK, In_Character, Location, MECH_USUALS, MechPilot, MechSpeed, MechType, mudconf, MECH::mynum, and Started.

00276 {
00277         MECH *mech = (MECH *) data;
00278 
00279         cch(MECH_USUALS);
00280         DOCHECK(!((MechType(mech) == CLASS_MECH) ||
00281                           (MechType(mech) == CLASS_VTOL) ||
00282                           (MechType(mech) == CLASS_VEH_GROUND)),
00283                         "The door ! The door ? The Door ?!? Where's the exit in this damned thing ?");
00284 
00285 /*  DOCHECK(FlyingT(mech) && !Landed(mech), "What, in the air ? Are you suicidal ?"); */
00286         DOCHECK(!In_Character(mech->mynum), "This unit isn't in character!");
00287         DOCHECK(!mudconf.btech_ic, "This MUX isn't in character!");
00288         DOCHECK(!In_Character(Location(mech->mynum)),
00289                         "Your location isn't in character!");
00290         DOCHECK(Started(mech) && (MechPilot(mech) == player),
00291                         "While it's running!? Don't be daft.");
00292         DOCHECK(fabs(MechSpeed(mech)) > 25.,
00293                         "Are you suicidal ? That thing is moving too fast !");
00294         /* Ok.. time to disembark ourselves */
00295         char_disembark(player, mech);
00296 }

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

Definition at line 170 of file eject.c.

References A_PILOTNUM, confdata::btech_ic, cch, char_eject(), char_lookupplayer(), CLASS_MECH, CLASS_VEH_GROUND, CLASS_VTOL, DOCHECK, FlyingT, GOD, HEAD, In_Character, IsDS, Landed, Location, MECH_USUALS, MechPilot, MechType, mudconf, MECH::mynum, PartIsNonfunctional, silly_atr_get(), and Started.

00171 {
00172         MECH *mech = (MECH *) data;
00173 
00174         cch(MECH_USUALS);
00175         DOCHECK(IsDS(mech), "Dropships do not support ejection.");
00176         DOCHECK(!((MechType(mech) == CLASS_MECH) ||
00177                           (MechType(mech) == CLASS_VTOL) ||
00178                           (MechType(mech) == CLASS_VEH_GROUND)),
00179                         "This unit has no ejection seat!");
00180         DOCHECK(FlyingT(mech) &&
00181                         !Landed(mech),
00182                         "Regrettably, right now you can only eject when landed, sorry - no parachute :P");
00183         DOCHECK(!In_Character(mech->mynum), "This unit isn't in character!");
00184         DOCHECK(!mudconf.btech_ic, "This MUX isn't in character!");
00185         DOCHECK(!In_Character(Location(mech->mynum)),
00186                         "Your location isn't in character!");
00187         DOCHECK(Started(mech) &&
00188                         MechPilot(mech) != player,
00189                         "You aren't in da pilot's seat - no ejection for you!");
00190         if(!Started(mech)) {
00191                 DOCHECK((char_lookupplayer(GOD, GOD, 0, silly_atr_get(mech->mynum,
00192                                                                                                                           A_PILOTNUM))) !=
00193                                 player,
00194                                 "You aren't the official pilot of this thing. Try 'disembark'");
00195         }
00196         if(MechType(mech) == CLASS_MECH)
00197                 DOCHECK(PartIsNonfunctional(mech, HEAD, 2),
00198                                 "The parts of cockpit that control ejection are already used. Try 'disembark'");
00199         /* Ok.. time to eject ourselves */
00200         char_eject(player, mech);
00201 }

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

Definition at line 446 of file eject.c.

References A_AFAIL, A_FAIL, A_LENTER, args, atr_get_str(), can_pass_lock, CargoSpace, CarMaxTon, CARRIER_TECH, cch, CHECK_BOTH, CLASS_BSUIT, CLASS_MECH, CLASS_MW, CLASS_VEH_GROUND, CLASS_VTOL, correct_speed(), Destroyed, did_it(), discard_mw(), DOCHECK, Fallen, FaMechRange, FindTargetDBREFFromMapNumber(), getMap(), getMech(), GetMechID(), GetSectInt, GOD, HEAD, HIDDEN, In_Character, InLineOfSight(), IsDS, Jumping, LBUF_SIZE, loud_teleport, MarkForLOSUpdate(), mech_notify(), mech_parseattributes(), mech_Rsetmapindex(), mech_Rsetxy(), MECH_USUAL, MECHALL, MechCarrying, MechCritStatus, MechFullNoRecycle(), MechLOSBroadcast(), MechSpecials2, MechSpeed, MechStatus, MechTeam, MechTons, MechType, MechX, MechY, MechZ, MMaxSpeed, MP1, MECH::mynum, notify, OODing, PartIsDestroyed, PartIsNonfunctional, SBUF_SIZE, SetCarrying, Shutdown, Standing, Started, TELE_ALL, tele_contents(), TOWED, tprintf(), and unit_is_fixable().

Referenced by auto_command_embark().

00447 {
00448 
00449         MECH *mech = (MECH *) data;
00450         MECH *target, *towee = NULL;
00451         int tmp;
00452         dbref target_num;
00453         MAP *newmap;
00454         int argc;
00455         char *args[4];
00456         char fail_mesg[SBUF_SIZE];
00457         char enter_lock[LBUF_SIZE];
00458         int i, j;
00459 
00460         if(player != GOD)
00461                 cch(MECH_USUAL);
00462         if(MechType(mech) == CLASS_MW) {
00463                 argc = mech_parseattributes(buffer, args, 1);
00464                 DOCHECK(argc != 1, "Invalid number of arguements.");
00465                 target_num = FindTargetDBREFFromMapNumber(mech, args[0]);
00466                 DOCHECK(target_num == -1,
00467                                 "That target is not in your line of sight.");
00468                 target = getMech(target_num);
00469                 DOCHECK(!target ||
00470                                 !InLineOfSight(mech, target, MechX(target), MechY(target),
00471                                                            FaMechRange(mech, target)),
00472                                 "That target is not in your line of sight.");
00473                 DOCHECK(OODing(target), "You should wait for your target to land first");
00474                 DOCHECK(MechZ(mech) > (MechZ(target) + 1),
00475                                 "You are too high above the target.");
00476                 DOCHECK(MechZ(mech) < (MechZ(target) - 1),
00477                                 "You can't reach that high !");
00478                 DOCHECK(MechX(mech) != MechX(target) ||
00479                                 MechY(mech) != MechY(target),
00480                                 "You need to be in the same hex!");
00481                 DOCHECK((!In_Character(mech->mynum))
00482                                 || (!In_Character(target->mynum)),
00483                                 "You don't really see a way to get in there.");
00484                 DOCHECK((MechType(target) == CLASS_VEH_GROUND
00485                                  || MechType(target) == CLASS_VTOL)
00486                                 && !unit_is_fixable(target),
00487                                 "You can't find and entrance amid the mass of twisted metal.");
00488 
00489                 if(!can_pass_lock(mech->mynum, target->mynum, A_LENTER)) {
00490 
00491                         /* Trigger FAIL & AFAIL */
00492                         memset(fail_mesg, 0, sizeof(fail_mesg));
00493                         snprintf(fail_mesg, LBUF_SIZE,
00494                                          "That unit's bay doors are locked.");
00495 
00496                         did_it(player, target->mynum, A_FAIL, fail_mesg, 0, NULL, A_AFAIL,
00497                                    (char **) NULL, 0);
00498 
00499                         return;
00500                 }
00501 
00502                 /* They passed the lock but does that mean there was no lock? */
00503                 memset(enter_lock, 0, sizeof(enter_lock));
00504                 atr_get_str(enter_lock, target->mynum, A_LENTER, &i, &j);
00505                 if(*enter_lock == '\0') {
00506 
00507                         /* Check their teams */
00508                         DOCHECK(MechTeam(mech) != MechTeam(target), "Locked. Damn !");
00509                 }
00510 
00511                 DOCHECK(fabs(MechSpeed(target)) > 15.,
00512                                 "Are you suicidal ? That thing is moving too fast !");
00513 
00514                 if(MechType(target) == CLASS_MECH) {
00515                         DOCHECK(!GetSectInt(target, HEAD),
00516                                         "Okay, just climb up to-- Wait... where did the head go??");
00517                         DOCHECK(PartIsDestroyed(target, HEAD, 2),
00518                                         "Okay, just climb up and open-- "
00519                                         "WTF ? Someone stole the cockpit!");
00520                         DOCHECK(PartIsNonfunctional(target, HEAD, 2),
00521                                         "Okay, just climb up and open-- hey, this door won't budge!");
00522                 }
00523                 mech_notify(mech, MECHALL, tprintf("You climb into %s.",
00524                                                                                    GetMechID(target)));
00525                 MechLOSBroadcast(mech, tprintf("climbs into %s.", GetMechID(target)));
00526                 tele_contents(mech->mynum, target->mynum, TELE_ALL);
00527                 discard_mw(mech);
00528                 return;
00529         }
00530         /* What heppens with a Bsuit squad? */
00531         /* Check if the vechile has cargo capacity, or is an Omni Mech */
00532         argc = mech_parseattributes(buffer, args, 1);
00533         DOCHECK(argc != 1, "Invalid number of arguements.");
00534         target_num = FindTargetDBREFFromMapNumber(mech, args[0]);
00535         DOCHECK(target_num == -1, "That target is not in your line of sight.");
00536         target = getMech(target_num);
00537         DOCHECK(!target ||
00538                         !InLineOfSight(mech, target, MechX(target), MechY(target),
00539                                                    FaMechRange(mech, target)),
00540                         "That target is not in your line of sight.");
00541         DOCHECK(MechCarrying(mech) == target_num,
00542                         "You cannot embark what your towing!");
00543         DOCHECK(Fallen(mech)
00544                         || Standing(mech), "Help! I've fallen and I can't get up!");
00545         DOCHECK(!Started(mech) || Destroyed(mech), "Ha Ha Ha.");
00546         DOCHECK(Jumping(mech), "You cannot do that while jumping!");
00547         DOCHECK(Jumping(target), "You cannot do that while it is jumping!");
00548         DOCHECK(MechSpecials2(mech) & CARRIER_TECH
00549                         && (IsDS(target) ? IsDS(mech) : 1),
00550                         "You're a bit bulky to do that yourself.");
00551         DOCHECK(MechCritStatus(mech) & HIDDEN, "You cannot embark while hidden.");
00552         DOCHECK(MechTons(mech) > CarMaxTon(target),
00553                         "You are too large for that class of carrier.");
00554         DOCHECK(MechType(mech) != CLASS_BSUIT
00555                         && !(MechSpecials2(target) & CARRIER_TECH),
00556                         "This unit can't handle your mass.");
00557         DOCHECK(MMaxSpeed(mech) < MP1, "You are to overloaded to enter.");
00558         DOCHECK(MechZ(mech) > (MechZ(target) + 1),
00559                         "You are too high above the target.");
00560         DOCHECK(MechZ(mech) < (MechZ(target) - 1), "You can't reach that high !");
00561         DOCHECK(MechX(mech) != MechX(target) ||
00562                         MechY(mech) != MechY(target), "You need to be in the same hex!");
00563 
00564         if(!can_pass_lock(mech->mynum, target->mynum, A_LENTER)) {
00565 
00566                 /* Trigger FAIL & AFAIL */
00567                 memset(fail_mesg, 0, sizeof(fail_mesg));
00568                 snprintf(fail_mesg, LBUF_SIZE, "That unit's bay doors are locked.");
00569 
00570                 did_it(player, target->mynum, A_FAIL, fail_mesg, 0, NULL, A_AFAIL,
00571                            (char **) NULL, 0);
00572 
00573                 return;
00574         }
00575 
00576         /* They passed the lock but does that mean there was no lock? */
00577         memset(enter_lock, 0, sizeof(enter_lock));
00578         atr_get_str(enter_lock, target->mynum, A_LENTER, &i, &j);
00579         if(*enter_lock == '\0') {
00580 
00581                 /* Check their teams */
00582                 DOCHECK(MechTeam(mech) != MechTeam(target), "Locked. Damn !");
00583         }
00584 
00585         DOCHECK(fabs(MechSpeed(target)) > 0,
00586                         "Are you suicidal ? That thing is moving too fast !");
00587         DOCHECK(!In_Character(mech->mynum) || !In_Character(target->mynum),
00588                         "You don't really see a way to get in there.");
00589 
00590         /* New message system for when someone tries to embark
00591          * but their sections are still cycling (or weapons) */
00592         if((tmp = MechFullNoRecycle(mech, CHECK_BOTH))) {
00593 
00594                 if(tmp == 1) {
00595                         notify(player, "You have weapons recycling!");
00596                 } else if(tmp == 2) {
00597                         notify(player,
00598                                    "You are still recovering from your previous action!");
00599                 } else {
00600                         notify(player, "error");
00601                 }
00602                 return;
00603         }
00604 
00605         DOCHECK((MechTons(mech) * 100) > CargoSpace(target),
00606                         "Not enough cargospace for you!");
00607         if(MechCarrying(mech) > 0) {
00608                 DOCHECK(!(towee = getMech(MechCarrying(mech))),
00609                                 "Internal error caused by towed unit! Contact a wizard!");
00610                 DOCHECK(MechTons(towee) > CarMaxTon(target),
00611                                 "Your towed unit is  too large for that class of carrier.");
00612                 DOCHECK(((MechTons(mech) + MechTons(towee)) * 100) >
00613                                 CargoSpace(target),
00614                                 "Not enough cargospace for you and your towed unit!");
00615         }
00616         newmap = getMap(mech->mapindex);
00617         if(MechType(mech) == CLASS_BSUIT) {
00618                 mech_notify(mech, MECHALL,
00619                                         tprintf("You climb into %s.", GetMechID(target)));
00620                 MechLOSBroadcast(mech, tprintf("climbs into %s.", GetMechID(target)));
00621         } else {
00622                 mech_notify(mech, MECHALL,
00623                                         tprintf("You climb up the entry ramp into %s.",
00624                                                         GetMechID(target)));
00625                 MechLOSBroadcast(mech,
00626                                                  tprintf("climbs up the entry ramp into %s.",
00627                                                                  GetMechID(target)));
00628                 if(towee && MechCarrying(mech) > 0) {
00629                         mech_notify(towee, MECHALL,
00630                                                 tprintf("You are drug up the entry ramp into %s.",
00631                                                                 GetMechID(target)));
00632                         MechLOSBroadcast(towee,
00633                                                          tprintf("is drug up the entry ramp into %s.",
00634                                                                          GetMechID(target)));
00635                 }
00636         }
00637         MarkForLOSUpdate(mech);
00638         MarkForLOSUpdate(target);
00639 
00640         if(MechCritStatus(target) & HIDDEN) {
00641                 MechCritStatus(target) &= ~HIDDEN;
00642                 MechLOSBroadcast(target, "becomes visible as it is embarked into.");
00643         }
00644 
00645         /* Check if the unit is towing something so the towed unit
00646          * is handled first because Shutdown() will cause it to drop
00647          * whatever its towing */
00648         if(towee && MechCarrying(mech) > 0) {
00649                 MarkForLOSUpdate(towee);
00650                 mech_Rsetmapindex(GOD, (void *) towee, tprintf("%d", (int) -1));
00651                 mech_Rsetxy(GOD, (void *) towee, tprintf("%d %d", 0, 0));
00652                 loud_teleport(towee->mynum, target->mynum);
00653                 CargoSpace(target) -= (MechTons(towee) * 100);
00654                 Shutdown(towee);
00655                 SetCarrying(mech, -1);
00656                 MechStatus(towee) &= ~TOWED;
00657         }
00658 
00659         /* Now handle the unit itself */
00660         mech_Rsetmapindex(GOD, (void *) mech, tprintf("%d", (int) -1));
00661         mech_Rsetxy(GOD, (void *) mech, tprintf("%d %d", 0, 0));
00662         loud_teleport(mech->mynum, target->mynum);
00663         CargoSpace(target) -= (MechTons(mech) * 100);
00664         Shutdown(mech);
00665 
00666         correct_speed(target);
00667 }

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

Handle the disembarking of units from within carriers.

Definition at line 301 of file eject.c.

References A_PILOTNUM, CargoSpace, char_getskilltarget(), char_getvalue(), char_lookupplayer(), CLASS_BSUIT, CLASS_MECH, CLASS_MW, CLASS_VEH_GROUND, CLASS_VTOL, correct_speed(), DEFAULT_COMM, Destroyed, DOCHECK, Elevation, EvalBit, figure_latest_tech_event(), fix_pilotdamage(), FlyingT, getMap(), getMech(), GetMechID(), GOD, Good_obj, Hardcode, HIDDEN, In_Character, initiate_ood(), isPlayer, Landed, LANDED, Location, loud_teleport, MECH::mapindex, MarkForLOSUpdate(), mech_Rsetmapindex(), mech_Rsetxy(), MechComm, MechCommLast, MechCritStatus, MechFalls(), MechFZ, MechLOSBroadcast(), MechPer, MechPilot, MechSpecials, MechSpeed, MechStatus, MechTons, MechType, MechX, MechY, MechZ, MMaxSpeed, MECH::mynum, notify, NUM_SECTIONS, PHYSICAL_RECYCLE_TIME, Quiet, ROTOR, SetCargoWeight(), SetRecycleLimb, silly_atr_get(), SS_ABILITY, StartBSuitRecycle(), Started, Startup, tprintf(), UnSetMechPKiller, UnZombifyMech, WalkingSpeed, Wiz, and ZSCALE.

Referenced by auto_command_udisembark(), and DestroyMech().

00302 {
00303 
00304         MECH *mech = (MECH *) data;     /* The disembarking unit */
00305         MECH *target;
00306         int newmech;                            /* The carrier. */
00307         MAP *mymap;                                     /* The map to disembark to */
00308         int under_repairs;                      /* Is the unit still under repairs? */
00309         int i;                                          /* Used in section recycle for loop. */
00310 
00311         /* Any IN_CHARACTER unit's pilot must match the invoker to disembark.
00312          * A unit that is not IC can be disembarked by anyone.
00313          */
00314         DOCHECK(In_Character(mech->mynum) && !Wiz(player) &&
00315                         (char_lookupplayer(GOD, GOD, 0,
00316                                                            silly_atr_get(mech->mynum,
00317                                                                                          A_PILOTNUM)) != player),
00318                         "This isn't your mech!");
00319 
00320         /* Find the carrier that the invoker's unit is in and check it for validity. */
00321         newmech = Location(mech->mynum);
00322         DOCHECK(!(Good_obj(newmech) &&
00323                           Hardcode(newmech)), "You're not being carried!");
00324         DOCHECK(!(target = getMech(newmech)), "Not being carried!");
00325         DOCHECK(target->mapindex == -1, "You are not on a map.");
00326 
00327         /* Don't allow repairing units to disembark */
00328         under_repairs = figure_latest_tech_event(mech);
00329         DOCHECK(under_repairs,
00330                         "This 'Mech is still under repairs (see checkstatus for more info)");
00331 
00332         DOCHECK(abs(MechSpeed(target)) > WalkingSpeed(MMaxSpeed(target)),
00333                         "You cannot leave while the carrier is moving faster than walk speed!");
00334 
00335         /* Carry out the disembarking. */
00336         mech_Rsetmapindex(GOD, (void *) mech, tprintf("%d",
00337                                                                                                   (int) target->mapindex));
00338         mech_Rsetxy(GOD, (void *) mech, tprintf("%d %d", MechX(target),
00339                                                                                         MechY(target)));
00340         MechZ(mech) = MechZ(target);
00341         MechFZ(mech) = ZSCALE * MechZ(mech);
00342         mymap = getMap(mech->mapindex);
00343         DOCHECK(!mymap,
00344                         "Major map error possible. Prolly should contact a wizard.");
00345 
00346         /* Teleporting loudly in order to trigger @aenter's and whatnot. */
00347         loud_teleport(mech->mynum, mech->mapindex);
00348 
00349         /* If we make it safely, start the invoker's unit up once it's on the map. */
00350         if(!Destroyed(mech) && Location(player) == mech->mynum) {
00351                 MechPilot(mech) = player;
00352                 Startup(mech);
00353         }
00354 
00355         MarkForLOSUpdate(mech);
00356         SetCargoWeight(mech);
00357         UnSetMechPKiller(mech);
00358         MechLOSBroadcast(mech, "powers up!");
00359         EvalBit(MechSpecials(mech), SS_ABILITY, ((MechPilot(mech) > 0 &&
00360                                                                                           isPlayer(MechPilot(mech))) ?
00361                                                                                          char_getvalue(MechPilot(mech),
00362                                                                                                                    "Sixth_Sense") :
00363                                                                                          0));
00364         MechComm(mech) = DEFAULT_COMM;
00365 
00366         if(isPlayer(MechPilot(mech)) && !Quiet(mech->mynum)) {
00367                 MechComm(mech) =
00368                         char_getskilltarget(MechPilot(mech), "Comm-Conventional", 0);
00369                 MechPer(mech) = char_getskilltarget(MechPilot(mech), "Perception", 0);
00370         } else {
00371                 MechComm(mech) = 6;
00372                 MechPer(mech) = 6;
00373         }
00374         MechCommLast(mech) = 0;
00375         UnZombifyMech(mech);
00376         CargoSpace(target) += (MechTons(mech) * 100);
00377         MarkForLOSUpdate(target);
00378 
00379         /* A hidden carrier that is disembarked from loses its HIDDEN status */
00380         if(MechCritStatus(target) & HIDDEN) {
00381                 MechCritStatus(target) &= ~HIDDEN;
00382                 MechLOSBroadcast(target,
00383                                                  "becomes visible as it is disembarked from.");
00384         }
00385 
00386         /* Para-dropping out of units from elevations. */
00387         if(!FlyingT(mech) &&
00388            MechZ(mech) > Elevation(mymap, MechX(mech), MechY(mech)) &&
00389            MechZ(mech) > 0) {
00390 
00391                 notify(player, "You open the hatch and drop out of the unit....");
00392                 MechLOSBroadcast(mech,
00393                                                  tprintf
00394                                                  ("drops out of %s and begins falling to the ground.",
00395                                                   GetMechID(target)));
00396                 initiate_ood(player, mech,
00397                                          tprintf("%d %d %d", MechX(mech), MechY(mech),
00398                                                          MechZ(mech)));
00399         } else {
00400                 if(MechType(mech) == CLASS_BSUIT) {
00401                         MechLOSBroadcast(mech,
00402                                                          tprintf("climbs out of %s!", GetMechID(target)));
00403                         notify(player, "You climb out of the unit.");
00404                 } else {
00405                         /* If the carrier is destroyed, do damage to the disembarking unit. */
00406                         if(Destroyed(target) || !Started(target)) {
00407                                 MechLOSBroadcast(mech,
00408                                                                  tprintf
00409                                                                  ("smashes open the ramp door and emerges from %s!",
00410                                                                   GetMechID(target)));
00411                                 notify(player, "You smash open the door and break out.");
00412                                 MechFalls(mech, 4, 0);
00413                         } else {
00414                                 /* All is well. */
00415                                 MechLOSBroadcast(mech,
00416                                                                  tprintf("emerges from the ramp out of %s!",
00417                                                                                  GetMechID(target)));
00418                                 notify(player, "You emerge from the unit loading ramp.");
00419                                 if(Landed(mech)
00420                                    && MechZ(mech) > Elevation(mymap, MechX(mech), MechY(mech))
00421                                    && FlyingT(mech))
00422                                         MechStatus(mech) &= ~LANDED;
00423                         }
00424                 }
00425         }
00426 
00427         /* Recycle any weapons/sections they have to prevent munchkin behavior. */
00428         if(MechType(mech) == CLASS_BSUIT) {
00429                 StartBSuitRecycle(mech, 20);
00430         } else if(MechType(mech) == CLASS_MECH || MechType(mech) == CLASS_MW) {
00431                 for(i = 0; i < NUM_SECTIONS; i++)
00432                         SetRecycleLimb(mech, i, PHYSICAL_RECYCLE_TIME);
00433         } else if(MechType(mech) == CLASS_VEH_GROUND
00434                           || MechType(mech) == CLASS_VTOL) {
00435                 for(i = 0; i < NUM_SECTIONS; i++)
00436                         if(i == ROTOR)
00437                                 continue;
00438                         else
00439                                 SetRecycleLimb(mech, i, PHYSICAL_RECYCLE_TIME);
00440         }
00441 
00442         fix_pilotdamage(mech, MechPilot(mech));
00443         correct_speed(target);
00444 }                                                               /* end mech_udisembark */

void pickup_mw ( MECH mech,
MECH target 
)

Definition at line 86 of file eject.c.

References CLASS_MECH, CLASS_VEH_GROUND, CLASS_VTOL, Contents, discard_mw(), DOCHECKMA, GetMechID(), GetMechToMechID(), mech_printf(), MECHALL, MechLOSBroadcast(), MechSpecials, MechTeam, MechType, MECH::mynum, notify_printf(), SALVAGE_TECH, TELE_ALL, tele_contents(), TELE_SLAVE, and tprintf().

Referenced by mech_pickup().

00087 {
00088         dbref mw;
00089 
00090         mw = Contents(target->mynum);
00091         DOCHECKMA((MechType(mech) != CLASS_MECH) &&
00092                           (MechType(mech) != CLASS_VEH_GROUND) &&
00093                           (MechType(mech) != CLASS_VTOL) &&
00094                           !(MechSpecials(mech) & SALVAGE_TECH),
00095                           "You can't pick up, period.") if(mw > 0)
00096                 notify_printf(mw,
00097                                           "%s scoops you up and brings you into the cockpit.",
00098                                           GetMechToMechID(target, mech));
00099         /* Put the player in the picker uppper and clear him from the map */
00100         MechLOSBroadcast(mech, tprintf("picks up %s.", GetMechID(target)));
00101         mech_printf(mech, MECHALL,
00102                                 "You pick up the stray mechwarrior from the field.");
00103         if(MechTeam(target) != MechTeam(mech))
00104                 tele_contents(target->mynum, mech->mynum, TELE_ALL | TELE_SLAVE);
00105         else
00106                 tele_contents(target->mynum, mech->mynum, TELE_ALL);
00107         discard_mw(target);
00108 }

int tele_contents ( dbref  from,
dbref  to,
int  flag 
)

Definition at line 38 of file eject.c.

References A_LOCK, confdata::btech_xploss, Contents, hush_teleport, loud_teleport, lower_xp(), mudconf, s_Slave, SAFE_DOLIST, silly_atr_set(), TELE_ALL, TELE_LOUD, TELE_SLAVE, TELE_XP, and Wiz.

Referenced by enter_mw_bay(), KillMechContentsIfIC(), mech_embark(), and pickup_mw().

00039 {
00040         dbref i, tmpnext;
00041         int count = 0;
00042 
00043         SAFE_DOLIST(i, tmpnext, Contents(from))
00044                 if((flag & TELE_ALL) || !Wiz(i)) {
00045                 if((flag & TELE_SLAVE) && !Wiz(i)) {
00046                         s_Slave(i);
00047                         silly_atr_set(i, A_LOCK, "");
00048                 }
00049                 if(flag & TELE_XP && !Wiz(i))
00050                         lower_xp(i, mudconf.btech_xploss);
00051                 if(flag & TELE_LOUD)
00052                         loud_teleport(i, to);
00053                 else
00054                         hush_teleport(i, to);
00055                 count++;
00056         }
00057         return count;
00058 }


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