summaryrefslogtreecommitdiff
path: root/src/game-server/character.cpp
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-02-17 12:24:45 +0100
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-08-26 22:56:47 +0200
commit44ee071d7ece5a2023f79307f36e8a244c9e7b3a (patch)
tree06b7fcea59bbbf1963b460ca9b678d0ea6fa90e4 /src/game-server/character.cpp
parente3a1e9c89e102dbf961c624435c495c759776312 (diff)
downloadmanaserv-44ee071d7ece5a2023f79307f36e8a244c9e7b3a.tar.gz
manaserv-44ee071d7ece5a2023f79307f36e8a244c9e7b3a.tar.bz2
manaserv-44ee071d7ece5a2023f79307f36e8a244c9e7b3a.tar.xz
manaserv-44ee071d7ece5a2023f79307f36e8a244c9e7b3a.zip
Removed skills
This removes support for skills. The plan is to allow to implement the skills as they were implemented before via attributes. This adds a lot more flexibility to the server creators while also removing the confusion about skills and attributes. So this change does: - Remove the skillmanager with all its calls, the skill xml file, etc - Move exp giving to the script engine: --> Allows to implement the old behaviour (and more) in the scripts - Remove the exp tag from the monster definition: + Since the server itself does not require it anymore it feels wrong to require it for EVERY monster. TODO: Add a system to add properties to the monsters/items.xml which allow defining things like the exp and allows to read the value from the script engine. + Small drawback, but it should not be hard to implement this property system. - Drop the level networking and calculation. + level calculation will happen via the attribute system later but i would prefer to do this in a seperate patch since this patch already got longer than expected especially since this requires to make setting correction points and available status points scriptable. + The level would be simply set as a attribute, the int number of it will be the level, the remaining digits will be the % number till the next levelup. - NOT remove any existing skill tables in the database update scripts. + There is no way to move them into the attribute table in a unified way (there are too many different way they could have been used). So server admins have to care about moving theirs skills to attributes themselves. + Keeping the old tables does not hurt for existing databases. So removing does not give any advantage/is required anyway. The now obsolote info about the EXP transaction is not removed for updated databases either. (The update script basically only bumps the version number without doing anything else. - bump the network protocol version --> old clients won't be able to connect. - bump the database version --> serveradmins need to update their db.
Diffstat (limited to 'src/game-server/character.cpp')
-rw-r--r--src/game-server/character.cpp162
1 files changed, 0 insertions, 162 deletions
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index a8d29625..e4a30a2f 100644
--- a/src/game-server/character.cpp
+++ b/src/game-server/character.cpp
@@ -31,7 +31,6 @@
#include "game-server/map.h"
#include "game-server/mapcomposite.h"
#include "game-server/mapmanager.h"
-#include "game-server/skillmanager.h"
#include "game-server/state.h"
#include "game-server/trade.h"
#include "scripting/scriptmanager.h"
@@ -46,12 +45,6 @@
#include <cmath>
#include <limits.h>
-// Experience curve related values
-const float CharacterComponent::EXPCURVE_EXPONENT = 3.0f;
-const float CharacterComponent::EXPCURVE_FACTOR = 10.0f;
-const float CharacterComponent::LEVEL_SKILL_PRECEDENCE_FACTOR = 0.75f;
-const float CharacterComponent::EXP_LEVEL_FLEXIBILITY = 1.0f;
-
Script::Ref CharacterComponent::mDeathCallback;
Script::Ref CharacterComponent::mDeathAcceptedCallback;
Script::Ref CharacterComponent::mLoginCallback;
@@ -76,10 +69,6 @@ CharacterComponent::CharacterComponent(Entity &entity, MessageIn &msg):
mDatabaseID(-1),
mHairStyle(0),
mHairColor(0),
- mLevel(1),
- mLevelProgress(0),
- mUpdateLevelProgress(false),
- mRecalculateLevel(true),
mSendAbilityCooldown(false),
mParty(0),
mTransaction(TRANS_NONE),
@@ -133,13 +122,6 @@ CharacterComponent::~CharacterComponent()
void CharacterComponent::update(Entity &entity)
{
- // Update character level if needed.
- if (mRecalculateLevel)
- {
- mRecalculateLevel = false;
- recalculateLevel(entity);
- }
-
// Dead character: don't regenerate anything else
if (entity.getComponent<BeingComponent>()->getAction() == DEAD)
return;
@@ -304,27 +286,6 @@ void CharacterComponent::sendStatus(Entity &entity)
}
if (attribMsg.getLength() > 2) gameHandler->sendTo(mClient, attribMsg);
mModifiedAttributes.clear();
-
- MessageOut expMsg(GPMSG_PLAYER_EXP_CHANGE);
- for (std::set<size_t>::const_iterator i = mModifiedExperience.begin(),
- i_end = mModifiedExperience.end(); i != i_end; ++i)
- {
- int skill = *i;
- expMsg.writeInt16(skill);
- expMsg.writeInt32(getExpGot(skill));
- expMsg.writeInt32(getExpNeeded(skill));
- expMsg.writeInt16(levelForExp(getExperience(skill)));
- }
- if (expMsg.getLength() > 2) gameHandler->sendTo(mClient, expMsg);
- mModifiedExperience.clear();
-
- if (mUpdateLevelProgress)
- {
- mUpdateLevelProgress = false;
- MessageOut progressMessage(GPMSG_LEVEL_PROGRESS);
- progressMessage.writeInt8(mLevelProgress);
- gameHandler->sendTo(mClient, progressMessage);
- }
}
void CharacterComponent::modifiedAllAttributes(Entity &entity)
@@ -350,55 +311,6 @@ void CharacterComponent::attributeChanged(Entity *entity, unsigned attr)
mModifiedAttributes.insert(attr);
}
-int CharacterComponent::expForLevel(int level)
-{
- return int(pow(level, EXPCURVE_EXPONENT) * EXPCURVE_FACTOR);
-}
-
-int CharacterComponent::levelForExp(int exp)
-{
- return int(pow(float(exp) / EXPCURVE_FACTOR, 1.0f / EXPCURVE_EXPONENT));
-}
-
-void CharacterComponent::receiveExperience(int skill, int experience, int optimalLevel)
-{
- // reduce experience when skill is over optimal level
- int levelOverOptimum = levelForExp(getExperience(skill)) - optimalLevel;
- if (optimalLevel && levelOverOptimum > 0)
- {
- experience *= EXP_LEVEL_FLEXIBILITY
- / (levelOverOptimum + EXP_LEVEL_FLEXIBILITY);
- }
-
- // Add exp
- int oldExp = mExperience[skill];
- long int newExp = mExperience[skill] + experience;
- if (newExp < 0)
- newExp = 0; // Avoid integer underflow/negative exp.
-
- // Check the skill cap
- long int maxSkillCap = Configuration::getValue("game_maxSkillCap", INT_MAX);
- assert(maxSkillCap <= INT_MAX); // Avoid integer overflow.
- if (newExp > maxSkillCap)
- {
- newExp = maxSkillCap;
- if (oldExp != maxSkillCap)
- {
- LOG_INFO("Player hit the skill cap");
- // TODO: Send a message to player letting them know they hit the cap
- // or not?
- }
- }
- mExperience[skill] = newExp;
- mModifiedExperience.insert(skill);
-
- // Inform account server
- if (newExp != oldExp)
- accountHandler->updateExperience(getDatabaseID(), skill, newExp);
-
- mRecalculateLevel = true;
-}
-
void CharacterComponent::incrementKillCount(int monsterType)
{
std::map<int, int>::iterator i = mKillCount.find(monsterType);
@@ -422,80 +334,6 @@ int CharacterComponent::getKillCount(int monsterType) const
return 0;
}
-
-void CharacterComponent::recalculateLevel(Entity &entity)
-{
- std::list<float> levels;
- std::map<int, int>::const_iterator a;
- for (a = getSkillBegin(); a != getSkillEnd(); a++)
- {
- // Only use the first 1000 skill levels in calculation
- if (a->first < 1000)
- {
- float expGot = getExpGot(a->first);
- float expNeed = getExpNeeded(a->first);
- levels.push_back(levelForExp(a->first) + expGot / expNeed);
- }
- }
- levels.sort();
-
- std::list<float>::iterator i = levels.end();
- float level = 0.0f;
- float factor = 1.0f;
- float factorSum = 0.0f;
- while (i != levels.begin())
- {
- i--;
- level += *i * factor;
- factorSum += factor;
- factor *= LEVEL_SKILL_PRECEDENCE_FACTOR;
- }
- level /= factorSum;
- level += 1.0f; // + 1.0f because the lowest level is 1 and not 0
-
- while (mLevel < level)
- {
- levelup(entity);
- }
-
- int levelProgress = int((level - floor(level)) * 100);
- if (levelProgress != mLevelProgress)
- {
- mLevelProgress = levelProgress;
- mUpdateLevelProgress = true;
- }
-}
-
-int CharacterComponent::getExpNeeded(size_t skill) const
-{
- int level = levelForExp(getExperience(skill));
- return CharacterComponent::expForLevel(level + 1) - expForLevel(level);
-}
-
-int CharacterComponent::getExpGot(size_t skill) const
-{
- int level = levelForExp(getExperience(skill));
- return mExperience.at(skill) - CharacterComponent::expForLevel(level);
-}
-
-void CharacterComponent::levelup(Entity &entity)
-{
- mLevel++;
-
- mCharacterPoints += CHARPOINTS_PER_LEVELUP;
- mCorrectionPoints += CORRECTIONPOINTS_PER_LEVELUP;
- if (mCorrectionPoints > CORRECTIONPOINTS_MAX)
- mCorrectionPoints = CORRECTIONPOINTS_MAX;
-
- MessageOut levelupMsg(GPMSG_LEVELUP);
- levelupMsg.writeInt16(mLevel);
- levelupMsg.writeInt16(mCharacterPoints);
- levelupMsg.writeInt16(mCorrectionPoints);
- gameHandler->sendTo(mClient, levelupMsg);
- LOG_INFO(entity.getComponent<BeingComponent>()->getName()
- << " reached level " << mLevel);
-}
-
AttribmodResponseCode CharacterComponent::useCharacterPoint(Entity &entity,
int attribute)
{