Don't like ads? PRO users don't see any ads ;-)
Guest

as

By: a guest on Jun 17th, 2012  |  syntax: Lua  |  size: 4.94 KB  |  hits: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. local config = {
  2.     removeOnUse = "no",
  3.     usableOnTarget = "yes", -- can be used on target? (fe. healing friend)
  4.     splashable = "no",
  5.     realAnimation = "no", -- make text effect visible only for players in range 1x1
  6.     healthMultiplier = 15,
  7.     manaMultiplier = 15
  8. }
  9.  
  10. config.removeOnUse = getBooleanFromString(config.removeOnUse)
  11. config.usableOnTarget = getBooleanFromString(config.usableOnTarget)
  12. config.splashable = getBooleanFromString(config.splashable)
  13. config.realAnimation = getBooleanFromString(config.realAnimation)
  14.  
  15. local POTIONS = {
  16.     [8704] = {empty = 7636, splash = 2, health = {50, 100}, storage = 49990}, -- small health potion
  17.     [7618] = {empty = 7636, splash = 2, health = {0.6,0.8,1.2}, storage = 49989}, -- health potion
  18.     [7588] = {empty = 7634, splash = 2, health = {2.1,2,2.5}, level = 50, storage = 49988}, -- strong health potion
  19.     [7591] = {empty = 7635, splash = 2, health = {4,7,10}, level = 80, storage = 49987}, -- great health potion
  20.     [8473] = {empty = 7635, splash = 2, health = 7, level = 130, storage = 49986}, -- ultimate health potion
  21.  
  22.     [7620] = {empty = 7636, splash = 7, mana = {1.5,1.1,0.5}, storage = 49985}, -- mana potion
  23.     [7589] = {empty = 7634, splash = 7, mana = {3.5,2,1}, level = 50, storage = 49984}, -- strong mana potion
  24.     [7590] = {empty = 7635, splash = 7, mana = {8,6,2.5}, level = 80, storage = 49983}, -- great mana potion
  25.  
  26.     [8472] = {empty = 7635, splash = 3, health = 3, mana = 3, level = 80, storage = 49982} -- great spirit potion
  27. }
  28.  
  29. local exhaust = createConditionObject(CONDITION_EXHAUST)
  30. setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
  31.  
  32. function onUse(cid, item, fromPosition, itemEx, toPosition)
  33.     local potion = POTIONS[item.itemid]
  34.     if(not potion) then
  35.         return false
  36.     end
  37.  
  38.     if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then
  39.         if(not config.splashable) then
  40.             return false
  41.         end
  42.  
  43.         if(toPosition.x == CONTAINER_POSITION) then
  44.             toPosition = getThingPos(item.uid)
  45.         end
  46.  
  47.         doDecayItem(doCreateItem(2016, potion.splash, toPosition))
  48.         doTransformItem(item.uid, potion.empty)
  49.         return true
  50.     end
  51.  
  52.     if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
  53.         doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
  54.         return true
  55.     end
  56.  
  57.     if potion.level and getPlayerLevel(cid) < potion.level and not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES) then
  58.         doCreatureSay(itemEx.uid, "You Need " .. potion.level .. " level for use this fluid.", TALKTYPE_ORANGE_1)
  59.         return true
  60.     end
  61.     local health = potion.health
  62.     local mana = potion.mana
  63.     if getPlayerStorageValue(cid, potion.storage) > 1 then
  64.     -- MAGOS
  65.        if getPlayerVocation(cid) == 1 and getPlayerVocation(cid) == 5 and getPlayerVocation(cid) == 9 and getPlayerVocation(cid) == 2 and getPlayerVocation(cid) == 6 and getPlayerVocation(cid) == 10 then
  66.         if health and not doCreatureAddHealth(itemEx.uid, getPlayerLevel(cid) * health[1]) then
  67.             return false
  68.         end
  69.         if mana and not doPlayerAddMana(itemEx.uid, getPlayerLevel(cid) * mana[1]) then
  70.             return false
  71.         end
  72.        end
  73.     -- PALLY
  74.        if getPlayerVocation(cid) == 3 and getPlayerVocation(cid) == 7 and getPlayerVocation(cid) == 11 then
  75.         if health and not doCreatureAddHealth(itemEx.uid, getPlayerLevel(cid) * health[2]) then
  76.             return false
  77.         end
  78.         if mana and not doPlayerAddMana(itemEx.uid, getPlayerLevel(cid) * mana[2]) then
  79.             return false
  80.         end
  81.        end
  82.     -- KINA
  83.        if getPlayerVocation(cid) == 4 and getPlayerVocation(cid) == 8 and getPlayerVocation(cid) == 12 then
  84.         if health and not doCreatureAddHealth(itemEx.uid, getPlayerLevel(cid) * health[3]) then
  85.             return false
  86.         end
  87.         if mana and not doPlayerAddMana(itemEx.uid, getPlayerLevel(cid) * mana[3]) then
  88.             return false
  89.         end
  90.        end
  91.         setPlayerStorageValue(cid, potion.storage, getPlayerStorageValue(cid, potion.storage)-1)
  92.         doPlayerSendTextMessage(cid, 19, "Haz usado una potion de "..getPlayerStorageValue(cid, potion.storage).." charges.")
  93.     else
  94.         doPlayerSendTextMessage(cid, 19, "Se te han acabado las cargas, compra mas diciendo: !charges |type|,|amount|.")
  95.         return false
  96.     end
  97.  
  98.  
  99.  
  100.     doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
  101.     if(not realAnimation) then
  102.         doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
  103.     else
  104.         for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
  105.             if(isPlayer(tid)) then
  106.                 doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1, false, tid)
  107.             end
  108.         end
  109.     end
  110.  
  111.  
  112.     doAddCondition(cid, exhaust)
  113.     return true
  114. end