Hello. I edited source code. These is what I edited:
In player.cpp
void Player::death(), changed "Level loss" part to:
[cpp] //Level loss
oldLevel = level;
uint32_t newLevel = level;
while((uint64_t)(experience - getLostExperience()) < Player::getExpForLevel(newLevel))
{
if(newLevel > 70)
newLevel--;
else
break;
}
experience -= getLostExperience();
if (experience < getExpForLevel (70))
{
experience = getExpForLevel (70);
}
level = newLevel;
if(newLevel != oldLevel)
{
char lvMsg[90];
sprintf(lvMsg, "You were downgraded from Level %d to Level %d.", oldLevel, newLevel);
sendTextMessage(MSG_EVENT_ADVANCE, lvMsg);
}
uint64_t currLevelExp = Player::getExpForLevel(newLevel);
levelPercent = Player::getPercentLevel(experience - currLevelExp, Player::getExpForLevel(newLevel + 1) - currLevelExp);[/cpp]
void Player:
reSave() now looks like this:
[cpp]{
if(health <= 0)
{
if(skillLoss)
{
while(oldLevel > 70 && experience < Player::getExpForLevel(oldLevel))
{
--oldLevel;
healthMax = std::max((int32_t)0, (healthMax - (int32_t)vocation->getHPGain()));
manaMax = std::max((int32_t)0, (manaMax - (int32_t)vocation->getManaGain()));
capacity = std::max((double)0, (capacity - (double)vocation->getCapGain()));
}
blessings = 0;
mana = manaMax;
}
health = healthMax;
}
}[/cpp]
I made this change so people cant die below level 70 and when they die they see what level they become before relogging (that is what happened to skills and magic level, but not exp and level, before edits) . As you can see above I added oldLevel = level; so I can still remove correct amount of hp, mana and cap from players who downgraded in level.
In player.h
Added
[cpp] //player death variable
uint32_t oldLevel;[/cpp]
Above
[cpp] //extra skill modifiers
int32_t varSkills[SKILL_LAST + 1];[/cpp]
... and below
[cpp] //player advances variables
uint32_t skills[SKILL_LAST + 1][3];[/cpp]
So I can set a value to varaible oldLevel in player::death and use it in player:
reSave.
Errors:
Instant server crash when I login with any player (god, player etc).
When I moved
[cpp] //player death variable
uint32_t oldLevel;[/cpp]
to between
[cpp]uint32_t level;[/cpp] and [cpp]uint32_t levelPercent;[/cpp] I couldnt use commands, magic levels was wrong and a bunch of things. Is this because for example [cpp]uint32_t magLevel;[/cpp] is behind what I changed so it moves one step down?
Please help me with what is wrong here. If you need more info to tell me what the problem is just post. Rep hunters and nice people, both appriciated
In player.cpp
void Player::death(), changed "Level loss" part to:
[cpp] //Level loss
oldLevel = level;
uint32_t newLevel = level;
while((uint64_t)(experience - getLostExperience()) < Player::getExpForLevel(newLevel))
{
if(newLevel > 70)
newLevel--;
else
break;
}
experience -= getLostExperience();
if (experience < getExpForLevel (70))
{
experience = getExpForLevel (70);
}
level = newLevel;
if(newLevel != oldLevel)
{
char lvMsg[90];
sprintf(lvMsg, "You were downgraded from Level %d to Level %d.", oldLevel, newLevel);
sendTextMessage(MSG_EVENT_ADVANCE, lvMsg);
}
uint64_t currLevelExp = Player::getExpForLevel(newLevel);
levelPercent = Player::getPercentLevel(experience - currLevelExp, Player::getExpForLevel(newLevel + 1) - currLevelExp);[/cpp]
void Player:
[cpp]{
if(health <= 0)
{
if(skillLoss)
{
while(oldLevel > 70 && experience < Player::getExpForLevel(oldLevel))
{
--oldLevel;
healthMax = std::max((int32_t)0, (healthMax - (int32_t)vocation->getHPGain()));
manaMax = std::max((int32_t)0, (manaMax - (int32_t)vocation->getManaGain()));
capacity = std::max((double)0, (capacity - (double)vocation->getCapGain()));
}
blessings = 0;
mana = manaMax;
}
health = healthMax;
}
}[/cpp]
I made this change so people cant die below level 70 and when they die they see what level they become before relogging (that is what happened to skills and magic level, but not exp and level, before edits) . As you can see above I added oldLevel = level; so I can still remove correct amount of hp, mana and cap from players who downgraded in level.
In player.h
Added
[cpp] //player death variable
uint32_t oldLevel;[/cpp]
Above
[cpp] //extra skill modifiers
int32_t varSkills[SKILL_LAST + 1];[/cpp]
... and below
[cpp] //player advances variables
uint32_t skills[SKILL_LAST + 1][3];[/cpp]
So I can set a value to varaible oldLevel in player::death and use it in player:
Errors:
Instant server crash when I login with any player (god, player etc).
When I moved
[cpp] //player death variable
uint32_t oldLevel;[/cpp]
to between
[cpp]uint32_t level;[/cpp] and [cpp]uint32_t levelPercent;[/cpp] I couldnt use commands, magic levels was wrong and a bunch of things. Is this because for example [cpp]uint32_t magLevel;[/cpp] is behind what I changed so it moves one step down?
Please help me with what is wrong here. If you need more info to tell me what the problem is just post. Rep hunters and nice people, both appriciated