CountEvent
From OPU Wiki
CountEvent is a counting event simular to CountTrigger.
Inherited from OP2Event
[edit]
Description
It counts the number of Units and fires when the count is lower, higher or equal to what's been set. It's called in the same manner as CountTrigger would be called, so changing existing CountTriggers to CountEvents should not create any problems.
CountEvent uses the same comparison constants as the Trigger system does, as defined in Enums.h:
- cmpEqual
- cmpLowerEqual
- cmpGreaterEqual
- cmpLower
- cmpGreater
[edit]
Constructors
Do NOT call the constructors directly, use the CreateCountEvent function instead:
| CountEvent *CreateCountEvent(bool enable,bool norepeat,int playerNum,map_id unitType,map_id weaponType,int refCount,compare_mode compareType,_callbackfunc callback,int id=0); |
An id can be supplied. This can be an integer or any other variable type:
void EventFired(OP2Event *event)
{
// Your code goes here
}
CountEvent *event1=CreateCountEvent(1,1,0,map_Lynx,map_Any,3,cmpEqual,EventFired);
event1 will fire, the moment Player 1 has 3 Lynx with whatever kind of weapontype.
[edit]
Members
| type | name | description |
| int | GetCount( ) | returns the number of units that was counted, the last time the EventFunction was called. Even if the event does not fire (yet), this count represents the current number of units of the type & weaponCargo the event is looking for |
