OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: bedges on 10 Aug 2006, 10:53:32
-
has anyone encountered this problem?
i've set up a trigger covering the map, to capture an array of all the east loons. in the init file i'm adding hit and killed eventhandlers to all of them. there's about 88.
problem is, the eventhandlers are not being added. am i asking too much of the engine? i have a bunch of other scripts activating from the init file, and thinking it was too much for flashpoint to cope with i separated them out in the opening cutscene. same problem - eventhandlers not being added...
:-\
-
It's not the engine. Bet its a typo in the syntax or something.
Make it work with just one loon, then two, then the whole 88.
-
hmmm, well it seems sticking a 1 second pause between the two eventhandler lines in the cutscene, like this -
{_x addeventhandler ["hit",{_this exec "betrayal.sqs"}]} foreach alleast
~1
{_x addeventhandler ["killed",{_this select 0 addaction ["Bury body","gravedigger.sqs"];_this exec "betrayal.sqs"}]} foreach alleast
has solved the problem. i wonder... ???
-
Ah yes, I've heard that before. Sorry, I would have mentioned it but not having touched Flashpoint for so long I've forgotten a lot.
-
As we all know OFP is quite heavy on the PC, and the sqs considered secondary for the game and thus it does not get priority on the CPU side..
When OFP starts to choke on something like a big array scanned and manipulated an item at a time (like in your case) the sqs may get skipped from here and there to get more CPU for the game itself.. Probably even more apparent when a mission initializes as the game has to 'spawn' all the units etc on the map etc..
Not that I know anything, just voicing out my own experiences :P
-
I've never seen an sqs get skipped.
I have seen people try to execute a {} ForEach ThisList before the trigger gets time to populate that list.
So add the eventhandlers a couple seconds after mission start, and it should work better.
-
I believe it was General Barron who did some extensive research about eventhandlers. I think he came to the conclusion that there is no other way than including a couple of ~seconds between the lines.
-
bedges, if by any means possible, (if your scripts have no pauses) replace your scripts started from the event handlers with preprocessed functions. That will give you a performance boost. Also you could stuff the code straight into the event handler so you'd need nothing else but the event handlers.
There are no conditions in the event handlers. Are you sure you need to start the script from the hit EH everytime a unit is hit? Could you put a if () then {} condition into the event handler, to prevent the script from starting every time?
-
Well Bedges, if i understood corectly you capture all loons by a trigger to put them into
an array.
By init file i guess you mean the init.sqs.
If it's like that i got an explanation for you:
Init.sqs will be executed before you capture the loons (somewhere between loading mission and
briefing screen if i remember corectly).
Best you cuold do is to start the eventhandler adding procedere out of the trigger which creates
the array.
Also don't use any unit's init field for that, since each unit will execute it's init-field before the trigger
start doing their job.
Mission.sqm is running sequentially and 'Sensors' are located after 'Units' (or groups).
~S~ CD
-
that explains it. i currently have most of the heavyweight stuff in the cutscene at the beginning of the mission, works fine.
@baddo - i may well do that. at the moment i'm just trying to complete the thing ;)
thanks for the assist gents.
-
Just to confirm, it is not necessary to have delays between the lines that assign Event Handlers. Chris Death is correct - if you are using a trigger to create a list of units that are to have event handlers assigned then that list will not exist until the trigger has fired and that will not happen until a small fraction of a second after the start of the mission. This will be after init.sqs has executed.
On a question of scale: I have not counted but Abandoned Armies must have not far short of 1,000 "killed" Event Handlers that are added to the units a few seconds after the start of the mission with no problem. EDIT: Just checked. There are at least 1,200 killed EHs in the mission
NB: To create a list of units have a look at this:
http://www.ofpec.com/forum/index.php?topic=27814.0