From eea0fc858b04574e61bbc0822960714ee828dfc2 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 27 Feb 2024 14:10:41 -0300 Subject: [PATCH] refactor: jean pierre foods (#2320) Close #2122 --- .../actions/other/jean_pierre_food.lua | 224 ------------------ .../scripts/movements/others/drowning.lua | 36 --- .../actions/items/banana_chocolate_shake.lua | 18 ++ data/scripts/actions/items/blessed_steak.lua | 19 ++ data/scripts/actions/items/carrot_cake.lua | 26 ++ .../actions/items/coconut_shrimp_bake.lua | 31 +++ .../actions/items/demonic_candy_ball.lua | 72 ++++++ .../actions/items/filled_jalapeno_peppers.lua | 23 ++ data/scripts/actions/items/hireling_foods.lua | 4 +- .../actions/items/hydra_tongue_salad.lua | 35 +++ .../actions/items/northern_fishburger.lua | 26 ++ .../actions/items/pot_of_blackjack.lua | 35 +++ data/scripts/actions/items/potions.lua | 6 +- .../actions/items/roasted_dragon_wings.lua | 26 ++ data/scripts/actions/items/rotworm_stew.lua | 19 ++ .../actions/items/sweet_mangonaise_elixir.lua | 53 +++++ .../items/tropical_fried_terrorbird.lua | 26 ++ .../actions/items/veggie_casserole.lua | 26 ++ .../scripts/movements/drowning.lua | 31 ++- .../functions/core/game/global_functions.cpp | 18 -- .../functions/core/game/global_functions.hpp | 2 - 21 files changed, 465 insertions(+), 291 deletions(-) delete mode 100644 data-otservbr-global/scripts/actions/other/jean_pierre_food.lua delete mode 100644 data-otservbr-global/scripts/movements/others/drowning.lua create mode 100644 data/scripts/actions/items/banana_chocolate_shake.lua create mode 100644 data/scripts/actions/items/blessed_steak.lua create mode 100644 data/scripts/actions/items/carrot_cake.lua create mode 100644 data/scripts/actions/items/coconut_shrimp_bake.lua create mode 100644 data/scripts/actions/items/demonic_candy_ball.lua create mode 100644 data/scripts/actions/items/filled_jalapeno_peppers.lua create mode 100644 data/scripts/actions/items/hydra_tongue_salad.lua create mode 100644 data/scripts/actions/items/northern_fishburger.lua create mode 100644 data/scripts/actions/items/pot_of_blackjack.lua create mode 100644 data/scripts/actions/items/roasted_dragon_wings.lua create mode 100644 data/scripts/actions/items/rotworm_stew.lua create mode 100644 data/scripts/actions/items/sweet_mangonaise_elixir.lua create mode 100644 data/scripts/actions/items/tropical_fried_terrorbird.lua create mode 100644 data/scripts/actions/items/veggie_casserole.lua rename {data-canary => data}/scripts/movements/drowning.lua (50%) diff --git a/data-otservbr-global/scripts/actions/other/jean_pierre_food.lua b/data-otservbr-global/scripts/actions/other/jean_pierre_food.lua deleted file mode 100644 index 71627cfc61c..00000000000 --- a/data-otservbr-global/scripts/actions/other/jean_pierre_food.lua +++ /dev/null @@ -1,224 +0,0 @@ -local conditions = { - CONDITION_POISON, - CONDITION_FIRE, - CONDITION_ENERGY, - CONDITION_PARALYZE, - CONDITION_DRUNK, - CONDITION_DROWN, - CONDITION_FREEZING, - CONDITION_DAZZLED, - CONDITION_CURSED, - CONDITION_BLEEDING, -} -local condition_shield = Condition(CONDITION_ATTRIBUTES) -condition_shield:setParameter(CONDITION_PARAM_SUBID, AttrSubId_JeanPierreDefense) -condition_shield:setParameter(CONDITION_PARAM_BUFF_SPELL, 1) -condition_shield:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) -condition_shield:setParameter(CONDITION_PARAM_SKILL_SHIELD, 10) -condition_shield:setParameter(CONDITION_PARAM_FORCEUPDATE, true) -local condition_ml = Condition(CONDITION_ATTRIBUTES) -condition_ml:setParameter(CONDITION_PARAM_SUBID, AttrSubId_JeanPierreMagic) -condition_ml:setParameter(CONDITION_PARAM_BUFF_SPELL, 1) -condition_ml:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) -condition_ml:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 5) -condition_ml:setParameter(CONDITION_PARAM_FORCEUPDATE, true) -local condition_melee = Condition(CONDITION_ATTRIBUTES) -condition_melee:setParameter(CONDITION_PARAM_SUBID, AttrSubId_JeanPierreMelee) -condition_melee:setParameter(CONDITION_PARAM_BUFF_SPELL, 1) -condition_melee:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) -condition_melee:setParameter(CONDITION_PARAM_SKILL_MELEE, 10) -condition_melee:setParameter(CONDITION_PARAM_FORCEUPDATE, true) -local condition_dist = Condition(CONDITION_ATTRIBUTES) -condition_dist:setParameter(CONDITION_PARAM_SUBID, AttrSubId_JeanPierreDistance) -condition_dist:setParameter(CONDITION_PARAM_BUFF_SPELL, 1) -condition_dist:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) -condition_dist:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 10) -condition_dist:setParameter(CONDITION_PARAM_FORCEUPDATE, true) -local condition_f = Condition(CONDITION_ATTRIBUTES) -condition_f:setParameter(CONDITION_PARAM_SUBID, AttrSubId_JeanPierreFishing) -condition_f:setParameter(CONDITION_PARAM_BUFF_SPELL, 1) -condition_f:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) -condition_f:setParameter(CONDITION_PARAM_SKILL_FISHING, 50) -condition_f:setParameter(CONDITION_PARAM_FORCEUPDATE, true) -local condition_speed = Condition(CONDITION_HASTE) -condition_speed:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) -condition_speed:setParameter(CONDITION_PARAM_SPEED, 729) -local combat_i = Combat() -combat_i:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED) -combat_i:setParameter(COMBAT_PARAM_AGGRESSIVE, 0) -local condition_i = Condition(CONDITION_INVISIBLE) -condition_i:setParameter(CONDITION_PARAM_TICKS, 600000) -combat_i:addCondition(condition_i) -local itemIds = { [9079] = 0, [9080] = 1, [9081] = 2, [9082] = 3, [9083] = 4, [9084] = 5, [9085] = 6, [9086] = 7, [9087] = 8, [9088] = 9, [11584] = 10, [11586] = 11, [11587] = 12, [11588] = 13 } - -local jeanPierreFood = Action() - -function jeanPierreFood.onUse(player, item, frompos, item2, topos) - local cid = player:getId() - if player:getStorageValue(17110 + itemIds[item.itemid]) > os.time() then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") - return true - end - player:setStorageValue(17110 + itemIds[item.itemid], os.time() + (15 * 60)) - - if item.itemid == 9079 then - item:remove(1) - Creature(cid):addHealth(getCreatureMaxHealth(cid) - getCreatureHealth(cid)) - player:say("Gulp.", TALKTYPE_MONSTER_SAY) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your health has been refilled.") - player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - return true - elseif item.itemid == 9080 then - item:remove(1) - for i = 1, #conditions do - doRemoveCondition(cid, conditions[i]) - end - player:say("Chomp.", TALKTYPE_MONSTER_SAY) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel better body condition.") - player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - return true - elseif item.itemid == 9081 then - item:remove(1) - Creature(cid):addCondition(condition_shield) - player:say("Chomp.", TALKTYPE_MONSTER_SAY) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel less vulnerable.") - player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - return true - elseif item.itemid == 9082 then - item:remove(1) - Creature(cid):addCondition(condition_ml) - player:say("Chomp.", TALKTYPE_MONSTER_SAY) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel smarter.") - player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - return true - elseif item.itemid == 9083 then - item:remove(1) - player:say("Slurp.", TALKTYPE_MONSTER_SAY) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You don't really know what this did to you, but suddenly you feel very happy.") - player:getPosition():sendMagicEffect(CONST_ME_HEARTS) - return true - elseif item.itemid == 9084 then - item:remove(1) - Creature(cid):addCondition(condition_melee) - player:say("Yum.", TALKTYPE_MONSTER_SAY) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel stronger.") - player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - return true - elseif item.itemid == 9085 then - item:remove(1) - Creature(cid):addCondition(condition_speed) - player:say("Munch.", TALKTYPE_MONSTER_SAY) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your speed has been increased.") - player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - return true - elseif item.itemid == 9086 then - item:remove(1) - Creature(cid):addMana(Creature(cid):getMaxMana() - Creature(cid):getMana()) - player:say("Chomp.", TALKTYPE_MONSTER_SAY) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your mana has been refilled.") - player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - return true - elseif item.itemid == 9087 then - item:remove(1) - Creature(cid):addCondition(condition_dist) - player:say("Mmmm.", TALKTYPE_MONSTER_SAY) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel more focused.") - player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - return true - elseif item.itemid == 9088 then - item:remove(1) - Creature(cid):addCondition(condition_f) - player:say("Smack.", TALKTYPE_MONSTER_SAY) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You felt fishing inspiration.") - player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - return true - elseif item.itemid == 11584 then - item:remove(1) - player:setStorageValue(15287, os.time() + 86400) - player:say("Yum.", TALKTYPE_MONSTER_SAY) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Underwater walking speed increased.") - player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - return true - elseif item.itemid == 11586 then - if math.random(1, 5) == 5 then - item:remove(1) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You take the last gulp from the large bowl. No leftovers!") - else - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You take a gulp from the large bowl, but there's still some blackjack in it.") - end - Creature(cid):addHealth(getCreatureMaxHealth(cid) - getCreatureHealth(cid)) - player:say("Gulp.", TALKTYPE_MONSTER_SAY) - player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - return true - elseif item.itemid == 11587 then - item:remove(1) - local c = { condition_shield, condition_ml, condition_melee, condition_dist, condition_speed } - local r = math.random(1, 4) - if r == 1 then - Creature(cid):addCondition(c[math.random(1, #c)]) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel stronger, but you have no idea what was increased.") - elseif r == 2 then - doSetCreatureLight(cid, 15, 154, 60 * 60 * 1000) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel enlightened.") - elseif r == 3 then - Creature(cid):addCondition(condition_i) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You became invisible.") - elseif r == 4 then - Creature(cid):addHealth(getCreatureMaxHealth(cid) - getCreatureHealth(cid)) - Creature(cid):addMana(Creature(cid):getMaxMana() - Creature(cid):getMana()) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your vitality has been restored.") - end - player:say("Smack.", TALKTYPE_MONSTER_SAY) - player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - return true - elseif item.itemid == 11588 then - local ring = getPlayerSlotItem(cid, CONST_SLOT_RING) - local r_t = { - [3095] = 3092, - [3096] = 3093, - [6300] = 6299, - [3099] = 3097, - [3088] = 3051, - [3089] = 3052, - [3048] = 3048, - [3087] = 3050, - [16264] = 16114, - [3100] = 3098, - [12670] = 12669, - [3086] = 3049, - [3094] = 3091, - [3090] = 3053, - } - if ring.itemid == 0 then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "No ring equipped.") - player:getPosition():sendMagicEffect(CONST_ME_POFF) - return true - end - - if r_t[ring.itemid] ~= nil then - item:remove(1) - if ring.itemid == r_t[ring.itemid] then - r_m_am = 20 - else - r_m_am = 1 - end - - for i = 1, 10 do - doPlayerAddItem(cid, r_t[ring.itemid], r_m_am) - end - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your ring has been multiplied.") - player:say("Slurp!", TALKTYPE_MONSTER_SAY) - return true - else - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "This ring cannot be multiplied.") - player:getPosition():sendMagicEffect(CONST_ME_POFF) - return true - end - end -end - -for index, value in pairs(itemIds) do - jeanPierreFood:id(index) -end - -jeanPierreFood:register() diff --git a/data-otservbr-global/scripts/movements/others/drowning.lua b/data-otservbr-global/scripts/movements/others/drowning.lua deleted file mode 100644 index 6f4fbd7efa6..00000000000 --- a/data-otservbr-global/scripts/movements/others/drowning.lua +++ /dev/null @@ -1,36 +0,0 @@ -local condition = Condition(CONDITION_DROWN) -condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, -20) -condition:setParameter(CONDITION_PARAM_TICKS, -1) -condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 2000) - -local drowning = MoveEvent() -drowning:type("stepin") - -function drowning.onStepIn(player, item, position, fromPosition) - if player:isPlayer() then - local headItem = player:getSlotItem(CONST_SLOT_HEAD) - if headItem and table.contains({ 5460, 11585, 13995 }, headItem.itemid) then - return true - elseif math.random(1, 10) == 1 then - position:sendMagicEffect(CONST_ME_BUBBLES) - end - player:addCondition(condition) - end - return true -end - -drowning:id(5404, 5405, 5406, 5407, 5408, 5409, 5743, 5764, 8755, 8756, 8757, 9291) -drowning:register() - -drowning = MoveEvent() -drowning:type("stepout") - -function drowning.onStepOut(creature, item, position, fromPosition) - if creature:isPlayer() then - creature:removeCondition(CONDITION_DROWN) - end - return true -end - -drowning:id(5404, 5405, 5406, 5407, 5408, 5409, 5743, 5764, 8755, 8756, 8757, 9291) -drowning:register() diff --git a/data/scripts/actions/items/banana_chocolate_shake.lua b/data/scripts/actions/items/banana_chocolate_shake.lua new file mode 100644 index 00000000000..083b4f965da --- /dev/null +++ b/data/scripts/actions/items/banana_chocolate_shake.lua @@ -0,0 +1,18 @@ +local bananaChocolateShake = Action() + +function bananaChocolateShake.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:hasExhaustion("special-foods-cooldown") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") + return true + end + + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You don't really know what this did to you, but suddenly you feel very happy.") + player:say("Slurp.", TALKTYPE_MONSTER_SAY) + player:getPosition():sendMagicEffect(CONST_ME_HEARTS) + player:setExhaustion("special-foods-cooldown", 10 * 60) + item:remove(1) + return true +end + +bananaChocolateShake:id(9083) +bananaChocolateShake:register() diff --git a/data/scripts/actions/items/blessed_steak.lua b/data/scripts/actions/items/blessed_steak.lua new file mode 100644 index 00000000000..32b2d12162e --- /dev/null +++ b/data/scripts/actions/items/blessed_steak.lua @@ -0,0 +1,19 @@ +local blessedSteak = Action() + +function blessedSteak.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:hasExhaustion("special-foods-cooldown") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") + return true + end + + player:addMana(player:getMaxMana()) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your mana has been refilled.") + player:say("Chomp.", TALKTYPE_MONSTER_SAY) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) + player:setExhaustion("special-foods-cooldown", 10 * 60) + item:remove(1) + return true +end + +blessedSteak:id(9086) +blessedSteak:register() diff --git a/data/scripts/actions/items/carrot_cake.lua b/data/scripts/actions/items/carrot_cake.lua new file mode 100644 index 00000000000..28432188685 --- /dev/null +++ b/data/scripts/actions/items/carrot_cake.lua @@ -0,0 +1,26 @@ +local distanceCondition = Condition(CONDITION_ATTRIBUTES) +distanceCondition:setParameter(CONDITION_PARAM_SUBID, JeanPierreDistance) +distanceCondition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1) +distanceCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) +distanceCondition:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 10) +distanceCondition:setParameter(CONDITION_PARAM_FORCEUPDATE, true) + +local carrotCake = Action() + +function carrotCake.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:hasExhaustion("special-foods-cooldown") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") + return true + end + + player:addCondition(distanceCondition) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel more focused.") + player:say("Mmmm.", TALKTYPE_MONSTER_SAY) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) + player:setExhaustion("special-foods-cooldown", 10 * 60) + item:remove(1) + return true +end + +carrotCake:id(9087) +carrotCake:register() diff --git a/data/scripts/actions/items/coconut_shrimp_bake.lua b/data/scripts/actions/items/coconut_shrimp_bake.lua new file mode 100644 index 00000000000..bc7ba97ddd3 --- /dev/null +++ b/data/scripts/actions/items/coconut_shrimp_bake.lua @@ -0,0 +1,31 @@ +local coconutShrimpBake = Action() + +function coconutShrimpBake.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:hasExhaustion("special-foods-cooldown") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") + return true + end + + local headItem = player:getSlotItem(CONST_SLOT_HEAD) + if not headItem then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You should only eat this dish when wearing a helmet of the deep or a depth galea and walking underwater.") + return true + end + + local acceptableHelmets = { 5460, 11585, 13995 } + if not table.contains(acceptableHelmets, headItem:getId()) then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You should only eat this dish when wearing a helmet of the deep or a depth galea and walking underwater.") + return true + end + + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your underwater walking speed while wearing a " .. headItem:getName() .. " has increased for twenty-four hours.") + player:say("Yum.", TALKTYPE_MONSTER_SAY) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) + player:setExhaustion("special-foods-cooldown", 10 * 60) + player:setExhaustion("coconut-shrimp-bake", 24 * 60 * 60) + item:remove(1) + return true +end + +coconutShrimpBake:id(11584) +coconutShrimpBake:register() diff --git a/data/scripts/actions/items/demonic_candy_ball.lua b/data/scripts/actions/items/demonic_candy_ball.lua new file mode 100644 index 00000000000..c2e44c1efb1 --- /dev/null +++ b/data/scripts/actions/items/demonic_candy_ball.lua @@ -0,0 +1,72 @@ +local defenseCondition = Condition(CONDITION_ATTRIBUTES) +defenseCondition:setParameter(CONDITION_PARAM_SUBID, JeanPierreDefense) +defenseCondition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1) +defenseCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) +defenseCondition:setParameter(CONDITION_PARAM_SKILL_SHIELD, 10) +defenseCondition:setParameter(CONDITION_PARAM_FORCEUPDATE, true) + +local magicLevelCondition = Condition(CONDITION_ATTRIBUTES) +magicLevelCondition:setParameter(CONDITION_PARAM_SUBID, JeanPierreMagicLevel) +magicLevelCondition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1) +magicLevelCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) +magicLevelCondition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 5) +magicLevelCondition:setParameter(CONDITION_PARAM_FORCEUPDATE, true) + +local meleeCondition = Condition(CONDITION_ATTRIBUTES) +meleeCondition:setParameter(CONDITION_PARAM_SUBID, JeanPierreMelee) +meleeCondition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1) +meleeCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) +meleeCondition:setParameter(CONDITION_PARAM_SKILL_MELEE, 10) +meleeCondition:setParameter(CONDITION_PARAM_FORCEUPDATE, true) + +local distanceCondition = Condition(CONDITION_ATTRIBUTES) +distanceCondition:setParameter(CONDITION_PARAM_SUBID, JeanPierreDistance) +distanceCondition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1) +distanceCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) +distanceCondition:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 10) +distanceCondition:setParameter(CONDITION_PARAM_FORCEUPDATE, true) + +local speedCondition = Condition(CONDITION_HASTE) +speedCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) +speedCondition:setParameter(CONDITION_PARAM_SPEED, 729) + +local lightCondition = Condition(CONDITION_LIGHT) +lightCondition:setParameter(CONDITION_PARAM_LIGHT_LEVEL, 15) +lightCondition:setParameter(CONDITION_PARAM_LIGHT_COLOR, 154) +lightCondition:setTicks(60 * 60 * 1000) + +local demonicCandyBall = Action() + +function demonicCandyBall.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:hasExhaustion("special-foods-cooldown") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") + return true + end + + local availableConditions = { defenseCondition, magicLevelCondition, meleeCondition, distanceCondition, speedCondition } + local randomConditionIndex = math.random(1, 4) + + if randomConditionIndex == 1 then + player:addCondition(availableConditions[math.random(1, #availableConditions)]) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel stronger, but you have no idea what was increased.") + elseif randomConditionIndex == 2 then + player:addCondition(lightCondition) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel enlightened.") + elseif randomConditionIndex == 3 then + player:addCondition(condition_i) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You became invisible.") + elseif randomConditionIndex == 4 then + player:addHealth(player:getMaxHealth()) + player:addMana(player:getMaxMana()) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your vitality has been restored.") + end + + player:say("Smack.", TALKTYPE_MONSTER_SAY) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) + player:setExhaustion("special-foods-cooldown", 10 * 60) + item:remove(1) + return true +end + +demonicCandyBall:id(11587) +demonicCandyBall:register() diff --git a/data/scripts/actions/items/filled_jalapeno_peppers.lua b/data/scripts/actions/items/filled_jalapeno_peppers.lua new file mode 100644 index 00000000000..57df8d6b191 --- /dev/null +++ b/data/scripts/actions/items/filled_jalapeno_peppers.lua @@ -0,0 +1,23 @@ +local speedCondition = Condition(CONDITION_HASTE) +speedCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) +speedCondition:setParameter(CONDITION_PARAM_SPEED, 729) + +local filledJalapenoPeppers = Action() + +function filledJalapenoPeppers.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:hasExhaustion("special-foods-cooldown") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") + return true + end + + player:addCondition(speedCondition) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your speed has been increased.") + player:say("Munch.", TALKTYPE_MONSTER_SAY) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) + player:setExhaustion("special-foods-cooldown", 10 * 60) + item:remove(1) + return true +end + +filledJalapenoPeppers:id(9085) +filledJalapenoPeppers:register() diff --git a/data/scripts/actions/items/hireling_foods.lua b/data/scripts/actions/items/hireling_foods.lua index 6b86c8d242a..30783fde9c8 100644 --- a/data/scripts/actions/items/hireling_foods.lua +++ b/data/scripts/actions/items/hireling_foods.lua @@ -42,7 +42,7 @@ function hirelingFoods.onUse(player, item, fromPosition, target, toPosition, isH return true end - if player:hasExhaustion("hireling-foods-cooldown") then + if player:hasExhaustion("special-foods-cooldown") then player:sendCancelMessage("You're still too full to eat any gourmet dishes for a while.") return true end @@ -56,7 +56,7 @@ function hirelingFoods.onUse(player, item, fromPosition, target, toPosition, isH end player:say(dish.message, TALKTYPE_MONSTER_SAY) - player:setExhaustion("hireling-foods-cooldown", 10 * 60) + player:setExhaustion("special-foods-cooldown", 10 * 60) item:remove(1) return true diff --git a/data/scripts/actions/items/hydra_tongue_salad.lua b/data/scripts/actions/items/hydra_tongue_salad.lua new file mode 100644 index 00000000000..4c8cad3258a --- /dev/null +++ b/data/scripts/actions/items/hydra_tongue_salad.lua @@ -0,0 +1,35 @@ +local conditionsToRemove = { + CONDITION_POISON, + CONDITION_FIRE, + CONDITION_ENERGY, + CONDITION_PARALYZE, + CONDITION_DRUNK, + CONDITION_DROWN, + CONDITION_FREEZING, + CONDITION_DAZZLED, + CONDITION_CURSED, + CONDITION_BLEEDING, +} + +local hydraTongueSalad = Action() + +function hydraTongueSalad.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:hasExhaustion("special-foods-cooldown") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") + return true + end + + for _, conditionType in ipairs(conditionsToRemove) do + player:removeCondition(conditionType) + end + + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel better body condition.") + player:say("Chomp.", TALKTYPE_MONSTER_SAY) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) + player:setExhaustion("special-foods-cooldown", 10 * 60) + item:remove(1) + return true +end + +hydraTongueSalad:id(9080) +hydraTongueSalad:register() diff --git a/data/scripts/actions/items/northern_fishburger.lua b/data/scripts/actions/items/northern_fishburger.lua new file mode 100644 index 00000000000..3648ba102b3 --- /dev/null +++ b/data/scripts/actions/items/northern_fishburger.lua @@ -0,0 +1,26 @@ +local fishingCondition = Condition(CONDITION_ATTRIBUTES) +fishingCondition:setParameter(CONDITION_PARAM_SUBID, JeanPierreFishing) +fishingCondition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1) +fishingCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) +fishingCondition:setParameter(CONDITION_PARAM_SKILL_FISHING, 50) +fishingCondition:setParameter(CONDITION_PARAM_FORCEUPDATE, true) + +local northernFishburger = Action() + +function northernFishburger.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:hasExhaustion("special-foods-cooldown") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") + return true + end + + player:addCondition(fishingCondition) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You felt fishing inspiration.") + player:say("Smack.", TALKTYPE_MONSTER_SAY) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) + player:setExhaustion("special-foods-cooldown", 10 * 60) + item:remove(1) + return true +end + +northernFishburger:id(9088) +northernFishburger:register() diff --git a/data/scripts/actions/items/pot_of_blackjack.lua b/data/scripts/actions/items/pot_of_blackjack.lua new file mode 100644 index 00000000000..fd4cc52b920 --- /dev/null +++ b/data/scripts/actions/items/pot_of_blackjack.lua @@ -0,0 +1,35 @@ +local potOfBlackjack = Action() + +function potOfBlackjack.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:hasExhaustion("special-foods-cooldown") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") + return true + end + + local remainingGulps = player:kv():get("pot-of-blackjack") or math.random(2, 4) + + if remainingGulps > 0 then + remainingGulps = remainingGulps - 1 + player:kv():set("pot-of-blackjack", remainingGulps) + + local message + if remainingGulps > 0 then + message = "You take a gulp from the large bowl, but there's still some blackjack in it." + else + message = "You take the last gulp from the large bowl. No leftovers!" + end + + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, message) + end + + player:addHealth(5000) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You take a gulp from the large bowl.") + player:say("Gulp.", TALKTYPE_MONSTER_SAY) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) + player:setExhaustion("special-foods-cooldown", 10 * 60) + item:remove(1) + return true +end + +potOfBlackjack:id(11586) +potOfBlackjack:register() diff --git a/data/scripts/actions/items/potions.lua b/data/scripts/actions/items/potions.lua index 55bf20e0e18..02e92349363 100644 --- a/data/scripts/actions/items/potions.lua +++ b/data/scripts/actions/items/potions.lua @@ -1,19 +1,19 @@ local berserk = Condition(CONDITION_ATTRIBUTES) berserk:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000) -berserk:setParameter(CONDITION_PARAM_SUBID, AttrSubId_JeanPierreMelee) +berserk:setParameter(CONDITION_PARAM_SUBID, JeanPierreMelee) berserk:setParameter(CONDITION_PARAM_SKILL_MELEE, 5) berserk:setParameter(CONDITION_PARAM_SKILL_SHIELD, -10) berserk:setParameter(CONDITION_PARAM_BUFF_SPELL, true) local mastermind = Condition(CONDITION_ATTRIBUTES) mastermind:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000) -mastermind:setParameter(CONDITION_PARAM_SUBID, AttrSubId_JeanPierreMagic) +mastermind:setParameter(CONDITION_PARAM_SUBID, JeanPierreMagicLevel) mastermind:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 3) mastermind:setParameter(CONDITION_PARAM_BUFF_SPELL, true) local bullseye = Condition(CONDITION_ATTRIBUTES) bullseye:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000) -bullseye:setParameter(CONDITION_PARAM_SUBID, AttrSubId_JeanPierreDistance) +bullseye:setParameter(CONDITION_PARAM_SUBID, JeanPierreDistance) bullseye:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 5) bullseye:setParameter(CONDITION_PARAM_SKILL_SHIELD, -10) bullseye:setParameter(CONDITION_PARAM_BUFF_SPELL, true) diff --git a/data/scripts/actions/items/roasted_dragon_wings.lua b/data/scripts/actions/items/roasted_dragon_wings.lua new file mode 100644 index 00000000000..719c7fa0e20 --- /dev/null +++ b/data/scripts/actions/items/roasted_dragon_wings.lua @@ -0,0 +1,26 @@ +local defenseCondition = Condition(CONDITION_ATTRIBUTES) +defenseCondition:setParameter(CONDITION_PARAM_SUBID, JeanPierreDefense) +defenseCondition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1) +defenseCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) +defenseCondition:setParameter(CONDITION_PARAM_SKILL_SHIELD, 10) +defenseCondition:setParameter(CONDITION_PARAM_FORCEUPDATE, true) + +local roastedDragonWings = Action() + +function roastedDragonWings.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:hasExhaustion("special-foods-cooldown") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") + return true + end + + player:addCondition(defenseCondition) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel less vulnerable.") + player:say("Chomp.", TALKTYPE_MONSTER_SAY) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) + player:setExhaustion("special-foods-cooldown", 10 * 60) + item:remove(1) + return true +end + +roastedDragonWings:id(9081) +roastedDragonWings:register() diff --git a/data/scripts/actions/items/rotworm_stew.lua b/data/scripts/actions/items/rotworm_stew.lua new file mode 100644 index 00000000000..7b965da5857 --- /dev/null +++ b/data/scripts/actions/items/rotworm_stew.lua @@ -0,0 +1,19 @@ +local rotwormStew = Action() + +function rotwormStew.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:hasExhaustion("special-foods-cooldown") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") + return true + end + + player:addHealth(player:getMaxHealth()) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your health has been refilled.") + player:say("Gulp.", TALKTYPE_MONSTER_SAY) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) + player:setExhaustion("special-foods-cooldown", 10 * 60) + item:remove(1) + return true +end + +rotwormStew:id(9079) +rotwormStew:register() diff --git a/data/scripts/actions/items/sweet_mangonaise_elixir.lua b/data/scripts/actions/items/sweet_mangonaise_elixir.lua new file mode 100644 index 00000000000..fc5d1f33272 --- /dev/null +++ b/data/scripts/actions/items/sweet_mangonaise_elixir.lua @@ -0,0 +1,53 @@ +local ringMultiplicationTable = { + [3048] = 3048, + [3049] = 3086, + [3050] = 3087, + [3051] = 3088, + [3052] = 3089, + [3053] = 3090, + [3091] = 3094, + [3092] = 3095, + [3093] = 3096, + [3097] = 3099, + [3098] = 3100, + [6299] = 6300, + [12669] = 12670, + [16114] = 16264, +} + +local sweetMangonaiseElixir = Action() + +function sweetMangonaiseElixir.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:hasExhaustion("special-foods-cooldown") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") + return true + end + + local playerRing = player:getSlotItem(CONST_SLOT_RING) + if not playerRing or not table.contains(ringMultiplicationTable, playerRing:getId()) then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "No ring equipped.") + player:getPosition():sendMagicEffect(CONST_ME_POFF) + return true + end + + local ringId = ringMultiplicationTable[playerRing:getId()] + if not ringId then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "This ring cannot be multiplied.") + player:getPosition():sendMagicEffect(CONST_ME_POFF) + return false + end + + for i = 1, 10 do + player:addItem(ringId) + end + + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your ring has been multiplied.") + player:say("Slurp.", TALKTYPE_MONSTER_SAY) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) + player:setExhaustion("special-foods-cooldown", 10 * 60) + item:remove(1) + return true +end + +sweetMangonaiseElixir:id(11588) +sweetMangonaiseElixir:register() diff --git a/data/scripts/actions/items/tropical_fried_terrorbird.lua b/data/scripts/actions/items/tropical_fried_terrorbird.lua new file mode 100644 index 00000000000..342ba545a25 --- /dev/null +++ b/data/scripts/actions/items/tropical_fried_terrorbird.lua @@ -0,0 +1,26 @@ +local magicLevelCondition = Condition(CONDITION_ATTRIBUTES) +magicLevelCondition:setParameter(CONDITION_PARAM_SUBID, JeanPierreMagicLevel) +magicLevelCondition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1) +magicLevelCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) +magicLevelCondition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 5) +magicLevelCondition:setParameter(CONDITION_PARAM_FORCEUPDATE, true) + +local tropicalFriedTerrorbird = Action() + +function tropicalFriedTerrorbird.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:hasExhaustion("special-foods-cooldown") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") + return true + end + + player:addCondition(magicLevelCondition) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel smarter.") + player:say("Chomp.", TALKTYPE_MONSTER_SAY) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) + player:setExhaustion("special-foods-cooldown", 10 * 60) + item:remove(1) + return true +end + +tropicalFriedTerrorbird:id(9082) +tropicalFriedTerrorbird:register() diff --git a/data/scripts/actions/items/veggie_casserole.lua b/data/scripts/actions/items/veggie_casserole.lua new file mode 100644 index 00000000000..d0ef6c99a78 --- /dev/null +++ b/data/scripts/actions/items/veggie_casserole.lua @@ -0,0 +1,26 @@ +local meleeCondition = Condition(CONDITION_ATTRIBUTES) +meleeCondition:setParameter(CONDITION_PARAM_SUBID, JeanPierreMelee) +meleeCondition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1) +meleeCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000) +meleeCondition:setParameter(CONDITION_PARAM_SKILL_MELEE, 10) +meleeCondition:setParameter(CONDITION_PARAM_FORCEUPDATE, true) + +local veggieCasserole = Action() + +function veggieCasserole.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:hasExhaustion("special-foods-cooldown") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait before using it again.") + return true + end + + player:addCondition(meleeCondition) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel stronger.") + player:say("Yum.", TALKTYPE_MONSTER_SAY) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) + player:setExhaustion("special-foods-cooldown", 10 * 60) + item:remove(1) + return true +end + +veggieCasserole:id(9084) +veggieCasserole:register() diff --git a/data-canary/scripts/movements/drowning.lua b/data/scripts/movements/drowning.lua similarity index 50% rename from data-canary/scripts/movements/drowning.lua rename to data/scripts/movements/drowning.lua index 00266d57d1e..a32dcb216cb 100644 --- a/data-canary/scripts/movements/drowning.lua +++ b/data/scripts/movements/drowning.lua @@ -3,16 +3,31 @@ condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, -20) condition:setParameter(CONDITION_PARAM_TICKS, -1) condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 2000) +local conditionHaste = Condition(CONDITION_HASTE) +conditionHaste:setTicks(-1) +conditionHaste:setFormula(1.0, 300, 1.0, 300) + local drowning = MoveEvent() drowning:type("stepin") function drowning.onStepIn(creature, item, position, fromPosition) - if creature:isPlayer() then - if math.random(1, 10) == 1 then - position:sendMagicEffect(CONST_ME_BUBBLES) + local player = creature:getPlayer() + if not player then + return false + end + + local headItem = player:getSlotItem(CONST_SLOT_HEAD) + if headItem and table.contains({ 5460, 11585, 13995 }, headItem:getId()) then + if player:hasExhaustion("coconut-shrimp-bake") then + player:addCondition(conditionHaste) end - creature:addCondition(condition) + + return true + elseif math.random(1, 10) == 1 then + position:sendMagicEffect(CONST_ME_BUBBLES) end + + player:addCondition(condition) return true end @@ -23,9 +38,13 @@ drowning = MoveEvent() drowning:type("stepout") function drowning.onStepOut(creature, item, position, fromPosition) - if creature:isPlayer() then - creature:removeCondition(CONDITION_DROWN) + local player = creature:getPlayer() + if not player then + return false end + + player:removeCondition(CONDITION_DROWN) + player:removeCondition(CONDITION_HASTE) return true end diff --git a/src/lua/functions/core/game/global_functions.cpp b/src/lua/functions/core/game/global_functions.cpp index 4c956dcb6d4..cbb133211f8 100644 --- a/src/lua/functions/core/game/global_functions.cpp +++ b/src/lua/functions/core/game/global_functions.cpp @@ -94,24 +94,6 @@ int GlobalFunctions::luaDoPlayerAddItem(lua_State* L) { return 1; } -int GlobalFunctions::luaDoSetCreatureLight(lua_State* L) { - // doSetCreatureLight(cid, lightLevel, lightColor, time) - std::shared_ptr creature = getCreature(L, 1); - if (!creature) { - reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND)); - pushBoolean(L, false); - return 1; - } - - uint16_t level = getNumber(L, 2); - uint16_t color = getNumber(L, 3); - uint32_t time = getNumber(L, 4); - std::shared_ptr condition = Condition::createCondition(CONDITIONID_COMBAT, CONDITION_LIGHT, time, level | (color << 8)); - creature->addCondition(condition); - pushBoolean(L, true); - return 1; -} - int GlobalFunctions::luaIsValidUID(lua_State* L) { // isValidUID(uid) pushBoolean(L, getScriptEnv()->getThingByUID(getNumber(L, -1)) != nullptr); diff --git a/src/lua/functions/core/game/global_functions.hpp b/src/lua/functions/core/game/global_functions.hpp index 1b9f3fbe12f..cef752c6695 100644 --- a/src/lua/functions/core/game/global_functions.hpp +++ b/src/lua/functions/core/game/global_functions.hpp @@ -25,7 +25,6 @@ class GlobalFunctions final : LuaScriptInterface { lua_register(L, "doAreaCombatMana", GlobalFunctions::luaDoAreaCombatMana); lua_register(L, "doChallengeCreature", GlobalFunctions::luaDoChallengeCreature); lua_register(L, "doPlayerAddItem", GlobalFunctions::luaDoPlayerAddItem); - lua_register(L, "doSetCreatureLight", GlobalFunctions::luaDoSetCreatureLight); lua_register(L, "doTargetCombatCondition", GlobalFunctions::luaDoTargetCombatCondition); lua_register(L, "doTargetCombatDispel", GlobalFunctions::luaDoTargetCombatDispel); lua_register(L, "doTargetCombatHealth", GlobalFunctions::luaDoTargetCombatHealth); @@ -66,7 +65,6 @@ class GlobalFunctions final : LuaScriptInterface { static int luaDoAreaCombatMana(lua_State* L); static int luaDoChallengeCreature(lua_State* L); static int luaDoPlayerAddItem(lua_State* L); - static int luaDoSetCreatureLight(lua_State* L); static int luaDoTargetCombatCondition(lua_State* L); static int luaDoTargetCombatDispel(lua_State* L); static int luaDoTargetCombatHealth(lua_State* L);