OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: dmakatra on 16 Jun 2003, 15:02:30

Title: random x and y=one point???
Post by: dmakatra on 16 Jun 2003, 15:02:30
I dunno really how IÂ'm gonna explain this but IÂ'm makin a random walkin script where u(me ;)) can set how big the area the guy(s) are goin to walk in x and y. Now, the random command now randomly spawns a pos in that area I choose but how the f*ck do I get my guys to walk there? IÂ've tried some ways like _x + _y = _thepoint and stuff but it doesnÂ't work.
I donÂ't want to use GLs and this have to be done someway since then those arty scripts wouldnÂ't work :-\. Plz help.

Thx in advance. :-*

EDIT: I made a little pic in MS Paint that can help u understand cause my english sux. ;D

*REMOVED*
Title: Re:random x and y=one point???
Post by: Chris Death on 16 Jun 2003, 15:14:04
hmm - shouldn't it be:

xxx doMove [_x,_y]

soz, can't test it here at work to ensure it's correct

~S~ CD
Title: Re:random x and y=one point???
Post by: dmakatra on 16 Jun 2003, 15:17:57
yea, tried that but it wouldnt work...  :-\
Title: Re:random x and y=one point???
Post by: Komuna on 16 Jun 2003, 15:27:08
[Chris Death]: Unit doMove [_x,_y,_z] - I belive _z is not mandatory, but try it, could be just a syntax error...

Unit Move [_x,_y] - This works fine... As doMove should work fine, to.

[Komuna]: ['Group','N'] SetWPPos [_x,_y,_z] - I'm not sure if the syntax is right... besides, i've never tested it ;D. But it could solve your problem, by conditioning a certain waypoint [Number='N'] of a certain 'Group' and activate it (or switch through trigger) when tha coordinates are given. #Edit: the command would set a new position for your WP (Waypoint)

Good luck, mate! :-* *



*sexual pervert... AhAhAh! ;)

Title: Re:random x and y=one point???
Post by: LCD on 16 Jun 2003, 16:05:05
u put point @ da westouthest (or da botom n left) of da area u want ;D name it startpoint

n point @ da eastnorthest (top right) of da area u want nd name it endinpoint

da script wil look like dat

_x = random ((getpos endinpoint select 0)-(getpos startpoint select 0))
_y = random ((getpos endinpoint select 1)-(getpos startpoint select 1))

unitname move [(getpos startpoint select 0)+_x,(getpos startpoint select 1)+_y,0]

shud work - if not ill find somin - cuz i know i did it in 1 of ma scripts

LCD OUT

[edit] or did i got da answer wrong ::)



Title: Re:random x and y=one point???
Post by: dmakatra on 16 Jun 2003, 16:15:08
Thx guys, IÂ'll try that when I get home, right now I am at the library in shorts and the rain is pissin down so I canÂ't get home :'( :P
Title: Re:random x and y=one point???
Post by: Wolfrug on 16 Jun 2003, 16:20:52
Huhm. Alright, in a script I'm not sure at this particular second. Not entirely sure what exactly it is that you need it for either. Might help if you'd enlighten us on that.

I mean, you can always make the "placement radius" of the waypoint huge to create some randomness...  ::)

Wolfrug out.
Title: Re:random x and y=one point???
Post by: dmakatra on 16 Jun 2003, 17:45:46
Code: [Select]
_center = _this select 0

_x = GetPos _Center select 0
_y = GetPos _Center select 1

_x = _x + Random(200) - 100
_y = _y + Random(200) - 100

Unit doMove [_x,_y]

Worked like a charm. Cheers.

*Topic solved and picture removed(need da space for more files ;D)*