timmiej93 Posted March 10, 2011 Report Share Posted March 10, 2011 Hey,I'm, trying to make a towtruck station, but therefore I need a return to "..." Vcmd. It's just that I don't have a clue how to make a new one like this. I did assign VcmdToTowTruck to the tow truck, but do I have to link this Vcmd to a script in some way??? Ofcourse there must be a script behind the Vcmd, or else it's just useless, but how do I link the two??I hope you understand what I mean, if not please leave a message.Tim Quote Link to comment Share on other sites More sharing options...
Newfoundking Posted March 11, 2011 Report Share Posted March 11, 2011 In the script you would link the command to the actual action. In theory, not in code, it would basically do this. The object button To Towtruck would have the unit go to the virtual object called XYZVO and unload a load, then go to ZYXVO and park to be called out again. Look at hoppah's to fire station commands to see the exact coding for this Quote Link to comment Share on other sites More sharing options...
timmiej93 Posted March 13, 2011 Author Report Share Posted March 13, 2011 Hey, thanks for responding.I think I got the basics scripted right now, but I would like to make the transported vehicle disappear after 5 (or so) seconds, without blowing it up and damaging something.Here's the script:Download//******************************************************************************************// #Version 1.0#//// Includes: To salvage station command.//// - VcmdToSalvageStation//// Script by Tim with use of Hoppah's scripts.////******************************************************************************************const char CMD_TOSALVAGE[] = "VcmdToSalvageStation";const char CMD_SIREN[] = "VcmdSiren";const char CMD_AUTOSIREN_OFF[] = "VcmdAutoSirenOff";const char CMD_WARNINGLIGHTS[] = "VcmdWarningLightsOn";const char DUMMY_WARNINGLIGHTS[] = "DummyHasWarningLights";const char DUMMY_GOHOME[] = "DummyGoHome";const char CMD_FLASHINGLIGHTS[] = "VcmdFlashingLights";const char CMD_GOHOME[] = "GoHome";const char CMD_UNLOAD[] = "unload";const char CMD_LOADUP[] = "loadup";const char OBJ_TOWTRUCK[] = "mod:Prototypes/Vehicles/02 LA TEC/tow_truck.e4p";const char OBJ_ROLLBACK[] = "mod:Prototypes/Vehicles/04 LA TEC/rollback.e4p";const char VO_SALVAGE1[] = "salvage_gate01";const char VO_TURNTO1[] = "salvage_vogate01a";const char VO_SALVAGE01[] = "salvage01";const char VO_SALVAGE02[] = "salvage02";const char VO_SALVAGE03[] = "salvage03";const char VO_SALVAGE_DROPOFF[] = "salvage_dropoff";const char VO_SALVAGE_DROPOFF_TURNTO[] = "salvage_dropoff_turnto";const char SND_TOSTATION[] = "mod:Audio/FX/radio/1019.wav";const char HINT_NOTVALID[] = "This vehicle doesn't belong in the fire station!";const char HINT_NOSPACE_SALVAGE[] = "No space at the Salvage Station, vehicle returns to base!";const char HINT_NOSPACE_AMBULANCE[] = "No space at the fire station, vehicle starts a patrol!";const char HINT_TRANSPORTS[] = "The ambulance has transports, it will go to the hospital first!";int DummyGroup = 32;object VcmdToSalvageStation : CommandScript{ VcmdToSalvageStation() { SetCursor("tosalvagestation"); SetIcon("tosalvagestation"); SetGroupID(DummyGroup); SetGroupLeader(true); SetRestrictions(RESTRICT_SELFEXECUTE); } bool CheckPossible(GameObject *Caller) { if (!Caller->IsValid()) return false; if (!Game::IsFreeplay()) return false; Vehicle v(Caller); if (v.IsCollidingWithVirtualObject(VO_SALVAGE01) || v.IsCollidingWithVirtualObject(VO_SALVAGE02) || v.IsCollidingWithVirtualObject(VO_SALVAGE03)) return false; if (!v.HasCommand("MoveTo")) return false; return true; } bool CheckTarget(GameObject *Caller, Actor *Target, int childID) { if (!Caller->IsValid() || !Target->IsValid() || (Caller->GetID() != Target->GetID())) return false; return true; } void PushActions(GameObject *Caller, Actor *Target, int ChildID) { Vector Pos = Caller->GetPosition(); Vehicle v(Caller); if (v.GetVehicleType() == VT_TEC_ASF && v.GetCarriedObjects().GetNumObjects()>0) { ActorList l1 = Game::GetActors(VO_SALVAGE_DROPOFF); ActorList l2 = Game::GetActors(VO_SALVAGE_DROPOFF_TURNTO); v.AssignCommand(CMD_UNLOAD); }else if (v.IsBlueLightEnabled()) Game::ExecuteCommand(CMD_FLASHINGLIGHTS, &v, &v); if (v.HasCommand(DUMMY_WARNINGLIGHTS)) { v.EnableBlinker(BLT_NONE); v.RemoveCommand(DUMMY_WARNINGLIGHTS); v.AssignCommand(CMD_WARNINGLIGHTS); } if (v.HasObjectPath(NULL)) Game::ExecuteCommand(DUMMY_GOHOME, &v, &v); if(StrCompare(v.GetPrototypeFileName(), OBJ_TOWTRUCK) == 0 || StrCompare(v.GetPrototypeFileName(), OBJ_ROLLBACK) == 0) { bool Possible = false; GameObjectList l4; Game::CollectObstaclesOnVirtualObject(VO_SALVAGE01, l4, ACTOR_VEHICLE); if(l4.GetNumObjects() == 0 && !Possible) Possible = true; GameObjectList l5; Game::CollectObstaclesOnVirtualObject(VO_SALVAGE02, l5, ACTOR_VEHICLE); if(l5.GetNumObjects() == 0 && !Possible) Possible = true; GameObjectList l6; Game::CollectObstaclesOnVirtualObject(VO_SALVAGE03, l6, ACTOR_VEHICLE); if(l6.GetNumObjects() == 0 && !Possible) Possible = true; if (Possible) { ActorList l1 = Game::GetActors(VO_SALVAGE1); ActorList l2 = Game::GetActors(VO_TURNTO1); } else { Mission::PlayHint(HINT_NOSPACE_SALVAGE); v.PushActionExecuteCommand(ACTION_NEWLIST, CMD_GOHOME, Caller, 0, false); return; } } Vehicle v(Caller); if(StrCompare(v.GetPrototypeFileName(), OBJ_TOWTRUCK) == 0 || StrCompare(v.GetPrototypeFileName(), OBJ_ROLLBACK) == 0) { ActorList l2 = Game::GetActors(VO_TURNTO1); if (!Game::IsSquadInVirtualObject(VO_SALVAGE01) && !Game::IsSquadInVirtualObject(VO_SALVAGE02) && !Game::IsSquadInVirtualObject(VO_SALVAGE03)) { ParkinglotFound = true; ActorList l1 = Game::GetActors(VO_SALVAGE01); } else if (Game::IsSquadInVirtualObject(VO_SALVAGE01) && !Game::IsSquadInVirtualObject(VO_SALVAGE02) && !Game::IsSquadInVirtualObject(VO_SALVAGE03)) { ParkinglotFound = true; ActorList l1 = Game::GetActors(VO_SALVAGE02); } else if (Game::IsSquadInVirtualObject(VO_SALVAGE01) && Game::IsSquadInVirtualObject(VO_SALVAGE02) && !Game::IsSquadInVirtualObject(VO_SALVAGE03)) { ParkinglotFound = true; ActorList l1 = Game::GetActors(VO_SALVAGE03); } else if (!Game::IsSquadInVirtualObject(VO_SALVAGE01) && Game::IsSquadInVirtualObject(VO_SALVAGE02) && !Game::IsSquadInVirtualObject(VO_SALVAGE03)) { ParkinglotFound = true; ActorList l1 = Game::GetActors(VO_SALVAGE02); ActorList l3 = Game::GetActors(VO_SALVAGE01); if(l3.GetNumActors() > 0) Vector Forward = l3.GetActor(0)->GetPosition(); GameObjectList l4; Game::CollectObstaclesOnVirtualObject(VO_SALVAGE02, l4, ACTOR_VEHICLE); for (int i = 0; i < l4.GetNumObjects(); i++) { Vehicle m = l4.GetObject(i); m.PushActionMove(ACTION_NEWLIST, Forward); } } else if (!Game::IsSquadInVirtualObject(VO_SALVAGE01) && !Game::IsSquadInVirtualObject(VO_SALVAGE02) && Game::IsSquadInVirtualObject(VO_SALVAGE03)) { ParkinglotFound = true; ActorList l1 = Game::GetActors(VO_SALVAGE02); ActorList l3 = Game::GetActors(VO_SALVAGE01); if(l3.GetNumActors() > 0) Vector Forward = l3.GetActor(0)->GetPosition(); GameObjectList l4; Game::CollectObstaclesOnVirtualObject(VO_SALVAGE03, l4, ACTOR_VEHICLE); for (int i = 0; i < l4.GetNumObjects(); i++) { Vehicle m = l4.GetObject(i); m.PushActionMove(ACTION_NEWLIST, Forward); } } else if (!Game::IsSquadInVirtualObject(VO_SALVAGE01) && Game::IsSquadInVirtualObject(VO_SALVAGE02) && Game::IsSquadInVirtualObject(VO_SALVAGE03)) { ParkinglotFound = true; ActorList l1 = Game::GetActors(VO_SALVAGE03); ActorList l3 = Game::GetActors(VO_SALVAGE01); if(l3.GetNumActors() > 0) Vector Forward = l3.GetActor(0)->GetPosition(); ActorList l4 = Game::GetActors(VO_SALVAGE02); if(l4.GetNumActors() > 0) Vector Forward2 = l4.GetActor(0)->GetPosition(); float rot[9]; float childRot[9]; GameObjectList l5; Game::CollectObstaclesOnVirtualObject(VO_SALVAGE02, l5, ACTOR_VEHICLE); for (int i = 0; i < l5.GetNumObjects(); i++) { Vehicle m = l5.GetObject(i); m.PushActionMove(ACTION_NEWLIST, Forward); } GameObjectList l6; Game::CollectObstaclesOnVirtualObject(VO_SALVAGE03, l6, ACTOR_VEHICLE); for (int i = 0; i < l6.GetNumObjects(); i++) { Vehicle c = l6.GetObject(i); c.PushActionWait(ACTION_NEWLIST, 0.7f); c.PushActionMove(ACTION_APPEND, Forward2); } } else { Mission::PlayHint(HINT_NOSPACE_SALVAGE); v.PushActionExecuteCommand(ACTION_NEWLIST, CMD_GOHOME, Caller, 0, false); return; } } }}; Quote Link to comment Share on other sites More sharing options...
timmiej93 Posted March 17, 2011 Author Report Share Posted March 17, 2011 Ok so this is how to check if the towtruck has a load right?v.GetCarriedObjects().GetNumObjects()>0When i hit the button now, it doesn't do anything exept for turning of the flashing lights. Quote Link to comment Share on other sites More sharing options...