示例#1
0
文件: cntrlcen.c 项目: paud/d2x-xl
//	-----------------------------------------------------------------------------
//	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--;
		}
	}
}
示例#2
0
文件: reactor.cpp 项目: paud/d2x-xl
//	-----------------------------------------------------------------------------
//	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]--;
		}
	}
}
//remove CObject from the world
void ReleaseObject (short nObject)
{
if ((nObject <= 0) || (nObject >= LEVEL_OBJECTS))
	return;

	int nParent;
	CObject *objP = OBJECTS + nObject;

if (objP->info.nType == OBJ_WEAPON) {
	if (gameData.demo.nVcrState != ND_STATE_PLAYBACK)
		RespawnDestroyedWeapon (nObject);
	if (objP->info.nId == GUIDEDMSL_ID) {
		nParent = OBJECTS [objP->cType.laserInfo.parent.nObject].info.nId;
		if (nParent != gameData.multiplayer.nLocalPlayer)
			gameData.objs.guidedMissile [nParent].objP = NULL;
		else if (gameData.demo.nState == ND_STATE_RECORDING)
			NDRecordGuidedEnd ();
		}
	}
if (objP == gameData.objs.viewerP)		//deleting the viewerP?
	gameData.objs.viewerP = gameData.objs.consoleP;						//..make the CPlayerData the viewerP
if (objP->info.nFlags & OF_ATTACHED)		//detach this from CObject
	DetachFromParent (objP);
if (objP->info.nAttachedObj != -1)		//detach all OBJECTS from this
	DetachChildObjects (objP);
if (objP->info.nType == OBJ_DEBRIS)
	gameData.objs.nDebris--;
OBJECTS [nObject].UnlinkFromSeg ();
Assert (OBJECTS [0].info.nNextInSeg != 0);
if ((objP->info.nType == OBJ_ROBOT) ||
	 (objP->info.nType == OBJ_REACTOR) ||
	 (objP->info.nType == OBJ_POWERUP) ||
	 (objP->info.nType == OBJ_HOSTAGE))
	ExecObjTriggers (nObject, 0);
objP->info.nType = OBJ_NONE;		//unused!
objP->info.nSignature = -1;
objP->info.nSegment = -1;				// zero it!
try {
	FreeObject (nObject);
	}
catch (...) {
	PrintLog ("Error freeing an object\n");
	}
SpawnLeftoverPowerups (nObject);
}