diff options
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | The Mana World.dev | 12 | ||||
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/being.cpp | 64 | ||||
-rw-r--r-- | src/being.h | 25 | ||||
-rw-r--r-- | src/localplayer.cpp | 15 | ||||
-rw-r--r-- | src/monster.cpp | 4 | ||||
-rw-r--r-- | src/net/beinghandler.cpp | 17 | ||||
-rw-r--r-- | src/net/charserverhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/equipmenthandler.cpp | 9 | ||||
-rw-r--r-- | src/player.cpp | 44 | ||||
-rw-r--r-- | src/player.h | 3 | ||||
-rw-r--r-- | src/resources/equipmentdb.cpp | 46 | ||||
-rw-r--r-- | src/resources/equipmentinfo.h | 34 | ||||
-rw-r--r-- | src/resources/monsterdb.cpp | 8 | ||||
-rw-r--r-- | src/resources/monsterinfo.cpp | 6 | ||||
-rw-r--r-- | src/resources/monsterinfo.h | 16 | ||||
-rw-r--r-- | tmw.cbp | 4 |
19 files changed, 155 insertions, 174 deletions
@@ -1,4 +1,20 @@ -2007-07-11 Bjørn Lindeijer <bjorn@lindeijer.nl> +2007-07-11 Philipp Sehmisch <tmw@crushnet.org> + + * src/resources/monsterdb.cpp, src/resources/monsterinfo.cpp, + src/resources/monsterinfo.h, src/monster.cpp: Renamed SoundEvent + to MonsterSoundEvent. + * src/resources/equipmentdb.cpp, src/resources/equipmentinfo.cpp, + src/resources/equipmentinfo.h: EquipmentDB now holds the type of + attack animation and the sounds of weapons. + * src/being.cpp. src/being.h, src/localplayer.cpp, + src/net/beinghandler.cpp, src/net/charserverhandler.cpp, + src/net/equipmenthandler.cpp, src/player.cpp, src/player.h: The + type of weapon player characters are using is now set using + setVisibleEquipment() instead of setWeapon() or setWeaponById(). + * src/CMakeLists.txt, src/Makefile.AM, tmw.cbp, The Mana World.dev: + Updated project files and buildscripts. + +2007-07-11 Bjørn Lindeijer <bjorn@lindeijer.nl> * src/gui/window.cpp: Fixed resizing windows by their resize grip. diff --git a/The Mana World.dev b/The Mana World.dev index 55e8512b..963e5c7c 100644 --- a/The Mana World.dev +++ b/The Mana World.dev @@ -1,7 +1,7 @@ [Project] FileName=The Mana World.dev Name=tmw -UnitCount=277 +UnitCount=278 Type=0 Ver=1 ObjFiles= @@ -2827,3 +2827,13 @@ Priority=1000 OverrideBuildCmd=0 BuildCmd= +[Unit278] +FileName=src\resources\equipmentinfo.cpp +CompileCpp=1 +Folder=tmw +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3585e938..e4c7bba9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -219,6 +219,7 @@ SET(SRCS resources/animation.h resources/equipmentdb.cpp resources/equipmentdb.h + resources/equipmentinfo.cpp resources/equipmentinfo.h resources/image.cpp resources/image.h diff --git a/src/Makefile.am b/src/Makefile.am index 207689cb..4f524373 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -168,6 +168,7 @@ tmw_SOURCES = gui/widgets/resizegrip.cpp \ resources/animation.h \ resources/equipmentdb.cpp \ resources/equipmentdb.h \ + resources/equipmentinfo.cpp \ resources/equipmentinfo.h \ resources/image.cpp \ resources/image.h \ diff --git a/src/being.cpp b/src/being.cpp index 0ddceb0f..5d30614c 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -32,14 +32,12 @@ #include "map.h" #include "particle.h" +#include "resources/equipmentdb.h" #include "resources/resourcemanager.h" #include "resources/imageset.h" #include "gui/gui.h" -#include "resources/resourcemanager.h" -#include "resources/imageset.h" - #include "utils/dtor.h" #include "utils/tostring.h" @@ -55,10 +53,10 @@ Being::Being(Uint32 id, Uint16 job, Map *map): mAttackSpeed(350), mEquipment(new Equipment()), mId(id), - mWeapon(0), mWalkSpeed(150), mDirection(DOWN), mMap(NULL), + mEquippedWeapon(NULL), mHairStyle(0), mHairColor(0), mSex(2), mSpeechTime(0), @@ -244,20 +242,12 @@ Being::setAction(Uint8 action) currentAction = ACTION_SIT; break; case ATTACK: - switch (getWeapon()) + if (mEquippedWeapon) { - case 3: - currentAction = ACTION_ATTACK; - break; - case 2: - currentAction = ACTION_ATTACK_BOW; - break; - case 1: - currentAction = ACTION_ATTACK_STAB; - break; - case 0: - currentAction = ACTION_ATTACK; - break; + currentAction = mEquippedWeapon->getAttackType(); + } + else { + currentAction = ACTION_ATTACK; } for (int i = 0; i < VECTOREND_SPRITE; i++) { @@ -455,46 +445,6 @@ Being::getType() const return UNKNOWN; } -void -Being::setWeaponById(Uint16 weapon) -{ - //TODO: Use an external file to map weapon IDs to weapon types - switch (weapon) - { - case 529: // iron arrows - case 1199: // arrows - break; - - case 623: //scythe - setWeapon(3); - break; - - case 1200: // bow - case 530: // short bow - case 545: // forest bow - setWeapon(2); - break; - - case 521: // sharp knife - /* UNCOMMENT TO TEST SHARP KNIFE AS SCYTHE - * setWeapon(3) - * break; - */ - case 522: // dagger - case 536: // short sword - case 1201: // knife - setWeapon(1); - break; - - case 0: // unequip - setWeapon(0); - break; - - default: - logger->log("Not a weapon: %d", weapon); - } -} - int Being::getOffset(char pos, char neg) const { diff --git a/src/being.h b/src/being.h index cdae05dc..f0c263b0 100644 --- a/src/being.h +++ b/src/being.h @@ -38,6 +38,7 @@ class AnimatedSprite; class Equipment; +class EquipmentInfo; class Item; class Map; class Graphics; @@ -258,27 +259,6 @@ class Being : public Sprite virtual Type getType() const; /** - * Gets the weapon picture id. - */ - Uint16 getWeapon() const { return mWeapon; } - - /** - * Sets the weapon picture id. - * - * @param weapon the picture id - */ - virtual void - setWeapon(Uint16 weapon) { mWeapon = weapon; } - - /** - * Sets the weapon picture id with the weapon id. - * - * @param weapon the weapon id - */ - void - setWeaponById(Uint16 weapon); - - /** * Gets the walk speed. */ Uint16 @@ -404,13 +384,14 @@ class Being : public Sprite getSpriteDirection() const; Uint32 mId; /**< Unique sprite id */ - Uint16 mWeapon; /**< Weapon picture id */ Uint16 mWalkSpeed; /**< Walking speed */ Uint8 mDirection; /**< Facing direction */ Map *mMap; /**< Map on which this being resides */ std::string mName; /**< Name of character */ SpriteIterator mSpriteIterator; + EquipmentInfo* mEquippedWeapon; /**< Engine-related infos about weapon */ + Path mPath; std::string mSpeech; Uint16 mHairStyle, mHairColor; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 24976c0a..cc270296 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -34,6 +34,8 @@ #include "net/messageout.h" #include "net/protocol.h" +#include "resources/equipmentinfo.h" + LocalPlayer *player_node = NULL; LocalPlayer::LocalPlayer(Uint32 id, Uint16 job, Map *map): @@ -61,7 +63,8 @@ void LocalPlayer::logic() case ATTACK: int frames = 4; - if (getWeapon() == 2) + if ( mEquippedWeapon + && mEquippedWeapon->getAttackType() == ACTION_ATTACK_BOW) { frames = 5; } @@ -392,10 +395,14 @@ void LocalPlayer::attack(Being *target, bool keep) setAction(ATTACK); mWalkTime = tick_time; - if (getWeapon() == 2) - sound.playSfx("sfx/bow_shoot_1.ogg"); - else + if (mEquippedWeapon) + { + std::string soundFile = mEquippedWeapon->getSound(EQUIP_EVENT_STRIKE); + if (soundFile != "") sound.playSfx(soundFile); + } + else { sound.playSfx("sfx/fist-swish.ogg"); + } MessageOut outMsg(mNetwork); outMsg.writeInt16(0x0089); diff --git a/src/monster.cpp b/src/monster.cpp index 687fe625..00e58648 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -73,7 +73,7 @@ Monster::setAction(Uint8 action) break; case DEAD: currentAction = ACTION_DEAD; - sound.playSfx(getInfo().getSound(EVENT_DIE)); + sound.playSfx(getInfo().getSound(MONSTER_EVENT_DIE)); break; case ATTACK: currentAction = ACTION_ATTACK; @@ -100,7 +100,7 @@ Monster::handleAttack(Being *victim, int damage) Being::handleAttack(victim, damage); const MonsterInfo &mi = getInfo(); - sound.playSfx(mi.getSound((damage > 0) ? EVENT_HIT : EVENT_MISS)); + sound.playSfx(mi.getSound((damage > 0) ? MONSTER_EVENT_HIT : MONSTER_EVENT_MISS)); } Being::TargetCursorSize diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index fc202b36..3bec6369 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -107,7 +107,7 @@ void BeingHandler::handleMessage(MessageIn *msg) dstBeing->setWalkSpeed(speed); dstBeing->mJob = job; dstBeing->setHairStyle(msg->readInt16()); - dstBeing->setWeapon(msg->readInt16()); + dstBeing->setVisibleEquipment(Being::WEAPON_SPRITE, msg->readInt16() * 10000); dstBeing->setVisibleEquipment( Being::BOTTOMCLOTHES_SPRITE, msg->readInt16()); @@ -257,22 +257,20 @@ void BeingHandler::handleMessage(MessageIn *msg) dstBeing->setHairStyle(id); break; case 2: - dstBeing->setWeapon(id); + dstBeing->setVisibleEquipment( + Being::WEAPON_SPRITE, id * 10000); break; case 3: // Change lower headgear for eAthena, pants for us dstBeing->setVisibleEquipment( - Being::BOTTOMCLOTHES_SPRITE, - id); + Being::BOTTOMCLOTHES_SPRITE, id); break; case 4: // Change upper headgear for eAthena, hat for us dstBeing->setVisibleEquipment( - Being::HAT_SPRITE, - id); + Being::HAT_SPRITE, id); break; case 5: // Change middle headgear for eathena, armor for us dstBeing->setVisibleEquipment( - Being::TOPCLOTHES_SPRITE, - id); + Being::TOPCLOTHES_SPRITE, id); break; case 6: dstBeing->setHairColor(id); @@ -312,7 +310,8 @@ void BeingHandler::handleMessage(MessageIn *msg) dstBeing->setWalkSpeed(speed); dstBeing->mJob = job; dstBeing->setHairStyle(msg->readInt16()); - dstBeing->setWeaponById(msg->readInt16()); // item id 1 + dstBeing->setVisibleEquipment( + Being::WEAPON_SPRITE, msg->readInt16()); msg->readInt16(); // item id 2 headBottom = msg->readInt16(); diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index a54a17de..6d4149ec 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -206,7 +206,7 @@ LocalPlayer* CharServerHandler::readPlayerData(MessageIn &msg, int &slot) Uint16 weapon = msg.readInt16(); if (weapon == 11) weapon = 2; - tempPlayer->setWeapon(weapon); + tempPlayer->setVisibleEquipment(Being::WEAPON_SPRITE, weapon * 10000); tempPlayer->mLevel = msg.readInt16(); msg.readInt16(); // skill point tempPlayer->setVisibleEquipment(Being::BOTTOMCLOTHES_SPRITE, msg.readInt16()); // head bottom diff --git a/src/net/equipmenthandler.cpp b/src/net/equipmenthandler.cpp index 74ce95f3..579b6ed3 100644 --- a/src/net/equipmenthandler.cpp +++ b/src/net/equipmenthandler.cpp @@ -125,7 +125,8 @@ void EquipmentHandler::handleMessage(MessageIn *msg) item = player_node->getInvItem(index); player_node->mEquipment->setEquipment(position, item); - player_node->setWeaponById(item->getId()); + player_node->setVisibleEquipment( + Being::WEAPON_SPRITE, item->getId()); break; case 0x01d7: @@ -138,7 +139,7 @@ void EquipmentHandler::handleMessage(MessageIn *msg) if (!being) break; - being->setWeaponById(itemId); + being->setVisibleEquipment(Being::WEAPON_SPRITE, itemId); break; case SMSG_PLAYER_UNEQUIP: @@ -181,7 +182,7 @@ void EquipmentHandler::handleMessage(MessageIn *msg) case 536: case 1200: case 1201: - player_node->setWeapon(0); + player_node->setVisibleEquipment(Being::WEAPON_SPRITE, 0); // TODO: Why this break? Shouldn't a weapon be // unequipped in inventory too? break; @@ -192,7 +193,7 @@ void EquipmentHandler::handleMessage(MessageIn *msg) logger->log("Unequipping: %i %i(%i) %i", index, equipPoint, type, position); break; - + case SMSG_PLAYER_ATTACK_RANGE: player_node->setAttackRange(msg->readInt16()); break; diff --git a/src/player.cpp b/src/player.cpp index ad19fe06..de3bc760 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -36,7 +36,6 @@ Player::Player(Uint32 id, Uint16 job, Map *map): Being(id, job, map) { - setWeapon(0); } void @@ -52,7 +51,8 @@ Player::logic() case ATTACK: int frames = 4; - if (getWeapon() == 2) + if ( mEquippedWeapon + && mEquippedWeapon->getAttackType() == ACTION_ATTACK_BOW) { frames = 5; } @@ -120,41 +120,6 @@ Player::setSex(Uint8 sex) Being::setSex(sex); } - -void -Player::setWeapon(Uint16 weapon) -{ - if (weapon != mWeapon) - { - AnimatedSprite *newWeaponSprite = NULL; - - switch (weapon) - { - case 0: - newWeaponSprite = - new AnimatedSprite("graphics/sprites/weapon-fist.xml"); - break; - case 1: - newWeaponSprite = - new AnimatedSprite("graphics/sprites/weapon-dagger.xml"); - break; - case 2: - newWeaponSprite = - new AnimatedSprite("graphics/sprites/weapon-bow.xml"); - break; - case 3: - newWeaponSprite = - new AnimatedSprite("graphics/sprites/weapon-scythe.xml"); - break; - } - - delete mSprites[WEAPON_SPRITE]; - mSprites[WEAPON_SPRITE] = newWeaponSprite; - } - Being::setWeapon(weapon); -} - - void Player::setHairColor(Uint16 color) { @@ -221,6 +186,11 @@ Player::setVisibleEquipment(Uint8 slot, int id) delete mSprites[slot]; mSprites[slot] = equipmentSprite; + if (slot == WEAPON_SPRITE) + { + mEquippedWeapon = EquipmentDB::get(id); + } + setAction(mAction); } diff --git a/src/player.h b/src/player.h index 4a9bed08..90d8e5a9 100644 --- a/src/player.h +++ b/src/player.h @@ -59,9 +59,6 @@ class Player : public Being virtual void setVisibleEquipment(Uint8 slot, int id); - - virtual void - setWeapon(Uint16 weapon); }; #endif diff --git a/src/resources/equipmentdb.cpp b/src/resources/equipmentdb.cpp index 64982ce3..9b963720 100644 --- a/src/resources/equipmentdb.cpp +++ b/src/resources/equipmentdb.cpp @@ -81,26 +81,46 @@ EquipmentDB::load() EquipmentInfo *currentInfo = new EquipmentInfo();
currentInfo->setSlot (XML::getProperty(equipmentNode, "slot", 0));
+ currentInfo->setAttackType (XML::getProperty(equipmentNode, "attacktype", ""));
- //iterate <sprite>s
+ //iterate <sprite>s and <sound>s
for_each_xml_child_node(spriteNode, equipmentNode)
{
- if (!xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
+ if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
{
- continue;
+ std::string gender = XML::getProperty(spriteNode, "gender", "unisex");
+ std::string filename = (const char*) spriteNode->xmlChildrenNode->content;
+
+ if (gender == "male" || gender == "unisex")
+ {
+ currentInfo->setSprite(filename, 0);
+ }
+
+ if (gender == "female" || gender == "unisex")
+ {
+ currentInfo->setSprite(filename, 1);
+ }
}
- std::string gender = XML::getProperty(spriteNode, "gender", "unisex");
- std::string filename = (const char*) spriteNode->xmlChildrenNode->content;
-
- if (gender == "male" || gender == "unisex")
- {
- currentInfo->setSprite(filename, 0);
- }
-
- if (gender == "female" || gender == "unisex")
+ if (xmlStrEqual(spriteNode->name, BAD_CAST "sound"))
{
- currentInfo->setSprite(filename, 1);
+ std::string event = XML::getProperty(spriteNode, "event", "");
+ const char *filename;
+ filename = (const char*) spriteNode->xmlChildrenNode->content;
+
+ if (event == "hit")
+ {
+ currentInfo->addSound(EQUIP_EVENT_HIT, filename);
+ }
+ else if (event == "strike")
+ {
+ currentInfo->addSound(EQUIP_EVENT_STRIKE, filename);
+ }
+ else
+ {
+ logger->log("EquipmentDB: Warning, sound effect %s for unknown event %s",
+ filename, event.c_str());
+ }
}
}
diff --git a/src/resources/equipmentinfo.h b/src/resources/equipmentinfo.h index 93a1cb42..5cd0643b 100644 --- a/src/resources/equipmentinfo.h +++ b/src/resources/equipmentinfo.h @@ -24,29 +24,53 @@ #ifndef _TMW_EQUIPMENTINFO_H_
#define _TMW_EQUIPMENTINFO_H_
-#include <string>
#include <map>
+#include <string>
+#include <vector>
+
+#include "spritedef.h"
+
+enum EquipmentSoundEvent
+{
+ EQUIP_EVENT_STRIKE,
+ EQUIP_EVENT_HIT
+};
class EquipmentInfo
{
public:
EquipmentInfo():
- mSlot (0)
+ mSlot (0),
+ mAttackType(ACTION_DEFAULT)
{
};
void
- setSlot (int slot) { mSlot = slot; };
+ setSlot (int slot) { mSlot = slot; }
const std::string&
- getSprite(int gender) {return animationFiles[gender]; };
+ getSprite(int gender) {return animationFiles[gender]; }
void
- setSprite(std::string animationFile, int gender) {animationFiles[gender] = animationFile; };
+ setSprite(std::string animationFile, int gender) {animationFiles[gender] = animationFile; }
+
+ void
+ setAttackType(std::string attackType);
+
+ const SpriteAction
+ getAttackType() { return mAttackType; }
+
+ void
+ addSound(EquipmentSoundEvent event, std::string filename);
+
+ std::string
+ getSound(EquipmentSoundEvent event) const;
private:
int mSlot; //not used at the moment but maybe useful on our own server
+ SpriteAction mAttackType;
std::map<int, std::string> animationFiles;
+ std::map<EquipmentSoundEvent, std::vector<std::string>* > mSounds;
};
#endif
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 89afc549..2ea9aebe 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -120,19 +120,19 @@ MonsterDB::load() if (event == "hit")
{
- currentInfo->addSound(EVENT_HIT, filename);
+ currentInfo->addSound(MONSTER_EVENT_HIT, filename);
}
else if (event == "miss")
{
- currentInfo->addSound(EVENT_MISS, filename);
+ currentInfo->addSound(MONSTER_EVENT_MISS, filename);
}
else if (event == "hurt")
{
- currentInfo->addSound(EVENT_HURT, filename);
+ currentInfo->addSound(MONSTER_EVENT_HURT, filename);
}
else if (event == "die")
{
- currentInfo->addSound(EVENT_DIE, filename);
+ currentInfo->addSound(MONSTER_EVENT_DIE, filename);
}
else
{
diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp index 43aac32a..b5fe3d29 100644 --- a/src/resources/monsterinfo.cpp +++ b/src/resources/monsterinfo.cpp @@ -41,7 +41,7 @@ MonsterInfo::~MonsterInfo() void
-MonsterInfo::addSound (SoundEvent event, std::string filename)
+MonsterInfo::addSound (MonsterSoundEvent event, std::string filename)
{
if (mSounds.find(event) == mSounds.end())
{
@@ -53,9 +53,9 @@ MonsterInfo::addSound (SoundEvent event, std::string filename) std::string
-MonsterInfo::getSound (SoundEvent event) const
+MonsterInfo::getSound (MonsterSoundEvent event) const
{
- std::map<SoundEvent, std::vector<std::string>* >::const_iterator i;
+ std::map<MonsterSoundEvent, std::vector<std::string>* >::const_iterator i;
i = mSounds.find(event);
diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h index 5a820659..7613fee2 100644 --- a/src/resources/monsterinfo.h +++ b/src/resources/monsterinfo.h @@ -31,12 +31,12 @@ #include "../being.h" -enum SoundEvent +enum MonsterSoundEvent { - EVENT_HIT, - EVENT_MISS, - EVENT_HURT, - EVENT_DIE + MONSTER_EVENT_HIT, + MONSTER_EVENT_MISS, + MONSTER_EVENT_HURT, + MONSTER_EVENT_DIE }; /** @@ -69,7 +69,7 @@ class MonsterInfo { mTargetCursorSize = targetCursorSize; } void - addSound(SoundEvent event, std::string filename); + addSound(MonsterSoundEvent event, std::string filename); const std::string& getName() const { return mName; } @@ -81,13 +81,13 @@ class MonsterInfo getTargetCursorSize() const { return mTargetCursorSize; } std::string - getSound(SoundEvent event) const; + getSound(MonsterSoundEvent event) const; private: std::string mName; std::string mSprite; Being::TargetCursorSize mTargetCursorSize; - std::map<SoundEvent, std::vector<std::string>* > mSounds; + std::map<MonsterSoundEvent, std::vector<std::string>* > mSounds; }; #endif @@ -1143,6 +1143,10 @@ <Option link="0"/> <Option target="default"/> </Unit> + <Unit filename="src\resources\equipmentinfo.cpp"> + <Option compilerVar="CPP"/> + <Option target="default"/> + </Unit> <Unit filename="src\resources\equipmentinfo.h"> <Option compilerVar=""/> <Option compile="0"/> |