diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-03-30 09:29:08 +0100 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-04-02 13:19:11 +0200 |
commit | 585a33e221a7ee392791f4fd5a5ec9214b8fe868 (patch) | |
tree | 3aa60a57ff7cdd8f57761d620352fd2ad4d0dd6f /src/scripting | |
parent | 4dfc82415691fe298f21bb2f81fed5c168ee14e5 (diff) | |
download | manaserv-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/scripting')
-rw-r--r-- | src/scripting/lua.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index d443899..cbdb088 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -33,6 +33,7 @@ extern "C" { #include "game-server/buysell.h" #include "game-server/character.h" #include "game-server/collisiondetection.h" +#include "game-server/combatcomponent.h" #include "game-server/effect.h" #include "game-server/gamehandler.h" #include "game-server/inventory.h" @@ -1417,7 +1418,7 @@ static int being_damage(lua_State *s) { dmg.skill = checkSkill(s, 8); } - being->damage(source, dmg); + being->getComponent<CombatComponent>()->damage(*being, source, dmg); return 0; } @@ -1692,7 +1693,7 @@ static int being_get_base_attribute(lua_State *s) int attr = luaL_checkint(s, 2); luaL_argcheck(s, attr > 0, 2, "invalid attribute id"); - lua_pushinteger(s, being->getAttribute(attr)); + lua_pushinteger(s, being->getAttributeBase(attr)); return 1; } |