Jump to content
Sign in to follow this  
OmniMax

Getdir\setdir getpos\setpos puzzle

Recommended Posts

Here is the situation.

We have a helicopter. Four 'training 3' planks. We need the training planks to setpos themselves to a point where they will go wherever the helicopter will go. Thats done. a plank for each side of the helicopter. (front, behind, left, right)

We also need these planks to keep the same direction. The planks on the sides of the helicopter (left, right) you can just getdir from the helicopter and make their facing the same as the choppers. The other planks, multiply the facing of the chopper by two?

This way, the planks follow the helicopter instead of the helicopter being "free floating", so that when the helicopter turns, so does the planks. Left planks will always remain left planks, &c...

edit: I think I know the problem, the actual azimuth of the planks isn't the way it will face, for example, if you put a training 3 in the editor facing 0 degrees azimuth, it will actually have the place where you can walk at 90 and 270 degrees. If anybody figures it out, reply and post.

here is the current script:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

#begin

_xPos = getPos UFO select 0

_yPos = getPos UFO select 1

_zPos = getPos UFO select 2

_azX = getDir UFO / 2

_azY = getDir UFO * 2

ply1 setPos [(_xPos +10),_yPos,_zPos]

ply2 setPos [(_xPos +11),_yPos,_zPos]

ply5 setPos [(_xPos -10),_yPos,_zPos]

ply6 setPos [(_xPos -11),_yPos,_zPos]

ply1 setDir _azX

ply2 setDir _azX

ply5 setDir _azX

ply6 setDir _azX

ply3 setPos [_xPos,(_yPos +10),_zPos]

ply4 setPos [_xPos,(_yPos +11),_zPos]

ply7 setPos [_xPos,(_yPos -10),_zPos]

ply8 setPos [_xPos,(_yPos -11),_zPos]

ply3 setDir _azY

ply4 setDir _azY

ply7 setDir _azY

ply8 setDir _azY

getDir player

goto "begin"

Please point out any errors, needed corrections, questions, or other googly nonsense in a reply. Thanks in advance.

Omni-Max

Share this post


Link to post
Share on other sites
Guest jacobaby

There is a better method of setting the exact position of something in relation to a helicopter.

What is the idea behind the planks? I may be able to help you here.

TJ

Share this post


Link to post
Share on other sites

For setting things in relation to an object I always use a method like...

#begin

_xh= getpos heli select 0

_yh= getpos heli select 1

_zh= getpos heli select 2

_dh= getdir heli

_set1 = 10

_set2 = 11

;this will always set the plank 10 meters to the left of the heli no matter what direction its facing.

ply1 setpos [(_xh)+_set1*sin(_dh -90), (_yh)+_set1*cos(_dh-90),_zh]

ply1 setdir _dh

;likewise but to the right 10 meters.

ply2 setpos [(_xh)-_set1*sin(_dh -90), (_yh)-_set1*cos(_dh-90),_zh]

ply2 setdir _dh

ply3 setpos [(_xh)+_set2*sin(_dh -90), (_yh)+_set2*cos(_dh-90),_zh]

ply3 setdir _dh

ply4 setpos [(_xh)-_set2*sin(_dh -90), (_yh)-_set2*cos(_dh-90),_zh]

ply4 setdir _dh

;Now for the planks infront of the heli

;this will always set the plank 10 meters infront of the heli and turn it perpendicular to the heli

ply5 setpos [(_xh)+_set1*sin(_dh), (_yh)+_set1*cos(_dh),_zh]

ply5 setdir (_dh-90)

;10 meters behind the heli

ply6 setpos [(_xh)-_set1*sin(_dh), (_yh)-_set1*cos(_dh),_zh]

ply6 setdir (_dh-90)

ply7 setpos [(_xh)+_set2*sin(_dh), (_yh)+_set2*cos(_dh),_zh]

ply7 setdir (_dh-90)

ply8 setpos [(_xh)-_set2*sin(_dh), (_yh)-_set2*cos(_dh),_zh]

ply8 setdir (_dh-90)

~0.05

goto "begin"

I might have read what you wanted wrong but I think that will do the trick for you. It will always set the planks in relation to the heli's direction and its position. Also, don't forget to put atleast a small waiting period within the loop, or it will cause your computer to crash since it will be an infinite and continous loop.

I hope I helped ya.

biggrin_o.gif

Share this post


Link to post
Share on other sites

There appears to be an error in the script. It gives me garbage about

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

ply8 setpos [(_xh)-_set2*sin(_dh), (_yh)-_set2*cos(_dh),_zh]

generic error in expression...none of the planks follow the helicopter. Does regular flashpoint v1.46 support trig? I know one thing v1.46 does not have is the setvelocity command. BIS should make an effort to convert\add commands from resistance to v1.46, seeing as 99% of people only play regular flashpoint online.

Thanks for helping me though, I have no clue about any trig seeing as I haven't taken it yet.

Share this post


Link to post
Share on other sites
There appears to be an error in the script. It gives me garbage about

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

ply8 setpos [(_xh)-_set2*sin(_dh), (_yh)-_set2*cos(_dh),_zh]

generic error in expression...none of the planks follow the helicopter. Does regular flashpoint v1.46 support trig? I know one thing v1.46 does not have is the setvelocity command. BIS should make an effort to convert\add commands from resistance to v1.46, seeing as p of people only play regular flashpoint online.

Thanks for helping me though, I have no clue about any trig seeing as I haven't taken it yet.

I think you have it the other way around. Almost everyone plays resistance online. I still wonder why people have not converted to resistance, it is afterall, and upgrade. It is almost practically free. $4.99 at a local game shop.

Share this post


Link to post
Share on other sites
Quote[/b] ]

I think you have it the other way around. Almost everyone plays resistance online. I still wonder why people have not converted to resistance, it is afterall, and upgrade. It is almost practically free. $4.99 at a local game shop.

What "server browser" do you use? Gamespy? I cannot even get my resistance to work. I wish it would, I could make more "fileless addons (scripts)". In any case, some commands need to be compatible on both games.

Share this post


Link to post
Share on other sites
Quote[/b] ]

I think you have it the other way around. Almost everyone plays resistance online. I still wonder why people have not converted to resistance, it is afterall, and upgrade. It is almost practically free. $4.99 at a local game shop.

What "server browser" do you use? Gamespy? I cannot even get my resistance to work. I wish it would, I could make more "fileless addons (scripts)". In any case, some commands need to be compatible on both games.

I use the ingame browser. It is far easier to use. Gamespy sucks arse. Some people use All Seeing Eye, but the ingame browser (under Multiplayer) is very simple to use and I rarley have any problems with it.

Share this post


Link to post
Share on other sites

Sorry, I'll check out my scripting...the time i wrote that it was about 3:50 in the a.m. and didn't test it out...ill look into it and see what i can come up with.... it might just be a parentheses somewhere.... crazy_o.gif

Share this post


Link to post
Share on other sites

very sorry about that...I had a feeling when I was writing it that you would have to have some extra parentheses.....

ok..it should be...

_xh= (getpos heli select 0)

_yh= (getpos heli select 1)

_zh= (getpos heli select 2)

_dh= (getdir heli)

sorry about that...it works for me! also try setting the loop at a smaller delay....

It's not a great system to make them follow the heli by setpos because it uses a lot of CPU power. I'm sure TJ can give ya a better way. The BAS system with their heli probably takes up less cpu....especially if its just a simple invisible roadway thats just setpos around it...not sure how they did it...if so then there would only be one thing to setpos...

sorry about the mix up there! it should work now

biggrin_o.gif

Share this post


Link to post
Share on other sites

p.s. I didn't mean it was a simple way that BAS did their walk in the heli system....

I know it had to take a long time to come up with, since everyone kept trying and trying to get it to do that and they were the first ones to get it right....that and they put a lot of hard work in their addons and all their scripting that they release! smile_o.gif GOOO BAS!! I'm really waiting for the new release!! smile_o.gif

p.p.s. I would def love to know how they did it myself!! ... I posibly could come up with a couple of addons myself utilizing the system biggrin_o.gif

Share this post


Link to post
Share on other sites

Walk in the heli system? Explain to me please, I never ever ever download any addons of any nature. Unless they're official.

You can actually walk inside the heli before getting in cargo?

Perhaps provide a link (download) and maybe with pictures if possible?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×