____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <setjmp.h>
#include "stratagus.h"
#include "script.h"
#include "unittype.h"
#include "unit_cache.h"
#include "player.h"
#include "trigger.h"
#include "results.h"
#include "interface.h"
#include "unit.h"
#include "iolib.h"
Go to the source code of this file.
Typedefs | |
| typedef int(* | CompareFunction )(int, int) |
Functions | |
| int | TriggerGetPlayer (lua_State *l) |
| get player number. | |
| const CUnitType * | TriggerGetUnitType (lua_State *l) |
| get the unit-type | |
| 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) |
| 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 (void) |
| test triggers | |
| void | TriggerCclRegister (void) |
| Register ccl features. | |
| void | SaveTriggers (CFile *file) |
| Save the trigger module. | |
| void | InitTriggers (void) |
| Setup triggers. | |
| void | CleanTriggers (void) |
| Cleanup the trigger module. | |
Variables | |
| CTimer | GameTimer |
| The game timer. | |
| static int | Trigger |
| static bool * | ActiveTriggers |
| TriggerDataType | TriggerData |
| Some data accessible for script during the game. | |
Definition in file trigger.cpp.
| typedef int(* CompareFunction)(int, int) |
Definition at line 152 of file trigger.cpp.
| void ActionDefeat | ( | ) |
Action condition player lose.
Definition at line 495 of file trigger.cpp.
References GameDefeat, and StopGame().
Referenced by tolua_stratagus_ActionDefeat00().
| void ActionDraw | ( | ) |
Action condition player draw.
Definition at line 503 of file trigger.cpp.
References GameDraw, and StopGame().
Referenced by tolua_stratagus_ActionDraw00().
| void ActionSetTimer | ( | int | cycles, | |
| bool | increasing | |||
| ) |
Action set timer
Definition at line 511 of file trigger.cpp.
References CTimer::Cycles, GameCycle, CTimer::Increasing, CTimer::Init, and CTimer::LastUpdate.
Referenced by tolua_stratagus_ActionSetTimer00().
| void ActionStartTimer | ( | ) |
Action start timer
Definition at line 522 of file trigger.cpp.
References CTimer::Init, and CTimer::Running.
Referenced by tolua_stratagus_ActionStartTimer00().
| void ActionStopTimer | ( | ) |
Action stop timer
Definition at line 531 of file trigger.cpp.
References CTimer::Running.
Referenced by tolua_stratagus_ActionStopTimer00().
| void ActionVictory | ( | ) |
Action condition player wins.
Definition at line 487 of file trigger.cpp.
References GameVictory, and StopGame().
Referenced by tolua_stratagus_ActionVictory00().
| static int CclAddTrigger | ( | lua_State * | l | ) | [static] |
Add a trigger.
Definition at line 539 of file trigger.cpp.
References ActiveTriggers, LuaCheckArgs, and LuaError.
Referenced by TriggerCclRegister().
| static int CclGetNumUnitsAt | ( | lua_State * | l | ) | [static] |
Return the number of units of a giver unit-type and player at a location.
Definition at line 188 of file trigger.cpp.
References ALL_BUILDINGS, ALL_FOODUNITS, ANY_UNIT, CUnitType::Building, CUnit::Constructed, CPlayer::Index, LuaCheckArgs, LuaError, LuaToNumber(), CUnit::Player, CUnitCache::Select(), TriggerGetUnitType(), CUnit::Type, UnitCache, and UnitMax.
Referenced by TriggerCclRegister().
| static int CclIfNearUnit | ( | lua_State * | l | ) | [static] |
Player has the quantity of unit-type near to unit-type.
Definition at line 259 of file trigger.cpp.
References _C_, ALL_BUILDINGS, ALL_FOODUNITS, ANY_UNIT, CUnitType::Building, CclGetUnitType(), FindUnitsByType(), GetCompareFunction(), CPlayer::Index, LuaCheckArgs, LuaError, LuaToNumber(), LuaToString(), CUnit::Player, CUnitCache::Select(), CUnitType::TileHeight, CUnitType::TileWidth, TriggerGetPlayer(), TriggerGetUnitType(), CUnit::Type, UnitCache, UnitMax, CUnitType::UnitType, UnitTypeLand, CUnit::X, and CUnit::Y.
Referenced by TriggerCclRegister().
| static int CclIfRescuedNearUnit | ( | lua_State * | l | ) | [static] |
Player has the quantity of rescued unit-type near to unit-type.
Definition at line 350 of file trigger.cpp.
References _C_, ALL_BUILDINGS, ALL_FOODUNITS, ANY_UNIT, CUnitType::Building, CclGetUnitType(), FindUnitsByType(), GetCompareFunction(), CPlayer::Index, LuaCheckArgs, LuaError, LuaToNumber(), LuaToString(), CUnit::Player, CUnit::RescuedFrom, CUnitCache::Select(), CUnitType::TileHeight, CUnitType::TileWidth, TriggerGetPlayer(), TriggerGetUnitType(), CUnit::Type, UnitCache, UnitMax, CUnitType::UnitType, UnitTypeLand, CUnit::X, and CUnit::Y.
Referenced by TriggerCclRegister().
| static int CclSetActiveTriggers | ( | lua_State * | l | ) | [static] |
Set the active triggers
Definition at line 596 of file trigger.cpp.
References ActiveTriggers, and LuaToBoolean().
Referenced by TriggerCclRegister().
| void CleanTriggers | ( | void | ) |
Cleanup the trigger module.
Clean up the trigger module.
Definition at line 778 of file trigger.cpp.
References ActiveTriggers, Lua, CTimer::Reset(), and Trigger.
Referenced by CleanGame(), and CleanModules().
| static int CompareEq | ( | int | a, | |
| int | b | |||
| ) | [static] |
| static int CompareGr | ( | int | a, | |
| int | b | |||
| ) | [static] |
| static int CompareGrEq | ( | int | a, | |
| int | b | |||
| ) | [static] |
| static int CompareLe | ( | int | a, | |
| int | b | |||
| ) | [static] |
| static int CompareLeEq | ( | int | a, | |
| int | b | |||
| ) | [static] |
| static int CompareNEq | ( | int | a, | |
| int | b | |||
| ) | [static] |
| static CompareFunction GetCompareFunction | ( | const char * | op | ) | [static] |
Returns a function pointer to the comparison function
| op | The operation |
Definition at line 161 of file trigger.cpp.
References CompareEq(), CompareGr(), CompareGrEq(), CompareLe(), CompareLeEq(), and CompareNEq().
Referenced by CclIfNearUnit(), and CclIfRescuedNearUnit().
| int GetNumOpponents | ( | int | player | ) |
Returns the number of opponents of a given player.
Definition at line 443 of file trigger.cpp.
References PlayerMax, and Players.
Referenced by tolua_stratagus_GetNumOpponents00().
| int GetTimer | ( | ) |
Check the timer value
Definition at line 462 of file trigger.cpp.
References CTimer::Cycles, and CTimer::Init.
Referenced by tolua_stratagus_GetTimer00().
| void InitTriggers | ( | void | ) |
Setup triggers.
Initialize the trigger module.
Definition at line 758 of file trigger.cpp.
References Lua, and LuaCall().
Referenced by CreateGame(), and InitModules().
| void SaveTriggers | ( | CFile * | file | ) |
Save the trigger module.
Save the trigger module.
| file | Open file to print to |
Definition at line 720 of file trigger.cpp.
References CTimer::Cycles, CTimer::Increasing, CTimer::Init, Lua, CFile::printf(), CTimer::Running, and Trigger.
Referenced by SaveGame().
| void SetTrigger | ( | int | trigger | ) |
Set the trigger values
Definition at line 588 of file trigger.cpp.
References Trigger.
Referenced by tolua_stratagus_SetTrigger00().
| void StopGame | ( | GameResults | result | ) |
Stop the running game with a given result
Definition at line 477 of file trigger.cpp.
References GamePaused, GameResult, and GameRunning.
Referenced by ActionDefeat(), ActionDraw(), ActionVictory(), and tolua_stratagus_StopGame00().
| void TriggerCclRegister | ( | void | ) |
Register ccl features.
Register CCL features for triggers.
Definition at line 705 of file trigger.cpp.
References CclAddTrigger(), CclGetNumUnitsAt(), CclIfNearUnit(), CclIfRescuedNearUnit(), CclSetActiveTriggers(), and Lua.
Referenced by InitCcl().
| static int TriggerExecuteAction | ( | int | script | ) | [static] |
Execute a trigger action
| script | Script to execute |
Definition at line 616 of file trigger.cpp.
References Lua, and LuaCall().
Referenced by TriggersEachCycle().
| int TriggerGetPlayer | ( | lua_State * | l | ) |
get player number.
Get player number.
| l | Lua state. |
Definition at line 75 of file trigger.cpp.
References _C_, CPlayer::Index, LuaError, LuaToNumber(), LuaToString(), PlayerMax, and ThisPlayer.
Referenced by CclCreateUnit(), CclGetUnits(), CclIfNearUnit(), CclIfRescuedNearUnit(), CclKillUnit(), CclKillUnitAt(), and CclOrderUnit().
| const CUnitType* TriggerGetUnitType | ( | lua_State * | l | ) |
get the unit-type
Get the unit-type.
| l | Lua state. |
Definition at line 105 of file trigger.cpp.
References ALL_BUILDINGS, ALL_FOODUNITS, ALL_UNITS, ANY_UNIT, CclGetUnitType(), and LuaToString().
Referenced by CclGetNumUnitsAt(), CclIfNearUnit(), CclIfRescuedNearUnit(), CclKillUnit(), CclKillUnitAt(), and CclOrderUnit().
| static void TriggerRemoveTrigger | ( | int | trig | ) | [static] |
Remove a trigger
| trig | Current trigger |
Definition at line 648 of file trigger.cpp.
References Lua.
Referenced by TriggersEachCycle().
| void TriggersEachCycle | ( | void | ) |
test triggers
Check trigger each game cycle.
Definition at line 659 of file trigger.cpp.
References GamePaused, Lua, LuaCall(), Trigger, TriggerExecuteAction(), and TriggerRemoveTrigger().
Referenced by GameMainLoop().
bool* ActiveTriggers [static] |
Definition at line 58 of file trigger.cpp.
Referenced by CclAddTrigger(), CclSetActiveTriggers(), and CleanTriggers().
The game timer.
the game timer
Definition at line 56 of file trigger.cpp.
Referenced by DrawTimer(), and UpdateTimer().
int Trigger [static] |
Definition at line 57 of file trigger.cpp.
Referenced by CleanTriggers(), SaveTriggers(), SetTrigger(), and TriggersEachCycle().
1.5.6