summaryrefslogtreecommitdiffstats
path: root/src/game-server/item.cpp
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-03-30 09:29:08 +0100
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-04-02 13:19:11 +0200
commit585a33e221a7ee392791f4fd5a5ec9214b8fe868 (patch)
tree3aa60a57ff7cdd8f57761d620352fd2ad4d0dd6f /src/game-server/item.cpp
parent4dfc82415691fe298f21bb2f81fed5c168ee14e5 (diff)
downloadmanaserv-585a33e221a7ee392791f4fd5a5ec9214b8fe868.tar.gz
manaserv-585a33e221a7ee392791f4fd5a5ec9214b8fe868.tar.xz
manaserv-585a33e221a7ee392791f4fd5a5ec9214b8fe868.zip
Moved fighting code into a component
All damage dealing is now handeled via CombatComponent. Monsters use a derived MonsterCombatComponent since they can have a damage mutation and have a seperate script callback. The wirering with Being is still not optional since most of the stuff does not exist as components. Things done: - Seperated the fighting code from Being and only let Characters and Monsters add the Component (less overhead for npcs) - Added a getter for Attribute values to prevent searching it all the time in non Being members - Fixed the type if the damage mutation to double (no idea why it was int) I did not want to copy it over incorrectly - Removed the addAttack/removeAttack overrides in Character and made the knuckleAttack being added based on newly added signals Future TODOS: - Remove depedency on Being as soon all needed dependencies are available as components of Entity - Move the monster script callback into the general combatcomponent and make it usuable for characters too
Diffstat (limited to 'src/game-server/item.cpp')
-rw-r--r--src/game-server/item.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/game-server/item.cpp b/src/game-server/item.cpp
index b7b0d78..7295b95 100644
--- a/src/game-server/item.cpp
+++ b/src/game-server/item.cpp
@@ -25,6 +25,7 @@
#include "game-server/attack.h"
#include "game-server/attributemanager.h"
#include "game-server/being.h"
+#include "game-server/combatcomponent.h"
#include "game-server/state.h"
#include "scripting/script.h"
#include "scripting/scriptmanager.h"
@@ -49,13 +50,13 @@ void ItemEffectAttrMod::dispell(Being *itemUser)
bool ItemEffectAttack::apply(Being *itemUser)
{
- itemUser->addAttack(mAttackInfo);
+ itemUser->getComponent<CombatComponent>()->addAttack(mAttackInfo);
return false;
}
void ItemEffectAttack::dispell(Being *itemUser)
{
- itemUser->removeAttack(mAttackInfo);
+ itemUser->getComponent<CombatComponent>()->removeAttack(mAttackInfo);
}
ItemEffectScript::~ItemEffectScript()