diff options
| author | Philipp Sehmisch <mana@crushnet.org> | 2010-07-09 15:21:50 +0200 |
|---|---|---|
| committer | Philipp Sehmisch <mana@crushnet.org> | 2010-07-09 15:22:11 +0200 |
| commit | 26d8eba0ad906cd9b4a95bbd94fc1556719fd5d2 (patch) | |
| tree | 6d7ea0ebe8be228a61315f72122eed3f2f995a0b /src/game-server/character.cpp | |
| parent | 2627acefebc688d9d9733abe23ba5aae79f66ea0 (diff) | |
| download | manaserv-26d8eba0ad906cd9b4a95bbd94fc1556719fd5d2.tar.gz manaserv-26d8eba0ad906cd9b4a95bbd94fc1556719fd5d2.tar.xz manaserv-26d8eba0ad906cd9b4a95bbd94fc1556719fd5d2.zip | |
Added LUA script bindings for manipulating the specials available to a character.
Added script call for getting the cost of a special (recharge only for now)
Deleting specials works server-sided but the client isn't informed about it properly. Specials without recharge cost don't appear for the player. Both of these features require an additional netcode message.
Reviewed-by: Freeyorp
Diffstat (limited to 'src/game-server/character.cpp')
| -rw-r--r-- | src/game-server/character.cpp | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index 258a702..46ffa05 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -232,14 +232,7 @@ void Character::useSpecial(int id) //tell script engine to cast the spell special->currentMana = 0; - Script *script = getMap()->getScript(); - if (script) { - script->prepare("cast"); - script->push(this); - script->push(id); - script->execute(); - } - + Script::perform_special_action(id, this); mSpecialUpdateNeeded = true; return; } @@ -661,14 +654,29 @@ void Character::giveSpecial(int id) { if (mSpecials.find(id) == mSpecials.end()) { - // TODO: get the needed mana from a SpecialDB - int neededMana; - if (id == 1) neededMana = 10; - if (id == 2) neededMana = 100; - if (id == 3) neededMana = 1000; - - Special *s = new Special(neededMana); + Special *s = new Special(); + Script::addDataToSpecial(id, s); mSpecials[id] = s; mSpecialUpdateNeeded = true; } } + +void Character::takeSpecial(int id) +{ + std::map<int, Special*>::iterator i = mSpecials.find(id); + if (i != mSpecials.end()) + { + delete i->second; + mSpecials.erase(i); + mSpecialUpdateNeeded = true; + } +} + +void Character::clearSpecials() +{ + for(std::map<int, Special*>::iterator i = mSpecials.begin(); i != mSpecials.end(); i++) + { + delete i->second; + } + mSpecials.clear(); +} |
