From 26d8eba0ad906cd9b4a95bbd94fc1556719fd5d2 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Fri, 9 Jul 2010 15:21:50 +0200 Subject: 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 --- src/game-server/character.cpp | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'src/game-server/character.cpp') 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::iterator i = mSpecials.find(id); + if (i != mSpecials.end()) + { + delete i->second; + mSpecials.erase(i); + mSpecialUpdateNeeded = true; + } +} + +void Character::clearSpecials() +{ + for(std::map::iterator i = mSpecials.begin(); i != mSpecials.end(); i++) + { + delete i->second; + } + mSpecials.clear(); +} -- cgit