OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Jim666 on 23 Jul 2005, 13:44:21

Title: Random
Post 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?
Title: Re:Random
Post by: bedges on 23 Jul 2005, 13:54:08
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.
Title: Re:Random
Post by: Jim666 on 23 Jul 2005, 14:06:26
Do the markers need to be named anything?
Title: Re:Random
Post by: h- on 23 Jul 2005, 15:32:21
Nope.
Title: Re:Random
Post by: rado1265 on 23 Jul 2005, 15:35:16
In fact yes, because I think you can't place a marker without a name.
Title: Re:Random
Post by: bedges on 23 Jul 2005, 16:17:28
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 ;)
Title: Re:Random
Post by: Terox on 24 Jul 2005, 16:14:03

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
Quote
_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
Title: Re:Random
Post by: Killzone on 07 Aug 2005, 21:47:51
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
Title: Re:Random
Post by: Chris Death on 07 Aug 2005, 22:15:47
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
Title: Re:Random
Post by: Dubieman on 08 Aug 2005, 14:54:18
Terox, why the script? The much easier way is via grouping to markers.
Title: Re:Random
Post by: Killzone on 08 Aug 2005, 17:35:41
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.