EDIT: Found Suma's comment on CPU impact of EH:s See the thread
Multiple scripts run from one event handler. Flip to page two of that thread and some ways down, Suma answers "The Sharpshooter" with:
(The Sharpshooter) "When I add an EventHandler to a unit(in the config.cpp) this means it will run the script the whole mission. Adding multiple units that have eventhandlers attached + all the scripting the mission will have and the units, ect. will make the mission heavyer, wonÂ't it ? I mean much heavyer, or the EventHandlers donÂ't use much CPU ?"(Suma) "It really depends on what event are you talking about. Properly implemented event handlers have nearly zero overhead, because they are executed only when even(sic!) is detected.
If you are talking about permanent script started from "init" event handler (or from any other handler), then yes, there will be exactly the same overhead with this script as with any other script. Be sure to use at least ~0.001 trick to if you need to use permanent scripts."My own testingSetup: OFP 1.96 with ECP 1.072, DR config, edits made to ECP_EventHandlers for testing.
DescriptionI have tried something similar: 150 Cobras on desert island (30 x 5) and me as a West "Officer" unit running around. I fail to see a difference between just having the ECP init EH present and having all of them there. This is using the 1.072 dev version of ECP with the DR config variant. (Binned using cpp2bin)
After 20-30 secs, I am pegged at 2-3 fps no matter if ECP_EventHandlers contain only the init EH or all of them (which doesn't include the
getout handler you had.)
This is using an Athlon XP 1900+, 1 GB PC2100 and an ATI 9600. OFP was loaded with
"-nosplash -nomap -mod=@ecp" and I have my OFP\Addons and OFP\Res\Addons entirely clean of any third-party addons.
View distance was 500 m, terrain detail to "Very low". @ECP\ECP_Settings has one change only:
ECP_override="low". I am amazed at how a 650 Mhz CPU and an old Matrox card can run what you described... or my compy/OFP settings are worse than I have thought ;D
In my experience, adding EH
declarations in configs are generally quite low-impact. Of course, there are zillions of addons out there that then
use the EH system badly, say by executing heavy scripts in the fired EH, which is a high frequency event. Furthermore, its quite common with an init EH starting a heavy monitor script that eats up CPU real quick. From digging through ECP, I suspect that's where the CPU cycles are going. NB: ECP is far from the only addon/mod that does that. In many cases, what they do is work around what is IMHO one of the great showstoppers of OFP:
The killed event is not broadcast. Why that wasn't fixed way back is truely mind-boggling...
ECP_EventHandlers used in testing"Light":
class ECP_EventHandlers
{
init="_this exec {\ECP_Effects\init.sqs}";
};
"Heavy" (Standard ECP 1.072) version:
class ECP_EventHandlers
{
init="_this exec {\ECP_Effects\init.sqs}";
// init="_this exec {\@ECP\Addons\ECP_Effects\init.sqs}";
killed="_this call ECP_EH_handler_killed";
hit="_this call ECP_EH_handler_hit";
fired="_this call ECP_EH_handler_fired";
IncomingMissile="_this call ECP_EH_handler_incomingmissile";
};
Test mission attached below: