1 //////////////////////////////////////////////////////////////////////////////// 2 // Copyright (C) 2004-2011 by The Allacrost Project 3 // Copyright (C) 2012-2016 by Bertram (Valyria Tear) 4 // All Rights Reserved 5 // 6 // This code is licensed under the GNU GPL version 2. It is free software and 7 // you may modify it and/or redistribute it under the terms of this license. 8 // See https://www.gnu.org/copyleft/gpl.html for details. 9 //////////////////////////////////////////////////////////////////////////////// 10 11 #ifndef __BATTLE_ACTION_HEADER__ 12 #define __BATTLE_ACTION_HEADER__ 13 14 #include "modes/battle/battle_target.h" 15 16 namespace vt_battle 17 { 18 19 namespace private_battle 20 { 21 22 /** **************************************************************************** 23 *** \brief Representation of a single action to be executed in battle 24 *** 25 *** This is an abstract base class for all action classes to inherit from. Actions are what 26 *** actors perform in battle whenever they move to attack an opponent, protect a comrade, use 27 *** an item, etc. There is no distinguishment between characters and enemies as far as the action 28 *** classes are concerned. All actions are implemented via Lua script functions that perform the 29 *** necessary synchronization of visual and audio media presented to the user as well as modifying 30 *** any change to the stats of the actor or target. Actions (and by proxy the actors executing them) 31 *** may be either processed individually one at a time, or multiple skills may be executed 32 *** simultaneously. 33 *** 34 *** Each action used determines the amount of time that the actor using the action 35 *** must wait in the warm up and cool down states. The warm up state is when the 36 *** actor has chosen to use the action but has not yet used it. The cool down state 37 *** occurs immediately after the actor finishes the action an 38 *** ***************************************************************************/ 39 class BattleAction 40 { 41 public: 42 BattleAction(BattleActor *user, BattleTarget target); 43 ~BattleAction()44 virtual ~BattleAction() 45 {} 46 47 //! \brief Returns true if this action consumes an item 48 virtual bool IsItemAction() const = 0; 49 50 //! \brief Init the battle action member and possible scripts Initialize()51 virtual bool Initialize() { 52 return true; 53 } 54 55 /** \brief Executes the warmup action. 56 *** \return True if the action executed fine, or false otherwise. 57 **/ 58 virtual void Warmup() = 0; 59 60 /** \brief Executes the action. 61 *** \return True if the action executed fine, or false otherwise. 62 **/ 63 virtual bool Execute() = 0; 64 65 ///! \brief Cancel a waiting action, and restore potential involved objects if necessary. 66 virtual void Cancel() = 0; 67 68 //! \brief Updates a skill process. Returns true when when the skill has finished Update()69 virtual bool Update() { 70 return true; 71 }; 72 73 //! \brief Tells whether the battle action is handled through a script IsScripted()74 virtual bool IsScripted() const { 75 return _is_scripted; 76 } 77 78 //! \brief Returns the name of the action that the player would read 79 virtual vt_utils::ustring GetName() const = 0; 80 81 //! \brief Returns the icon filename of the action that the player would need 82 virtual std::string GetIconFilename() const = 0; 83 84 //! \brief Returns whether a short notice should be shown just before triggering the action. 85 virtual bool ShouldShowSkillNotice() const = 0; 86 87 //! \brief Returns the number of milliseconds that the owner actor must wait in the warm up state 88 virtual uint32_t GetWarmUpTime() const = 0; 89 90 //! \brief Returns the number of milliseconds that the owner actor must wait in the cool down state 91 virtual uint32_t GetCoolDownTime() const = 0; 92 93 //! \brief Returns the character action name played before at warmup time. 94 virtual std::string GetWarmupActionName() const = 0; 95 96 //! \brief Returns the character action name played before executing the scripted function. 97 virtual std::string GetActionName() const = 0; 98 99 //! \name Class member access functions 100 //@{ GetActor()101 BattleActor *GetActor() { 102 return _actor; 103 } 104 GetTarget()105 BattleTarget &GetTarget() { 106 return _target; 107 } 108 //@} 109 110 protected: 111 //! \brief The actor who will be executing the action 112 BattleActor *_actor; 113 114 //! \brief The target of the action which may be an attack point, actor, or entire party 115 BattleTarget _target; 116 117 /** The functions of the possible animation. 118 *** When valid, the Update function should be called until the function returns true. 119 **/ 120 luabind::object _init_function; 121 luabind::object _update_function; 122 123 //! \brief The Animation script, used when the skill is animated. 124 vt_script::ReadScriptDescriptor _anim_script; 125 126 //! \brief Tells whether the battle action animation is scripted. 127 bool _is_scripted; 128 129 //! \brief Initialize (Calling #Initialize) a scripted battle animation when one is existing. _InitAnimationScript()130 virtual void _InitAnimationScript() 131 {} 132 }; 133 134 } // namespace private_battle 135 136 } // namespace vt_battle 137 138 #endif // __BATTLE_ACTION_HEADER__ 139