OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Mad Pup on 08 Feb 2012, 12:57:32
-
I'm making one of my mission's intro, and I have multiple resistance running around, and killing multiple cops. Now I was wondering how I can get the different resistance groups to stay where they are, until indicated to move to their next waypoint in a script. Or could I use game logic, at the position of the current waypoint, and use the domove command in the script whenever I want them to take off?
-
Hi Mad Pup!
If there are not so many resistance units going around, you may try to give each one of them a name (es. res1, res2, res3, res4 etc.) and then, when you want them to stop doing anything, you may try to run this line:
{_x stop true} forEach [res1, res2, res3, res4]
Then, when you want resistance units to move again from where they previously left, you have to run this line:
{_x stop false} forEach [res1, res2, res3, res4]
Cheers!
-
Would I replace _x with something? or leave it?
Okay, so let me get this straight: Lets say res1 is running, and I want res2 and res3 to stop, the script would be:
{_x stop true} forEach [res2, res3]
like that?
-
That's correct pup. '_x' is used to select all units within an array. In this instance, the array is [res2, res3]. You could use the 'disableAI "move"' command as well I guess, if you want them to stop completely. Both commands should work fine.
-
Alright.
Thank you both Gruntage, and Doktor Headshot! :D
-Mad Pup
EDIT: It's not working for some reason, it's giving me an error
Uknown Opporator: stop
???
The script line was
{_x stop true} forEach [res1, res2, res3]
-
Alright.
Thank you both Gruntage, and Doktor Headshot! :D
-Mad Pup
You're welcome! :)
EDIT: It's not working for some reason, it's giving me an error
Uknown Opporator: stop
???
The script line was
{_x stop true} forEach [res1, res2, res3]
Very weird, because script line is correctly written! Where are you running that script line from?
-
I was testing it out, I gave the player an action "STOP!"
init.sqs
stop = west1 addaction ["STOP!","stop.sqs"]
stop.sqs
{_x stop true} forEach [res1, res2, res3]
west1 removeaction stop
continue = west1 addaction ["Continue...","cont.sqs"]
exit
cont.sqs
{_x stop false} forEach [res1, res2, res3]
west1 removeaction continue
stop = west1 addaction ["STOP!","stop.sqs"]
exit
thats all I had.
EDIT: I'm running this mission in the Mission Editor, if that's what you meant.
-
Sounds strange.
Try this:
{dostop _x} forEach [res1, res2]
Shouldn't matter where you put that it should work.
-
I found the error.
You assigned "wrong" name to the stopping action: as matter of fact, you called stopping action "stop" but OFP thinks that "stop" refers to stop command (http://www.ofpec.com/COMREF/index.php?action=details&id=359&game=All) (which is the one you used before to stop resistance units) and not to a name of an action.
Solution is very simple: you just need to change the name of action from "stop" in something else (e.g. "freeze"). I attached a demo of your script finely working. You may want to check it to be sure about what I said.
Cheers ;)
-
Does the SetWP command work for AI? Will the AI actually move to the waypoint, once the waypoint is moved in a script?
Thanks in advance!
-Mad Pup
-
If you mean 'setwppos' then yes it will work:
[_unit, _wpindex] setwppos _location
_unit = unit name
_wpindex = which waypoint it is, 1 is the first waypoint, 2 is the second, etc.
_location = where you want the waypoint to move to, can be used with GLs, markers etc.
If you plan on using this in your 'stop' script, you'll want to make sure that all units are 'stop false' before you use this command. They won't move anywhere otherwise (unless I'm mistaken).
Hope this helps
-
Mmmk I wasn't sure, tested it out once, and it didn't seem to work, but I think I had the script command wrong.
Also: For anyone who reads this, if you have an empty vehicle and put a soldier in it through script command, the stop command doesn't work.
Example:
If you have an empty green car named car1, and another soldier named sol1, with this in it's init field:
this moveindriver car1
and you try to use the stop command with sol1, it won't work. It will only work if sol1 is a vehicle unit.
-Mad Pup
-
Have you tried ordering the actual vehicle to stop? Rather than the unit occupying the vehicle? :scratch:
So you would say:
car1 stop true
I've used the stop command with a vehicle before but that vehicle was the actual unit, rather than being empty with a guy driving it.
If it's for a cutscene, then you could just remove the fuel from the vehicle, forcing it to stop.
-
Oh, I never thought of that. I guess you could do that.