Guest courtney.wiseman Posted June 2, 2008 Report Share Posted June 2, 2008 can any one send me a script that is for a EM3 mission like the mission the bus driver crashes on the moterway Quote Link to comment Share on other sites More sharing options...
Rulerz Posted October 31, 2008 Report Share Posted October 31, 2008 You still want?Hereconst int MAXVICS = 20;bool driverescape = false;int SpecialHouses = 0;bool FirstVehicle = true;bool AfterCutscene = false;bool HintEscapee = false;bool HintFires2 = false;bool HintDead = false;bool HintArrest = false;object Mission05 : MissionScript{ GameObject AccidentCar; GameObject RaceCar; Person CrossingVictim; Person Victim[MAXVICS]; Person Driver; GameObject Smoke_l; GameObject Smoke_r; GameObject Observer; GameObject White; GameObject CS_WheelSmoke[4]; GameObject FashionShop; GameObject Sign; int NumVics; int CS_SampleRefACar; int CS_SampleRefRCar; int CS_Sliding; int mPhysicsTicks; enum { MAX_DEAD_PEOPLE = 4, MAX_SPECIAL_BURNT_HOUSES = 2, MAX_BURNT_HOUSES = 7, MAX_ARRESTED_PERSONS = 5, }; Mission05() { } void Start() { GameObjectList l0 = Game::GetGameObjects(); int j=0; for(int i=0; i<l0.GetNumObjects(); i++) { GameObject *obj = l0.GetObject(i); if (obj->GetType()==ACTOR_PERSON) { Person p = (Person*)obj; if(j<2) j++; else j = 0; } if(!AccidentCar.GetID() && obj->HasName("cs_left_car")) { AccidentCar = *obj; AccidentCar.SetFlag(OF_TRANSPORTABLE); } else if(!RaceCar.GetID() && obj->HasName("cs_right_car")) { RaceCar = *obj; RaceCar.SetFlag(OF_TRANSPORTABLE); } else if (obj->HasName("Smoke_l")) { Smoke_l = *obj; } else if (obj->HasName("Smoke_r")) { Smoke_r = *obj; } else if(!Observer.GetID() && obj->HasName("observer")) { Observer = *obj; //Observer.SetFlag(OF_TRANSPORTABLE); } else if(!White.GetID() && obj->HasName("white")) { White = *obj; White.SetFlag(OF_TRANSPORTABLE); Person p = (Person*)obj; White.SetEquipment(EQUIP_STARTERFLAG); } } PersonList pl("Victim"); CrossingVictim = *pl.GetPerson(0); PersonList p1("vic1"); Victim[0] = *(p1.GetPerson(0)); PersonList p2("vic2"); Victim[1] = *(p2.GetPerson(0)); PersonList p3("vic3"); Victim[2] = *(p3.GetPerson(0)); PersonList p4("vic4"); Victim[3] = *(p4.GetPerson(0)); PersonList p5("vic5"); Victim[4] = *(p5.GetPerson(0)); PersonList p6("vic6"); Victim[5] = *(p6.GetPerson(0)); PersonList p7("vic7"); Victim[6] = *(p7.GetPerson(0)); PersonList p8("vic8"); Victim[7] = *(p8.GetPerson(0)); NumVics = 8; GameObjectList l2("cs_wheelsmoke"); for (int i = 0; i < 4; i++) { CS_WheelSmoke[i] = *l2.GetObject(i); CS_WheelSmoke[i].Hide(); } GameObjectList l3("FashionShop"); FashionShop = *l3.GetObject(0); GameObjectList l4("cs_sign"); Sign = *l4.GetObject(0); if(!AccidentCar.GetID()) System::Log("AccidentCar is missing"); if(!RaceCar.GetID()) System::Log("RaceCar is missing"); if(!CrossingVictim.GetID()) System::Log("CrossingVictim is missing"); if(!Smoke_l.GetID()) System::Log("Gas left is missing"); if(!Smoke_r.GetID()) System::Log("Gas right is missing"); if(!Observer.GetID()) System::Log("Observer car right is missing"); if(!White.GetID()) System::Log("The girl with the flag is missing"); Mission::SetCounter("ArrestedPersons",0); Mission::AddObjective("M05_ARREST_RACE_DRIVER"); //Mission::StartSingleTimer("StartCutScene", 3.0f); } void RunCutScene() { for(int i = 0; i < NumVics; i++) { Victim[i].SetAnimationTime(0.0f); Victim[i].StopAnimation(); } Audio::PlaySoundtrack("5", 0.1f); CS_Sliding = -1; Mission::StartCutScene(); Mission::ShowBlackBars(); float x, y, z; White.GetPosition(x, y, z); Audio::PlaySample3D("mod:/Audio/FX/misc/crowd01.wav", x, y, z); Camera::StartTransition("Unnamed0", 0.01f); } void OnCameraTransitionFinished() { if (Mission::IsCutSceneRunning()) { White.SetAnimation("waveflag"); Mission::StartSingleTimer("CS_RaceStart", 2.2f); } } void RaceStart() { for (int i = 0; i < 4; i++) { CS_WheelSmoke[i].Show(); CS_WheelSmoke[i].StartParticleEffect(); } AccidentCar.SetObjectPath("cs_left_path"); AccidentCar.SetCurrentPathSpeed(31.0f, 0.5f); RaceCar.SetObjectPath("cs_right_path"); RaceCar.SetCurrentPathSpeed(30.0f, 0.5f); Mission::StartSingleTimer("CS_CrossingVictimWalk", 1.2f); //Mission::StartSingleTimer("CS_ChangeCamera", 3.0f); Camera::FollowTarget(&AccidentCar, 0, 0, 0, true); Audio::PlaySample("mod:/Audio/FX/vehicles/tyresqueal01.wav"); CS_SampleRefACar = Audio::PlaySample("mod:/Audio/FX/vehicles/carmotor04.wav"); CS_SampleRefRCar = Audio::PlaySample("mod:/Audio/FX/vehicles/carmotor04.wav"); } void ChangeCutSceneCamera() { Camera::SynchronizeWithPhysics(); Camera::SetCameraToLocation("Unnamed1"); Game::SetGameSpeed(0.7f); Camera::FollowTarget(&AccidentCar, 0, 0, 0, true); Camera::LookAtTarget(&AccidentCar, true, 100.0f, 2.0f); Camera::Rotate(200, 0, 0, 15.0f); //Audio::PlaySoundtrack("5", 1.0f); } void OnTrigger(const char *Trigger, Actor *Collider) { if (Mission::IsCutSceneRunning() && Trigger == "cs_evade" && Collider->HasName("cs_left_car")) { System::Print("Trigger 'evade'"); GameObject Obj(Collider); if (!Obj.IsPhysicsSimulationEnabled()) { Obj.SetPosition(-2810.827881, -1568.366943, -782.000000); Obj.SetRotation(0.529212, -0.848472, 0.005562, 0.848425, 0.529241, 0.008917, -0.010510, 0.000000, 0.999945); /*Obj.SetPosition(-2808.069824, -1575.084351, -782.000000); Obj.SetRotation(0.462137, -0.886808, 0.000000, 0.886808, 0.462137, 0.000000, 0.000000, 0.000000, 1.000000);*/ Obj.EnablePhysicsSimulation(true); mPhysicsTicks = Game::GetPhysicsStep(); AccidentCar.StartPhysicsEvent(41); Game::SetGameSpeed(0.3f); Obj.ApplyForce(0, 100, 0, 0, 0, 0, 3500); Audio::PlaySample("mod:/Audio/FX/destruction/carcrash03.wav"); Audio::StopSample(CS_SampleRefACar); //Obj.EnablePhysics(); RaceCar.SetCurrentPathSpeed(0.0f, -4.0f); Audio::StopSample(CS_SampleRefRCar); } } else if (Mission::IsCutSceneRunning() && Trigger == "cs_camerachange" && Collider->HasName("cs_left_car")) { ChangeCutSceneCamera(); } else if(!HintEscapee && Trigger == "hint_gangster") { Mission::PlayHint("M05_DRIVER_FLEEING"); HintEscapee = true; } } void OnPhysicsEvent(GameObject *obj) { obj->Explode(); Audio::PlaySample("mod:/Audio/FX/destruction/traincrash03.wav"); Mission::StartSingleTimer("CS_End", 1.7f, true); CS_Sliding = 0; FashionShop.Burn(); } void OnCollision(GameObject *Collider1, GameObject *Collider2) { if (Mission::IsCutSceneRunning()) { if (!Collider2) { if (Collider1->HasName("cs_left_car") && (CS_Sliding > -1)) { CS_Sliding++; if ((CS_Sliding < 150) && (CS_Sliding % 25 == 0)) Audio::PlaySample("mod:/Audio/FX/destruction/demolition01.wav"); } } else { GameObject *house = NULL, *car = NULL, *person = NULL; //if (Collider1->HasName("FashionShop") && Collider2->HasName("cs_left_car")) //{ // house = Collider1; // car = Collider2; //} //else if (Collider2->HasName("FashionShop") && Collider1->HasName("cs_left_car")) //{ // house = Collider2; // car = Collider1; //} //else if (Collider1->GetType() == ACTOR_PERSON && Collider2->HasName("cs_left_car")) { person = Collider1; } else if (Collider1->HasName("cs_left_car") && Collider2->GetType() == ACTOR_PERSON) { person = Collider2; } //if (house) //{ // if (AccidentCar.GetBurningStatus() == OBS_NORMAL) // { // System::Log("Physics step on explode: %d", Game::GetPhysicsStep() - mPhysicsTicks); // AccidentCar.Explode(); // Audio::PlaySample("mod:/Audio/FX/destruction/traincrash03.wav"); // Mission::StartSingleTimer("CS_End", 1.7f, true); // CS_Sliding = 0; // house->Burn(); // } //} //else if (person) { if (!person->IsPhysicsSimulationEnabled() && person->GetID() != CrossingVictim.GetID()) { //Collider1->SetAnimationTime(0.0f); person->EnablePhysicsSimulation(); person->EnablePhysics(); Person p = (Person*)person; p.Injure(INJUREREASON_ENERGY); } } } } } void UpdateCutScene() { } void Update() { if(!HintFires2 && Mission::GetCounter("Burning Houses") > 5) { HintFires2 = true; Mission::PlayHint("M05_FIRE02"); } if(!HintDead && Mission::GetCounter("Dead civils") > 0) { HintDead = true; Mission::PlayHint("M05_INJURED_DEAD"); } if(Mission::GetCounter("Injured Civils")== 0) Mission::SetObjectiveAccomplished("M05_TREAT_AND_TRANSPORT_INJURED_PERSONS", true); if(AfterCutscene && Driver.IsValid()) { if(Driver.HasArrived("driver_path_2")) driverescape = true; } } void OnMissionLeft(GameObject *obj) { if(obj && obj->GetID() == Driver.GetID()) Mission::SetObjectiveAccomplished("M05_ARREST_RACE_DRIVER", true); } void StartSecondPath() { Driver.SetObjectPath("driver_path_2"); } PathFinishedAction OnPathFinished(const char *Path, GameObject *Obj) { if(Obj && Path=="escape_path" && Obj->GetID()==RaceCar.GetID()) { Driver = Game::CreatePerson("mod:Prototypes/Persons/Civil/streetracer01.e3p", "Driver"); float x, y, z; RaceCar.GetPosition(x, y, z); y -= 100; Driver.SetPosition(x, y, z); Driver.SetEscapePath("driver_path_1"); Driver.SetFleeing(true); Driver.SetMessageGroup("flight"); return PATH_STOP; } else if(Obj && Path=="driver_path_1" && Obj->GetID()==Driver.GetID()) { VehicleList l3("D_police"); for(int i = 0; i<l3.GetNumVehicles();i++) if(Driver.Distance(l3.GetVehicle(i)) <= 100) { StartSecondPath(); return; } Driver.PushActionWait(ACTION_INSERT,1); StartSecondPath(); } return PATH_DEFAULT; } void OnTimer(const char *Timer, float Time) { switch(Timer) { case "StartCutScene": { RunCutScene(); break; } case "CS_RaceStart": { RaceStart(); White.StopAnimation(); break; } case "CS_CrossingVictimWalk": { CrossingVictim.SetAnimation("run"); CrossingVictim.SetObjectPath("cs_victim_path"); break; } case "CS_ChangeCamera": { break; } case "CS_CarSliding": { Audio::PlaySample("mod:/Audio/FX/destruction/explosion03.wav"); break; } case "CS_End": { Mission::HideBlackBars(); Mission::EndCutScene(); Game::SetGameSpeed(1.0f); float x, y, z; Camera::Get(x, y, z); Camera::Set(x, y, 200.0f); Mission::StartSingleTimer("CS_Check", 5.0f); System::Print("Escape-Path"); RaceCar.PushActionWait(ACTION_NEWLIST, 0.0f); RaceCar.SetObjectPath("escape_path"); RaceCar.SetCurrentPathSpeed(10.0f, 2.0f); Observer.SetObjectPath("northen_path"); White.SetObjectPath("white_path"); AfterCutscene = true; Mission::AddObjective("M05_TREAT_AND_TRANSPORT_INJURED_PERSONS"); Mission::AddObjective("M05_EXTINGUISH_FIRES"); Mission::AddObjective("M05_TRANSPORT_WRECK"); Audio::SetMusicLevel(0.2f); break; } case "CS_Check": { //for (int i = 0; i < NumVics; i++) //{ // Victim[i].DumpObjectPositionAndRotation("Victim[i]"); //} //if (Sign.IsValid()) // Sign.DumpObjectPositionAndRotation("Sign"); //AccidentCar.DumpObjectPositionAndRotation("AccidentCar"); Sign.DisablePhysicsSimulation(); AccidentCar.DisablePhysicsSimulation(); //Sign.SetPlacementNone(); //AccidentCar.SetPlacementNone(); if (Sign.IsValid()) { if (Sign.Distance(-2314.819336, 184.850021, -779.237061) > 1.0f) { Sign.SetPosition(-2314.819336, 184.850021, -779.237061); Sign.SetRotation(-0.000006, 0.933998, 0.357279, 0.000003, -0.357279, 0.933998, 1.000000, 0.000007, -0.000000); System::Log("?CutScene: Sign too far away from preset"); } } if (AccidentCar.Distance(-2282.250732, 562.604065, -724.171204) > 1.0f) { AccidentCar.SetPosition(-2282.250732, 562.604065, -724.171204); AccidentCar.SetRotation(-0.862085, -0.506764, 0.000027, -0.506764, 0.862085, -0.000022, -0.000012, -0.000033, -1.000000); System::Log("?CutScene: AccidentCar too far away from preset"); } Sign.EnablePhysicsSimulation(); AccidentCar.EnablePhysicsSimulation(); if (Victim[0].Distance(-2511.181396, -1321.158325, -768.913757) > 1.0f) { Victim[0].Injure(INJUREREASON_ENERGY); Victim[0].DisablePhysicsSimulation(); Victim[0].SetPosition(-2511.181396, -1321.158325, -768.913757); Victim[0].SetRotationPutInXY(0.706639, -0.285365, 0.647479, 0.631727, -0.157744, -0.758971, 0.318720, 0.945348, 0.068805); System::Log("?CutScene: Vic 1 too far away from preset"); } if (Victim[1].Distance(-2212.655273, 5.111188, -779.595642) > 1.0f) { Victim[1].Injure(INJUREREASON_ENERGY); Victim[1].DisablePhysicsSimulation(); Victim[1].SetPosition(-2212.655273, 5.111188, -779.595642); Victim[1].SetRotationPutInXY(0.009504, 0.691150, 0.722648, -0.089478, -0.719194, 0.689024, 0.995943, -0.071210, 0.055007); System::Log("?CutScene: Vic 2 too far away from preset"); } if (Victim[2].Distance(-2333.146729, -400.425720, -777.837769) > 1.0f) { Victim[2].Injure(INJUREREASON_ENERGY); Victim[2].DisablePhysicsSimulation(); Victim[2].SetPosition(-2333.146729, -400.425720, -777.837769); Victim[2].SetRotationPutInXY(-0.094419, -0.984924, -0.144949, 0.048736, -0.149998, 0.987484, -0.994339, 0.086173, 0.062164); System::Log("?CutScene: Vic 3 too far away from preset"); } if (Victim[3].Distance(-2449.726318, -320.003326, -779.393738) > 1.0f) { Victim[3].Injure(INJUREREASON_ENERGY); Victim[3].DisablePhysicsSimulation(); Victim[3].SetPosition(-2449.726318, -320.003326, -779.393738); Victim[3].SetRotationPutInXY(0.036819, 0.816233, 0.576549, -0.089397, -0.571937, 0.815412, 0.995315, -0.081565, 0.051910); System::Log("?CutScene: Vic 4 too far away from preset"); } if (Victim[4].Distance(-2658.540283, -1111.164551, -765.956848) > 1.0f) { Victim[4].Injure(INJUREREASON_ENERGY); Victim[4].DisablePhysicsSimulation(); Victim[4].SetPosition(-2658.540283, -1111.164551, -765.956848); Victim[4].SetRotationPutInXY(0.115247, 0.618137, -0.777576, 0.054405, -0.785545, -0.616409, -0.991846, 0.028736, -0.124162); System::Log("?CutScene: Vic 5 too far away from preset"); } if (Victim[5].Distance(-2497.291748, -801.483154, -778.140015) > 1.0f) { Victim[5].Injure(INJUREREASON_ENERGY); Victim[5].DisablePhysicsSimulation(); Victim[5].SetPosition(-2497.291748, -801.483154, -778.140015); Victim[5].SetRotationPutInXY(0.115641, 0.742766, 0.659489, -0.299460, -0.606981, 0.736137, 0.947075, -0.282618, 0.152237); System::Log("?CutScene: Vic 6 too far away from preset"); } break; } } } void OnSquadVehicleArrived(Vehicle *v) { if(FirstVehicle) { Mission::StartSingleTimer("StartCutScene", 3.0f); FirstVehicle = false; } } ActionCallbackResult OnPostAction(const char *Action, ActionCallback* Data) { switch(Action) { case "EActionArrestPerson" : { if(Data->Parameters[0].iValue!=Driver.GetID()) { Mission::IncCounter("ArrestedPersons"); Mission::PlayHint("M05_ARREST_INNOCENT"); } break; } } return ACTION_CONTINUE; } MoveCollCheck OnCheckMoveCollision(GameObject *Obj, Actor *act) { if (Mission::IsCutSceneRunning()) { if (Obj->HasName("cs_left_car")) { return MCC_IGNORE_CONTINUE; } } return MCC_HALT_CONTINUE; } MissionState GetMissionState() { if(driverescape) { Audio::SetMusicLevel(0.3f); return MISSION_FAILED; } if(Mission::GetCounter("Civil Deaths") >= MAX_DEAD_PEOPLE) { Audio::SetMusicLevel(0.3f); return MISSION_FAILED; } if(AfterCutscene && Mission::AllObjectivesAccomplished()) { Audio::SetMusicLevel(0.4f); return MISSION_SUCCEEDED; } if(Mission::GetCounter("Burning Houses") >= MAX_BURNT_HOUSES) { Audio::SetMusicLevel(0.3f); return MISSION_FAILED; } if(Mission::GetCounter("ArrestedPersons") >= MAX_ARRESTED_PERSONS) { Audio::SetMusicLevel(0.3f); return MISSION_FAILED; } if(Mission::GetCounter("Burning Houses") == 0) Mission::SetObjectiveAccomplished("M05_EXTINGUISH_FIRES", true); else Mission::SetObjectiveAccomplished("M05_EXTINGUISH_FIRES", false); SpecialHouses = 0; GameObjectList l0("Special"); for(int i=0; i<l0.GetNumObjects(); i++) { GameObject *obj = l0.GetObject(i); if(obj->GetBurningStatus() == OBS_FULLBURNED) SpecialHouses++; } if(SpecialHouses >= MAX_SPECIAL_BURNT_HOUSES ) { Audio::SetMusicLevel(0.3f); return MISSION_FAILED; } if(!AccidentCar.IsValid()) Mission::SetObjectiveAccomplished("M05_TRANSPORT_WRECK", true); return MISSION_RUNNING; } const char *GetFailReason() { if(driverescape) return "M05_GANGSTER_ESCAPED"; if(Mission::GetCounter("Civil deaths") >= MAX_DEAD_PEOPLE) return "TOO_MANY_DEADS"; if(Mission::GetCounter("Burning Houses") >= MAX_BURNT_HOUSES) return "TOO_MANY_FIRES"; if(SpecialHouses >= MAX_SPECIAL_BURNT_HOUSES ) return "TOO_MANY_FIRES"; if(Mission::GetCounter("ArrestedPersons") >= MAX_ARRESTED_PERSONS) return "M05_TOO_MANY_INNOCENT_ARRESTED"; return "UNKNOWN"; } bool SerializeTo(ScriptSerializer *Serializer) { int Version = 0x0100; Serializer->Write(Version); Serializer->Write(driverescape); Serializer->Write(SpecialHouses); Serializer->Write(FirstVehicle); Serializer->Write(AfterCutscene); Serializer->Write(AccidentCar); Serializer->Write(RaceCar); Serializer->Write(CrossingVictim); for(int i=0; i<MAXVICS; i++) Serializer->Write(Victim[i]); Serializer->Write(FashionShop); Serializer->Write(Sign); Serializer->Write(Driver); Serializer->Write(Smoke_l); Serializer->Write(Smoke_r); Serializer->Write(Observer); Serializer->Write(White); for(int i=0; i<4; i++) Serializer->Write(CS_WheelSmoke[i]); Serializer->Write(NumVics); Serializer->Write(CS_SampleRefACar); Serializer->Write(CS_SampleRefRCar); Serializer->Write(CS_Sliding); Serializer->Write(HintEscapee); Serializer->Write(HintFires2); Serializer->Write(HintDead); Serializer->Write(HintArrest); return true; } bool SerializeFrom(ScriptSerializer *Serializer) { int Version; Serializer->Read(Version); //Serializer->Read(driverescape); driverescape = Serializer->ReadBool(); Serializer->Read(SpecialHouses); //Serializer->Read(FirstVehicle); FirstVehicle = Serializer->ReadBool(); //Serializer->Read(AfterCutscene); AfterCutscene = Serializer->ReadBool(); Serializer->Read(AccidentCar); Serializer->Read(RaceCar); Serializer->Read(CrossingVictim); for(int i=0; i<MAXVICS; i++) Serializer->Read(Victim[i]); Serializer->Read(FashionShop); Serializer->Read(Sign); Serializer->Read(Driver); Serializer->Read(Smoke_l); Serializer->Read(Smoke_r); Serializer->Read(Observer); Serializer->Read(White); for(int i=0; i<4; i++) Serializer->Read(CS_WheelSmoke[i]); Serializer->Read(NumVics); Serializer->Read(CS_SampleRefACar); Serializer->Read(CS_SampleRefRCar); Serializer->Read(CS_Sliding); //Serializer->Read(HintEscapee); HintEscapee = Serializer->ReadBool(); //Serializer->Read(HintFires2); HintFires2 = Serializer->ReadBool(); //Serializer->Read(HintDead); HintDead = Serializer->ReadBool(); //Serializer->Read(HintArrest); HintArrest = Serializer->ReadBool(); return true; } float GetRating() { return 1.0f; }}; Quote Link to comment Share on other sites More sharing options...