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

@ -24447,27 +24447,27 @@ Attributes = {Waypoints=500}
TypeID = 5405 TypeID = 5405
Name = "ocean floor" Name = "ocean floor"
Flags = {Bank,Unmove} Flags = {Bank,Unmove,CollisionEvent}
Attributes = {Waypoints=500} Attributes = {Waypoints=500}
TypeID = 5406 TypeID = 5406
Name = "ocean floor" Name = "ocean floor"
Flags = {Bank,Unmove} Flags = {Bank,Unmove,CollisionEvent}
Attributes = {Waypoints=500} Attributes = {Waypoints=500}
TypeID = 5407 TypeID = 5407
Name = "ocean floor" Name = "ocean floor"
Flags = {Bank,Unmove} Flags = {Bank,Unmove,CollisionEvent}
Attributes = {Waypoints=500} Attributes = {Waypoints=500}
TypeID = 5408 TypeID = 5408
Name = "ocean floor" Name = "ocean floor"
Flags = {Bank,Unmove} Flags = {Bank,Unmove,CollisionEvent}
Attributes = {Waypoints=500} Attributes = {Waypoints=500}
TypeID = 5409 TypeID = 5409
Name = "ocean floor" Name = "ocean floor"
Flags = {Bank,Unmove} Flags = {Bank,Unmove,CollisionEvent}
Attributes = {Waypoints=500} Attributes = {Waypoints=500}
TypeID = 5410 TypeID = 5410
@ -25925,12 +25925,12 @@ Name = "" # this is nothing in client
TypeID = 5743 TypeID = 5743
Name = "wooden floor" Name = "wooden floor"
Flags = {Bank,Unmove} Flags = {Bank,Unmove,CollisionEvent}
Attributes = {Waypoints=500} Attributes = {Waypoints=500}
TypeID = 5744 TypeID = 5744
Name = "wooden floor" Name = "wooden floor"
Flags = {Bank,Unmove} Flags = {Bank,Unmove,CollisionEvent}
Attributes = {Waypoints=500} Attributes = {Waypoints=500}
TypeID = 5745 TypeID = 5745
@ -26017,7 +26017,7 @@ Attributes = {Waypoints=110}
TypeID = 5764 TypeID = 5764
Name = "a ventilation grille" Name = "a ventilation grille"
Flags = {Bank,Unmove} Flags = {Bank,Unmove,CollisionEvent}
Attributes = {Waypoints=500} Attributes = {Waypoints=500}
TypeID = 5765 TypeID = 5765

View File

@ -388,8 +388,12 @@
<movevent event="StepIn" movementid="237" script="nostalrius/237.lua" /> <movevent event="StepIn" movementid="237" script="nostalrius/237.lua" />
<!-- Nostalrius Default Movements --> <!-- Nostalrius Default Movements -->
<movevent event="StepIn" itemid="5404" script="misc/drowning.lua" /> <movevent event="StepIn" fromid="5404" toid="5409" script="misc/drowning.lua" />
<movevent event="StepOut" itemid="5404" script="misc/drowning.lua"/> <movevent event="StepOut" fromid="5404" toid="5409" script="misc/drowning.lua"/>
<movevent event="StepIn" fromid="5743" toid="5744" script="misc/drowning.lua" />
<movevent event="StepOut" fromid="5743" toid="5744" script="misc/drowning.lua"/>
<movevent event="StepIn" itemid="5764" script="misc/drowning.lua" />
<movevent event="StepOut" itemid="5764" script="misc/drowning.lua"/>
<!-- Floorchange --> <!-- Floorchange -->
<movevent event="StepIn" itemid="293" script="misc/floorchange.lua" /> <movevent event="StepIn" itemid="293" script="misc/floorchange.lua" />
@ -666,6 +670,10 @@
<movevent event="StepIn" itemid="2151" function="onStepInField" /> <movevent event="StepIn" itemid="2151" function="onStepInField" />
<movevent event="AddItem" itemid="2151" function="onAddField" /> <movevent event="AddItem" itemid="2151" function="onAddField" />
<!-- Helmets -->
<movevent event="Equip" itemid="5460" slot="head" function="onEquipItem" script="misc/helmet_of_the_deep.lua" />
<movevent event="DeEquip" itemid="5460" slot="head" function="onDeEquipItem" />
<!-- Boots --> <!-- Boots -->
<movevent event="Equip" itemid="3079" slot="feet" function="onEquipItem" /> <movevent event="Equip" itemid="3079" slot="feet" function="onEquipItem" />
<movevent event="DeEquip" itemid="3079" slot="feet" function="onDeEquipItem" /> <movevent event="DeEquip" itemid="3079" slot="feet" function="onDeEquipItem" />

View File

@ -1,6 +1,5 @@
local condition = Condition(CONDITION_DROWN) local condition = Condition(CONDITION_DROWN)
condition:setParameter(CONDITION_PARAM_HIT_DAMAGE, 20) condition:setTiming(5)
condition:setTiming(9999)
function onStepIn(creature, item, position, fromPosition) function onStepIn(creature, item, position, fromPosition)
@ -9,6 +8,11 @@ function onStepIn(creature, item, position, fromPosition)
return true return true
end end
local helmet = player:getSlotItem(CONST_SLOT_HEAD)
if helmet ~= nil and helmet:getId() == 5460 then
return true
end
if math.random(1, 10) == 1 then if math.random(1, 10) == 1 then
position:sendMagicEffect(CONST_ME_BUBBLES) position:sendMagicEffect(CONST_ME_BUBBLES)
end end

View File

@ -0,0 +1,4 @@
function onEquip(player, item, slot)
player:removeCondition(CONDITION_DROWN)
return true
end

View File

@ -917,6 +917,13 @@ bool ConditionDamage::executeCondition(Creature* creature, int32_t)
return false; return false;
} }
} else if (conditionType == CONDITION_DROWN) { } 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; const int32_t r_cycle = cycle;
if (r_cycle) { if (r_cycle) {
if (count <= 0) { if (count <= 0) {

View File

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

View File

@ -1164,6 +1164,7 @@ void Player::onThink(uint32_t interval)
addMessageBuffer(); addMessageBuffer();
} }
lastWalkingTime += interval;
if (!getTile()->hasFlag(TILESTATE_NOLOGOUT) && !isAccessPlayer()) { if (!getTile()->hasFlag(TILESTATE_NOLOGOUT) && !isAccessPlayer()) {
idleTime += interval; idleTime += interval;
const int32_t kickAfterMinutes = g_config.getNumber(ConfigManager::KICK_AFTER_MINUTES); 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() { void resetIdleTime() {
idleTime = 0; idleTime = 0;
resetLastWalkingTime();
}
int32_t getIdleTime() const {
return idleTime;
}
void resetLastWalkingTime() {
lastWalkingTime = 0;
}
int32_t getLastWalkingTime() const {
return lastWalkingTime;
} }
bool isInGhostMode() const { bool isInGhostMode() const {
@ -1045,6 +1058,7 @@ class Player final : public Creature, public Cylinder
int32_t bloodHitCount = 0; int32_t bloodHitCount = 0;
int32_t shieldBlockCount = 0; int32_t shieldBlockCount = 0;
int32_t idleTime = 0; int32_t idleTime = 0;
int32_t lastWalkingTime = 0;
uint16_t staminaMinutes = 3360; uint16_t staminaMinutes = 3360;
uint16_t maxWriteLen = 0; uint16_t maxWriteLen = 0;