Home   Help Search Login Register  

Author Topic: a mapful of eventhandlers...  (Read 1505 times)

0 Members and 1 Guest are viewing this topic.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
a mapful of eventhandlers...
« 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...

 :-\

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re: a mapful of eventhandlers...
« Reply #1 on: 10 Aug 2006, 11:17:07 »
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.
Plenty of reviewed ArmA missions for you to play

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: a mapful of eventhandlers...
« Reply #2 on: 10 Aug 2006, 11:21:00 »
hmmm, well it seems sticking a 1 second pause between the two eventhandler lines in the cutscene, like this -

Code: [Select]
{_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...  ???

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re: a mapful of eventhandlers...
« Reply #3 on: 10 Aug 2006, 11:59:18 »
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.
Plenty of reviewed ArmA missions for you to play

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: a mapful of eventhandlers...
« Reply #4 on: 11 Aug 2006, 09:27:07 »
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
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re: a mapful of eventhandlers...
« Reply #5 on: 11 Aug 2006, 12:37:52 »
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.
Dinger/Cfit

Offline nominesine

  • Former Staff
  • ****
  • I'm NOT back!
    • The IKB Forum
Re: a mapful of eventhandlers...
« Reply #6 on: 11 Aug 2006, 13:10:28 »
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.
OFPEC | Intel Depot
RETARDED Ooops... Retired!

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re: a mapful of eventhandlers...
« Reply #7 on: 11 Aug 2006, 14:34:17 »
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?

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re: a mapful of eventhandlers...
« Reply #8 on: 11 Aug 2006, 22:18:44 »
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
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: a mapful of eventhandlers...
« Reply #9 on: 11 Aug 2006, 22:27:54 »
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.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: a mapful of eventhandlers...
« Reply #10 on: 13 Aug 2006, 07:20:09 »
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
« Last Edit: 13 Aug 2006, 10:33:08 by THobson »