Spilt actions.h into specific header.

This commit is contained in:
joris 2012-02-27 19:46:19 +01:00
parent 39cf8c1d78
commit 4a958b3c16
42 changed files with 1342 additions and 639 deletions

View file

@ -302,7 +302,74 @@ set(stratagus_SRCS
${CMAKE_CURRENT_BINARY_DIR}/tolua.cpp
)
set(stratagus_HDRS
set(stratagus_guichan_HDRS
src/guichan/include/guichan/actionlistener.h
src/guichan/include/guichan/allegro.h
src/guichan/include/guichan/basiccontainer.h
src/guichan/include/guichan/cliprectangle.h
src/guichan/include/guichan/color.h
src/guichan/include/guichan/defaultfont.h
src/guichan/include/guichan/exception.h
src/guichan/include/guichan/focushandler.h
src/guichan/include/guichan/font.h
src/guichan/include/guichan/graphics.h
src/guichan/include/guichan/gsdl.h
src/guichan/include/guichan/gui.h
src/guichan/include/guichan.h
src/guichan/include/guichan/imagefont.h
src/guichan/include/guichan/image.h
src/guichan/include/guichan/imageloader.h
src/guichan/include/guichan/input.h
src/guichan/include/guichan/key.h
src/guichan/include/guichan/keyinput.h
src/guichan/include/guichan/keylistener.h
src/guichan/include/guichan/listmodel.h
src/guichan/include/guichan/mouseinput.h
src/guichan/include/guichan/mouselistener.h
src/guichan/include/guichan/platform.h
src/guichan/include/guichan/rectangle.h
src/guichan/include/guichan/sdl/sdlgraphics.h
src/guichan/include/guichan/sdl/sdlimageloader.h
src/guichan/include/guichan/sdl/sdlinput.h
src/guichan/include/guichan/sdl/sdlpixel.h
src/guichan/include/guichan/widget.h
src/guichan/include/guichan/widgets/button.h
src/guichan/include/guichan/widgets/container.h
src/guichan/include/guichan/widgets/dropdown.h
src/guichan/include/guichan/widgets/checkbox.h
src/guichan/include/guichan/widgets/icon.h
src/guichan/include/guichan/widgets/label.h
src/guichan/include/guichan/widgets/listbox.h
src/guichan/include/guichan/widgets/radiobutton.h
src/guichan/include/guichan/widgets/scrollarea.h
src/guichan/include/guichan/widgets/slider.h
src/guichan/include/guichan/widgets/textbox.h
src/guichan/include/guichan/widgets/textfield.h
src/guichan/include/guichan/widgets/window.h
src/guichan/include/guichan/x.h
)
set(stratagus_action_HDRS
src/include/action/action_attack.h
src/include/action/action_board.h
src/include/action/action_build.h
src/include/action/action_built.h
src/include/action/action_die.h
src/include/action/action_follow.h
src/include/action/action_move.h
src/include/action/action_patrol.h
src/include/action/action_repair.h
src/include/action/action_research.h
src/include/action/action_resource.h
src/include/action/action_spellcast.h
src/include/action/action_still.h
src/include/action/action_train.h
src/include/action/action_unload.h
src/include/action/action_upgradeto.h
)
set(stratagus_generic_HDRS
src/ai/ai_local.h
src/video/intern_video.h
src/video/renderer.h
@ -362,52 +429,14 @@ set(stratagus_HDRS
src/include/video.h
src/include/wav.h
src/include/widgets.h
src/guichan/include/guichan/actionlistener.h
src/guichan/include/guichan/allegro.h
src/guichan/include/guichan/basiccontainer.h
src/guichan/include/guichan/cliprectangle.h
src/guichan/include/guichan/color.h
src/guichan/include/guichan/defaultfont.h
src/guichan/include/guichan/exception.h
src/guichan/include/guichan/focushandler.h
src/guichan/include/guichan/font.h
src/guichan/include/guichan/graphics.h
src/guichan/include/guichan/gsdl.h
src/guichan/include/guichan/gui.h
src/guichan/include/guichan.h
src/guichan/include/guichan/imagefont.h
src/guichan/include/guichan/image.h
src/guichan/include/guichan/imageloader.h
src/guichan/include/guichan/input.h
src/guichan/include/guichan/key.h
src/guichan/include/guichan/keyinput.h
src/guichan/include/guichan/keylistener.h
src/guichan/include/guichan/listmodel.h
src/guichan/include/guichan/mouseinput.h
src/guichan/include/guichan/mouselistener.h
src/guichan/include/guichan/platform.h
src/guichan/include/guichan/rectangle.h
src/guichan/include/guichan/sdl/sdlgraphics.h
src/guichan/include/guichan/sdl/sdlimageloader.h
src/guichan/include/guichan/sdl/sdlinput.h
src/guichan/include/guichan/sdl/sdlpixel.h
src/guichan/include/guichan/widget.h
src/guichan/include/guichan/widgets/button.h
src/guichan/include/guichan/widgets/container.h
src/guichan/include/guichan/widgets/dropdown.h
src/guichan/include/guichan/widgets/checkbox.h
src/guichan/include/guichan/widgets/icon.h
src/guichan/include/guichan/widgets/label.h
src/guichan/include/guichan/widgets/listbox.h
src/guichan/include/guichan/widgets/radiobutton.h
src/guichan/include/guichan/widgets/scrollarea.h
src/guichan/include/guichan/widgets/slider.h
src/guichan/include/guichan/widgets/textbox.h
src/guichan/include/guichan/widgets/textfield.h
src/guichan/include/guichan/widgets/window.h
src/guichan/include/guichan/x.h
)
source_group(include FILES ${stratagus_HDRS})
source_group(include FILES ${stratagus_generic_HDRS})
source_group(include\\action FILES ${stratagus_action_HDRS})
source_group(include\\guichan FILES ${stratagus_guichan_HDRS})
set (stratagus_HDRS ${stratagus_generic_HDRS} ${stratagus_action_HDRS} ${stratagus_guichan_HDRS})
# Additional platform checks

View file

@ -43,18 +43,19 @@
#include <string.h>
#include "stratagus.h"
#include "unittype.h"
#include "action/action_attack.h"
#include "animation.h"
#include "player.h"
#include "unit.h"
#include "missile.h"
#include "actions.h"
#include "sound.h"
#include "map.h"
#include "pathfinder.h"
#include "script.h"
#include "iolib.h"
#include "map.h"
#include "missile.h"
#include "pathfinder.h"
#include "player.h"
#include "script.h"
#include "sound.h"
#include "ui.h"
#include "unit.h"
#include "unittype.h"
/*----------------------------------------------------------------------------
-- Defines

View file

@ -37,17 +37,18 @@
#include <stdlib.h>
#include "stratagus.h"
#include "unittype.h"
#include "action/action_board.h"
#include "animation.h"
#include "player.h"
#include "unit.h"
#include "actions.h"
#include "pathfinder.h"
#include "map.h"
#include "iolib.h"
#include "map.h"
#include "pathfinder.h"
#include "player.h"
#include "script.h"
#include "ui.h"
#include "unit.h"
#include "unittype.h"
enum {

View file

@ -39,17 +39,19 @@
#include "stratagus.h"
#include "actions.h"
#include "unittype.h"
#include "animation.h"
#include "player.h"
#include "unit.h"
#include "action/action_build.h"
#include "action/action_built.h"
#include "ai.h"
#include "pathfinder.h"
#include "tileset.h"
#include "animation.h"
#include "iolib.h"
#include "pathfinder.h"
#include "player.h"
#include "script.h"
#include "tileset.h"
#include "ui.h"
#include "unit.h"
#include "unittype.h"
extern void AiReduceMadeInBuilt(PlayerAi &pai, const CUnitType &type);

View file

@ -34,16 +34,17 @@
#include <stdlib.h>
#include "stratagus.h"
#include "actions.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
#include "sound.h"
#include "map.h"
#include "action/action_built.h"
#include "ai.h"
#include "construct.h"
#include "iolib.h"
#include "map.h"
#include "player.h"
#include "script.h"
#include "sound.h"
#include "unit.h"
#include "unittype.h"
extern void AiReduceMadeInBuilt(PlayerAi &pai, const CUnitType &type);

View file

@ -37,11 +37,13 @@
#include <stdlib.h>
#include "stratagus.h"
#include "unittype.h"
#include "action/action_die.h"
#include "animation.h"
#include "unit.h"
#include "actions.h"
#include "iolib.h"
#include "unit.h"
#include "unittype.h"
/*----------------------------------------------------------------------------
-- Functions

View file

@ -38,13 +38,15 @@
#include <string.h>
#include "stratagus.h"
#include "unit.h"
#include "unittype.h"
#include "pathfinder.h"
#include "actions.h"
#include "action/action_follow.h"
#include "iolib.h"
#include "pathfinder.h"
#include "script.h"
#include "ui.h"
#include "unit.h"
#include "unittype.h"
enum {
State_Init = 0,

View file

@ -38,18 +38,19 @@
#include "stratagus.h"
#include "actions.h"
#include "unittype.h"
#include "animation.h"
#include "unit.h"
#include "pathfinder.h"
#include "sound.h"
#include "interface.h"
#include "map.h"
#include "action/action_move.h"
#include "ai.h"
#include "animation.h"
#include "interface.h"
#include "iolib.h"
#include "map.h"
#include "pathfinder.h"
#include "script.h"
#include "sound.h"
#include "ui.h"
#include "unit.h"
#include "unittype.h"
/*----------------------------------------------------------------------------
-- Functions

View file

@ -37,14 +37,16 @@
#include <stdlib.h>
#include "stratagus.h"
#include "unit.h"
#include "unittype.h"
#include "actions.h"
#include "pathfinder.h"
#include "map.h"
#include "action/action_patrol.h"
#include "iolib.h"
#include "map.h"
#include "pathfinder.h"
#include "script.h"
#include "ui.h"
#include "unit.h"
#include "unittype.h"
/*----------------------------------------------------------------------------
-- Functions

View file

@ -37,20 +37,18 @@
#include <stdlib.h>
#include "stratagus.h"
#include "unittype.h"
#include "action/action_repair.h"
#include "action/action_built.h"
#include "animation.h"
#include "player.h"
#include "unit.h"
#include "missile.h"
#include "actions.h"
#include "sound.h"
#include "tileset.h"
#include "map.h"
#include "pathfinder.h"
#include "interface.h"
#include "iolib.h"
#include "player.h"
#include "script.h"
#include "sound.h"
#include "unit.h"
#include "ui.h"
#include "unittype.h"
/*----------------------------------------------------------------------------
-- Functions

View file

@ -37,18 +37,20 @@
#include <stdlib.h>
#include "stratagus.h"
#include "sound.h"
#include "unitsound.h"
#include "unittype.h"
#include "animation.h"
#include "player.h"
#include "unit.h"
#include "actions.h"
#include "upgrade_structs.h"
#include "upgrade.h"
#include "action/action_research.h"
#include "ai.h"
#include "animation.h"
#include "iolib.h"
#include "script.h"
#include "sound.h"
#include "player.h"
#include "unit.h"
#include "unitsound.h"
#include "unittype.h"
#include "upgrade_structs.h"
#include "upgrade.h"
/*----------------------------------------------------------------------------
-- Functions

View file

@ -38,18 +38,20 @@
#include <string.h>
#include "stratagus.h"
#include "action/action_resource.h"
#include "animation.h"
#include "interface.h"
#include "iolib.h"
#include "map.h"
#include "pathfinder.h"
#include "player.h"
#include "script.h"
#include "sound.h"
#include "ui.h"
#include "unit.h"
#include "unittype.h"
#include "animation.h"
#include "actions.h"
#include "pathfinder.h"
#include "interface.h"
#include "sound.h"
#include "map.h"
#include "script.h"
#include "iolib.h"
#include "ui.h"
/*----------------------------------------------------------------------------
-- Declarations

View file

@ -42,21 +42,20 @@
#include <stdlib.h>
#include "stratagus.h"
#include "video.h"
#include "unittype.h"
#include "action/action_spellcast.h"
#include "animation.h"
#include "player.h"
#include "unit.h"
#include "missile.h"
#include "actions.h"
#include "pathfinder.h"
#include "sound.h"
#include "tileset.h"
#include "map.h"
#include "spells.h"
#include "iolib.h"
#include "missile.h"
#include "pathfinder.h"
#include "player.h"
#include "script.h"
#include "sound.h"
#include "spells.h"
#include "ui.h"
#include "unit.h"
#include "unittype.h"
/*----------------------------------------------------------------------------
-- Functions

View file

@ -37,18 +37,19 @@
#include <stdlib.h>
#include "stratagus.h"
#include "missile.h"
#include "unittype.h"
#include "action/action_still.h"
#include "animation.h"
#include "unit.h"
#include "actions.h"
#include "tileset.h"
#include "map.h"
#include "pathfinder.h"
#include "spells.h"
#include "player.h"
#include "iolib.h"
#include "map.h"
#include "missile.h"
#include "player.h"
#include "script.h"
#include "spells.h"
#include "tileset.h"
#include "unit.h"
#include "unittype.h"
enum {
SUB_STILL_INIT = 0,

View file

@ -37,19 +37,18 @@
#include <stdlib.h>
#include "stratagus.h"
#include "video.h"
#include "action/action_train.h"
#include "ai.h"
#include "animation.h"
#include "iolib.h"
#include "player.h"
#include "sound.h"
#include "ui.h"
#include "unit.h"
#include "unitsound.h"
#include "unittype.h"
#include "animation.h"
#include "player.h"
#include "unit.h"
#include "actions.h"
#include "missile.h"
#include "sound.h"
#include "ai.h"
#include "ui.h"
#include "iolib.h"
/*----------------------------------------------------------------------------
-- Functions

View file

@ -37,15 +37,17 @@
#include <stdlib.h>
#include "stratagus.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
#include "actions.h"
#include "action/action_unload.h"
#include "iolib.h"
#include "map.h"
#include "pathfinder.h"
#include "player.h"
#include "script.h"
#include "iolib.h"
#include "ui.h"
#include "unit.h"
#include "unittype.h"
/*----------------------------------------------------------------------------
-- Functions

View file

@ -37,17 +37,18 @@
#include <stdlib.h>
#include "stratagus.h"
#include "player.h"
#include "unittype.h"
#include "animation.h"
#include "unit.h"
#include "actions.h"
#include "ai.h"
#include "map.h"
#include "spells.h"
#include "script.h"
#include "iolib.h"
#include "action/action_upgradeto.h"
#include "ai.h"
#include "animation.h"
#include "iolib.h"
#include "map.h"
#include "player.h"
#include "script.h"
#include "spells.h"
#include "unit.h"
#include "unittype.h"
/*----------------------------------------------------------------------------
-- Functions

View file

@ -41,16 +41,34 @@
#include "stratagus.h"
#include "actions.h"
#include "video.h"
#include "unittype.h"
#include "action/action_attack.h"
#include "action/action_board.h"
#include "action/action_build.h"
#include "action/action_built.h"
#include "action/action_die.h"
#include "action/action_follow.h"
#include "action/action_move.h"
#include "action/action_patrol.h"
#include "action/action_repair.h"
#include "action/action_research.h"
#include "action/action_resource.h"
#include "action/action_spellcast.h"
#include "action/action_still.h"
#include "action/action_train.h"
#include "action/action_unload.h"
#include "action/action_upgradeto.h"
#include "animation.h"
#include "player.h"
#include "unit.h"
#include "missile.h"
#include "commands.h"
#include "map.h"
#include "missile.h"
#include "player.h"
#include "sound.h"
#include "spells.h"
#include "commands.h"
#include "unit.h"
#include "unittype.h"
#include "video.h"
//SpawnMissile flags
#define ANIM_SM_DAMAGE 1

View file

@ -38,16 +38,18 @@
#include <string.h>
#include "stratagus.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
#include "actions.h"
#include "tileset.h"
#include "action/action_train.h"
#include "map.h"
#include "upgrade.h"
#include "pathfinder.h"
#include "player.h"
#include "spells.h"
#include "tileset.h"
#include "upgrade.h"
#include "ui.h"
#include "unit.h"
#include "unittype.h"
/*----------------------------------------------------------------------------
-- Functions

View file

@ -38,15 +38,18 @@
#include <stdlib.h>
#include "stratagus.h"
#include "ai_local.h"
#include "action/action_build.h"
#include "action/action_resource.h"
#include "depend.h"
#include "map.h"
#include "pathfinder.h"
#include "player.h"
#include "unit.h"
#include "unittype.h"
#include "upgrade.h"
#include "map.h"
#include "pathfinder.h"
#include "ai_local.h"
#include "actions.h"
#include "player.h"
#include "depend.h"
/*----------------------------------------------------------------------------
-- Defines

View file

@ -0,0 +1,67 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_ATTACK_H__
#define __ACTION_ATTACK_H__
#include "actions.h"
//@{
class COrder_Attack : public COrder
{
friend COrder* COrder::NewActionAttack(const CUnit &attacker, CUnit &target);
friend COrder* COrder::NewActionAttack(const CUnit &attacker, const Vec2i &dest);
friend COrder* COrder::NewActionAttackGround(const CUnit &attacker, const Vec2i &dest);
public:
COrder_Attack(bool ground) : COrder(ground ? UnitActionAttackGround : UnitActionAttack), State(0)
{}
virtual COrder_Attack* Clone() const { return new COrder_Attack(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
bool IsWeakTargetSelected() const;
private:
bool CheckForDeadGoal(CUnit &unit);
bool CheckForTargetInRange(CUnit &unit);
void MoveToTarget(CUnit &unit);
void AttackTarget(CUnit &unit);
private:
int State;
};
//@}
#endif // !__ACTION_ATTACK_H__

View file

@ -0,0 +1,60 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_BOARD_H__
#define __ACTION_BOARD_H__
#include "actions.h"
//@{
class COrder_Board : public COrder
{
friend COrder* COrder::NewActionBoard(CUnit &unit);
public:
COrder_Board() : COrder(UnitActionBoard), State(0) {}
virtual COrder_Board *Clone() const { return new COrder_Board(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
private:
bool WaitForTransporter(CUnit &unit);
private:
int State;
};
//@}
#endif // !__ACTION_BOARD_H__

View file

@ -0,0 +1,68 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_BUILD_H__
#define __ACTION_BUILD_H__
#include "actions.h"
//@{
class COrder_Build : public COrder
{
friend COrder* COrder::NewActionBuild(const CUnit &builder, const Vec2i &pos, CUnitType &building);
public:
COrder_Build() : COrder(UnitActionBuild), Type(NULL), State(0) {}
virtual COrder_Build *Clone() const { return new COrder_Build(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
virtual void AiUnitKilled(CUnit &unit);
const CUnitType& GetUnitType() const { return *Type; }
private:
bool MoveToLocation(CUnit &unit);
CUnit *CheckCanBuild(CUnit &unit);
bool StartBuilding(CUnit &unit, CUnit &ontop);
bool BuildFromOutside(CUnit &unit) const;
private:
CUnitType *Type; /// build a unit of this unit-type
CUnitPtr BuildingUnit; /// unit builded.
int State;
};
//@}
#endif // !__ACTION_BUILD_H__

View file

@ -0,0 +1,76 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_BUILT_H__
#define __ACTION_BUILT_H__
#include "actions.h"
//@{
class COrder_Built : public COrder
{
friend COrder* COrder::NewActionBuilt(CUnit &builder, CUnit &unit);
public:
COrder_Built() : COrder(UnitActionBuilt), ProgressCounter(0), IsCancelled(false), Frame(NULL) {}
virtual COrder_Built *Clone() const { return new COrder_Built(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual void Cancel(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
virtual void UpdateUnitVariables(CUnit &unit) const;
virtual void FillSeenValues(CUnit &unit) const;
virtual void AiUnitKilled(CUnit &unit);
void Progress(CUnit & unit, int amount);
void ProgressHp(CUnit &unit, int amount);
const CConstructionFrame& GetFrame() const { return *Frame; }
const CUnitPtr &GetWorker() const { return Worker; }
CUnit *GetWorkerPtr() { return Worker; }
private:
void Boost(CUnit &building, int amount, int varIndex) const;
void UpdateConstructionFrame(CUnit &unit);
private:
CUnitPtr Worker; /// Worker building this unit
int ProgressCounter; /// Progress counter, in 1/100 cycles.
bool IsCancelled; /// Cancel construction
const CConstructionFrame *Frame; /// Construction frame
};
//@}
#endif // !__ACTION_BUILT_H__

View file

@ -0,0 +1,53 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_DIE_H__
#define __ACTION_DIE_H__
#include "actions.h"
//@{
class COrder_Die : public COrder
{
public:
COrder_Die() : COrder(UnitActionDie) {}
virtual COrder_Die *Clone() const { return new COrder_Die(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
};
//@}
#endif // !__ACTION_DIE_H__

View file

@ -0,0 +1,55 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_FOLLOW_H__
#define __ACTION_FOLLOW_H__
#include "actions.h"
//@{
class COrder_Follow : public COrder
{
public:
COrder_Follow() : COrder(UnitActionFollow), State(0) {}
virtual COrder_Follow *Clone() const { return new COrder_Follow(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
private:
unsigned int State;
};
//@}
#endif // !__ACTION_FOLLOW_H__

View file

@ -0,0 +1,53 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_MOVE_H__
#define __ACTION_MOVE_H__
#include "actions.h"
//@{
class COrder_Move : public COrder
{
public:
COrder_Move() : COrder(UnitActionMove) {}
virtual COrder_Move *Clone() const { return new COrder_Move(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
};
//@}
#endif // !__ACTION_MOVE_H__

View file

@ -0,0 +1,59 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_PATROL_H__
#define __ACTION_PATROL_H__
#include "actions.h"
//@{
class COrder_Patrol : public COrder
{
friend COrder* COrder::NewActionPatrol(const Vec2i &currentPos, const Vec2i &dest);
public:
COrder_Patrol() : COrder(UnitActionPatrol), WaitingCycle(0) {}
virtual COrder_Patrol *Clone() const { return new COrder_Patrol(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
const Vec2i& GetWayPoint() const { return WayPoint; }
private:
Vec2i WayPoint; /// position for patroling.
unsigned int WaitingCycle; /// number of cycle pathfinder wait.
};
//@}
#endif // !__ACTION_PATROL_H__

View file

@ -0,0 +1,61 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_REPAIR_H__
#define __ACTION_REPAIR_H__
#include "actions.h"
//@{
class COrder_Repair : public COrder
{
friend COrder* COrder::NewActionRepair(CUnit &unit, CUnit &target);
friend COrder* COrder::NewActionRepair(const Vec2i &pos);
public:
COrder_Repair() : COrder(UnitActionRepair), State(0), RepairCycle(0) {}
virtual COrder_Repair *Clone() const { return new COrder_Repair(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
private:
bool RepairUnit(const CUnit &unit, CUnit &goal);
private:
unsigned int State;
unsigned int RepairCycle;
};
//@}
#endif // !__ACTION_REPAIR_H__

View file

@ -0,0 +1,61 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_RESEARCH_H__
#define __ACTION_RESEARCH_H__
#include "actions.h"
//@{
class COrder_Research : public COrder
{
public:
COrder_Research() : COrder(UnitActionResearch), Upgrade(NULL) {}
virtual COrder_Research *Clone() const { return new COrder_Research(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual void Cancel(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
virtual void UpdateUnitVariables(CUnit &unit) const;
const CUpgrade& GetUpgrade() const { return *Upgrade; }
void SetUpgrade(CUpgrade &upgrade) { Upgrade = &upgrade; }
private:
CUpgrade *Upgrade;
};
//@}
#endif // !__ACTION_RESEARCH_H__

View file

@ -0,0 +1,96 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_RESOURCE_H__
#define __ACTION_RESOURCE_H__
#include "actions.h"
//@{
class COrder_Resource : public COrder
{
friend COrder* COrder::NewActionResource(CUnit &harvester, const Vec2i &pos);
friend COrder* COrder::NewActionResource(CUnit &harvester, CUnit &mine);
friend COrder* COrder::NewActionReturnGoods(CUnit &harvester, CUnit *depot);
public:
COrder_Resource(CUnit &harvester) : COrder(UnitActionResource), worker(&harvester),
CurrentResource(0), State(0), TimeToHarvest(0), DoneHarvesting(false)
{
Resource.Pos.x = Resource.Pos.y = -1;
}
~COrder_Resource();
virtual COrder_Resource *Clone() const { return new COrder_Resource(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
virtual bool OnAiHitUnit(CUnit &unit, CUnit *attacker, int /*damage*/);
Vec2i GetHarvestLocation() const;
bool IsGatheringStarted() const;
bool IsGatheringFinished() const;
bool IsGatheringWaiting() const;
private:
int MoveToResource_Terrain(CUnit &unit);
int MoveToResource_Unit(CUnit &unit);
int MoveToResource(CUnit &unit);
void UnitGotoGoal(CUnit &unit, CUnit *const goal, int state);
int StartGathering(CUnit &unit);
void LoseResource(CUnit &unit, const CUnit &source);
int GatherResource(CUnit &unit);
int StopGathering(CUnit &unit);
int MoveToDepot(CUnit &unit);
bool WaitInDepot(CUnit &unit);
void DropResource(CUnit &unit);
void ResourceGiveUp(CUnit &unit);
bool ActionResourceInit(CUnit &unit);
private:
CUnitPtr worker; /// unit that own this order.
unsigned char CurrentResource;
struct {
Vec2i Pos; /// position for terrain resource.
CUnitPtr Mine;
} Resource;
CUnitPtr Depot;
int State;
int TimeToHarvest; /// how much time until we harvest some more.
bool DoneHarvesting; /// Harvesting done, wait for action to break.
};
//@}
#endif // !__ACTION_RESOURCE_H__

View file

@ -0,0 +1,63 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_SPELLCAST_H__
#define __ACTION_SPELLCAST_H__
#include "actions.h"
//@{
class COrder_SpellCast : public COrder
{
public:
COrder_SpellCast() : COrder(UnitActionSpellCast), Spell(NULL), State(0) {}
virtual COrder_SpellCast *Clone() const { return new COrder_SpellCast(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
virtual void OnAnimationAttack(CUnit &unit);
const SpellType& GetSpell() const { return *Spell; }
void SetSpell(SpellType &spell) { Spell = &spell; }
private:
bool SpellMoveToTarget(CUnit &unit);
private:
SpellType *Spell;
int State;
};
//@}
#endif // !__ACTION_SPELLCAST_H__

View file

@ -0,0 +1,57 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_STILL_H__
#define __ACTION_STILL_H__
#include "actions.h"
//@{
class COrder_Still : public COrder
{
public:
COrder_Still(bool stand) : COrder(stand ? UnitActionStandGround : UnitActionStill), State(0) {}
virtual COrder_Still *Clone() const { return new COrder_Still(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
private:
bool AutoAttackStand(CUnit &unit);
private:
int State;
};
//@}
#endif // !__ACTION_STILL_H__

View file

@ -0,0 +1,64 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_TRAIN_H__
#define __ACTION_TRAIN_H__
#include "actions.h"
//@{
class COrder_Train : public COrder
{
friend COrder* COrder::NewActionTrain(CUnit &trainer, CUnitType &type);
public:
COrder_Train() : COrder(UnitActionTrain), Type(NULL), Ticks(0) {}
virtual COrder_Train *Clone() const { return new COrder_Train(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual void Cancel(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
virtual void UpdateUnitVariables(CUnit &unit) const;
void ConvertUnitType(const CUnit &unit, CUnitType& newType);
const CUnitType &GetUnitType() const { return *Type; }
private:
CUnitType *Type; /// train a unit of this unit-type
int Ticks; /// Ticks to complete
};
//@}
#endif // !__ACTION_TRAIN_H__

View file

@ -0,0 +1,59 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_UNLOAD_H__
#define __ACTION_UNLOAD_H__
#include "actions.h"
//@{
class COrder_Unload : public COrder
{
friend COrder* COrder::NewActionUnload(const Vec2i &pos, CUnit *what);
public:
COrder_Unload() : COrder(UnitActionUnload), State(0) {}
virtual COrder_Unload *Clone() const { return new COrder_Unload(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
private:
bool LeaveTransporter(CUnit &transporter);
private:
int State;
};
//@}
#endif // !__ACTION_UNLOAD_H__

View file

@ -0,0 +1,79 @@
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name actions.h - The actions headerfile. */
//
// (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#ifndef __ACTION_UPGRADETO_H__
#define __ACTION_UPGRADETO_H__
#include "actions.h"
//@{
class COrder_TransformInto : public COrder
{
friend COrder* COrder::NewActionTransformInto(CUnitType &type);
public:
COrder_TransformInto() : COrder(UnitActionTransformInto), Type(NULL) {}
virtual COrder_TransformInto *Clone() const { return new COrder_TransformInto(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
private:
CUnitType *Type; /// Transform unit into this unit-type
};
class COrder_UpgradeTo : public COrder
{
friend COrder* COrder::NewActionUpgradeTo(CUnit &unit, CUnitType &type);
public:
COrder_UpgradeTo() : COrder(UnitActionUpgradeTo), Type(NULL), Ticks(0) {}
virtual COrder_UpgradeTo *Clone() const { return new COrder_UpgradeTo(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual void Cancel(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
virtual void UpdateUnitVariables(CUnit &unit) const;
const CUnitType& GetUnitType() const { return *Type; }
private:
CUnitType *Type; /// upgrate to this unit-type
int Ticks; /// Ticks to complete
};
#endif // !__ACTIONS_H__

View file

@ -189,423 +189,6 @@ public:
} Data; /// Storage room for different commands
};
class COrder_Attack : public COrder
{
friend COrder* COrder::NewActionAttack(const CUnit &attacker, CUnit &target);
friend COrder* COrder::NewActionAttack(const CUnit &attacker, const Vec2i &dest);
friend COrder* COrder::NewActionAttackGround(const CUnit &attacker, const Vec2i &dest);
public:
COrder_Attack(bool ground) : COrder(ground ? UnitActionAttackGround : UnitActionAttack), State(0)
{}
virtual COrder_Attack* Clone() const { return new COrder_Attack(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
bool IsWeakTargetSelected() const;
private:
bool CheckForDeadGoal(CUnit &unit);
bool CheckForTargetInRange(CUnit &unit);
void MoveToTarget(CUnit &unit);
void AttackTarget(CUnit &unit);
private:
int State;
};
class COrder_Board : public COrder
{
friend COrder* COrder::NewActionBoard(CUnit &unit);
public:
COrder_Board() : COrder(UnitActionBoard), State(0) {}
virtual COrder_Board *Clone() const { return new COrder_Board(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
private:
bool WaitForTransporter(CUnit &unit);
private:
int State;
};
class COrder_Build : public COrder
{
friend COrder* COrder::NewActionBuild(const CUnit &builder, const Vec2i &pos, CUnitType &building);
public:
COrder_Build() : COrder(UnitActionBuild), Type(NULL), State(0) {}
virtual COrder_Build *Clone() const { return new COrder_Build(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
virtual void AiUnitKilled(CUnit &unit);
const CUnitType& GetUnitType() const { return *Type; }
private:
bool MoveToLocation(CUnit &unit);
CUnit *CheckCanBuild(CUnit &unit);
bool StartBuilding(CUnit &unit, CUnit &ontop);
bool BuildFromOutside(CUnit &unit) const;
private:
CUnitType *Type; /// build a unit of this unit-type
CUnitPtr BuildingUnit; /// unit builded.
int State;
};
class COrder_Built : public COrder
{
friend COrder* COrder::NewActionBuilt(CUnit &builder, CUnit &unit);
public:
COrder_Built() : COrder(UnitActionBuilt), ProgressCounter(0), IsCancelled(false), Frame(NULL) {}
virtual COrder_Built *Clone() const { return new COrder_Built(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual void Cancel(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
virtual void UpdateUnitVariables(CUnit &unit) const;
virtual void FillSeenValues(CUnit &unit) const;
virtual void AiUnitKilled(CUnit &unit);
void Progress(CUnit & unit, int amount);
void ProgressHp(CUnit &unit, int amount);
const CConstructionFrame& GetFrame() const { return *Frame; }
const CUnitPtr &GetWorker() const { return Worker; }
CUnit *GetWorkerPtr() { return Worker; }
private:
void Boost(CUnit &building, int amount, int varIndex) const;
void UpdateConstructionFrame(CUnit &unit);
private:
CUnitPtr Worker; /// Worker building this unit
int ProgressCounter; /// Progress counter, in 1/100 cycles.
bool IsCancelled; /// Cancel construction
const CConstructionFrame *Frame; /// Construction frame
};
class COrder_Die : public COrder
{
public:
COrder_Die() : COrder(UnitActionDie) {}
virtual COrder_Die *Clone() const { return new COrder_Die(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
};
class COrder_Follow : public COrder
{
public:
COrder_Follow() : COrder(UnitActionFollow), State(0) {}
virtual COrder_Follow *Clone() const { return new COrder_Follow(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
private:
unsigned int State;
};
class COrder_Move : public COrder
{
public:
COrder_Move() : COrder(UnitActionMove) {}
virtual COrder_Move *Clone() const { return new COrder_Move(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
};
class COrder_Patrol : public COrder
{
friend COrder* COrder::NewActionPatrol(const Vec2i &currentPos, const Vec2i &dest);
public:
COrder_Patrol() : COrder(UnitActionPatrol), WaitingCycle(0) {}
virtual COrder_Patrol *Clone() const { return new COrder_Patrol(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
const Vec2i& GetWayPoint() const { return WayPoint; }
private:
Vec2i WayPoint; /// position for patroling.
unsigned int WaitingCycle; /// number of cycle pathfinder wait.
};
class COrder_Repair : public COrder
{
friend COrder* COrder::NewActionRepair(CUnit &unit, CUnit &target);
friend COrder* COrder::NewActionRepair(const Vec2i &pos);
public:
COrder_Repair() : COrder(UnitActionRepair), State(0), RepairCycle(0) {}
virtual COrder_Repair *Clone() const { return new COrder_Repair(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
private:
bool RepairUnit(const CUnit &unit, CUnit &goal);
private:
unsigned int State;
unsigned int RepairCycle;
};
class COrder_Research : public COrder
{
public:
COrder_Research() : COrder(UnitActionResearch), Upgrade(NULL) {}
virtual COrder_Research *Clone() const { return new COrder_Research(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual void Cancel(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
virtual void UpdateUnitVariables(CUnit &unit) const;
const CUpgrade& GetUpgrade() const { return *Upgrade; }
void SetUpgrade(CUpgrade &upgrade) { Upgrade = &upgrade; }
private:
CUpgrade *Upgrade;
};
class COrder_Resource : public COrder
{
friend COrder* COrder::NewActionResource(CUnit &harvester, const Vec2i &pos);
friend COrder* COrder::NewActionResource(CUnit &harvester, CUnit &mine);
friend COrder* COrder::NewActionReturnGoods(CUnit &harvester, CUnit *depot);
public:
COrder_Resource(CUnit &harvester) : COrder(UnitActionResource), worker(&harvester),
CurrentResource(0), State(0), TimeToHarvest(0), DoneHarvesting(false)
{
Resource.Pos.x = Resource.Pos.y = -1;
}
~COrder_Resource();
virtual COrder_Resource *Clone() const { return new COrder_Resource(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
virtual bool OnAiHitUnit(CUnit &unit, CUnit *attacker, int /*damage*/);
Vec2i GetHarvestLocation() const;
bool IsGatheringStarted() const;
bool IsGatheringFinished() const;
bool IsGatheringWaiting() const;
private:
int MoveToResource_Terrain(CUnit &unit);
int MoveToResource_Unit(CUnit &unit);
int MoveToResource(CUnit &unit);
void UnitGotoGoal(CUnit &unit, CUnit *const goal, int state);
int StartGathering(CUnit &unit);
void LoseResource(CUnit &unit, const CUnit &source);
int GatherResource(CUnit &unit);
int StopGathering(CUnit &unit);
int MoveToDepot(CUnit &unit);
bool WaitInDepot(CUnit &unit);
void DropResource(CUnit &unit);
void ResourceGiveUp(CUnit &unit);
bool ActionResourceInit(CUnit &unit);
private:
CUnitPtr worker; /// unit that own this order.
unsigned char CurrentResource;
struct {
Vec2i Pos; /// position for terrain resource.
CUnitPtr Mine;
} Resource;
CUnitPtr Depot;
int State;
int TimeToHarvest; /// how much time until we harvest some more.
bool DoneHarvesting; /// Harvesting done, wait for action to break.
};
class COrder_SpellCast : public COrder
{
public:
COrder_SpellCast() : COrder(UnitActionSpellCast), Spell(NULL), State(0) {}
virtual COrder_SpellCast *Clone() const { return new COrder_SpellCast(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
virtual void OnAnimationAttack(CUnit &unit);
const SpellType& GetSpell() const { return *Spell; }
void SetSpell(SpellType &spell) { Spell = &spell; }
private:
bool SpellMoveToTarget(CUnit &unit);
private:
SpellType *Spell;
int State;
};
class COrder_Still : public COrder
{
public:
COrder_Still(bool stand) : COrder(stand ? UnitActionStandGround : UnitActionStill), State(0) {}
virtual COrder_Still *Clone() const { return new COrder_Still(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
private:
bool AutoAttackStand(CUnit &unit);
private:
int State;
};
class COrder_Train : public COrder
{
friend COrder* COrder::NewActionTrain(CUnit &trainer, CUnitType &type);
public:
COrder_Train() : COrder(UnitActionTrain), Type(NULL), Ticks(0) {}
virtual COrder_Train *Clone() const { return new COrder_Train(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual void Cancel(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
virtual void UpdateUnitVariables(CUnit &unit) const;
void ConvertUnitType(const CUnit &unit, CUnitType& newType);
const CUnitType &GetUnitType() const { return *Type; }
private:
CUnitType *Type; /// train a unit of this unit-type
int Ticks; /// Ticks to complete
};
class COrder_TransformInto : public COrder
{
friend COrder* COrder::NewActionTransformInto(CUnitType &type);
public:
COrder_TransformInto() : COrder(UnitActionTransformInto), Type(NULL) {}
virtual COrder_TransformInto *Clone() const { return new COrder_TransformInto(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
private:
CUnitType *Type; /// Transform unit into this unit-type
};
class COrder_Unload : public COrder
{
friend COrder* COrder::NewActionUnload(const Vec2i &pos, CUnit *what);
public:
COrder_Unload() : COrder(UnitActionUnload), State(0) {}
virtual COrder_Unload *Clone() const { return new COrder_Unload(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
private:
bool LeaveTransporter(CUnit &transporter);
private:
int State;
};
class COrder_UpgradeTo : public COrder
{
friend COrder* COrder::NewActionUpgradeTo(CUnit &unit, CUnitType &type);
public:
COrder_UpgradeTo() : COrder(UnitActionUpgradeTo), Type(NULL), Ticks(0) {}
virtual COrder_UpgradeTo *Clone() const { return new COrder_UpgradeTo(*this); }
virtual void Save(CFile &file, const CUnit &unit) const;
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
virtual void Execute(CUnit &unit);
virtual void Cancel(CUnit &unit);
virtual PixelPos Show(const CViewport& vp, const PixelPos& lastScreenPos) const;
virtual void UpdateUnitVariables(CUnit &unit) const;
const CUnitType& GetUnitType() const { return *Type; }
private:
CUnitType *Type; /// upgrate to this unit-type
int Ticks; /// Ticks to complete
};
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/

View file

@ -42,24 +42,29 @@
#include <sstream>
#include "stratagus.h"
#include "video.h"
#include "action/action_built.h"
#include "action/action_research.h"
#include "action/action_train.h"
#include "action/action_upgradeto.h"
#include "font.h"
#include "sound.h"
#include "unitsound.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
#include "upgrade.h"
#include "icons.h"
#include "interface.h"
#include "ui.h"
#include "map.h"
#include "menus.h"
#include "network.h"
#include "player.h"
#include "sound.h"
#include "spells.h"
#include "tileset.h"
#include "trigger.h"
#include "network.h"
#include "menus.h"
#include "spells.h"
#include "actions.h"
#include "ui.h"
#include "unit.h"
#include "unitsound.h"
#include "unittype.h"
#include "upgrade.h"
#include "video.h"
#ifdef DEBUG
#include "../ai/ai_local.h"
#endif

View file

@ -41,6 +41,7 @@
#include <ctype.h>
#include "stratagus.h"
#include "tileset.h"
#include "video.h"
#include "map.h"
@ -62,6 +63,7 @@
#include "spells.h"
#include "widgets.h"
#include "actions.h"
#include "action/action_train.h"
/*----------------------------------------------------------------------------
-- Variables

View file

@ -39,6 +39,23 @@
#include "stratagus.h"
#include "unit.h"
#include "action/action_attack.h"
#include "action/action_board.h"
#include "action/action_build.h"
#include "action/action_built.h"
#include "action/action_die.h"
#include "action/action_follow.h"
#include "action/action_move.h"
#include "action/action_patrol.h"
#include "action/action_repair.h"
#include "action/action_research.h"
#include "action/action_resource.h"
#include "action/action_spellcast.h"
#include "action/action_still.h"
#include "action/action_train.h"
#include "action/action_unload.h"
#include "action/action_upgradeto.h"
#include "unit_manager.h"
#include "unittype.h"
#include "animation.h"

View file

@ -36,28 +36,29 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include "stratagus.h"
#include <vector>
#include "video.h"
#include "sound.h"
#include "unitsound.h"
#include "editor.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
#include "tileset.h"
#include "map.h"
#include "actions.h"
#include "action/action_build.h"
#include "action/action_built.h"
#include "action/action_upgradeto.h"
#include "construct.h"
#include "cursor.h"
#include "interface.h"
#include "editor.h"
#include "font.h"
#include "ui.h"
#include "actions.h"
#include "interface.h"
#include "map.h"
#include "player.h"
#include "script.h"
#include "sound.h"
#include "tileset.h"
#include "unit.h"
#include "unitsound.h"
#include "unittype.h"
#include "ui.h"
#include "video.h"
/*----------------------------------------------------------------------------
-- Variables

View file

@ -36,27 +36,23 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include <string>
#include <vector>
#include <map>
#include "stratagus.h"
#include "upgrade.h"
#include "player.h"
#include "action/action_train.h"
#include "depend.h"
#include "interface.h"
#include "iolib.h"
#include "map.h"
#include "player.h"
#include "script.h"
#include "spells.h"
#include "unit.h"
#include "unittype.h"
#include "actions.h"
#include "iolib.h"
#include "myendian.h"
#include "util.h"
/*----------------------------------------------------------------------------