Author Topic: knowsAbout position?  (Read 670 times)

0 Members and 1 Guest are viewing this topic.

Offline Engima

  • Members
  • *
knowsAbout position?
« on: 08 Oct 2010, 13:33:42 »
Hi everyone! I'm new in this ArmA world, (I switched from Silent Hunter since the total failure of Silent Hunter 5). Anyway, I'm trying to learn about scripting, and I currently have a question about the knowsAbout function.

I've figured out that the knowsAbout value is between 0 and 4, and that if an enemy unit knows enough about me it has also put me on a position (if I run away from that position and it doesn't se me, the last position I was seen in is still the position the enemy unit knows about). Now, am I right about this, and is there any way for me to somehow get that position?

The thing is that I want another unit redirected to that spot, but right now I'm just able to redirect it to "position player" which is a little too accurate...

Offline Wolfrug

  • Addons Depot
  • Administrator
  • *****
  • Official OFPEC Old Timer
Re: knowsAbout position?
« Reply #1 on: 08 Oct 2010, 14:26:54 »
Hello there Engima, and welcome to the wonderful world of Arma Editing!

You're quite correct as to how knowsAbout works, but I don't really see the problem? Let's say unit1 knowsabout the player, and sends unit2 to the player's location: as long as these two events are simultaneous (unit1 spots player, collects player's position, and then orders unit2 to move there), there's nothing stopping the player from moving on from that position and out of unit2's way. To wit:

Code: [Select]
waitUntil {unit1 knowsabout Player > 2};
_pos = position Player;
unit2 doMove _pos;

unit2 will now simply move to the "last known" location of Player, rather than the player's current location. You could in fact do away with the _pos altogether, but I added it to make it clearer how the engine handles this: "position Player" is simply an array of numbers, and once that array of numbers has been given to a unit via doMove, it's not going to change unless you issue a new doMove (e.g. in game, if you give the order "move to that car", and then you drive away with the car, the AI will not start following the car around, but go to where the car was at the time the order was given).

However, there is also one other, more modern command you could use instead of knowsabout: nearTargets. This will give a list of all known targets around a unit, including a -perceived- location, which is actually even better than the above. This is the location the AI -thinks- the enemy is at. You've probably experienced this when for instance your squad leader gives you an order to engage an enemy, but the red little square isn't actually pointing at any enemies: it's pointing at where the SL -thinks- the enemy is.

Using this command is considerably harder though, so the question is: what are you trying to do, and will the above solution be enough?

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline ZapBrannigan

  • Members
  • *
Re: knowsAbout position?
« Reply #2 on: 08 Oct 2010, 15:45:50 »
I Have used a trigger to do pretty effectively what you are trying to do.    make a trigger, and group it to the player, set activation to  detected by opfor(blufor)  and on activation   unit domove getpos player     set the trigger to be activated repeatedly. it seems to work really well to do what you are trying to do.    you also could add a condition to stop the trigger from firing if you want, or another trigger to make the unit search for the player when he arrives at his suspected location.

good luck!