OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Milwot on 01 May 2004, 19:40:15

Title: Random positions for a vehicle
Post by: Milwot on 01 May 2004, 19:40:15
In the same way the hostage in "Operation Lojack" is at one of six random locations, I want to place a fuel truck in the same way...what would the script look like to do this?
Title: Re:Random positions for a vehicle
Post by: dmakatra on 01 May 2004, 19:52:17
Put this in a script:

Code: [Select]
_truck = _this select 0

_random = random 6

? _random =< 1 : _truck setpos getpos pos1
? _random =< 2 : _truck setpos getpos pos2
? _random =< 3 : _truck setpos getpos pos3
? _random =< 4 : _truck setpos getpos pos4
? _random =< 5 : _truck setpos getpos pos5
? _random =< 6 : _truck setpos getpos pos6

exit

And execute it like this:
[Truckname] exec "nameofscript.sqs"

:beat: *Gets Shot* :beat:
Title: Re:Random positions for a vehicle
Post by: j-man on 01 May 2004, 20:18:14
I believe it's something like this:

_truck = _this select 0

_random = random 6

?(_random > 0) && (_random <= 1) : _truck setpos getpos pos1
?(_random > 1) && (_random <= 2) : _truck setpos getpos pos2
?(_random > 2) && (_random <= 3) : _truck setpos getpos pos3
?(_random > 3) && (_random <= 4) : _truck setpos getpos pos4
?(_random > 4) && (_random <= 5) : _truck setpos getpos pos5
?(_random > 5) && (_random <= 6) : _truck setpos getpos pos6
Title: Re:Random positions for a vehicle
Post by: Milwot on 01 May 2004, 20:19:15
Hmm...looks good...I put it in a script, put some "empty" markers down, and named the truck "truck"....but when I execute it, it says '
  • } Error Invalid Number in expression[/b]
Title: Re:Random positions for a vehicle
Post by: Milwot on 01 May 2004, 20:23:37
...and after trying J-man's version, it still says that and doesn't work....I'm using a radio Alpha trigger to do it....lemme know what you think...
Title: Re:Random positions for a vehicle
Post by: Chris Death on 01 May 2004, 20:27:11
hmm - I'm a friend of using scripted solutions, but i'm also
a friend of easy & simple solutions - even if there's no need
for scripts  ;)

Maybe this one got lost during OFP's 3 years being:

create 6 markers and place them where you want the truck
to possibly appear

create your truck now and group it with all 6 markers (press F2
and drag a line from-to)

Now preview your mission as often as u want and guess where
the truck will appear  :D

:edit - off course you can make your markers invisible (make
'em rectangle size: 0/0 or so), once you did your drag-line-to-group job. If you do it before, i wish yer good luck to find the
markers  ;D

~S~ CD
Title: Re:Random positions for a vehicle
Post by: Planck on 01 May 2004, 20:28:44
Or even this:

Code: [Select]
_truck = _this select 0

_random = random 6
_num = random mod 1
_random = random - _num

? _random = 1 : _truck setpos getpos pos1
? _random = 2 : _truck setpos getpos pos2
? _random = 3 : _truck setpos getpos pos3
? _random = 4 : _truck setpos getpos pos4
? _random = 5 : _truck setpos getpos pos5
? _random = 6 : _truck setpos getpos pos6

exit

@Milwot

Where have you defined the positions:
pos1 through to pos6?


EDIT:.......OOPS


Planck
Title: Re:Random positions for a vehicle
Post by: Milwot on 01 May 2004, 20:33:13
Well waddya know...

No scripts are needed....Chris Death's Idea works...just group the truck to the markers and it works perfectly...

I defined the positions using "empty" markers...keep them together to find them, then move them to where they need to be.
Title: Re:Random positions for a vehicle
Post by: dmakatra on 01 May 2004, 21:53:29
There reason it didn't work was because you used markers, I thought you were going to use GLs or invisible Hs. You ahve to change the command getpos to getmarkerpos in order for it to work. ;)

:beat: *Gets Shot* :beat: