diff options
author | Chuck Miller <shadowmil@gmail.com> | 2010-02-10 23:46:49 -0500 |
---|---|---|
committer | Chuck Miller <shadowmil@gmail.com> | 2010-02-10 23:50:23 -0500 |
commit | 85e7f2a79477712bf3082cb82e6a73c51361abb0 (patch) | |
tree | c8a42adb06e0c5ba416bd30fcd1808c1e4f26ddc /src/resources | |
parent | 3a761a242436e521c7fa8ef3746551ac7b746308 (diff) | |
download | Mana-85e7f2a79477712bf3082cb82e6a73c51361abb0.tar.gz Mana-85e7f2a79477712bf3082cb82e6a73c51361abb0.tar.bz2 Mana-85e7f2a79477712bf3082cb82e6a73c51361abb0.tar.xz Mana-85e7f2a79477712bf3082cb82e6a73c51361abb0.zip |
Adds missile-particle attribute to items and monster attacks
To use simply add something like: missile-particle="graphics/particles/arrow.particle.xml"
to the item's or monster's xml entry
This will only work on equipped weapons, and on specified monster attacks.
This patch also fixes a memory leak with target particles
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/itemdb.cpp | 2 | ||||
-rw-r--r-- | src/resources/iteminfo.h | 8 | ||||
-rw-r--r-- | src/resources/monsterdb.cpp | 4 | ||||
-rw-r--r-- | src/resources/monsterinfo.cpp | 12 | ||||
-rw-r--r-- | src/resources/monsterinfo.h | 6 |
5 files changed, 29 insertions, 3 deletions
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 0cb18e76..c215e942 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -150,6 +150,7 @@ void ItemDB::load() std::string description = XML::getProperty(node, "description", ""); int weaponType = weaponTypeFromString(XML::getProperty(node, "weapon-type", "")); int attackRange = XML::getProperty(node, "attack-range", 0); + std::string missileParticle = XML::getProperty(node, "missile-particle", ""); ItemInfo *itemInfo = new ItemInfo; itemInfo->setId(id); @@ -161,6 +162,7 @@ void ItemDB::load() itemInfo->setWeight(weight); itemInfo->setWeaponType(weaponType); itemInfo->setAttackRange(attackRange); + itemInfo->setMissileParticle(missileParticle); std::string effect; for (int i = 0; i < int(sizeof(fields) / sizeof(fields[0])); ++i) diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 88cdcd85..796382cd 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -180,6 +180,11 @@ class ItemInfo void setWeaponType(int); + // Handlers for seting and getting the string used for particles when attacking + void setMissileParticle(std::string s) { mMissileParticle = s; } + + std::string getMissileParticle() const { return mMissileParticle; } + SpriteAction getAttackType() const { return mAttackType; } @@ -208,6 +213,9 @@ class ItemInfo SpriteAction mAttackType; /**< Attack type, in case of weapon. */ int mAttackRange; /**< Attack range, will be zero if non weapon. */ + // Particle to be shown when weapon attacks + std::string mMissileParticle; + /** Maps gender to sprite filenames. */ std::map<int, std::string> mAnimationFiles; diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 5ccb5dd1..dffac5f5 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -133,7 +133,9 @@ void MonsterDB::load() spriteNode, "particle-effect", ""); SpriteAction spriteAction = SpriteDef::makeSpriteAction( XML::getProperty(spriteNode, "action", "attack")); - currentInfo->addMonsterAttack(id, particleEffect, spriteAction); + const std::string missileParticle = XML::getProperty( + spriteNode, "missile-particle", ""); + currentInfo->addMonsterAttack(id, particleEffect, spriteAction, missileParticle); } else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx")) { diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp index 2d788a72..fbb93ec1 100644 --- a/src/resources/monsterinfo.cpp +++ b/src/resources/monsterinfo.cpp @@ -62,6 +62,14 @@ const std::string &MonsterInfo::getAttackParticleEffect(int attackType) const return (i == mMonsterAttacks.end()) ? empty : (*i).second->particleEffect; } +const std::string &MonsterInfo::getAttackMissileParticle(int attackType) const +{ + static std::string empty(""); + std::map<int, MonsterAttack*>::const_iterator i = + mMonsterAttacks.find(attackType); + return (i == mMonsterAttacks.end()) ? empty : (*i).second->missileParticle; +} + SpriteAction MonsterInfo::getAttackAction(int attackType) const { std::map<int, MonsterAttack*>::const_iterator i = @@ -71,10 +79,12 @@ SpriteAction MonsterInfo::getAttackAction(int attackType) const void MonsterInfo::addMonsterAttack(int id, const std::string &particleEffect, - SpriteAction action) + SpriteAction action, + const std::string &missileParticle) { MonsterAttack *a = new MonsterAttack; a->particleEffect = particleEffect; + a->missileParticle = missileParticle; a->action = action; mMonsterAttacks[id] = a; } diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h index f6cec609..4e92ad02 100644 --- a/src/resources/monsterinfo.h +++ b/src/resources/monsterinfo.h @@ -39,6 +39,7 @@ enum MonsterSoundEvent struct MonsterAttack { + std::string missileParticle; std::string particleEffect; SpriteAction action; }; @@ -81,10 +82,13 @@ class MonsterInfo void addMonsterAttack(int id, const std::string &particleEffect, - SpriteAction action); + SpriteAction action, + const std::string &missileParticle); const std::string &getAttackParticleEffect(int attackType) const; + const std::string &getAttackMissileParticle(int attackType) const; + SpriteAction getAttackAction(int attackType) const; const std::list<std::string>& getParticleEffects() const |