proper drowning implementation

This commit is contained in:
ErikasKontenis
2019-12-05 14:40:09 +02:00
parent 4a87cd754c
commit 6fff6a868a
8 changed files with 52 additions and 14 deletions

View File

@@ -917,6 +917,13 @@ bool ConditionDamage::executeCondition(Creature* creature, int32_t)
return false;
}
} else if (conditionType == CONDITION_DROWN) {
if (isFirstCycle && count - max_count == -2) {
doDamage(creature, -20);
isFirstCycle = false;
count = max_count;
return true;
}
const int32_t r_cycle = cycle;
if (r_cycle) {
if (count <= 0) {

View File

@@ -283,7 +283,7 @@ class ConditionDamage final : public Condition
int32_t max_count = 0;
int32_t factor_percent = -1;
int32_t hit_damage = 0;
bool isFirstCycle = true;
uint32_t owner = 0;
bool doDamage(Creature* creature, int32_t healthChange);

View File

@@ -1164,6 +1164,7 @@ void Player::onThink(uint32_t interval)
addMessageBuffer();
}
lastWalkingTime += interval;
if (!getTile()->hasFlag(TILESTATE_NOLOGOUT) && !isAccessPlayer()) {
idleTime += interval;
const int32_t kickAfterMinutes = g_config.getNumber(ConfigManager::KICK_AFTER_MINUTES);

View File

@@ -286,6 +286,19 @@ class Player final : public Creature, public Cylinder
void resetIdleTime() {
idleTime = 0;
resetLastWalkingTime();
}
int32_t getIdleTime() const {
return idleTime;
}
void resetLastWalkingTime() {
lastWalkingTime = 0;
}
int32_t getLastWalkingTime() const {
return lastWalkingTime;
}
bool isInGhostMode() const {
@@ -1045,6 +1058,7 @@ class Player final : public Creature, public Cylinder
int32_t bloodHitCount = 0;
int32_t shieldBlockCount = 0;
int32_t idleTime = 0;
int32_t lastWalkingTime = 0;
uint16_t staminaMinutes = 3360;
uint16_t maxWriteLen = 0;