// ----------------------------------------------------------------------------- // Called when control center gets destroyed. // This code is common to whether control center is implicitly imbedded in a boss, // or is an CObject of its own. // if objP == NULL that means the boss was the control center and don't set gameData.reactor.nDeadObj void DoReactorDestroyedStuff (CObject *objP) { int i, bFinalCountdown, bReactor = objP && (objP->info.nType == OBJ_REACTOR); CTrigger *trigP = NULL; if ((gameData.app.nGameMode & GM_MULTI_ROBOTS) && gameData.reactor.bDestroyed) return; // Don't allow resetting if control center and boss on same level // Must toggle walls whether it is a boss or control center. if ((!objP || (objP->info.nType == OBJ_ROBOT)) && gameStates.gameplay.bKillBossCheat) return; // And start the countdown stuff. bFinalCountdown = !(gameStates.app.bD2XLevel && gameStates.gameplay.bMultiBosses && extraGameInfo [0].nBossCount); if (bFinalCountdown || (gameStates.app.bD2XLevel && bReactor && (trigP = FindObjTrigger (objP->Index (), TT_COUNTDOWN, -1)))) { // If a secret level, delete secret.sgc to indicate that we can't return to our secret level. if (bFinalCountdown) { if (extraGameInfo [0].nBossCount) KillAllBossRobots (0); for (i = 0; i < gameData.reactor.triggers.nLinks; i++) SEGMENTS [gameData.reactor.triggers.segments [i]].ToggleWall (gameData.reactor.triggers.sides [i]); if (gameData.missions.nCurrentLevel < 0) CFile::Delete ("secret.sgc", gameFolders.szSaveDir); } InitCountdown (trigP, bFinalCountdown, -1); } if (bReactor) { ExecObjTriggers (objP->Index (), 0); if (0 <= (i = FindReactor (objP))) { gameData.reactor.states [i].nDeadObj = objP->Index (); gameStates.gameplay.nReactorCount [0]--; } } }
// ----------------------------------------------------------------------------- // Called when control center gets destroyed. // This code is common to whether control center is implicitly imbedded in a boss, // or is an tObject of its own. // if objP == NULL that means the boss was the control center and don't set gameData.reactor.nDeadObj void DoReactorDestroyedStuff (tObject *objP) { int i, bFinalCountdown, bReactor = objP && (objP->nType == OBJ_CNTRLCEN); tTrigger *trigP = NULL; if ((gameData.app.nGameMode & GM_MULTI_ROBOTS) && gameData.reactor.bDestroyed) return; // Don't allow resetting if control center and boss on same level // Must toggle walls whether it is a boss or control center. for (i = 0; i < gameData.reactor.triggers.nLinks; i++) WallToggle (gameData.segs.segments + gameData.reactor.triggers.nSegment [i], gameData.reactor.triggers.nSide [i]); if ((!objP || (objP->nType == OBJ_ROBOT)) && gameStates.gameplay.bKillBossCheat) return; // And start the countdown stuff. bFinalCountdown = !(gameStates.app.bD2XLevel && gameStates.gameplay.bMultiBosses && extraGameInfo [0].nBossCount); if (bFinalCountdown || (gameStates.app.bD2XLevel && bReactor && (trigP = FindObjTrigger (OBJ_IDX (objP), TT_COUNTDOWN, -1)))) { // If a secret level, delete secret.sgc to indicate that we can't return to our secret level. if (bFinalCountdown) if (gameData.missions.nCurrentLevel < 0) CFDelete ("secret.sgc", gameFolders.szSaveDir); InitCountdown (trigP, bFinalCountdown || bReactor); } if (bReactor) { ExecObjTriggers (OBJ_IDX (objP), 0); if (0 <= (i = FindReactor (objP))) { gameData.reactor.states [i].nDeadObj = OBJ_IDX (objP); gameStates.gameplay.nReactorCount--; } } }
void Init(void) { __disable_interrupt(); ENABLE_LCD_LED(); DISABLE_LCD_POWER(); /* clear shipping mode, if set to allow configuration */ PMMCTL0_H = PMMPW_H; PM5CTL0 &= ~LOCKLPM5; PMMCTL0_H = 0x00; /* disable DMA during read-modify-write cycles */ DMACTL4 = DMARMWDIS; #ifdef BOOTLOADER /* * enable RAM alternate interrupt vectors * these are defined in AltVect.s43 and copied to RAM by cstartup */ SYSCTL |= SYSRIVECT; ClearBootloaderSignature(); #else SaveResetSource(); #endif SetupClockAndPowerManagementModule(); CheckResetCode(); if (niReset != NORMAL_RESET_CODE) { InitProperty(); #if COUNTDOWN_TIMER InitCountdown(); #endif } InitBufferPool(); // message queue InitBattery(); CheckClip(); PrintF("*** %s:%s ***", niReset == FLASH_RESET_CODE ? "FLASH" : (niReset == MASTER_RESET_CODE ? "MASTER" : "NORMAL"), niBuild); ShowWatchdogInfo(); WhoAmI(); /* timer for battery checking at a regular frequency. */ StartTimer(BatteryTimer); InitVibration(); InitRealTimeClock(); // enable rtc interrupt LcdPeripheralInit(); DrawSplashScreen(); SerialRamInit(); /* turn the radio on; initialize the serial port profile or BLE/GATT */ CreateAndSendMessage(TurnRadioOnMsg, MSG_OPT_NONE); DISABLE_LCD_LED(); }
int CTrigger::Operate (short nObject, int nPlayer, int bShot, bool bObjTrigger) { if (m_info.flags & TF_DISABLED) return 1; //1 means don't send trigger hit to other players CObject* objP = (nObject >= 0) ? OBJECTS + nObject : NULL; bool bIsPlayer = objP && (objP->info.nType == OBJ_PLAYER); if (bIsPlayer) { if (!IsMultiGame && (nObject != LOCALPLAYER.nObject)) return 1; } else { nPlayer = -1; if ((m_info.nType != TT_TELEPORT) && (m_info.nType != TT_SPEEDBOOST)) { if (objP && (objP->info.nType != OBJ_ROBOT) && (objP->info.nType != OBJ_REACTOR) && (objP->info.nType != OBJ_HOSTAGE) && (objP->info.nType != OBJ_POWERUP)) return 1; if (!bObjTrigger) return 1; } else if (objP && (objP->info.nType != OBJ_ROBOT) && (objP->info.nType != OBJ_REACTOR) && (objP->info.nType != OBJ_HOSTAGE) && (objP->info.nType != OBJ_POWERUP)) return 1; } int nTrigger = bObjTrigger ? OBJTRIGGERS.Index (this) : TRIGGERS.Index (this); if (!bObjTrigger && (m_info.nType != TT_TELEPORT) && (m_info.nType != TT_SPEEDBOOST)) { int t = gameStates.app.nSDLTicks; if ((gameData.trigs.delay [nTrigger] >= 0) && (t - gameData.trigs.delay [nTrigger] < 750)) return 1; gameData.trigs.delay [nTrigger] = gameStates.app.nSDLTicks; } if (m_info.flags & TF_ONE_SHOT) //if this is a one-bShot... m_info.flags |= TF_DISABLED; //..then don't let it happen again if (m_info.tOperated < 0) { m_info.tOperated = gameData.time.xGame; m_info.nObject = nObject; m_info.nPlayer = nPlayer; m_info.bShot = bShot; } if (Delay () > 0) { gameData.trigs.delay [nTrigger] = -1; return 0; } switch (m_info.nType) { case TT_EXIT: if (DoExit (nPlayer)) return 1; break; case TT_SECRET_EXIT: if (DoSecretExit (nPlayer)) return 1; break; case TT_OPEN_DOOR: DoLink (); PrintMessage (nPlayer, bShot, "Door%s opened!"); break; case TT_CLOSE_DOOR: DoCloseDoor (); PrintMessage (nPlayer, bShot, "Door%s closed!"); break; case TT_UNLOCK_DOOR: DoUnlockDoors (); PrintMessage (nPlayer, bShot, "Door%s unlocked!"); break; case TT_LOCK_DOOR: DoLockDoors (); PrintMessage (nPlayer, bShot, "Door%s locked!"); break; case TT_OPEN_WALL: if (DoChangeWalls ()) { if (WallIsForceField ()) PrintMessage (nPlayer, bShot, "Force field%s deactivated!"); else PrintMessage (nPlayer, bShot, "Wall%s opened!"); } break; case TT_CLOSE_WALL: if (DoChangeWalls ()) { if (WallIsForceField ()) PrintMessage (nPlayer, bShot, "Force field%s activated!"); else PrintMessage (nPlayer, bShot, "Wall%s closed!"); } break; case TT_ILLUSORY_WALL: //don't know what to say, so say nothing DoChangeWalls (); PrintMessage (nPlayer, bShot, "Creating Illusion!"); break; case TT_MATCEN: if (!(gameData.app.nGameMode & GM_MULTI) || (gameData.app.nGameMode & GM_MULTI_ROBOTS)) DoMatCen (nPlayer == gameData.multiplayer.nLocalPlayer); break; case TT_ILLUSION_ON: DoIllusionOn (); PrintMessage (nPlayer, bShot, "Illusion%s on!"); break; case TT_ILLUSION_OFF: DoIllusionOff (); PrintMessage (nPlayer, bShot, "Illusion%s off!"); break; case TT_LIGHT_OFF: if (DoLightOff ()) PrintMessage (nPlayer, bShot, "Lights off!"); break; case TT_LIGHT_ON: if (DoLightOn ()) PrintMessage (nPlayer, bShot, "Lights on!"); break; case TT_TELEPORT: if (bObjTrigger) { DoTeleportBot (objP); PrintMessage (nPlayer, bShot, "Robot is fleeing!"); } else { if (bIsPlayer) { if (nPlayer != gameData.multiplayer.nLocalPlayer) break; if ((LOCALPLAYER.shields < 0) || gameStates.app.bPlayerIsDead) break; } audio.PlaySound (SOUND_SECRET_EXIT, I2X (1)); DoTeleport (nObject); if (bIsPlayer) PrintMessage (nPlayer, bShot, "Teleport!"); } break; case TT_SPEEDBOOST: if (bIsPlayer) { if (nPlayer != gameData.multiplayer.nLocalPlayer) break; if ((LOCALPLAYER.shields < 0) || gameStates.app.bPlayerIsDead) break; } DoSpeedBoost (nObject); if (bIsPlayer) PrintMessage (nPlayer, bShot, "Speed Boost!"); break; case TT_SHIELD_DAMAGE: if (!gameStates.app.bPlayerIsDead) { if (gameStates.app.bD1Mission) LOCALPLAYER.shields -= TRIGGERS [nTrigger].m_info.value; else LOCALPLAYER.shields -= (fix) ((float (I2X (1)) * X2F (TRIGGERS [nTrigger].m_info.value))); if (LOCALPLAYER.shields < 0) StartPlayerDeathSequence (OBJECTS + gameData.multiplayer.players [gameData.multiplayer.nLocalPlayer].nObject); } break; case TT_ENERGY_DRAIN: if (!gameStates.app.bPlayerIsDead) { if (gameStates.app.bD1Mission) LOCALPLAYER.energy -= TRIGGERS [nTrigger].m_info.value; else LOCALPLAYER.energy -= (fix) (LOCALPLAYER.energy * X2F (TRIGGERS [nTrigger].m_info.value) / 100); if (LOCALPLAYER.energy < 0) LOCALPLAYER.energy = 0; } break; case TT_CHANGE_TEXTURE: DoChangeTexture (); PrintMessage (nPlayer, 2, "Walls have been changed!"); break; case TT_SPAWN_BOT: DoSpawnBots (objP); PrintMessage (nPlayer, 1, "Robot is summoning help!"); break; case TT_SET_SPAWN: DoSetSpawnPoints (); PrintMessage (nPlayer, 1, "New spawn points set!"); break; case TT_SMOKE_LIFE: case TT_SMOKE_SPEED: case TT_SMOKE_DENS: case TT_SMOKE_SIZE: case TT_SMOKE_DRIFT: break; case TT_COUNTDOWN: InitCountdown (this, 1, -1); break; case TT_MESSAGE: DoShowMessage (); break; case TT_SOUND: DoPlaySound (nObject); break; case TT_MASTER: DoMasterTrigger (nObject); break; case TT_ENABLE_TRIGGER: DoEnableTrigger (); #if DBG PrintMessage (nPlayer, 2, "Triggers have been enabled!"); #endif break; case TT_DISABLE_TRIGGER: DoDisableTrigger (); #if DBG PrintMessage (nPlayer, 2, "Triggers have been disabled!"); #endif break; case TT_DESCENT1: OperateD1 (nObject, nPlayer, bShot); break; default: Int3 (); break; } if (m_info.flags & TF_ALTERNATE) m_info.nType = oppTrigTypes [m_info.nType]; return 0; }