Ghost Graphic Designs Posted July 28, 2014 Report Share Posted July 28, 2014 Hi again. So, I have this parking script and, apparentely the vehicles don't follow the coordinates/vectors given by the script [anfahrpos = Vector (-300,0,0);wendepos = Vector (-600,0,0);] and the units park how they want (both park well sometimes, others not). I don't know the reason why the vectors aren't working, so I'm asking the support/advice of someone who knows what is causing this problem and/or how can I make the vehicles turn to a specific VO (like the Harbor City parking script, for example). I can't use Harbor City's script, because the callout system is different and it has to be this specific parking script. Anyways, here's the script://////////////////////////////////////////////////////////////////////////////////////////////////////////// Freeplay GoHome - Script v1.3 //// ******************************************** //// //// 1.0| VCmdFPGoHome //// | //// 2.0| DUMMYFPGoHome //// | | //// | |- Zu parkende Einheiten sind durch Kommentarzeilen (//) in Bloecke unterteilt. //// | | Jeder von ihnen kann entfernt werden, ohne dass das Skript unbrauchbar wird. //// | | //// | '- Die mit einem Stern (*) markierten Zeilen muessen angepasst werden. //// | Mehrere Sterne bedeuten lediglich mehrere Anpassungen in einer Zeile. //// | Dabei gilt: Zwei Sterne entsprechen zwei Anpassungen, und so weiter. //// | //// 2.1| DUMMYFPGoHomePersonal //// | //// |- Ausgangspunkte fuer das Fahrzeug-Personal sind durch Kommentarzeilen (//) in Bloecke //// | unterteilt. Jeder von ihnen kann entfernt werden, ohne dass das Skript unbrauchbar //// | wird. //// | //// '- Die mit einem Stern (*) markierten Zeilen muessen angepasst werden. //// Mehrere Sterne bedeuten lediglich mehrere Anpassungen in einer Zeile. //// Dabei gilt: Zwei Sterne entsprechen zwei Anpassungen, und so weiter. //// //// _____________________ //// a-rescue und Magicman mŸssen in der Readme genannt werden & der Kommentar muss so bleiben. //// Sonst freie Nutzung fŸr alle. ////////////////////////////////////////////////////////////////////////////////////////////////////////////const char IMG_ICON[] = "parken"; // Name des Iconsconst char IMG_CURSOR[] = "parken"; // Name des Cursorsconst char DUMMYGOHOME_V[] = "DUMMYFPGoHome2";const char DUMMYGOHOME_P[] = "DUMMYFPGoHomePersonal2";const char COMMANDABLE_TRUE[] = "DUMMYSetCommandableTrue";const char COMMANDABLE_FALSE[] = "DUMMYSetCommandableFalse";const char FREEFORALERT_TRUE[] = "DUMMYFPSetFreeForAlertTrue";const char FREEFORALERT_FALSE[] = "DUMMYFPSetFreeForAlertFalse";const char FREEFORALERT[] = "DUMMYFPIsFreeForAlert";const char INBASE_TRUE[] = "DUMMYFPSetInBaseTrue";const char INBASE_FALSE[] = "DUMMYFPSetInBaseFalse";const char INBASE[] = "DUMMYFPIsInBase";int DummyGroup = "90";// 1.0object VCmdFPGoHome2 : CommandScript{ VCmdFPGoHome2() { SetIcon(IMG_ICON); SetCursor(IMG_CURSOR); SetValidTargets(ACTOR_VEHICLE); SetRestrictions(RESTRICT_SELFEXECUTE); SetPossibleCallers(ACTOR_VEHICLE); SetGroupID(DummyGroup); } bool CheckGroupVisibility(GameObject *Caller) { /*Vehicle v(Caller); PersonList pl = v.GetPassengers(); PersonList tl = v.GetTransports(); if (pl.GetNumPersons() > 0 && tl.GetNumPersons() == 0) return true; return false;*/ return true; } bool CheckPossible(GameObject *Caller) { if (!Caller->IsValid() || Caller->GetType() != ACTOR_VEHICLE) return false; Vehicle v(Caller); PersonList pl = v.GetPassengers(); PersonList tl = v.GetTransports(); if (v.IsValid() && !v.IsDestroyed() /*&& pl.GetNumPersons() > 0*/ && tl.GetNumPersons() == 0) { return true; } return false; } bool CheckTarget(GameObject *Caller, Actor *Target, int ChildID) { if (!Caller->IsValid() || !Target->IsValid() || Caller->GetID() != Target->GetID()) return false; Vehicle v(Caller); PersonList pl = v.GetPassengers(); PersonList tl = v.GetTransports(); if (v.IsValid() && !v.IsDestroyed() /*&& pl.GetNumPersons() > 0*/ && tl.GetNumPersons() == 0) { return true; } return false; } void PushActions(GameObject *Caller, Actor *Target, int childID) { Vehicle v(Caller); if (v.IsBlueLightEnabled()) { v.EnableBlueLights(false); } if (v.HasCommand("DUMMYHasSiren")) { Game::ExecuteCommand("DUMMYDisableSiren", &v, &v); } if (v.HasCommand("DUMMYHasAutoSiren")) { Game::ExecuteCommand("VCmdAutoSirenOff", &v, &v); } v.PushActionWait(ACTION_NEWLIST, 0.1); v.PushActionExecuteCommand(ACTION_APPEND, DUMMYGOHOME_V , &v, 1, true); }};// 2.0object DUMMYFPGoHome2 : CommandScript{ DUMMYFPGoHome2() { SetGroupID(DummyGroup); } bool CheckPossible(GameObject *Caller) { return true; } bool CheckTarget(GameObject *Caller, Actor *Target, int ChildID) { return true; } void PushActions(GameObject *Caller, Actor *Target, int childID) { Vehicle v(Caller); ActorList al; Actor parkplatz; Vector parkpos; Vector anfahrpos; Vector wendepos; PersonList pl;/////// VUCI32 ///////////////////////////////////////////////////////////////////////////////////////////////////////////// if (v.HasName("VUCI32")) // Fahrzeugname { al=Game::GetActors("VUCI32_park"); // Name des virtuellen Objektes wo das Fahrzeug parken soll anfahrpos = Vector (-300,0,0); wendepos = Vector (-600,0,0); } else /////// VLCI31 ///////////////////////////////////////////////////////////////////////////////////////////////////////////// if (v.HasName("VLCI31")) // Fahrzeugname { al=Game::GetActors("VLCI31_park"); // Name des virtuellen Objektes wo das Fahrzeug parken soll anfahrpos = Vector (-300,0,0); wendepos = Vector (-600,0,0); } else//Weitere Fahrzeugblšcke hier einfŸgen { Mission::PlayHint("Fuer dieses Fahrzeug konnte kein Parkplatz gefunden werden! Code 1"); return; } if(al.GetNumActors() > 0) { parkplatz = *al.GetActor(0); parkpos = parkplatz.GetPosition(); } else { Mission::PlayHint("Fuer dieses Fahrzeug konnte kein Parkplatz gefunden werden! Code 2"); return; } bool vready = true; if (v.GetNumPassengers() == 0) { vready = false; } pl = v.GetPassengers(); for(int i=0; i < pl.GetNumPersons(); i++) { if (pl.GetPerson(i)->GetLife() < pl.GetPerson(i)->GetMaxLife()) { vready = false; } } if (vready) { Game::ExecuteCommand(FREEFORALERT_TRUE, &v, &v); } Game::FindFreePosition(&v, parkpos); v.PushActionMove(ACTION_NEWLIST, parkpos+anfahrpos); v.PushActionTurnTo(ACTION_APPEND, parkpos+wendepos); v.PushActionMove(ACTION_APPEND, parkpos); v.PushActionExecuteCommand(ACTION_APPEND, INBASE_TRUE, &v, 1, true); v.PushActionExecuteCommand(ACTION_APPEND, COMMANDABLE_FALSE, &v, 1, true); v.PushActionExecuteCommand(ACTION_APPEND, DUMMYGOHOME_P, &v, 1, true); v.PushActionExecuteCommand(ACTION_APPEND, "CloseGate", Caller, 1, true); }};// 2.1object DUMMYFPGoHomePersonal2 : CommandScript{ DUMMYFPGoHomePersonal2() { SetGroupID(DummyGroup); } bool CheckPossible(GameObject *Caller) { return true; } bool CheckTarget(GameObject *Caller, Actor *Target, int ChildID) { return true; } void PushActions(GameObject *Caller, Actor *Target, int childID) { Vehicle v(Caller); PersonList pl = v.GetPassengers(); for(int i=0; i < pl.GetNumPersons(); i++) { Person p = pl.GetPerson(i); v.RemovePassenger(&p); p.PushActionDeleteOwner(ACTION_NEWLIST); } }};In this case, VLCI 31 and VUCI 32 are the only vehicles that I have at this moment and the rest of script works fine (vehicles disable lights, goes to the VO, gates are closed and the personnel gets out and is deleted). Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Chris07 Posted July 29, 2014 Report Share Posted July 29, 2014 I'm not exactly sure what's gonig on in the script after a quick look through. Comments being in German don't help Why use vectors to position things? Do you need fine grain control over their direction? Why not use virtual objects? VO_1 (Placed directly in front of parking spot)VO_2 (The actual parking spot)VO_3 (Placed in the direction you want the vehicle to point when its done parking relative to the position of VO_2. In most cases this VO can be omitted and VO_1 can be used) 1. Send vehicle to VO_1's location2. Make vehicle face VO_23. Send Vehicle to VO_2's location4. Make Vehicle Turn to face VO_3 (or VO_2 depending) I haven't really played with vectors and doing things manually that way. I find the VO method easier. Quote Link to comment Share on other sites More sharing options...
Ghost Graphic Designs Posted July 29, 2014 Author Report Share Posted July 29, 2014 *double post by accident, sorry* Quote Link to comment Share on other sites More sharing options...
Ghost Graphic Designs Posted July 29, 2014 Author Report Share Posted July 29, 2014 I'm not exactly sure what's gonig on in the script after a quick look through. Comments being in German don't help Why use vectors to position things? Do you need fine grain control over their direction? Why not use virtual objects? VO_1 (Placed directly in front of parking spot)VO_2 (The actual parking spot)VO_3 (Placed in the direction you want the vehicle to point when its done parking relative to the position of VO_2. In most cases this VO can be omitted and VO_1 can be used) 1. Send vehicle to VO_1's location2. Make vehicle face VO_23. Send Vehicle to VO_2's location4. Make Vehicle Turn to face VO_3 (or VO_2 depending) I haven't really played with vectors and doing things manually that way. I find the VO method easier.That's the part of the LA script that I'm trying to replace in this script. Instead of making the vehicle move to their VO and turn to a specific vector, I was looking for a script combo that made the vehicle move to the VO, turn to another VO and did all of the other things in the original script (delete personnel, close the gates, disable all of the lights and be set as non-commandable untill it's called via-dispatcher script). Either way, I think that I might have the solution. Instead of making the vehicle move to the VO and (not) facing the vector, I'll try to replace that part with a line for the vehicle to execute the LaToFireStation.script. Dunno if this works, but it's worth a shot. EDIT: doesn't work, FML. Quote Link to comment Share on other sites More sharing options...
Chris07 Posted July 29, 2014 Report Share Posted July 29, 2014 The code to do that is all over the place and in several mods:General idea is thus:ActorList aList1 = Game::GetActors(VO_1); ActorList aList2 = Game::GetActors(VO_2);ActorList aList3 = Game::GetActors(VO_3);if(aList1.GetNumActors() > 0) { Vector FirstPoint = aList1.GetActor(0)->GetPosition();} else { Mission::PlayHint("FirstPoint VO not found"); return; //something went wrong. abort.}if(aList2.GetNumActors() > 0) { Vector Park = aList2.GetActor(0)->GetPosition();} else { Mission::PlayHint("Park VO not found"); return; //something went wrong. abort.}if(aList3.GetNumActors() > 0) { Vector TurnTo = aList3.GetActor(0)->GetPosition();} else { Mission::PlayHint("TurnTo VO not found"); return; //something went wrong. abort.}//v = the Vehicle Objectv.PushActionMove(ACTION_NEWLIST, FirstPoint);v.PushActionTurnTo(ACTION_APPEND, Park);v.PushActionWait(ACTION_APPEND, 1.0f);v.PushActionMove(ACTION_APPEND, Park);v.PushActionTurnTo(ACTION_APPEND, TurnTo);...where VO_1 VO_2 VO_3 correspond to the VOs described in my first post. Quote Link to comment Share on other sites More sharing options...
Ghost Graphic Designs Posted July 30, 2014 Author Report Share Posted July 30, 2014 Managed to fix it. Thanks for help, guys. Quote Link to comment Share on other sites More sharing options...
timmiej93 Posted July 30, 2014 Report Share Posted July 30, 2014 Hey guys, First of all, good explaining on your behalf again Chris, it's really helpful. Second of all, could someone explain to me how those vectors with coordinates work? Vector (-600,0,0); Do the three numbers work according to the normal XYZ format? And what direction would those be then? Tim Quote Link to comment Share on other sites More sharing options...
Ghost Graphic Designs Posted July 30, 2014 Author Report Share Posted July 30, 2014 Hey guys, First of all, good explaining on your behalf again Chris, it's really helpful. Second of all, could someone explain to me how those vectors with coordinates work? Vector (-600,0,0); Do the three numbers work according to the normal XYZ format? And what direction would those be then? TimVehicle parks faced to the North:vehicles comes from = Vector (0,300,0);vehicle final position faced to = Vector (0,600,0); Vehicle parks faced to the South:vehicles comes from = Vector (0,-300,0);vehicle final position faced to = Vector (0,-600,0); Vehicle parks faced to the East:vehicles comes from = Vector (-300,0,0);vehicle final position faced to = Vector (-600,0,0); Vehicle parks faced to the West:vehicles comes from = Vector (300,0,0);vehicle final position faced to = Vector (600,0,0); This is what I figured out from the readme that the original scripter included in the script pack. Either way, I think that's better for someone to explain it other than me. I'm not good at explaining stuff. Quote Link to comment Share on other sites More sharing options...
timmiej93 Posted July 30, 2014 Report Share Posted July 30, 2014 I think I get it though .So given Vector (x,y,z);X would be West(+) - East (-)Y would be North (+) - South (-)Z would be stupid, unless you are on a ramp or something Quote Link to comment Share on other sites More sharing options...