Jump to content
Sign in to follow this  
mr.peanut

bulletbase + nearestObject = ArmA on its knees

Recommended Posts

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">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:

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

{

  smb_bullet = (position _this nearestObject "BulletBase");

  sleep 0.001;

};

The other is:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">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 OFPEC 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 in question is a resource hog. Is there any way to improve this situation?

pistols.gif

Share this post


Link to post
Share on other sites

I guess that nearestObject is the problem because it is very slow. You would need to find an alternative faster method to reduce the lag.

Share this post


Link to post
Share on other sites

It might be more efficient to add 'fired' event handlers to all units / vehicles on the map. If they fired somewhat in the direction / vicinity of the player, then you could follow or extrapolate the path of the bullet to see if it goes near the player.

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  

×