diff options
author | Freeyorp <Freeyorp101@hotmail.com> | 2010-05-17 20:55:06 +1200 |
---|---|---|
committer | Freeyorp <Freeyorp101@hotmail.com> | 2010-07-10 21:51:07 +1200 |
commit | 98cdcb1de4f422255aa5ef924042ae7d00a5b968 (patch) | |
tree | 1746776580502fb007581f171fa89638ab6bc64f /src/game-server/being.hpp | |
parent | 26d8eba0ad906cd9b4a95bbd94fc1556719fd5d2 (diff) | |
download | manaserv-98cdcb1de4f422255aa5ef924042ae7d00a5b968.tar.gz manaserv-98cdcb1de4f422255aa5ef924042ae7d00a5b968.tar.xz manaserv-98cdcb1de4f422255aa5ef924042ae7d00a5b968.zip |
New attribute system and major changes to many low-level areas.
Attribute system:
Structure is no longer completely hardcoded. Attributes and structure is
defined by new xml file (defaulting to stats.xml)
Structure defines non-base modifications to an attribute, to be used by
modifiers from items, effects, etc.
Calculating the base value for core attributes is still done in C++ (and for
such fundamental elements the only reason I can think of to do it any other
way is perhaps being able to quickly change scripts without a compile could be
useful for testing, but such things are a low priority anyway)
Item structure:
Modifiers are now through triggers rather than single events. This also
removes hardcoded types - an item could be both able to be equipped and be
able to be activated.
Item activation no longer consumes by default, this must be specified by the
property <consumes /> inside the trigger.
Currently only attribute modifications, autoattacks, and consumes are defined
as effects, but stubs for others do exist. Autoattacks are currently
non-functional, and this should be rectified with some urgency.
Auto Attacks:
AutoAttacks are now separate entities, though not fully complete, nor fully
integrated with all beings yet. Integration with the Character class is
urgent, integration with other Being children less so.
When fully integrated this will allow for multiple autoattacks, through
equipping multiple items with this as an equip effect or even through other
means if needed.
Equipment structure:
As ItemClass types are no longer hardcoded, so too are equip types. An item
have multiple ways to be equipped across multiple equipment slots with any
number in each slot. Character maximums are global but configurable.
Miscellaneous:
Speed, money, and weight are now attributes.
Some managers have been changed into classes such that their associated
classes can have them as friends, to avoid (ab)use of public accessors.
The serialise procedure should also be set as a friend of Character (both in
the account- and game- server) as well; having public accessors returning
iterators is simply ridiculous.
Some start for such cleanups have been made, but this is not the primary focus
here. Significant work will need to be done before this is resolved
completely, but the start is there.
BuySell::registerPlayerItems() has been completely disabled temporarily. The
previous function iterated through equipment, yet in the context I think it is
intended to fill items? I have been unable to update this function to fit the
modifications made to the Inventory/Equipment/Possessions, as I am unsure what
exactly what it should be doing.
ItemClass::mSpriteId was previously unused, so had been removed, but I
notice that it was used when transmitting equipment to nearby clients.
Experimentation showed that this value was never set to anything other than
0, and so has been left out of the ItemManager rewrite.
I am not entirely sure what is happening here, but it should be worth looking
into at a later time, as I am not sure how equipment appearences would be sent
otherwise.
Diffstat (limited to 'src/game-server/being.hpp')
-rw-r--r-- | src/game-server/being.hpp | 100 |
1 files changed, 31 insertions, 69 deletions
diff --git a/src/game-server/being.hpp b/src/game-server/being.hpp index f8a65c9..96151a3 100644 --- a/src/game-server/being.hpp +++ b/src/game-server/being.hpp @@ -28,11 +28,15 @@ #include "limits.h" #include "game-server/actor.hpp" +#include "game-server/attribute.hpp" +#include "game-server/autoattack.hpp" class Being; class MapComposite; class StatusEffect; +typedef std::map< unsigned int, Attribute > AttributeMap; + /** * Beings and actors directions * Needs to match client @@ -50,60 +54,10 @@ enum TimerID T_M_STROLL, // time until monster strolls to new location T_M_KILLSTEAL_PROTECTED, // killsteal protection time T_M_DECAY, // time until dead monster is removed - T_B_ATTACK_TIME, // time until being can attack again + T_M_ATTACK_TIME, // time until monster can attack again T_B_HP_REGEN // time until hp is regenerated again }; -/** - * Methods of damage calculation - */ -enum -{ - DAMAGE_PHYSICAL = 0, - DAMAGE_MAGICAL, - DAMAGE_OTHER -}; - -/** - * Structure that describes the severity and nature of an attack a being can - * be hit by. - */ -struct Damage -{ - unsigned short base; /**< Base amount of damage. */ - unsigned short delta; /**< Additional damage when lucky. */ - unsigned short cth; /**< Chance to hit. Opposes the evade attribute. */ - unsigned char element; /**< Elemental damage. */ - unsigned char type; /**< Damage type: Physical or magical? */ - std::list<size_t> usedSkills; /**< Skills used by source (needed for exp calculation) */ -}; - - -/** - * Holds the base value of an attribute and the sum of all its modifiers. - * While base + mod may be negative, the modified attribute is not. - */ -struct Attribute -{ - unsigned short base; - short mod; -}; - -struct AttributeModifier -{ - /**< Number of ticks (0 means permanent, e.g. equipment). */ - unsigned short duration; - short value; /**< Positive or negative amount. */ - unsigned char attr; /**< Attribute to modify. */ - /** - * Strength of the modification. - * - Zero means permanent, e.g. equipment. - * - Non-zero means spell. Can only be removed by a wizard with a - * dispell level higher than this value. - */ - unsigned char level; -}; - struct Status { StatusEffect *status; @@ -111,7 +65,6 @@ struct Status }; typedef std::map< int, Status > StatusEffects; -typedef std::vector< AttributeModifier > AttributeModifiers; /** * Type definition for a list of hits @@ -209,8 +162,6 @@ class Being : public Actor * Gets beings speed. * The speed is given in tiles per second. */ - float getSpeed() const - { return (float)(1000 / (float)mSpeed); } /** * Gets beings speed. @@ -218,7 +169,6 @@ class Being : public Actor * This function automatically transform it * into millsecond per tile. */ - void setSpeed(float s); /** * Gets the damage list. @@ -236,6 +186,7 @@ class Being : public Actor * Performs an attack. * Return Value: damage inflicted or -1 when illegal target */ + int performAttack(Being *target, const Damage &damage); int performAttack(Being *target, unsigned range, const Damage &damage); /** @@ -268,19 +219,32 @@ class Being : public Actor /** * Sets an attribute. */ - void setAttribute(int n, int value) - { mAttributes[n].base = value; } + void setAttribute(unsigned int id, double value, bool calc = true); /** * Gets an attribute. */ - int getAttribute(int n) const - { return mAttributes[n].base; } + double getAttribute(unsigned int id) const; /** * Gets an attribute after applying modifiers. */ - int getModifiedAttribute(int) const; + double getModifiedAttribute(unsigned int id) const; + + /** + * No-op to satisfy shared structure. + * @note The game server calculates this manually, so nothing happens + * here. + */ + void setModAttribute(unsigned int id, double value); + + /** + * Checks whether or not an attribute exists in this being. + * @returns True if the attribute is present in the being, false otherwise. + */ + + bool checkAttributeExists(unsigned int id) const + { return mAttributes.count(id); } /** * Adds a modifier to one attribute. @@ -289,17 +253,16 @@ class Being : public Actor * @param lvl If non-zero, indicates that a temporary modifier can be * dispelled prematuraly by a spell of given level. */ - void applyModifier(int attr, int value, int duration = 0, int lvl = 0); + void applyModifier(unsigned int attr, double value, unsigned int layer, + unsigned int duration = 0, unsigned int id = 0); - /** - * Removes all the modifiers with a level low enough. - */ - void dispellModifiers(int level); + bool removeModifier(unsigned int attr, double value, unsigned int layer, + unsigned int id = 0, bool fullcheck = false); /** * Called when an attribute modifier is changed. */ - virtual void modifiedAttribute(int) {} + virtual void modifiedAttribute(unsigned int) {} /** * Sets a statuseffect on this being @@ -355,7 +318,8 @@ class Being : public Actor protected: static const int TICKS_PER_HP_REGENERATION = 100; Action mAction; - std::vector< Attribute > mAttributes; + AttributeMap mAttributes; + AutoAttacks mAutoAttacks; StatusEffects mStatus; Being *mTarget; Point mOld; /**< Old coordinates. */ @@ -384,12 +348,10 @@ class Being : public Actor Being &operator=(const Being &rhs); Path mPath; - unsigned int mSpeed; /**< Speed. */ unsigned char mDirection; /**< Facing direction. */ std::string mName; Hits mHitsTaken; /**< List of punches taken since last update. */ - AttributeModifiers mModifiers; /**< Currently modified attributes. */ typedef std::map<TimerID, int> Timers; Timers mTimers; |