Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checks on player death, player speed breakpoint and misc enhancements #378

Merged
merged 22 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ autoLoot = false
-- deposited to your bank account.
autoBank = false

-- configure maximum value of critical imbuement
criticalChance = 10

-- Stamina in Trainers
staminaTrainer = false
staminaTrainerDelay = 5
Expand Down
1 change: 1 addition & 0 deletions src/config/config_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ enum integerConfig_t {
MAX_ALLOWED_ON_A_DUMMY,
FREE_QUEST_STAGE,
DEPOTCHEST,
CRITICALCHANCE,

LAST_INTEGER_CONFIG
};
Expand Down
1 change: 1 addition & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ bool ConfigManager::load()
integer[MAX_ALLOWED_ON_A_DUMMY] = getGlobalNumber(L, "maxAllowedOnADummy", 1);
integer[FREE_QUEST_STAGE] = getGlobalNumber(L, "freeQuestStage", 1);
integer[DEPOTCHEST] = getGlobalNumber(L, "depotChest", 4);
integer[CRITICALCHANCE] = getGlobalNumber(L, "criticalChance", 10);

floating[RATE_HEALTH_REGEN] = getGlobalFloat(L, "rateHealthRegen", 1.0);
floating[RATE_HEALTH_REGEN_SPEED] = getGlobalFloat(L, "rateHealthRegenSpeed", 1.0);
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ bool Creature::dropCorpse(Creature* lastHitCreature, Creature* mostDamageCreatur
g_game().internalAddItem(tile, corpse, INDEX_WHEREEVER, FLAG_NOLIMIT);
dropLoot(corpse->getContainer(), lastHitCreature);
corpse->startDecaying();
bool corpses = corpse->isRewardCorpse() && (corpse->getID() == ITEM_MALE_CORPSE || corpse->getID() == ITEM_FEMALE_CORPSE);
bool corpses = corpse->isRewardCorpse() || (corpse->getID() == ITEM_MALE_CORPSE || corpse->getID() == ITEM_FEMALE_CORPSE);
if (mostDamageCreature && mostDamageCreature->getPlayer() && !corpses) {
Player* player = mostDamageCreature->getPlayer();
if (g_configManager().getBoolean(AUTOBANK)) {
Expand Down
44 changes: 21 additions & 23 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1526,9 +1526,7 @@ void Player::onCreatureAppear(Creature* creature, bool isLogin)
bed->wakeUp(this);
}

if (isLogin) {
andersonfaaria marked this conversation as resolved.
Show resolved Hide resolved
SPDLOG_INFO("{} has logged in", name);
}
SPDLOG_INFO("{} has logged in", name);

if (guild) {
guild->addMember(this);
Expand All @@ -1554,6 +1552,15 @@ void Player::onCreatureAppear(Creature* creature, bool isLogin)

g_game().checkPlayersRecord();
IOLoginData::updateOnlineStatus(guid, true);
} else if (!isLogin) {
std::string bless = getBlessingsName();
std::ostringstream lostBlesses;
if (bless.length() == 0) {
lostBlesses << "You lost all your blessings.";
} else {
lostBlesses << "You are still blessed with " << bless;
}
sendTextMessage(MESSAGE_EVENT_ADVANCE, lostBlesses.str());
}
}

Expand Down Expand Up @@ -1629,14 +1636,21 @@ void Player::onRemoveCreature(Creature* creature, bool isLogout)

if (creature == this) {
if (isLogout) {
if (party) {
party->leaveParty(this);
}
if (guild) {
guild->removeMember(this);
}

loginPosition = getPosition();
lastLogout = time(nullptr);
SPDLOG_INFO("{} has logged out", getName());
g_chat().removeUserFromAllChannels(*this);
clearPartyInvitations();
IOLoginData::updateOnlineStatus(guid, false);
}

lastLogout = time(nullptr);

if (eventWalk != 0) {
setFollowCreature(nullptr);
}
Expand All @@ -1647,16 +1661,6 @@ void Player::onRemoveCreature(Creature* creature, bool isLogout)

closeShopWindow();

if (party && isLogout) {
party->leaveParty(this);
}

if (guild && isLogout) {
guild->removeMember(this);
}

IOLoginData::updateOnlineStatus(guid, false);

bool saved = false;
for (uint32_t tries = 0; tries < 3; ++tries) {
if (IOLoginData::savePlayer(this)) {
Expand Down Expand Up @@ -2642,14 +2646,6 @@ void Player::death(Creature* lastHitCreature)
}
}

std::ostringstream lostBlesses;
if (bless.length() == 0) {
lostBlesses << "You lost all your blesses.";
} else {
lostBlesses << "You are still blessed with " << bless;
}
sendTextMessage(MESSAGE_EVENT_ADVANCE, lostBlesses.str());

sendStats();
sendSkills();
sendReLoginWindow(unfairFightReduction);
Expand Down Expand Up @@ -2743,6 +2739,8 @@ void Player::despawn()
listWalkDir.clear();
stopEventWalk();
onWalkAborted();
g_game().playerSetAttackedCreature(this->getID(), 0);
g_game().playerFollowCreature(this->getID(), 0);

// remove check
Game::removeCreatureCheck(this);
Expand Down
4 changes: 2 additions & 2 deletions src/creatures/players/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct OpenContainer {

using MuteCountMap = std::map<uint32_t, uint32_t>;

static constexpr int32_t PLAYER_MAX_SPEED = 4500;
static constexpr int32_t PLAYER_MAX_SPEED = 70000;
static constexpr int32_t PLAYER_MIN_SPEED = 10;

class Player final : public Creature, public Cylinder
Expand Down Expand Up @@ -2116,7 +2116,7 @@ class Player final : public Creature, public Cylinder
std::map<uint8_t, uint16_t> maxValuePerSkill = {
{SKILL_LIFE_LEECH_CHANCE, 100},
{SKILL_MANA_LEECH_CHANCE, 100},
{SKILL_CRITICAL_HIT_CHANCE, 10}
{SKILL_CRITICAL_HIT_CHANCE, g_configManager().getNumber(CRITICALCHANCE)}
};

std::map<uint32_t, Reward*> rewardMap;
Expand Down