Jump to content
Ghost Graphic Designs

Setting up an alarm script

Recommended Posts

Sup. 

 

I'm trying to make a not-so-simple alarm script like most of the german mods and like the Copenhagen Mod (once again lol). The script is based on a person prototype that has the command to call the units. When you click on "Call Light Pumper" it will play an alarm sound, spawn the personnel, open the respective gates and send the vehicle to the scene and I'll need the opposite for the units to return to the station, delete the personnel and close the gates. I'll need these options, if possible (and with different alarm sounds for each option):

  • Fire Engine + Light Pumper + Ladder Truck + Ambulance (the ambo comes from outside of the map)
  • Fire Engine + Light Pumper
  • Fire Engine
  • Ladder Truck + Light Pumper
  • Light Pumper
  • Battalion Chief
  • Light Equipment Vehicle (only lights)
  • Ambulance
  • 2x Fire Engine + Light Pumper + Ladder Truck + Ambulance + Command Unit (all come from outside of the map)

Are these ideas possible? I've seen some german scripts and I really dunno where to start. I can edit scripts and change some simple stuff, but other than that I really don't have lots of experience in scripting.

 

PS: I'm not asking someone to make a script for me. I'm just asking for some guidelines to know what I have to do and which lines I need to edit.

 

Here's the script I'm trying to edit

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

** Berufsfeuerwehr-Alarmierungsscript by Wingman **
** Das Alarmierungsscript ist stark vereinfacht, **
** sodass auch anfänger es verstehen sollten. **
** Regeln entnehmen sie der Readme, bei der zu **
** beachten ist das sie aktuell ist. Auch **
** mündlich oder schriftlich ausgesprochene **
** Verbote gelten. -Wingman- **
**************************************************/

const char *Startpunkt = "VOName"; // Hier der Name des Virtuellen Objektes an dem die Personen starten sollen
const char *Fahrzeugname = "Fahrzeug"; // Hier den Namen des Fahrzeuges, in dem die Personen einsteigen sollen
const char *PersonenProto1 = "mod:Prototypes/Persons/Fire Department/firefighternorm_upgrade2.e4p"; // Hier den Pfad zu einem Prototypen von denen Personen erstellt werden soll
const char *PersonenProto2 = "mod:Prototypes/Persons/Fire Department/firefighterabc_upgraded2.e4p"; // Hier den Pfad zu einem Prototypen von denen Personen erstellt werden soll. Falls nicht benötigt frei lassen
const char *PersonenProto3 = "mod:Prototypes/Persons/Fire Department/firefightermask_upgraded2.e4p"; // Hier den Pfad zu einem Prototypen von denen Personen erstellt werden soll. Falls nicht benötigt frei lassen
int AnzahlProto1 = 3; // Hier die Anzahl der Personen die vonm Prototyp 1 erstellt werden soll. Wenn keine erstellt werden sollen einfach eine 0.
int AnzahlProto2 = 2; // Hier die Anzahl der Personen die vonm Prototyp 2 erstellt werden soll. Wenn keine erstellt werden sollen einfach eine 0.
int AnzahlProto3 = 1; // Hier die Anzahl der Personen die vonm Prototyp 3 erstellt werden soll. Wenn keine erstellt werden sollen einfach eine 0.
int ZurEst = 0; // Hier kannst du einstellen ob das Fahrzeug direkt zur Einsatzstelle fahren soll oder ob es vom user gesteuert wird. 0 = Direkt. 1 = User.
int SoSiAn = 0; //Hier kannst du einstellen ob das Fahrzeug ein Sondersignal einschalten soll. Hierzu wird ein zusätzliches Script benötigt. 0 = An. 1 = Aus.
const char *SoSiScript = "VCmdSiren"; // Hier muss der Name des Commandscripts vom SoSi-Script rein. Falls vorhanden.
float WarteZeit = 5.f; //Hier kannst du die Wartezeit einstellen bis die Personen erscheinen und zu den fahrzeugen laufen.
Vector EPos;
const char *SoundPfad = "mod:Audio/Alarm.wav"; // Hier den Sound der bei der Alarmierung abgespielt werden soll. Falls keiner einfach frei lassen.
int TorAuf = 1; // Hier stellen sie ein ob ein tor geöffnet werden soll. 0 = auf. 1 = Nichts.
const char *TorName = "GateFZ1"; // Hier den Namen des Tores, das geöffnet werden soll.
const char *TorAniName = "open"; // Hier den Namen der Animation von dem Tor.

object AlarmFahrzeug1 : CommandScript
{
AlarmFahrzeug1()
{
SetIcon("IconName"); // Hier den Icon Namen
SetCursor("CursorName"); // Hier den Cursorname
if (ZurEst == 0)
SetValidTargets(ACTOR_STREET || ACTOR_FLOOR);
else
SetActivationByLeftClick(true);
}

bool CheckPossible(GameObject *Caller)
{
GameObjectList gol;
gol = Game::GetGameObjects(Fahrzeugname);
GameObject *go;
go = *gol.GetObject(0);
Vehicle v(go);
if (v.HasCommand("DUMMYFPSetFreeForAlertFalse"))
return false;
return true;
}

bool CheckTarget(GameObject *Caller, Actor *Target, int ChildID)
{
return true;
}

void PushActions(GameObject *Caller, Actor *Target, int childID)
{
GameObjectList gol;
gol = Game::GetGameObjects(Fahrzeugname);
GameObject *go;
go = *gol.GetObject(0);
Vehicle v(go);
ActorList al = Game::GetActors(Startpunkt);
Actor a = *al.GetActor(0);
Vector SP = a.GetPosition();
EPos = Game::GetCommandPos();
v.AssignCommand("DUMMYFPSetFreeForAlertFalse");
v.SetMaxPassengers((AnzahlProto1 + AnzahlProto2 + AnzahlProto3));
Audio::PlaySample(SoundPfad);

if (TorAuf == 0)
{
GameObjectList gol = Game::GetGameObjects(TorName);
GameObject *go1;
go1 = *gol.GetObject(0);
go1->PushActionSwitchAnim(ACTION_APPEND, TorAniName);
}

for (int i = 0; i < AnzahlProto1 || i < AnzahlProto2 || i < AnzahlProto3; i++)
{
if (i < AnzahlProto1)
{
Person p = Game::CreatePerson(PersonenProto1,"Unnamed");
p.PushActionShowHide(ACTION_NEWLIST, true);
p.SetRole(ROLE_SQUAD);
p.SetUpgradeLevel(3);
p.PushActionWait(ACTION_APPEND, WarteZeit);
Game::FindFreePosition(&p, SP, 100.f);
p.SetPosition(SP);
p.PushActionShowHide(ACTION_APPEND, false);
p.PushActionMove(ACTION_APPEND, v.GetPosition());
p.PushActionEnterCar(ACTION_APPEND, &v);
p.PushActionExecuteCommand(ACTION_APPEND, "FahrenAlarmFahrzeug1", &v, 0, false);
}

if (i < AnzahlProto2)
{
Person p = Game::CreatePerson(PersonenProto2,"Unnamed");
p.PushActionShowHide(ACTION_NEWLIST, true);
p.SetRole(ROLE_SQUAD);
p.SetUpgradeLevel(3);
p.PushActionWait(ACTION_APPEND, WarteZeit);
Game::FindFreePosition(&p, SP, 100.f);
p.SetPosition(SP);
p.PushActionShowHide(ACTION_APPEND, false);
p.PushActionMove(ACTION_APPEND, v.GetPosition());
p.PushActionEnterCar(ACTION_APPEND, &v);
p.PushActionExecuteCommand(ACTION_APPEND, "FahrenAlarmFahrzeug1", &v, 0, false);
}

if (i < AnzahlProto3)
{
Person p = Game::CreatePerson(PersonenProto3,"Unnamed");
p.PushActionShowHide(ACTION_NEWLIST, true);
p.SetRole(ROLE_SQUAD);
p.SetUpgradeLevel(3);
p.PushActionWait(ACTION_APPEND, WarteZeit);
Game::FindFreePosition(&p, SP, 100.f);
p.SetPosition(SP);
p.PushActionShowHide(ACTION_APPEND, false);
p.PushActionMove(ACTION_APPEND, v.GetPosition());
p.PushActionEnterCar(ACTION_APPEND, &v);
p.PushActionExecuteCommand(ACTION_APPEND, "FahrenAlarmFahrzeug1", &v, 0, false);
}
}
}
};

object FahrenAlarmFahrzeug1 : CommandScript
{
FahrenAlarmFahrzeug1()
{
SetIcon("IconName");
SetCursor("CursorName");
}

bool CheckPossible(GameObject *Caller)
{
return true;
}

bool CheckTarget(GameObject *Caller, Actor *Target, int ChildID)
{
return true;
}

void PushActions(GameObject *Caller, Actor *Target, int childID)
{
Person p(Caller);
Vehicle v(Target);

if (v.GetNumPassengers() == (AnzahlProto1 + AnzahlProto2 + AnzahlProto3))
{
if (ZurEst == 0)
v.PushActionMove(ACTION_APPEND, EPos);

if (SoSiAn == 0)
v.PushActionExecuteCommand(ACTION_INSERT, SoSiScript, &v, 0, false);
}
}
};

 

Thanks in advance, guys. :)

Link to comment
Share on other sites

Hey,

There are several different alarm scripts like that on the German forum. It's worth downloading them and either using them or studying how they work. You can also look at mods which have similar systems to what you want - you mentioned Copenhagen mod - and see how they do it.

Assuming you want the same dispatch method for all/most of your vehicles, you can just compile a script for one vehicle and check it works then copy & paste for each other vehicle but changing the targets (ie prototypes, VOs). You can check the LA mod as well to see how it does it. I hope that all made sense. If there's a more specific area of the script you want help with, let us know.

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...