int calcWeatherPilotEffects(MECH * mech) { MAP *map = FindObjectsData(mech->mapindex); int onTheGround = 1; int mod = 0; if (!map) return 0; onTheGround = (!Jumping(mech) && (MechZ(mech) <= Elevation(map, MechX(mech), MechY(mech)))); if (onTheGround) { if ((MapEffectHvyRain(map) || MapEffectHvySnow(map) || MapEffectHighWinds(map) || MapEffectBlizzard(map))) mod += 1; if (MechMove(mech) != MOVE_HOVER) { if (HexHasDeepSnow(map, MechX(mech), MechY(mech))) mod += 1; if (HexHasMud(map, MechX(mech), MechY(mech))) mod += 1; if (HexHasRapids(map, MechX(mech), MechY(mech))) mod += 2; } return mod; } return 0; }
void check_stagger_event(EVENT * event) { MECH *mech = (MECH *) event->data; /* get the mech */ SendDebug(tprintf("Triggered stagger check for %d.", mech->mynum)); if ((StaggerLevel(mech) < 1) || Fallen(mech) || (MechType(mech) != CLASS_MECH)) { StopStaggerCheck(mech); return; } if (Jumping(mech)) { return; } mech_notify(mech, MECHALL, "You stagger from the damage!"); if (!MadePilotSkillRoll(mech, calcStaggerBTHMod(mech))) { mech_notify(mech, MECHALL, "You loose the battle with gravity and tumble over!!"); MechLOSBroadcast(mech, "tumbles over, staggered by the damage!"); MechFalls(mech, 1, 0); } StopStaggerCheck(mech); }
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 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); }
////////////////////////////////////////////////////////////////////////// // // Class Logical // Expr* Logical::Gen() { int f = NewLabel(); int a = NewLabel(); Temp* temp = new Temp( m_pType ); Jumping( -1, f ); char code[ 30 ]; Emit( temp->ToString() + " = true" ); sprintf_s( code, "goto L%d", a ); Emit( code ); EmitLabel( f ); sprintf_s( code, "goto L%d", a ); EmitLabel( a ); return temp; }
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); } }
void Character::Update() { //Ai module for character if (aiEnabled_) { if (GetCurrentPositionX() - GetMoveSpeedDelta() <= 0) { SetKeyRight(true); SetKeyLeft(false); } else if (GetCurrentPositionX() + GetWidth() + GetMoveSpeedDelta() >= mapWidth_) { SetKeyLeft(true); SetKeyRight(false); } if (KeyRight_) { CollisionMovingRight(); } else if (KeyLeft_) { CollisionMovingLeft(); } //Characters forever in a state of falling? if (GetCharacterYAxisState() == CHARACTERYAXISSTATES::CHARACTERFALLING || GetCharacterYAxisState() == CHARACTERYAXISSTATES::CHARACTERONGROUND) { Falling(); } else if (GetCharacterYAxisState() == CHARACTERYAXISSTATES::CHARACTERJUMPING) { Jumping(); } } }
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); }
static int load_update1(void *key, void *data, int depth, void *arg) { const dbref key_val = (dbref)key; XCODE *const xcode_obj = data; FILE *const fp = arg; MAP *map; int doh; char mapbuffer[MBUF_SIZE]; MECH *mech; int i; int ctemp; switch (xcode_obj->type) { case GTYPE_MAP: map = (MAP *)xcode_obj; memset(map->mapobj, 0, sizeof(map->mapobj)); map->map = NULL; strcpy(mapbuffer, map->mapname); doh = (map->flags & MAPFLAG_MAPO); if(strcmp(map->mapname, "Default Map")) map_loadmap(1, map, mapbuffer); if(!strcmp(map->mapname, "Default Map") || !map->map) initialize_map_empty(map, key_val); if(!feof(fp)) { load_mapdynamic(fp, map); if(!feof(fp)) if(doh) load_mapobjs(fp, map); } if(feof(fp)) { map->first_free = 0; map->mechflags = NULL; map->mechsOnMap = NULL; map->LOSinfo = NULL; } debug_fixmap(GOD, map, NULL); break; case GTYPE_MECH: mech = (MECH *)xcode_obj; if(!(FlyingT(mech) && !Landed(mech))) { MechDesiredSpeed(mech) = 0; MechSpeed(mech) = 0; MechVerticalSpeed(mech) = 0; } ctemp = MechCocoon(mech); if(MechCocoon(mech)) { MechCocoon(mech) = 0; initiate_ood((dbref) GOD, mech, tprintf("%d %d %d", MechX(mech), MechY(mech), MechZ(mech))); MechCocoon(mech) = ctemp; } if(!FlyingT(mech) && Started(mech) && Jumping(mech)) mech_Rsetxy(GOD, (void *) mech, tprintf("%d %d", MechX(mech),MechY(mech))); MechStatus(mech) &= ~(BLINDED | UNCONSCIOUS | JUMPING | TOWED); MechSpecials2(mech) &= ~(ECM_ENABLED | ECM_DISTURBANCE | ECM_PROTECTED | ECCM_ENABLED | ANGEL_ECM_ENABLED | ANGEL_ECCM_ENABLED | ANGEL_ECM_PROTECTED | ANGEL_ECM_DISTURBED); MechCritStatus(mech) &= ~(JELLIED | LOAD_OK | OWEIGHT_OK | SPEED_OK); MechWalkXPFactor(mech) = 999; MechCarrying(mech) = -1; MechBoomStart(mech) = 0; MechC3iNetworkSize(mech) = -1; MechHeatLast(mech) = 0; MechCommLast(mech) = 0; // ClearStaggerDamage mech->rd.staggerDamageList = NULL; if(!(MechXPMod(mech))) MechXPMod(mech) = 1; for(i = 0; i < FREQS; i++) if(mech->freq[i] < 0) mech->freq[i] = 0; break; } return 1; }
int run_test_case(int casenum__) { switch (casenum__) { case 0: { int x = 5; int y = 4; int jumpLengths[] = {2, 5}; string expected__ = "Able"; clock_t start__ = clock(); string received__ = Jumping().ableToGet(x, y, vector <int>(jumpLengths, jumpLengths + (sizeof jumpLengths / sizeof jumpLengths[0]))); return verify_case(casenum__, expected__, received__, clock()-start__); } case 1: { int x = 3; int y = 4; int jumpLengths[] = {4}; string expected__ = "Not able"; clock_t start__ = clock(); string received__ = Jumping().ableToGet(x, y, vector <int>(jumpLengths, jumpLengths + (sizeof jumpLengths / sizeof jumpLengths[0]))); return verify_case(casenum__, expected__, received__, clock()-start__); } case 2: { int x = 3; int y = 4; int jumpLengths[] = {6}; string expected__ = "Not able"; clock_t start__ = clock(); string received__ = Jumping().ableToGet(x, y, vector <int>(jumpLengths, jumpLengths + (sizeof jumpLengths / sizeof jumpLengths[0]))); return verify_case(casenum__, expected__, received__, clock()-start__); } case 3: { int x = 0; int y = 1; int jumpLengths[] = {100, 100}; string expected__ = "Able"; clock_t start__ = clock(); string received__ = Jumping().ableToGet(x, y, vector <int>(jumpLengths, jumpLengths + (sizeof jumpLengths / sizeof jumpLengths[0]))); return verify_case(casenum__, expected__, received__, clock()-start__); } case 4: { int x = 300; int y = 400; int jumpLengths[] = {500}; string expected__ = "Able"; clock_t start__ = clock(); string received__ = Jumping().ableToGet(x, y, vector <int>(jumpLengths, jumpLengths + (sizeof jumpLengths / sizeof jumpLengths[0]))); return verify_case(casenum__, expected__, received__, clock()-start__); } case 5: { int x = 11; int y = 12; int jumpLengths[] = {1,2,3,4,5,6,7,8,9,10}; string expected__ = "Able"; clock_t start__ = clock(); string received__ = Jumping().ableToGet(x, y, vector <int>(jumpLengths, jumpLengths + (sizeof jumpLengths / sizeof jumpLengths[0]))); return verify_case(casenum__, expected__, received__, clock()-start__); } case 6: { int x = 11; int y = 12; int jumpLengths[] = {1,2,3,4,5,6,7,8,9,100}; string expected__ = "Not able"; clock_t start__ = clock(); string received__ = Jumping().ableToGet(x, y, vector <int>(jumpLengths, jumpLengths + (sizeof jumpLengths / sizeof jumpLengths[0]))); return verify_case(casenum__, expected__, received__, clock()-start__); } // custom cases case 7: { int x = 1; int y = 0; int jumpLengths[] = {100, 101}; string expected__ = "Able"; clock_t start__ = clock(); string received__ = Jumping().ableToGet(x, y, vector <int>(jumpLengths, jumpLengths + (sizeof jumpLengths / sizeof jumpLengths[0]))); return verify_case(casenum__, expected__, received__, clock()-start__); } case 8: { int x = 10; int y = 10; int jumpLengths[] = {1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000}; string expected__ = "Able"; clock_t start__ = clock(); string received__ = Jumping().ableToGet(x, y, vector <int>(jumpLengths, jumpLengths + (sizeof jumpLengths / sizeof jumpLengths[0]))); return verify_case(casenum__, expected__, received__, clock()-start__); } /* case 9: { int x = ; int y = ; int jumpLengths[] = ; string expected__ = ; clock_t start__ = clock(); string received__ = Jumping().ableToGet(x, y, vector <int>(jumpLengths, jumpLengths + (sizeof jumpLengths / sizeof jumpLengths[0]))); return verify_case(casenum__, expected__, received__, clock()-start__); }*/ default: return -1; } }