void mech_recovery_event(EVENT * e) { MECH *mech = (MECH *) e->data; if (Destroyed(mech) || !Uncon(mech)) return; if (handlemwconc(mech, 0)) { MechStatus(mech) &= ~UNCONSCIOUS; mech_notify(mech, MECHALL, "The pilot regains consciousness!"); return; } }
static void mech_enterbay_event(MUXEVENT * e) { MECH *mech = (MECH *) e->data, *ds, *tmpm = NULL; long ref = (long) e->data2; long bayn; int x = 5, y = 5; MAP *tmpmap; if(!Started(mech) || Uncon(mech) || Jumping(mech) || (MechType(mech) == CLASS_MECH && (Fallen(mech) || Standing(mech))) || OODing(mech) || (fabs(MechSpeed(mech)) * 5 >= MMaxSpeed(mech) && fabs(MMaxSpeed(mech)) >= MP1) || (MechType(mech) == CLASS_VTOL && AeroFuel(mech) <= 0)) return; tmpmap = getMap(ref); if(!(ds = getMech(tmpmap->onmap))) return; if(!Find_DS_Bay_In_MechHex(mech, ds, &bayn)) return; /* whee */ ref = AeroBay(ds, bayn); StopBSuitSwarmers(FindObjectsData(mech->mapindex), mech, 1); mech_notify(mech, MECHALL, "You enter the bay."); MechLOSBroadcast(mech, tprintf("has entered %s at %d,%d.", GetMechID(ds), MechX(mech), MechY(mech))); MarkForLOSUpdate(mech); if(MechType(mech) == CLASS_MW && !In_Character(ref)) { enter_mw_bay(mech, ref); return; } if(MechCarrying(mech) > 0) tmpm = getMech(MechCarrying(mech)); mech_Rsetmapindex(GOD, (void *) mech, tprintf("%d", ref)); mech_Rsetxy(GOD, (void *) mech, tprintf("%d %d", x, y)); MechLOSBroadcast(mech, "has entered the bay."); loud_teleport(mech->mynum, ref); if(tmpm) { mech_Rsetmapindex(GOD, (void *) tmpm, tprintf("%d", ref)); mech_Rsetxy(GOD, (void *) tmpm, tprintf("%d %d", x, y)); loud_teleport(tmpm->mynum, ref); } }
MECH *getOtherMechInNetwork(MECH * mech, int wIdx, int tCheckECM, int tCheckStarted, int tCheckUncon, int tIsC3) { MECH *tempMech; dbref refOtherMech; int networkSize; networkSize = (tIsC3 ? MechC3NetworkSize(mech) : MechC3iNetworkSize(mech)); if((wIdx >= networkSize) || (wIdx < 0)) return NULL; refOtherMech = (tIsC3 ? MechC3NetworkElem(mech, wIdx) : MechC3iNetworkElem(mech, wIdx)); if(refOtherMech > 0) { tempMech = getMech(refOtherMech); if(!tempMech) return NULL; if(MechTeam(tempMech) != MechTeam(mech)) return NULL; if(tempMech->mapindex != mech->mapindex) return NULL; if(Destroyed(tempMech)) return NULL; if(tIsC3) { if(!HasC3(tempMech)) /* Sanity check */ return NULL; if(C3Destroyed(tempMech)) return NULL; } else { if(!HasC3i(tempMech)) /* Sanity check */ return NULL; if(C3iDestroyed(tempMech)) return NULL; } if(tCheckECM) if(AnyECMDisturbed(tempMech)) return NULL; if(tCheckStarted) if(!Started(tempMech)) return NULL; if(tCheckUncon) if(Uncon(tempMech)) return NULL; return tempMech; } return NULL; }
void mech_unjam_ammo_event(EVENT * objEvent) { MECH *objMech = (MECH *) objEvent->data; /* get the mech */ int wWeapNum = (int) objEvent->data2; /* and now the weapon number */ int wSect, wSlot, wWeapStatus, wWeapIdx; int ammoLoc, ammoCrit, ammoLeft; int wRoll = 0; int wRollNeeded = 0; if (Uncon(objMech) || !Started(objMech)) return; wWeapStatus = FindWeaponNumberOnMech(objMech, wWeapNum, &wSect, &wSlot); if (wWeapStatus == TIC_NUM_DESTROYED) /* return if the weapon has been destroyed */ return; wWeapIdx = FindWeaponIndex(objMech, wWeapNum); ammoLeft = FindAmmoForWeapon_sub(objMech, wSect, wSlot, wWeapIdx, 0, &ammoLoc, &ammoCrit, 0, 0); if (!ammoLeft) { SetPartTempNuke(objMech, wSect, wSlot, 0); mech_notify(objMech, MECHALL, tprintf ("You finish bouncing around and realize you nolonger have ammo for your %s!", get_parts_long_name(I2Weapon(wWeapIdx), 0))); return; } if (MechWeapons[wWeapStatus].special & RAC) { wRoll = Roll(); wRollNeeded = FindPilotGunnery(objMech, wWeapStatus) + 3; mech_notify(objMech, MECHPILOT, "You make a roll to unjam the weapon!"); mech_notify(objMech, MECHPILOT, tprintf("Modified Gunnery Skill: BTH %d\tRoll: %d", wRollNeeded, wRoll)); if (wRoll < wRollNeeded) { mech_notify(objMech, MECHALL, "Your attempt to remove the jammed slug fails. You'll need to try again to clear it."); return; } } else { if (!MadePilotSkillRoll(objMech, 0)) { mech_notify(objMech, MECHALL, "Your attempt to remove the jammed slug fails. You'll need to try again to clear it."); return; } } SetPartTempNuke(objMech, wSect, wSlot, 0); mech_notify(objMech, MECHALL, tprintf("You manage to clear the jam on your %s!", get_parts_long_name(I2Weapon(wWeapIdx), 0))); MechLOSBroadcast(objMech, "ejects a mangled shell!"); SetPartData(objMech, ammoLoc, ammoCrit, GetPartData(objMech, ammoLoc, ammoCrit) - 1); }