diff --git a/data/actions/scripts/misc/fluids.lua b/data/actions/scripts/misc/fluids.lua index 4d8160f..c3ce9d6 100644 --- a/data/actions/scripts/misc/fluids.lua +++ b/data/actions/scripts/misc/fluids.lua @@ -2,12 +2,7 @@ local drunk = Condition(CONDITION_DRUNK) drunk:setParameter(CONDITION_PARAM_TICKS, 60000) local poison = Condition(CONDITION_POISON) -poison:setParameter(CONDITION_PARAM_DELAYED, true) -poison:setParameter(CONDITION_PARAM_MINVALUE, -50) -poison:setParameter(CONDITION_PARAM_MAXVALUE, -120) -poison:setParameter(CONDITION_PARAM_STARTVALUE, -5) -poison:setParameter(CONDITION_PARAM_TICKINTERVAL, 5000) -poison:setParameter(CONDITION_PARAM_FORCEUPDATE, true) +poison:setTiming(100) local messages = { [FLUID_WATER] = "Gulp.", @@ -48,7 +43,7 @@ function onUse(player, item, fromPosition, target, toPosition) if self and item:getFluidType() == FLUID_BEER or item:getFluidType() == FLUID_WINE or item:getFluidType() == FLUID_RUM then player:addCondition(drunk) elseif self and item:getFluidType() == FLUID_SLIME then - player:addCondition(slime) + player:addCondition(poison) elseif item:getFluidType() == FLUID_MANAFLUID then target:addMana(math.random(50, 100)) target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) diff --git a/data/items/items.srv b/data/items/items.srv index 41bc61b..37bd791 100644 --- a/data/items/items.srv +++ b/data/items/items.srv @@ -9303,7 +9303,7 @@ TypeID = 2121 Name = "poison gas" Flags = {CollisionEvent,Unmove,Avoid,MagicField,Expire} Attributes = {AvoidDamageTypes=POISON,Brightness=2,LightColor=104,ExpireTarget=0,TotalExpireTime=250} -MagicField = {Type=POISON,Count=100} +MagicField = {Type=POISON,Count=100,Damage=5} TypeID = 2122 Name = "an energy field" @@ -9338,7 +9338,7 @@ TypeID = 2127 Name = "poison gas" Flags = {CollisionEvent,Unmove,Avoid,MagicField} Attributes = {AvoidDamageTypes=POISON,Brightness=2,LightColor=104} -MagicField = {Type=POISON,Count=100} +MagicField = {Type=POISON,Count=100,Damage=5} TypeID = 2128 Name = "a magic wall" @@ -9376,7 +9376,7 @@ TypeID = 2134 Name = "poison gas" Flags = {CollisionEvent,Unmove,Avoid,MagicField,Expire} Attributes = {AvoidDamageTypes=POISON,Brightness=2,LightColor=214,ExpireTarget=0,TotalExpireTime=8} -MagicField = {Type=POISON,Count=100} +MagicField = {Type=POISON,Count=100,Damage=5} TypeID = 2135 Name = "an energy field" @@ -24442,7 +24442,7 @@ Attributes = {Brightness=7,LightColor=207} TypeID = 5404 Name = "ocean floor" -Flags = {Bank,Unmove} +Flags = {Bank,Unmove,CollisionEvent} Attributes = {Waypoints=500} TypeID = 5405 diff --git a/data/monster/781/massive water elemental.xml b/data/monster/781/massive water elemental.xml index d80a50b..e3a03f9 100644 --- a/data/monster/781/massive water elemental.xml +++ b/data/monster/781/massive water elemental.xml @@ -28,7 +28,7 @@ - + diff --git a/data/movements/movements.xml b/data/movements/movements.xml index 420dbab..5b07647 100644 --- a/data/movements/movements.xml +++ b/data/movements/movements.xml @@ -388,7 +388,9 @@ - + + + diff --git a/data/movements/scripts/misc/drowning.lua b/data/movements/scripts/misc/drowning.lua new file mode 100644 index 0000000..aeabc52 --- /dev/null +++ b/data/movements/scripts/misc/drowning.lua @@ -0,0 +1,27 @@ +local condition = Condition(CONDITION_DROWN) +condition:setParameter(CONDITION_PARAM_HIT_DAMAGE, 20) +condition:setTiming(9999) + + +function onStepIn(creature, item, position, fromPosition) + local player = creature:getPlayer() + if player == nil then + return true + end + + if math.random(1, 10) == 1 then + position:sendMagicEffect(CONST_ME_BUBBLES) + end + player:addCondition(condition) + return true +end + +function onStepOut(creature, item, position, fromPosition) + local player = creature:getPlayer() + if player == nil then + return true + end + + player:removeCondition(CONDITION_DROWN) + return true +end diff --git a/src/condition.cpp b/src/condition.cpp index d5c5ece..237db4e 100644 --- a/src/condition.cpp +++ b/src/condition.cpp @@ -916,6 +916,21 @@ bool ConditionDamage::executeCondition(Creature* creature, int32_t) } else { return false; } + } else if (conditionType == CONDITION_DROWN) { + const int32_t r_cycle = cycle; + if (r_cycle) { + if (count <= 0) { + count = max_count; + cycle = r_cycle + 2 * (r_cycle <= 0) - 1; + doDamage(creature, -20); + } + else { + --count; + } + } + else { + return false; + } } return true; diff --git a/src/condition.h b/src/condition.h index 2535aa0..fe81f43 100644 --- a/src/condition.h +++ b/src/condition.h @@ -255,6 +255,8 @@ class ConditionDamage final : public Condition count = max_count = 8; } else if (type == CONDITION_ENERGY) { count = max_count = 10; + } else if (type == CONDITION_DROWN) { + count = max_count = 3; } } diff --git a/src/items.cpp b/src/items.cpp index 767ada3..e87c360 100644 --- a/src/items.cpp +++ b/src/items.cpp @@ -515,7 +515,6 @@ bool Items::loadItems() items[id].conditionDamage.reset(conditionDamage); } else if (identifier == "poison") { conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_POISON); - conditionDamage->setParam(CONDITION_PARAM_DELAYED, true); combatType = COMBAT_EARTHDAMAGE; items[id].combatType = combatType; items[id].conditionDamage.reset(conditionDamage); diff --git a/src/luascript.cpp b/src/luascript.cpp index a995631..93466f1 100644 --- a/src/luascript.cpp +++ b/src/luascript.cpp @@ -1154,6 +1154,7 @@ void LuaScriptInterface::registerFunctions() registerEnum(CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT) registerEnum(CONDITION_PARAM_STAT_MAGICPOINTSPERCENT) registerEnum(CONDITION_PARAM_PERIODICDAMAGE) + registerEnum(CONDITION_PARAM_HIT_DAMAGE) registerEnum(CONDITION_PARAM_SKILL_MELEEPERCENT) registerEnum(CONDITION_PARAM_SKILL_FISTPERCENT) registerEnum(CONDITION_PARAM_SKILL_CLUBPERCENT) diff --git a/src/monster.cpp b/src/monster.cpp index 9c65630..60fd7d1 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -876,7 +876,7 @@ void Monster::doAttacking(uint32_t) for (spellBlock_t& spellBlock : mType->info.attackSpells) { if (spellBlock.range != 0 && std::max(Position::getDistanceX(myPos, targetPos), Position::getDistanceY(myPos, targetPos)) <= spellBlock.range) { - if (normal_random(0, spellBlock.chance) == 0 && (master || health > mType->info.runAwayHealth || normal_random(1, 3) == 1)) { + if (uniform_random(0, spellBlock.chance) == 0 && (master || health > mType->info.runAwayHealth || uniform_random(1, 3) == 1)) { updateLookDirection(); minCombatValue = spellBlock.minCombatValue; @@ -977,7 +977,7 @@ void Monster::onThinkTarget(uint32_t interval) void Monster::onThinkDefense(uint32_t) { for (const spellBlock_t& spellBlock : mType->info.defenseSpells) { - if (normal_random(0, spellBlock.chance) == 0 && (master || health > mType->info.runAwayHealth || normal_random(1, 3) == 1)) { + if (uniform_random(0, spellBlock.chance) == 0 && (master || health > mType->info.runAwayHealth || uniform_random(1, 3) == 1)) { minCombatValue = spellBlock.minCombatValue; maxCombatValue = spellBlock.maxCombatValue; spellBlock.spell->castSpell(this, this);