Maffegozer Posted May 11, 2010 Report Share Posted May 11, 2010 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 werdenconst char STR_ProtoPerson[] = "mod:Prototypes/Persons/03Politie/policeman_m.e4p"; // Prototyp der Person, die erstellt wirdconst char STR_VehicleName[] = "NOODHULP_01"; // Name des zu alarmierenden Fahrzeugs - Muss einmalig sein auf der Karteconst char CommandIcon[] = "NOODHULP_01"; // Name des zu verwendenen Icons - Wird automatisch aus dem entsprechenden Ordner genommenconst char AlarmMessage[] = "Spoedrit Noodhulp Tilburg!"; // Die Nachricht die beim Alarm abgespielt wirdconst char AlarmSound[] = "pfad_zum_sound"; // Pfad zum Sound der abgespielt wird - muss Mono & WAV seinconst int PersonCounter = 2; // Anzahl der zu erstellenden Personenconst int VehicleSirenID = 1; // 1 = SoSi Script ist vorhanden soll ausgeführt werden, 0 = SoSi Script soll nicht ausgeführt werdenconst int GameSoundID = 1; // 1 = Es soll ein Alarmsound abgespielt werdenconst 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// Dummycommandobject DummyVehicleNotFree : CommandScript{ DummyVehicleNotFree() { SetGroupID(DummyGroup); } bool CheckTarget(GameObject *Caller, Actor *Target, int childID) { return false; }};// ALARMERING_NOODHULP_01object 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"); } } }}; Quote Link to comment Share on other sites More sharing options...
Kookas Posted May 12, 2010 Report Share Posted May 12, 2010 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_VObjPersonstartpolAmbulance station:STR_VObjPersonstartambFire station:STR_VObjPersonstartfirThen 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. Quote Link to comment Share on other sites More sharing options...
Maffegozer Posted May 12, 2010 Author Report Share Posted May 12, 2010 Will take a look at that.Thanks!So basically i'm doing things which are not necessary. Quote Link to comment Share on other sites More sharing options...