fluids.lua

main 86 lines · 2.6 KB Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1local drunk = Condition(CONDITION_DRUNK)
2drunk:setParameter(CONDITION_PARAM_TICKS, 60000)
3
4local poison = Condition(CONDITION_POISON)
5poison:setParameter(CONDITION_PARAM_DELAYED, true)
6poison:setParameter(CONDITION_PARAM_MINVALUE, -50)
7poison:setParameter(CONDITION_PARAM_MAXVALUE, -120)
8poison:setParameter(CONDITION_PARAM_STARTVALUE, -5)
9poison:setParameter(CONDITION_PARAM_TICKINTERVAL, 4000)
10poison:setParameter(CONDITION_PARAM_FORCEUPDATE, true)
11
12local fluidMessage = {
13 [3] = "Aah...",
14 [4] = "Urgh!",
15 [5] = "Mmmh.",
16 [7] = "Aaaah...",
17 [10] = "Aaaah...",
18 [11] = "Urgh!",
19 [13] = "Urgh!",
20 [15] = "Aah...",
21 [19] = "Urgh!",
22 [27] = "Aah...",
23 [43] = "Aaaah..."
24}
25
26local distillery = {[5513] = 5469, [5514] = 5470}
27
28function onUse(player, item, fromPosition, target, toPosition, isHotkey)
29 local targetItemType = ItemType(target.itemid)
30 if targetItemType and targetItemType:isFluidContainer() then
31 if target.type == 0 and item.type ~= 0 then
32 target:transform(target:getId(), item.type)
33 item:transform(item:getId(), 0)
34 return true
35 elseif target.type ~= 0 and item.type == 0 then
36 target:transform(target:getId(), 0)
37 item:transform(item:getId(), target.type)
38 return true
39 end
40 end
41
42 if target.itemid == 1 then
43 if item.type == 0 then
44 player:sendTextMessage(MESSAGE_STATUS_SMALL, "It is empty.")
45 elseif target.uid == player.uid then
46 if table.contains({3, 15, 43}, item.type) then
47 player:addCondition(drunk)
48 elseif item.type == 4 then
49 player:addCondition(poison)
50 elseif item.type == 7 then
51 player:addMana(math.random(50, 150))
52 fromPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
53 elseif item.type == 10 then
54 player:addHealth(60)
55 fromPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
56 end
57 player:say(fluidMessage[item.type] or "Gulp.", TALKTYPE_MONSTER_SAY)
58 item:transform(item:getId(), 0)
59 else
60 Game.createItem(2016, item.type, toPosition):decay()
61 item:transform(item:getId(), 0)
62 end
63 else
64 local fluidSource = targetItemType and targetItemType:getFluidSource() or 0
65 if fluidSource ~= 0 then
66 item:transform(item:getId(), fluidSource)
67 elseif table.contains(distillery, target.itemid) then
68 local tmp = distillery[target.itemid]
69 if tmp then
70 item:transform(item:getId(), 0)
71 else
72 player:sendCancelMessage("You have to process the bunch into the distillery to get rum.")
73 end
74 elseif item.type == 0 then
75 player:sendTextMessage(MESSAGE_STATUS_SMALL, "It is empty.")
76 else
77 if toPosition.x == CONTAINER_POSITION then
78 toPosition = player:getPosition()
79 end
80 Game.createItem(2016, item.type, toPosition):decay()
81 item:transform(item:getId(), 0)
82 end
83 end
84 return true
85end
86
Top