Jump to content
Haszki

NYC FireStation

Recommended Posts

HI, In the second third base for the car is reserved for an ambulance to be able to change the fire trucks parked there?

//******************************************************************************************

// #Version 1.4#

//

// Includes: To fire station command.

//

// - VcmdToFireStation

//

// Script by Hoppah

//

// Usage of this script in other mods is NOT allowed without permission of Hoppah

//

//******************************************************************************************

const char NAME_FS1_CP[] = "fs1_cp";

const char NAME_FS2_CP[] = "fs2_cp";

const char CMD_AUTOSIREN_OFF[] = "VcmdAutoSirenOff";

const char CMD_FLASHINGLIGHTS[] = "VcmdFlashingLights";

const char CMD_WARNINGLIGHTS[] = "VcmdWarningLightsOn";

const char CMD_FLOODLIGHTS_OFF[] = "VcmdFloodLightsOff";

const char CMD_FLOODLIGHTS_ON[] = "VcmdFloodLightsOn";

const char CMD_PATROL[] = "VcmdPatrol";

const char CMD_TOFIRESTATION[] = "VcmdToFireStation";

const char DUMMY_PATROL[] = "DummyPatrol";

const char DUMMY_WARNINGLIGHTS[] = "DummyHasWarningLights";

const char DUMMY_DISABLE[] = "DummyDisableSiren";

const char DUMMY_HASSIREN[] = "DummyHasSiren";

const char DUMMY_HOSESON[] = "DummyHosesAreOn";

const char DUMMY_VCALLED[] = "DummyVehicleCalled";

const char DUMMY_GATES[] = "DummyGates";

const char PROTO_ENGINE01[] = "mod:Prototypes/Vehicles/Straz/MAtegoGBA.e4p";

const char PROTO_ENGINE02[] = "mod:Prototypes/Vehicles/Straz/Scania GCBA.e4p";

const char PROTO_SQUAD01[] = "mod:Prototypes/Vehicles/02 Fire Department/squad61.e4p";

const char PROTO_LADDER01[] = "mod:Prototypes/Vehicles/02 Fire Department/ladder01.e4p";

const char PROTO_LADDER02[] = "mod:Prototypes/Vehicles/Straz/DLK.e4p";

const char PROTO_RESCUE01[] = "mod:Prototypes/Vehicles/02 Fire Department/Rescue1.e4p";

const char PROTO_BAT01[] = "mod:Prototypes/Vehicles/Straz/KDOW.e4p";

const char PROTO_BAT02[] = "mod:Prototypes/Vehicles/Straz/Ford Mondeo.e4p";

const char PROTO_AMBO01[] = "mod:Prototypes/Vehicles/01 Ambulance/Ambulance01.e4p";

const char VO_FP1[] = "fs_fp01";

const char VO_FP2[] = "fs_fp02";

const char VO_FP3[] = "fs_fp03";

const char VO_FP4[] = "fs_fp04";

const char VO_FP5[] = "fs_fp05";

const char VO_FP6[] = "fs_fp06";

const char VO_FP7[] = "fs_fp07";

const char VO_FP8[] = "fs_fp08";

const char NAME_GATE01[] = "fs_gate01";

const char NAME_GATE02[] = "fs_gate02";

const char NAME_GATE03[] = "fs_gate03";

//const char NAME_GATE04[] = "fs_gate04";

//const char NAME_GATE05[] = "fs_gate05";

const char NAME_GATE06[] = "fs_gate06";

const char NAME_GATE07[] = "fs_gate07";

const char NAME_GATE08[] = "fs_gate08";

const char VO_GATE01[] = "fs_vogate01";

const char VO_GATE02[] = "fs_vogate02";

const char VO_GATE03[] = "fs_vogate03";

const char VO_GATE04[] = "fs_vogate04";

const char VO_GATE05[] = "fs_vogate05";

const char VO_GATE06[] = "fs_vogate06";

const char VO_GATE07[] = "fs_vogate07";

const char VO_GATE08[] = "fs_vogate08";

const char VO_LADDER01[] = "fs_ladder01";

const char VO_LADDER02[] = "fs_ladder02";

const char VO_ENGINE01[] = "fs_engine01";

const char VO_ENGINE02[] = "fs_engine02";

const char VO_SQUAD01[] = "fs_squad01";

const char VO_RESCUE01[] = "fs_rescue01";

const char VO_BAT01[] = "fs_bat01";

const char VO_BAT02[] = "fs_bat02";

const char VO_FS01[] = "fs1";

const char VO_FS02[] = "fs2";

const char VO_FS01_SPAWN[] = "fs1_spawn";

const char VO_FS02_SPAWN[] = "fs2_spawn";

const char HINT_NOSPACE[] = "No space at the fire station, vehicle returns to base!";

const char HINT_NOTVALID[] = "This vehicle doesn't belong in the fire station!";

int DummyGroup = 32;

object VcmdToFireStation : CommandScript

{

VcmdToFireStation()

{

SetCursor("tofirestation");

SetIcon("tofirestation");

SetGroupID(DummyGroup);

SetGroupLeader(true);

SetRestrictions(RESTRICT_SELFEXECUTE);

}

bool CheckPossible(GameObject *Caller)

{

if (!Caller->IsValid())

return false;

if (!Game::IsFreeplay())

return false;

Vehicle v(Caller);

if (v.IsCollidingWithVirtualObject(VO_FS01) || v.IsCollidingWithVirtualObject(VO_FS02) || v.HasCommand(DUMMY_HOSESON) || v.IsInstalled())

return false;

if (!v.HasCommand("MoveTo"))

return false;

return true;

}

bool CheckTarget(GameObject *Caller, Actor *Target, int childID)

{

if (!Caller->IsValid() || !Target->IsValid() || (Caller->GetID() != Target->GetID()))

return false;

return true;

}

void PushActions(GameObject *Caller, Actor *Target, int ChildID)

{

if (ChildID == 0)

{

Vehicle v(Caller);

if (v.IsBlueLightEnabled())

Game::ExecuteCommand(CMD_FLASHINGLIGHTS, &v, &v);

if (v.HasCommand(DUMMY_WARNINGLIGHTS))

{

v.EnableBlinker(BLT_NONE);

v.RemoveCommand(DUMMY_WARNINGLIGHTS);

v.AssignCommand(CMD_WARNINGLIGHTS);

}

if (v.HasCommand(CMD_FLOODLIGHTS_OFF))

{

v.EnableSpecialLights(false);

v.RemoveCommand(CMD_FLOODLIGHTS_OFF);

v.AssignCommand(CMD_FLOODLIGHTS_ON);

}

if (v.HasObjectPath(NULL))

Game::ExecuteCommand(DUMMY_PATROL, &v, &v);

if (v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF))

Game::ExecuteCommand(DUMMY_DISABLE, &v, &v);

GameObjectList l1;

ActorList g1;

if (StrCompare(v.GetPrototypeFileName(), PROTO_LADDER01) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_LADDER01, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_FP1);

}

else if (StrCompare(v.GetPrototypeFileName(), PROTO_ENGINE01) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_ENGINE01, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_FP2);

}

else if (StrCompare(v.GetPrototypeFileName(), PROTO_SQUAD01) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_SQUAD01, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_FP3);

}

else if (StrCompare(v.GetPrototypeFileName(), PROTO_RESCUE01) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_RESCUE01, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_FP4);

}

else if (StrCompare(v.GetPrototypeFileName(), PROTO_BAT01) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_BAT01, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_FP5);

}

else if (StrCompare(v.GetPrototypeFileName(), PROTO_LADDER02) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_LADDER02, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_FP6);

}

else if (StrCompare(v.GetPrototypeFileName(), PROTO_ENGINE02) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_ENGINE02, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_FP7);

}

else if (StrCompare(v.GetPrototypeFileName(), PROTO_BAT02) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_BAT02, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_FP8);

}

else

{

Mission::PlayHint(HINT_NOTVALID);

return;

}

if (l1.GetNumObjects() > 0)

{

Mission::PlayHint(HINT_NOSPACE);

v.PushActionReturnToBase(ACTION_NEWLIST);

return;

}

Vector Pos = g1.GetActor(0)->GetPosition();

v.PushActionmove(ACTION_NEWLIST, Pos);

v.PushActionWait(ACTION_APPEND, 0.1f);

v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOFIRESTATION, Caller, 1, false);

}

if (ChildID == 1)

{

Vehicle v(Caller);

GameObjectList l1, g3;

ActorList g1, g2;

GameObject gate;

Vector Pos1, Pos2;

bool OpenGate = false;

if (StrCompare(v.GetPrototypeFileName(), PROTO_LADDER01) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_LADDER01, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_LADDER01);

g2 = Game::GetActors(VO_GATE01);

g3 = Game::GetGameObjects(NAME_GATE01);

}

else if (StrCompare(v.GetPrototypeFileName(), PROTO_ENGINE01) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_ENGINE01, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_ENGINE01);

g2 = Game::GetActors(VO_GATE02);

g3 = Game::GetGameObjects(NAME_GATE01);

}

else if (StrCompare(v.GetPrototypeFileName(), PROTO_SQUAD01) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_SQUAD01, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_SQUAD01);

g2 = Game::GetActors(VO_GATE03);

g3 = Game::GetGameObjects(NAME_GATE02);

}

else if (StrCompare(v.GetPrototypeFileName(), PROTO_RESCUE01) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_RESCUE01, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_RESCUE01);

g2 = Game::GetActors(VO_GATE04);

g3 = Game::GetGameObjects(NAME_GATE02);

}

else if (StrCompare(v.GetPrototypeFileName(), PROTO_BAT01) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_BAT01, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_BAT01);

g2 = Game::GetActors(VO_GATE05);

g3 = Game::GetGameObjects(NAME_GATE03);

}

else if (StrCompare(v.GetPrototypeFileName(), PROTO_LADDER02) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_LADDER02, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_LADDER02);

g2 = Game::GetActors(VO_GATE06);

g3 = Game::GetGameObjects(NAME_GATE06);

}

else if (StrCompare(v.GetPrototypeFileName(), PROTO_ENGINE02) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_ENGINE02, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_ENGINE02);

g2 = Game::GetActors(VO_GATE07);

g3 = Game::GetGameObjects(NAME_GATE07);

}

else if (StrCompare(v.GetPrototypeFileName(), PROTO_BAT02) == 0)

{

Game::CollectObstaclesOnVirtualObject(VO_BAT02, l1, ACTOR_VEHICLE);

g1 = Game::GetActors(VO_BAT02);

g2 = Game::GetActors(VO_GATE08);

g3 = Game::GetGameObjects(NAME_GATE08);

}

else

{

Mission::PlayHint(HINT_NOTVALID);

return;

}

if (l1.GetNumObjects() > 0)

{

Mission::PlayHint(HINT_NOSPACE);

v.PushActionReturnToBase(ACTION_NEWLIST);

return;

}

if (v.HasCommand(DUMMY_VCALLED))

v.RemoveCommand(DUMMY_VCALLED);

Pos1 = g1.GetActor(0)->GetPosition();

Pos2 = g2.GetActor(0)->GetPosition();

gate = g3.GetObject(0);

if (gate.GetUserData() == 0)

OpenGate = true;

v.PushActionTurnTo(ACTION_NEWLIST, Pos1);

//v.PushActionRotateTarget(ACTION_APPEND, &v, 0, 180, 0, 0.01);

if (OpenGate)

v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false); //Open gate

v.PushActionWait(ACTION_APPEND, 0.1f);

v.PushActionmove(ACTION_APPEND, Pos1);

v.PushActionTurnTo(ACTION_APPEND, Pos2);

if (StrCompare(v.GetPrototypeFileName(), PROTO_BAT01) != 0)

v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOFIRESTATION, Caller, 2, false);

v.PushActionWait(ACTION_APPEND, 4.0f);

if (OpenGate)

v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false); //Close gate

}

if (ChildID == 2)

{

Vehicle v(Caller);

if (v.IsCollidingWithVirtualObject(VO_FS01))

ActorList l1 = Game::GetActors(VO_FS01_SPAWN);

else if (v.IsCollidingWithVirtualObject(VO_FS02))

ActorList l1 = Game::GetActors(VO_FS02_SPAWN);

else

return;

Vector Pos = l1.GetActor(0)->GetPosition();

PersonList pass = v.GetPassengers();

if (pass.GetNumPersons() > 0)

{

for(int i=0; i<pass.GetNumPersons(); i++)

{

Person *p = pass.GetPerson(i);

p->PushActionLeaveCar(ACTION_NEWLIST, Caller);

p->PushActionmove(ACTION_APPEND, Pos);

p->PushActionDeleteOwner(ACTION_APPEND);

}

}

}

if (ChildID == 3) //temp!

{

if (v.GetNumPassengers() > 0 && (FS1Closer && cp1.HasCommand("VcmdAutoStaffOff")) || (FS2Closer && cp2.HasCommand("VcmdAutoStaffOff")))

v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOFIRESTATION, Caller, 2, false);

GameObjectList cpl1 = Game::GetGameObjects(NAME_FS1_CP);

GameObject cp1 = cpl1.GetObject(0);

GameObjectList cpl2 = Game::GetGameObjects(NAME_FS2_CP);

GameObject cp2 = cpl2.GetObject(0);

bool FS1Closer = false;

bool FS2Closer = false;

if (Math::dist(Pos.x, Pos.y, cp1.GetPosition().x, cp1.GetPosition().y) > Math::dist(Pos.x, Pos.y, cp2.GetPosition().x, cp2.GetPosition().y))

FS2Closer = true;

else

FS1Closer = true;

}

}

};

object DummyEngine : CommandScript

{

DummyEngine()

{

SetGroupID(DummyGroup);

}

bool CheckTarget(GameObject *Caller, Actor *Target, int ChildID)

{

}

void PushActions(GameObject *Caller, Actor *Target, int ChildID)

{

}

};

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...