_________ __ __
/ _____// |_____________ _/ |______ ____ __ __ ______
\_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
/ \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
/_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
\/ \/ \//_____/ \/
______________________ ______________________
T H E W A R B E G I N S
Stratagus - A free fantasy real time strategy game engine
#include "stratagus.h"#include "trigger.h"#include "interface.h"#include "iolib.h"#include "map.h"#include "player.h"#include "results.h"#include "script.h"#include "unit.h"#include "unit_find.h"#include "unittype.h"trigger.cpp - The trigger handling. | |
| typedef int(* | CompareFunction) (int, int) |
| CTimer | GameTimer |
| static int | Trigger |
| The game timer. More... | |
| static bool * | ActiveTriggers |
| TriggerDataType | TriggerData |
| Some data accessible for script during the game. More... | |
| int | TriggerGetPlayer (lua_State *l) |
| const CUnitType * | TriggerGetUnitType (lua_State *l) |
| get player number. More... | |
| static int | CompareEq (int a, int b) |
| static int | CompareNEq (int a, int b) |
| static int | CompareGrEq (int a, int b) |
| static int | CompareGr (int a, int b) |
| static int | CompareLeEq (int a, int b) |
| static int | CompareLe (int a, int b) |
| static CompareFunction | GetCompareFunction (const char *op) |
| static int | CclGetNumUnitsAt (lua_State *l) |
| static int | CclIfNearUnit (lua_State *l) |
| static int | CclIfRescuedNearUnit (lua_State *l) |
| int | GetNumOpponents (int player) |
| int | GetTimer () |
| void | StopGame (GameResults result) |
| Outcome of the game. More... | |
| void | ActionVictory () |
| void | ActionDefeat () |
| void | ActionDraw () |
| void | ActionSetTimer (int cycles, bool increasing) |
| void | ActionStartTimer () |
| void | ActionStopTimer () |
| static int | CclAddTrigger (lua_State *l) |
| void | SetTrigger (int trigger) |
| static int | CclSetActiveTriggers (lua_State *l) |
| static int | TriggerExecuteAction (int script) |
| static void | TriggerRemoveTrigger (int trig) |
| void | TriggersEachCycle () |
| get the unit-type More... | |
| void | TriggerCclRegister () |
| test triggers More... | |
| void | SaveTriggers (CFile &file) |
| Register ccl features. More... | |
| void | InitTriggers () |
| Save the trigger module. More... | |
| void | CleanTriggers () |
| Setup triggers. More... | |
| typedef int(* CompareFunction) (int, int) |
| void ActionDefeat | ( | ) |
Action condition player lose.
| void ActionDraw | ( | ) |
Action condition player draw.
| void ActionSetTimer | ( | int | cycles, |
| bool | increasing | ||
| ) |
Action set timer
| void ActionStartTimer | ( | ) |
Action start timer
| void ActionStopTimer | ( | ) |
Action stop timer
| void ActionVictory | ( | ) |
Action condition player wins.
|
static |
Description
Add a trigger.
Example:
AddTrigger( function() return (GetPlayerData(1,"UnitTypesCount","unit-farm") >= 4) end, function() return ActionVictory() end )
|
static |
Description
Return the number of units of a given unit-type and player at a location.
Example:
– Get the number of knights from player 1 from position 0,0 to 20,15 num_units = GetNumUnitsAt(1,"unit-knight",{0,0},{20,15}) print(num_units)
|
static |
Description
Player has the quantity of unit-type near to unit-type.
Example:
AddTrigger( function() return IfNearUnit(0,">",1,"unit-peasant","unit-town-hall") end, function() AddMessage("Player 0 has more than 1 peasant near the Town Hall") return false end )
|
static |
Description
Player has the quantity of rescued unit-type near to unit-type.
Example:
IfRescuedNearUnit("this", ">=", 1, "unit-archer", "unit-circle-of-power")
|
static |
Set the active triggers
| void CleanTriggers | ( | ) |
Setup triggers.
Clean up the trigger module.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Returns a function pointer to the comparison function
| op | The operation |
| int GetNumOpponents | ( | int | player | ) |
Description
Returns the number of opponents of a given player.
| int GetTimer | ( | ) |
Check the timer value
| void InitTriggers | ( | ) |
Save the trigger module.
Initialize the trigger module.
| void SetTrigger | ( | int | trigger | ) |
Set the trigger values
| void StopGame | ( | GameResults | result | ) |
Outcome of the game.
Stop the running game with a given result
| void TriggerCclRegister | ( | ) |
test triggers
Register CCL features for triggers.
|
static |
Execute a trigger action
| script | Script to execute |
| int TriggerGetPlayer | ( | lua_State * | l | ) |
Get player number.
| l | Lua state. |
| const CUnitType* TriggerGetUnitType | ( | lua_State * | l | ) |
get player number.
Get the unit-type.
| l | Lua state. |
|
static |
Remove a trigger
| trig | Current trigger |
| void TriggersEachCycle | ( | ) |
get the unit-type
Check trigger each game cycle.
|
static |
| CTimer GameTimer |
|
static |
The game timer.
| TriggerDataType TriggerData |
Some data accessible for script during the game.
the game timer
1.8.17
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.