OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Mr.Peanut on 26 May 2008, 00:50:30

Title: bullets and nearestObject bring ArmA to its knees
Post by: Mr.Peanut on 26 May 2008, 00:50:30
Code: [Select]
waitUntil {not isNull (position _this nearestObject "BulletBase")};1) Make the above a one line script
2) execVM the script from a unit's init
3) Approach unit and shoot firearm
4) Watch ArmA hiccup terribly

I can replace the above with two scripts. One is:
Code: [Select]
while {TRUE} do
{
   smb_bullet = (position _this nearestObject "BulletBase");
   sleep 0.001;
};
The other is:
Code: [Select]
waitUntil {not isNull smb_bullet};However, when sleep is set long enough to not cause a hiccup, the bullet is not always detected.
Yes I am trying to catch bullets from the target, not the creation point.  A recent thread about the dammaged event handler got me curious.

Now, for the first example, I know that waitUntil is trying check its condition each engine timeslice, and that the condition is a bit nasty. Is there any way to improve this situation?


Title: Re: bullets and nearestObject bring ArmA to its knees
Post by: Rommel92 on 26 May 2008, 09:08:30
Code: [Select]
If ((count (position _x nearObjects ["BulletBase", (300 / _morale)])) > 0) then
{
_morale = _morale - 0.4;
};

From my latest AI Suppression script, Im pretty sure it is what you were looking for. Heres a cutout for you:

Code: [Select]
VAR = position _this nearObjects ["BulletBase", 30];
VAR2 = count VAR; hint format["%1",VAR2];
sleep (random 2.5);

A sleep of random 2.0 is enough to catch most bullets, up to 75%, so 3/4 bullets are detected, increasing this to perhaps random 0.8 should catch all. (I use random to prevent systematic pauses when playing and running many others scripts in a demanding mission.)

 :good:
Title: Re: bullets and nearestObject bring ArmA to its knees
Post by: Mr.Peanut on 26 May 2008, 15:33:23
But you are simply trying to get a measure of the bullet "volume density", and I am trying to catch individual bullets. You only need an approximate measure of the number amount of bullets flying around your target ever 2 seconds or so to make a morale check. I need a 90-95% reliable catch of every single bullet. Needless-to-say, I would be limiting players to firearms with low firerates.
Title: Re: bullets and nearestObject bring ArmA to its knees
Post by: Rommel92 on 26 May 2008, 15:51:04
I think even for optimisation you will have better luck with a "Fired" eventhandler.
This is mainly due to the fact that if you want 90-95 % of all individual bullets, the delay needed will be so low that you may be better off having these as running across units will be an absolute killer for your PC (among others) to handle.  :good:
Title: Re: bullets and nearestObject bring ArmA to its knees
Post by: Mr.Peanut on 26 May 2008, 18:04:20
It is not important. I was experimenting after reading a thread where someone wanted to use dammaged event handlers to make units only vulnerable to headshots, but could not because in ArmA they do not fire fast enough or before the hit eventhandler.

For SP, I suppose the fired eventhandler could be used for this if the target is at close range.