The signal script is used to control the signal from emergency vehicles. For this purpose every emergency vehicle has assigned a control button and a sound file via a script.
1 Necessary adjustments
In order to get the script working, some changes to the respective script files must be performed manually. In the following lines, the paths of the prototype to the vehicles must be specified. For each vehicle its own sound file is played.
// Here specify the paths of your vehicles!
const char PROTO_FF_RW[] = "mod:Prototypes/Vehicles/Fire Department/rw.e4p";
const char PROTO_FF_TLF[] = "mod:Prototypes/Vehicles/Fire Department/tlf.e4p";
const char PROTO_FF_DLK[] = "mod:Prototypes/Vehicles/Fire Department/dlk.e4p";
In the following lines, the strings above ("PROTO_XX_XXX") must be entered. Also the paths to the respective sound files are defined here.
// Here the stringID of the above used name should be set. In my case PROTO_FF_RW!
if (StrCompare(v.GetPrototypeFileName(), PROTO_FF_RW) == 0)
{
// Here you must enter a valid link to a Siren Sound, in 'mono' coded!
soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/tatuetata_rw_loop.wav", CarPos, true);
}
if (StrCompare(v.GetPrototypeFileName(), PROTO_FF_TLF) == 0)
{
// Here you must enter a valid link to a Siren Sound, in 'mono' coded!
soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/tatuetata_tlf_loop.wav", CarPos, true);
}
if (StrCompare(v.GetPrototypeFileName(), PROTO_FF_DLK) == 0)
{
// Here you must enter a valid link to a Siren Sound, in 'mono' coded!
soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/tatuetata_dlk_loop.wav", CarPos, true);
Display More
2 Script
The script is offered as a download, as well as a code directly from this page. (sosi.rar)
Includes: - Continuous signal ccript - all necessary dummies.
Features: - Players can enable and disable signal manually - Continuous signal goes off automatically when the vehicle has arrived or begins to extinguish / install itself (DLK).
Fixes in V.2.0: - Continuous signal ends when a vehicle is driven to the base - Continuous signal ends when a vehicle has been sent directly from the base to a certain point.
Explanations of the script: I'm sorry, but the fact that some problems have set, I am no longer able to explain the script amateur justice - it has become rather complicated. However, for direct questions I am able to help.
//**************************************************************************************************
// #Version 2.0# ****
// ****
// Includes: all Sirens ****
// ****
// 1.0| VCmdSiren ****
// 1.1| DUMMYUpdatePos ****
// 1.2| DUMMYDisableSiren ****
// 1.3| DUMMYFindPath ****
// 1.4| DUMMYHasSiren ****
// ****
// childID 1 for disabling bluelights. ****
// ****
// ****
// **************************************************************************************************
// Here you can specify the name of an icon for the button bar.
// Automatically taken from the folders UI/Game/Icons/Command/ and UI/Game/icons/cursors.
const char IMG[] = "horn";
const char EACTION_FINDPATH[] = "EActionFindPath";
const char DUMMY_HASSIREN[] = "DUMMYHasSiren";
const char DUMMY_UPDATEPOS[] = "DUMMYUpdatePos";
const char DUMMY_FINDPATH[] = "DUMMYFindPath";
const char CMD_MOVETO[] = "MoveTo";
const char NAME_DUMMYOBJECT[] = "HelpingObjekt_Roger";
const char PROTO_BFW_LF[] = "mod:Prototypes/Vehicles/Fire Department/gtf.e4p";
const char PROTO_BFW_TLF[] = "mod:Prototypes/Vehicles/Fire Department/tlf.e4p";
int DummyGroup = 20;
// 01.0
object VCmdSiren : CommandScript
{
VCmdSiren()
{
SetIcon(IMG);
SetCursor(IMG);
SetRestrictions(RESTRICT_SELFEXECUTE);
}
bool CheckPossible(GameObject *Caller)
{
if (!Caller->IsValid())
return false;
if (Caller->GetType() == ACTOR_VEHICLE)
{
return true;
}
return false;
}
bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
if (!Target->IsValid() || Target->GetID() != Caller->GetID())
return false;
if (!Caller->HasCommand(CMD_MOVETO) || Caller->GetType() != ACTOR_VEHICLE)
return false;
return true;
}
void PushActions(GameObject *Caller, Actor *Target, int childID)
{
Vehicle v(Caller);
if (!v.HasCommand(DUMMY_HASSIREN) && (childID != 2 && childID != 1))
{
int soundID;
v.EnableBlueLights(true);
Vector CarPos = v.GetPosition();
// Here, enter the const char name from above as in the two examples below.
if (StrCompare(v.GetPrototypeFileName(), PROTO_BFW_LF) == 0)
{
// Here the path of the sound file must be available.
soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/feuerwehr1_loop.wav", CarPos, true);
}
if (StrCompare(v.GetPrototypeFileName(), PROTO_BFW_TLF) == 0)
{
soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/feuerwehr2_loop.wav", CarPos, true);
}
GameObject mDummy = Game::CreateObject("mod:Prototypes/Objects/Misc/empty.e4p", NAME_DUMMYOBJECT);
mDummy.Hide();
mDummy.SetPosition(CarPos);
mDummy.SetUserData(soundID);
mDummy.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_UPDATEPOS, &v, soundID, false);
v.SetUserData(soundID);
v.AssignCommand(DUMMY_HASSIREN);
return;
}
if (v.HasCommand(DUMMY_HASSIREN))
{
if (childID == 1)
{
v.EnableBlueLights(false);
}
if (v.HasCommand(DUMMY_HASSIREN))
{
int ref = Caller->GetUserData();
Audio::StopSample(ref);
GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT);
for(int i=0; i<list.GetNumObjects(); i++)
{
GameObject *obj = list.GetObject(i);
if (obj->GetUserData() == ref)
{
int mSirTest = i;
GameObject *obj = list.GetObject(mSirTest);
obj->PushActionDeleteOwner(ACTION_NEWLIST);
v.RemoveCommand(DUMMY_HASSIREN);
}
}
}
return;
}
}
};
// 01.1
object DUMMYUpdatePos : CommandScript
{
DUMMYUpdatePos()
{
SetGroupID(DummyGroup);
}
bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
}
void PushActions(GameObject *Caller, Actor *Target, int childID)
{
Vehicle v(Target);
GameObject mDummy(Caller);
Vector CarPos = v.GetPosition();
if (v.IsDestroyed() || !v.IsValid())
{
int ref = mDummy.GetUserData();
Audio::StopSample(ref);
mDummy.PushActionDeleteOwner(ACTION_NEWLIST);
} else
{
mDummy.SetPosition(CarPos);
Audio::UpdatePos(childID, CarPos, true);
if (v.IsCurrentAction(EACTION_FINDPATH))
{
if (!v.HasCommand(DUMMY_FINDPATH))
{
v.AssignCommand(DUMMY_FINDPATH);
}
}
mDummy.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_UPDATEPOS, Target, childID, false);
}
if (v.HasCommand(DUMMY_FINDPATH))
{
if (!v.IsCurrentAction(EACTION_FINDPATH) && v.GetNumActions() == 0)
{
v.RemoveCommand(DUMMY_HASSIREN);
v.RemoveCommand(DUMMY_FINDPATH);
int ref = Caller->GetUserData();
Audio::StopSample(ref);
GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT);
for(int i = 0; i < list.GetNumObjects(); i++)
{
GameObject *obj = list.GetObject(i);
if (obj->GetUserData() == ref)
{
int mSirTest = i;
GameObject *obj = list.GetObject(mSirTest);
obj->PushActionDeleteOwner(ACTION_NEWLIST);
v.RemoveCommand(DUMMY_HASSIREN);
if (v.HasCommand(DUMMY_FINDPATH))
{
v.RemoveCommand(DUMMY_FINDPATH);
}
}
}
}
}
}
};
// 01.2
object DUMMYDisableSiren : CommandScript
{
DUMMYDisableSiren()
{
SetGroupID(DummyGroup);
}
bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
}
void PushActions(GameObject *Caller, Actor *Target, int childID)
{
Vehicle v(Caller);
if (childID == 1)
{
v.EnableBlueLights(false);
}
int ref = Caller->GetUserData();
Audio::StopSample(ref);
GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT);
for(int i = 0; i < list.GetNumObjects(); i++)
{
GameObject *obj = list.GetObject(i);
if (obj->GetUserData() == ref)
{
int mSirTest = i;
GameObject *obj = list.GetObject(mSirTest);
obj->PushActionDeleteOwner(ACTION_NEWLIST);
v.RemoveCommand(DUMMY_HASSIREN);
if (v.HasCommand(DUMMY_FINDPATH))
{
v.RemoveCommand(DUMMY_FINDPATH);
}
}
}
}
};
// 01.3
object DUMMYFindPath : CommandScript
{
DUMMYFindPath()
{
SetGroupID(DummyGroup);
}
bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
return false;
}
void PushActions(GameObject *Caller, Actor *Target, int childID)
{
}
};
// 01.4
object DUMMYHasSiren : CommandScript
{
DUMMYHasSiren()
{
SetGroupID(DummyGroup);
}
bool CheckGroupVisibility(GameObject *Caller)
{
return false;
}
bool CheckPossible(GameObject *Caller)
{
return false;
}
bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
return false;
}
void PushActions(GameObject *Caller, Actor *Target, int childID)
{
}
};
Display More
3 Adaptation to other scripts
To disable the signal automatically, we need a small piece of code in each script the following list:
- Cool.script
- Deinstall.script
- Emptycar.script
- Extinguish.script
- GoHome.script
- Install.script
- Move.script
For correct function, the code must be within the "void Push Action (GameObject * Caller, Actor * Target, int childID)" - but possibly at the end!
The code must be as follows:
if (Caller->GetType() == ACTOR_VEHICLE)
{
Vehicle v(Caller);
v.PushActionExecuteCommand(ACTION_APPEND, "VCmdSiren", Caller, 2, false);
}
Below an explanation of each function:
Vehicle v(Caller); - Transfers the caller, so the performing part of the script is a vehicle v (v = the "Name").
PushActionExecuteCommand - Executes a command in order.
ACTION_APPEND - The specification of the order (here ACTION_APPEND for the inserting to the end of the existing list).
VCmdSiren - The name of the performing comands.
Caller - Here, the target for the executed command is passed, in this case, the caller itself.
2 - Is a so-called child ID, here there are 2 options!
1 → The vehicle turns off the signal the blue lights are turned off.
2 → The vehicle runs the blue lights.
false - Specifies whether to be tested in the executed command if the command is possible (we in this case dont care, so false for "no").
Alternatively, the modified source files are also available for download. In addition, there is subsequently a revised sample script.
Example script: „deinstall.script“
object Deinstall: CommandScript
{
Deinstall()
{
SetValidTargets(ACTOR_VEHICLE);
SetGroupID(CGROUP_INSTALL);
SetRestrictions(RESTRICT_SELFEXECUTE);
}
bool CheckGroupVisibility(GameObject *Caller)
{
if(!Caller->IsValid() || Caller->GetType() != ACTOR_VEHICLE)
return false;
Vehicle v(Caller);
return v.IsInstalled();
}
bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
if(!Caller->IsValid() || !Target->IsValid() || Caller->GetID() != Target->GetID() || Caller->GetType() != ACTOR_VEHICLE)
return false;
Vehicle v(Caller);
if (!v.IsInstalled() || v.IsUplifted() || v.IsUplifting() || !v.IsBasketEmpty())
return false;
return true;
}
void PushActions(GameObject *Caller, Actor *Target, int childID)
{
Caller->PushActionDeinstall(ACTION_NEWLIST);
if (Caller->GetType() == ACTOR_VEHICLE)
{
Vehicle v(Caller);
v.PushActionExecuteCommand(ACTION_APPEND, "VCmdSiren", Caller, 2, false);
}
}
};
Display More
4 Troubleshooting
If error messages and problems occur, the author of the script can be contacted. For this, a detailed description of the fault and, optimally, a log file is to be added.
Author: Bass-ti
Contact: Bass-ti@ddr-mod.de
Script name: SoSi.script
Script version: V.2.0 Datum: 24.04.2006
Note: This script uses a DUMMY-Command which normally should not see as a player. To hide it, it is necessary that the hazard lights script is used.