gnurf 0 Posted November 12, 2003 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
RED 0 Posted November 12, 2003 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
gnurf 0 Posted November 12, 2003 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  ) 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
RED 0 Posted November 12, 2003 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
gnurf 0 Posted November 12, 2003 Yeah i know functions pause the game untill they finish (learnt that the hard way ). 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
gnurf 0 Posted November 13, 2003 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...  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
gnurf 0 Posted November 14, 2003 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
Doolittle 0 Posted November 14, 2003 Quote[/b] ]fleeing unitOperand 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. Doolittle Share this post Link to post Share on other sites
gnurf 0 Posted November 14, 2003 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... Share this post Link to post Share on other sites
Doolittle 0 Posted November 15, 2003 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