$treeview $search $mathjax
Stratagus
2.2.7
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
00001 // _________ __ __ 00002 // / _____// |_____________ _/ |______ ____ __ __ ______ 00003 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ 00004 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | 00005 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > 00006 // \/ \/ \//_____/ \/ 00007 // ______________________ ______________________ 00008 // T H E W A R B E G I N S 00009 // Stratagus - A free fantasy real time strategy game engine 00010 // 00012 // 00013 // (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon 00014 // 00015 // This program is free software; you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation; only version 2 of the License. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 // GNU General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00027 // 02111-1307, USA. 00028 // 00029 00030 #ifndef __ACTIONS_H__ 00031 #define __ACTIONS_H__ 00032 00034 00035 #include "unitptr.h" 00036 #include "vec2i.h" 00037 00038 /*---------------------------------------------------------------------------- 00039 -- Declarations 00040 ----------------------------------------------------------------------------*/ 00041 00049 enum UnitAction { 00050 UnitActionNone, 00051 00052 UnitActionStill, 00053 UnitActionStandGround, 00054 UnitActionFollow, 00055 UnitActionMove, 00056 UnitActionAttack, 00057 UnitActionAttackGround, 00058 UnitActionDie, 00059 00060 UnitActionSpellCast, 00061 00062 UnitActionTrain, 00063 UnitActionUpgradeTo, 00064 UnitActionResearch, 00065 UnitActionBuilt, 00066 00067 // Compound actions 00068 UnitActionBoard, 00069 UnitActionUnload, 00070 UnitActionPatrol, 00071 UnitActionBuild, 00072 00073 UnitActionRepair, 00074 UnitActionResource, 00075 UnitActionTransformInto 00076 }; 00077 00078 class CAnimation; 00079 class CConstructionFrame; 00080 class CFile; 00081 class CUnit; 00082 class CUnitType; 00083 class CUpgrade; 00084 class PathFinderInput; 00085 class SpellType; 00086 class CViewport; 00087 struct lua_State; 00088 00092 class COrder 00093 { 00094 public: 00095 explicit COrder(int action) : Goal(), Action(action), Finished(false) { 00096 } 00097 virtual ~COrder(); 00098 00099 virtual COrder *Clone() const = 0; 00100 virtual void Execute(CUnit &unit) = 0; 00101 virtual void Cancel(CUnit &unit) {} 00102 virtual bool IsValid() const = 0; 00103 00104 virtual PixelPos Show(const CViewport &vp, const PixelPos &lastScreenPos) const = 0; 00105 00106 virtual void OnAnimationAttack(CUnit &unit); 00107 00108 virtual void Save(CFile &file, const CUnit &unit) const = 0; 00109 bool ParseGenericData(lua_State *l, int &j, const char *value); 00110 virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit) = 0; 00111 00112 virtual void UpdateUnitVariables(CUnit &unit) const {} 00113 virtual void FillSeenValues(CUnit &unit) const; 00114 virtual void AiUnitKilled(CUnit &unit); 00115 00116 virtual void UpdatePathFinderData(PathFinderInput &input) = 0; 00117 00118 bool HasGoal() const { return Goal != NULL; } 00119 CUnit *GetGoal() const { return Goal; }; 00120 void SetGoal(CUnit *const new_goal); 00121 void ClearGoal(); 00122 00123 virtual bool OnAiHitUnit(CUnit &unit, CUnit *attacker, int /*damage*/); 00124 00125 static COrder *NewActionAttack(const CUnit &attacker, CUnit &target); 00126 static COrder *NewActionAttack(const CUnit &attacker, const Vec2i &dest); 00127 static COrder *NewActionAttackGround(const CUnit &attacker, const Vec2i &dest); 00128 static COrder *NewActionBoard(CUnit &unit); 00129 static COrder *NewActionBuild(const CUnit &builder, const Vec2i &pos, CUnitType &building); 00130 static COrder *NewActionBuilt(CUnit &builder, CUnit &unit); 00131 static COrder *NewActionDie(); 00132 static COrder *NewActionFollow(CUnit &dest); 00133 static COrder *NewActionMove(const Vec2i &pos); 00134 static COrder *NewActionPatrol(const Vec2i ¤tPos, const Vec2i &dest); 00135 static COrder *NewActionRepair(CUnit &unit, CUnit &target); 00136 static COrder *NewActionRepair(const Vec2i &pos); 00137 static COrder *NewActionResearch(CUnit &unit, CUpgrade &upgrade); 00138 static COrder *NewActionResource(CUnit &harvester, const Vec2i &pos); 00139 static COrder *NewActionResource(CUnit &harvester, CUnit &mine); 00140 static COrder *NewActionReturnGoods(CUnit &harvester, CUnit *depot); 00141 static COrder *NewActionSpellCast(const SpellType &spell, const Vec2i &pos, CUnit *target); 00142 static COrder *NewActionStandGround(); 00143 static COrder *NewActionStill(); 00144 static COrder *NewActionTrain(CUnit &trainer, CUnitType &type); 00145 static COrder *NewActionTransformInto(CUnitType &type); 00146 static COrder *NewActionUnload(const Vec2i &pos, CUnit *what); 00147 static COrder *NewActionUpgradeTo(CUnit &unit, CUnitType &type); 00148 00149 protected: 00150 void UpdatePathFinderData_NotCalled(PathFinderInput &input); 00151 00152 private: 00153 CUnitPtr Goal; 00154 public: 00155 const unsigned char Action; 00156 bool Finished; 00157 }; 00158 00159 typedef COrder *COrderPtr; 00160 00161 00162 /*---------------------------------------------------------------------------- 00163 -- Variables 00164 ----------------------------------------------------------------------------*/ 00165 00166 extern unsigned SyncHash; 00167 00168 /*---------------------------------------------------------------------------- 00169 -- Actions: in action_<name>.c 00170 ----------------------------------------------------------------------------*/ 00171 00172 extern int GetNumWaitingWorkers(const CUnit &mine); 00173 extern bool AutoAttack(CUnit &unit); 00174 extern bool AutoRepair(CUnit &unit); 00175 extern bool AutoCast(CUnit &unit); 00176 extern void UnHideUnit(CUnit &unit); 00177 00179 extern int DoActionMove(CUnit &unit); 00181 extern void AnimateActionAttack(CUnit &unit, COrder &order); 00182 00183 /*---------------------------------------------------------------------------- 00184 -- Actions: actions.c 00185 ----------------------------------------------------------------------------*/ 00186 00188 extern void CclParseOrder(lua_State *l, CUnit &unit, COrderPtr *order); 00189 00191 extern void UnitActions(); 00192 00194 00195 #endif // !__ACTIONS_H__