Advertisement
Alscara

fluids.lua

Jun 24th, 2015
527
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.64 KB | None | 0 0
  1. local drunk = Condition(CONDITION_DRUNK)
  2. drunk:setParameter(CONDITION_PARAM_TICKS, 60000)
  3.  
  4. local poison = Condition(CONDITION_POISON)
  5. poison:setParameter(CONDITION_PARAM_DELAYED, true)
  6. poison:setParameter(CONDITION_PARAM_MINVALUE, -50)
  7. poison:setParameter(CONDITION_PARAM_MAXVALUE, -120)
  8. poison:setParameter(CONDITION_PARAM_STARTVALUE, -5)
  9. poison:setParameter(CONDITION_PARAM_TICKINTERVAL, 4000)
  10. poison:setParameter(CONDITION_PARAM_FORCEUPDATE, true)
  11.  
  12. local fluidType = {3, 4, 5, 7, 10, 11, 13, 15, 19}
  13. local fluidMessage = {"Aah...", "Urgh!", "Mmmh.", "Aaaah...", "Aaaah...", "Urgh!", "Urgh!", "Aah...", "Urgh!"}
  14. local specialFluids = {36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110}
  15. local specialMessages = {"Ugh.", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah..."}
  16.  
  17.  
  18. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  19.     local targetItemType = ItemType(target.itemid)
  20.     if targetItemType and targetItemType:isFluidContainer() then
  21.         if target.type == 0 and item.type ~= 0 then
  22.             for i = 0, #specialFluids do
  23.                 if item.type == specialFluids[i] then
  24.                     target:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION))
  25.                     item:removeAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
  26.                 end
  27.             end
  28.             target:transform(target:getId(), item.type)
  29.             item:transform(item:getId(), 0)
  30.             return true
  31.         elseif target.type ~= 0 and item.type == 0 then
  32.             for i = 0, #specialFluids do
  33.                 if target.type == specialFluids[i] then
  34.                     item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, target:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION))
  35.                     target:removeAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
  36.                 end
  37.             end
  38.             item:transform(item:getId(), target.type)
  39.             target:transform(target:getId(), 0)
  40.             return true
  41.         end
  42.     end
  43.    
  44.     if target:isCreature() then
  45.         if item.type == 0 then
  46.             player:sendTextMessage(MESSAGE_STATUS_SMALL, "It is empty.")
  47.         elseif target == player then
  48.             if item.type == 3 or item.type == 15 then
  49.                 player:addCondition(drunk)
  50.             elseif item.type == 4 then
  51.                 player:addCondition(poison)
  52.             elseif item.type == 7 then
  53.                 player:addMana(math.random(50, 150))
  54.                 fromPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
  55.             elseif item.type == 10 then
  56.                 player:addHealth(60)
  57.                 fromPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
  58.             end
  59.             for i = 0, #fluidType do
  60.                 if item.type == fluidType[i] then
  61.                     player:say(fluidMessage[i], TALKTYPE_MONSTER_SAY)
  62.                     item:transform(item:getId(), 0)
  63.                     return true
  64.                 end
  65.             end
  66.             for i = 0, #specialFluids do
  67.                 if item.type == specialFluids[i] then
  68.                     local effects = item:getEffects(item)
  69.                     usePotion(player, effects)
  70.                     player:say(specialMessages[i], TALKTYPE_MONSTER_SAY)
  71.                     item:transform(item:getId(), 0)
  72.                     item:removeAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
  73.                     return true
  74.                 end
  75.             end
  76.             item:transform(item:getId(), 0)
  77.             player:say("Gulp.", TALKTYPE_MONSTER_SAY)
  78.         else
  79.             Game.createItem(2016, item.type, toPosition):decay()
  80.             item:transform(item:getId(), 0)
  81.         end
  82.     else
  83.         local fluidSource = targetItemType and targetItemType:getFluidSource() or 0
  84.         if fluidSource ~= 0 then
  85.             item:transform(item:getId(), fluidSource)
  86.         elseif item.type == 0 then
  87.             if item:getId() == 2006 and target:getId() == 12289 then
  88.                 player:sendAlchemyWindow()
  89.             else
  90.                 player:sendTextMessage(MESSAGE_STATUS_SMALL, "It is empty.")
  91.             end
  92.         else
  93.             if toPosition.x == CONTAINER_POSITION then
  94.                 toPosition = player:getPosition()
  95.             end
  96.             for i = 0, #specialFluids do
  97.                 if item.type == specialFluids[i] then
  98.                     item:removeAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
  99.                 end
  100.             end
  101.             Game.createItem(2016, item.type, toPosition):decay()
  102.             item:transform(item:getId(), 0)
  103.         end
  104.     end
  105.     return true
  106. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement