Home   Help Search Login Register  

Author Topic: Teleport a group 500m behind the player.  (Read 747 times)

0 Members and 1 Guest are viewing this topic.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Teleport a group 500m behind the player.
« on: 31 Dec 2005, 08:21:26 »
How do I do it?
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Ding

  • Contributing Member
  • **
  • Jurassic Park
Re:Teleport a group 500m behind the player.
« Reply #1 on: 31 Dec 2005, 11:11:48 »
get pos command? or are you thinking of somthing more specific? as i can imagine you have already looked at the getpos command
"If I remain lost and die on a cross, atleast I wasn't born in a manger"

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Teleport a group 500m behind the player.
« Reply #2 on: 31 Dec 2005, 11:28:53 »
To find a point 500m behind the player use:
X coordinate = (getPos player select 0) - 500*sin(getDir Player)
y coordinate = (getPos player select 1) - 500*cos(getDir Player)

You will need to teleport them one at a time, you cannot setPos a group as a whole.

If you want them to keep in formation then I suggest something like:
Code: [Select]
_relPos = []
{_relPos = _relPos + [[(getPos leader group _x select 0)-(getPos _x select 0),(getPos leader group _x select 1)-(getPos _x select 1)]]} forEach units groupname

This will give you an array of relative positions. Then setPos the leader of the group 500m behind the player as above. Then setPos the units of the group using the relative position you calculated earlier.  You might also want to modify the relative posisions so that the formation is facing towards the player.  Happy to help with all of that, but I am not sure what you need exactly.   My guess is that if they are not vehicles then setPossing them all to the same point 500m behind the player would be sufficient as they will quickly sort themselves out.  The code for that is:

Code: [Select]
{_x setPos [(getPos player select 0) - 500*sin(getDir Player),(getPos player select 1) - 500*cos(getDir Player),0]} forEach units groupname
Done from memory and so not tested

« Last Edit: 31 Dec 2005, 16:38:41 by THobson »

Offline Trapper

  • Honoured Contributor
  • ***
  • I'm a llama!
Re:Teleport a group 500m behind the player.
« Reply #3 on: 31 Dec 2005, 13:43:13 »
Wow THobson, I was thinking about forever how this could be solved with trigonometry, and then you show up with these simple looking lines. And they are working. :)

Would you mind if I create a polar coordinate function from this for the library? Looks like this is still missing over there.
It was already done by joltan.

CalcRelPos
http://www.ofpec.com/editors/funcref.php?letter=C#CalcRelPos

In this case the syntax is
_position = [player,180,500,0] call CalcRelPos
Then it returns the [x,y,z] position 500m behind the player.
« Last Edit: 31 Dec 2005, 13:58:03 by Trapper »

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re:Teleport a group 500m behind the player.
« Reply #4 on: 31 Dec 2005, 14:07:31 »
What I'm trying to do is have an allied AI team join the player's group. I want them to approach from behind because then the player won't see them magically pop up. They then move to the player and join.

I don't think it needs to be really complicated.
I'll try your code snippet now.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re:Teleport a group 500m behind the player.
« Reply #5 on: 31 Dec 2005, 14:57:41 »
It works lovely. Cheers fellas.  ;D
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."