summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-03 20:10:33 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-03 20:10:33 +0300
commit51975cd8624fff3b20aa3b7b1932555e32786561 (patch)
tree55ff8d9c5a459bada8038807a1eaf0dfe98945e2 /src/resources
parentfd16292e758ab6fc910ed07441e6e477d616201c (diff)
downloadmanaplus-51975cd8624fff3b20aa3b7b1932555e32786561.tar.gz
manaplus-51975cd8624fff3b20aa3b7b1932555e32786561.tar.bz2
manaplus-51975cd8624fff3b20aa3b7b1932555e32786561.tar.xz
manaplus-51975cd8624fff3b20aa3b7b1932555e32786561.zip
Add spawn animation to mobs.
Also impliment sound events: SOUND_EVENT_MOVE, SOUND_EVENT_SIT, SOUND_EVENT_SPAWN
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/animation.cpp8
-rw-r--r--src/resources/animation.h4
-rw-r--r--src/resources/beinginfo.h5
-rw-r--r--src/resources/monsterdb.cpp12
-rw-r--r--src/resources/spritedef.cpp5
-rw-r--r--src/resources/spritedef.h1
6 files changed, 33 insertions, 2 deletions
diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp
index 328824827..fe5822f7b 100644
--- a/src/resources/animation.cpp
+++ b/src/resources/animation.cpp
@@ -31,7 +31,7 @@ Animation::Animation():
void Animation::addFrame(Image *image, int delay, int offsetX, int offsetY)
{
- Frame frame = { image, delay, offsetX, offsetY };
+ Frame frame = { image, delay, offsetX, offsetY, "" };
mFrames.push_back(frame);
mDuration += delay;
}
@@ -45,3 +45,9 @@ bool Animation::isTerminator(const Frame &candidate)
{
return (candidate.image == NULL);
}
+
+void Animation::addJump(std::string name)
+{
+ Frame frame = { 0, 0, 0, 0, name };
+ mFrames.push_back(frame);
+}
diff --git a/src/resources/animation.h b/src/resources/animation.h
index a78850b3a..9ec8396af 100644
--- a/src/resources/animation.h
+++ b/src/resources/animation.h
@@ -26,6 +26,7 @@
#include <libxml/tree.h>
#include <vector>
+#include <string>
class Image;
@@ -38,6 +39,7 @@ struct Frame
int delay;
int offsetX;
int offsetY;
+ std::string nextAction;
};
/**
@@ -78,6 +80,8 @@ class Animation
int getDuration() const
{ return mDuration; }
+ void addJump(std::string name);
+
/**
* Determines whether the given animation frame is a terminator.
*/
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index d5c0c6b28..192a4c3b5 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -54,7 +54,10 @@ enum SoundEvent
SOUND_EVENT_HIT = 0,
SOUND_EVENT_MISS,
SOUND_EVENT_HURT,
- SOUND_EVENT_DIE
+ SOUND_EVENT_DIE,
+ SOUND_EVENT_MOVE,
+ SOUND_EVENT_SIT,
+ SOUND_EVENT_SPAWN
};
typedef std::map<SoundEvent, std::vector<std::string>* > SoundEvents;
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index 8990d679a..9fce60306 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -134,6 +134,18 @@ void MonsterDB::load()
{
currentInfo->addSound(SOUND_EVENT_DIE, filename);
}
+ else if (event == "move")
+ {
+ currentInfo->addSound(SOUND_EVENT_MOVE, filename);
+ }
+ else if (event == "sit")
+ {
+ currentInfo->addSound(SOUND_EVENT_SIT, filename);
+ }
+ else if (event == "spawn")
+ {
+ currentInfo->addSound(SOUND_EVENT_SPAWN, filename);
+ }
else
{
logger->log("MonsterDB: Warning, sound effect %s for "
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index ceefac845..b3b473cd7 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -102,6 +102,7 @@ void SpriteDef::substituteActions()
substituteAction(SpriteAction::SLEEP, SpriteAction::SIT);
substituteAction(SpriteAction::HURT, SpriteAction::STAND);
substituteAction(SpriteAction::DEAD, SpriteAction::HURT);
+ substituteAction(SpriteAction::SPAWN, SpriteAction::STAND);
}
void SpriteDef::loadSprite(xmlNodePtr spriteNode, int variant,
@@ -287,6 +288,10 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode,
{
animation->addTerminator();
}
+ else if (xmlStrEqual(frameNode->name, BAD_CAST "jump"))
+ {
+ animation->addJump(XML::getProperty(frameNode, "action", ""));
+ }
} // for frameNode
}
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index 1ad74d744..424d88869 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -84,6 +84,7 @@ namespace SpriteAction
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 SPAWN = "spawn";
static const std::string INVALID = "";
}