OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: dmakatra on 29 Apr 2004, 19:16:30

Title: Moving GLs
Post by: dmakatra on 29 Apr 2004, 19:16:30
Hi! I have a GL which I want to move. But I don't know where, 'cause the player decide it by the onmapsingleclick command. And I do not want to move it like KA-BAM fast like GLs normally do but about 2 meters each time then a delay on one sec or maybe something like that. Any ideas how I should do this? Cheers!

:beat: *Gets GLed* :beat:
Title: Re:Moving GLs
Post by: DBR_ONIX on 29 Apr 2004, 20:14:48
For the not moving too fast
If you use the command to stop them, with a delay of a few seconds, then let them move for another 2 seconds, that should work

- Ben
Title: Re:Moving GLs
Post by: dmakatra on 29 Apr 2004, 21:04:33
GL's moves FAST. Really FAST. If you put a WP they will be there before you can say the shortest word in the dictonary. ;)

:beat: *Gets Shot* :beat:
Title: Re:Moving GLs
Post by: Raptorsaurus on 29 Apr 2004, 22:24:49
Make a script that plots multiple points between the GL's present postition and the new postition, then have the script move the GL incrementally from point to point with a delay between moves until it reaches the final point.
Title: Re:Moving GLs
Post by: Wadmann on 30 Apr 2004, 00:45:39
I had used a GL to create a conversation of sorts using waypoints to activate the sidechat command and having the waypoints pause by the countdown option. I believe that you should be able to slow the pace down with this method.

                                                                          Wadmann
Title: Re:Moving GLs
Post by: dmakatra on 30 Apr 2004, 09:21:22
The problem is that I do not know how many points/WPs that I need since I not know the location. If the player clicks right next to the GL it would take as much time to get there as clicking 50 km away from the GL.

:beat: *Gets Shot* :beat:
Title: Re:Moving GLs
Post by: dmakatra on 01 May 2004, 15:47:29
OK, with a lot of frustrating experimenting, digging in others scripts, comref reading I finally got a script here:

Code: [Select]
_GL = _this select 0
_target = _this select 1
_speed = _this select 2

#loop
_dir=[_GL,_target] call DirToObj

_1x= getpos _GL select 0
_1y= getpos _GL select 1

_2x=_1x+(_speed * (sin(_dir)))
_2y=_1y+(_speed * (cos(_dir)))

_GL setpos [_2x, _2y, 0]

~2
goto "loop"
exit

Basicly, it was the two lines with sin and cos that got me. I had to dig in other scripts that I could find and stuff like that to find out wtf they were doing. Anyway, it now works fine. With one exception. An error message. The script works as it should but it doesn't look too good with an error message showing all the time. :P

'_GL setpos [_2x, _2y, 0]|#|': Error Type Any, expected Number

How do I get rid of it? Cheers!

:beat: *Gets Shot* :beat:
Title: Re:Moving GLs
Post by: SandVoss on 18 May 2004, 12:51:42
With GL u mean the mercedes GL? Where did u download it? ;D
Title: Re:Moving GLs
Post by: dmakatra on 18 May 2004, 13:25:50
...

Why dig up this ol' thread? ???

...

Anyway, I still got the error msg problem so any help would be appriciated.

:beat: *Gets Shot* :beat:
Title: Re:Moving GLs
Post by: Chris Death on 18 May 2004, 14:55:29
lo Armsty,

Quote
_2x=_1x+(_speed * (sin(_dir)))
_2y=_1y+(_speed * (cos(_dir)))

I just noticed that you didn't initialize _2x and _2y.

Therefore the two operations in the quote above don't work.

Code: [Select]
_2x = 0
_2y = 0

somewhere at the start would fix that prob.

P.S: not sure if it will fix your main problem, as i haven't had a
look onto anything else yet - will do so after this reply  ;)

:edit - just to make clear what i meant above:

you cannot add values to a variable, which is actually not defined/initialized as such.

Code: [Select]
_a = 0
_b = 1
_c = 2
_a = _b + _c

works

Code: [Select]
_b = 1
_c = 2
_a = _b + _c

doesn't work because _a was not initialized as a numeric variable (= it doesn't exist that way), therefore you can't add anything to it.

~S~ CD
Title: Re:Moving GLs
Post by: dmakatra on 18 May 2004, 18:35:00
OK, cheers Chris, will check that out.

:beat: *Gets Shot* :beat:
Title: Re:Moving GLs
Post by: dmakatra on 19 May 2004, 11:14:23
Checked it out. Doesn't work. :-/

Ah, crap me, the script works, just displays error message. Therefor I am locking this thread.

:beat: *Gets Locked* :beat: