Jump to content
Sign in to follow this  
gnurf

Battle / gunfire detection?

Recommended Posts

Im trying to find a way to detect if a civilian unit considers it self to be underfire. (Is there a value that can be tested???)

If there is no value that can be tested then how does the AI determine that a civilian unit should go prone due to gunfire? Does it detect the weapon being fired or the bullet being to close or what?

Share this post


Link to post
Share on other sites

I think it would use the nearestobject command to check if the bullets are near the unit. You could write a function that would check to see if there are any bullets near the man. Or you could just see what combat mode he is in, if he goes prone then you will know he is under fire (though this may not work all the time, or there may be no shots near him)

RED

Share this post


Link to post
Share on other sites
Quote[/b] ]Or you could just see what combat mode he is in

Nope combatMode for civilians is allways "YELLOW" (never fire). I guess this can be set by a script/trigger but it does not automaticaly change becouse the unit is under fire. (Atleast not when i tested it)

The same goes for behaviour which is allways "AWARE".

About creating a function well... The script is setup to run very slowly and handles a rather big amount of civilian groups. So the chances of a unit being close to a bullet when the function is called is extremly low. Unless ofcourse there is a prolonged firefight with continious fire (i have yet to see that in flashpoint smile_o.gif  )

Unless someone has another idea or knows what im doing wrong when testing behaviour/combatMode, i guess i´ll have to write a function for this.

Share this post


Link to post
Share on other sites

You could use the fired eventhandler to call a function which will check to see if the bullets are near the civi (this won't work if the civi is far away from the shooter)

Remember that functions stop the game until they have stopped running.

RED

Share this post


Link to post
Share on other sites

Yeah i know functions pause the game untill they finish (learnt that the hard way biggrin_o.gif ). Thats why i don´t consider it a good idea to call a function here. That would force the function to run god knows how many times per second in an intense firefight. And if it needs to check every civi for distance to nearest bullet that would really slow the game down...i think.

The script im working on currently works with one civi at a time. Thats why i'm considering making a function that uses the nearestobject command (as suggested). Ofcouse that would mean only having to check for the pressence of a bullet against the current civi and not all of them for every fired event. Ofcourse the downside of this is that while being busy working with another civilian you can shoot a PK right in front of the civilians face and the function would never detect it.

I have considerd the idea of testing if a unit has gone prone to determin if he is being attacked, but a unit shot in the legs is allways prone (or am i misstaken?) and the poor guy would allways keep runing... crawling for his life.

Share this post


Link to post
Share on other sites

Final problem, where can i find a list of the names for projectiles that is fired from smallarms like m16's and ak74´s in resistance and the original release? There must be one out there but i can´t find it...  sad_o.gif

Is it even possible to use nearestObject with smallarm projectiles?!? (beginning to have doubts)

Should anyone be intressted this is the function mentioned previously.

It takes any position as argument and returns a Boolean.

True if any known type of object/projectile is detected and false if not.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_objects","_position","_i","_loops","_return","_tmp"];

_objects = ["zuni","heat105","shell105","gun120","heat120","shell120","gun120","heat125","shell125","gun125","heat73","shell73","gun73","grenadeHand","grenade"];

_position = _this select 0;

_i = 0;

_loops = count _objects;

_return = false;

while "(( _loops > _i ) and !(_return))" do

{

    _tmp = nearestobject [_position, (_objects select _i)];

    IF ( _tmp == _tmp ) then

    {

         _return = true;

    };

    _i = _i + 1;

};

_return

I still say this is a bad way to detect if a civilian unit is under fire, if you got any suggestions, PLEASE!...

Share this post


Link to post
Share on other sites

Done some testing by using the ammo string that is returned by the "fire" event handler to see if what ever is fired can be tested as an object with the nearestobject command.

Of all handguns i tested that fired bullets, none fired ammunition that was considerd an object.

All tank shells and missile types however are considerd objects, basiclly anything that has a model.

Conclusion: trying to detect bullets to see if there is a fire fight don´t work at all.

the end

Share this post


Link to post
Share on other sites
Quote[/b] ]fleeing unit

Operand types:

   unit: Object

Type of returned value:

   Boolean

Description:

   Check if unit is fleeing. Dead or empty unit returns false.

Example:

   fleeing eastReconGroup

Maybe this will work for ya. smile_o.gif

Doolittle

Share this post


Link to post
Share on other sites

Ok did some testing with that and that don´t work for civilians either. For a civilian to start fleeing i had to execute all his fellow squad members and also push him out of his starting position. Once he started fleeing, he ran straight back to his original starting position where he again imidietly returned false when fleeing was tested.

Its ok that the civis runs to their starting point, they can allways be redirected but i don't want to have to kill allmost all of them for them to realise that they are in harms way.

This (civilians == cattle) should allways return true...

biggrin_o.gif

Share this post


Link to post
Share on other sites

What about this....send them to a Sentry waypoint.  Then have the next waypoint be somewhere away from where you think the enemy comes from.  This way as soon as they "see" anything...they will move to the next waypoint. But this doesn't mean they run only when shot at...they just run whenever.

Also I believe a unit's rank determins when they run away or not.

Anyways, good luck...maybe what you want to do is impossible.

Try using unarmed soldiers. Maybe they behave differently. If they see an enemy and they can't fire on them then they run??

Doolittle

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  

×