Jump to content
Maffegozer

Quick little question about: Alarm Script

Recommended Posts

Hello,

I've got a quick question.

Because.

For my private mod.

I got an alarm script

.

But I wonder.

Could I make it that people spawn at differrent spots (virtual objects) on the map instead of only one?

If it is, what do I need to change?

Script I use:


int DummyGroup = 20;

// Definitionen - Hier muss geändert werden!

const char STR_VObjPersonStart[] = "NOODHULP_01"; // Name des VO's, wo die Feuerwehrleute erstellt werden
const char STR_ProtoPerson[] = "mod:Prototypes/Persons/03Politie/policeman_m.e4p"; // Prototyp der Person, die erstellt wird
const char STR_VehicleName[] = "NOODHULP_01"; // Name des zu alarmierenden Fahrzeugs - Muss einmalig sein auf der Karte
const char CommandIcon[] = "NOODHULP_01"; // Name des zu verwendenen Icons - Wird automatisch aus dem entsprechenden Ordner genommen
const char AlarmMessage[] = "Spoedrit Noodhulp Tilburg!"; // Die Nachricht die beim Alarm abgespielt wird
const char AlarmSound[] = "pfad_zum_sound"; // Pfad zum Sound der abgespielt wird - muss Mono & WAV sein
const int PersonCounter = 2; // Anzahl der zu erstellenden Personen
const int VehicleSirenID = 1; // 1 = SoSi Script ist vorhanden soll ausgeführt werden, 0 = SoSi Script soll nicht ausgeführt werden
const int GameSoundID = 1; // 1 = Es soll ein Alarmsound abgespielt werden
const int VehicleWaitingTime = 10.0; // Zeit, bis das Fahrzeug nach dem Alarm losfährt (Sekunden). In dieser Zeit müssen auch die Personen einstellen.

// Ab hier sind keine Änderungen notwendig

// Dummycommand

object DummyVehicleNotFree : CommandScript
{
DummyVehicleNotFree()
{
SetGroupID(DummyGroup);
}

bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
return false;
}
};

// ALARMERING_NOODHULP_01

object ALARMERING_NOODHULP_01 : CommandScript // Selbstverständlich kann der Script-Name geändert werden ;-)
{
ALARMERING_NOODHULP_01() // Muss identisch mit dem Namen oben sein
{
SetCursor(CommandIcon);
SetIcon(CommandIcon);
SetValidTargets(ACTOR_FLOOR);
}

bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
if(!Target->GetType() == ACTOR_FLOOR)
return false;

return true;
}

void PushActions(GameObject *Caller, Actor *Target, int childID)
{
GameObjectList l0 = Game::GetGameObjects(TYPE_VEHICLE);
for(int i=0; i<l0.GetNumObjects(); i++)
{
ActorList PerStartList(STR_VObjPersonStart);
if (PerStartList.GetNumActors() == 0)
{
System::Log("Alarmscript fehlgeschlagen - Kein Virtual Object gefunden!");
return;
}

GameObject *Obj = l0.GetObject(i);
Vehicle v(Obj);

if(v.HasName(STR_VehicleName) && !v.HasCommand("DummyVehicleNotFree"))
{
for(int j=0; j<PersonCounter; j++)
{
Vector Pos = v.GetPosition();

Person p = Game::CreatePerson(STR_ProtoPerson, "POLICEMAN_M");

Vector pStartPos(PerStartList.GetActor(0)->GetPosition());
Game::FindFreePosition(&p, pStartPos, 100.f);

p.SetPosition(pStartPos);
p.PushActionMove(ACTION_NEWLIST, Pos);
p.PushActionTurnTo(ACTION_APPEND, &v);
p.PushActionEnterCar(ACTION_APPEND, &v);
}

Mission::PlayHint(AlarmMessage);
if(GameSoundID == 1)
{
Audio::PlaySample(AlarmSound);
}
Vector TargetPos=Game::GetCommandPos();
Game::FindFreePosition(&v, TargetPos, 90);

v.PushActionWait(ACTION_NEWLIST, VehicleWaitingTime);
if(VehicleSirenID == 1)
{
v.PushActionExecuteCommand(ACTION_APPEND, "VCmdSiren", &v, 0, false);
}
v.PushActionMove(ACTION_APPEND, TargetPos);
v.AssignCommand("DummyVehicleNotFree");
}
}
}
};

Link to comment
Share on other sites

The thing is, I don't think this is the ideal way. I would do it by putting a virtual object on the map for each person spawn, and then naming those objects. Then I would create a person directly on them. Like at the police station door:

STR_VObjPersonstartpol

Ambulance station:

STR_VObjPersonstartamb

Fire station:

STR_VObjPersonstartfir

Then I would use either switch cases or alot of if tests (I personally prefer if tests) to check if I'm calling a police car, an ambulance, or a fire engine.

If I'm calling a police car, then I would do this:

Vector pStartPos(STR_VObjPersonstartpol->GetPosition());

If I'm calling an ambulance, I would do this:

Vector pStartPos(STR_VObjPersonstartamb->GetPosition());

And so on.

Something along those lines, anyway.

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