potions.lua

main 83 lines · 4.4 KB Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1local berserk = Condition(CONDITION_ATTRIBUTES)
2berserk:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000)
3berserk:setParameter(CONDITION_PARAM_SKILL_MELEE, 5)
4berserk:setParameter(CONDITION_PARAM_SKILL_SHIELD, -10)
5berserk:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
6
7local mastermind = Condition(CONDITION_ATTRIBUTES)
8mastermind:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000)
9mastermind:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 3)
10mastermind:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
11
12local bullseye = Condition(CONDITION_ATTRIBUTES)
13bullseye:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000)
14bullseye:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 5)
15bullseye:setParameter(CONDITION_PARAM_SKILL_SHIELD, -10)
16bullseye:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
17
18local potions = {
19 [6558] = {transform = {7588, 7589}, effect = CONST_ME_DRAWBLOOD},
20 [7439] = {condition = berserk, vocations = {4, 8}, effect = CONST_ME_MAGIC_RED, description = "Only knights may drink this potion.", text = "You feel stronger."},
21 [7440] = {condition = mastermind, vocations = {1, 2, 5, 6}, effect = CONST_ME_MAGIC_BLUE, description = "Only sorcerers and druids may drink this potion.", text = "You feel smarter."},
22 [7443] = {condition = bullseye, vocations = {3, 7}, effect = CONST_ME_MAGIC_GREEN, description = "Only paladins may drink this potion.", text = "You feel more accurate."},
23 [7588] = {health = {250, 350}, vocations = {3, 4, 7, 8}, level = 50, flask = 7634, description = "Only knights and paladins of level 50 or above may drink this fluid."},
24 [7589] = {mana = {115, 185}, vocations = {1, 2, 3, 5, 6, 7}, level = 50, flask = 7634, description = "Only sorcerers, druids and paladins of level 50 or above may drink this fluid."},
25 [7590] = {mana = {150, 250}, vocations = {1, 2, 5, 6}, level = 80, flask = 7635, description = "Only druids and sorcerers of level 80 or above may drink this fluid."},
26 [7591] = {health = {425, 575}, vocations = {4, 8}, level = 80, flask = 7635, description = "Only knights of level 80 or above may drink this fluid."},
27 [7618] = {health = {125, 175}, flask = 7636},
28 [7620] = {mana = {75, 125}, flask = 7636},
29 [8472] = {health = {250, 350}, mana = {100, 200}, vocations = {3, 7}, level = 80, flask = 7635, description = "Only paladins of level 80 or above may drink this fluid."},
30 [8473] = {health = {650, 850}, vocations = {4, 8}, level = 130, flask = 7635, description = "Only knights of level 130 or above may drink this fluid."},
31 [8474] = {antidote = true, flask = 7636},
32 [8704] = {health = {60, 90}, flask = 7636},
33 [26029] = {mana = {425, 575}, vocations = {1, 2, 5, 6}, level = 130, flask = 7635, description = "Only druids and sorcerers of level 130 or above may drink this fluid."},
34 [26030] = {health = {420, 580}, mana = {200, 350}, vocations = {3, 7}, level = 130, flask = 7635, description = "Only paladins of level 130 or above may drink this fluid."},
35 [26031] = {health = {875, 1125}, vocations = {4, 8}, level = 200, flask = 7635, description = "Only knights of level 200 or above may drink this fluid."}
36}
37
38function onUse(player, item, fromPosition, target, toPosition, isHotkey)
39 if type(target) == "userdata" and not target:isPlayer() then
40 return false
41 end
42
43 local potion = potions[item:getId()]
44 if potion.level and player:getLevel() < potion.level or potion.vocations and not table.contains(potion.vocations, player:getVocation():getId()) then
45 player:say(potion.description, TALKTYPE_MONSTER_SAY)
46 return true
47 end
48
49 if potion.condition then
50 player:addCondition(potion.condition)
51 player:say(potion.text, TALKTYPE_MONSTER_SAY)
52 player:getPosition():sendMagicEffect(potion.effect)
53 elseif potion.transform then
54 item:transform(potion.transform[math.random(#potion.transform)])
55 item:getPosition():sendMagicEffect(potion.effect)
56 return true
57 else
58 if potion.health then
59 doTargetCombat(0, target, COMBAT_HEALING, potion.health[1], potion.health[2])
60 end
61
62 if potion.mana then
63 doTargetCombat(0, target, COMBAT_MANADRAIN, potion.mana[1], potion.mana[2])
64 end
65
66 if potion.antidote then
67 target:removeCondition(CONDITION_POISON)
68 end
69
70 player:addAchievementProgress("Potion Addict", 100000)
71 player:addItem(potion.flask)
72 target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
73 target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
74 end
75
76 if not configManager.getBoolean(configKeys.REMOVE_POTION_CHARGES) then
77 return true
78 end
79
80 item:remove(1)
81 return true
82end
83
Top