Jump to content
redarmy

Any FPS hit with this particular event handler?

Recommended Posts

Hard to test this in actual gameplay.

 

What im trying to do for all high command AI groups(since no rearm function exists in Arma for other groups or is broken mostly when they try rearm) is to add this line to EACH AI  in order to ensure they have their ammo/mags/rockets/grenades replenish instantly(there may be between 40-60 AI with this in their init,and sporadic to intense combat with most units engaging at same time)

 

this addEventHandler ["Reloaded",{  
 _unit = _this select 0 ;  
 _mag = _this select 3 select 0 ;  
 _unit addMagazine _mag ;  
}] ;  

quoted from a BI dev:

 

 And that the EH code is unscheduled and will drop fps 

Im unfamiliar with scripting language and if i had to guess,what im attemping will only add(heavily) to the work on the CPU during firefights.

 

Would i be correct ? And if so is there a better general solution to keeping or through a trigger to rearm all AI squads with their initial loadouts during a scenario?

 

Im quite frustrated with the limitations here coupled with the fact,an AI AA vic will HAPPILY fire all 4 AA missiles as quick as possible into a transport helo while the 1 would do,and an AT missile specialists will fire his 2nd missile at a f**king MRAP before the 1st one(which was overkill anyway) hits,while theres actual MBTs everywhere.

 

ZEUS give me strength!

Share this post


Link to post
Share on other sites

It will produce fps drops if heavy code is executed there which runtime is some milli seconds. such code should be spawned inside the event handler to avoid fps drops.

But this is not the case here. no need to burden the script scheduler here.

You can just do what you want to without any noticeable drops on fps.

 

Edit: Also how often is one of all AIs reloading in a scenario on a typicall firefight? I guess no more than once a second. Thats nothing what you should worry about.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
3 minutes ago, sarogahtyp said:

It will produce fps drops if heavy code is executed there which runtime is some milli seconds. such code should be spawned inside the event handler to avoid fps drops.

But this is not the case here. no need to burden the script scheduler here.

You can just do what you want to without any noticeable drops on fps.

"when heavy code is executed there" are you referring to any "extra" code on the activation of the event? and so you mean this event handler is "simple enough" for it to be unnoticable .

Think i can understand , just trying to better understand the impact of event handlers,didnt realise there were so many of them or what they really did till i looked at the wiki.

 

So out of curiousity in your opinion,would an event handler the same as mine above cause significant impact if say it was run on "fire" instead of reloaded? and adding an extra bullet instead of a magazine?

Share this post


Link to post
Share on other sites

event handlers are the most effecient way to execute code when something (in this case the reload) happens. Therefore you are good with it.

If one needs to do something when a weapon is fired then he will use that fired event handler and he can do that because its just the best way.

The thing what a scripter has to think about is can I use an EH (then he should do that), are there multiple EHs which would do the job and which of them is the one which gets least likely triggert (to save most performance.)

 

If the right EH is found then the code executed if EH triggers comes in play. There we have to cases:

 

1. some simple code with a few lines which runtime is mostly much lower than  1 ms

 - nothing more is to be done, those code can just be executed as is in the EH.

- that means it will get executed completely and instantly in the executing instance. This is called unscheduled environment

 

2. a heavy code which is doin multiple loop iterations and which runtime is more, much more or just near 1ms.

 - those code if it would be executed in above mentioned unscheduled environment would cause fps drops or even temporarly game freezes (depending on the work to do).

- the reason is that all other stuff waits for the code to get finished ( yeah arma is a mostly single thread/core using program :)

- but what is to do with such code? it has to get spawned to be executed in the scheduled environment.

- what happens there? the script scheduler takes care about the code now.

- the scheduler will execute parts of the code on defined time frames now.

- this results in an undefined execution time of the code (mostly much longer than in unscheduled env.)

- but the advantage is that the code will not cause fps drops anymore.

- Only if too many such scripts overload the script scheduler then fps drops may happen or scripts are not working as intended anymore because ther runtime gets extensivly high.

 

Further details on Scheduler:

https://community.bistudio.com/wiki/Scheduler

 

Getting code fast:

https://community.bistudio.com/wiki/Code_Optimisation

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

As a small side not for those who are interested:

 

On 06/15/2017 I initially created the Scheduler page on BI wiki and many other biki authors pushed it to the current state. The reason was to have a summary of the scheduler which clears up misunderstandings.

To this day (5 years later) this ACE wiki page still exists:

Pure Nonsense

 

Quote

... Avoid the usage of scheduled space as much as possible and stay in unscheduled. This is to provide a smooth experience to the user by guaranteeing code to run when we want it.  ... This also helps avoid various bugs as a result of unguaranteed execution sequences when running multiple scripts. ...

 

To be fair there are other pages on their wiki which describe how to use cba stuff to avoid executing code in scheduled env. which may be okay. But if you read this page alone than thats absolute nonsense!

  • Like 5

Share this post


Link to post
Share on other sites

Thanks alot i appreciate the detailed explanation.  Theres so much to read into here it makes my head spin honestly but the more i crack open an idea the more i need,then the more  i need to fully understand it/troubleshoot it.

 

Arma is an absolute rabbit hole in every sense.

 

Regarding ACE iv always avoided it on suspicion and word of mouth that it bogs things down,but without your explanation and links i wouldnt have truly known details. Your post got me very interested im going to look into the scheduler link. 

 

Thanks alot

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

×