Home   Help Search Login Register  

Author Topic: detecting east distance relative to player  (Read 2432 times)

0 Members and 1 Guest are viewing this topic.

Offline Supergrunt

  • Members
  • *
detecting east distance relative to player
« on: 28 Jul 2010, 11:15:56 »
i have a mission set up where the player is undercover (he is setcaptive true) now i want the city of baghdad patrolled by enemy's who when to close to the player wil see who he is and attack him (setcaptive false)

now i remember i read somewhere that setcaptive can only be processed once or twice true --> False ---> true - False  but then it wont work anymore  if this is so the mission is canceld but if not ......

then i need to know how to detect when ANY east soldier is closer then 10 meter from the player to update the trigger to setcaptive false (i know the  .. "name" distance "name" <  ...  code  but i cant figure out how to set it up for ANY east soldier not just some of them


Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: detecting east distance relative to player
« Reply #1 on: 28 Jul 2010, 17:21:01 »
I suggest you use a trigger instead for this - will require a slight script, but you can initiate it inside the game no problem. This is how, in a nutshell:

Place trigger, repeatedly, 10x10 circle, activated by: east present.

Give it a name, e.g. "SGR_Spotted" (in the 'name' field, NOT 'text'!)

Activated by: this
On Activation: Player setcaptive FALSE

Then in, for instance, your player's init field, add this tiny little script:
Code: [Select]
nul = [] spawn {while {alive Player} do {SGR_Spotted setpos getpos Player; sleep 0.5}};
This will now, every half second, place the trigger named SGR_Spotted on top of Player (make it the name of the unit instead if you want for testing purposes etc). From there it'll activate normally.

If you want, you can add a couple of seconds to the "min/max/med" TIMEOUT section on the trigger: that will give the player a few moments to get away if wandering within 10 meters of the player.

This is pretty basic, but should work. Note that if the enemy is e.g. behind a wall or hasn't spotted the player, then his cover will still be blown. This can be worked around easily enough, but that all depends on how sophisticated you want the mission to be :)

Good luck!

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

Offline Pirin

  • Members
  • *
Re: detecting east distance relative to player
« Reply #2 on: 28 Jul 2010, 22:47:37 »
One problem with setCaptive is that your guy will be considered Civilian and won't trigger other BLUFOR triggers, if any.

Here's how I answered a similar question on the BIS forums:

In your OPFOR group leaders put this (could probably use allGroups and side check to add it to everyone):

Code: [Select]
{_x disableAI "TARGET"; _x disableAI "AUTOTARGET"; _x setBehaviour "CARELESS"} foreach units group this;
Then in a trigger put this:

Condition:
Code: [Select]
(player findNearestEnemy position player) distance player < 10
OnAct:
Code: [Select]
op = (player findNearestEnemy position player);{_x enableAI "TARGET"; _x enableAI "AUTOTARGET"; _x setBehaviour "COMBAT"} forEach units group op;
You'll be able to walk around and be ignored till you get within 10m of a target, at which point their group will give you the whatfor.   :good:

Offline Supergrunt

  • Members
  • *
Re: detecting east distance relative to player
« Reply #3 on: 28 Jul 2010, 23:28:48 »
i will defintly try that (matter a fact i will try it right now :P )

one small question on top if it

if i use in condition

 
Code: [Select]
(player findNearestEnemy position player) distance player < 10 OR player hasweapon "...."  
onact :
 
Code: [Select]
op = (player findNearestEnemy position player);{_x enableAI "TARGET"; _x enableAI "AUTOTARGET"; _x setBehaviour "COMBAT"} forEach units group op;
it will set their status when either the player is 10 meters away or when he has a certain weapon or am i wrong ?

if right (or shown the right way) is it also possible to set it when the player carries any kind of weapon ?

« Last Edit: 28 Jul 2010, 23:46:09 by Supergrunt »