Jump to content
Guest e34p

BMA Alarm script

Recommended Posts

Could anyone help me understand the BMA fire alarm script and explain how to get it working?

Kind regards

E34P

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

** BMA Script by Wingman. Kommentiert. **

** Die Nutzungsbestimmungen entnehmen sie der Read-Me **

** Mündlich oder schriftlich ausgesprochen Verbote **

** gelten auch für dieses Script. -Wingman- **

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

// * BMA Script

// V 1.1 *Fehlalarm hinzugefügt

const char *ObjName = "Fahrzeug"; // Hier musst du einen Namen eines Objektes auf der Map angeben das neutral auf der Map steht. Es darf von keinem anderen Script betroffen sein und es darf nicht vom User gesteuert werden oder zerstört werden. z.B. eine Flasche oder ein Auto. In dem Namen darf kein BMA drin vorkommen, da es sonst vom script als BMA erkannt wird.

int Nachricht = 0; // Hier können sie einstellen ob eine Textnachricht gezeigt werden soll wenn ein BMA auslöst. 0 = Textnachricht. 1 = Keine Nachricht

const char *TextNachricht = "Automatic Fire Alarm"; // Hier können sie den Text bestimmen der gezeigt werden soll wenn ein BMA auslöst

int Audio = 1; // Hier können sie einstellen ob ein Sound abgespielt werden soll wenn ein BMA auslöst. 0 = Sound abspielen. 1 = Sound nicht abspielen

const char *PfadAudio = "mod:Audio/BMA.wav"; // Hier können sie den Soundpfad angeben der abgespielt werden soll wenn ein BMA auslöst

int Audio3D = 1; // Hier können sie einstellen ob ein Sound vom BMA (als 3D sound) abgespielt werden soll wenn es auslöst. 0 = 3D Sound abspielen. 1 = 3D Sound nicht abspielen

const char *PfadAudio3D = "mod:Audio/BMA.wav"; // Hier können sie den Soundpfad angeben der vom BMA(als 3D Sound) abgespielt werden soll wenn es auslöst

int Licht = 1; // Soll ein Licht aktiviert werden wenn das BMA auslöst. Licht muss als Special Light deklariert sein. 0 = Licht. 1 = Kein Licht

int FehlalarmDichte = 15; // Hier kannst du dichte eines Fehlalarmes einer Brandmeldeanlaga einstellen. Die Chance wird in 1 : ? das eine Anlage auslöst angegeben. Dabei hat jede einzelne Anlage alle 5 Sekunden die Chance von 1 : ?(der Zahl) auszulösen. Empfohlen wird 30. Also desto kleiner die Zahl desto höher die Wahrscheinlichkeit eines Fehlalarms und desto höher die Zahl desto geringer die chance.

int EID;

object UpdateBMA : CommandScript

{

UpdateBMA()

{

SetIcon("afa");

SetCursor("afa");

}

bool CheckPossible(GameObject *Caller)

{

return true;

}

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

{

return true;

}

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

{

GameObjectList gol = Game::GetGameObjectsWithPrefix("BMA");

GameObject *go;

for (int i = 0; i < gol.GetNumObjects(); i++)

{

go = *gol.GetObject(i);

if (Game::IsBurningObjectInVirtualObject(go->GetName()) && !go->HasCommand("Ausgeloest"))

{

if (Nachricht == 0)

Mission::PlayHint("BMA Ausgelöst!!!");

if (Audio == 1)

Audio::PlaySample(PfadAudio);

if (Audio3D == 1)

{

int x;

x = Audio::PlaySample3D(PfadAudio3D, go->GetPosition());

}

if (Licht == 1)

go->EnableSpecialLights(true);

go->AssignCommand("Ausgeloest");

}

else if ((Math::rand()%FehlalarmDichte) == 1 && !Mission::HasObjective("BMA Ausgelöst"))

{

if (Nachricht == 0)

Mission::PlayHint("BMA Ausgelöst!!!");

if (Audio == 1)

Audio::PlaySample(PfadAudio);

if (Audio3D == 1)

{

int x;

x = Audio::PlaySample3D(PfadAudio3D, go->GetPosition());

}

if (Licht == 1)

go->EnableSpecialLights(true);

go->AssignCommand("Ausgeloest");

go->AssignCommand("E_Fehlalarm");

EID = Game::ShowEvent("BMA Ausgelöst", go->GetPosition());

Mission::AddObjective("BMA Ausgelöst");

Mission::SetObjectiveAccomplished("BMA Ausgelöst", false);

}

}

if (Mission::HasObjective("BMA Ausgelöst"))

{

GameObjectList gol = Game::GetGameObjectsWithPrefix("BMA");

GameObject *go;

int Zaehler = 0;

for (int i = 0; i < gol.GetNumObjects(); i++)

{

go = *gol.GetObject(i);

if (go->HasCommand("E_Fehlalarm"))

Zaehler++;

if (Zaehler == 0 && (i + 1) == gol.GetNumObjects())

{

Game::SetEventFinished(EID, true, 50);

Mission::SetObjectiveAccomplished("BMA Ausgelöst", true);

Mission::RemoveObjective("BMA Ausgelöst");

}

}

}

GameObjectList gol = Game::GetGameObjects(ObjName);

GameObject *go;

go = *gol.GetObject(0);

go->PushActionWait(ACTION_APPEND, 5.f);

go->PushActionExecuteCommand(ACTION_APPEND, "UpdateBMA", Target, 15, false);

}

};

object BMA_Aus : CommandScript

{

BMA_Aus()

{

SetIcon("IconName");

SetCursor("CursorName");

}

bool CheckPossible(GameObject *Caller)

{

return true;

}

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

{

if (Target->GetType() == ACTOR_OBJECT)

{

GameObject go(Target);

if (!go.HasCommand("Ausgeloest"))

return false;

}

else

return false;

return true;

}

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

{

GameObject go(Target);

Person p(Caller);

p.SetCommandable(false);

p.PushActionMove(ACTION_NEWLIST, go.GetPosition());

p.PushActionTurnTo(ACTION_APPEND, go.GetPosition());

p.PushActionSwitchAnim(ACTION_APPEND, "treatinjured2");

p.PushActionWait(ACTION_APPEND, 15.f);

p.PushActionSwitchAnim(ACTION_APPEND, "idle");

p.PushActionExecuteCommand(ACTION_APPEND, "BMA_Aus2", Target, 0, false);

}

};

object BMA_Aus2 : CommandScript

{

BMA_Aus2()

{

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);

GameObject go(Target);

p.SetCommandable(true);

if (Game::IsBurningObjectInVirtualObject(go.GetName()))

{

Mission::PlayHint("Zurückstellen nicht gelungen. Es brennt noch.");

return;

}

else

{

Mission::PlayHint("BMA erfolgreich zurückgestellt.");

if (Licht == 0)

go.EnableSpecialLights(false);

go.RemoveCommand("Ausgeloest");

go.RemoveCommand("E_Fehlalarm");

}

}

};

object Ausgeloest : CommandScript

{

Ausgeloest()

{

SetGroupID(20);

}

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)

{

}

};

object E_Fehlalarm : CommandScript

{

E_Fehlalarm()

{

SetGroupID(20);

}

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)

{

}

};

Link to comment
Share on other sites

It says on the read me that I need to copy bits into the "startup script"

What script is that?

Download and use this: http://www.emergency-forum.de/index.php?page=DatabaseItem&id=1414

You will find the startup script in it.

is this a fire alarm that plays when fire is active in a building or is this somethin else?

The script registers if there is fire in a marked area, and if there is, then it activates and automatic fire alarm.

Besides that it randomly activates some of the alarms from time to time.

Pretty cool script :)

Link to comment
Share on other sites

Ok thanks. Do you need to do anything to make them activate randomly without a fire or does the script just do that four you? You don't need to put anything in the specs files do you?

Link to comment
Share on other sites

Ok thanks. Do you need to do anything to make them activate randomly without a fire or does the script just do that four you? You don't need to put anything in the specs files do you?

The reason that you need the things in the startup script is because it starts up the script.

The script then functions as a loop and checks all the different alarms around the city one at a time to check if there are any fires.

Besides that, the script also makes a loop which says that it should create a random number, and if that number is something specific it activates a false alarm :)

Link to comment
Share on other sites

I am struggling as well. I'm attempting to add this script into the LA MOD. I started with adding the VO's and then the corresponding BMA objects. I even remembered the icons. The script is added into the ...script/command folder and the start script is in the script folder. I still can't seem to get an activation. The only thing that I could see wrong would be that I just transferred the BMA script and start script from the new Manhattan Mod (its for my personal use). Does the start script need to change?? I tried going to the link above to download the read me however I can not find a download button. Any help or even small tutorial would be appreciated. It seems like a very simple script however I still can not get it to work.

Thanks

Link to comment
Share on other sites

I am struggling as well. I'm attempting to add this script into the LA MOD. I started with adding the VO's and then the corresponding BMA objects. I even remembered the icons. The script is added into the ...script/command folder and the start script is in the script folder. I still can't seem to get an activation. The only thing that I could see wrong would be that I just transferred the BMA script and start script from the new Manhattan Mod (its for my personal use). Does the start script need to change?? I tried going to the link above to download the read me however I can not find a download button. Any help or even small tutorial would be appreciated. It seems like a very simple script however I still can not get it to work.

Thanks

You need to add this bit to your fp_freeplay.script:

GameObjectList gol = Game::GetGameObjects("tree3"); // Hier den Namen, des Objektes das neutral auf der Map steht, siehe 3.

GameObject *go;

go = *gol.GetObject(0);

Game::ExecuteCommand("UpdateBMA", go);

Also you need to add a object on the map and name it "tree3" (no quotes) in order to start the script in game, can be a bottle etc, better something that doesn't burn or get destroyed. Also remember to add the audio.

Link to comment
Share on other sites

Anyone have an idea on how to get it to loop the alarm sound at the location of the box until reset?

 

This line hasn't been working for me; it plays once and then stops.

int x;            x = Audio::PlaySample3D(PfadAudio3D, go->GetPosition(), true);

Probably need a line to stop the sound when the alarm is reset, but I don't think one is already in the script.

Link to comment
Share on other sites

BMA is German for Brandmeldeanlage or simply 'fire alarm system'.

 

The script is run in the background by a dummy object. To initiate this, you will need to edit the freeplay startup script (fp_freeplay.script / fp_challenge.script). That script locates the dummy object and initiates the fire alarm system script.

 

What the script itself does, I'm not sure, but I'm guessing it adds a new event/objective with false and true fire alarms.

The bunch of text at the beginning of the script are settings you can change.

Link to comment
Share on other sites

Got it to play and stop a repeating 3D sound.

 

Step 1: Find this line (two places)...

x = Audio::PlaySample3D(PfadAudio3D, go->GetPosition(), true);

...and add...

go->SetUserData(x);

...after it.

 

Step 2: Find...

go.RemoveCommand("AlarmTriggered");go.RemoveCommand("FalseAlarm");

...and add these lines after it...

if (Audio3D == 0){	int ref = Target->GetUserData();	Audio::StopSample(ref);}

That pretty much wraps up the script as far as I'm concerned. I'm not sure about the permissions on the BMA script, otherwise I'd post mine here for others to use.

Free to use, it seems, so here's the whole package with English readme and script.

 

FireAlarms.rar

Link to comment
Share on other sites

 

Got it to play and stop a repeating 3D sound.

 

Step 1: Find this line (two places)...

x = Audio::PlaySample3D(PfadAudio3D, go->GetPosition(), true);

...and add...

go->SetUserData(x);

...after it.

 

Step 2: Find...

go.RemoveCommand("AlarmTriggered");
go.RemoveCommand("FalseAlarm");

...and add these lines after it...

if (Audio3D == 0)
{
    int ref = Target->GetUserData();
    Audio::StopSample(ref);
}

That pretty much wraps up the script as far as I'm concerned. I'm not sure about the permissions on the BMA script, otherwise I'd post mine here for others to use.

Free to use, it seems, so here's the whole package with English readme and script.

attachicon.gif Fire Alarm Script with False Alarms (BMA).rar

The loot, could you please reupload those files. Im getting unknown format or damaged message.

Link to comment
Share on other sites

Thanks again, got it working perfectly. I've added 13 alarm systems to the map. I was going to think about making it so that if a box trips it automatically dispatches an engine if available. 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...