Home   Help Search Login Register  

Author Topic: Getting map positions x, y etc...  (Read 934 times)

0 Members and 2 Guests are viewing this topic.

mr.sert

  • Guest
Getting map positions x, y etc...
« on: 28 Oct 2002, 12:05:44 »
I have seen in some scripts where it appears they require you get the location of where you want something to pop up, or where you want your artillery to hit, or things to re-spawn, etc. How do you get this information? What is the easiest way to do this? Thanks in advance.....

- Mr. Sert

The_Milky_Bar_Kid

  • Guest
Re:Getting map positions x, y etc...
« Reply #1 on: 29 Oct 2002, 00:51:00 »
Well, if you want something to spawn at a specific place, I like to use triggers.  I know it can make the mission turn out a bit messy looking, but I find it's the easiest way.  Say I wanted to move a man to a certain place, in the mission editor I would place a trigger, where I wanted to move the man to, with axisA=0 and axisB=0 (so it's no actually there) and name="man1pos" and place a man with name "man1".  Then in a script (or another trigger) I would do this:

_man1posx = getpos man1pos select 0
_man1posy = getpos man1pos select 1

man1 setpos [_man1posx, _man1posy, 0]

Hope that helps.

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Re:Getting map positions x, y etc...
« Reply #2 on: 29 Oct 2002, 12:15:17 »
Yup. Since Kid already posted an exact example here, i thought i'd give some more general info.

Positions in OpF are normally just taken from an object. That means, that 'something' must be in your map already at the appropriate position. This could be a trigger as kid described, or a gamelogic or a unit (ppl or vehicles).

Positions can also be calculated, but this requires the use of mostly complicated scripts that in turn need some info as their own input. A good example would be an Ari script which calculates the impact point of a placed artillery object in the map, but needs the name of the object. So it depends on the position of the artillery.

Last thing i can think of is to get a position by user input. The new command that shipped with 1.85, "OnSingleMapClick" can give you info where the user clicked on the ingame map.


Generally i'd say that it's far more easier to get a position of an object than to determine which object to take the position from. Most AI scripts just take the position of the player and reveal this to all enemy AI unit so they can hunt down the player. This is an easy way, but can be unrealistic at times. A more realistic way would be to check which AI units have been hit / are dead, get their positions and send patrols to rush to this general area.

My 2 cents.  :)