void mech_move_event(EVENT * e) { MECH *mech = (MECH *) e->data; if (MechType(mech) == CLASS_VTOL) if (Landed(mech) || FuelCheck(mech)) return; UpdateHeading(mech); if ((IsMechLegLess(mech)) || Jumping(mech) || OODing(mech)) { if (MechDesiredFacing(mech) != MechFacing(mech)) MECHEVENT(mech, EVENT_MOVE, mech_move_event, MOVE_TICK, 0); return; } UpdateSpeed(mech); move_mech(mech); if (mech->mapindex < 0) return; if (MechType(mech) == CLASS_VEH_NAVAL && MechRTerrain(mech) != BRIDGE && MechRTerrain(mech) != ICE && MechRTerrain(mech) != WATER) return; if (MechSpeed(mech) || MechDesiredSpeed(mech) || MechDesiredFacing(mech) != MechFacing(mech) || ((MechType(mech) == CLASS_VTOL || MechMove(mech) == MOVE_SUB) && MechVerticalSpeed(mech))) MECHEVENT(mech, EVENT_MOVE, mech_move_event, MOVE_TICK, 0); }
void ProlongUncon(MECH * mech, int len) { int l; if (Destroyed(mech)) return; if (!Recovering(mech)) { MechStatus(mech) |= UNCONSCIOUS; MECHEVENT(mech, EVENT_RECOVERY, mech_recovery_event, len, 0); return; } l = event_last_type_data(EVENT_RECOVERY, (void *) mech) + len; event_remove_type_data(EVENT_RECOVERY, (void *) mech); MECHEVENT(mech, EVENT_RECOVERY, mech_recovery_event, l, 0); }
void mech_fall_event(EVENT * e) { MECH *mech = (MECH *) e->data; int fallspeed = (int) e->data2; int fallen_elev; if (Started(mech) && fallspeed >= 0) return; if (fallspeed <= 0 && (!Started(mech) || !(FlyingT(mech)) || ((AeroFuel(mech) <= 0) && !AeroFreeFuel(mech)) || ((MechType(mech) == CLASS_VTOL) && (SectIsDestroyed(mech, ROTOR))))) fallspeed -= FALL_ACCEL; else fallspeed += FALL_ACCEL; MarkForLOSUpdate(mech); if (MechsElevation(mech) > abs(fallspeed)) { MechZ(mech) -= abs(fallspeed); MechFZ(mech) = MechZ(mech) * ZSCALE; MECHEVENT(mech, EVENT_FALL, mech_fall_event, FALL_TICK, fallspeed); return; } /* Time to hit da ground */ fallen_elev = factoral(abs(fallspeed)); mech_notify(mech, MECHALL, "You hit the ground!"); MechLOSBroadcast(mech, "hits the ground!"); MechFalls(mech, fallen_elev, 0); MechStatus(mech) &= ~JUMPING; }
void mech_plos_event(EVENT * e) { MECH *mech = (MECH *) e->data, *target; MAP *map; int mapvis; int maplight; float range; int i; if (!Started(mech)) return; if (!(map = getMap(mech->mapindex))) return; MECHEVENT(mech, EVENT_PLOS, mech_plos_event, PLOS_TICK, 0); if (!MechPNumSeen(mech) && !(MechSpecials(mech) & AA_TECH)) return; mapvis = map->mapvis; maplight = map->maplight; MechPNumSeen(mech) = 0; for (i = 0; i < map->first_free; i++) if (map->mechsOnMap[i] > 0 && map->mechsOnMap[i] != mech->mynum) if (!(map->LOSinfo[mech->mapnumber][i] & MECHLOSFLAG_SEEN)) { target = FindObjectsData(map->mechsOnMap[i]); if (!target) continue; range = FlMechRange(map, mech, target); MechPNumSeen(mech)++; Sensor_DoWeSeeNow(mech, &map->LOSinfo[mech->mapnumber][i], range, -1, -1, target, mapvis, maplight, map->cloudbase, 1, 0); } }
void FailureRadioShort(MECH * mech, int weapnum, int weaptype, int section, int critical, int roll, int *modifier, int *type) { MECHEVENT(mech, EVENT_MRECOVERY, mech_rrec_event, Number(30, Number(40, 200)), (int) MechRadioRange(mech)); MechRadioRange(mech) = 0; }
void mech_jump_event(EVENT * e) { MECH *mech = (MECH *) e->data; MECHEVENT(mech, EVENT_JUMP, mech_jump_event, JUMP_TICK, 0); move_mech(mech); if (!Jumping(mech)) StopJump(mech); }
void FailureRadioRange(MECH * mech, int weapnum, int weaptype, int section, int critical, int roll, int *modifier, int *type) { int mod = failures[GetBrandIndex(-2) + roll - 1].data; mod = MIN(MechRadioRange(mech) - 1, mod); MECHEVENT(mech, EVENT_MRECOVERY, mech_rrec_event, Number(30, Number(40, 200)), (int) mod); MechRadioRange(mech) -= mod; }
void aero_move_event(EVENT * e) { MECH *mech = (MECH *) e->data; if (!Landed(mech)) { /* Returns 1 only if we 1) Ran out of fuel, and 2) Were VTOL, and 3) Crashed */ if (FuelCheck(mech)) return; /* Genuine CHEAT :-) */ if (Started(mech)) { aero_UpdateHeading(mech); aero_UpdateSpeed(mech); } if (Fallen(mech)) MechStartFZ(mech) = MechStartFZ(mech) - 1; move_mech(mech); if (IsDS(mech) && MechZ(mech) <= (MechElevation(mech) + 5) && ((event_tick / WEAPON_TICK) % 10) == 0) DS_BlastNearbyMechsAndTrees(mech, "You are hit by the DropShip's plasma exhaust!", "is hit directly by DropShip's exhaust!", "You are hit by the DropShip's plasma exhaust!", "is hit by DropShip's exhaust!", "light up and burn.", 8); MECHEVENT(mech, EVENT_MOVE, aero_move_event, MOVE_TICK, 0); } else if (Landed(mech) && !Fallen(mech) && RollingT(mech)) { UpdateHeading(mech); UpdateSpeed(mech); move_mech(mech); if (fabs(MechSpeed(mech)) > 0.0 || fabs(MechDesiredSpeed(mech)) > 0.0 || MechDesiredFacing(mech) != MechFacing(mech)) if (!FuelCheck(mech)) MECHEVENT(mech, EVENT_MOVE, aero_move_event, MOVE_TICK, 0); } }
void MaybeRecycle(MECH * mech, int wticks) { int nr, dat; if (!(Started(mech) && !Destroyed(mech))) return; nr = NextRecycle(mech); UpdateRecycling(mech); if (nr < 0) MechLWRT(mech) = event_tick; if (nr < 0 || nr > ((wticks + 1) * WEAPON_TICK)) { dat = MAX(1, wticks * WEAPON_TICK); MECHEVENT(mech, EVENT_RECYCLE, mech_recycle_event, dat, 0); #ifdef WEAPON_RECYCLE_DEBUG SendDebug(tprintf("%6d Recycle event for #%d set in %ds.", event_tick, mech->mynum, dat)); #endif } #ifdef WEAPON_RECYCLE_DEBUG else SendDebug(tprintf("%6d Recycle event for #%d exists at %d secs", event_tick, mech->mynum, nr)); #endif }
void FailureComputerScanner(MECH * mech, int weapnum, int weaptype, int section, int critical, int roll, int *modifier, int *type) { int tmp = failures[GetBrandIndex(-1) + roll - 1].data; switch (tmp) { case 1: MECHEVENT(mech, EVENT_MRECOVERY, mech_srec_event, Number(30, Number(40, 200)), (int) MechTacRange(mech)); MechTacRange(mech) = 0; break; case 2: MECHEVENT(mech, EVENT_MRECOVERY, mech_srec_event, Number(30, Number(40, 200)), MechLRSRange(mech) + 256); MechLRSRange(mech) = 0; break; case 4: MECHEVENT(mech, EVENT_MRECOVERY, mech_srec_event, Number(30, Number(40, 200)), MechScanRange(mech) + 512); MechScanRange(mech) = 0; break; case 7: MECHEVENT(mech, EVENT_MRECOVERY, mech_srec_event, Number(30, Number(40, 200)), (int) MechTacRange(mech)); MECHEVENT(mech, EVENT_MRECOVERY, mech_srec_event, Number(30, Number(40, 200)), MechLRSRange(mech) + 256); MECHEVENT(mech, EVENT_MRECOVERY, mech_srec_event, Number(30, Number(40, 200)), MechScanRange(mech) + 512); MechTacRange(mech) = 0; MechLRSRange(mech) = 0; MechScanRange(mech) = 0; break; } }
void mech_enterbay(dbref player, void *data, char *buffer) { char *args[3]; int argc; dbref ref = -1, bayn = -1; MECH *mech = data, *ds; MAP *map; cch(MECH_USUAL); DOCHECK(MechType(mech) == CLASS_VTOL && AeroFuel(mech) <= 0, "You lack fuel to maneuver in!"); DOCHECK(Jumping(mech), "While in mid-jump? No way."); DOCHECK(MechType(mech) == CLASS_MECH && (Fallen(mech) || Standing(mech)), "Crawl inside? I think not. Stand first."); DOCHECK(OODing(mech), "While in mid-flight? No way."); DOCHECK((argc = mech_parseattributes(buffer, args, 2)) == 2, "Hmm, invalid number of arguments?"); if(argc > 0) DOCHECK((ref = FindTargetDBREFFromMapNumber(mech, args[0])) <= 0, "Invalid target!"); if(ref < 0) { DOCHECK(!Find_Single_DS_In_MechHex(mech, &ref, &bayn), "No DS bay found in your hex!"); DOCHECK(ref < 0, "Multiple enterable things found ; use the id for specifying which you want."); DOCHECK(!(ds = getMech(ref)), "You sense wrongness in fabric of space."); } else { DOCHECK(!(ds = getMech(ref)), "You sense wrongness in fabric of space."); DOCHECK(!Find_DS_Bay_In_MechHex(mech, ds, &bayn), "You see no bays in your hex."); } DOCHECK(IsDS(mech) && !(MechSpecials2(mech) & CARRIER_TECH), "Your craft can't enter bays."); DOCHECK(!DS_Bay_Is_Open(mech, ds, AeroBay(ds, bayn)), "The door has been jammed!"); DOCHECK(IsDS(mech), "Your unit is a bit too large to fit in there."); DOCHECK((fabs((float) (MechSpeed(mech) - MechSpeed(ds)))) > MP1, "Speed difference's too large to enter!"); DOCHECK(MechZ(ds) != MechZ(mech), "Get to same elevation before thinking about entering!"); DOCHECK(abs(MechVerticalSpeed(mech) - MechVerticalSpeed(ds)) > 10, "Vertical speed difference is too great to enter safely!"); DOCHECK(MechType(mech) == CLASS_MECH && !MechIsQuad(mech) && (IsMechLegLess(mech)), "Without legs? Are you kidding?"); ref = AeroBay(ds, bayn); map = getMap(ref); DOCHECK(!map, "You sense wrongness in fabric of space."); DOCHECK(EnteringHangar(mech), "You are already entering the hangar!"); if(!can_pass_lock(mech->mynum, ref, A_LENTER)) { char *msg = silly_atr_get(ref, A_FAIL); if(!msg || !*msg) msg = "You are unable to enter the bay!"; notify(player, msg); return; } DOCHECK(!DS_Bay_Is_EnterOK(mech, ds, AeroBay(ds, bayn)), "Someone else is using the door at the moment."); DOCHECK(!(map = getMap(mech->mapindex)), "You sense a wrongness in fabric of space."); HexLOSBroadcast(map, MechX(mech), MechY(mech), "The bay doors at $h start to open.."); MECHEVENT(mech, EVENT_ENTER_HANGAR, mech_enterbay_event, 12, ref); }