diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-04-03 13:29:05 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-04-04 16:22:11 +0200 |
commit | f8e816d9185c09d1c17d921b775e483d132982e5 (patch) | |
tree | 3ab299ab6057db3bfd8feb24130a6fcb7e64a60d /src/game-server/character.h | |
parent | e4baa92aae537921dd17873328a95ab17afcfdfc (diff) | |
download | manaserv-f8e816d9185c09d1c17d921b775e483d132982e5.tar.gz manaserv-f8e816d9185c09d1c17d921b775e483d132982e5.tar.xz manaserv-f8e816d9185c09d1c17d921b775e483d132982e5.zip |
Enhanced special support
- Made the current charge being saved.
- Added script binds:
- chr_set_special_recharge_speed
- chr_get_special_recharge_speed
- chr_set_special_mana
- chr_get_special_mana
- get_special_info
- Added special info lua class. Functions:
- name
- needed_mana
- rechargeable
- on_use
- on_recharged
- category
Further the engine no longer sets charge to 0 after using of specials
this allows more flexbilillity (like failing specials).
Changes on the xml database:
- recharge renamed to rechargeable (needed by client and server)
- needed - the needed mana to trigger a special (server only)
- rechargespeed - the defailt recharge speed in mana per tick (server only)
- target - the type of target (either being or point) (server and client)
I also made the lua engine pushing nil instead of a 0 light userdata when
the pointer was 0.
Database update needed.
Change is tested.
Mana-Mantis: #167, #156
Reviewed-by: bjorn.
Diffstat (limited to 'src/game-server/character.h')
-rw-r--r-- | src/game-server/character.h | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/src/game-server/character.h b/src/game-server/character.h index eb8e432..ec3fc73 100644 --- a/src/game-server/character.h +++ b/src/game-server/character.h @@ -24,8 +24,12 @@ #include "common/defines.h" #include "common/inventorydata.h" #include "common/manaserv_protocol.h" + #include "game-server/being.h" +#include "game-server/specialmanager.h" + #include "scripting/script.h" + #include "utils/logger.h" #include <map> @@ -39,18 +43,26 @@ class MessageOut; class Point; class Trade; -struct Special +struct SpecialValue { - Special() - : currentMana(0) - , neededMana(0) + SpecialValue(unsigned int currentMana, + const SpecialManager::SpecialInfo *specialInfo) + : currentMana(currentMana) + , rechargeSpeed(specialInfo->defaultRechargeSpeed) + , specialInfo(specialInfo) {} - int currentMana; - int neededMana; + unsigned int currentMana; + unsigned int rechargeSpeed; + const SpecialManager::SpecialInfo *specialInfo; }; /** + * Stores specials by their id. + */ +typedef std::map<unsigned int, SpecialValue> SpecialMap; + +/** * The representation of a player's character in the game world. */ class Character : public Being @@ -82,15 +94,37 @@ class Character : public Being void respawn(); /** - * makes the character perform a special action + * makes the character perform a special action on a being + * when it is allowed to do so + */ + void useSpecialOnBeing(int id, Being *b); + + /** + * makes the character perform a special action on a map point * when it is allowed to do so */ - void useSpecial(int id); + void useSpecialOnPoint(int id, int x, int y); /** * Allows a character to perform a special action */ - void giveSpecial(int id); + bool giveSpecial(int id, int currentMana = 0); + + /** + * Sets new current mana + makes sure that the client will get informed. + */ + bool setSpecialMana(int id, int mana); + + /** + * Gets the special value by id + */ + SpecialMap::iterator findSpecial(int id) + { return mSpecials.find(id); } + + /** + * Sets recharge speed of a special + */ + bool setSpecialRechargeSpeed(int id, int speed); /** * Removes all specials from character @@ -105,7 +139,7 @@ class Character : public Being /** * Removes an available special action */ - void takeSpecial(int id); + bool takeSpecial(int id); /** * Gets client computer. @@ -289,10 +323,10 @@ class Character : public Being int getSpecialSize() const { return mSpecials.size(); } - const std::map<int, Special*>::const_iterator getSpecialBegin() const + const SpecialMap::const_iterator getSpecialBegin() const { return mSpecials.begin(); } - const std::map<int, Special*>::const_iterator getSpecialEnd() const + const SpecialMap::const_iterator getSpecialEnd() const { return mSpecials.end(); } /** @@ -393,6 +427,8 @@ class Character : public Being { return BLOCKTYPE_CHARACTER; } private: + bool specialUseCheck(SpecialMap::iterator it); + double getAttrBase(AttributeMap::const_iterator it) const { return it->second.getBase(); } double getAttrMod(AttributeMap::const_iterator it) const @@ -461,11 +497,10 @@ class Character : public Being std::map<int, int> mExperience; /**< experience collected for each skill.*/ - std::map<int, Special*> mSpecials; + SpecialMap mSpecials; std::map<int, int> mStatusEffects; /**< only used by select functions to make it easier to make the accountserver do not modify or use anywhere else*/ - int mRechargePerSpecial; bool mSpecialUpdateNeeded; int mDatabaseID; /**< Character's database ID. */ |