summaryrefslogtreecommitdiff
path: root/src/resources/spritedef.h
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-29 20:20:51 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-29 20:20:51 +0200
commitae898aa1a5175b2b08f7248e4cd89bf61bc8e4be (patch)
tree041646a78229772ae7bb55222659fc4826325c43 /src/resources/spritedef.h
parent2b1c0dcf269d617de1f6c203df547166661f089e (diff)
downloadmana-client-ae898aa1a5175b2b08f7248e4cd89bf61bc8e4be.tar.gz
mana-client-ae898aa1a5175b2b08f7248e4cd89bf61bc8e4be.tar.bz2
mana-client-ae898aa1a5175b2b08f7248e4cd89bf61bc8e4be.tar.xz
mana-client-ae898aa1a5175b2b08f7248e4cd89bf61bc8e4be.zip
Changed the items loading to handle a new 'attack-action' parameter.
The old behaviour was to load the weapon-type value and do many unnecessary checks and transformation on it: The weapon-type was transformed using hard-coded values into an integer enum value. The exact same thing was done on the opposite side in the animation files before comparing the two. As both data were string values, I simplified all of it by using the value taken in items.xml to call the corresponding action. This now also permit to set up new attack animation in items.xml and in the playerset.xml without having the need to modify the client code. Last but not least, the weapon-type value was used by both the skills and the actions and avoided the possibility to set up a definite action for a weapon-type. Note: The weapon-type parameter will become deprecated for the server in favor of a 'skill' parameter to reflect more it's actual use. This patch is the first step to fix Manasource issue: #157.
Diffstat (limited to 'src/resources/spritedef.h')
-rw-r--r--src/resources/spritedef.h41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index bc9ae45f..16b8c0c8 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -54,7 +54,7 @@ struct SpriteDisplay
};
typedef std::list<SpriteReference*>::const_iterator SpriteRefs;
-
+#if 0
enum SpriteAction
{
ACTION_DEFAULT = 0,
@@ -84,7 +84,33 @@ enum SpriteAction
ACTION_DEAD,
ACTION_INVALID
};
-
+#endif
+#if 1 // Aim to be reached
+/*
+ * Remember those are the main action.
+ * Action subtypes, e.g.: "attack_bow" are to be passed by items.xml after
+ * an ACTION_ATTACK call.
+ * Which special to be use to to be passed with the USE_SPECIAL call.
+ * Running, walking, ... is a sub-type of moving.
+ * ...
+ * Please don't add hard-coded subtypes here!
+ */
+namespace SpriteAction
+{
+ static const std::string DEFAULT = "stand";
+ static const std::string STAND = "stand";
+ static const std::string SIT = "sit";
+ static const std::string SLEEP = "sleep";
+ static const std::string DEAD = "dead";
+ static const std::string MOVE = "walk";
+ static const std::string ATTACK = "attack";
+ static const std::string HURT = "hurt";
+ static const std::string USE_SPECIAL = "special";
+ static const std::string CAST_MAGIC = "magic";
+ static const std::string USE_ITEM = "item";
+ static const std::string INVALID = "";
+};
+#endif
enum SpriteDirection
{
DIRECTION_DEFAULT = 0,
@@ -109,12 +135,7 @@ class SpriteDef : public Resource
/**
* Returns the specified action.
*/
- Action *getAction(SpriteAction action) const;
-
- /**
- * Converts a string into a SpriteAction enum.
- */
- static SpriteAction makeSpriteAction(const std::string &action);
+ Action *getAction(std::string action) const;
/**
* Converts a string into a SpriteDirection enum.
@@ -170,12 +191,12 @@ class SpriteDef : public Resource
* When there are no animations defined for the action "complete", its
* animations become a copy of those of the action "with".
*/
- void substituteAction(SpriteAction complete, SpriteAction with);
+ void substituteAction(std::string complete, std::string with);
typedef std::map<std::string, ImageSet*> ImageSets;
typedef ImageSets::iterator ImageSetIterator;
- typedef std::map<SpriteAction, Action*> Actions;
+ typedef std::map<std::string, Action*> Actions;
ImageSets mImageSets;
Actions mActions;