Outpost2 Triggers

Trigger processing is done by at routine at address 00403230.
The call to the exported trigger function from the DLL is made at address 00403294.

The game processes a linked list of triggers. The address of the first trigger can be found at [004E9E9C].

TYPE1:
Format of class
---------------
Size: 0x50

Offset 	Size 	Description
------ 	---- 	-----------
0x0	4	class vtbl pointer (004D5E08)
0x4	4	ScStub::ID
0x8	4	contains: 0x02
0xC	4	points to next (associated) Trigger descendent
0x10	4	points to previous Trigger
0x14	4	points to next Trigger of same TYPE
0x18	4	points to previous Trigger of same TYPE
0x1C	4	contains: 0x01
0x20	4	pointer to callbackFunction string (at offset 0x30)
0x24	4	callbackAddress - Address of DLL function for trigger
0x28	4	pointer to next Trigger of same class
0x2C	4	pointer to previous Trigger of same class
0x30	0x20	callbackFunction (null-terminated string)


ExportedFunction vtbl
---------------------
9 Entries.
Note: Some addresses at matching offsets are shared by the Trigger class. This would suggest they are part of the same class hierarchy.

Offset 	Address 	Description
------ 	------- 	-----------
0x0 	00475870 	
0x4 	00475860 	
0x8 	004756D0 	
0xC 	00424A30 	Enable
0x10 	00424A40 	Disable
0x14 	004756E0 	
0x18 	00475750 	
0x1C 	00424A50 	?Destroy?
0x20 	0047B620 	

===============================================================

TYPE2:
Format of Trigger classes (including _Trigger)
----------------------------------------------
Size: undetermined

Offset 	Size 	Description
------ 	---- 	-----------
0x0	4	vtbl pointer
0x4	4	ScStub::ID
0x8	4	boolEnabled (0 or 1)
0xC	4	points to next Trigger
0x10	4	points to previous Trigger
0x14	4	points to next Trigger of same TYPE
0x18	4	points to previous Trigger of same TYPE
0x1C	4	boolNoRepeat (0 or 1)
0x20	4	contains: 0x3E - ?HasFired (for Victory/Failure)?
0x24	4	points to associated _Trigger (0 for Victory/Failure)
0x28	4	pointer to next Trigger of same class
0x2C	4	pointer to previous Trigger of same class
0x30	?	see list below

---------------------------------------------------------------

TimeTrigger (Size: 0x38) - vtable= 004D6560
0x30	4	time1 (if using 2 times, the random time value is inserted in both time1 and time2)
0x34	4	time2 (contains same value as time1)

ResourceTrigger (Size: 0x40) - vtable= 004D6590
0x30	4	resourceType
0x34	4	refAmount
0x38	4	playerNum
0x3C	4	compare_mode

ResearchTrigger (Size: 0x38) - vtable= 004D65C0
0x30 	4	TechID
0x34 	4	playerNum

OnePlayerLefttrigger (Size: 0x30) - vtable= 004D65F0

RectTrigger (Size: 0x44) - vtable= 004D6620
0x30	4	x*32
0x34	4	y*32
0x38	4	width*32
0x3C	4	height*32
0x40	4	2^playerNum

PointTrigger (Size: 0x3C) - vtable= 004D6650
0x30	4	x*32
0x34	4	y*32
0x38	4	2^playerNum

SetTrigger (Size: 0x58) - vtable= 004D6680
0x30	4	totalTriggers
0x34	4	neededTriggers
0x38	4	trigger1
0x3C	4	trigger2
0x40	4	trigger3
0x44	4	trigger4
0x48	4	trigger5
0x4C	4	trigger6
0x50	4	trigger7
0x54	4	trigger8

AttackedTrigger (Size: 0x34) - vtable= 004D66B0
0x30	4	group ID

DamagedTrigger (Size: 0x38) - vtable= 004D66E0
0x30	4	group ID
0x34	4	damage

EscapeTrigger (Size: 0x54) - vtable= 004D6710
0x30	4	x*32
0x34	4	y*32
0x38	4	width*32
0x3C	4	height*32
0x40	4	refValue
0x44	4	unitType
0x48	4	cargoType
0x4C	4	cargoAmount
0x50	4	2^playerNum

CountTrigger (Size: 0x44) - vtable= 004D6740
0x30	4	Type of unit to count (map_id)
0x34	4	WeaponCargo of unit to count
0x38	4	refCount
0x3C	4	playerNum
0x40	4	compare_mode

KitTrigger (Size: 0x3C) - vtable= 004D6770
0x30	4	unitType
0x34	4	refCount
0x38	4	playerNum

EvacTrigger (Size: 0x34) - vtable= 004D67A0
0x30	4	refValue

MidasTrigger (Size: 0x38) - vtable= 004D67D0
0x30	4	time1
0x34	4	time2 (same value as time1)

BuildingCountTrigger (Size: 0x3C) - vtable= 004D6800
0x30	4	refCount
0x34	4	playerNum
0x38	4	compare_mode

VehicleCountTrigger (Size: 0x3C) - vtable= 004D6830
0x30	4	refCount
0x34	4	playerNum
0x38	4	compare_mode

SpecialTargetTrigger (Size: 0x3C) - vtable= 004D6860
0x30	4	unit ID
0x34	4	-1 ?
0x38	4	targetType

OperationalTrigger (Size: 0x40) - vtable= 004D6890
0x30	4	unitType
0x34	4	refValue
0x38	4	playerNum
0x3C	4	compare_mode

VictoryCondition (Size: 0x38) - vtable= 004D68C0
0x30	4	pointer to objective text
0x34	4	ID of associated Trigger

FailureCondition (Size: 0x38) - vtable= 004D68F0
0x30	4	pointer to objective text (unused)
0x34	4	ID of associated Trigger


===============================================================

Trigger descendents vtbl
------------------------
11 Entries. (Entry size: 0x30 bytes)

Offset 	Address 	Description
------ 	------- 	-----------
0x0 	*
0x4 	*
0x8 	004920A0	
0xC 	00424A30	void Enable()
0x10 	00424A40	void Disable()
0x14 	*
0x18 	*
0x1C 	00491FF0	void Destroy()
0x20 	00491F90
0x24 	*		bool HasFired()
0x28 	00491E70	void* GetCallbackFunctionAddress()

Trigger name		vtable       0x00        0x04        0x08        0x0C        0x10        0x14        0x18        0x1C        0x20        0x24        0x28
------------		------       ----        ----        ----        ----        ----        ----        ----        ----        ----        ----        ----
_Trigger		004D6530     004920B0    00492090    004920A0    00424A30    00424A40    00491E90    00491F10    00491FF0    00491F90    004C14B0    00491E70
TimeTrigger		004D6560     00492100    004920F0    004920A0    00424A30    00424A40    004921B0    00492230    00491FF0    00491F90    00492180    00491E70
ResourceTrigger		004D6590     00492320    00492310    004920A0    00424A30    00424A40    004925C0    00492640    00491FF0    00491F90    004923D0    00491E70
ResearchTrigger		004D65C0     00492730    00492720    004920A0    00424A30    00424A40    00492860    004928E0    00491FF0    00491F90    004927D0    00491E70
OnePlayerLefttrigger	004D65F0     004929D0    004929C0    004920A0    00424A30    00424A40    00491E90    00491F10    00491FF0    00491F90    00492A40    00491E70
RectTrigger		004D6620     00492B20    00492B10    004920A0    00424A30    00424A40    00492C70    00492CF0    00491FF0    00491F90    00492BE0    00491E70
PointTrigger		004D6650     00492DE0    00492DD0    004920A0    00424A30    00424A40    00492F10    00492F90    00491FF0    00491F90    00492E90    00491E70
SetTrigger		004D6680     00493080    00493070    004920A0    00424A30    00424A40    004931C0    00493240    00491FF0    00491F90    00493130    00491E70
AttackedTrigger		004D66B0     00493330    00493320    004920A0    00424A30    00424A40    004933E0    00493460    00491FF0    00491F90    004933B0    00491E70
DamagedTrigger		004D66E0     00493550    00493540    004920A0    00424A30    00424A40    00493620    004936A0    00491FF0    00491F90    004935E0    00491E70
EscapeTrigger		004D6710     00493790    00493780    004920A0    00424A30    00424A40    00493990    00493A10    00491FF0    00491F90    00493870    00491E70
CountTrigger		004D6740     00493B00    00493AF0    004920A0    00424A30    00424A40    00494130    004941B0    00491FF0    00491F90    00493BC0    00491E70
KitTrigger		004D6770     004942A0    00494290    004920A0    00424A30    00424A40    004944C0    00494540    00491FF0    00491F90    00494350    00491E70
EvacTrigger		004D67A0     00494630    00494620    004920A0    00424A30    00424A40    004947E0    00494860    00491FF0    00491F90    004946D0    00491E70
MidasTrigger		004D67D0     00494950    00494940    004920A0    00424A30    00424A40    00494A60    00494AE0    00491FF0    00491F90    004949D0    00491E70
BuildingCountTrigger	004D6800     00494BD0    00494BC0    004920A0    00424A30    00424A40    00494D20    00494DA0    00491FF0    00491F90    00494C80    00491E70
VehicleCountTrigger	004D6830     00494E90    00494E80    004920A0    00424A30    00424A40    00495020    004950A0    00491FF0    00491F90    00494F40    00491E70
SpecialTargetTrigger	004D6860     00495190    00495180    004920A0    00424A30    00424A40    004952A0    00495320    00491FF0    00491F90    00495220    00491E70
OperationalTrigger	004D6890     00495410    00495400    004920A0    00424A30    00424A40    00495690    00495710    00491FF0    00491F90    004954C0    00491E70
VictoryCondition	004D68C0     00495800    004957F0    004920A0    00424A30    00424A40    004958E0    00495960    00491FF0    00491F90    00495890    00491E70
FailureCondition	004D68F0     00495A50    00495A40    004920A0    00424A30    00424A40    00495B30    00495BB0    00491FF0    00491F90    00495AE0    00491E70



===============================================================

Format of ExportedFunction class
--------------------------------
Offset 	Size 	Description
------ 	---- 	-----------
0x0 	4 	vtbl pointer
0x4 	 	
0x8 	 	
0xC 	 	
0x10 	 	
0x14 	 	
0x18 	 	
0x1C 	 	
0x20 	 	Pointer to Trigger name (ASCII)
0x24 	 	Pointer to Trigger function
0x28 	 	
0x2C 	 	
0x30 	 	
0x34 	 	
0x38 	 	
0x3C 	 	


