timmiej93 Posted August 10, 2014 Report Share Posted August 10, 2014 Hey guys, I'm trying to create a script that constantly checks if a vehicle is inside a VO, so it can open a gate. I know what you're thinking, why not just use a trigger? I tried that, but there were a few flaws with it:- Vehicles just drove straight through the gate- The "open" animation often wasn't even finished before it started the 'close' animation, resulting in a weird jump in the fence- The gates not opening at all sometimes. Other reasons why I want to use a script for these gates are:- Opening times, automatically "unlock" the gates after 7am and lock them after 5pm.- Being able to push a button on a controlpanel to open or close the gate- Nicer opening and closing settings- Bonus: Scripting experience for me. So if anyone understands what I'm trying to achieve, I could definitely use your help, I'm willing to test everything. Tim Quote Link to comment Share on other sites More sharing options...
Hoppah Posted August 10, 2014 Report Share Posted August 10, 2014 I assume its for freeplay and you tried the default garage doors first? (the one of the original freeplay map) A button that opens the gate is very easy to do. It's like the command for the fire stations in the LA mod to open the gates.A gate that opens automatically with a custom script is more complex. The US Army mod has a similar code in it. For freeplay there'd be a script running every 1 to 5 seconds to check that perimeter. Quote Link to comment Share on other sites More sharing options...
timmiej93 Posted August 11, 2014 Author Report Share Posted August 11, 2014 Bullocks.. Just typed a lengthy answer, wifi drops and tapatalk refuses to post. I'll from a PC tomorrow.. -------------- Alright, let's try again. I'll definitely have a look at the US Army mod, see if that's of any help for me, thanks for the tip. It is indeed freeplay, yes. Unfortunately, I never played the original freeplay map, only modded ones, so I'm not quite familiar with it, and not quite sure which garage doors you mean. I've probably been doing something weird if it's that easy, because it just won't work. I've copied parts of your VcmdOpenGates (and close) scripts, and changed them so they should work for me, but the FOR parameter or whatever it's called, never get's caled. It's something like this: for(i = 0; i < gate->GetNumObjects; i++);If I'm able to read this correct, this states that there is in fact no gate? ---------------- So I've just tested the FOR parameter, like this: for(int i=0; i < gate01.GetNumObjects(); i++) { System::Log("gate01"); Mission::PlayHint("gate01"); }Entire script:const char DUMMY_TECHGATES[] = "DummyTechGates";const char NAME_GATE01[] = "gate01";const char NAME_GATE02[] = "gate02";const char OBJ_TECVAN[] = "mod:Prototypes/Vehicles/04 LA Tec/engineer_vehicle.e4p";const char OBJ_ROLLBACK[] = "mod:Prototypes/Vehicles/04 LA Tec/rollback.e4p";const char OBJ_ROLLBACK2[] = "mod:Prototypes/Vehicles/04 LA Tec/tow_truck.e4p";const char OBJ_RB_LOADED[] = "mod:Prototypes/Vehicles/04 LA Tec/rollback2.e4p";const char OBJ_RB2_LOADED[] = "mod:Prototypes/Vehicles/04 LA Tec/tow_truck2.e4p";const char VO_GATE01[] = "TT_voentrygate01";const char VO_GATE02[] = "TT_voentrygate02";const char TRIGGER_GATE01[] = "TT_entrygate01";const char TRIGGER_GATE02[] = "TT_entrygate01";const char ANI_CLOSE[] = "close";const char ANI_OPEN[] = "open";const char VOSET_ROAD[] = "Freely Accessible";const char VOSET_BARRICADE[] = "Barricade"; object TechGates : CommandScript{ TechGates() { } bool CheckPossible(GameObject *Caller) { } bool CheckTarget(GameObject *Caller, Actor *Target, int childID) { } void PushActions(GameObject *Caller, Actor *Target, int ChildID) { GameObjectList gate01 = Game::GetGameObjects(NAME_GATE01); GameObjectList gate02 = Game::GetGameObjects(NAME_GATE02); for(int i=0; i < gate01.GetNumObjects(); i++) { System::Log("gate01"); Mission::PlayHint("gate01"); } for(int i=0; i < gate02.GetNumObjects(); i++) { System::Log("gate02"); Mission::PlayHint("gate02"); } }}; And just like I thought, the log file is clear. I used the following gate:LA Modmod:Prototype/Objects/Fences/industryfence03Industry Fence 03 Animated Could this particular gate be causing this? ---------------------- PS. I've checked the US army mod script, but that's a bit above me I'm afraid.I get how the below script works, but when trying to integrate it into my own script, it just does nothing. I think it has something to do with the parameter "Trigger", it's like the game doesn't know what it is when I'm playing the LA Mod (which I'm modding for), and when looking in the missionscript from the US Army mod, it doesn't look like it gets defined somewhere void OnTrigger(const char *Trigger, Actor *Collider) { switch(Trigger) { case "gate" : { if (Collider->GetType() == ACTOR_PERSON || Collider->GetType() == ACTOR_VEHICLE) { if (mBarrier.IsValid() && !mBarrier.IsCurrentAnimation("open")) { if (Collider->GetType() == ACTOR_VEHICLE) Vehicle v(Collider); if (Collider->GetType() == ACTOR_PERSON) Person v(Collider); if(v.IsCurrentAction("EActionMove") || v.IsCurrentAction("EActionFindPath")) mBarrier.SetAnimation("open"); mBarrier.PushActionWait(ACTION_NEWLIST, 10.f); mBarrier.PushActionSwitchAnim(ACTION_APPEND, "close"); } } } break; Quote Link to comment Share on other sites More sharing options...
itchboy Posted August 14, 2014 Report Share Posted August 14, 2014 Bullocks.. Just typed a lengthy answer, wifi drops and tapatalk refuses to post. I'll from a PC tomorrow.. -------------- Alright, let's try again. I'll definitely have a look at the US Army mod, see if that's of any help for me, thanks for the tip. It is indeed freeplay, yes. Unfortunately, I never played the original freeplay map, only modded ones, so I'm not quite familiar with it, and not quite sure which garage doors you mean. I've probably been doing something weird if it's that easy, because it just won't work. I've copied parts of your VcmdOpenGates (and close) scripts, and changed them so they should work for me, but the FOR parameter or whatever it's called, never get's caled. It's something like this: for(i = 0; i < gate->GetNumObjects; i++);If I'm able to read this correct, this states that there is in fact no gate? ---------------- And just like I thought, the log file is clear. I used the following gate:LA Modmod:Prototype/Objects/Fences/industryfence03Industry Fence 03 Animated Could this particular gate be causing this? ---------------------- PS. I've checked the US army mod script, but that's a bit above me I'm afraid.I get how the below script works, but when trying to integrate it into my own script, it just does nothing. I think it has something to do with the parameter "Trigger", it's like the game doesn't know what it is when I'm playing the LA Mod (which I'm modding for), and when looking in the missionscript from the US Army mod, it doesn't look like it gets defined somewhere void OnTrigger(const char *Trigger, Actor *Collider) { switch(Trigger) { case "gate" : { if (Collider->GetType() == ACTOR_PERSON || Collider->GetType() == ACTOR_VEHICLE) { if (mBarrier.IsValid() && !mBarrier.IsCurrentAnimation("open")) { if (Collider->GetType() == ACTOR_VEHICLE) Vehicle v(Collider); if (Collider->GetType() == ACTOR_PERSON) Person v(Collider); if(v.IsCurrentAction("EActionMove") || v.IsCurrentAction("EActionFindPath")) mBarrier.SetAnimation("open"); mBarrier.PushActionWait(ACTION_NEWLIST, 10.f); mBarrier.PushActionSwitchAnim(ACTION_APPEND, "close"); } } } break;The US Army mod relies on a mission script. There are many script functions in missionscripts (like the void OnTrigger() function), but unfortunately due to EM4's programming, it CANNOT be put into EM4 freeplay. You would have to make a script that constantly runs itself again and again every 1 - 5 seconds.IMO, the best way to go around this is to simply make a script that opens or closes the gate, and that script can be called/invoked whenever a vehicle wants to enter or exit the station. Creating a script that constantly runs in the background is quite a CPU eating process (especially for people with shitty PC's like me)A way more complicated option is to completely recreate freeplay into campaign. It would take MASSIVE balls and skills to do that and not to mention a lot of time, but in the end, it will probably be the greatest scripting innovation to ever come to EM4. Moreso if it were customizeable and events could be added and parameters be changed. Whoever could do this would be a god amongst men. Quote Link to comment Share on other sites More sharing options...
timmiej93 Posted August 14, 2014 Author Report Share Posted August 14, 2014 (edited) So what you're implying would be something like this:- Adding something like below to the move script: (Not sure if it would work though, since move might only be affected on clicking, and not when it has been driving for a while.) if (Vehicle collides with gate VO) { Call command X } And then just make script X that opens the gate? PS. I thought the US Army mod is pretty much freeplay into campaign? As far as I've seen, it's pretty much that, and it's quite awesome. Too bad of the many ambushes though. ------------ Well the gates not opening is definitely up to the gates themselves.. Added a firestation gate next to it, included it into the script, and that one worked. Time to find an alternative then, unfortunately..Could anyone check if this gate can be opened and closed like the fire station gates?LA Modmod:Prototype/Objects/Fences/industryfence03Industry Fence 03 Animated If not, does anyone know of a good looking animated gate that can be moved like the firestation gates?? Edited August 15, 2014 by timmiej93 Quote Link to comment Share on other sites More sharing options...