Advertisement
Guest User

potions.lua

a guest
Dec 10th, 2013
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.29 KB | None | 0 0
  1. local ultimateHealthPot = 8473
  2. local greatHealthPot = 7591
  3. local greatManaPot = 7590
  4. local greatSpiritPot = 8472
  5. local strongHealthPot = 7588
  6. local strongManaPot = 7589
  7. local healthPot = 7618
  8. local manaPot = 7620
  9. local smallHealthPot = 8704
  10. local antidotePot = 8474
  11. local greatEmptyPot = 7635
  12. local strongEmptyPot = 7634
  13. local emptyPot = 7636
  14.  
  15. local antidote = createCombatObject()
  16. setCombatParam(antidote, COMBAT_PARAM_TYPE, COMBAT_HEALING)
  17. setCombatParam(antidote, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
  18. setCombatParam(antidote, COMBAT_PARAM_TARGETCASTERORTOPMOST, TRUE)
  19. setCombatParam(antidote, COMBAT_PARAM_AGGRESSIVE, false)
  20. setCombatParam(antidote, COMBAT_PARAM_DISPEL, CONDITION_POISON)
  21.  
  22. local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
  23. setConditionParam(exhaust, CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))
  24. -- 1000 - 100 due to exact condition timing. -100 doesn't hurt us, and players don't have reminding ~50ms exhaustion.
  25.  
  26. function onUse(cid, item, fromPosition, itemEx, toPosition)
  27.     if itemEx.itemid ~= 1 or itemEx.type ~= THING_TYPE_PLAYER then
  28.         return true
  29.     end
  30.  
  31.     if(getCreatureCondition(cid, CONDITION_EXHAUST_HEAL) == true) then
  32.         doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
  33.         return true
  34.     end
  35.  
  36.     if(item.itemid == antidotePot) then
  37.         if(doCombat(itemEx.uid, antidote, numberToVariant(itemEx.uid)) == LUA_ERROR) then
  38.             return false
  39.         end
  40.         doAddCondition(cid, exhaust)
  41.         doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
  42.         doRemoveItem(item.uid, 1)
  43.         doPlayerAddItem(cid, emptyPot, 1)
  44.     elseif(item.itemid == smallHealthPot) then
  45.         if(doTargetCombatHealth(0, itemEx.uid, COMBAT_HEALING, 50, 100, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
  46.             return false
  47.         end
  48.         doAddCondition(cid, exhaust)
  49.         doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
  50.         doRemoveItem(item.uid, 1)
  51.         doPlayerAddItem(cid, emptyPot, 1)
  52.     elseif(item.itemid == healthPot) then
  53.         if(doTargetCombatHealth(0, itemEx.uid, COMBAT_HEALING, 100, 200, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
  54.             return false
  55.         end
  56.         doAddCondition(cid, exhaust)
  57.         doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
  58.         doRemoveItem(item.uid, 1)
  59.         doPlayerAddItem(cid, emptyPot, 1)
  60.     elseif(item.itemid == manaPot) then
  61.         if(doTargetCombatMana(0, itemEx.uid, 70, 130, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
  62.             return false
  63.         end
  64.         doAddCondition(cid, exhaust)
  65.         doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
  66.         doRemoveItem(item.uid, 1)
  67.         doPlayerAddItem(cid, emptyPot, 1)
  68.     elseif(item.itemid == strongHealthPot) then
  69.         if(not(isKnight(itemEx.uid) or isPaladin(itemEx.uid)) or (getPlayerLevel(itemEx.uid) < 50)) and not(getPlayerGroupId(itemEx.uid) >= 2) then
  70.             doCreatureSay(itemEx.uid, "This potion can only be consumed by paladins and knights of level 50 or higher.", TALKTYPE_ORANGE_1)
  71.             return true
  72.         end
  73.  
  74.         if(doTargetCombatHealth(0, itemEx.uid, COMBAT_HEALING, 200, 400, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
  75.             return false
  76.         end
  77.         doAddCondition(cid, exhaust)
  78.         doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
  79.         doRemoveItem(item.uid, 1)
  80.         doPlayerAddItem(cid, strongEmptyPot, 1)
  81.     elseif(item.itemid == strongManaPot) then
  82.         if(not(isSorcerer(itemEx.uid) or isDruid(itemEx.uid) or isPaladin(itemEx.uid)) or (getPlayerLevel(itemEx.uid) < 50)) and not(getPlayerGroupId(itemEx.uid) >= 2) then
  83.             doCreatureSay(itemEx.uid, "This potion can only be consumed by sorcerers, druids and paladins of level 50 or higher.", TALKTYPE_ORANGE_1)
  84.             return true
  85.         end
  86.  
  87.         if(doTargetCombatMana(0, itemEx.uid, 110, 190, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
  88.             return false
  89.         end
  90.         doAddCondition(cid, exhaust)
  91.         doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
  92.         doRemoveItem(item.uid, 1)
  93.         doPlayerAddItem(cid, strongEmptyPot, 1)
  94.     elseif(item.itemid == greatSpiritPot) then
  95.         if(not(isPaladin(itemEx.uid)) or (getPlayerLevel(itemEx.uid) < 80)) and not(getPlayerGroupId(itemEx.uid) >= 2) then
  96.             doCreatureSay(itemEx.uid, "This potion can only be consumed by paladins of level 80 or higher.", TALKTYPE_ORANGE_1)
  97.             return TRUE
  98.         end
  99.  
  100.         if(doTargetCombatHealth(0, itemEx.uid, COMBAT_HEALING, 200, 400, CONST_ME_MAGIC_BLUE) == LUA_ERROR or doTargetCombatMana(0, itemEx.uid, 110, 190, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
  101.             return true
  102.         end
  103.         doAddCondition(cid, exhaust)
  104.         doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
  105.         doRemoveItem(item.uid, 1)
  106.         doPlayerAddItem(cid, greatEmptyPot, 1)
  107.     elseif(item.itemid == greatHealthPot) then
  108.         if(not(isKnight(itemEx.uid)) or (getPlayerLevel(itemEx.uid) < 80)) and not(getPlayerGroupId(itemEx.uid) >= 2) then
  109.             doCreatureSay(itemEx.uid, "This potion can only be consumed by knights of level 80 or higher.", TALKTYPE_ORANGE_1)
  110.             return true
  111.         end
  112.  
  113.         if(doTargetCombatHealth(0, itemEx.uid, COMBAT_HEALING, 500, 700, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
  114.             return false
  115.         end
  116.         doAddCondition(cid, exhaust)
  117.         doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
  118.         doRemoveItem(item.uid, 1)
  119.         doPlayerAddItem(cid, greatEmptyPot, 1)
  120.     elseif(item.itemid == greatManaPot) then
  121.         if(not(isSorcerer(itemEx.uid) or isDruid(itemEx.uid)) or (getPlayerLevel(itemEx.uid) < 80)) and not(getPlayerGroupId(itemEx.uid) >= 2) then
  122.             doCreatureSay(itemEx.uid, "This potion can only be consumed by sorcerers and druids of level 80 or higher.", TALKTYPE_ORANGE_1)
  123.             return true
  124.         end
  125.  
  126.         if(doTargetCombatMana(0, itemEx.uid, 200, 300, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
  127.             return false
  128.         end
  129.         doAddCondition(cid, exhaust)
  130.         doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
  131.         doRemoveItem(item.uid, 1)
  132.         doPlayerAddItem(cid, greatEmptyPot, 1)
  133.     elseif(item.itemid == ultimateHealthPot) then
  134.         if(not(isKnight(itemEx.uid)) or (getPlayerLevel(itemEx.uid) < 130)) and not(getPlayerGroupId(itemEx.uid) >= 2) then
  135.             doCreatureSay(cid, "This potion can only be consumed by knights of level 130 or higher.", TALKTYPE_ORANGE_1)
  136.             return true
  137.         end
  138.  
  139.         if(doTargetCombatHealth(0, itemEx.uid, COMBAT_HEALING, 800, 1000, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
  140.             return false
  141.         end
  142.         doAddCondition(cid, exhaust)
  143.         doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
  144.         doRemoveItem(item.uid, 1)
  145.         doPlayerAddItem(cid, greatEmptyPot, 1)
  146.     end
  147.     return true
  148. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement