Jump to content
Sign in to follow this  
nullsystems

sideEnemy and distance

Recommended Posts

Hola

Just having a look at distance and sideEnemy and im having a little trouble.

I understand:

? (side civ1 == sideEnemy ) : hint "Tis an enemy"

However, what im looking for is to do something like this:

player distance (side unit == sideEnemy) < 5

Im looking to get that distance line to work with ANY unit thats enemy, but I cant do that. Any ideas?

Share this post


Link to post
Share on other sites

Partial answer:

Im not at me ARMA rig to test but Ive given you some hint code to verify and tweak:

Arguments can be passed into script and made to be generic local variables. These generic local variables will work with any units that activate the script, within certain parameters.

Trigger: Anybody Detected By West

So in that trigger you should bet the detector and detected. the one who sets off the trigger can become the generic variable

this exec "distance_check.sqs"

in script:

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

hint format ["this value %1", _this]

~1

;check this hint for the "this" array value. use two units with names to test and see where the detected unit and the detecting unit is in the list.

_detector  = _this select x

_detected  = _this select y

;(where x/y is either 0/1 you will have to verify what these values would be because they are referencing the "this" array that is discussed above)

? side (_detected == sideEnemy): hint "enemy detected!"

? player distance _detected < 5:hint "enemy is less than 5 meters away."

Basically, passing variables into a script can make the script work dynamically and you can lose those hardcoded names. It also depends how you want this info to be used in mission and how the argument is passed in. You may not want to use a detected by trigger and you will have to make further adjustments accordingly.

EDIT: I changed my code to use the player variable as in your example. But if you wanted to run this code on AI than the _detector variable will work. Were you getting an error with the code for distance check you were using? Let me know.

EDIT2: distance will only check point to point values between individual objects AFAIK. To get the distance of the entire side of enemy is impossible as your really just needing the distance of closest enemy as the front of the enemy force. You could check the distance to a group by getting the leader groupname value and then checking against that unit. So it all depends on what your trying to do.

PM for additional info/questions.

Share this post


Link to post
Share on other sites
Hola

Just having a look at distance and sideEnemy and im having a little trouble.

I understand:

? (side civ1 == sideEnemy ) : hint "Tis an enemy"

However, what im looking for is to do something like this:

player distance (side unit == sideEnemy) < 5

Im looking to get that distance line to work with ANY unit thats enemy, but I cant do that. Any ideas?

Try this, it may help with what you're trying to achieve. Didn't test it though.

unitarray=player nearobjects 5

?(player countenemy unitarray)>0:hint "Tis an enemy"

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  

×