OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Jim666 on 23 Jul 2005, 13:44:21
-
I've got a mission where your soppose to assinate a enemy officer, I want the officer to start in random places, (I dont mean placement radious) I want to script it like, each time you start a different mission he can be in a different town, or in a different part of the town.
How can i go about doing this?
-
create several empty markers in the places you want, then group them all to the officer. he'll spawn in random placement each time the game is played.
-
Do the markers need to be named anything?
-
Nope.
-
In fact yes, because I think you can't place a marker without a name.
-
indeed yes. they needn't be anything special, but flashpoint won't let you place an unnamed marker.
the only difficulty you'll have is with grouping them to the unit, because as soon as you switch to 'groups' the markers will disappear ;)
-
MISSION EDITOR
in the "Init field" of your officer unit place the following line
this exec "setpos.sqs"
and then create a number of empty markers, lets name them "pos1", "pos2" etc at the spawn location of your choice
Setpos.sqs
_unit = _this select 0
@ alive _unit
;; following is an array containing all the markers you want as a possible setpos location
_markers = ["pos1","pos2","pos3","pos4","pos5","pos6"]
_count = count _markers
_count = _count + 0.9
_rnd = random count
_rnd = _rnd - (_rnd mod 1)
_pos = getmarkerpos (_markers select _rnd)
_unit setpos _pos
exit
the unit will initially spawn at the location placed by you in the editor and then a fraction of a second later will be setpossed to one of the markers selected at random
-
Hi
I seen this script and decided to try it because I could use something like this but I keep getting this error. I am not very good at diagnosing a problem. I need some help
Here is the error I get.
_unit = _this select l#l" :error select, type object, expected array
I put an enemy on the map and created some markers and named them pos1, pos2, pos3, pos4, pos5, and pos6
As always thanks people ;D
-
Well, that's because in unit's init field:
this exec "script.sqs"
will pass the unit itself to the script.
Then in the script it should look like:
_unit = _this
~S~ CD
-
Terox, why the script? The much easier way is via grouping to markers.
-
Yea I just ended up grouping the markers. I never knew you could group them. It worked out perfectly. Its nice not knowing where the enemy is coming from.