Debian Codegraph @

engine/include/trigger.h

raw
1 // ____ _ __
2 // / __ )____ _____ | | / /___ ___________
3 // / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
4 // / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
5 // /_____/\____/____/ |__/|__/\__,_/_/ /____/
6 //
7 // A futuristic real-time strategy game.
8 // This file is part of Bos Wars.
9 //
10 /**@name trigger.h - The game trigger headerfile. */
11 //
12 // (c) Copyright 2002-2007 by Lutz Sammer and Jimmy Salmon
13 //
14 // This program is free software; you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation; only version 2 of the License.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 // 02111-1307, USA.
27
28 #ifndef __TRIGGER_H__
29 #define __TRIGGER_H__
30
31 //@{
32
33 /*----------------------------------------------------------------------------
34 -- Declarations
35 ----------------------------------------------------------------------------*/
36
37 class CUnit;
38 class CUnitType;
39 struct lua_State;
40 class CFile;
41
42 /**
43 ** Timer structure
44 */
45 class CTimer {
46 public:
47 CTimer() : Init(false), Running(false), Increasing(false), Cycles(0),
48 LastUpdate(0) {}
49
50 void Reset() {
51 Init = false;
52 Running = false;
53 Increasing = false;
54 Cycles = 0;
55 LastUpdate = 0;
56 }
57
58 bool Init; /// timer is initialized
59 bool Running; /// timer is running
60 bool Increasing; /// increasing or decreasing
61 long Cycles; /// current value in game cycles
62 unsigned long LastUpdate; /// GameCycle of last update
63 };
64
65 #define ANY_UNIT ((const CUnitType *)0)
66 #define ALL_UNITS ((const CUnitType *)-1)
67 #define ALL_FOODUNITS ((const CUnitType *)-2)
68 #define ALL_BUILDINGS ((const CUnitType *)-3)
69
70
71 /**
72 ** Data to referer game info when game running.
73 */
74 typedef struct {
75 CUnit *Attacker; /// Unit which send the missile.
76 CUnit *Defender; /// Unit which is hit by missile.
77 CUnit *Active; /// Unit which is selected or else under cursor unit.
78 } TriggerDataType;
79
80 /*----------------------------------------------------------------------------
81 -- Variables
82 ----------------------------------------------------------------------------*/
83
84 extern CTimer GameTimer; /// the game timer
85
86 /// Some data accessible for script during the game.
87 extern TriggerDataType TriggerData;
88
89
90 /*----------------------------------------------------------------------------
91 -- Functions
92 ----------------------------------------------------------------------------*/
93
94 extern int TriggerGetPlayer(lua_State *l);/// get player number.
95 extern const CUnitType *TriggerGetUnitType(lua_State *l); /// get the unit-type
96 extern bool TriggerMatchUnitType(const CUnit *unit, const CUnitType *triggerUnitType);
97 extern void TriggersEachCycle(void); /// test triggers
98
99 extern void TriggerCclRegister(void); /// Register ccl features
100 extern void SaveTriggers(CFile *file); /// Save the trigger module
101 extern void InitTriggers(void); /// Setup triggers
102 extern void CleanTriggers(void); /// Cleanup the trigger module
103
104 //@}
105
106 #endif // !__TRIGGER_H__