So I'e decided to use the last of my remaining free time to update a mod of mine. I am trying to create my own "Auto Spawn" script for freeplay. When freeplay loads, I want all vehicles to spawn in their parking spots. I've managed to get them all to spawn (they don't face the right direction but thats a fix for another time), but the biggest problem that I need some help with is that they spawn without ANY commands. I can select the vehicle without a problem, but no commands show up. When I attempt to forcibly add a commands like:
v.AssignCommand("MoveTo");
Still nothing appears. Not even the MoveTo command I'm explicitly adding.
Â
All vehicles are affected by this, and all vehicles have their commands set in the editor.
Â
Here is my code thus far:
//******************************************************************************************// Northview South County - VEHICLE SPAWN SCRIPT v1.0//// Author(s): Chris07// Reuse without explicit permission from author is forbidden!////******************************************************************************************//Vehicle Prototype Delcarationsconstchar PROTO_ENGINE01[]="mod:Prototypes/Vehicles/02 LA Fire Department/fire_engine1.e4p";constchar PROTO_ENGINE02[]="mod:Prototypes/Vehicles/02 LA Fire Department/fire_engine2.e4p";constchar PROTO_RENGINE01[]="mod:Prototypes/Vehicles/02 LA Fire Department/rescue_engine1.e4p";constchar PROTO_RENGINE02[]="mod:Prototypes/Vehicles/02 LA Fire Department/rescue_engine2.e4p";constchar PROTO_BC[]="mod:Prototypes/Vehicles/02 LA Fire Department/battalion_chief_vehicle.e4p";constchar PROTO_SQUAD[]="mod:Prototypes/Vehicles/02 LA Fire Department/squad_1.e4p";constchar PROTO_HEAVYRESCUE[]="mod:Prototypes/Vehicles/02 LA Fire Department/Rescue.e4p";constchar PROTO_RESCUECRANE[]="mod:Prototypes/Vehicles/02 LA Fire Department/heavy_rescue_crane.e4p";constchar PROTO_HAZMAT[]="mod:Prototypes/Vehicles/02 LA Fire Department/hazmat_squad.e4p";constchar PROTO_BRUSH[]="mod:Prototypes/Vehicles/02 LA Fire Department/brush_truck.e4p";constchar PROTO_TANKER[]="mod:Prototypes/Vehicles/02 LA Fire Department/water_tanker.e4p";constchar PROTO_AMBULANCE01[]="mod:Prototypes/Vehicles/01 LA Ambulance/amrambulance01.e4p";constchar PROTO_AMBULANCE02[]="mod:Prototypes/Vehicles/01 LA Ambulance/amrambulance02.e4p";constchar PROTO_AMBULANCE03[]="mod:Prototypes/Vehicles/01 LA Ambulance/amrambulance03.e4p";constchar PROTO_AMBULANCE04[]="mod:Prototypes/Vehicles/01 LA Ambulance/amrambulance04.e4p";constchar PROTO_AMBULANCE05[]="mod:Prototypes/Vehicles/01 LA Ambulance/amrambulance05.e4p";constchar PROTO_EMS_SUP[]="mod:Prototypes/Vehicles/01 LA Ambulance/supervisor.e4p";constchar PROTO_PATROL01[]="mod:Prototypes/Vehicles/03 LA Police/cv_patrol1.e4p";constchar PROTO_PATROL02[]="mod:Prototypes/Vehicles/03 LA Police/cv_patrol2.e4p";constchar PROTO_PATROL03[]="mod:Prototypes/Vehicles/03 LA Police/dodge_charger_patrol3.e4p";constchar PROTO_PATROL04[]="mod:Prototypes/Vehicles/03 LA Police/cv_patrol4.e4p";constchar PROTO_PATROL05[]="mod:Prototypes/Vehicles/03 LA Police/dodge_charger_patrol5.e4p";constchar PROTO_PATROL06[]="mod:Prototypes/Vehicles/03 LA Police/cv_patrol6.e4p";constchar PROTO_UMPCPATROL[]="mod:Prototypes/Vehicles/03 LA Police/ATF_cv.e4p";constchar PROTO_SUVPATROL[]="mod:Prototypes/Vehicles/03 LA Police/suv_lapd.e4p";constchar PROTO_SWATUMPC[]="mod:Prototypes/Vehicles/03 LA Police/cv_umpc.e4p";constchar PROTO_SWATRESCUE[]="mod:Prototypes/Vehicles/03 LA Police/rescue_truck02_lapd.e4p";constchar PROTO_BOMBSQUAD[]="mod:Prototypes/Vehicles/03 LA Police/suv_bomb_squad.e4p";constchar PROTO_TRANSPORTVAN[]="mod:Prototypes/Vehicles/03 LA Police/svan1.e4p";//VO Declarations (Parking Spots)constchar VO_ENGINE01[]="E81_1";constchar VO_ENGINE02[]="E83_1";constchar VO_RENGINE01[]="E82_1";constchar VO_RENGINE02[]="E84_1";constchar VO_BC[]="BC11_1";constchar VO_SQUAD[]="S83_1";constchar VO_HEAVYRESCUE[]="HR81_1";constchar VO_RESCUECRANE[]="C81_1";constchar VO_HAZMAT[]="H81_1";constchar VO_BRUSH[]="B82_1";constchar VO_TANKER[]="T83_1";constchar VO_AMBULANCE01[]="M511_1";constchar VO_AMBULANCE02[]="M512_1";constchar VO_AMBULANCE03[]="M513_1";constchar VO_AMBULANCE04[]="M521_1";constchar VO_AMBULANCE05[]="M522_1";constchar VO_EMS_SUP[]="EMS5_1";constchar VO_PATROL01[]="7A1_1";constchar VO_PATROL02[]="7A2_1";constchar VO_PATROL03[]="7A3_1";constchar VO_PATROL04[]="7A4_1";constchar VO_PATROL05[]="7A5_1";constchar VO_PATROL06[]="7A6_1";constchar VO_UMPCPATROL[]="umpc_1";constchar VO_SUVPATROL[]="7S1_1";constchar VO_SWATUMPC[]="tac1_1";constchar VO_SWATRESCUE[]="tac2_1";constchar VO_BOMBSQUAD[]="eod_1";constchar VO_TRANSPORTVAN[]="tac3_1";//VO Declarations (Orientation Markers)constchar VO_ENGINE01_ORIENT[]="E81_2";constchar VO_ENGINE02_ORIENT[]="E83_2";constchar VO_RENGINE01_ORIENT[]="E82_2";constchar VO_RENGINE02_ORIENT[]="E84_2";constchar VO_BC_ORIENT[]="BC11_2";constchar VO_SQUAD_ORIENT[]="S83_2";constchar VO_HEAVYRESCUE_ORIENT[]="HR81_2";constchar VO_RESCUECRANE_ORIENT[]="C81_2";constchar VO_HAZMAT_ORIENT[]="H81_2";constchar VO_BRUSH_ORIENT[]="B82_2";constchar VO_TANKER_ORIENT[]="T83_2";constchar VO_AMBULANCE01_ORIENT[]="M511_2";constchar VO_AMBULANCE02_ORIENT[]="M512_2";constchar VO_AMBULANCE03_ORIENT[]="M513_2";constchar VO_AMBULANCE04_ORIENT[]="M521_2";constchar VO_AMBULANCE05_ORIENT[]="M522_2";constchar VO_EMS_SUP_ORIENT[]="EMS5_2";constchar VO_PATROL01_ORIENT[]="7A1_2";constchar VO_PATROL02_ORIENT[]="7A2_2";constchar VO_PATROL03_ORIENT[]="7A3_2";constchar VO_PATROL04_ORIENT[]="7A4_2";constchar VO_PATROL05_ORIENT[]="7A5_2";constchar VO_PATROL06_ORIENT[]="7A6_2";constchar VO_UMPCPATROL_ORIENT[]="umpc_2";constchar VO_SUVPATROL_ORIENT[]="7S1_2";constchar VO_SWATUMPC_ORIENT[]="tac1_2";constchar VO_SWATRESCUE_ORIENT[]="tac2_2";constchar VO_BOMBSQUAD_ORIENT[]="eod_2";constchar VO_TRANSPORTVAN_ORIENT[]="tac3_2";//Personnel Prototype Declarationsconstchar PROTO_[]="mod:Prototypes/Vehicles/01 LA Ambulance/ambulance01.e4p";//Misc declarationconstchar UNNAMED[]="Unnamed";
object SpawnVehiclesSP_FireEms:CommandScript{SpawnVehiclesSP_FireEms(){//Nothing to do here}boolCheckPossible(GameObject*Caller){returntrue;}boolCheckTarget(GameObject*Caller,Actor*Target,int childID){returntrue;}voidPushActions(GameObject*Caller,Actor*Target,int childID){SpawnVehicle(PROTO_ENGINE01, VO_ENGINE01,1);SpawnVehicle(PROTO_ENGINE02, VO_ENGINE02,1);/*
SpawnVehicle(PROTO_RENGINE01, VO_RENGINE01, 2);
SpawnVehicle(PROTO_RENGINE02, VO_RENGINE02, 2);
SpawnVehicle(PROTO_BC, VO_BC, 3);
SpawnVehicle(PROTO_HEAVYRESCUE, VO_HEAVYRESCUE, 4);
SpawnVehicle(PROTO_RESCUECRANE, VO_RESCUECRANE, 5);
SpawnVehicle(PROTO_HAZMAT, VO_HAZMAT, 6);
SpawnVehicle(PROTO_SQUAD, VO_SQUAD, 7);
SpawnVehicle(PROTO_BRUSH, VO_BRUSH, 8);
SpawnVehicle(PROTO_TANKER, VO_TANKER, 9);
*/}voidSpawnVehicle(constchar*VehicleProto,constchar*VehicleVO,intVehicleTypeID=-1){ActorList spawnList =Game::GetActors(VehicleVO);for(int i =0; i < spawnList.GetNumActors(); i++){Vector spawnLoc = spawnList.GetActor(0)->GetPosition();Vehicle v =Game::CreateVehicle(VehicleProto, UNNAMED);
v.EnableBlueLights(false);
v.SetPosition(spawnLoc);
v.UpdatePlacement();switch(VehicleTypeID){case1:
v.SetMaxPassengers(6);
v.SetSpeed(12.0f);
v.SetCommandable(true);
v.AssignCommand("MoveTo");
v.AssignCommand("GoHome");break;default:
v.EnableBlueLights(true);//Visually tell me that I missed you}}}};
Â
As for the Switch statement...I know it's working since the spawned vehicles have the correct number of seats set meaning the v.SetMaxPassengers(6); is being called.
So I'e decided to use the last of my remaining free time to update a mod of mine. I am trying to create my own "Auto Spawn" script for freeplay. When freeplay loads, I want all vehicles to spawn in their parking spots. I've managed to get them all to spawn (they don't face the right direction but thats a fix for another time), but the biggest problem that I need some help with is that they spawn without ANY commands. I can select the vehicle without a problem, but no commands show up. When I attempt to forcibly add a commands like:
v.AssignCommand("MoveTo");
Still nothing appears. Not even the MoveTo command I'm explicitly adding.
Â
All vehicles are affected by this, and all vehicles have their commands set in the editor.
Â
Here is my code thus far:
Â
As for the Switch statement...I know it's working since the spawned vehicles have the correct number of seats set meaning the v.SetMaxPassengers(6); is being called.
Â
Thanks for the help!