I was wondering if there was a list somewhere detailing approximately how much memory each event type takes up. I know I would make use of it when planning out the final parts of my events file and when deciding which events to delete!
An event uses 284 bytes + strings. Double-trigger (@AND) events are stored as two separate events. Therefore, any strings in the action part of a double-trigger event are duplicated! Each character in a string = 1 byte. Each string ends with a null terminator: add another byte. Which events use strings?
Triggers:
AlphaCentauriArrival (Race)
BribeUnit (Who, Whom)
CheckFlag (Who)
CityDestroyed (City, Owner)
CityProduction (Builder)
CityTaken (City, Attacker, Defender)
Negotiation (Talker, Listener)
ReceivedTechnology (Receiver)
UnitKilled (Unit, Attacker, Defender)
Actions:
ChangeMoney (Receiver)
CreateUnit (Owner, Unit, HomeCity)
MakeAggression (Who, Whom)
MoveUnit (Owner, Unit)
PlayAVIFile ([FileName.avi])
PlayWaveFile ([FileName.wav])
Text ([Text])*
* Each line (maximum of 10 lines, 255 characters each) is a separate string with a null terminator.
There are quite a few event parameters that would appear to be strings, but are, in fact, converted to flags and form part of the main body (284 bytes) of the event. They could've done the same with a number of those listed above.
Example:
Code:
@IF
CityTaken
city=Wizard's Tower [15 bytes]
attacker=Heroes [7 bytes]
defender=Necromancers [13 bytes]
@THEN
CreateUnit
owner=Heroes [7 bytes]
unit=Bone Golem [11 bytes]
veteran=true
homecity=None [5 bytes]
locations
20,20
endlocations
Text
1234567890 [11 bytes]
1234567890 [11 bytes]
EndText
@ENDIF
Total = 284 (body) + 80 (strings) = 364 bytes
One important question I do have is regarding the DELAY line. I know you must leave spare memory to cope with the delays or they will not trigger. In my events file I currently have 16 events with a 1 turn delay, 1 event with a 2 turn delay and 5 events with an 8 turn delay. Is there a way to calculate how much memory space I need to leave?
See
this thread.
So if I understand this correctly I would have 10x 1 turn delay events running at the same time and I would need 2840 bytes free (10x 284), but if they were staggered throughout the game and didn't overlap I would only need to put 284 bytes aside to cope with them, right?
Also, if I understand this right a delay event with a delay of 8 turns will still only take up 284 bytes as long as it is in effect. I have five of these running together so I just need to reserve 1420 bytes and check there are no other ones that are likely to trigger at the same time. Is this correct?
Yes and yes. See link.
Having looked at Catfish's LotR events I think I have it right. It says there are 4755 bytes remaining heap space to cope with 16 concurrent delayed events. 16 x 284 = 4544 bytes. Good!
You obviously don't have the latest version.
If Brussels taken then Delay 12 turns then check Allied Flag 2 is off. If so then display text and create Heavy Panzers at x/y.
Is it possible to trigger the event, wait twelve turns and then check if the flag is on/off before triggering the event (or not triggering if flag is on)?
Yes. Use two flags. Turn on a second flag at the beginning of the game. Capturing Brussels switches it off 12 turns later. Have another event (JustOnce modifier) check the state of both flags every turn. When both are off, heavy panzers are created. If, after 12 turns, Allied Flag 2 is switched on, no panzers will be created. However, it would be possible for the Germans to obtain the tanks at a later time if Allied Flag 2 is switched off at a later time. If that's a situation you want to avoid, then switch the states of the flags and drop the Continuous modifier from the second. That way the panzers can only appear 12 turns after the fall of Brussels. Clear as mud?
I have a feeling that the DelayPerFlag line may help but having read the MACRO info I am none the wiser.
Not here.
Is it possible to give a random percentage chance of a unit being created as a result of a UNITKILLED trigger?
IE: TRIGGER: French Infantry killed = ACTION: 50% chance of Free French unit being created
Yes, see the link above. There are two methods listed there.