Advertisement
Guest User

demonoak.lua

a guest
Dec 9th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. dofile('data/lib/demonOakQuest.lua')
  2. local start_storage = 1013
  3. local demon_stor = 1015
  4.  
  5. local floorDamage =
  6. {
  7. min = 170,
  8. max = 210,
  9. type = COMBAT_EARTHDAMAGE,
  10. effect = CONST_ME_BIGPLANTS
  11. }
  12.  
  13. function onUse(cid, item, fromPosition, itemEx, toPosition)
  14.  
  15. if isInArray(demonOak, itemEx.itemid) then
  16.  
  17. local get = getPlayerStorageValue(cid, itemEx.itemid)
  18. if get == -1 then setPlayerStorageValue(cid, itemEx.itemid, 1) end
  19. get = getPlayerStorageValue(cid, itemEx.itemid)
  20.  
  21. local k = 0
  22. for i = demonOak[1], demonOak[#demonOak] do
  23. if(getPlayerStorageValue(cid, i) == (waves and waves > 0 and waves) + 1) then
  24. k = k + 1
  25. end
  26. end
  27.  
  28. if killAllBeforeCut or k == #demonOak then
  29. if (isMonsterInArea(questAreaPosition[1], questAreaPosition[2], true, true)) then
  30. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to kill all monsters first.")
  31. return true
  32. end
  33. end
  34.  
  35. if(k == #demonOak) then
  36. doTeleportThing(cid, positions.kick)
  37. doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Tell Oldrak about your great victory against the demon oak.")
  38. setPlayerStorageValue(cid, storages.done, 1)
  39. setPlayerStorageValue(cid, start_storage, 3)
  40. return true
  41. end
  42.  
  43. if getPlayerStorageValue(cid, itemEx.itemid) >= (waves and waves > 0 and waves) + 1 then
  44. return doSendMagicEffect(toPosition, CONST_ME_POFF)
  45. end
  46.  
  47. local deny = false
  48. local cbs = 0
  49. if summons_[itemEx.itemid] then
  50. if summons_[itemEx.itemid][get] then
  51. for _, s in ipairs(summons_[itemEx.itemid][get]) do
  52. for i = 1, s.count do
  53. local sPos = positions.summon[math.random(#positions.summon)]
  54. local thing = getTopCreature(sPos)
  55. local area
  56. if isMonster(thing.uid) then
  57. area = getCreaturesInRange(sPos, 2, 2)
  58. for _, pos in pairs(area) do
  59. if isCreature(getTopCreature(pos).uid) or not isInRange(pos, questAreaPosition[1], questAreaPosition[2]) then
  60. deny = true
  61. break
  62. else
  63. if (getPlayerStorageValue(cid, demon_stor) <= 37 and tonumber(doSummonCreature(s.monster, pos)) == nil) then
  64. cbs = cbs + 1
  65. end
  66. break
  67. end
  68. end
  69. else
  70. if (getPlayerStorageValue(cid, demon_stor) >= 38) then
  71. doSummonCreature("Demon", sPos)
  72. local demons = getCreaturesInRange(getPlayerPosition(cid), 7, 7, true,false,true)
  73. for i = 1, #demons do
  74. doRemoveCreature(demons[i])
  75. end
  76. doSummonCreature("Demon", sPos)
  77. elseif (getPlayerStorageValue(cid, demon_stor) <= 37 and tonumber(doSummonCreature(s.monster, sPos)) == nil) then
  78. cbs = cbs + 1
  79. end
  80. end
  81. end
  82. end
  83.  
  84. if cbs > 0 then
  85. return doPlayerSendCancel(cid, "There are " .. cbs .. " monster that could not be summoned. Wave has not been counted.")
  86. end
  87.  
  88. if not deny then
  89. setPlayerStorageValue(cid, itemEx.itemid, get + 1)
  90. end
  91. if isLastCut(cid) then
  92. doCreatureSay(cid, "HOW IS THAT POSSIBLE?!? MY MASTER WILL CRUSH YOU!! AHRRGGG!", TALKTYPE_ORANGE_2, false, cid, (positions.demonOak or getCreaturePosition(cid)))
  93. else
  94. doCreatureSay(cid, sounds[2][math.random(1, #sounds[2])], TALKTYPE_ORANGE_2, false, cid, (positions.demonOak or getCreaturePosition(cid)))
  95. end
  96. doSendMagicEffect(toPosition, CONST_ME_DRAWBLOOD)
  97. else
  98. local r = math.random(1, 100)
  99. if (r >= 90) then
  100. local sPos = positions.summon[math.random(#positions.summon)]
  101. doSummonCreature("bonebeast", sPos)
  102. doSummonCreature("bonebeast", sPos)
  103. doSummonCreature("bonebeast", sPos)
  104. doSummonCreature("bonebeast", sPos)
  105. end
  106. end
  107. end
  108. setPlayerStorageValue(cid, itemEx.itemid, get + 1)
  109. doTargetCombatHealth(0, cid, floorDamage.type, -floorDamage.min, -floorDamage.max, floorDamage.effect)
  110. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerStorageValue(cid, itemEx.itemid))
  111. doSendMagicEffect(toPosition, CONST_ME_DRAWBLOOD)
  112. doCreatureSay(cid, "-krrrrak-", TALKTYPE_ORANGE_2, false, cid, getThingPos(itemEx.uid))
  113. if (getPlayerStorageValue(cid, demon_stor) < 1) then
  114. setPlayerStorageValue(cid, demon_stor, 1)
  115. else
  116. setPlayerStorageValue(cid, demon_stor, getPlayerStorageValue(cid, demon_stor) + 1)
  117. end
  118. end
  119. return true
  120. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement