autor: bercik » 11 mar 2006, 21:01
po podmianie orginalnego skryptu (Data/Scripts/Game/Mission/10.script) na ponizszy mozliwe jest rozbrojenie bomby (inzynier potrzebuje na to 30 sek) i niedopuszczenie do eksplozji ... skrypt byl sprawdzany tylko w prostym wariancie - nie bylo testowane dzialanie zapisow gry itp.
- Kod: Zaznacz cały
// Mission 10
// win-conditions:
// - all injured and dead persons are removed
// - all fires are extinguished
// lose-conditions:
// - more than 10 persons died
// - 10 or more houses are burning at the same time
enum
{
MAX_DIED_PERSONS = 10,
MAX_BURNING_HOUSES = 8,
MAX_BURNING_HOUSES_FORHINT4 = 5,
MAX_BURNING_HOUSES_FORACTIONTRACK = 5,
MAX_HINTS = 6,
MAX_GANGSTERS = 2,
MAX_FIRECATCHERS = 13,
MAX_AFTEREXPLOSION_DEAD = 5, // should never be less than 1
MAX_AFTEREXPLOSION_INJURED = 13, // should never be less than 1
VAL_CIVILIAN_GAZER = 5, // every 5th cinema visitor should become a gazer
};
const int MAX_BLOCKING_DEBRIS = 3; // do not change this on your own.
const int MAX_EVACUATE_PATHS = 4;
const int MAX_CINEMA_SOUNDS = 2;
const int TIME_COUNTDOWN = 10 * 60; // 10 minutes until bomb explodes
const char TIMER_ESCAPE[] = "TimerGangsterEscape";
const float TIME_ESCAPE = 10.f * 60.f; // 10 minutes after the explosion the bombers will escape
// Hint0: Evacuate Cinema
const char TIMER_HINT_0[] = "TimerHint0";
const float TIME_HINT_0 = TIME_COUNTDOWN - 5.f * 60.f;
// Hint1: Find the Bomb
const char TIMER_HINT_1[] = "TimerHint1";
const float TIME_HINT_1 = TIME_COUNTDOWN - 6.f * 60.f;
// Hint3: Not enough time to defuse bomb
const char TIMER_HINT_3[] = "TimerHint3";
const float TIME_HINT_3 = TIME_COUNTDOWN - 2.f * 60.f;
// Hint5: Gangsters spotted
const char TIMER_HINT_5[] = "TimerHint5";
const float TIME_HINT_5 = TIME_ESCAPE - 5.f * 60.f;
const char MSGGROUP_AFTEREXPLOSION[] = "afterboom";
const char GAZERTARGET_RUIN[] = "CinemaRuin";
const char GAZERTARGET_CINEMA[] = "CinemaBomb";
const char VOBJECT_EXPLOSION_AREA[] = "explosion";
const char VOBJECT_BODYPLACE[] = "bodyplace";
const char NAME_VISITORS[] = "cinemapers";
const float RUIN_PLACEMENT_Y = 16385.0f;
const float VISITORS_PLACEMENT_X = 7.f;
const char PATH_EVACUATE0[] = "evacuate01";
const char PATH_EVACUATE1[] = "evacuate02";
const char PATH_EVACUATE2[] = "evacuate03";
const char PATH_EVACUATE3[] = "evacuate04";
const char SOUND_AMBIENT_CINEMA[] = "mod:Audio/Ambient/Cinema01.wav";
const char CINEMA_SCREEN_TEXTURE[] = "mod:Models/Objects/HouseFurniture/cinema01_display.tga";
const char CINEMA_SCREEN_VIDEO[] = "base:Video/cinema.mpg";
// CutScene Variables
const int CS_MAXWINDOWBURST = 10;
const int CS_MAXEXPLOSION = 10;
const int CS_MAXDUST = 10;
const int CS_MAXDEBRIS = 20;
const int CS_MAXDOOR = 2;
object Mission10 : MissionScript
{
GameObject CS_ParticleWindowBurst[CS_MAXWINDOWBURST];
GameObject CS_ParticleExplosion[CS_MAXEXPLOSION];
GameObject CS_ParticleDust[CS_MAXDUST];
GameObject CS_Debris[CS_MAXDEBRIS];
GameObject CS_Door[CS_MAXDOOR];
GameObjectList CutSceneObstacles;
OpenHouse mCinema;
GameObject mCinemaRuin;
GameObject mBomb;
Person mGirl;
Person mGangster[MAX_GANGSTERS];
GameObject mFireCatcher[MAX_FIRECATCHERS];
Person mBlockedPerson[MAX_BLOCKING_DEBRIS];
Path mEvacuatePath[MAX_EVACUATE_PATHS];
bool mTooManyDied;
bool mFireOutOfControl;
bool mBombFound;
bool mDefusingBomb;
bool mBombExploded;
bool mObjectiveTransportInjured;
bool mObjectiveExtinguishFires;
bool mObjectiveArrestGangsters;
bool mGangsterLeftLevel[MAX_GANGSTERS];
bool mGangsterOutOfOrder[MAX_GANGSTERS];
bool mCinemaEvacuated;
bool mSoundtrackFiresRunning;
int mNumCiviliansInCinema;
float mDefusingProgress;
int mNumInjuredPersons;
int mGazerCounter;
const char *mHintTexts[MAX_HINTS];
int mHintCounter[MAX_HINTS];
const char *mEvacuatePathName[MAX_EVACUATE_PATHS];
int mAmbientCinemaSound[MAX_CINEMA_SOUNDS];
int CS_NumDebris;
int CS_NumDoor;
int CS_NumParticlesDust;
int CS_NumParticlesExplosion;
int CS_NumParticlesWindowBurst;
Mission10()
{
mTooManyDied = false;
mFireOutOfControl = false;
mBombFound = false;
mDefusingBomb = false;
mBombExploded = false;
mObjectiveTransportInjured = false;
mObjectiveExtinguishFires = false;
mObjectiveArrestGangsters = true;
mNumCiviliansInCinema = 0;
mCinemaEvacuated = false;
mSoundtrackFiresRunning = false;
mDefusingProgress = 0.0f;
mGazerCounter = 0;
for(int i = 0; i < MAX_HINTS; ++i)
mHintCounter[i] = 0;
for(int i = 0; i < MAX_GANGSTERS; ++i)
{
mGangsterLeftLevel[i] = false;
mGangsterOutOfOrder[i] = false;
}
for(int i = 0; i < MAX_CINEMA_SOUNDS; ++i)
mAmbientCinemaSound[i] = 0;
mEvacuatePathName[0] = PATH_EVACUATE0;
mEvacuatePathName[1] = PATH_EVACUATE1;
mEvacuatePathName[2] = PATH_EVACUATE2;
mEvacuatePathName[3] = PATH_EVACUATE3;
}
bool SerializeTo(ScriptSerializer *Stream)
{
System::Log("M10: SerializeTo() begin.");
const int Version = 0x100;
Stream->Write(Version);
Stream->Write(CS_NumParticlesWindowBurst);
for(int i = 0; i < CS_NumParticlesWindowBurst; ++i)
Stream->Write(CS_ParticleWindowBurst[i]);
Stream->Write(CS_NumParticlesExplosion);
for(int i = 0; i < CS_NumParticlesExplosion; ++i)
Stream->Write(CS_ParticleExplosion[i]);
Stream->Write(CS_NumParticlesDust);
for(int i = 0; i < CS_NumParticlesDust; ++i)
Stream->Write(CS_ParticleDust[i]);
Stream->Write(CS_NumDebris);
for(int i = 0; i < CS_NumDebris; ++i)
Stream->Write(CS_Debris[i]);
Stream->Write(CS_NumDoor);
for(int i = 0; i < CS_NumDoor; ++i)
Stream->Write(CS_Door[i]);
Stream->Write(CutSceneObstacles);
Stream->Write(mCinema);
Stream->Write(mCinemaRuin);
Stream->Write(mBomb);
Stream->Write(mGirl);
Stream->Write((int) MAX_GANGSTERS);
for(int i = 0; i < MAX_GANGSTERS; ++i)
{
Stream->Write(mGangsterLeftLevel[i]);
Stream->Write(mGangsterOutOfOrder[i]);
Stream->Write(mGangster[i]);
}
Stream->Write((int) MAX_FIRECATCHERS);
for(int i = 0; i < MAX_FIRECATCHERS; ++i)
Stream->Write(mFireCatcher[i]);
Stream->Write(MAX_BLOCKING_DEBRIS);
for(int i = 0; i < MAX_BLOCKING_DEBRIS; ++i)
Stream->Write(mBlockedPerson[i]);
Stream->Write(MAX_EVACUATE_PATHS);
for(int i = 0; i < MAX_EVACUATE_PATHS; ++i)
Stream->Write(mEvacuatePath[i]);
Stream->Write(MAX_CINEMA_SOUNDS);
for(int i = 0; i < MAX_CINEMA_SOUNDS; ++i)
Stream->Write(mAmbientCinemaSound[i]);
Stream->Write((int) MAX_HINTS);
for(int i = 0; i < MAX_HINTS; ++i)
Stream->Write(mHintCounter[i]);
Stream->Write(mTooManyDied);
Stream->Write(mFireOutOfControl);
Stream->Write(mBombFound);
Stream->Write(mDefusingBomb);
Stream->Write(mBombExploded);
Stream->Write(mObjectiveTransportInjured);
Stream->Write(mObjectiveExtinguishFires);
Stream->Write(mObjectiveArrestGangsters);
Stream->Write(mCinemaEvacuated);
Stream->Write(mSoundtrackFiresRunning);
Stream->Write(mNumCiviliansInCinema);
Stream->Write(mDefusingProgress);
Stream->Write(mNumInjuredPersons);
Stream->Write(mGazerCounter);
System::Log("M10: SerializeTo() end.");
return true;
}
bool SerializeFrom(ScriptSerializer *Stream)
{
System::Log("M10: SerializeFrom() begin.");
int Version;
Stream->Read(Version);
Stream->Read(CS_NumParticlesWindowBurst);
for(int i = 0; i < CS_NumParticlesWindowBurst; ++i)
Stream->Read(CS_ParticleWindowBurst[i]);
Stream->Read(CS_NumParticlesExplosion);
for(int i = 0; i < CS_NumParticlesExplosion; ++i)
Stream->Read(CS_ParticleExplosion[i]);
Stream->Read(CS_NumParticlesDust);
for(int i = 0; i < CS_NumParticlesDust; ++i)
Stream->Read(CS_ParticleDust[i]);
Stream->Read(CS_NumDebris);
for(int i = 0; i < CS_NumDebris; ++i)
Stream->Read(CS_Debris[i]);
Stream->Read(CS_NumDoor);
for(int i = 0; i < CS_NumDoor; ++i)
Stream->Read(CS_Door[i]);
Stream->Read(CutSceneObstacles);
Stream->Read(mCinema);
Stream->Read(mCinemaRuin);
Stream->Read(mBomb);
Stream->Read(mGirl);
int dummy = 0;
Stream->Read(dummy);
if(dummy != MAX_GANGSTERS)
return false;
for(int i = 0; i < MAX_GANGSTERS; ++i)
{
//Stream->Read(mGangsterLeftLevel[i]);
mGangsterLeftLevel[i] = Stream->ReadBool();
//Stream->Read(mGangsterOutOfOrder[i]);
mGangsterOutOfOrder[i] = Stream->ReadBool();
Stream->Read(mGangster[i]);
}
Stream->Read(dummy);
if(dummy != MAX_FIRECATCHERS)
return false;
for(int i = 0; i < MAX_FIRECATCHERS; ++i)
Stream->Read(mFireCatcher[i]);
Stream->Read(dummy);
if(dummy != MAX_BLOCKING_DEBRIS)
return false;
for(int i = 0; i < MAX_BLOCKING_DEBRIS; ++i)
Stream->Read(mBlockedPerson[i]);
Stream->Read(dummy);
if(dummy != MAX_EVACUATE_PATHS)
return false;
for(int i = 0; i < MAX_EVACUATE_PATHS; ++i)
Stream->Read(mEvacuatePath[i]);
Stream->Read(dummy);
if(dummy != MAX_CINEMA_SOUNDS)
return false;
for(int i = 0; i < MAX_CINEMA_SOUNDS; ++i)
Stream->Read(mAmbientCinemaSound[i]);
Stream->Read(dummy);
if(dummy != MAX_HINTS)
return false;
for(int i = 0; i < MAX_HINTS; ++i)
Stream->Read(mHintCounter[i]);
//Stream->Read(mTooManyDied);
mTooManyDied = Stream->ReadBool();
//Stream->Read(mFireOutOfControl);
mFireOutOfControl = Stream->ReadBool();
//Stream->Read(mBombFound);
mBombFound = Stream->ReadBool();
//Stream->Read(mDefusingBomb);
mDefusingBomb = Stream->ReadBool();
//Stream->Read(mBombExploded);
mBombExploded = Stream->ReadBool();
//Stream->Read(mObjectiveTransportInjured);
mObjectiveTransportInjured = Stream->ReadBool();
//Stream->Read(mObjectiveExtinguishFires);
mObjectiveExtinguishFires = Stream->ReadBool();
//Stream->Read(mObjectiveArrestGangsters);
mObjectiveArrestGangsters = Stream->ReadBool();
//Stream->Read(mCinemaEvacuated);
mCinemaEvacuated = Stream->ReadBool();
//Stream->Read(mSoundtrackFiresRunning);
mSoundtrackFiresRunning = Stream->ReadBool();
Stream->Read(mNumCiviliansInCinema);
Stream->Read(mDefusingProgress);
Stream->Read(mNumInjuredPersons);
Stream->Read(mGazerCounter);
if(!mBombExploded)
{
if(!Audio::PlayTextureVideo(CINEMA_SCREEN_TEXTURE, CINEMA_SCREEN_VIDEO, true))
System::Log("M10: Unable to start cinema screen movie after Serialization.");
}
System::Log("M10: SerializeFrom() end.");
return true;
}
void Start()
{
System::Log("Script start mission 10.");
int numGangsters = 0;
int numFireCatchers = 0;
GameObjectList l0 = Game::GetGameObjects();
for(int i=0; i<l0.GetNumObjects(); i++)
{
GameObject *obj = l0.GetObject(i);
if(obj->HasName("bomb"))
mBomb = *obj;
else if(obj->HasName("bombgirl") && obj->GetType() == ACTOR_PERSON)
{
Person p(obj);
mGirl = p;
}
else if(obj->HasName("gangster") && obj->GetType() == ACTOR_PERSON)
{
if(numGangsters < MAX_GANGSTERS)
{
Person p(obj);
mGangster[numGangsters++] = p;
}
else
System::Log("M10: Too many gangsters. Increase MAX_GANGSTERS in mission script!");
}
else if(obj->HasName("firecatcher"))
{
if(numFireCatchers < MAX_FIRECATCHERS)
mFireCatcher[numFireCatchers++] = *obj;
else
System::Log("M10: Too many fire catchers. Increase MAX_FIRECATCHERS in mission script.");
}
else if(obj->HasName("CinemaRuin"))
mCinemaRuin = *obj;
else if(obj->HasName("Cinema") && obj->GetType() == ACTOR_OPEN_HOUSE)
{
OpenHouse house(obj);
mCinema = house;
}
else if(obj->HasName("s2_blocked01") && obj->GetType() == ACTOR_PERSON)
{
Person p(obj);
mBlockedPerson[0] = p;
}
else if(obj->HasName("s2_blocked02") && obj->GetType() == ACTOR_PERSON)
{
Person p(obj);
mBlockedPerson[1] = p;
}
else if(obj->HasName("s2_blocked03") && obj->GetType() == ACTOR_PERSON)
{
Person p(obj);
mBlockedPerson[2] = p;
}
}
for(int i = 0; i < MAX_EVACUATE_PATHS; i++)
{
ActorList list(mEvacuatePathName[i]);
if(list.GetNumActors() > 0)
{
System::Log("M10: evac path %i found", i);
Path evap(list.GetActor(0));
mEvacuatePath[i] = evap;
}
else
System::Log("M10: evacuate path %i (%s) is missing!", i, mEvacuatePathName[i]);
}
ActorList soundpos("cinemasound");
if(soundpos.GetNumActors() > 0)
{
int index = 0;
for(int i = 0; i < soundpos.GetNumActors(); ++i)
{
if(index < MAX_CINEMA_SOUNDS)
{
float x, y, z;
soundpos.GetActor(i)->GetPosition(x, y, z);
mAmbientCinemaSound[index++] = Audio::PlaySample3D(SOUND_AMBIENT_CINEMA, x, y, z, true);
}
else
System::Log("M10: Too many cinemasound places. Increase MAX_CINEMA_SOUNDS in mission script!");
}
}
if(soundpos.GetNumActors() < MAX_CINEMA_SOUNDS)
System::Log("M10: %i missing cinemasound places.", MAX_CINEMA_SOUNDS - soundpos.GetNumActors());
// Check for missing stuff
if(!mBomb.IsValid())
System::Log("M10: Da bomb is missing!");
if(!mGirl.IsValid())
System::Log("M10: bombgirl is missing!");
if(!mCinema.IsValid())
System::Log("M10: cinema is missing!");
if(!mCinemaRuin.IsValid())
System::Log("M10: cinema ruin is missing!");
for(int i = 0; i < MAX_GANGSTERS; ++i)
{
if(!mGangster[i].IsValid())
System::Log("M10: gangster (%i) is missing!", i);
}
for(int i = 0; i < MAX_FIRECATCHERS; ++i)
{
if(!mFireCatcher[i].IsValid())
System::Log("M10: fire catcher (%i) is missing!", i);
}
for(int i = 0; i < MAX_BLOCKING_DEBRIS; ++i)
{
if(!mBlockedPerson[i].IsValid())
System::Log("M10: blocked person (%i) is missing!", i);
}
mNumCiviliansInCinema = mCinema.NumNonSquadPersonsInside();
System::Log("M10: Number of civilians inside cinema at start: %i", mNumCiviliansInCinema);
InitCutSceneVars();
Mission::AddObjective("M10_DEFUSE_BOMB");
Mission::AddObjective("M10_EVACUATE_CINEMA");
Mission::AddObjective("M10_ARREST_BOMBER");
Mission::StartCountDown(TIME_COUNTDOWN);
Mission::StartSingleTimer(TIMER_HINT_0, TIME_HINT_0);
Mission::StartSingleTimer(TIMER_HINT_1, TIME_HINT_1);
Mission::StartSingleTimer(TIMER_HINT_3, TIME_HINT_3);
Audio::PlaySoundtrack("10", 0.0f);
if(!Audio::PlayTextureVideo(CINEMA_SCREEN_TEXTURE, CINEMA_SCREEN_VIDEO, true))
System::Log("M10: Unable to start cinema screen movie.");
System::Log("M10: End of start.");
}
void InitCutSceneVars()
{
GameObjectList l0("cs_windowburst");
CS_NumParticlesWindowBurst = 0;
for (int i = 0; i < l0.GetNumObjects() && CS_NumParticlesWindowBurst < CS_MAXWINDOWBURST; i++)
{
CS_ParticleWindowBurst[CS_NumParticlesWindowBurst] = *l0.GetObject(i);
CS_ParticleWindowBurst[CS_NumParticlesWindowBurst].Hide();
CS_ParticleWindowBurst[CS_NumParticlesWindowBurst].StopParticleEffect();
CS_NumParticlesWindowBurst++;
}
GameObjectList l1("cs_explosion");
CS_NumParticlesExplosion = 0;
for (int i = 0; i < l1.GetNumObjects() && CS_NumParticlesExplosion < CS_MAXEXPLOSION; i++)
{
CS_ParticleExplosion[CS_NumParticlesExplosion] = *l1.GetObject(i);
CS_ParticleExplosion[CS_NumParticlesExplosion].Hide();
CS_ParticleExplosion[CS_NumParticlesExplosion].StopParticleEffect();
CS_NumParticlesExplosion++;
}
GameObjectList l2("cs_dust");
CS_NumParticlesDust = 0;
for (int i = 0; i < l2.GetNumObjects() && CS_NumParticlesDust < CS_MAXDUST; i++)
{
CS_ParticleDust[CS_NumParticlesDust] = *l2.GetObject(i);
CS_ParticleDust[CS_NumParticlesDust].Hide();
CS_ParticleDust[CS_NumParticlesDust].StopParticleEffect();
CS_NumParticlesDust++;
}
GameObjectList l3("cs_debris");
CS_NumDebris = 0;
for (int i = 0; i < l3.GetNumObjects() && CS_NumDebris < CS_MAXDEBRIS; i++)
{
CS_Debris[CS_NumDebris] = *l3.GetObject(i);
CS_Debris[CS_NumDebris].Hide();
CS_NumDebris++;
}
System::Print("Number of debris: %d", CS_NumDebris);
GameObjectList l4("cs_door");
CS_NumDoor = 0;
for (int i = 0; i < l4.GetNumObjects() && CS_NumDoor < CS_MAXDOOR; i++)
{
CS_Door[CS_NumDoor] = *l4.GetObject(i);
CS_Door[CS_NumDoor].Hide();
CS_NumDoor++;
}
}
void ShowHint(int hintId_)
{
mHintTexts[0] = "M10_GOTTA_EVACUATE_CINEMA";
mHintTexts[1] = "M10_BOMB_IN_CINEMA";
mHintTexts[2] = "M10_CLEAR_SEAT";
mHintTexts[3] = "M10_FAILED_TO_DEFUSE_BOMB";
mHintTexts[4] = "ALLM_TOO_MANY_FIRES";
mHintTexts[5] = "M10_SUSPECTS";
++mHintCounter[hintId_];
Mission::PlayHint(mHintTexts[hintId_]);
System::Log("M10: Hint %i displayed.", hintId_);
}
void OnCountDownEnded()
{
RunCutScene();
mBombExploded = true;
Game::SetDefaultMessageGroup(MSGGROUP_AFTEREXPLOSION);
}
void RunCutScene()
{
System::Log("M10: CutScene Started");
Game::CollectObstaclesOnTrigger("CS_Vanish", CutSceneObstacles);
Game::HideObjects(CutSceneObstacles);
mCinema.Close();
mCinema.EnableSpecialLights(true);
ShowSquadsInCinema(false);
Audio::StopSoundtrack();
Mission::StartCutScene();
Mission::ShowBlackBars();
Camera::StartTransition("CutScene1", 3.0f);
}
void ShowSquadsInCinema(bool show_)
{
PersonList squads = mCinema.GetSquadPersonsInside();
for(int i = 0; i < squads.GetNumPersons(); ++i)
{
if(show_)
squads.GetPerson(i)->Show();
else
squads.GetPerson(i)->Hide();
}
System::Log("M10: ShowSquadsInCinema() called for %i persons.", squads.GetNumPersons());
}
void StartFire()
{
for(int i = 0; i < MAX_FIRECATCHERS; ++i)
{
mFireCatcher[i].Burn();
}
GameObjectList burning01("burning01");
if(burning01.GetNumObjects() > 0)
{
FireObject right(burning01.GetObject(0)->GetFireChild("Right"));
right.Burn();
right.SetTemperature(right.GetMaxMaterialTemperature());
System::Log("M10: burning01 Right FireObject set to temperature %i", (int) right.GetMaxMaterialTemperature());
FireObject front(burning01.GetObject(0)->GetFireChild("Front"));
front.Burn();
front.SetTemperature(front.GetMaxMaterialTemperature());
System::Log("M10: burning01 Front FireObject set to temperature %i", (int) front.GetMaxMaterialTemperature());
}
Mission::RemoveObjective("M10_EVACUATE_CINEMA");
Mission::RemoveObjective("M10_DEFUSE_BOMB");
System::Log("M10: Fire started, Objectives updated.");
}
void DropFlyingChair()
{
System::Log("M10: DropFlyingChair()");
GameObjectList flyingchair("s2_chair");
if(flyingchair.GetNumObjects() > 0)
{
GameObject *chair = flyingchair.GetObject(0);
if(!chair->IsValid())
return;
chair->Burn();
float x, y, z;
chair->GetPosition(x, y, z);
chair->SetPosition(x, y + RUIN_PLACEMENT_Y, z);
chair->EnablePhysicsSimulation();
chair->EnablePhysics();
}
}
void DestroyCinema()
{
System::Log("M10: Destroy Cinema.");
for(int i = 0; i < MAX_CINEMA_SOUNDS; ++i)
{
Audio::StopSample(mAmbientCinemaSound[i]);
mAmbientCinemaSound[i] = 0;
}
System::Log("M10: Stopping video texture...");
Audio::StopTextureVideo(CINEMA_SCREEN_TEXTURE);
System::Log("M10: Video texture successfully stopped.");
ReplaceCinema();
InjureBystanders();
PlaceDeadAndInjured();
StartFire();
Game::DeactivateWaitingPoint(GAZERTARGET_CINEMA);
Game::ActivateWaitingPoint(GAZERTARGET_RUIN);
}
void ReplaceCinema()
{
// Move all ruin stuff and blocked persons to their right position and hide old cinema
float x, y, z;
mCinema.GetPosition(x, y, z);
mCinema.Hide(); // Do not delete it, because all dead persons are still in the house
mBomb.Hide();
float rx, ry;
rx = 0.0f;
ry = RUIN_PLACEMENT_Y;
System::Log("M10: ReplaceCinema by x = %i and y = %i", (int) rx, (int) ry);
mCinemaRuin.GetPosition(x, y, z);
mCinemaRuin.SetPosition(x + rx, y + ry, z);
for(int i = 0; i < MAX_BLOCKING_DEBRIS; ++i)
{
mBlockedPerson[i].GetPosition(x, y, z);
mBlockedPerson[i].SetPosition(x + rx, y + ry, z);
mBlockedPerson[i].Injure(INJUREREASON_ENERGY, false);
}
GameObjectList ruinStuff("s2");
for(int i = 0; i < ruinStuff.GetNumObjects(); ++i)
{
GameObject *obj = ruinStuff.GetObject(i);
obj->GetPosition(x, y, z);
obj->SetPosition(x + rx, y + ry, z);
}
GameObjectList oldStuff("s1");
for(int i = 0; i < oldStuff.GetNumObjects(); ++i)
{
Game::RemoveGameObject(oldStuff.GetObject(i));
}
}
void InjureBystanders()
{
System::Log("M10: InjureBystanders() called.");
GameObjectList explosion;
if(Game::CollectObstaclesOnVirtualObject(VOBJECT_EXPLOSION_AREA, explosion))
{
System::Log("M10: %i objects in explosion area found.", explosion.GetNumObjects());
int numPersons = 0;
int numVehicles = 0;
int numRemoved = 0;
mNumInjuredPersons = 0;
float x = 0, y = 0, z = 0;
for(int i = 0; i < explosion.GetNumObjects(); ++i)
{
if(explosion.GetObject(i)->GetType() == ACTOR_PERSON)
{
Person person(explosion.GetObject(i));
if(person.GetEnteredHouseID() != -1 || person.GetEnteredCarID() != -1)
continue;
bool skip = false;
for(int j = 0; j < MAX_BLOCKING_DEBRIS; ++j)
{
if(mBlockedPerson[j].GetID() == person.GetID())
{
skip = true;
break;
}
}
if(skip)
continue;
++numPersons;
if(mNumInjuredPersons < MAX_AFTEREXPLOSION_INJURED)
{
++mNumInjuredPersons;
person.Injure(INJUREREASON_ENERGY, false);
person.GetPosition(x, y, z);
if(Game::FindFreePosition(&person, x, y, z, 400.0f))
person.SetPosition(x, y, z);
else
System::Log("M10: No free position found for bystander.");
}
else
{
Game::RemoveGameObject(&person);
++numRemoved;
}
}
else if(explosion.GetObject(i)->GetType() == ACTOR_VEHICLE)
{
++numVehicles;
Vehicle vehicle(explosion.GetObject(i));
vehicle.Destroy();
vehicle.GetPosition(x, y, z);
if(Game::FindFreePosition(&vehicle, x, y, z, 500.0f))
vehicle.SetPosition(x, y, z);
else
System::Log("M10: No free position found for destroyed vehicle.");
}
}
System::Log("M10: %i bystanders injured, %i removed. (Total in area: %i)", mNumInjuredPersons, numRemoved, numPersons);
System::Log("M10: %i vehicles destroyed by explosion.", numVehicles);
}
}
void PlaceDeadAndInjured()
{
System::Log("M10: PlaceDeadAndInjured() called.");
// Find all dead persons in cinema
int numDead = mCinema.NumSquadPersonsInside() + mCinema.NumNonSquadPersonsInside();
System::Log("M10: Total number of persons in cinema: %i", numDead);
Person *deadTechnician = NULL;
if(numDead > 0 && MAX_AFTEREXPLOSION_DEAD > 0 && MAX_AFTEREXPLOSION_INJURED > 0)
{
Person *deads[MAX_AFTEREXPLOSION_DEAD];
for(int i = 0; i < MAX_AFTEREXPLOSION_DEAD; ++i)
deads[i] = NULL;
Person *injureds[MAX_AFTEREXPLOSION_INJURED];
for(int i = 0; i < MAX_AFTEREXPLOSION_INJURED; ++i)
injureds[i] = NULL;
PersonList squads = mCinema.GetSquadPersonsInside();
PersonList civilians = mCinema.GetNonSquadPersonsInside();
if(numDead > MAX_AFTEREXPLOSION_DEAD)
{
float fraction = (float) MAX_AFTEREXPLOSION_DEAD / (float) numDead;
int numSquadsToPlace = (int) (squads.GetNumPersons() * fraction * squads.GetNumPersons() / (float) numDead);
System::Log("M10: Number of dead squads to place out of cinema: %i", numSquadsToPlace);
int index_dead = 0;
int index_injured = 0;
for(int i = 0; i < squads.GetNumPersons(); ++i)
{
Person *person = squads.GetPerson(i);
if(!deadTechnician && person->GetBehaviour() == BEHAVIOUR_SQUAD_THW)
deadTechnician = person;
else
{
if(index_dead < numSquadsToPlace)
deads[index_dead++] = person;
else if(index_injured < MAX_AFTEREXPLOSION_INJURED - mNumInjuredPersons)
injureds[index_injured++] = person;
else
Game::RemoveGameObject(person);
}
}
numSquadsToPlace = index_dead;
int numSquadsInjured = index_injured;
mNumInjuredPersons += index_injured;
System::Log("M10: %i squads killed, %i squads injured (out of %i) and placed outside cinema.", index_dead, index_injured, squads.GetNumPersons());
for(int i = 0; i < civilians.GetNumPersons(); ++i)
{
if(index_dead < MAX_AFTEREXPLOSION_DEAD)
deads[index_dead++] = civilians.GetPerson(i);
else if(index_injured < MAX_AFTEREXPLOSION_INJURED - mNumInjuredPersons)
injureds[index_injured++] = civilians.GetPerson(i);
else
Game::RemoveGameObject(civilians.GetPerson(i));
}
System::Log("M10: %i civilians killed, %i injured (out of %i) and placed outside cinema.", index_dead - numSquadsToPlace, index_injured - numSquadsInjured, civilians.GetNumPersons());
}
else
{
int index = 0;
for(int i = 0; i < squads.GetNumPersons(); ++i)
{
Person *person = squads.GetPerson(i);
if(!deadTechnician && person->GetBehaviour() == BEHAVIOUR_SQUAD_THW)
deadTechnician = person;
else
deads[index++] = person;
}
for(int i = 0; i < civilians.GetNumPersons(); ++i)
deads[index++] = civilians.GetPerson(i);
System::Log("M10: %i squads and %i civilians killed and placed outside cinema.", squads.GetNumPersons(), civilians.GetNumPersons());
}
// Place other dead persons outside of the cinema ruin
ActorList bodyPlaces(VOBJECT_BODYPLACE);
if(bodyPlaces.GetNumActors() > 0)
{
int bodyCount = 0;
for(int i = 0; i < MAX_AFTEREXPLOSION_DEAD; ++i)
{
if(deads[i])
{
if(bodyCount >= bodyPlaces.GetNumActors())
bodyCount = 0;
float x, y, z;
bodyPlaces.GetActor(bodyCount)->GetPosition(x, y, z);
int tries = 0;
deads[i]->SetEnteredHouseID(-1);
while(!Game::FindFreePosition(deads[i], x, y, z, 200.0f) && tries < 20)
{
x += RandomValue(-30, 50);
y += RandomValue(-50, 30);
++tries;
}
System::Log("M10: %i tries needed to find free position around bodyplace %i for dead.", tries + 1, bodyCount);
if(tries == 20)
{
System::Log("M10: Could not find a free body position!");
Game::RemoveGameObject(deads[i]);
deads[i] = NULL;
++bodyCount;
continue;
}
deads[i]->SetPosition(x, y, z);
deads[i]->Kill(INJUREREASON_ENERGY);
++bodyCount;
}
else
break;
}
for(int i = 0; i < MAX_AFTEREXPLOSION_INJURED; ++i)
{
if(injureds[i])
{
if(bodyCount >= bodyPlaces.GetNumActors())
bodyCount = 0;
float x, y, z;
bodyPlaces.GetActor(bodyCount)->GetPosition(x, y, z);
int tries = 0;
injureds[i]->SetEnteredHouseID(-1);
while(!Game::FindFreePosition(injureds[i], x, y, z, 200.0f) && tries < 20)
{
x += RandomValue(-30, 50);
y += RandomValue(-50, 30);
++tries;
}
System::Log("M10: %i tries needed to find free position around bodyplace %i for injured.", tries + 1, bodyCount);
if(tries == 20)
{
System::Log("M10: Could not find a free body position!");
Game::RemoveGameObject(injureds[i]);
injureds[i] = NULL;
++bodyCount;
continue;
}
injureds[i]->SetPosition(x, y, z);
injureds[i]->Injure(INJUREREASON_ENERGY, false);
++bodyCount;
}
else
break;
}
}
else
System::Log("M10: bodyplace missing!");
// Place dead technician under debris
if(deadTechnician)
{
int location = RandomValue(0, 2);
System::Log("M10: Dead technician placed under debris %i", location +1);
Person *oldBlocked = &mBlockedPerson[location];
float x, y, z;
oldBlocked->GetPosition(x, y, z);
float rot[9];
oldBlocked->GetRotation(rot[0], rot[1], rot[2], rot[3], rot[4], rot[5], rot[6], rot[7], rot[8]);
Game::RemoveGameObject(oldBlocked);
*oldBlocked = *deadTechnician;
deadTechnician = oldBlocked;
deadTechnician->SetEnteredHouseID(-1);
deadTechnician->SetPosition(x, y, z);
deadTechnician->SetRotation(rot[0], rot[1], rot[2], rot[3], rot[4], rot[5], rot[6], rot[7], rot[8]);
deadTechnician->Kill(INJUREREASON_ENERGY);
}
}
}
void StandUpVisitor(Person &visitor)
{
if(visitor.IsCurrentAnimation("sit"))
{
float x, y, z;
visitor.GetPosition(x, y, z);
float dx = 0.0f, dy = 0.0f, dz = 0.0f;
dx = VISITORS_PLACEMENT_X;
float rot[9] = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
visitor.GetRotation(rot[0], rot[1], rot[2], rot[3], rot[4], rot[5], rot[6], rot[7], rot[8]);
Math::RotateVector(dx, dy, dz, rot);
x += dx;
y += dy;
z += dz;
visitor.SetPosition(x, y, z);
visitor.SetAnimation("standup2");
}
}
void StartEvacuation()
{
if(mBombExploded)
return;
System::Log("M10: Evacuation of cinema started.");
mCinemaEvacuated = true;
Mission::PlayHint("ID_EVACUATE");
PersonList civilians(mCinema.GetNonSquadPersonsInside());
System::Log("M10: Num civilians in cinema: %i", civilians.GetNumPersons());
for(int i = 0; i < civilians.GetNumPersons(); ++i)
{
Person person(civilians.GetPerson(i));
StandUpVisitor(person);
float x, y, z;
person.GetPosition(x, y, z);
int pathNum = -1;
float maxDist = 1e30f;
for(int j = 0; j < MAX_EVACUATE_PATHS; ++j)
{
if(!mEvacuatePath[j].IsValid())
{
System::Log("M10: evacuation path %i is not valid.", j+1);
continue;
}
float dist = mEvacuatePath[j].GetDistance(x, y, z);
if(dist < maxDist)
{
pathNum = j;
maxDist = dist;
}
}
if(pathNum == -1)
{
System::Log("M10: no nearest evacuation path found.");
continue;
}
float time = RandomValue(0, 2) + (maxDist / 50.0f);
person.PushActionWait(ACTION_NEWLIST, time);
person.SetStandardPath(mEvacuatePathName[pathNum]);
person.SetObjectPath(mEvacuatePathName[pathNum]);
}
System::Log("M10: Evacuation successfully initiated.");
}
int RandomValue(int min_, int max_)
{
if(min_ > max_)
return max_;
return (int) (min_ + (Math::rand() / (float) Math::RANDMAX) * (max_ - min_));
}
void OnCameraTransitionFinished()
{
if (Mission::IsCutSceneRunning())
{
Mission::StartSingleTimer("CS_Explosion", 1.0f);
}
}
void Update()
{
if(!mObjectiveTransportInjured)
{
if(Mission::GetCounter("Injured Persons") + Mission::GetCounter("Dead Persons") > 0)
{
Mission::AddObjective("TRANSPORT_INJURED");
mObjectiveTransportInjured = true;
}
}
if(mObjectiveArrestGangsters)
{
for(int i = 0; i < MAX_GANGSTERS; ++i)
{
if(!mGangsterLeftLevel[i] && mGangster[i].IsInjured())
mGangsterOutOfOrder[i] = true;
if(mGangsterLeftLevel[i] && !mGangsterOutOfOrder[i])
{
System::Log("M10: Gangster left level, but was not captured. Objective removed!");
mObjectiveArrestGangsters = false;
Mission::RemoveObjective("M10_ARREST_BOMBER");
break;
}
}
}
if(!mObjectiveExtinguishFires)
{
if(Mission::GetCounter("Burning Objects") + Mission::GetCounter("Burning Houses") > 0)
{
Mission::AddObjective("EXTINGUISH_FIRES");
mObjectiveExtinguishFires = true;
}
}
if(mObjectiveExtinguishFires)
{
int burningHouses = Mission::GetCounter("Burning Houses");
if(mHintCounter[4] == 0 && burningHouses >= MAX_BURNING_HOUSES_FORHINT4)
ShowHint(4);
if(mSoundtrackFiresRunning && burningHouses < MAX_BURNING_HOUSES_FORACTIONTRACK)
{
mSoundtrackFiresRunning = false;
Audio::SetMusicLevel(0.2f);
}
else if(!mSoundtrackFiresRunning && burningHouses >= MAX_BURNING_HOUSES_FORACTIONTRACK)
{
mSoundtrackFiresRunning = true;
Audio::SetMusicLevel(0.3f);
}
}
if(!mBombExploded)
{
mCinema.EnableSpecialLights(!mCinema.IsOpen());
}
}
void OnTimer(const char *Timer, float Time)
{
switch (Timer)
{
case TIMER_HINT_0:
{
if(mNumCiviliansInCinema <= mCinema.NumNonSquadPersonsInside())
ShowHint(0);
}
break;
case TIMER_HINT_1:
{
if(!mBombFound)
ShowHint(1);
}
break;
case TIMER_HINT_3:
{
if(mDefusingBomb)
ShowHint(3);
Audio::SetMusicLevel(0.1f);
}
break;
case TIMER_HINT_5:
{
bool stillWaiting = true;
for(int i = 0; i < MAX_GANGSTERS; ++i)
{
if(mGangsterLeftLevel[i] || mGangsterOutOfOrder[i])
{
stillWaiting = false;
break;
}
else if(!mGangsterLeftLevel[i] && mGangster[i].IsFleeing())
{
stillWaiting = false;
break;
}
}
if(stillWaiting)
ShowHint(5);
}
break;
case TIMER_ESCAPE:
{
if(mObjectiveArrestGangsters)
{
System::Log("M10: Gangsters start to flee.");
for(int i = 0; i < MAX_GANGSTERS; ++i)
{
if(!mGangsterOutOfOrder[i] && !mGangsterLeftLevel[i])
mGangster[i].SetFleeing(true);
}
}
}
break;
case "CS_Explosion":
{
Audio::PlaySample("mod:/Audio/FX/destruction/explosion04.wav");
for (int i = 0; i < CS_NumParticlesWindowBurst; i++)
{
CS_ParticleWindowBurst[i].Show();
CS_ParticleWindowBurst[i].StartParticleEffect();
}
for (int i = 0; i < CS_NumParticlesExplosion; i++)
{
CS_ParticleExplosion[i].Show();
CS_ParticleExplosion[i].StartParticleEffect();
}
for (int i = 0; i < CS_NumParticlesDust; i++)
{
CS_ParticleDust[i].Show();
CS_ParticleDust[i].StartParticleEffect();
}
for (int i = 0; i < CS_NumDoor; i++)
{
CS_Door[i].Show();
float x, y, z;
CS_Door[i].GetPosition(x, y, z);
CS_Door[i].ApplyForce(0, x, y, z, 0.0f, -10000.0f, 0.0f);
}
Mission::StartSingleTimer("CS_Debris", 0.3f, true);
mCinema.EnableSpecialLights(false);
Game::SetGameSpeed(0.5f);
Camera::SynchronizeWithPhysics();
Camera::Rotate(70, 0, 0, 4.0f);
float x, y, z;
float dirX, dirY, dirZ;
Camera::Get(x, y, z);
Camera::GetDirection(dirX, dirY, dirZ);
System::Print("cam direction: %d %d %d", (int)dirX, (int)dirY, (int)dirZ);
float TargetPointX = x + dirX*5000.0f;
float TargetPointY = y + dirY*5000.0f;
float TargetPointZ = z + dirZ*5000.0f;
Camera::LookAtPoint(TargetPointX, TargetPointY, TargetPointZ, false, -0.0f, 4.0f);
Mission::StartSingleTimer("CS_CloseBars", 2.0f, true);
break;
}
case "CS_Debris":
{
// allow the debris to fly through the walls
mCinema.DisablePhysics();
for (int i = 0; i < CS_NumDebris; i++)
{
CS_Debris[i].Show();
float x, y, z;
CS_Debris[i].GetPosition(x, y, z);
CS_Debris[i].ApplyForce(0, x, y, z, 1000.0f, -5000.0f, 0.0f);
}
Audio::PlaySample("mod:/Audio/FX/destruction/demolition01.wav");
break;
}
case "CS_CloseBars":
{
Game::SetGameSpeed(0.5f); // Sicherheitshalber
Mission::CloseBlackBars(3.0f, 3.0f);
Mission::StartSingleTimer("CS_CleanUp", 1.5f);
Mission::StartSingleTimer("CS_End", 2.0f);
break;
}
case "CS_CleanUp":
{
// clean up
Game::ShowObjects(CutSceneObstacles);
for (int i = 0; i < CS_NumParticlesWindowBurst; i++)
{
CS_ParticleWindowBurst[i].Hide();
}
for (int i = 0; i < CS_NumParticlesExplosion; i++)
{
CS_ParticleExplosion[i].Hide();
}
for (int i = 0; i < CS_NumParticlesDust; i++)
{
CS_ParticleDust[i].Hide();
}
for (int i = 0; i < CS_NumDebris; i++)
{
CS_Debris[i].Hide();
}
for (int i = 0; i < CS_NumDoor; i++)
{
CS_Door[i].Hide();
}
//mCinema.EnablePhysics();
ShowSquadsInCinema(true);
DestroyCinema();
break;
}
case "CS_End":
{
Game::SetGameSpeed(1.0f);
Mission::EndCutScene();
Audio::PlaySoundtrack("10", 0.2f);
DropFlyingChair();
Mission::StartSingleTimer(TIMER_ESCAPE, TIME_ESCAPE);
Mission::StartSingleTimer(TIMER_HINT_5, TIME_HINT_5);
break;
}
}
}
void OnMissionLeft(GameObject *Obj_)
{
// Check if gangster was catched and transported ouf of level (ignore as soon as one of them escaped)
if(mObjectiveArrestGangsters && !Mission::IsObjectiveAccomplished("M10_ARREST_BOMBER") && Obj_->GetType() == ACTOR_PERSON)
{
Person person(Obj_);
if(person.GetRole() == ROLE_GANGSTER)
{
for(int i = 0; i < MAX_GANGSTERS; ++i)
{
if(!mGangsterLeftLevel[i] && mGangster[i].GetID() == person.GetID())
{
System::Log("M10: Gangster transported out of level.");
mGangsterOutOfOrder[i] = true;
mGangsterLeftLevel[i] = true;
break;
}
}
}
}
}
PathFinishedAction OnPathFinished(const char *Path_, GameObject *Caller_)
{
if(Caller_->GetType() == ACTOR_PERSON)
{
if(Caller_->HasName(NAME_VISITORS))
{
Person person(Caller_);
if(person.GetEnteredHouseID() == -1)
{
person.SetDefaultMessageGroup();
if(mGazerCounter++ % VAL_CIVILIAN_GAZER == 0)
person.SetBehaviour(BEHAVIOUR_CIVILIAN_GAZER);
person.SetStandardPath("");
return PATH_STOP;
}
else
System::Log("M10: Path finished without leaving cinema.");
}
else
{
for(int i = 0; i < MAX_GANGSTERS; ++i)
{
if(!mGangsterLeftLevel[i])
{
if(mGangster[i].GetID() == Caller_->GetID())
{
System::Log("M10: Gangster escaped level.");
mGangsterLeftLevel[i] = true;
return PATH_STOP;
}
}
}
}
}
return PATH_DEFAULT;
}
ActionCallbackResult OnPreAction(const char *Action_, ActionCallback* Data_)
{
switch (Action_)
{
case "EActionUse":
{
if(Data_->Parameters[0].iValue == mBomb.GetID())
{
mBombFound = true;
if(mGirl.IsCurrentAnimation("sit"))
{
ShowHint(2);
return ACTION_CLEAR;
}
mDefusingBomb = true;
float *time = reinterpret_cast<float*>(Data_->Parameters[2].pValue);
*time = 30.0;
if(mDefusingProgress > 0)
{
time = reinterpret_cast<float*>(Data_->Parameters[1].pValue);
*time = mDefusingProgress;
}
System::Log("M10: Started to defuse bomb.");
}
}
break;
case "EActionAskPerson":
{
if(mBombExploded)
{
Person target(&Game::GetActor(Data_->Parameters[0].iValue));
target.SetDefaultMessageGroup();
}
}
break;
case "EActionEvacuate":
{
if(!mBombExploded)
{
if(Data_->Parameters[0].iValue == mCinema.GetID())
{
if(!mCinemaEvacuated)
StartEvacuation();
return ACTION_SKIP;
}
}
}
break;
}
return ACTION_CONTINUE;
}
ActionCallbackResult OnPostAction(const char *Action_, ActionCallback* Data_)
{
switch(Action_)
{
case "EActionUse":
{
System::Log("Bomba rozbrojona !!!");
Mission::StopCountDown();
Mission::SetObjectiveAccomplished("M10_DEFUSE_BOMB", true);
if(Data_->Parameters[0].iValue == mBomb.GetID())
mDefusingBomb = false;
}
break;
case "EActionArrestPerson":
{
if(!mBombExploded)
{
Person person(&Game::GetActor(Data_->Parameters[0].iValue));
if(person.HasName(NAME_VISITORS) && person.GetEnteredHouseID() == -1)
{
if(person.GetBehaviour() != BEHAVIOUR_CIVILIAN_GAZER)
{
if(mGazerCounter++ % VAL_CIVILIAN_GAZER == 0)
person.SetBehaviour(BEHAVIOUR_CIVILIAN_GAZER);
}
person.SetDefaultMessageGroup();
person.SetStandardPath("");
}
}
}
break;
}
return ACTION_CONTINUE;
}
ActionCallbackResult OnAbortAction(const char *Action_, ActionCallback* Data_)
{
switch(Action_)
{
case "EActionUse":
{
if(Data_->Parameters[0].iValue == mBomb.GetID())
{
mDefusingBomb = false;
float *time = reinterpret_cast<float*>(Data_->Parameters[1].pValue);
mDefusingProgress = *time;
}
}
break;
case "EActionArrestPerson":
{
if(!mBombExploded)
{
Person person(&Game::GetActor(Data_->Parameters[0].iValue));
if(person.HasName(NAME_VISITORS) && person.GetEnteredHouseID() == -1)
{
if(person.GetBehaviour() != BEHAVIOUR_CIVILIAN_GAZER)
{
if(mGazerCounter++ % VAL_CIVILIAN_GAZER == 0)
person.SetBehaviour(BEHAVIOUR_CIVILIAN_GAZER);
}
person.SetDefaultMessageGroup();
person.SetStandardPath("");
}
}
}
break;
}
return ACTION_CONTINUE;
}
MissionState GetMissionState()
{
if(Mission::IsCutSceneRunning())
return MISSION_RUNNING;
if(Mission::IsDefaultLogicNegative())
{
Audio::SetMusicLevel(0.4f);
return MISSION_FAILED;
}
if (Mission::GetCounter("Person deaths") >= MAX_DIED_PERSONS)
{
mTooManyDied = true;
Audio::SetMusicLevel(0.4f);
return MISSION_FAILED;
}
if (Mission::GetCounter("Burning Houses") >= MAX_BURNING_HOUSES)
{
mFireOutOfControl = true;
Audio::SetMusicLevel(0.4f);
return MISSION_FAILED;
}
if(mObjectiveTransportInjured)
{
if(Mission::GetCounter("Injured Persons") + Mission::GetCounter("Dead Persons") == 0)
{
if(!Mission::IsObjectiveAccomplished("TRANSPORT_INJURED"))
Mission::SetObjectiveAccomplished("TRANSPORT_INJURED", true);
}
else
{
if(Mission::IsObjectiveAccomplished("TRANSPORT_INJURED"))
Mission::SetObjectiveAccomplished("TRANSPORT_INJURED", false);
}
}
if(mObjectiveExtinguishFires)
{
if(Mission::GetCounter("Burning Objects") + Mission::GetCounter("Burning Houses") == 0 )
{
if (!Mission::IsObjectiveAccomplished("EXTINGUISH_FIRES"))
Mission::SetObjectiveAccomplished("EXTINGUISH_FIRES", true);
}
else
{
if (Mission::IsObjectiveAccomplished("EXTINGUISH_FIRES"))
Mission::SetObjectiveAccomplished("EXTINGUISH_FIRES", false);
}
}
if(mObjectiveArrestGangsters && !Mission::IsObjectiveAccomplished("M10_ARREST_BOMBER"))
{
bool allArrestedAndLeft = true;
for(int i = 0; i < MAX_GANGSTERS; ++i)
{
if(!mGangsterLeftLevel[i] || !mGangsterOutOfOrder[i])
{
allArrestedAndLeft = false;
break;
}
}
if(allArrestedAndLeft)
Mission::SetObjectiveAccomplished("M10_ARREST_BOMBER", true);
}
if(!mBombExploded)
{
if(mCinema.NumNonSquadPersonsInside() == 0)
{
if(!Mission::IsObjectiveAccomplished("M10_EVACUATE_CINEMA"))
Mission::SetObjectiveAccomplished("M10_EVACUATE_CINEMA", true);
}
else
{
if(Mission::IsObjectiveAccomplished("M10_EVACUATE_CINEMA"))
Mission::SetObjectiveAccomplished("M10_EVACUATE_CINEMA", false);
}
}
if (Mission::IsDefaultLogicPositive() && Mission::AllObjectivesAccomplished())
{
Audio::SetMusicLevel(0.5f);
return MISSION_SUCCEEDED;
}
return MISSION_RUNNING;
}
const char *GetFailReason()
{
if (mTooManyDied)
return "TOO_MANY_DIED";
if (mFireOutOfControl)
return "TOO_MANY_FIRES";
return "UNKNOWN";
}
float GetRating()
{
float rating = 1.0f;
for(int i = 0; i < MAX_GANGSTERS; ++i)
{
if(mGangsterLeftLevel[i] && !mGangsterOutOfOrder[i])
{
rating -= 0.1f;
break;
}
}
return rating;
}
};
"God, root, what is difference?"
Zapraszam do odwiedzenia mojego serwisu WWW poświęconego szeroko rozumianej "komputerologii" - http://www.opcode.eu.org/ - tam również więcej informacji o mnie.