diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-04-13 22:48:28 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-04-16 17:42:45 -0600 |
commit | 11a6f342e579c26320334b9ae9735701386e3b25 (patch) | |
tree | 5de9a3647f881a1f27f4dc31054ad086bdc86d84 /src/monster.cpp | |
parent | 9f6c1f0bd9d2ef9a3be35fee2c488d8ea6c09d6d (diff) | |
download | mana-11a6f342e579c26320334b9ae9735701386e3b25.tar.gz mana-11a6f342e579c26320334b9ae9735701386e3b25.tar.bz2 mana-11a6f342e579c26320334b9ae9735701386e3b25.tar.xz mana-11a6f342e579c26320334b9ae9735701386e3b25.zip |
Add race support for eAthena
The job/class field is used to select the race. If the given race isn't defined,
it falls back on the first race (so servers can use jobs/classes without races).
Also rename job to subtype for Being and subclasses, and begin support for
changing monster and NPC subtypes on the fly (particle effects still need to be
reset when they change).
Reviewed-by: Bertram
Diffstat (limited to 'src/monster.cpp')
-rw-r--r-- | src/monster.cpp | 69 |
1 files changed, 39 insertions, 30 deletions
diff --git a/src/monster.cpp b/src/monster.cpp index 23be9395..0876b08d 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -35,37 +35,11 @@ #include "resources/monsterdb.h" #include "resources/monsterinfo.h" -Monster::Monster(int id, int job, Map *map): - Being(id, job, map), +Monster::Monster(int id, int subtype, Map *map): + Being(id, subtype, map), mAttackType(1) { - const MonsterInfo &info = getInfo(); - - // Setup Monster sprites - const std::list<std::string> &sprites = info.getSprites(); - - for (std::list<std::string>::const_iterator i = sprites.begin(); - i != sprites.end(); i++) - { - std::string file = "graphics/sprites/" + *i; - mSprites.push_back(AnimatedSprite::load(file)); - } - - // Ensure that something is shown - if (mSprites.size() == 0) - { - mSprites.push_back(AnimatedSprite::load("graphics/sprites/error.xml")); - } - - if (Particle::enabled) - { - const std::list<std::string> &particleEffects = info.getParticleEffects(); - for (std::list<std::string>::const_iterator i = particleEffects.begin(); - i != particleEffects.end(); i++) - { - controlParticle(particleEngine->addEffect((*i), 0, 0)); - } - } + setSubtype(subtype); mNameColor = &userPalette->getColor(UserPalette::MONSTER); mTextColor = &userPalette->getColor(UserPalette::MONSTER); @@ -86,6 +60,7 @@ void Monster::logic() Being::logic(); } + void Monster::setAction(Action action, int attackType) { SpriteAction currentAction = ACTION_INVALID; @@ -144,6 +119,40 @@ void Monster::setAction(Action action, int attackType) } } +void Monster::setSubtype(Uint16 subtype) +{ + Being::setSubtype(subtype); + + const MonsterInfo &info = getInfo(); + + // Setup Monster sprites + const std::list<std::string> &sprites = info.getSprites(); + + mSprites.clear(); + for (std::list<std::string>::const_iterator i = sprites.begin(); + i != sprites.end(); i++) + { + std::string file = "graphics/sprites/" + *i; + mSprites.push_back(AnimatedSprite::load(file)); + } + + // Ensure that something is shown + if (mSprites.size() == 0) + { + mSprites.push_back(AnimatedSprite::load("graphics/sprites/error.xml")); + } + + if (Particle::enabled) + { + const std::list<std::string> &particleEffects = info.getParticleEffects(); + for (std::list<std::string>::const_iterator i = particleEffects.begin(); + i != particleEffects.end(); i++) + { + controlParticle(particleEngine->addEffect((*i), 0, 0)); + } + } +} + void Monster::handleAttack(Being *victim, int damage, AttackType type) { Being::handleAttack(victim, damage, type); @@ -170,7 +179,7 @@ Being::TargetCursorSize Monster::getTargetCursorSize() const const MonsterInfo &Monster::getInfo() const { - return MonsterDB::get(mJob); + return MonsterDB::get(mSubType); } void Monster::updateCoords() |