Guest User

Untitled

a guest
Jul 17th, 2012
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 191.02 KB | None | 0 0
  1. const_distance_delay = 56
  2.  
  3. local hitmonchans = {
  4. ["Hitmonchan"] = {
  5.                          [0] = {out = 559, eff = 112},  --outfit normal
  6.                          [1] = {out = 1075, eff = 35},    --outfit fogo
  7.                          [2] = {out = 1077, eff = 48},    --outfit raio
  8.                          [3] = {out = 1078, eff = 43},    --outfit gelo
  9.                          [4] = {out = 1076, eff = 140}   --outfit ghost
  10.                   },
  11.  
  12. ["Elite Hitmonchan"] = {              
  13.                          --aconcelho trocar a outfit do shiny hitmonchan pela do elite hitmonchan do PO...
  14.                          [0] = {out = 837, eff = 112},  --outfit normal
  15.                          [1] = {out = 1080, eff = 35},    --outfit fogo
  16.                          [2] = {out = 1081, eff = 48},    --outfit raio
  17.                          [3] = {out = 1082, eff = 43},    --outfit gelo
  18.                          [4] = {out = 1079, eff = 140}   --outfit ghost
  19.                   },
  20.                  
  21. ["Shiny Hitmonchan"] = {              
  22.                          --aconcelho trocar a outfit do shiny hitmonchan pela do elite hitmonchan do PO...
  23.                          [0] = {out = 837, eff = 112},  --outfit normal
  24.                          [1] = {out = 1080, eff = 35},    --outfit fogo
  25.                          [2] = {out = 1081, eff = 48},    --outfit raio
  26.                          [3] = {out = 1082, eff = 43},    --outfit gelo
  27.                          [4] = {out = 1079, eff = 140}   --outfit ghost
  28.                        }
  29. }
  30.  
  31. function getMasterTarget(cid)
  32.     return getCreatureTarget(getCreatureMaster(cid))
  33. end
  34.  
  35. function doAreaCombatWithDelay(cid, target, pos, area, type, effect, a, b)
  36.     if not isCreature(cid) then return true end
  37.     local topos = {}
  38.         if isCreature(target) then topos = getThingPosWithDebug(target) else topos = pos end
  39.     doAreaCombatHealth(cid, type, topos, area, -math.abs(a), -math.abs(b), effect)
  40. end
  41.  
  42. function doAreaCombatHealthAtDistance(cid, type, pos, area, min, max, effect)
  43.     local delay = 0
  44.     if isCreature(cid) and isCreature(getMasterTarget(cid)) then
  45.         delay = getDistanceBetween(getThingPosWithDebug(cid), getThingPosWithDebug(getMasterTarget(cid))) * const_distance_delay
  46.         addEvent(doAreaCombatWithDelay, delay, cid, getMasterTarget(cid), getThingPosWithDebug(getMasterTarget(cid)), area, type, effect, -min, -max)
  47.     return true
  48.     end
  49.     doAreaCombatHealth(cid, type, pos, area, min, max, effect)
  50. end
  51.  
  52. function docastspell(cid, spell, mina, maxa)
  53.  
  54. local getThingPositionWithDebug = getThingPosWithDebug
  55.  
  56. if not isCreature(cid) or getCreatureHealth(cid) <= 0 then return false end
  57. if isSleeping(cid) then return true end
  58. if getPlayerStorageValue(cid, 6) >= 1 then doSendAnimatedText(getThingPositionWithDebug(cid), "DISABLED", 152) return true end
  59. if isMonster(cid) and not isSummon(cid) then
  60.     if getCreatureCondition(cid, CONDITION_EXHAUST) then
  61.     return true
  62.     end
  63.     doCreatureAddCondition(cid, wildexhaust)
  64. end
  65.  
  66. local mydir = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  67. local target = 0
  68. local getDistDelay = 0
  69.  
  70. if isCreature(getMasterTarget(cid)) then
  71.     target = getMasterTarget(cid)
  72.     getDistDelay = getDistanceBetween(getThingPositionWithDebug(cid), getThingPositionWithDebug(target)) * const_distance_delay
  73. end
  74.  
  75. local movetype = getSpecialAttack(cid)
  76.  
  77. local min = 0
  78. local max = 0
  79. local healMultiplier = 1
  80.  
  81. if mina and maxa then
  82. min = math.abs(mina)
  83. max = math.abs(maxa)
  84. elseif not isPlayer(cid) then
  85.     if movesinfo[spell] then
  86.         if movesinfo[spell].t == "fighting" then
  87.             movetype = getOffense(cid) * 1.4 + getSpecialAttack(cid) * 0.45
  88.         elseif movesinfo[spell].t == "normal" then
  89.             movetype = movetype * 0.6 + getOffense(cid) * 0.6
  90.         end
  91.     min = 5 + getPokemonLevel(cid) + (movesinfo[spell].f / 100 * movetype * specialoffenseRate)
  92.     max = min + getPokemonLevel(cid) * levelFactor
  93.         if not isSummon(cid) then
  94.             doCreatureSay(cid, string.upper(spell).."!", TALKTYPE_MONSTER)
  95.         end
  96.         if isNpcSummon(cid) then
  97.             local mnn = {" use ", " "}
  98.             local use = mnn[math.random(#mnn)]
  99.             doCreatureSay(getCreatureMaster(cid), getPlayerStorageValue(cid, 1007)..","..use..""..doCorrectString(spell).."!", 1)
  100.         end
  101.     else
  102.     print("Error trying to use move "..spell..", move not specified in moves table.")
  103.     end
  104.    
  105. end
  106. --- CONFUSED -------------------------------
  107. if getPlayerStorageValue(cid, 3891) >= 1 then
  108.     if math.random(1,100) <= 33 then
  109.     doSendAnimatedText(getThingPositionWithDebug(cid), "SELF HIT", 180)
  110.     doTargetCombatHealth(cid, cid, COMBAT_PHYSICALDAMAGE, -min/3, -max/3, 3)
  111.     return true
  112.     end
  113. end
  114. --- BLIND ----------------------------------
  115. if getPlayerStorageValue(cid, 3890) >= 1 then
  116.     doSendAnimatedText(getThingPositionWithDebug(cid), "MISS", 215)
  117.     setPlayerStorageValue(cid, 3890, -1)
  118. return true
  119. end
  120. --- FOCUS ----------------------------------
  121. if getPlayerStorageValue(cid, 253) >= 0 and movesinfo[spell] and movesinfo[spell].f ~= 0 then
  122.     min = min * 3
  123.     max = max * 3
  124.     healMultiplier = 3
  125.     setPlayerStorageValue(cid, 253, -1)
  126. end
  127. ---- MIMIC ---------------------------------
  128. setPlayerStorageValue(cid, 877, spell)
  129. ---- COUNTER -------------------------------
  130. if isCreature(target) and getPlayerStorageValue(target, 879) >= 1 and getDistanceBetween(getThingPositionWithDebug(cid), getThingPositionWithDebug(target)) <= 2 and spell ~= "Counter" then
  131.     if movesinfo[spell] and movesinfo[spell].t == "fighting" or movesinfo[spell].t == "normal" then
  132.         if not isInArray({"Hyper Beam", "Hyper Voice", "Counter"}, spell) then
  133.             docastspell(target, spell, min * 2, max * 2)
  134.             doSendAnimatedText(getThingPositionWithDebug(target), "COUNTER", 215)
  135.             setPlayerStorageValue(target, 879, -1)
  136.         end
  137.     end
  138. end
  139. --------------------------------------------
  140.  
  141.  
  142. if spell == "Dynamic Punch" then
  143.  
  144. local dirs = {
  145. [1] = 0,
  146. [2] = 4,
  147. [3] = 6,
  148. [4] = 1,
  149. [5] = 3,
  150. [6] = 2
  151. }
  152.  
  153.     doAreaCombatHealth(cid, FIGHTINGDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 112)
  154.     local targetarea = getThingPositionWithDebug(getMasterTarget(cid))
  155.     for effcs = 1, 6 do
  156.     addEvent(doSendMagicEffect, 150 * effcs, getPosByDir(getThingPositionWithDebug(getMasterTarget(cid)), dirs[effcs]), 5)
  157.     end
  158.  
  159. elseif spell == "Quick Attack" then
  160.  
  161.     doSendMagicEffect(getThingPositionWithDebug(cid), 211)
  162.     local x = getClosestFreeTile(cid, getThingPositionWithDebug(getMasterTarget(cid)))
  163.     doTeleportThing(cid, x, false)
  164.     doFaceCreature(cid, getThingPositionWithDebug(getMasterTarget(cid)))
  165.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  166.  
  167. elseif spell == "Slam" then
  168.  
  169.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 118)
  170.  
  171. elseif spell == "Rapid Hit" then
  172.  
  173.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  174.  
  175.     local hitalvo = getMasterTarget(cid)
  176.  
  177.     local function sendef(cid)
  178.         if isCreature(cid) then
  179.         doSendMagicEffect(getThingPositionWithDebug(cid), 3)
  180.         end
  181.     end
  182.  
  183.     for times = 0, 3 do
  184.     addEvent(sendef, 200*times+80, hitalvo)
  185.     end
  186.  
  187. elseif spell == "Bite" or tonumber(spell) == 5 then
  188.  
  189.     doAreaCombatHealth(cid, DARKDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 146)
  190.  
  191. elseif spell == "Slash" or tonumber(spell) == 6 then
  192.  
  193.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 142)
  194.  
  195. elseif spell == "Splash" or tonumber(spell) == 7 then
  196.  
  197.     doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), splash, -min, -max, 255)
  198.     doSendMagicEffect(getThingPositionWithDebug(cid), 53)
  199.  
  200. elseif spell == "Doubleslap" then
  201.  
  202.     local slapalvo = getMasterTarget(cid)
  203.     local summon = cid
  204.     local function doSlap(cid, target)
  205.         if isCreature(cid) and isCreature(target) then
  206.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 3)
  207.         end
  208.     end
  209.  
  210.     addEvent(doSlap, 0, summon, slapalvo)
  211.     addEvent(doSlap, 600, summon, slapalvo)
  212.  
  213. elseif spell == "Mega Punch" then
  214.  
  215.     doAreaCombatHealth(cid, FIGHTINGDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 112)
  216.  
  217. elseif spell == "Scratch" then
  218.  
  219.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 142)
  220.  
  221. elseif spell == "Confusion" then
  222.  
  223.     doAreaCombatHealth(cid, PSYCHICDAMAGE, getThingPositionWithDebug(cid), confusion, -min, -max, 133)
  224.  
  225. elseif spell == "Psychic" then
  226.  
  227.     doAreaCombatHealth(cid, PSYCHICDAMAGE, getThingPositionWithDebug(cid), psychic, -min, -max, 136)
  228.  
  229. elseif spell == "Absorb" or spell == "Leech Life" then
  230.  
  231.     local life = getCreatureHealth(getMasterTarget(cid))
  232.  
  233.     doAreaCombatHealth(cid, GRASSDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 14)
  234.  
  235.     local newlife = life - getCreatureHealth(getMasterTarget(cid))
  236.  
  237.     doSendMagicEffect(getThingPositionWithDebug(cid), 14)
  238.     if newlife >= 1 then
  239.     doCreatureAddHealth(cid, newlife)
  240.     doSendAnimatedText(getThingPositionWithDebug(cid), "+"..newlife.."", 32)
  241.     end
  242.  
  243. elseif spell == "Mud Shot" then
  244.  
  245.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 1)
  246.  
  247.     local function doEffect(cid, target)
  248.         if not isCreature(cid) or not isCreature(target) then return true end
  249.     doAreaCombatHealth(cid, GROUNDDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 34)
  250.         if math.random(1, 100) >= 78 then
  251.             local rounds = math.random(6, 10)
  252.             rounds = rounds + math.floor(getPokemonLevel(cid) / 20)
  253.             doAdvancedBlind(target, rounds, getPlayerStorageValue(target, 3890), 34)
  254.         end
  255.     end
  256.  
  257.     addEvent(doEffect, getDistDelay, cid, target)
  258.  
  259. elseif spell == "Bubbles" then
  260.  
  261.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 2)
  262.     doAreaCombatHealthAtDistance(cid, WATERDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 25)
  263.  
  264. elseif spell == "Waterfall" then
  265.  
  266.         doSendDistanceShoot(getThingPositionWithDebug(cid), {x=getThingPositionWithDebug(cid).x, y=getThingPositionWithDebug(cid).y-5, z=getThingPositionWithDebug(cid).z}, 2)
  267.  
  268.         local function spout(params)
  269.         if isCreature(params.cid) then
  270.         for x = -2,2 do
  271.             for y = -2,2 do
  272.         local newpos = getThingPositionWithDebug(params.cid)
  273.         newpos.x = newpos.x+x
  274.         newpos.y = newpos.y+y
  275.         doSendDistanceShoot({x=getThingPositionWithDebug(params.cid).x, y=getThingPositionWithDebug(params.cid).y-5, z=getThingPositionWithDebug(params.cid).z}, newpos, 2)
  276.         end
  277.         end
  278.         end
  279.         end
  280.        
  281.  
  282.         local function spdmg(params)
  283.         if isCreature(params.cid) then
  284.         doAreaCombatHealth(params.cid, WATERDAMAGE, getThingPositionWithDebug(params.cid), waterspout, -min, -max, 68)
  285.         end
  286.         end
  287.  
  288.         addEvent(spout, 300, {cid = cid})
  289.         addEvent(spdmg, 450, {cid = cid})
  290.  
  291. elseif spell == "Horn Attack" then
  292.  
  293.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 15)
  294.     --doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  295.     addEvent(doAreaCombatWithDelay, getDistDelay, cid, target, getThingPositionWithDebug(target), 0, NORMALDAMAGE, 3, -min, -max)
  296.  
  297. elseif spell == "Rock Throw" then
  298.  
  299.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 11)
  300.     doAreaCombatHealthAtDistance(cid, ROCKDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  301.  
  302. elseif spell == "Headbutt" or spell == "Pound" or spell == "Tackle" then
  303.  
  304.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  305.  
  306. elseif spell == "Super Sonic" or spell == "Confuse Ray" then
  307.  
  308.     local target = getMasterTarget(cid)
  309.     local rounds = math.random(4, 7)
  310.     rounds = rounds + math.floor(getPokemonLevel(cid) / 35)
  311.  
  312.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 32)
  313.     doAdvancedConfuse(target, rounds, getPlayerStorageValue(target, 3891))
  314.  
  315. elseif spell == "Fury Attack" then
  316.  
  317.     local alvo = getMasterTarget(cid)
  318.  
  319.     local function doFuryAttack(cid, target, round, rounds)
  320.         if not isCreature(cid) then return true end
  321.         if round > rounds then
  322.         doSendAnimatedText(getThingPositionWithDebug(cid), ""..rounds.." HITS", 35)
  323.         return true
  324.         end
  325.         if isCreature(getMasterTarget(cid)) and getMasterTarget(cid) ~= target then
  326.         doSendAnimatedText(getThingPositionWithDebug(cid), ""..rounds.." HITS", 35)
  327.         return true
  328.         end
  329.         if not isCreature(getMasterTarget(cid)) then
  330.         doSendAnimatedText(getThingPositionWithDebug(cid), ""..rounds.." HITS", 35)
  331.         return true
  332.         end
  333.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 15)
  334.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  335.         addEvent(doFuryAttack, 700, cid, target, round + 1, rounds)
  336.     end
  337.        
  338.     local ther = math.random(1, 200)
  339.         if ther <= 75 then
  340.             maxr = 2
  341.         elseif ther >= 76 and ther <= 100 then
  342.             maxr = 4
  343.         elseif ther >= 101 and ther <= 175 then
  344.             maxr = 3
  345.         elseif ther >= 176 then
  346.             maxr = 5
  347.         end
  348.  
  349.     doFuryAttack(cid, alvo, 1, maxr)
  350.  
  351. elseif spell == "Dragon Claw" then
  352.  
  353.     local alvo = getMasterTarget(cid)
  354.  
  355.     local function doFuryAttack(cid, target, round, rounds)
  356.         if not isCreature(cid) then return true end
  357.         if round > rounds then
  358.         doSendAnimatedText(getThingPositionWithDebug(cid), ""..rounds.." HITS", 35)
  359.         return true
  360.         end
  361.         if isCreature(getMasterTarget(cid)) and getMasterTarget(cid) ~= target then
  362.         doSendAnimatedText(getThingPositionWithDebug(cid), ""..rounds.." HITS", 35)
  363.         return true
  364.         end
  365.         if not isCreature(getMasterTarget(cid)) then
  366.         doSendAnimatedText(getThingPositionWithDebug(cid), ""..rounds.." HITS", 35)
  367.         return true
  368.         end
  369.         doAreaCombatHealth(cid, DRAGONDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 15)
  370.         addEvent(doFuryAttack, 700, cid, target, round + 1, rounds)
  371.     end
  372.        
  373.     local ther = math.random(1, 200)
  374.         if ther <= 75 then
  375.             maxr = 2
  376.         elseif ther >= 76 and ther <= 100 then
  377.             maxr = 4
  378.         elseif ther >= 101 and ther <= 175 then
  379.             maxr = 3
  380.         elseif ther >= 176 then
  381.             maxr = 5
  382.         end
  383.  
  384.     doFuryAttack(cid, alvo, 1, maxr)
  385.  
  386. elseif spell == "Aura Sphere" then
  387.  
  388.     local alvo = getMasterTarget(cid)
  389.  
  390.     local function doFuryAttack(cid, target, round, rounds)
  391.         if not isCreature(cid) then return true end
  392.         if round > rounds then
  393.         doSendAnimatedText(getThingPositionWithDebug(cid), ""..rounds.." HITS", 35)
  394.         return true
  395.         end
  396.         if isCreature(getMasterTarget(cid)) and getMasterTarget(cid) ~= target then
  397.         doSendAnimatedText(getThingPositionWithDebug(cid), ""..rounds.." HITS", 35)
  398.         return true
  399.         end
  400.         if not isCreature(getMasterTarget(cid)) then
  401.         doSendAnimatedText(getThingPositionWithDebug(cid), ""..rounds.." HITS", 35)
  402.         return true
  403.         end
  404.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 33)
  405.         doAreaCombatHealth(cid, FIGHTINGDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 143)
  406.         addEvent(doFuryAttack, 700, cid, target, round + 1, rounds)
  407.     end
  408.        
  409.     local ther = math.random(1, 200)
  410.         if ther <= 75 then
  411.             maxr = 1
  412.         elseif ther >= 76 and ther <= 100 then
  413.             maxr = 2
  414.         elseif ther >= 101 and ther <= 175 then
  415.             maxr = 1
  416.         elseif ther >= 176 then
  417.             maxr = 2
  418.         end
  419.  
  420.     doFuryAttack(cid, alvo, 1, maxr)
  421.  
  422. elseif spell == "Water Gun" then
  423.  
  424.     if mydir == 0 then
  425.         doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), wg1n, -min, -max, 74)
  426.         doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), wg2n, -min, -max, 75)
  427.         doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), wg3n, -min, -max, 76)
  428.     elseif mydir == 2 then
  429.         doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), wg1s, -min, -max, 77)
  430.         doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), wg2s, -min, -max, 75)
  431.         doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), wg3s, -min, -max, 78)
  432.     elseif mydir == 1 then
  433.         doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), wg1e, -min, -max, 69)
  434.         doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), wg2e, -min, -max, 70)
  435.         doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), wg3e, -min, -max, 71)
  436.     elseif mydir == 3 then
  437.         doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), wg1w, -min, -max, 72)
  438.         doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), wg2w, -min, -max, 70)
  439.         doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), wg3w, -min, -max, 73)
  440.     end
  441.  
  442. elseif spell == "Peck" then
  443.  
  444.         doAreaCombatHealth(cid, FLYINGDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  445.  
  446. elseif spell == "Pluck" then
  447.  
  448.     doAreaCombatHealth(cid, FLYINGDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), pluck, -min, -max, 3)
  449.  
  450. elseif spell == "Sand Attack" then
  451.  
  452.         local posicao = getThingPositionWithDebug(cid)
  453.  
  454.         local function sandattack(params)
  455.             if isCreature(params.cid) and isSightClear(posicao, params.ar, false) then
  456.             doAreaCombatHealth(params.cid, GROUNDDAMAGE, params.ar, sand1, -min, -max, params.ef)
  457.             end
  458.         end
  459.  
  460.         if mydir == 0 then
  461.             addEvent(sandattack, 0, {cid = cid, ar = {x=posicao.x, y=posicao.y-1, z=posicao.z}, ef = 120})
  462.             addEvent(sandattack, 400, {cid = cid, ar = {x=posicao.x, y=posicao.y-2, z=posicao.z}, ef = 120})
  463.             addEvent(sandattack, 800, {cid = cid, ar = {x=posicao.x, y=posicao.y-3, z=posicao.z}, ef = 120})
  464.         elseif mydir == 2 then
  465.             addEvent(sandattack, 0, {cid = cid, ar = {x=posicao.x, y=posicao.y+1, z=posicao.z}, ef = 122})
  466.             addEvent(sandattack, 400, {cid = cid, ar = {x=posicao.x, y=posicao.y+2, z=posicao.z}, ef = 122})
  467.             addEvent(sandattack, 800, {cid = cid, ar = {x=posicao.x, y=posicao.y+3, z=posicao.z}, ef = 122})
  468.         elseif mydir == 1 then
  469.             addEvent(sandattack, 0, {cid = cid, ar = {x=posicao.x+1, y=posicao.y, z=posicao.z}, ef = 121})
  470.             addEvent(sandattack, 400, {cid = cid, ar = {x=posicao.x+2, y=posicao.y, z=posicao.z}, ef = 121})
  471.             addEvent(sandattack, 800, {cid = cid, ar = {x=posicao.x+3, y=posicao.y, z=posicao.z}, ef = 121})
  472.         elseif mydir == 3 then
  473.             addEvent(sandattack, 0, {cid = cid, ar = {x=posicao.x-1, y=posicao.y, z=posicao.z}, ef = 119})
  474.             addEvent(sandattack, 400, {cid = cid, ar = {x=posicao.x-2, y=posicao.y, z=posicao.z}, ef = 119})
  475.             addEvent(sandattack, 800, {cid = cid, ar = {x=posicao.x-3, y=posicao.y, z=posicao.z}, ef = 119})
  476.         end
  477.  
  478. elseif spell == "Spark" then
  479.  
  480.                 local function spark(params)
  481.                 if isCreature(params.cid) then
  482.                 doSendDistanceShoot(getThingPositionWithDebug(params.cid), params.cidpos, 40)
  483.                 doAreaCombatHealth(cid, ELECTRICDAMAGE, params.cidpos, 0, -min, -max, 48)
  484.                 end
  485.                 end
  486.         for a = -1, 1 do
  487.             for b = -1, 1 do
  488.             cidpos = getThingPositionWithDebug(cid)
  489.             cidpos.x = cidpos.x+a
  490.             cidpos.y = cidpos.y+b
  491.             addEvent(spark, math.abs(a)*350 + math.abs(b)*650, {cid = cid, cidpos = cidpos})
  492.             end
  493.         end
  494.  
  495. elseif spell == "Razor Leaf" then
  496.  
  497.     local alvo = getMasterTarget(cid)
  498.  
  499.             local function throw(cid, target)
  500.             if isCreature(cid) then
  501.             if isCreature(target) then
  502.             doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 8)
  503.             addEvent(doAreaCombatWithDelay, getDistanceBetween(getThingPositionWithDebug(cid), getThingPositionWithDebug(target)) * 60, cid, target, getThingPositionWithDebug(target), 0, GRASSDAMAGE, 3, -min, -max)
  504.             end
  505.             end
  506.             end
  507.  
  508.         addEvent(throw, 0, cid, alvo)
  509.         addEvent(throw, 550, cid, alvo)
  510.  
  511. elseif spell == "Waterball" then
  512.  
  513.         local function throw(params)
  514.         if isCreature(params.cid) then
  515.         if isCreature(getMasterTarget(params.cid)) then
  516.         doSendDistanceShoot(getThingPositionWithDebug(params.cid), getThingPositionWithDebug(getMasterTarget(params.cid)), 2)
  517.         addEvent(doAreaCombatWithDelay, getDistDelay, cid, target, getThingPositionWithDebug(target), waba, WATERDAMAGE, 68, -min, -max)
  518.         end
  519.         end
  520.         end
  521.  
  522.         addEvent(throw, 0, {cid = cid})
  523.  
  524. elseif spell == "Restore" or spell == "Selfheal" or spell == "Recover" then
  525.  
  526.     local amount = getSpecialAttack(cid) * 4 * healMultiplier
  527.     doSendMagicEffect(getThingPositionWithDebug(cid), 14)
  528.     doCreatureAddHealth(cid, amount)
  529.     doSendAnimatedText(getThingPositionWithDebug(cid), "+"..amount.."", 35)
  530.  
  531. elseif spell == "Aqua Ring" then
  532.  
  533.     local amount = getSpecialAttack(cid) * 3 * healMultiplier
  534.     doSendMagicEffect(getThingPositionWithDebug(cid), 68)
  535.     doCreatureAddHealth(cid, amount)
  536.     doSendAnimatedText(getThingPositionWithDebug(cid), "+"..amount.."", 35)
  537.  
  538. elseif spell == "Acid" then
  539.  
  540.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 14)
  541.     doAreaCombatHealthAtDistance(cid, POISONDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 20)
  542.  
  543. elseif spell == "Thundershock" or spell == "Thunder Shock" then
  544.  
  545.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 40)
  546.     doAreaCombatHealthAtDistance(cid, ELECTRICDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 48)
  547.  
  548. elseif spell == "Water Pulse" then
  549.  
  550.         local function throw(params)
  551.             if isCreature(params.cid) then
  552.             if isCreature(getMasterTarget(params.cid)) then
  553.             doSendDistanceShoot(getThingPositionWithDebug(params.cid), getThingPositionWithDebug(getMasterTarget(params.cid)), 33)
  554.             addEvent(doAreaCombatWithDelay, getDistDelay, cid, target, getThingPositionWithDebug(target), 0, WATERDAMAGE, 68, -min, -max)
  555.             end
  556.             end
  557.         end
  558.  
  559.         addEvent(throw, 0, {cid = cid})
  560.  
  561. elseif spell == "String Shot" then
  562.  
  563.         local target = getMasterTarget(cid)
  564.         local rounds = math.random(6, 10)
  565.         rounds = rounds + math.floor(getPokemonLevel(cid) / 20)
  566.         doAdvancedBlind(target, rounds, getPlayerStorageValue(target, 3890), 137)
  567.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 23)
  568.  
  569. elseif spell == "Thunder Wave" then
  570.  
  571.     if mydir == 0 then
  572.         doAreaCombatHealth(cid, THUNDERWAVEDAMAGE, getThingPositionWithDebug(cid), tsn, -min, -max, 48)
  573.     elseif mydir == 1 then
  574.         doAreaCombatHealth(cid, THUNDERWAVEDAMAGE, getThingPositionWithDebug(cid), tse, -min, -max, 48)
  575.     elseif mydir == 2 then
  576.         doAreaCombatHealth(cid, THUNDERWAVEDAMAGE, getThingPositionWithDebug(cid), tss, -min, -max, 48)
  577.     elseif mydir == 3 then
  578.         doAreaCombatHealth(cid, THUNDERWAVEDAMAGE, getThingPositionWithDebug(cid), tsw, -min, -max, 48)
  579.     end
  580.  
  581. elseif spell == "Leech Seed" then
  582.  
  583.     local leecher = cid
  584.     local leeched = getMasterTarget(cid)
  585.     local dmg = 1.5 * getPokemonLevel(cid)
  586.  
  587.         local function drain(cid, target)
  588.         if isCreature(cid) and isCreature(target) then
  589.         local life = getCreatureHealth(target)
  590.         doAreaCombatHealth(cid, GRASSDAMAGE, getThingPositionWithDebug(target), 0, -dmg, -dmg, 45)
  591.         local newlife = life - getCreatureHealth(leeched)
  592.         if newlife >= 1 then
  593.         doSendMagicEffect(getThingPositionWithDebug(leecher), 14)
  594.         doCreatureAddHealth(leecher, newlife)
  595.         doSendAnimatedText(getThingPositionWithDebug(leecher), "+"..newlife.."", 32)
  596.         end
  597.         end
  598.         end
  599.  
  600.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 1)
  601.     for rounds = 1, 5 do
  602.     addEvent(drain, 2000 * rounds, leecher, leeched)
  603.     end
  604.  
  605. elseif spell == "Sludge" then    
  606.  
  607.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 6)
  608.         doAreaCombatHealthAtDistance(cid, POISONDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 116)
  609.  
  610. elseif spell == "Poison Sting" then
  611.  
  612.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 15)
  613.         doAreaCombatHealthAtDistance(cid, POISONDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 20)
  614.  
  615. elseif spell == "Bug Bite" then
  616.  
  617.         doAreaCombatHealth(cid, BUGDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 138)
  618.  
  619. elseif spell == "Pin Missile" then
  620.  
  621.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 13)
  622.         doAreaCombatHealthAtDistance(cid, POISONDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  623.  
  624. elseif spell == "Rock Slide" then
  625.  
  626.         local function doRockHurt(cid, target)
  627.             if not isCreature(target) or not isCreature(cid) then return true end
  628.         doAreaCombatHealth(cid, ROCKDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 44)
  629.         end
  630.  
  631.         local function doFallRock(cid, target)
  632.             if not isCreature(target) or not isCreature(cid) then return true end
  633.         local pos = getThingPositionWithDebug(target)
  634.         pos.x = pos.x + math.random(-3, 1)
  635.         local ry = math.random(5, 7)
  636.         pos.y = pos.y - ry
  637.         doSendDistanceShoot(pos, getThingPositionWithDebug(target), 11)
  638.         addEvent(doRockHurt, ry * 52, cid, target)
  639.         end    
  640.  
  641.     local alvo = getMasterTarget(cid)
  642.  
  643.     for rocks = 0, 4 do
  644.         addEvent(doFallRock, rocks * 65, cid, alvo)
  645.     end
  646.  
  647. elseif spell == "Gust" then
  648.  
  649.     local posicao = getThingPositionWithDebug(cid)
  650.  
  651.     local function gust(params)
  652.     if isCreature(params.cid) and isSightClear(posicao, params.ar, false) then
  653.     doAreaCombatHealth(cid, FLYINGDAMAGE, params.ar, sand1, -min, -max, 42)
  654.     end
  655.     end
  656.  
  657.     if mydir == 0 then
  658.         for b = 0, 3 do
  659.             addEvent(gust, 350 * b, {cid = cid, ar = {x=posicao.x, y=posicao.y-(b+1), z=posicao.z}})
  660.         end
  661.     elseif mydir == 2 then
  662.         for b = 0, 3 do
  663.             addEvent(gust, 350 * b, {cid = cid, ar = {x=posicao.x, y=posicao.y+(b+1), z=posicao.z}})
  664.         end
  665.     elseif mydir == 1 then
  666.         for b = 0, 3 do
  667.             addEvent(gust, 350 * b, {cid = cid, ar = {x=posicao.x+(1+b), y=posicao.y, z=posicao.z}})
  668.         end
  669.     elseif mydir == 3 then
  670.         for b = 0, 3 do
  671.             addEvent(gust, 350 * b, {cid = cid, ar = {x=posicao.x-(1+b), y=posicao.y, z=posicao.z}})
  672.         end
  673.     end
  674.  
  675. elseif spell == "Whirlwind" then
  676.  
  677.     local posicao = getThingPositionWithDebug(cid)
  678.        
  679.     local function wwind(params)
  680.     if isCreature(cid) and isSightClear(posicao, params.ar, false) then
  681.     doAreaCombatHealth(cid, FLYINGDAMAGE, params.ar, params.br, -min, -max, 42)
  682.     end
  683.     end
  684.  
  685.     if mydir == 0 then
  686.         addEvent(wwind, 0, {cid = cid, ar = {x=posicao.x, y=posicao.y-1, z=posicao.z}, br = sand1})
  687.         addEvent(wwind, 350, {cid = cid, ar = {x=posicao.x, y=posicao.y-2, z=posicao.z}, br = whirl3})
  688.         addEvent(wwind, 700, {cid = cid, ar = {x=posicao.x, y=posicao.y-3, z=posicao.z}, br = whirl5})
  689.         addEvent(wwind, 1050, {cid = cid, ar = {x=posicao.x, y=posicao.y-4, z=posicao.z}, br = whirl5})
  690.     elseif mydir == 2 then
  691.         addEvent(wwind, 0, {cid = cid, ar = {x=posicao.x, y=posicao.y+1, z=posicao.z}, br = sand1})
  692.         addEvent(wwind, 350, {cid = cid, ar = {x=posicao.x, y=posicao.y+2, z=posicao.z}, br = whirl3})
  693.         addEvent(wwind, 700, {cid = cid, ar = {x=posicao.x, y=posicao.y+3, z=posicao.z}, br = whirl5})
  694.         addEvent(wwind, 1050, {cid = cid, ar = {x=posicao.x, y=posicao.y+4, z=posicao.z}, br = whirl5})
  695.     elseif mydir == 1 then
  696.         addEvent(wwind, 0, {cid = cid, ar = {x=posicao.x+1, y=posicao.y, z=posicao.z}, br = sand1})
  697.         addEvent(wwind, 350, {cid = cid, ar = {x=posicao.x+2, y=posicao.y, z=posicao.z}, br = whirl32})
  698.         addEvent(wwind, 700, {cid = cid, ar = {x=posicao.x+3, y=posicao.y, z=posicao.z}, br = whirl52})
  699.         addEvent(wwind, 1050, {cid = cid, ar = {x=posicao.x+4, y=posicao.y, z=posicao.z}, br = whirl52})
  700.     elseif mydir == 3 then
  701.         addEvent(wwind, 0, {cid = cid, ar = {x=posicao.x-1, y=posicao.y, z=posicao.z}, br = sand1})
  702.         addEvent(wwind, 350, {cid = cid, ar = {x=posicao.x-2, y=posicao.y, z=posicao.z}, br = whirl32})
  703.         addEvent(wwind, 700, {cid = cid, ar = {x=posicao.x-3, y=posicao.y, z=posicao.z}, br = whirl52})
  704.         addEvent(wwind, 1050, {cid = cid, ar = {x=posicao.x-4, y=posicao.y, z=posicao.z}, br = whirl52})
  705.     end
  706.  
  707. elseif spell == "Hyper Fang" then
  708.  
  709.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 146)
  710.  
  711. elseif spell == "Rollout" then
  712. local outfits = {
  713. ["Voltorb"] = {lookType = 638},
  714. ["Electrode"] = {lookType = 637},
  715. ["Sandshrew"] = {lookType = 635},
  716. ["Sandslash"] = {lookType = 636},
  717. ["Phanpy"] = {lookType = 1005},
  718. ["Dolphan"] = {lookType = 1007},
  719. ["Miltank"] = {lookType = 1006},
  720. ["Golem"] = {lookType = 639},
  721. ["Shiny Electrode"] = {lookType = 1387},
  722. ["Shiny Sandshrew"] = {lookType = 1390},
  723. ["Shiny Sandslash"] = {lookType = 1389},
  724. ["Shiny Golem"] = {lookType = 639},
  725. ["Shiny Voltorb"] = {lookType = 1388}
  726. }
  727.  
  728.     if outfits[getCreatureName(cid)] then
  729.         doSetCreatureOutfit(cid, outfits[getCreatureName(cid)], 8300)
  730.     end
  731.  
  732.     --doCreatureAddCondition(cid, rollspeedcondition)
  733.  
  734.     local outfit = getCreatureOutfit(cid).lookType
  735.  
  736.     local function roll(cid, outfit)
  737.     if not isCreature(cid) then return true end
  738.     if getCreatureOutfit(cid).lookType ~= outfit then return true end
  739.        doAreaCombatHealth(cid, ROCKDAMAGE, getThingPositionWithDebug(cid), splash, -min, -max, 255)
  740.     end
  741.  
  742.     for r = 1, 11 do  --8
  743.         addEvent(roll, 750 * r, cid, outfit)
  744.     end
  745.    
  746. elseif spell == "Vine Whip" then
  747.  
  748. local area = getThingPositionWithDebug(cid)
  749. local dano = {}
  750. local effect = 255
  751.  
  752.     if mydir == 0 then
  753.         area.x = area.x + 1
  754.         area.y = area.y - 1
  755.         dano = whipn
  756.         effect = 80
  757.     elseif mydir == 1 then
  758.         area.x = area.x + 2
  759.         area.y = area.y + 1
  760.         dano = whipe
  761.         effect = 83
  762.     elseif mydir == 2 then
  763.         area.x = area.x + 1
  764.         area.y = area.y + 2    
  765.         dano = whips
  766.         effect = 81
  767.     elseif mydir == 3 then
  768.         area.x = area.x - 1
  769.         area.y = area.y + 1
  770.         dano = whipw
  771.         effect = 82
  772.     end
  773.  
  774.         doSendMagicEffect(area, effect)
  775.         doAreaCombatHealth(cid, GRASSDAMAGE, getThingPositionWithDebug(cid), dano, -min, -max, 255)
  776.  
  777. elseif spell == "Psycho Shift" then
  778.  
  779.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 39)
  780.         doAreaCombatHealthAtDistance(cid, PSYCHOSHIFTDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 134)
  781.  
  782. elseif spell == "Poison Bomb" then
  783.  
  784.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 20)
  785.         doAreaCombatHealthAtDistance(cid, POISONDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), bomb, -min, -max, 114)
  786.  
  787. elseif spell == "Toxic Needle" then
  788.  
  789.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 15)
  790.         doAreaCombatHealthAtDistance(cid, POISONDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 20)
  791.  
  792. elseif spell == "Harden" then
  793.  
  794.         local function effect(params)
  795.             if isCreature(params.cid) then
  796.             doSendMagicEffect(getThingPositionWithDebug(params.cid), 144)
  797.             end
  798.         end
  799.  
  800.     local function doReduceDefense(cid, qnt)
  801.         if not isCreature(cid) then return true end
  802.         local a = getDefense(cid)
  803.         setPlayerStorageValue(cid, 1002, a - qnt)
  804.     end
  805.    
  806.     local function doDoubleDefense(cid)
  807.         if not isCreature(cid) then return true end
  808.         local a = getDefense(cid)
  809.         setPlayerStorageValue(cid, 1002, a * 2)
  810.         local b = getDefense(cid)
  811.         local c = b - a
  812.     addEvent(doReduceDefense, 11 * 1500 + 40, cid, c)
  813.     end
  814.  
  815.     doDoubleDefense(cid)
  816.  
  817.     for times = 0, 11 do
  818.         addEvent(effect, 1500 * times + 40, {cid = cid})
  819.     end
  820.  
  821. elseif spell == "Fireball" then
  822.  
  823.     doSendMoveEffect(cid, getMasterTarget(cid), 3)
  824.  
  825.     local function damage(cid, target)
  826.         if not isCreature(cid) or not isCreature(target) then return true end
  827.         doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(target), waba, -min, -max, 5)
  828.     end
  829.  
  830.     addEvent(damage, 100, cid, getMasterTarget(cid))
  831.  
  832. elseif spell == "Toxic" then
  833.  
  834.     if mydir == 0 then
  835.         areaa = toxicn
  836.     elseif mydir == 1 then
  837.         areaa = toxice
  838.     elseif mydir == 2 then
  839.         areaa = toxics
  840.     elseif mydir == 3 then
  841.         areaa = toxicw
  842.     end
  843.  
  844.         doAreaCombatHealth(cid, POISONDAMAGE, getThingPositionWithDebug(cid), areaa, -min, -max, 114)
  845.    
  846. elseif spell == "Aqua Tail" then
  847.  
  848.     local function rebackSpd(cid, sss)
  849.         if not isCreature(cid) then return true end
  850.         doChangeSpeed(cid, sss)
  851.         setPlayerStorageValue(cid, 446, -1)
  852.     end
  853.  
  854.     local x = getCreatureSpeed(cid)
  855.     doFaceOpposite(cid)
  856.     doChangeSpeed(cid, -x)
  857.     addEvent(rebackSpd, 400, cid, x)
  858.     setPlayerStorageValue(cid, 446, 1)
  859.     doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 68)
  860.  
  861. elseif spell == "Fire Fang" then
  862.  
  863.     local target = getMasterTarget(cid)
  864.  
  865.     doSendMagicEffect(getThingPositionWithDebug(getMasterTarget(cid)), 146)
  866.  
  867.         local function doBite(cid, target)
  868.             if not isCreature(cid) or not isCreature(target) then return true end
  869.         doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 5)
  870.         end
  871.  
  872.     addEvent(doBite, 200, cid, target)
  873.  
  874. elseif spell == "Psy Pulse" then
  875.  
  876.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 24)
  877.         doAreaCombatHealthAtDistance(cid, PSYCHICDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 136)
  878.  
  879. elseif spell == "Ember" then
  880.  
  881.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 3)
  882.         doAreaCombatHealthAtDistance(cid, FIREDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 5)
  883.  
  884. elseif spell == "Wing Attack" then
  885.  
  886. local damagearea = {}
  887. local effectpos = getThingPositionWithDebug(cid)
  888. local effect = 255
  889. local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  890.  
  891.     if a == 0 then
  892.         effect = 128
  893.         effectpos.x = effectpos.x + 1
  894.         effectpos.y = effectpos.y - 1
  895.         damagearea = wingdn
  896.     elseif a == 1 then
  897.         effectpos.x = effectpos.x + 1
  898.         effectpos.y = effectpos.y + 1
  899.         effect = 129
  900.         damagearea = wingde
  901.     elseif a == 2 then
  902.         effectpos.x = effectpos.x + 1
  903.         effectpos.y = effectpos.y + 1
  904.         effect = 131
  905.         damagearea = wingds
  906.     elseif a == 3 then
  907.         effectpos.x = effectpos.x - 1
  908.         effectpos.y = effectpos.y + 1
  909.         effect = 130
  910.         damagearea = wingdw
  911.     end
  912.  
  913.         doSendMagicEffect(effectpos, effect)
  914.         doAreaCombatHealth(cid, FLYINGDAMAGE, getThingPositionWithDebug(cid), damagearea, -min, -max, CONST_ME_NONE)
  915.  
  916. elseif spell == "Poisonous Wing" then
  917.  
  918. local damagearea = {}
  919. local effectpos = getThingPositionWithDebug(cid)
  920. local effect = 255
  921. local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  922.  
  923.     if a == 0 then
  924.         effect = 128
  925.         effectpos.x = effectpos.x + 1
  926.         effectpos.y = effectpos.y - 1
  927.         damagearea = wingdn
  928.     elseif a == 1 then
  929.         effectpos.x = effectpos.x + 1
  930.         effectpos.y = effectpos.y + 1
  931.         effect = 129
  932.         damagearea = wingde
  933.     elseif a == 2 then
  934.         effectpos.x = effectpos.x + 1
  935.         effectpos.y = effectpos.y + 1
  936.         effect = 131
  937.         damagearea = wingds
  938.     elseif a == 3 then
  939.         effectpos.x = effectpos.x - 1
  940.         effectpos.y = effectpos.y + 1
  941.         effect = 130
  942.         damagearea = wingdw
  943.     end
  944.  
  945.         doSendMagicEffect(effectpos, effect)
  946.         doAreaCombatHealth(cid, POISONDAMAGE, getThingPositionWithDebug(cid), damagearea, -min, -max, 114)
  947.  
  948. elseif spell == "Mud Bomb" then
  949.  
  950.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 38)
  951.  
  952.         local function doDamageWithDelay(cid, target)
  953.         if not isCreature(cid) or not isCreature(target) then return true end
  954.         doAreaCombatHealth(cid, GROUNDDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), bomb, -min, -max, 116)
  955.         doAreaCombatHealth(cid, null, getThingPositionWithDebug(getMasterTarget(cid)), bomb, 0, 0, 34)
  956.  
  957.         if math.random(1, 100) >= 50 then
  958.             local rounds = math.random(6, 10)
  959.             rounds = rounds + math.floor(getPokemonLevel(cid) / 20)
  960.             doAdvancedBlind(target, rounds, getPlayerStorageValue(target, 3890), 34)
  961.         end
  962.         end
  963.  
  964.         addEvent(doDamageWithDelay, getDistDelay, cid, target)
  965.  
  966. elseif spell == "Sonicboom" then
  967.  
  968.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 33)
  969.         doAreaCombatHealthAtDistance(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 244)
  970.  
  971. elseif spell == "Flamethrower" then
  972.  
  973. local flamepos = getThingPositionWithDebug(cid)
  974. local effect = 255
  975. local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  976.  
  977.     if a == 0 then
  978.         flamepos.x = flamepos.x+1
  979.         flamepos.y = flamepos.y-1
  980.         effect = 106
  981.         doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(cid), flamen, -min, -max, 255)
  982.     elseif a == 1 then
  983.         flamepos.x = flamepos.x+3
  984.         flamepos.y = flamepos.y+1
  985.         effect = 109
  986.         doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(cid), flamee, -min, -max, 255)
  987.     elseif a == 2 then
  988.         flamepos.x = flamepos.x+1
  989.         flamepos.y = flamepos.y+3
  990.         effect = 107
  991.         doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(cid), flames, -min, -max, 255)
  992.     elseif a == 3 then
  993.         flamepos.x = flamepos.x-1
  994.         flamepos.y = flamepos.y+1
  995.         effect = 108
  996.         doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(cid), flamew, -min, -max, 255)
  997.     end
  998.  
  999.         doSendMagicEffect(flamepos, effect)
  1000.  
  1001. elseif spell == "Selfdestruct" then
  1002.  
  1003.         setPlayerStorageValue(cid, 33, 1)
  1004.  
  1005.         local function death(params)
  1006.             if isCreature(params.cid) then
  1007.             doCreatureAddHealth(params.cid, -getCreatureMaxHealth(cid))
  1008.             end
  1009.         end
  1010.  
  1011.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), destruct1, -min, -max, 5)
  1012.         addEvent(doAreaCombatHealth, 150, cid, NORMALDAMAGE, getThingPositionWithDebug(cid), destruct2, -(min*0.7), -(max*0.8), 5)
  1013.         addEvent(doAreaCombatHealth, 250, cid, NORMALDAMAGE, getThingPositionWithDebug(cid), destruct3, -(min*0.4), -(max*0.5), 5)
  1014.         addEvent(death, 250, {cid = cid})
  1015.  
  1016. elseif spell == "Drill Peck" then
  1017.  
  1018.         doAreaCombatHealth(cid, FLYDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 110)
  1019.  
  1020.         local hitalvo = getMasterTarget(cid)
  1021.  
  1022.         local function hit(cid, target)
  1023.             if isCreature(cid) and isCreature(target) then
  1024.                 if getMasterTarget(cid) == target then
  1025.                 doAreaCombatHealth(cid, FLYDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 110)
  1026.                 end
  1027.             end
  1028.         end
  1029.  
  1030.         addEvent(hit, 480, cid, hitalvo)
  1031.         addEvent(hit, 880, cid, hitalvo)
  1032.  
  1033. elseif spell == "Dizzy Punch" then
  1034.  
  1035.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 26)
  1036.         doAreaCombatHealth(cid, FIGHTINGDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  1037.         local rounds = getPokemonLevel(cid) / 12
  1038.             rounds = rounds + 2
  1039.         doAdvancedConfuse(target, rounds, getPlayerStorageValue(target, 3891))
  1040.  
  1041. elseif spell == "Poison Gas" then
  1042.  
  1043.     local function gas(params)
  1044.         if not isCreature(params.cid) then return true end
  1045.         doAreaCombatHealth(params.cid, POISONDAMAGE, getThingPositionWithDebug(cid), bomb2, -min, -max, 114)
  1046.     end
  1047.  
  1048.     addEvent(gas, 000, {cid = cid, cb = cb})
  1049.     addEvent(gas, 500, {cid = cid, cb = cb})
  1050.     addEvent(gas, 1000, {cid = cid, cb = cb})
  1051.     addEvent(gas, 1500, {cid = cid, cb = cb})
  1052.     addEvent(gas, 2300, {cid = cid, cb = cb})
  1053.     addEvent(gas, 2800, {cid = cid, cb = cb})
  1054.     addEvent(gas, 3300, {cid = cid, cb = cb})
  1055.     addEvent(gas, 3800, {cid = cid, cb = cb})
  1056.     addEvent(gas, 4600, {cid = cid, cb = cb})
  1057.     addEvent(gas, 5100, {cid = cid, cb = cb})
  1058.  
  1059. elseif spell == "Twister" then
  1060.  
  1061.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 36)
  1062.     doAreaCombatHealthAtDistance(cid, DRAGONDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 42)
  1063.  
  1064. elseif spell == "Rock Tomb" then
  1065.  
  1066. local rock1 = {}
  1067. local rock2 = {}
  1068. local rock3 = {}
  1069. local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  1070.  
  1071.     if a == 0 then
  1072.         rock1 = {x=getThingPositionWithDebug(cid).x+1, y=getThingPositionWithDebug(cid).y-1, z=getThingPositionWithDebug(cid).z}
  1073.         rock2 = {x=getThingPositionWithDebug(cid).x+0, y=getThingPositionWithDebug(cid).y-1, z=getThingPositionWithDebug(cid).z}
  1074.         rock3 = {x=getThingPositionWithDebug(cid).x-1, y=getThingPositionWithDebug(cid).y-1, z=getThingPositionWithDebug(cid).z}
  1075.         doAreaCombatHealth(cid, ROCKDAMAGE, getThingPositionWithDebug(cid), tombn, -min, -max, 118)
  1076.     elseif a == 2 then
  1077.         rock1 = {x=getThingPositionWithDebug(cid).x+1, y=getThingPositionWithDebug(cid).y+1, z=getThingPositionWithDebug(cid).z}
  1078.         rock2 = {x=getThingPositionWithDebug(cid).x+0, y=getThingPositionWithDebug(cid).y+1, z=getThingPositionWithDebug(cid).z}
  1079.         rock3 = {x=getThingPositionWithDebug(cid).x-1, y=getThingPositionWithDebug(cid).y+1, z=getThingPositionWithDebug(cid).z}
  1080.         doAreaCombatHealth(cid, ROCKDAMAGE, getThingPositionWithDebug(cid), tombs, -min, -max, 118)
  1081.     elseif a == 3 then
  1082.         rock1 = {x=getThingPositionWithDebug(cid).x-1, y=getThingPositionWithDebug(cid).y+1, z=getThingPositionWithDebug(cid).z}
  1083.         rock2 = {x=getThingPositionWithDebug(cid).x-1, y=getThingPositionWithDebug(cid).y+0, z=getThingPositionWithDebug(cid).z}
  1084.         rock3 = {x=getThingPositionWithDebug(cid).x-1, y=getThingPositionWithDebug(cid).y-1, z=getThingPositionWithDebug(cid).z}
  1085.         doAreaCombatHealth(cid, ROCKDAMAGE, getThingPositionWithDebug(cid), tombw, -min, -max, 118)
  1086.     elseif a == 1 then
  1087.         rock1 = {x=getThingPositionWithDebug(cid).x+1, y=getThingPositionWithDebug(cid).y+1, z=getThingPositionWithDebug(cid).z}
  1088.         rock2 = {x=getThingPositionWithDebug(cid).x+1, y=getThingPositionWithDebug(cid).y+0, z=getThingPositionWithDebug(cid).z}
  1089.         rock3 = {x=getThingPositionWithDebug(cid).x+1, y=getThingPositionWithDebug(cid).y-1, z=getThingPositionWithDebug(cid).z}
  1090.         doAreaCombatHealth(cid, ROCKDAMAGE, getThingPositionWithDebug(cid), tombe, -min, -max, 118)
  1091.     end
  1092.  
  1093.     doSendDistanceShoot(getThingPositionWithDebug(cid), rock1, 11)
  1094.     doSendDistanceShoot(getThingPositionWithDebug(cid), rock2, 11)
  1095.     doSendDistanceShoot(getThingPositionWithDebug(cid), rock3, 11)
  1096.  
  1097. elseif spell == "Discharge" then
  1098.  
  1099.         local function discharge(cid, time)
  1100.             if not isCreature(cid) then
  1101.             return true
  1102.             end
  1103.  
  1104.             if time == 0 then
  1105.             doSendAnimatedText(getThingPositionWithDebug(cid), "CHARGING", 210)
  1106.             doSendMagicEffect(getThingPositionWithDebug(cid), 48)
  1107.             addEvent(discharge, 1000, cid, time + 1)
  1108.             return true
  1109.             end
  1110.  
  1111.             if math.random(1, 100) >= 78 then
  1112.             doCreatureSay(cid, "DISCHARGE!", TALKTYPE_MONSTER)
  1113.             doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), charge, -(min*(time)), -(max*(time)), 48)
  1114.             else
  1115.                 if time >= 6 then
  1116.                 doSendAnimatedText(getThingPositionWithDebug(cid), "FAIL", 215)
  1117.                 return true
  1118.                 end
  1119.  
  1120.                 doSendAnimatedText(getThingPositionWithDebug(cid), "CHARGING", 210)
  1121.                 doSendMagicEffect(getThingPositionWithDebug(cid), 48)
  1122.                 addEvent(discharge, 1000, cid, time + 1)
  1123.             return true
  1124.             end
  1125.             end
  1126.  
  1127.     discharge(cid, 0)
  1128.  
  1129. elseif spell == "Mega Prick" then
  1130.  
  1131.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 25)
  1132.     doAreaCombatHealthAtDistance(cid, BUGDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  1133.                
  1134. elseif spell == "Gunk Shot" then
  1135.  
  1136.     local target = getMasterTarget(cid)
  1137.  
  1138.     local function rocksdown(cid, target, pos)
  1139.         if not isCreature(cid) then return true end
  1140.         if not isCreature(target) then return true end
  1141.  
  1142.         doSendDistanceShoot(pos, getThingPositionWithDebug(target), 6)
  1143.         doAreaCombatHealth(cid, POISONDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), tresportres, -min, -max, 116)
  1144.     end
  1145.  
  1146.     local function rocksup(cid, target)
  1147.         if not isCreature(cid) or not isCreature(target) then return true end
  1148.  
  1149.         local posa = getThingPositionWithDebug(cid)
  1150.         local posb = getThingPositionWithDebug(target)
  1151.         local xx = 0
  1152.             if posb.x < posa.x then
  1153.             xx = -1
  1154.             end
  1155.         local posc = posa
  1156.         posc.x = posc.x + xx
  1157.         posc.y = posc.y - 3
  1158.  
  1159.         doSendDistanceShoot(getThingPositionWithDebug(cid), posc, 6)
  1160.     addEvent(rocksdown, 300, cid, target, posc)
  1161.     end
  1162.    
  1163.     rocksup(cid, target)
  1164.  
  1165. elseif spell == "Tornado" then
  1166.  
  1167.     local pos = getThingPositionWithDebug(cid)
  1168.  
  1169.     local function tornado(cid, area, effect, type)
  1170.     if not isCreature(cid) then return true end
  1171.     doAreaCombatHealth(cid, type, pos, area, -min, -max, effect)
  1172.     end
  1173.  
  1174.         addEvent(tornado, 0, cid, tor1, CONST_ME_POFF, null)
  1175.         addEvent(tornado, 200, cid, tor1, 42, FLYDAMAGE)
  1176.         addEvent(tornado, 500, cid, tor2, CONST_ME_POFF, null)
  1177.         addEvent(tornado, 700, cid, tor2, 42, FLYDAMAGE)
  1178.         addEvent(tornado, 1000, cid, tor3, CONST_ME_POFF, null)
  1179.         addEvent(tornado, 1200, cid, tor3, 42, FLYDAMAGE)
  1180.         addEvent(tornado, 750, cid, tor1, CONST_ME_POFF, null)
  1181.         addEvent(tornado, 1250, cid, tor2, CONST_ME_POFF, null)
  1182.         addEvent(tornado, 1550, cid, tor3, CONST_ME_POFF, null)
  1183.  
  1184. elseif spell == "Psybeam" then
  1185.  
  1186.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid), true) or getCreatureLookDir(cid)
  1187.  
  1188.     if a == 0 then
  1189.         doAreaCombatHealth(cid, PSYDAMAGE, getThingPositionWithDebug(cid), bmn, -min, -max, 57)
  1190.     elseif a == 2 then
  1191.         doAreaCombatHealth(cid, PSYDAMAGE, getThingPositionWithDebug(cid), bms, -min, -max, 58)
  1192.     elseif a == 1 then
  1193.         doAreaCombatHealth(cid, PSYDAMAGE, getThingPositionWithDebug(cid), bme, -min, -max, 234)
  1194.     elseif a == 3 then
  1195.         doAreaCombatHealth(cid, PSYDAMAGE, getThingPositionWithDebug(cid), bmw, -min, -max, 209)
  1196.     end
  1197.  
  1198. elseif spell == "Leaf Storm" or tonumber(spell) == 73 then
  1199.  
  1200.     doAreaCombatHealth(cid, GRASSDAMAGE, getThingPositionWithDebug(cid), grassarea, -min, -max, 255)
  1201.  
  1202.     local pos = getThingPositionWithDebug(cid)
  1203.  
  1204.     local function doSendLeafStorm(cid, pos)
  1205.         if not isCreature(cid) then return true end
  1206.     doSendDistanceShoot(getThingPositionWithDebug(cid), pos, 8)
  1207.     end
  1208.  
  1209.     for a = 1, 250 do
  1210.         local lugar = {x = pos.x + math.random(-9, 9), y = pos.y + math.random(-8, 8), z = pos.z}
  1211.         addEvent(doSendLeafStorm, a * 2, cid, lugar)
  1212.     end
  1213.  
  1214. elseif spell == "Magical Leaf" or tonumber(spell) == 73 then
  1215.  
  1216.     doAreaCombatHealth(cid, GRASSDAMAGE, getThingPositionWithDebug(cid), grassarea, -min, -max, 255)
  1217.  
  1218.     local pos = getThingPositionWithDebug(cid)
  1219.  
  1220.     local function doSendLeafStorm(cid, pos)
  1221.         if not isCreature(cid) then return true end
  1222.     doSendDistanceShoot(getThingPositionWithDebug(cid), pos, 21)
  1223.     end
  1224.  
  1225.     for a = 1, 250 do
  1226.         local lugar = {x = pos.x + math.random(-9, 9), y = pos.y + math.random(-8, 8), z = pos.z}
  1227.         addEvent(doSendLeafStorm, a * 2, cid, lugar)
  1228.     end
  1229.  
  1230. elseif spell == "Ranging Blast" then
  1231.  
  1232.     doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(cid), rageblast1, -min, -max, 6)
  1233.  
  1234.     local function damage(cid, area)
  1235.         if not isCreature(cid) then return true end
  1236.     doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(cid), area, -min, -max, 6)
  1237.     end
  1238.  
  1239.     addEvent(damage, 200, cid, rageblast2)
  1240.     addEvent(damage, 400, cid, rageblast3)
  1241.     addEvent(damage, 600, cid, rageblast4)
  1242.     addEvent(damage, 800, cid, rageblast5)
  1243.  
  1244. elseif spell == "Will-O-Wisp" then
  1245.  
  1246. local function damage(cid, area, eff)
  1247. if not isCreature(cid) then return true end
  1248. doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(cid), area, -min, -max,  eff)
  1249. end
  1250. addEvent(damage, 1, cid, wow1, 143)
  1251. addEvent(damage, 20, cid, wow1, 19)
  1252. addEvent(damage, 600, cid, wow2, 143)
  1253. addEvent(damage, 620, cid, wow2, 19)
  1254.  
  1255. elseif spell == "Psyusion" then
  1256.  
  1257. local function damage(cid, area, eff)
  1258. if not isCreature(cid) then return true end
  1259. doAreaCombatHealth(cid, PSYCHICDAMAGE, getThingPositionWithDebug(cid), area, -min, -max,  eff)
  1260. end
  1261. addEvent(damage, 1, cid, psyusion1, 133)
  1262. addEvent(damage, 400, cid, psyusion2, 136)
  1263. addEvent(damage, 800, cid, psyusion3, 133)
  1264. addEvent(damage, 1200, cid, psyusion4, 136)
  1265. addEvent(damage, 1600, cid, psyusion5, 137)
  1266.  
  1267. elseif spell == "Tri Attack" or spell == "Tri-attack" then
  1268.  
  1269.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 238)
  1270.  
  1271. elseif spell == "Petal Dance" or tonumber(spell) == 76 then
  1272.  
  1273. doAreaCombatHealth(cid, GRASSDAMAGE, getThingPositionWithDebug(cid), grassarea, -min, -max, 255)
  1274.  
  1275.     local lugar = getThingPositionWithDebug(cid)
  1276.         for x= -7,7 do
  1277.             for y= -6,6 do
  1278.             local topos = {x=lugar.x+x, y=lugar.y+y, z=lugar.z}
  1279.             doSendDistanceShoot(getThingPositionWithDebug(cid), topos, 21)
  1280.             end
  1281.         end
  1282.  
  1283. elseif spell == "Dragon Pulse" then
  1284.  
  1285.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 24)
  1286.     doAreaCombatHealthAtDistance(cid, DRAGONDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 136)
  1287.  
  1288. elseif spell == "Zaap Cannon" or spell == "Chaarge Beam" then
  1289.  
  1290.   local a = isCreature(target) and getCreatureDirectionToTarget(cid, target) or getCreatureLookDir(cid)
  1291.    
  1292.     if a == 0 then
  1293.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), wg1n, -min, -max, 94)
  1294.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), wg2n, -min, -max, 93)
  1295.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), wg3n, -min, -max, 95)
  1296.     elseif a == 2 then
  1297.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), wg1s, -min, -max, 91)
  1298.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), wg2s, -min, -max, 93)
  1299.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), wg3s, -min, -max, 92)
  1300.     elseif a == 1 then
  1301.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), wg1e, -min, -max, 86)
  1302.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), wg2e, -min, -max, 88)
  1303.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), wg3e, -min, -max, 87)
  1304.     elseif a == 3 then
  1305.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), wg1w, -min, -max, 89)
  1306.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), wg2w, -min, -max, 88)
  1307.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), wg3w, -min, -max, 90)
  1308.     end  
  1309.    
  1310. elseif spell == "Zap Cannon" then
  1311.  
  1312.     local function useSolarBeam(cid)
  1313.         if not isCreature(cid) then
  1314.         return true
  1315.         end
  1316.         if isSleeping(cid) then
  1317.         return true
  1318.         end
  1319.             local effect1 = 255
  1320.             local effect2 = 255
  1321.             local effect3 = 255
  1322.             local effect4 = 255
  1323.             local effect5 = 255
  1324.             local area = {}
  1325.             local pos1 = getThingPositionWithDebug(cid)
  1326.             local pos2 = getThingPositionWithDebug(cid)
  1327.             local pos3 = getThingPositionWithDebug(cid)
  1328.             local pos4 = getThingPositionWithDebug(cid)
  1329.             local pos5 = getThingPositionWithDebug(cid)
  1330.         if getCreatureLookDir(cid) == 1 then
  1331.             effect1 = 4
  1332.             effect2 = 10
  1333.             effect3 = 10
  1334.             effect4 = 10
  1335.             effect5 = 26
  1336.             pos1.x = pos1.x + 2
  1337.             pos1.y = pos1.y + 1
  1338.             pos2.x = pos2.x + 3
  1339.             pos2.y = pos2.y + 1
  1340.             pos3.x = pos3.x + 4
  1341.             pos3.y = pos3.y + 1
  1342.             pos4.x = pos4.x + 5
  1343.             pos4.y = pos4.y + 1
  1344.             pos5.x = pos5.x + 6
  1345.             pos5.y = pos5.y + 1
  1346.             area = solare
  1347.         elseif getCreatureLookDir(cid) == 0 then
  1348.             effect1 = 36
  1349.             effect2 = 37
  1350.             effect3 = 37
  1351.             effect4 = 38
  1352.             pos1.x = pos1.x + 1
  1353.             pos1.y = pos1.y - 1
  1354.             pos2.x = pos2.x + 1
  1355.             pos2.y = pos2.y - 3
  1356.             pos3.x = pos3.x + 1
  1357.             pos3.y = pos3.y - 4
  1358.             pos4.x = pos4.x + 1
  1359.             pos4.y = pos4.y - 5
  1360.             area = solarn
  1361.         elseif getCreatureLookDir(cid) == 2 then
  1362.             effect1 = 46
  1363.             effect2 = 50
  1364.             effect3 = 50
  1365.             effect4 = 59
  1366.             pos1.x = pos1.x + 1
  1367.             pos1.y = pos1.y + 2
  1368.             pos2.x = pos2.x + 1
  1369.             pos2.y = pos2.y + 3
  1370.             pos3.x = pos3.x + 1
  1371.             pos3.y = pos3.y + 4
  1372.             pos4.x = pos4.x + 1
  1373.             pos4.y = pos4.y + 5
  1374.             area = solars
  1375.         elseif getCreatureLookDir(cid) == 3 then
  1376.             effect1 = 115
  1377.             effect2 = 162
  1378.             effect3 = 162
  1379.             effect4 = 162
  1380.             effect5 = 163
  1381.             pos1.x = pos1.x - 1
  1382.             pos1.y = pos1.y + 1
  1383.             pos2.x = pos2.x - 3
  1384.             pos2.y = pos2.y + 1
  1385.             pos3.x = pos3.x - 4
  1386.             pos3.y = pos3.y + 1
  1387.             pos4.x = pos4.x - 5
  1388.             pos4.y = pos4.y + 1
  1389.             pos5.x = pos5.x - 6
  1390.             pos5.y = pos5.y + 1
  1391.             area = solarw
  1392.         end
  1393.  
  1394.         if effect1 ~= 255 then
  1395.             doSendMagicEffect(pos1, effect1)
  1396.         end
  1397.         if effect2 ~= 255 then
  1398.             doSendMagicEffect(pos2, effect2)
  1399.         end
  1400.         if effect3 ~= 255 then
  1401.             doSendMagicEffect(pos3, effect3)
  1402.         end
  1403.         if effect4 ~= 255 then
  1404.             doSendMagicEffect(pos4, effect4)
  1405.         end
  1406.         if effect5 ~= 255 then
  1407.             doSendMagicEffect(pos5, effect5)
  1408.         end
  1409.    
  1410.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), area, -min, -max, 255) 
  1411.         doRegainSpeed(cid)
  1412.     end
  1413.  
  1414.     local function ChargingBeam(cid)
  1415.         if not isCreature(cid) then
  1416.         return true
  1417.         end
  1418.         if isSleeping(cid) then
  1419.         return true
  1420.         end
  1421.         local tab = {}
  1422.  
  1423.         for x = -2, 2 do
  1424.             for y = -2, 2 do
  1425.                 local pos = getThingPositionWithDebug(cid)
  1426.                 pos.x = pos.x + x
  1427.                 pos.y = pos.y + y
  1428.                     if pos.x ~= getThingPositionWithDebug(cid).x and pos.y ~= getThingPositionWithDebug(cid).y then
  1429.                     table.insert(tab, pos)
  1430.                     end
  1431.             end
  1432.         end
  1433.     doSendDistanceShoot(tab[math.random(#tab)], getThingPositionWithDebug(cid), 41)
  1434.     end
  1435.  
  1436. doChangeSpeed(cid, -getCreatureSpeed(cid))
  1437.  
  1438. for r = 1, 10 do
  1439.     addEvent(ChargingBeam, r*9, cid)
  1440. end
  1441.  
  1442. addEvent(useSolarBeam, 100, cid)
  1443.  
  1444. elseif spell == "Charge Beam" then
  1445.  
  1446.     for pa = -2, 2 do
  1447.         for pb = -2, 2 do
  1448.             local pos = getThingPositionWithDebug(cid)
  1449.             pos.x = pos.x+pa
  1450.             pos.y = pos.y+pb
  1451.             doSendDistanceShoot(pos, getThingPositionWithDebug(cid), 40)
  1452.         end
  1453.     end
  1454.         local function dmgbeam(cid)
  1455.         if not isCreature(cid) then return true end
  1456.         local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  1457.             if a == 0 then
  1458.                 doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), beamn, -min, -max, 48)
  1459.             elseif a == 1 then
  1460.                 doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), beame, -min, -max, 48)
  1461.             elseif a == 2 then
  1462.                 doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), beams, -min, -max, 48)
  1463.             elseif a == 3 then
  1464.                 doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(cid), beamw, -min, -max, 48)
  1465.             end
  1466.         end
  1467.  
  1468.         addEvent(dmgbeam, 700, cid)
  1469.  
  1470. elseif spell == "Slime Wave" then
  1471.  
  1472.     local function slime(cid, area)
  1473.         if not isCreature(cid) then return true end
  1474.         doAreaCombatHealth(cid, POISONDAMAGE, area, wave, -min, -max, 116)
  1475.         doAreaCombatHealth(cid, null, area, wave, -min, -max, 114)
  1476.     end
  1477.  
  1478.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  1479.     local posicao = getThingPositionWithDebug(cid)
  1480.  
  1481.     if a == 0 then
  1482.         addEvent(slime, 0, cid, {x=posicao.x, y=posicao.y-1, z=posicao.z})
  1483.         addEvent(slime, 150, cid, {x=posicao.x, y=posicao.y-2, z=posicao.z})
  1484.         addEvent(slime, 300, cid, {x=posicao.x, y=posicao.y-3, z=posicao.z})
  1485.         addEvent(slime, 450, cid, {x=posicao.x, y=posicao.y-4, z=posicao.z})
  1486.     elseif a == 1 then
  1487.         addEvent(slime, 0, cid, {x=posicao.x+1, y=posicao.y, z=posicao.z})
  1488.         addEvent(slime, 150, cid, {x=posicao.x+2, y=posicao.y, z=posicao.z})
  1489.         addEvent(slime, 300, cid, {x=posicao.x+3, y=posicao.y, z=posicao.z})
  1490.         addEvent(slime, 450, cid, {x=posicao.x+4, y=posicao.y, z=posicao.z})
  1491.     elseif a == 2 then
  1492.         addEvent(slime, 0, cid, {x=posicao.x, y=posicao.y+1, z=posicao.z})
  1493.         addEvent(slime, 150, cid, {x=posicao.x, y=posicao.y+2, z=posicao.z})
  1494.         addEvent(slime, 300, cid, {x=posicao.x, y=posicao.y+3, z=posicao.z})
  1495.         addEvent(slime, 450, cid, {x=posicao.x, y=posicao.y+4, z=posicao.z})
  1496.     elseif a == 3 then
  1497.         addEvent(slime, 0, cid, {x=posicao.x-1, y=posicao.y, z=posicao.z})
  1498.         addEvent(slime, 150, cid, {x=posicao.x-2, y=posicao.y, z=posicao.z})
  1499.         addEvent(slime, 300, cid, {x=posicao.x-3, y=posicao.y, z=posicao.z})
  1500.         addEvent(slime, 450, cid, {x=posicao.x-4, y=posicao.y, z=posicao.z})
  1501.     end
  1502.  
  1503. elseif spell == "Earthshock" then
  1504.  
  1505.     doAreaCombatHealth(cid, GROUNDDAMAGE, getThingPositionWithDebug(cid), eshock, -min, -max, 255)
  1506.  
  1507.     local sps = getThingPositionWithDebug(cid)
  1508.     sps.x = sps.x+1
  1509.     sps.y = sps.y+1
  1510.     doSendMagicEffect(sps, 127)
  1511.  
  1512. elseif spell == "Flame Burst" then
  1513.  
  1514.     doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(cid), eshock, -min, -max, 255)
  1515.  
  1516.     local sps = getThingPositionWithDebug(cid)
  1517.     sps.x = sps.x+1
  1518.     sps.y = sps.y+1
  1519.     doSendMagicEffect(sps, 241)
  1520.  
  1521. elseif spell == "Solar Beam" then
  1522.  
  1523.     local function useSolarBeam(cid)
  1524.         if not isCreature(cid) then
  1525.         return true
  1526.         end
  1527.         if isSleeping(cid) then
  1528.         return true
  1529.         end
  1530.             local effect1 = 255
  1531.             local effect2 = 255
  1532.             local effect3 = 255
  1533.             local effect4 = 255
  1534.             local effect5 = 255
  1535.             local area = {}
  1536.             local pos1 = getThingPositionWithDebug(cid)
  1537.             local pos2 = getThingPositionWithDebug(cid)
  1538.             local pos3 = getThingPositionWithDebug(cid)
  1539.             local pos4 = getThingPositionWithDebug(cid)
  1540.             local pos5 = getThingPositionWithDebug(cid)
  1541.         if getCreatureLookDir(cid) == 1 then
  1542.             effect1 = 4
  1543.             effect2 = 10
  1544.             effect3 = 10
  1545.             effect4 = 10
  1546.             effect5 = 26
  1547.             pos1.x = pos1.x + 2
  1548.             pos1.y = pos1.y + 1
  1549.             pos2.x = pos2.x + 3
  1550.             pos2.y = pos2.y + 1
  1551.             pos3.x = pos3.x + 4
  1552.             pos3.y = pos3.y + 1
  1553.             pos4.x = pos4.x + 5
  1554.             pos4.y = pos4.y + 1
  1555.             pos5.x = pos5.x + 6
  1556.             pos5.y = pos5.y + 1
  1557.             area = solare
  1558.         elseif getCreatureLookDir(cid) == 0 then
  1559.             effect1 = 36
  1560.             effect2 = 37
  1561.             effect3 = 37
  1562.             effect4 = 38
  1563.             pos1.x = pos1.x + 1
  1564.             pos1.y = pos1.y - 1
  1565.             pos2.x = pos2.x + 1
  1566.             pos2.y = pos2.y - 3
  1567.             pos3.x = pos3.x + 1
  1568.             pos3.y = pos3.y - 4
  1569.             pos4.x = pos4.x + 1
  1570.             pos4.y = pos4.y - 5
  1571.             area = solarn
  1572.         elseif getCreatureLookDir(cid) == 2 then
  1573.             effect1 = 46
  1574.             effect2 = 50
  1575.             effect3 = 50
  1576.             effect4 = 59
  1577.             pos1.x = pos1.x + 1
  1578.             pos1.y = pos1.y + 2
  1579.             pos2.x = pos2.x + 1
  1580.             pos2.y = pos2.y + 3
  1581.             pos3.x = pos3.x + 1
  1582.             pos3.y = pos3.y + 4
  1583.             pos4.x = pos4.x + 1
  1584.             pos4.y = pos4.y + 5
  1585.             area = solars
  1586.         elseif getCreatureLookDir(cid) == 3 then
  1587.             effect1 = 115
  1588.             effect2 = 162
  1589.             effect3 = 162
  1590.             effect4 = 162
  1591.             effect5 = 163
  1592.             pos1.x = pos1.x - 1
  1593.             pos1.y = pos1.y + 1
  1594.             pos2.x = pos2.x - 3
  1595.             pos2.y = pos2.y + 1
  1596.             pos3.x = pos3.x - 4
  1597.             pos3.y = pos3.y + 1
  1598.             pos4.x = pos4.x - 5
  1599.             pos4.y = pos4.y + 1
  1600.             pos5.x = pos5.x - 6
  1601.             pos5.y = pos5.y + 1
  1602.             area = solarw
  1603.         end
  1604.  
  1605.         if effect1 ~= 255 then
  1606.             doSendMagicEffect(pos1, effect1)
  1607.         end
  1608.         if effect2 ~= 255 then
  1609.             doSendMagicEffect(pos2, effect2)
  1610.         end
  1611.         if effect3 ~= 255 then
  1612.             doSendMagicEffect(pos3, effect3)
  1613.         end
  1614.         if effect4 ~= 255 then
  1615.             doSendMagicEffect(pos4, effect4)
  1616.         end
  1617.         if effect5 ~= 255 then
  1618.             doSendMagicEffect(pos5, effect5)
  1619.         end
  1620.    
  1621.         doAreaCombatHealth(cid, GRASSDAMAGE, getThingPositionWithDebug(cid), area, -min, -max, 255)
  1622.         doRegainSpeed(cid)
  1623.     end
  1624.  
  1625.     local function ChargingBeam(cid)
  1626.         if not isCreature(cid) then
  1627.         return true
  1628.         end
  1629.         if isSleeping(cid) then
  1630.         return true
  1631.         end
  1632.         local tab = {}
  1633.  
  1634.         for x = -2, 2 do
  1635.             for y = -2, 2 do
  1636.                 local pos = getThingPositionWithDebug(cid)
  1637.                 pos.x = pos.x + x
  1638.                 pos.y = pos.y + y
  1639.                     if pos.x ~= getThingPositionWithDebug(cid).x and pos.y ~= getThingPositionWithDebug(cid).y then
  1640.                     table.insert(tab, pos)
  1641.                     end
  1642.             end
  1643.         end
  1644.     doSendDistanceShoot(tab[math.random(#tab)], getThingPositionWithDebug(cid), 37)
  1645.     end
  1646.  
  1647. doChangeSpeed(cid, -getCreatureSpeed(cid))
  1648.  
  1649. for r = 1, 270 do
  1650.     addEvent(ChargingBeam, r*9, cid)
  1651. end
  1652.  
  1653. addEvent(useSolarBeam, 2800, cid)
  1654.  
  1655. elseif spell == "Sleep Powder" then
  1656.  
  1657.     local calc = math.floor(getPokemonLevel(cid) / 20)
  1658.     local v1 = 6
  1659.     local v2 = v1 + calc
  1660.     doAreaCombatHealth(cid, SLEEP_POWDERDAMAGE, getThingPositionWithDebug(cid), powders, -v1, -v2, 27)
  1661.  
  1662. elseif spell == "Stun Spore" then
  1663.  
  1664.     local area = powders
  1665.  
  1666.     doAreaCombatCondition(cid, getThingPositionWithDebug(cid), area, stunsporecondition, 85)
  1667.  
  1668. elseif spell == "Poison Powder" then
  1669.  
  1670.     local v1 = (10 + getPokemonLevel(cid)) * 2
  1671.         setPlayerStorageValue(cid, 919231, v1)
  1672.     local v3 = getPokemonLevel(cid) / 10 + 5
  1673.  
  1674.     doAreaCombatHealth(cid, POISON_POWDERDAMAGE, getThingPositionWithDebug(cid), powders, -v3, -v3, 84)
  1675.  
  1676. elseif spell == "Body Slam" then
  1677.    
  1678.     doBodyPush(cid, target, true)
  1679.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  1680.  
  1681. elseif spell == "Bullet Seed" then
  1682.  
  1683.     local function doShootBulletSeed(cid, target, shoot, effect)
  1684.         if not isCreature(cid) or not isCreature(target) then return true end
  1685.         if getCreatureHealth(target) <= 0 then return true end
  1686.         if shoot then
  1687.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 1)
  1688.         end
  1689.         if effect then
  1690.         doSendMagicEffect(getThingPositionWithDebug(target), effect)
  1691.         end
  1692.  
  1693.         doAreaCombatHealth(cid, GRASSDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 245)
  1694.     end
  1695.  
  1696.     for a = 1, 9 do
  1697.         if a == 3 or a == 6 or a == 9 then
  1698.             addEvent(doShootBulletSeed, a * 65, cid, getMasterTarget(cid), true, 45)
  1699.         else
  1700.             addEvent(doShootBulletSeed, a * 65, cid, getMasterTarget(cid), true, 3)
  1701.         end
  1702.     end
  1703.  
  1704.  
  1705. elseif spell == "Flame Wheel" then
  1706.  
  1707.     local function sendFireEff(cid, dir)
  1708.         if not isCreature(cid) then return true end
  1709.         doAreaCombatHealth(cid, FIREDAMAGE, getPosByDir(getThingPositionWithDebug(cid), dir), 0, -min, -max, 237)
  1710.     end
  1711.  
  1712.     local function doSpinFire(cid)
  1713.         if not isCreature(cid) then return true end
  1714.         local t = {
  1715.             [1] = SOUTHWEST,
  1716.             [2] = SOUTH,
  1717.             [3] = SOUTHEAST,
  1718.             [4] = EAST,
  1719.             [5] = NORTHEAST,
  1720.             [6] = NORTH,
  1721.             [7] = NORTHWEST,
  1722.             [8] = WEST,
  1723.             [17] = SOUTHWEST,
  1724.             }
  1725.         for a = 1, 17 do
  1726.             if not t[a] then
  1727.             addEvent(sendFireEff, a * 140, cid, t[a-8])
  1728.             else
  1729.             addEvent(sendFireEff, a * 140, cid, t[a])
  1730.             end
  1731.         end
  1732.     end
  1733.  
  1734.     doSpinFire(cid, false, cid)
  1735.  
  1736. elseif spell == "Burning Skin" then
  1737.  
  1738.     local function doBurnSkin(cid)
  1739.         if not isCreature(cid) then return true end
  1740.         doSendMagicEffect(getThingPositionWithDebug(cid), 35)
  1741.         for a = 0, 7 do
  1742.             local pos = getPosByDir(getThingPositionWithDebug(cid), a)
  1743.             local man = getTopCreature(pos).uid
  1744.             if isCreature(man) then
  1745.                 doAreaCombatHealth(cid, FIREDAMAGE, pos, 0, -min, -max, 255)
  1746.             end
  1747.         end
  1748.     end
  1749.  
  1750.     for b = 1, 10 do
  1751.         addEvent(doBurnSkin, b * 650, cid)
  1752.     end
  1753.  
  1754. elseif spell == "Fire Blast" then
  1755.  
  1756.     local posicao = getThingPositionWithDebug(cid)
  1757.  
  1758.     local function fireBlast(cid, area1, area2, effect, area3)
  1759.         if not isCreature(cid) then return true end
  1760.         if not isSightClear(posicao, area1, false) then return true end
  1761.         doAreaCombatHealth(cid, null, area1, 0, -min, -max, effect)
  1762.             if area2.x ~= getThingPositionWithDebug(cid).x or area2.y ~= getThingPositionWithDebug(cid).y then
  1763.                 doAreaCombatHealth(cid, null, area2, area3, -min, -max, 35)
  1764.             end
  1765.         doAreaCombatHealth(cid, FIREDAMAGE, area1, area3, -min, -max, 35)
  1766.     end
  1767.  
  1768.     local m = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  1769.  
  1770.     if m == 0 then
  1771.         for a = 0, 5 do
  1772.             addEvent(fireBlast, 300 * a, cid, {x = posicao.x, y = posicao.y - (a + 1), z = posicao.z}, {x = posicao.x, y = posicao.y - a, z = posicao.z}, 60, whirl3)
  1773.         end
  1774.     elseif m == 2 then
  1775.         for a = 0, 5 do
  1776.             addEvent(fireBlast, 300 * a, cid, {x = posicao.x, y = posicao.y + (a + 1), z = posicao.z}, {x = posicao.x, y = posicao.y + a, z = posicao.z}, 62, whirl3)
  1777.         end
  1778.     elseif m == 1 then
  1779.         for a = 0, 5 do
  1780.             addEvent(fireBlast, 300 * a, cid, {x = posicao.x + a + 1, y = posicao.y, z = posicao.z}, {x = posicao.x + a, y = posicao.y, z = posicao.z}, 61, whirl3)
  1781.         end
  1782.     elseif m == 3 then
  1783.         for a = 0, 5 do
  1784.             addEvent(fireBlast, 300 * a, cid, {x = posicao.x - (a + 1), y = posicao.y, z = posicao.z}, {x = posicao.x - a, y = posicao.y, z = posicao.z}, 63, whirl3)
  1785.         end
  1786.     end
  1787.  
  1788. elseif spell == "Dark Blast" then
  1789.  
  1790.     local posicao = getThingPositionWithDebug(cid)
  1791.  
  1792.     local function fireBlast(cid, area1, area2, effect, area3)
  1793.         if not isCreature(cid) then return true end
  1794.         if not isSightClear(posicao, area1, false) then return true end
  1795.         doAreaCombatHealth(cid, null, area1, 0, -min, -max, effect)
  1796.             if area2.x ~= getThingPositionWithDebug(cid).x or area2.y ~= getThingPositionWithDebug(cid).y then
  1797.                 doAreaCombatHealth(cid, null, area2, area3, -min, -max, 47)
  1798.             end
  1799.         doAreaCombatHealth(cid, DARKDAMAGE, area1, area3, -min, -max, 47)
  1800.     end
  1801.  
  1802.     local m = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  1803.  
  1804.     if m == 0 then
  1805.         for a = 0, 5 do
  1806.             addEvent(fireBlast, 300 * a, cid, {x = posicao.x, y = posicao.y - (a + 1), z = posicao.z}, {x = posicao.x, y = posicao.y - a, z = posicao.z}, 47, whirl3)
  1807.         end
  1808.     elseif m == 2 then
  1809.         for a = 0, 5 do
  1810.             addEvent(fireBlast, 300 * a, cid, {x = posicao.x, y = posicao.y + (a + 1), z = posicao.z}, {x = posicao.x, y = posicao.y + a, z = posicao.z}, 47, whirl3)
  1811.         end
  1812.     elseif m == 1 then
  1813.         for a = 0, 5 do
  1814.             addEvent(fireBlast, 300 * a, cid, {x = posicao.x + a + 1, y = posicao.y, z = posicao.z}, {x = posicao.x + a, y = posicao.y, z = posicao.z}, 47, whirl3)
  1815.         end
  1816.     elseif m == 3 then
  1817.         for a = 0, 5 do
  1818.             addEvent(fireBlast, 300 * a, cid, {x = posicao.x - (a + 1), y = posicao.y, z = posicao.z}, {x = posicao.x - a, y = posicao.y, z = posicao.z}, 47, whirl3)
  1819.         end
  1820.     end
  1821.  
  1822. elseif spell == "Bubble Blast" then
  1823.  
  1824.     local pos = getThingPositionWithDebug(cid)
  1825.  
  1826.     local function doSendBubble(cid, pos)
  1827.         if not isCreature(cid) then return true end
  1828.         doSendDistanceShoot(getThingPositionWithDebug(cid), pos, 2)
  1829.         doSendMagicEffect(pos, 25)
  1830.         doAreaCombatHealth(cid, WATERDAMAGE, pos, 0, -min, -max, 1)
  1831.     end
  1832.  
  1833.     for b = 1, 3 do
  1834.         for a = 1, 20 do
  1835.             local lugar = {x = pos.x + math.random(-3, 3), y = pos.y + math.random(-2, 2), z = pos.z}
  1836.             addEvent(doSendBubble, a * 75, cid, lugar)
  1837.         end
  1838.     end
  1839.  
  1840.  
  1841. elseif spell == "Jet Cannons" then
  1842.  
  1843.     local function doWaterGun(cid, pos, effectlist, arealist)
  1844.         if not isCreature(cid) then return true end
  1845.         doAreaCombatHealth(cid, WATERDAMAGE, pos, arealist[1], -min, -max, effectlist[1])
  1846.         doAreaCombatHealth(cid, WATERDAMAGE, pos, arealist[2], -min, -max, effectlist[2])
  1847.         doAreaCombatHealth(cid, WATERDAMAGE, pos, arealist[3], -min, -max, effectlist[3])
  1848.     end
  1849.  
  1850.     local pos = getThingPositionWithDebug(cid)
  1851.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  1852.  
  1853.     if a == 0 then
  1854.  
  1855.         local list = {74, 75, 76}
  1856.         local lisx = {jg1n, jg2n, jg3n}
  1857.         doWaterGun(cid, pos, list, lisx)
  1858.  
  1859.     elseif a == 2 then
  1860.  
  1861.         local list = {77, 75, 78}
  1862.         local lisx = {jg1s, jg2s, jg3s}
  1863.         doWaterGun(cid, pos, list, lisx)
  1864.  
  1865.     elseif a == 1 then
  1866.  
  1867.         local list = {69, 70, 71}
  1868.         local lisx = {jg1e, jg2e, jg3e}
  1869.         doWaterGun(cid, pos, list, lisx)
  1870.  
  1871.     elseif a == 3 then
  1872.  
  1873.         local list = {72, 70, 73}
  1874.         local lisx = {jg1w, jg2w, jg3w}
  1875.         doWaterGun(cid, pos, list, lisx)
  1876.     end
  1877.  
  1878. elseif spell == "Hydro Pump" then
  1879.  
  1880.     local function doUpdateHydroPumpPos(cid, pos)
  1881.         if isCreature(cid) then
  1882.         return getThingPositionWithDebug(cid)
  1883.         else
  1884.         return pos
  1885.         end
  1886.     end
  1887.        
  1888.  
  1889.     local function doSendHydroPump(pos, base)
  1890.     if base then
  1891.     doSendMagicEffect(pos, 53)
  1892.     end
  1893.         local topos = {x = pos.x, y = pos.y, z = pos.z}
  1894.         topos.x = topos.x + math.random(-1, 1)
  1895.         local random = math.random(-6, -4)
  1896.         topos.y = topos.y + random
  1897.     doSendDistanceShoot(pos, topos, 2)
  1898.     addEvent(doSendMagicEffect, math.abs(random) * 50, topos, 1)
  1899.     end
  1900.  
  1901.     local target = getMasterTarget(cid)
  1902.     local pos = getThingPositionWithDebug(target)
  1903.  
  1904.     for a = 1, 18 do
  1905.         local backup = pos
  1906.         pos = doUpdateHydroPumpPos(target, backup)
  1907.         if a == 3 or a == 6 or a == 9 or a == 12 or a == 15 or a == 18 then
  1908.             addEvent(doSendHydroPump, a * 55, pos, true)
  1909.         else
  1910.             addEvent(doSendHydroPump, a * 55, pos, false)
  1911.         end
  1912.     end
  1913.  
  1914.     doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 255)
  1915.  
  1916. elseif spell == "Skull Bash" then
  1917.  
  1918.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 118)
  1919.  
  1920. elseif spell == "Sing" then
  1921.  
  1922.     doAreaCombatHealth(cid, SLEEP_POWDERDAMAGE, getThingPositionWithDebug(cid), powders, -6, -10, 33)
  1923.     local pos = getThingPositionWithDebug(cid)
  1924.  
  1925.     local function doSing(cid, effect, pos)
  1926.         if not isCreature(cid) then return true end
  1927.         doAreaCombatHealth(cid, null, pos, powders, 0, 0, effect)
  1928.     end
  1929.  
  1930. elseif spell == "Invisible" or spell == "GhostInvisible" then
  1931.  
  1932.     if getPokemonLevel(cid) <= 40 then
  1933.         doCreatureAddCondition(cid, weakinvisible)
  1934.     else
  1935.         doCreatureAddCondition(cid, stronginvisible)
  1936.     end
  1937.         doSendMagicEffect(getThingPositionWithDebug(cid), 134)
  1938.  
  1939. elseif spell == "Mach Punch" then
  1940.  
  1941.     doSendMagicEffect(getThingPositionWithDebug(cid), 211)
  1942.     local x = getClosestFreeTile(cid, getThingPositionWithDebug(getMasterTarget(cid)))
  1943.     doTeleportThing(cid, x, false)
  1944.     doFaceCreature(cid, getThingPositionWithDebug(getMasterTarget(cid)))
  1945.     doAreaCombatHealth(cid, FIGHTDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 112)
  1946.  
  1947. elseif spell == "Hypnosis" then
  1948.  
  1949.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 24)
  1950.     doAreaCombatHealthAtDistance(cid, SLEEP_POWDERDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -5, -9, 255)
  1951.  
  1952. elseif spell == "Dark Void" then
  1953.  
  1954.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 20)
  1955.     doAreaCombatHealthAtDistance(cid, SLEEP_POWDERDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -5, -9, 255)
  1956.  
  1957. elseif spell == "Extreme Speed" or tonumber(spell) == 102 then
  1958.  
  1959.     doCreatureAddCondition(cid, permanentinvisible)
  1960.     local x = getCreatureSpeed(cid)
  1961.     local target = getMasterTarget(cid)
  1962.     doChangeSpeed(cid, -x)
  1963.     doSendMagicEffect(getThingPositionWithDebug(cid), 211)
  1964.  
  1965.         local function doFinishExtremeSpeed(cid, target, x)
  1966.             if not isCreature(cid) then return true end
  1967.             if not isCreature(target) then doRemoveCondition(cid, CONDITION_INVISIBLE) return true end
  1968.             doTeleportThing(cid, getClosestFreeTile(cid, getThingPositionWithDebug(target)), false)
  1969.             doRemoveCondition(cid, CONDITION_INVISIBLE)
  1970.             doSendMagicEffect(getThingPositionWithDebug(cid), 211)
  1971.             doFaceCreature(cid, getThingPositionWithDebug(target))
  1972.             doChangeSpeed(cid, x)
  1973.             doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 3)
  1974.         end
  1975.  
  1976.         local function doExtremeSpeed(cid, target, x)
  1977.             if not isCreature(cid) then return true end
  1978.             if not isCreature(target) then
  1979.             doRemoveCondition(cid, CONDITION_INVISIBLE)
  1980.             doChangeSpeed(cid, x)
  1981.             doSendMagicEffect(getThingPositionWithDebug(cid), 211)
  1982.             return true
  1983.             end
  1984.             if getDistanceBetween(getThingPositionWithDebug(cid), getThingPositionWithDebug(target)) <= 1 then
  1985.                 doSendMagicEffect(getPosByDir(getThingPositionWithDebug(target), math.random(0, 7)), 211)
  1986.             else
  1987.                 local dir = getDirectionTo(getThingPositionWithDebug(cid), getThingPositionWithDebug(target))
  1988.                 doSendMagicEffect(getPosByDir(getThingPositionWithDebug(cid), dir), 211)
  1989.                 doTeleportThing(cid, getPosByDir(getThingPositionWithDebug(cid), dir), false)
  1990.             end
  1991.         end
  1992.  
  1993.     for a = 1, 6 do
  1994.         addEvent(doExtremeSpeed, 60 * a, cid, target, x)
  1995.     end
  1996.         addEvent(doFinishExtremeSpeed, 60 * 6, cid, target, x) 
  1997.    
  1998. elseif spell == "Zen Headbutt" then
  1999.  
  2000.     doSendMagicEffect(getThingPositionWithDebug(getMasterTarget(cid)), 136)
  2001.     doAreaCombatHealth(cid, PSYDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  2002.  
  2003. elseif spell == "Mega Kick" or spell == "Low Kick" then
  2004.  
  2005.     doAreaCombatHealth(cid, FIGHTINGDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 113)
  2006.  
  2007. elseif spell == "Double Punch" then
  2008.  
  2009.     local target = getMasterTarget(cid)
  2010.  
  2011.     local function doPunch(cid, target)
  2012.         if isCreature(cid) and isCreature(target) then
  2013.         doAreaCombatHealth(cid, FIGHTDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 112)
  2014.         end
  2015.     end
  2016.  
  2017.     addEvent(doPunch, 0, cid, target)
  2018.     addEvent(doPunch, 600, cid, target)
  2019.  
  2020. elseif spell == "Triple Punch" then
  2021.  
  2022.     local target = getMasterTarget(cid)
  2023.  
  2024.     local function doPunch(cid, target)
  2025.         if isCreature(cid) and isCreature(target) then
  2026.         doAreaCombatHealth(cid, FIGHTDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 112)
  2027.         end
  2028.     end
  2029.  
  2030.     addEvent(doPunch, 0, cid, target)
  2031.     addEvent(doPunch, 600, cid, target)
  2032.     addEvent(doPunch, 1200, cid, target)
  2033.  
  2034. elseif spell == "Double Kick" then
  2035.  
  2036.     local target = getMasterTarget(cid)
  2037.  
  2038.     local function doKick(cid, target)
  2039.         if isCreature(cid) and isCreature(target) then
  2040.         doAreaCombatHealth(cid, FIGHTDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 113)
  2041.         end
  2042.     end
  2043.  
  2044.     addEvent(doKick, 0, cid, target)
  2045.     addEvent(doKick, 600, cid, target)
  2046.  
  2047. elseif spell == "Triple Kick" then
  2048.  
  2049.     local target = getMasterTarget(cid)
  2050.  
  2051.     local function doKick(cid, target)
  2052.         if isCreature(cid) and isCreature(target) then
  2053.         doAreaCombatHealth(cid, FIGHTDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 113)
  2054.         end
  2055.     end
  2056.  
  2057.     addEvent(doKick, 0, cid, target)
  2058.     addEvent(doKick, 600, cid, target)
  2059.     addEvent(doKick, 1200, cid, target)
  2060.  
  2061. elseif spell == "Hi Jump Kick" then
  2062.  
  2063.     doSendMagicEffect(getThingPositionWithDebug(cid), 211)
  2064.     local x = getClosestFreeTile(cid, getThingPositionWithDebug(getMasterTarget(cid)))
  2065.     doTeleportThing(cid, x, false)
  2066.     doFaceCreature(cid, getThingPositionWithDebug(getMasterTarget(cid)))
  2067.     doAreaCombatHealth(cid, FIGHTDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 113)
  2068.  
  2069. elseif spell == "Focus Punch" then
  2070.  
  2071.     local function doFocusPunch(cid)
  2072.         if not isCreature(cid) then return true end
  2073.         doSendMagicEffect(getThingPositionWithDebug(cid), 144)
  2074.     end
  2075.  
  2076.     local function useFocusPunch(cid, target)
  2077.         if not isCreature(cid) or not isCreature(target) then return true end
  2078.         doAreaCombatHealth(cid, FIGHTDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 231)
  2079.     end
  2080.  
  2081.     local target = getMasterTarget(cid)
  2082.  
  2083.     for a = 1, 8 do
  2084.         addEvent(doFocusPunch, a * 160, cid)
  2085.     end
  2086.         addEvent(useFocusPunch, 160 * 8 + 1000, cid, target)
  2087.  
  2088. elseif spell == "Omnikick" then
  2089.  
  2090.     doCreatureAddCondition(cid, permanentinvisible)
  2091.     doSendMagicEffect(getThingPositionWithDebug(cid), 211)
  2092.  
  2093.     local t = {NORTHWEST, NORTHEAST, SOUTHWEST, SOUTHEAST, SOUTH, WEST, EAST, NORTH}
  2094.  
  2095.     local function doRandomDK(cid, target, t, damage)
  2096.         if not isCreature(cid) or not isCreature(target) then return true end
  2097.             local a = t[math.random(1, 8)]
  2098.             local pos = getPosByDir(getThingPositionWithDebug(target), a)
  2099.         doSendMagicEffect(pos, 211)
  2100.         doSendDistanceShoot(pos, getThingPositionWithDebug(target), 19)
  2101.     if damage then
  2102.         doTeleportThing(cid, pos, false)
  2103.         doFaceCreature(cid, getThingPositionWithDebug(target))
  2104.         doAreaCombatHealth(cid, FIGHTDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 3)
  2105.     end
  2106.     end
  2107.  
  2108.     local target = getMasterTarget(cid)
  2109.  
  2110.     local function doEndDK(cid)
  2111.         if not isCreature(cid) then return true end
  2112.         doRemoveCondition(cid, CONDITION_INVISIBLE)
  2113.         doSendMagicEffect(getThingPositionWithDebug(cid), 211)
  2114.     end
  2115.  
  2116.     for a = 1, 24 do
  2117.         if a == 8 or a == 16 or a == 24 then
  2118.             addEvent(doRandomDK, a * 75, cid, target, t, true)
  2119.         else
  2120.             addEvent(doRandomDK, a * 75, cid, target, t, false)
  2121.         end
  2122.     end
  2123.  
  2124.         addEvent(doEndDK, 24 * 75, cid)
  2125.  
  2126. elseif spell == "Crunch" then
  2127.  
  2128.     doAreaCombatHealth(cid, DARKDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 138)
  2129.  
  2130. elseif spell == "Thunder Fang" then
  2131.  
  2132.     local target = getMasterTarget(cid)
  2133.  
  2134.     doSendMagicEffect(getThingPositionWithDebug(getMasterTarget(cid)), 146)
  2135.  
  2136.         local function doBite(cid, target)
  2137.             if not isCreature(cid) or not isCreature(target) then return true end
  2138.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 48)
  2139.         end
  2140.  
  2141.     addEvent(doBite, 200, cid, target)
  2142.  
  2143. elseif spell == "Poison Fang" then
  2144.  
  2145.     local target = getMasterTarget(cid)
  2146.  
  2147.     doSendMagicEffect(getThingPositionWithDebug(getMasterTarget(cid)), 146)
  2148.  
  2149.         local function doBite(cid, target)
  2150.             if not isCreature(cid) or not isCreature(target) then return true end
  2151.         doAreaCombatHealth(cid, POISONDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 114)
  2152.         end
  2153.  
  2154.     addEvent(doBite, 200, cid, target)
  2155.  
  2156. elseif spell == "Ice Fang" then
  2157.  
  2158.     local target = getMasterTarget(cid)
  2159.  
  2160.     doSendMagicEffect(getThingPositionWithDebug(getMasterTarget(cid)), 146)
  2161.  
  2162.         local function doBite(cid, target)
  2163.             if not isCreature(cid) or not isCreature(target) then return true end
  2164.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 17)
  2165.         end
  2166.  
  2167.     addEvent(doBite, 200, cid, target)
  2168.  
  2169. elseif spell == "Aqua Jet" then
  2170.  
  2171.     for a = -7, 7 do
  2172.         for b = -6, 6 do
  2173.         local pos = getThingPositionWithDebug(cid)
  2174.         local place = {x=pos.x+a,y=pos.y+b,z=pos.z}
  2175.         doSendDistanceShoot(getThingPositionWithDebug(cid), place, 2)
  2176.         end
  2177.     end
  2178.  
  2179.     doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), grassarea, -min, -max, 255)
  2180.  
  2181.  
  2182. elseif spell == "Hyper Cut" then
  2183.  
  2184.     local target = getMasterTarget(cid)
  2185.     local apos = getThingPositionWithDebug(target)
  2186.     local bpos = getThingPositionWithDebug(cid)
  2187.  
  2188.         local function doCut(cid, pos)
  2189.             if not isCreature(cid) then doSendMagicEffect(pos, 160) return true end
  2190.         doAreaCombatHealth(cid, NORMALDAMAGE, pos, 0, -min, -max, 160)
  2191.         end
  2192.  
  2193.     local t = {
  2194.     [1] = {x = apos.x + 1, y = apos.y - 1, z = apos.z},
  2195.     [2] = {x = apos.x - 1, y = apos.y + 1, z = apos.z},
  2196.     [3] = {x = apos.x - 1, y = apos.y - 1, z = apos.z},
  2197.     [4] = {x = apos.x + 1, y = apos.y + 1, z = apos.z}}
  2198.  
  2199.     local delay = 0
  2200.  
  2201.     if (bpos.x == apos.x + 1 and bpos.y == apos.y + 1) or (bpos.x == apos.x - 1 and bpos.y == apos.y - 1) then
  2202.         doCut(cid, t[1])
  2203.         addEvent(doCut, 200, cid, apos)
  2204.         addEvent(doCut, 400, cid, t[2])
  2205.     else
  2206.         doCut(cid, t[3])
  2207.         addEvent(doCut, 200, cid, apos)
  2208.         addEvent(doCut, 400, cid, t[4])
  2209.     end    
  2210.  
  2211. elseif spell == "Psyshock" then
  2212.  
  2213.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid), true) or getCreatureLookDir(cid)
  2214.  
  2215.     if a == 0 then
  2216.         doAreaCombatHealth(cid, PSYDAMAGE, getThingPositionWithDebug(cid), tsn, -min, -max, 47)
  2217.     elseif a == 1 then
  2218.         doAreaCombatHealth(cid, PSYDAMAGE, getThingPositionWithDebug(cid), tse, -min, -max, 47)
  2219.     elseif a == 2 then
  2220.         doAreaCombatHealth(cid, PSYDAMAGE, getThingPositionWithDebug(cid), tss, -min, -max, 47)
  2221.     elseif a == 3 then
  2222.         doAreaCombatHealth(cid, PSYDAMAGE, getThingPositionWithDebug(cid), tsw, -min, -max, 47)
  2223.     end
  2224.  
  2225. elseif spell == "Psywave" then
  2226.  
  2227.     local mydir = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid), true) or getCreatureLookDir(cid)
  2228.  
  2229.     if mydir == 0 then
  2230.         doAreaCombatHealth(cid, PSYDAMAGE, getThingPositionWithDebug(cid), tsn, -min, -max, 136)
  2231.     elseif mydir == 1 then
  2232.         doAreaCombatHealth(cid, PSYDAMAGE, getThingPositionWithDebug(cid), tse, -min, -max, 136)
  2233.     elseif mydir == 2 then
  2234.         doAreaCombatHealth(cid, PSYDAMAGE, getThingPositionWithDebug(cid), tss, -min, -max, 136)
  2235.     elseif mydir == 3 then
  2236.         doAreaCombatHealth(cid, PSYDAMAGE, getThingPositionWithDebug(cid), tsw, -min, -max, 136)
  2237.     end
  2238.  
  2239. elseif spell == "Mega Drain" then
  2240.  
  2241.     local life = getCreatureHealth(getMasterTarget(cid))
  2242.  
  2243.     doAreaCombatHealth(cid, GRASSDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 14)
  2244.  
  2245.     local newlife = (life - getCreatureHealth(getMasterTarget(cid)))
  2246.  
  2247.     doSendMagicEffect(getThingPositionWithDebug(cid), 239)
  2248.     if newlife >= 1 then
  2249.     doCreatureAddHealth(cid, newlife)
  2250.     doSendAnimatedText(getThingPositionWithDebug(cid), "+"..newlife.."", 35)
  2251.     end
  2252.  
  2253. elseif spell == "Multislap" then
  2254.  
  2255.     local slapalvo = getMasterTarget(cid)
  2256.     local random = math.random(1, 4)
  2257.  
  2258.     local function doSlap(cid, target)
  2259.         if isCreature(cid) and isCreature(target) then
  2260.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 148)
  2261.         end
  2262.     end
  2263.  
  2264.     local function doSayTimes(cid, target, time, say)
  2265.         if not isCreature(cid) then return true end
  2266.         if not isCreature(target) or say then
  2267.         doSendAnimatedText(getThingPositionWithDebug(cid), ""..time.." SLAPS", 215)
  2268.         return true
  2269.         end
  2270.     end
  2271.            
  2272.  
  2273.     for a = 0, random do
  2274.         if a == random then
  2275.             addEvent(doSayTimes, a * 700, cid, slapalvo, a + 1, true)
  2276.         else
  2277.             addEvent(doSayTimes, a * 700, cid, slapalvo, a + 1, false)
  2278.         end
  2279.         addEvent(doSlap, a * 700, cid, slapalvo)
  2280.     end
  2281.  
  2282. elseif spell == "Disable" then
  2283.  
  2284.     local function doEnable(cid, what)
  2285.         if not isCreature(cid) then return true end
  2286.         local a = getPlayerStorageValue(cid, 6)
  2287.         if a ~= what then return true end
  2288.         if getPlayerStorageValue(cid, 6) <= 0 then
  2289.             doSendAnimatedText(getThingPositionWithDebug(cid), "ENABLED", COLOR_GRASS)
  2290.         return true
  2291.         end
  2292.         setPlayerStorageValue(cid, 6, a - 1)
  2293.         doSendMagicEffect(getThingPositionWithDebug(cid), 29)
  2294.         addEvent(doEnable, 500, cid, what - 1)
  2295.     end
  2296.  
  2297.  
  2298.     local target = getMasterTarget(cid)
  2299.  
  2300.     if isPlayer(target) then return true end
  2301.  
  2302.     doSendMagicEffect(getThingPositionWithDebug(target), 29)
  2303.     local time = math.random(6, 12) + math.floor(getPokemonLevel(cid) / 7.5)
  2304.  
  2305.     if getPlayerStorageValue(target, 6) > 0 then
  2306.         setPlayerStorageValue(target, 6, getPlayerStorageValue(target, 6) + time)
  2307.         local b = getPlayerStorageValue(target, 6)
  2308.         doEnable(target, b)
  2309.         return true
  2310.     end
  2311.  
  2312.     doSendAnimatedText(getThingPositionWithDebug(target), "DISABLED", 152)
  2313.     setPlayerStorageValue(target, 6, time)
  2314.     local b = getPlayerStorageValue(target, 6)
  2315.     doEnable(target, b)
  2316.    
  2317.  
  2318. elseif spell == "Reversal" then
  2319.  
  2320.     local health = math.floor(getCreatureHealth(cid) / getCreatureMaxHealth(cid) * 100)
  2321.     local increase = (100 - health) * 0.03
  2322.     local rate = 1 + increase
  2323.  
  2324.     doAreaCombatHealth(cid, FIGHTDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min * rate, -max * rate, 231)
  2325.  
  2326. elseif spell == "Demon Kicker" then
  2327.  
  2328.     local sp = getCreatureSpeed(cid)
  2329.     doChangeSpeed(cid, -sp)
  2330.     local b = getMasterTarget(cid)
  2331.     local pos = getThingPositionWithDebug(b)
  2332.  
  2333.     local function doShootKick(cid, pos, speed)
  2334.         if not isCreature(cid) then return true end
  2335.         doSendDistanceShoot(getThingPositionWithDebug(cid), pos, 19)
  2336.         if speed > 0 then
  2337.         doChangeSpeed(cid, speed)
  2338.         end
  2339.     end
  2340.  
  2341.     for a = 0, 45 do
  2342.         if a == 30 then
  2343.             addEvent(doShootKick, a * 10, cid, pos, sp)
  2344.         else
  2345.             addEvent(doShootKick, a * 10, cid, pos, -1)
  2346.         end
  2347.     end
  2348.  
  2349.  
  2350.     doAreaCombatHealth(cid, FIGHTDAMAGE, getThingPositionWithDebug(b), 0, -min, -max, 3)
  2351.  
  2352. elseif spell == "Furious Legs" then
  2353.  
  2354.     local outfit = {}
  2355.           outfit.lookType = 652
  2356.  
  2357.     if isCreature(getMasterTarget(cid)) then
  2358.         doFaceCreature(cid, getThingPositionWithDebug(getMasterTarget(cid)))
  2359.     end
  2360.  
  2361.     local b = mydir
  2362.     local p = getThingPositionWithDebug(cid)
  2363.  
  2364.     local t = {}
  2365.  
  2366.     if b == NORTH then
  2367.         for k = -1, 1 do
  2368.             local pos = {x = p.x - k, y = p.y - 1, z = p.z}
  2369.             table.insert(t, pos)
  2370.         end
  2371.     elseif b == SOUTH then
  2372.         for k = -1, 1 do
  2373.             local pos = {x = p.x - k, y = p.y + 1, z = p.z}
  2374.             table.insert(t, pos)
  2375.         end
  2376.     elseif b == EAST then
  2377.         for k = -1, 1 do
  2378.             local pos = {x = p.x + 1, y = p.y + k, z = p.z}
  2379.             table.insert(t, pos)
  2380.         end
  2381.     elseif b == WEST then
  2382.         for k = -1, 1 do
  2383.             local pos = {x = p.x - 1, y = p.y + k, z = p.z}
  2384.             table.insert(t, pos)
  2385.         end
  2386.     end
  2387.  
  2388.     local a = getCreatureSpeed(cid)
  2389.         doChangeSpeed(cid, -a)
  2390.  
  2391.     doSetCreatureOutfit(cid, outfit, -1)
  2392.  
  2393.     local function doKickPos(cid, pos)
  2394.         if not isCreature(cid) then return true end
  2395.         doAreaCombatHealth(cid, FIGHTDAMAGE, pos, 0, -min, -max, 113)
  2396.     end
  2397.  
  2398.     local function doReturn(cid, speed)
  2399.         if not isCreature(cid) then return true end
  2400.         doRemoveCondition(cid, CONDITION_OUTFIT)
  2401.         doChangeSpeed(cid, speed)
  2402.     end
  2403.  
  2404.     for times = 0, 2 do
  2405.         for kicks = 1, 3 do
  2406.             addEvent(doKickPos, kicks * 140 + times * 400, cid, t[kicks])
  2407.         end
  2408.     end
  2409.  
  2410.         addEvent(doReturn, 1480, cid, a)
  2411.  
  2412. elseif spell == "Hyper Beam" then
  2413.  
  2414.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  2415.  
  2416.     if a == 0 then
  2417.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), wg1n, -min, -max, 152)
  2418.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), wg2n, -min, -max, 158)
  2419.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), wg3n, -min, -max, 156)
  2420.     elseif a == 2 then
  2421.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), wg1s, -min, -max, 151)
  2422.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), wg2s, -min, -max, 158)
  2423.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), wg3s, -min, -max, 155)
  2424.     elseif a == 1 then
  2425.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), wg1e, -min, -max, 149)
  2426.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), wg2e, -min, -max, 157)
  2427.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), wg3e, -min, -max, 153)
  2428.     elseif a == 3 then
  2429.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), wg1w, -min, -max, 150)
  2430.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), wg2w, -min, -max, 157)
  2431.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), wg3w, -min, -max, 154)
  2432.     end
  2433.  
  2434. elseif spell == "Fire Punch" then
  2435.  
  2436.     local target = getMasterTarget(cid)
  2437.  
  2438.     doSendMagicEffect(getThingPositionWithDebug(getMasterTarget(cid)), 112)
  2439.  
  2440.         local function doPunch(cid, target)
  2441.             if not isCreature(cid) or not isCreature(target) then return true end
  2442.         doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 6)
  2443.         end
  2444.  
  2445.     addEvent(doPunch, 200, cid, target)
  2446.  
  2447. elseif spell == "Thunder Punch" then
  2448.  
  2449.     local target = getMasterTarget(cid)
  2450.  
  2451.     doSendMagicEffect(getThingPositionWithDebug(getMasterTarget(cid)), 112)
  2452.  
  2453.         local function doPunch(cid, target)
  2454.             if not isCreature(cid) or not isCreature(target) then return true end
  2455.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 48)
  2456.         end
  2457.  
  2458.     addEvent(doPunch, 200, cid, target)
  2459.  
  2460. elseif spell == "Ice Punch" then
  2461.  
  2462.     local target = getMasterTarget(cid)
  2463.  
  2464.     doSendMagicEffect(getThingPositionWithDebug(getMasterTarget(cid)), 112)
  2465.  
  2466.         local function doPunch(cid, target)
  2467.             if not isCreature(cid) or not isCreature(target) then return true end
  2468.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 17)
  2469.         end
  2470.  
  2471.     addEvent(doPunch, 200, cid, target)
  2472.  
  2473. elseif spell == "Fire Kick" then
  2474.  
  2475.     local target = getMasterTarget(cid)
  2476.  
  2477.     doSendMagicEffect(getThingPositionWithDebug(getMasterTarget(cid)), 113)
  2478.  
  2479.         local function doPunch(cid, target)
  2480.             if not isCreature(cid) or not isCreature(target) then return true end
  2481.         doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 5)
  2482.         end
  2483.  
  2484.     addEvent(doPunch, 200, cid, target)
  2485.  
  2486. elseif spell == "Thunder Kick" then
  2487.  
  2488.     local target = getMasterTarget(cid)
  2489.  
  2490.     doSendMagicEffect(getThingPositionWithDebug(getMasterTarget(cid)), 113)
  2491.  
  2492.         local function doPunch(cid, target)
  2493.             if not isCreature(cid) or not isCreature(target) then return true end
  2494.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 48)
  2495.         end
  2496.  
  2497.     addEvent(doPunch, 200, cid, target)
  2498.  
  2499. elseif spell == "Ice Kick" then
  2500.  
  2501.     local target = getMasterTarget(cid)
  2502.  
  2503.     doSendMagicEffect(getThingPositionWithDebug(getMasterTarget(cid)), 113)
  2504.  
  2505.         local function doPunch(cid, target)
  2506.             if not isCreature(cid) or not isCreature(target) then return true end
  2507.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 17)
  2508.         end
  2509.  
  2510.     addEvent(doPunch, 200, cid, target)
  2511.  
  2512. elseif spell == "Mud Slap" or spell == "Mud-slap" then
  2513.  
  2514.     local target = getMasterTarget(cid)
  2515.  
  2516.     local function jogarLama(cid, target, damage)
  2517.         if not isCreature(target) then return true end
  2518.         if not isCreature(cid) then return true end
  2519.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 38)
  2520.         if damage then
  2521.         doAreaCombatHealth(cid, GROUNDDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 3)
  2522.         end
  2523.     end
  2524.  
  2525.     for a = 1, 23 do
  2526.         if a == 4 or a == 15 or a == 22 then
  2527.             addEvent(jogarLama, a * 32, cid, target, true)
  2528.         else
  2529.             addEvent(jogarLama, a * 32, cid, target, false)
  2530.         end
  2531.     end
  2532.  
  2533. elseif spell == "Fire Mark" then
  2534.  
  2535.     local target = getMasterTarget(cid)
  2536.  
  2537.     local function markFire(cid, target, damage)
  2538.         if not isCreature(target) then return true end
  2539.         if not isCreature(cid) then return true end
  2540.         doSendMagicEffect(getThingPositionWithDebug(target), 219)
  2541.         if damage then
  2542.         doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 35)
  2543.         end
  2544.     end
  2545.  
  2546.     for a = 1, 23 do
  2547.         if a == 4 or a == 15 or a == 22 then
  2548.             addEvent(markFire, a * 32, cid, target, true)
  2549.         else
  2550.             addEvent(markFire, a * 32, cid, target, false)
  2551.         end
  2552.     end
  2553.  
  2554. elseif spell == "Horn Drill" then
  2555.  
  2556.     local target = getMasterTarget(cid)
  2557.     local a = getThingPositionWithDebug(cid)
  2558.     local b = getThingPositionWithDebug(target)
  2559.     local c = getDirectionTo(a, b)
  2560.  
  2561.     for distance = 1, 3 do
  2562.         b = getPosByDir(b, c)
  2563.     end
  2564.  
  2565.     doSendDistanceShoot(a, b, 25)
  2566.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 3)
  2567.  
  2568. elseif spell == "Giga Impact" then
  2569.  
  2570.     local target = getMasterTarget(cid)
  2571.     local a = getThingPositionWithDebug(cid)
  2572.     local b = getThingPositionWithDebug(target)
  2573.     local c = getDirectionTo(a, b)
  2574.  
  2575.     doCreatureAddCondition(cid, permanentinvisible)
  2576.     doTeleportThing(cid, b)
  2577.  
  2578.     local function doAppear(cid)
  2579.         if not isCreature(cid) then return true end
  2580.         doRemoveCondition(cid, CONDITION_INVISIBLE)
  2581.     end
  2582.  
  2583.     doSendDistanceShoot(a, b, 10)
  2584.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 3)
  2585.     addEvent(doAppear, 250, cid)
  2586.  
  2587. elseif spell == "Dig" then
  2588.  
  2589.     doCreatureAddCondition(cid, permanentinvisible)
  2590.     doSendMagicEffect(getThingPositionWithDebug(cid), 3)
  2591.  
  2592.     local function backtoground(cid)
  2593.         if not isCreature(cid) then return true end
  2594.         doRemoveCondition(cid, CONDITION_INVISIBLE)
  2595.         local pos = getThingPositionWithDebug(cid)
  2596.         doSendMagicEffect(pos, 118)
  2597.         doSendMagicEffect(pos, 127)
  2598.         doAreaCombatHealth(cid, GROUNDDAMAGE, getThingPositionWithDebug(cid), splash, -min, -max, 255)
  2599.     return true
  2600.     end
  2601.  
  2602.     addEvent(backtoground, 6 * 450 + 150, cid)
  2603.  
  2604. elseif spell == "X-Scissor" then
  2605.  
  2606.     local a = getThingPositionWithDebug(target)
  2607.     a.x = a.x + 1
  2608.     a.y = a.y + 1
  2609.  
  2610.     for b = 1, 3 do
  2611.         addEvent(doSendMagicEffect, b * 70, a, 16)
  2612.     end
  2613.  
  2614.     doAreaCombatHealth(cid, BUGDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 255)
  2615.  
  2616. elseif spell == "Iron Tail" then
  2617.  
  2618.     local function rebackSpd(cid, sss)
  2619.         if not isCreature(cid) then return true end
  2620.         doChangeSpeed(cid, sss)
  2621.         setPlayerStorageValue(cid, 446, -1)
  2622.     end
  2623.  
  2624.     local x = getCreatureSpeed(cid)
  2625.     doFaceOpposite(cid)
  2626.     doChangeSpeed(cid, -x)
  2627.     addEvent(rebackSpd, 400, cid, x)
  2628.     setPlayerStorageValue(cid, 446, 1)
  2629.     doAreaCombatHealth(cid, STEELDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 160)
  2630.  
  2631. elseif spell == "Dragon Tail" then
  2632.  
  2633.     local function rebackSpd(cid, sss)
  2634.         if not isCreature(cid) then return true end
  2635.         doChangeSpeed(cid, sss)
  2636.         setPlayerStorageValue(cid, 446, -1)
  2637.     end
  2638.  
  2639.     local x = getCreatureSpeed(cid)
  2640.     doFaceOpposite(cid)
  2641.     doChangeSpeed(cid, -x)
  2642.     addEvent(rebackSpd, 400, cid, x)
  2643.     setPlayerStorageValue(cid, 446, 1)
  2644.     doAreaCombatHealth(cid, DRAGONDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 136)
  2645.  
  2646. elseif spell == "Swift" then
  2647.  
  2648.     local target = getMasterTarget(cid)
  2649.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 32)
  2650.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 111)
  2651.  
  2652. elseif spell == "Crabhammer" then
  2653.  
  2654.     local target = getMasterTarget(cid)
  2655.     doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 225)
  2656.  
  2657. elseif spell == "Dream Eater" then
  2658.  
  2659.     local target = getMasterTarget(cid)
  2660.  
  2661.     if not isSleeping(target) then
  2662.         doSendMagicEffect(getThingPositionWithDebug(target), 3)
  2663.         doSendAnimatedText(getThingPositionWithDebug(target), "FAIL", 155)
  2664.     return true
  2665.     end
  2666.  
  2667.     local function nightmare(target)
  2668.         if not isCreature(target) then return true end
  2669.         doSendMagicEffect(getThingPositionWithDebug(target), 139)
  2670.     end
  2671.  
  2672.     local a = getCreatureHealth(target)
  2673.    
  2674.     for j = 0, 1 do
  2675.         addEvent(nightmare, j * 150, target)
  2676.     end
  2677.  
  2678.     doAreaCombatHealth(cid, PSYCHICDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 138)
  2679.     local b = getCreatureHealth(target)
  2680.     local c = a - b
  2681.     doCreatureAddHealth(cid, math.ceil(c / 2))
  2682.     doSendMagicEffect(getThingPositionWithDebug(cid), 12)
  2683.     doSendAnimatedText(getThingPositionWithDebug(cid), "+"..math.ceil(c/2).."", 155)
  2684.  
  2685. elseif spell == "Stomp" then
  2686.  
  2687.     local target = getMasterTarget(cid)
  2688.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 231)
  2689.  
  2690. elseif spell == "Giga Drain" then
  2691.  
  2692.     local life = getCreatureHealth(getMasterTarget(cid))
  2693.     local target = getMasterTarget(cid)
  2694.  
  2695.     doAreaCombatHealth(cid, GRASSDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 14)
  2696.  
  2697.     local newlife = (life - getCreatureHealth(getMasterTarget(cid)))
  2698.  
  2699.     local function doEffect(cid, target)
  2700.         if not isCreature(cid) or not isCreature(target) then return true end
  2701.         local t = {37, 30}
  2702.         doSendDistanceShoot(getThingPositionWithDebug(target), getThingPositionWithDebug(cid), t[math.random(1, 2)])
  2703.     end
  2704.  
  2705.     for a = 1, 7 do
  2706.         addEvent(doEffect, a * 65, cid, target)
  2707.     end
  2708.  
  2709.     doSendMagicEffect(getThingPositionWithDebug(cid), 239)
  2710.     if newlife >= 1 then
  2711.     doCreatureAddHealth(cid, newlife)
  2712.     doSendAnimatedText(getThingPositionWithDebug(cid), "+"..newlife.."", 35)
  2713.     end
  2714.  
  2715. elseif spell == "Nature Ball" then
  2716.  
  2717.     local target = getMasterTarget(cid)
  2718.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target),  1)
  2719.     doAreaCombatHealthAtDistance(cid, GRASSDAMAGE, getThingPositionWithDebug(target), splash, -min, -max, 245)
  2720.  
  2721. elseif spell == "Shockwave" or spell == "Shock Wave" then
  2722.  
  2723.     local posicao = getThingPositionWithDebug(cid)
  2724.        
  2725.     local function doShockWave(cid, pos, varx, vary, effect)
  2726.     if isCreature(cid) and isSightClear(posicao, pos, false) then
  2727.     doAreaCombatHealth(cid, GROUNDDAMAGE, pos, whirl3, -min, -max, 255)
  2728.     doSendMagicEffect({x = pos.x + varx, y = pos.y + vary, z = pos.z}, effect)
  2729.     end
  2730.     end
  2731.  
  2732.     local effect = 255
  2733.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  2734.  
  2735.     if a == 0 then
  2736.         effect = 126
  2737.         for sw = 0, 5 do
  2738.             addEvent(doShockWave, 325 * sw, cid, {x = posicao.x, y = posicao.y - (sw + 1), z = posicao.z}, 1, 1, effect)
  2739.         end
  2740.     elseif a == 2 then
  2741.         effect = 125
  2742.         for sw = 0, 5 do
  2743.             addEvent(doShockWave, 325 * sw, cid, {x = posicao.x, y = posicao.y + (sw + 1), z = posicao.z}, 1, 1, effect)
  2744.         end
  2745.     elseif a == 1 then
  2746.         effect = 124
  2747.         for sw = 0, 5 do
  2748.             addEvent(doShockWave, 325 * sw, cid, {x = posicao.x + (sw + 1), y = posicao.y, z = posicao.z}, 1, 1, effect)
  2749.         end
  2750.     elseif a == 3 then
  2751.         effect = 123
  2752.         for sw = 0, 5 do
  2753.             addEvent(doShockWave, 325 * sw, cid, {x = posicao.x - (sw + 1), y = posicao.y, z = posicao.z}, 1, 1, effect)
  2754.         end
  2755.     end
  2756.  
  2757. elseif spell == "Sandstorm" then
  2758.  
  2759.     local t = {}
  2760.     local m = getThingPositionWithDebug(cid)
  2761.         for x = -5, 5 do
  2762.             for y = -5, 5 do
  2763.             local pos = {x = m.x + x, y = m.y + y, z = m.z, stackpos = 0}
  2764.             table.insert(t, pos)
  2765.             end
  2766.         end
  2767.  
  2768.     local function doGroundDamage(cid, pos)
  2769.         if not isCreature(cid) then return true end
  2770.     doAreaCombatHealth(cid, GROUNDDAMAGE, pos, 0, -min, -max, 255)
  2771.         local mpos = pos
  2772.         mpos.x = mpos.x + 1
  2773.         doSendMagicEffect(mpos, 85)
  2774.     end
  2775.  
  2776.     local function doFallGround(cid, pos)
  2777.         if not isCreature(cid) then return true end
  2778.         local apos = pos
  2779.         local frompos = {x=apos.x-5,y=apos.y-4,z=apos.z}
  2780.         doSendDistanceShoot(frompos, pos, 22)
  2781.         addEvent(doGroundDamage, 385, cid, pos)
  2782.     end
  2783.  
  2784.     for a = 1, #t do
  2785.         if #t >= 1 then
  2786.         local random = math.random(1, #t)
  2787.         addEvent(doFallGround, a * 24, cid, t[random])
  2788.         t = doRemoveElementFromTable(t, t[random])
  2789.         end
  2790.     end
  2791.  
  2792.     for randomic = 1, 128 do
  2793.         local randompos = {x=m.x+math.random(-4,4),y=m.y+math.random(-4,4),z=m.z}
  2794.         addEvent(doFallGround, randomic * math.random(25, 30), cid, randompos)
  2795.     end
  2796.  
  2797. elseif spell == "Windstorm" then
  2798.  
  2799.     local t = {}
  2800.     local m = getThingPositionWithDebug(cid)
  2801.         for x = -5, 5 do
  2802.             for y = -5, 5 do
  2803.             local pos = {x = m.x + x, y = m.y + y, z = m.z}
  2804.             table.insert(t, pos)
  2805.             end
  2806.         end
  2807.  
  2808.     local function doWindStorm(cid, pos)
  2809.         if not isCreature(cid) then return true end
  2810.         doAreaCombatHealth(cid, FLYDAMAGE, pos, 0, -min, -max, 42)
  2811.         doSendMagicEffect(pos, CONST_ME_POFF)
  2812.         doSendDistanceShoot(pos, {x=pos.x+math.random(-2,2),y=pos.y+math.random(-2,2),z=pos.z}, 36)
  2813.         doSendDistanceShoot(pos, {x=pos.x+math.random(-2,2),y=pos.y+math.random(-2,2),z=pos.z}, 36)
  2814.         doSendDistanceShoot(pos, {x=pos.x+math.random(-2,2),y=pos.y+math.random(-2,2),z=pos.z}, 36)
  2815.     end
  2816.  
  2817.     for b = 1, 3 do
  2818.     for a = 1, #t do
  2819.         if #t >= 1 then
  2820.         local random = math.random(1, #t)
  2821.         addEvent(doWindStorm, 25 * a, cid, t[random])
  2822.         t = doRemoveElementFromTable(t, t[random])
  2823.         end
  2824.     end
  2825.     end
  2826.  
  2827. elseif spell == "Air Slash" then
  2828.  
  2829.     local target = getMasterTarget(cid)
  2830.  
  2831.     local pos1 = getThingPositionWithDebug(target)
  2832.         pos1.x = pos1.x - 2
  2833.         pos1.y = pos1.y - 2
  2834.     local pos2 = getThingPositionWithDebug(target)
  2835.         pos2.x = pos2.x + 2
  2836.         pos2.y = pos2.y + 2
  2837.  
  2838.     for a = 1, 7 do
  2839.         addEvent(doSendDistanceShoot, a * 50, pos1, pos2, 36)
  2840.     end
  2841.         doAreaCombatHealth(cid, FLYDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 42)
  2842.  
  2843.  
  2844. elseif spell == "Fury Swipes" then
  2845.  
  2846.     local chance = {2, 3, 4, 5, 2, 3, 3, 2}
  2847.  
  2848.     local random = chance[math.random(1, #chance)]
  2849.  
  2850.     local function doFurySwipe(cid, target, round, limit)
  2851.         local ret = "S"
  2852.         if not isCreature(cid) then return true end
  2853.         if round <= 1 then ret = "" end
  2854.         if not isCreature(target) or getCreatureHealth(target) <= 0 then
  2855.         doSendAnimatedText(getThingPositionWithDebug(cid), round.." HIT"..ret.."", 215)
  2856.         return true end
  2857.         if round >= limit then doSendAnimatedText(getThingPositionWithDebug(cid), round.." HIT"..ret.."", 215) return true end
  2858.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 142)
  2859.         addEvent(doFurySwipe, 450, cid, target, round + 1, limit)
  2860.     end
  2861.  
  2862.     local target = getMasterTarget(cid)
  2863.  
  2864.     doFurySwipe(cid, target, 0, random)    
  2865.  
  2866. elseif spell == "Wind Vortex" then
  2867.  
  2868.     local pos = getThingPositionWithDebug(cid)
  2869.     local mainpos = getThingPositionWithDebug(cid)
  2870.  
  2871.     local a = {
  2872.     [1] = {x = pos.x, y = pos.y - 4, z = pos.z},
  2873.     [2] = {x = pos.x - 4, y = pos.y, z = pos.z},
  2874.     [3] = {x = pos.x, y = pos.y + 4, z = pos.z},
  2875.     [4] = {x = pos.x + 4, y = pos.y, z = pos.z},
  2876.     [5] = {x = pos.x, y = pos.y - 4, z = pos.z}}
  2877.     local b = {
  2878.     [1] = {x = pos.x - 3, y = pos.y, z = pos.z},
  2879.     [2] = {x = pos.x, y = pos.y + 3, z = pos.z},
  2880.     [3] = {x = pos.x + 3, y = pos.y, z = pos.z},
  2881.     [4] = {x = pos.x, y = pos.y + 3, z = pos.z},
  2882.     [5] = {x = pos.x - 3, y = pos.y, z = pos.z}}
  2883.     local c = {
  2884.     [1] = {x = pos.x, y = pos.y + 2, z = pos.z},
  2885.     [2] = {x = pos.x + 2, y = pos.y, z = pos.z},
  2886.     [3] = {x = pos.x, y = pos.y - 2, z = pos.z},
  2887.     [4] = {x = pos.x - 2, y = pos.y, z = pos.z},
  2888.     [5] = {x = pos.x, y = pos.y + 2, z = pos.z}}
  2889.  
  2890.     local function doWindVortex(cid, pos1, pos2)
  2891.         if not isCreature(cid) then return true end
  2892.         doSendDistanceShoot(pos1, pos2, 36)
  2893.         local effects = {CONST_ME_POFF, 3, 148}
  2894.         --doSendMagicEffect(pos1, effects[math.random(1, 3)])
  2895.     end
  2896.  
  2897.     for aaa = 0, 7 do
  2898.         for aa = 1, 4 do
  2899.             addEvent(doWindVortex, aa * 50 + aaa * 225, cid, a[aa], a[aa+1])
  2900.         end
  2901.     end
  2902.  
  2903.     for bbb = 0, 7 do
  2904.         for bb = 1, 4 do
  2905.             addEvent(doWindVortex, bb * 50 + bbb * 225, cid, b[bb], b[bb+1])
  2906.         end
  2907.     end
  2908.  
  2909.     for ccc = 0, 7 do
  2910.         for cc = 1, 4 do
  2911.             addEvent(doWindVortex, cc * 50 + ccc * 225, cid, c[cc], c[cc+1])
  2912.         end
  2913.     end
  2914.  
  2915.  
  2916.     local function doWindVortexDamage(cid, mainpos)
  2917.         if not isCreature(cid) then return true end
  2918.     doAreaCombatHealth(cid, FLYDAMAGE, mainpos, wvortex, -min, -max, 255)
  2919.     end
  2920.  
  2921.     for dmg = 1, 13 do
  2922.         addEvent(doWindVortexDamage, dmg * 150, cid, mainpos)
  2923.     end
  2924.  
  2925. elseif spell == "Fire Spin" then
  2926.  
  2927.     local pos = getThingPositionWithDebug(cid)
  2928.     local mainpos = getThingPositionWithDebug(cid)
  2929.  
  2930.     local a = {
  2931.     [1] = {x = pos.x, y = pos.y - 4, z = pos.z},
  2932.     [2] = {x = pos.x - 4, y = pos.y, z = pos.z},
  2933.     [3] = {x = pos.x, y = pos.y + 4, z = pos.z},
  2934.     [4] = {x = pos.x + 4, y = pos.y, z = pos.z},
  2935.     [5] = {x = pos.x, y = pos.y - 4, z = pos.z}}
  2936.     local b = {
  2937.     [1] = {x = pos.x - 3, y = pos.y, z = pos.z},
  2938.     [2] = {x = pos.x, y = pos.y + 3, z = pos.z},
  2939.     [3] = {x = pos.x + 3, y = pos.y, z = pos.z},
  2940.     [4] = {x = pos.x, y = pos.y + 3, z = pos.z},
  2941.     [5] = {x = pos.x - 3, y = pos.y, z = pos.z}}
  2942.     local c = {
  2943.     [1] = {x = pos.x, y = pos.y + 2, z = pos.z},
  2944.     [2] = {x = pos.x + 2, y = pos.y, z = pos.z},
  2945.     [3] = {x = pos.x, y = pos.y - 2, z = pos.z},
  2946.     [4] = {x = pos.x - 2, y = pos.y, z = pos.z},
  2947.     [5] = {x = pos.x, y = pos.y + 2, z = pos.z}}
  2948.  
  2949.     local function doWindVortex(cid, pos1, pos2)
  2950.         if not isCreature(cid) then return true end
  2951.         doSendDistanceShoot(pos1, pos2, 3)
  2952.         local effects = {CONST_ME_POFF, 3, 44}
  2953.         --doSendMagicEffect(pos1, effects[math.random(1, 3)])
  2954.     end
  2955.  
  2956.     for aaa = 0, 7 do
  2957.         for aa = 1, 4 do
  2958.             addEvent(doWindVortex, aa * 50 + aaa * 225, cid, a[aa], a[aa+1])
  2959.         end
  2960.     end
  2961.  
  2962.     for bbb = 0, 7 do
  2963.         for bb = 1, 4 do
  2964.             addEvent(doWindVortex, bb * 50 + bbb * 225, cid, b[bb], b[bb+1])
  2965.         end
  2966.     end
  2967.  
  2968.     for ccc = 0, 7 do
  2969.         for cc = 1, 4 do
  2970.             addEvent(doWindVortex, cc * 50 + ccc * 225, cid, c[cc], c[cc+1])
  2971.         end
  2972.     end
  2973.  
  2974.  
  2975.     local function doWindVortexDamage(cid, mainpos)
  2976.         if not isCreature(cid) then return true end
  2977.     doAreaCombatHealth(cid, FIREDAMAGE, mainpos, wvortex, -min, -max, 255)
  2978.     end
  2979.  
  2980.     for dmg = 1, 13 do
  2981.         addEvent(doWindVortexDamage, dmg * 150, cid, mainpos)
  2982.     end
  2983.  
  2984. elseif spell == "Wind Blow" then
  2985.  
  2986.     doAreaCombatHealth(cid, FLYDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 42)
  2987.  
  2988. elseif spell == "Hurricane" then
  2989.  
  2990.     local a = {
  2991.     [1] = NORTH,
  2992.     [2] = NORTHWEST,
  2993.     [3] = WEST,
  2994.     [4] = SOUTHWEST,
  2995.     [5] = SOUTH,
  2996.     [6] = SOUTHEAST,
  2997.     [7] = EAST,
  2998.     [8] = NORTHEAST}
  2999.  
  3000.     local pos = getThingPositionWithDebug(cid)
  3001.  
  3002.  
  3003.     local function doHurricane(cid, dir, extended)
  3004.         if not isCreature(cid) then return true end
  3005.         local pos = {}
  3006.         if extended then
  3007.             pos = getThingPositionWithDebug(cid)
  3008.         local b = {
  3009.     [1] = {x = pos.x, y = pos.y + 2, z = pos.z},
  3010.     [2] = {x = pos.x - 1, y = pos.y + 2, z = pos.z},
  3011.     [3] = {x = pos.x - 2, y = pos.y + 2, z = pos.z},
  3012.     [4] = {x = pos.x - 2, y = pos.y + 1, z = pos.z},
  3013.     [5] = {x = pos.x - 2, y = pos.y, z = pos.z},
  3014.     [6] = {x = pos.x - 2, y = pos.y - 1, z = pos.z},
  3015.     [7] = {x = pos.x - 2, y = pos.y - 2, z = pos.z},
  3016.     [8] = {x = pos.x - 1, y = pos.y - 2, z = pos.z},
  3017.     [9] = {x = pos.x, y = pos.y - 2, z = pos.z},
  3018.     [10] = {x = pos.x + 1, y = pos.y - 2, z = pos.z},
  3019.     [11] = {x = pos.x + 2, y = pos.y - 2, z = pos.z},
  3020.     [12] = {x = pos.x + 2, y = pos.y - 1, z = pos.z},
  3021.     [13] = {x = pos.x + 2, y = pos.y, z = pos.z},
  3022.     [14] = {x = pos.x + 2, y = pos.y + 1, z = pos.z},
  3023.     [15] = {x = pos.x + 2, y = pos.y + 2, z = pos.z},
  3024.     [16] = {x = pos.x + 1, y = pos.y + 2, z = pos.z},}
  3025.             pos = b[dir]
  3026.         else
  3027.             pos = getPosByDir(getThingPositionWithDebug(cid), dir)
  3028.         end
  3029.     doAreaCombatHealth(cid, FLYDAMAGE, pos, 0, -min, -max, 42)
  3030.     end
  3031.  
  3032.     for r = 0, 5 do
  3033.         for t = 1, 8 do
  3034.             addEvent(doHurricane, t * 150 + r * 1205, cid, a[t], false)
  3035.         end
  3036.     end
  3037.  
  3038.     for r = 0, 2 do
  3039.         for k = 1, 16 do
  3040.             addEvent(doHurricane, k * 130 + r * 2200, cid, k, true)
  3041.         end
  3042.     end
  3043.  
  3044. elseif spell == "Whirlpool" then
  3045.  
  3046.     local a = {
  3047.     [1] = NORTH,
  3048.     [2] = NORTHWEST,
  3049.     [3] = WEST,
  3050.     [4] = SOUTHWEST,
  3051.     [5] = SOUTH,
  3052.     [6] = SOUTHEAST,
  3053.     [7] = EAST,
  3054.     [8] = NORTHEAST}
  3055.  
  3056.     local pos = getThingPositionWithDebug(cid)
  3057.  
  3058.  
  3059.     local function doHurricane(cid, dir, extended)
  3060.         if not isCreature(cid) then return true end
  3061.         local pos = {}
  3062.         if extended then
  3063.             pos = getThingPositionWithDebug(cid)
  3064.         local b = {
  3065.     [1] = {x = pos.x, y = pos.y + 2, z = pos.z},
  3066.     [2] = {x = pos.x - 1, y = pos.y + 2, z = pos.z},
  3067.     [3] = {x = pos.x - 2, y = pos.y + 2, z = pos.z},
  3068.     [4] = {x = pos.x - 2, y = pos.y + 1, z = pos.z},
  3069.     [5] = {x = pos.x - 2, y = pos.y, z = pos.z},
  3070.     [6] = {x = pos.x - 2, y = pos.y - 1, z = pos.z},
  3071.     [7] = {x = pos.x - 2, y = pos.y - 2, z = pos.z},
  3072.     [8] = {x = pos.x - 1, y = pos.y - 2, z = pos.z},
  3073.     [9] = {x = pos.x, y = pos.y - 2, z = pos.z},
  3074.     [10] = {x = pos.x + 1, y = pos.y - 2, z = pos.z},
  3075.     [11] = {x = pos.x + 2, y = pos.y - 2, z = pos.z},
  3076.     [12] = {x = pos.x + 2, y = pos.y - 1, z = pos.z},
  3077.     [13] = {x = pos.x + 2, y = pos.y, z = pos.z},
  3078.     [14] = {x = pos.x + 2, y = pos.y + 1, z = pos.z},
  3079.     [15] = {x = pos.x + 2, y = pos.y + 2, z = pos.z},
  3080.     [16] = {x = pos.x + 1, y = pos.y + 2, z = pos.z},}
  3081.             pos = b[dir]
  3082.         else
  3083.             pos = getPosByDir(getThingPositionWithDebug(cid), dir)
  3084.         end
  3085.     doAreaCombatHealth(cid, WATERDAMAGE, pos, 0, -min, -max, 53)
  3086.     end
  3087.  
  3088.     for r = 0, 5 do
  3089.         for t = 1, 8 do
  3090.             addEvent(doHurricane, t * 150 + r * 1205, cid, a[t], false)
  3091.         end
  3092.     end
  3093.  
  3094.     for r = 0, 2 do
  3095.         for k = 1, 16 do
  3096.             addEvent(doHurricane, k * 130 + r * 2200, cid, k, true)
  3097.         end
  3098.     end
  3099.  
  3100. elseif spell == "Aeroblast" then
  3101.  
  3102.     local pos = getThingPositionWithDebug(cid)
  3103.     local cidpos = getThingPositionWithDebug(cid)
  3104.     local tpos = pos
  3105.     local t = {}
  3106.    
  3107.  
  3108.     for a = 1, 6 do
  3109.         tpos = getPosByDir(tpos, mydir)
  3110.         table.insert(t, tpos)
  3111.         doAreaCombatHealth(cid, FLYDAMAGE, tpos, 0, -min, -max, 255)
  3112.     end
  3113.  
  3114.     local function doAeroEffect(cid, cidpos, pos, varxa, varxb, varya, varyb)
  3115.         if not isCreature(cid) then return true end
  3116.         doSendDistanceShoot(cidpos, pos, 36)
  3117.             if math.random(1, 7) <= 3 then
  3118.                 doSendDistanceShoot(cidpos, {x=cidpos.x+math.random(varxa,varxb),y=cidpos.y+math.random(varya,varyb),z=cidpos.z}, 36)
  3119.             end
  3120.     end
  3121.  
  3122.     local varxa = 0
  3123.     local varxb = 0
  3124.     local varya = 0
  3125.     local varyb = 0
  3126.  
  3127.     local function doHyperBeamEffect(cid, a, mpos)
  3128.         if not isCreature(cid) then return true end
  3129.         local pos = mpos
  3130.         local beam = {
  3131.         [NORTH] = {effect = {152, 158, 158, 158, 156}, xvar = 0, yvar = -1},
  3132.         [SOUTH] = {effect = {151, 158, 158, 158, 155}, xvar = 0, yvar = 1},
  3133.         [EAST] = {effect = {149, 157, 157, 157, 153}, xvar = 1, yvar = 0},
  3134.         [WEST] = {effect = {150, 157, 157, 157, 154}, xvar = -1, yvar = 0}}
  3135.         for bb = 1, 5 do
  3136.             local wx = beam[a].xvar
  3137.             local wy = beam[a].yvar
  3138.             local ef = beam[a].effect[bb]
  3139.             local topos = {x=pos.x+(wx*bb),y=pos.y+(wy*bb),z=pos.z}
  3140.             doSendMagicEffect(topos, ef)
  3141.         end
  3142.     end
  3143.  
  3144.     for a = 0, 2 do
  3145.         addEvent(doHyperBeamEffect, a * 300, cid, mydir, cidpos)
  3146.     end
  3147.  
  3148.     if mydir == 0 then
  3149.         varxa = -2
  3150.         varxb = 2
  3151.         varya = 1
  3152.         varyb = 3
  3153.     elseif mydir == 1 then
  3154.         varxa = -3
  3155.         varxb = -1
  3156.         varya = -2
  3157.         varyb = 2
  3158.     elseif mydir == 2 then
  3159.         varxa = -2
  3160.         varxb = 2
  3161.         varya = -3
  3162.         varyb = -1
  3163.     elseif mydir == 3 then
  3164.         varxa = 1
  3165.         varxb = 3
  3166.         varya = -2
  3167.         varyb = 2
  3168.     end
  3169.  
  3170.     for etc = 1, 25 do
  3171.         for b = 1, 5 do
  3172.             if etc <= 24 then
  3173.                 addEvent(doAeroEffect, b * 25 + etc * 50, cid, cidpos, t[b], varxa, varxb, varya, varyb)
  3174.             else
  3175.                 addEvent(doAeroEffect, b * 25 + etc * 50, cid, cidpos, t[b], varxa, varxb, varya, varyb)
  3176.             end
  3177.         end
  3178.     end
  3179.  
  3180.  
  3181. elseif spell == "Falling Rocks" then
  3182.  
  3183.     local t = {}
  3184.     local m = getThingPositionWithDebug(cid)
  3185.         for x = -4, 4 do
  3186.             for y = -4, 4 do
  3187.             local pos = {x = m.x + x, y = m.y + y, z = m.z, stackpos = 0}
  3188.             table.insert(t, pos)
  3189.             end
  3190.         end
  3191.  
  3192.     local function doCrushRock(cid, pos)
  3193.         if not isCreature(cid) then return true end
  3194.     local effect = 44
  3195.         pos.stackpos = 0
  3196.         if getTileThingByPos(pos).itemid >= 4820 and getTileThingByPos(pos).itemid <= 4825 then
  3197.         effect = 1
  3198.         end
  3199.     doAreaCombatHealth(cid, ROCKDAMAGE, pos, 0, -min, -max, effect)
  3200.     end
  3201.  
  3202.     local function doFallRock(cid, pos)
  3203.         if not isCreature(cid) then return true end
  3204.         local apos = pos
  3205.         local frompos = {x=apos.x-4,y=apos.y-3,z=apos.z}
  3206.         doSendDistanceShoot(frompos, pos, 11)
  3207.         addEvent(doCrushRock, 385, cid, pos)
  3208.     end
  3209.  
  3210.     for a = 1, #t do
  3211.         if #t >= 1 then
  3212.         local random = math.random(1, #t)
  3213.         addEvent(doFallRock, a * 24, cid, t[random])
  3214.         t = doRemoveElementFromTable(t, t[random])
  3215.         end
  3216.     end
  3217.  
  3218.     for randomic = 1, 128 do
  3219.         local randompos = {x=m.x+math.random(-3,3),y=m.y+math.random(-3,3),z=m.z}
  3220.         addEvent(doFallRock, randomic * math.random(25, 30), cid, randompos)
  3221.     end
  3222.  
  3223. elseif spell == "Blizzard" then
  3224.  
  3225.     local t = {}
  3226.     local m = getThingPositionWithDebug(cid)
  3227.         for x = -5, 5 do
  3228.             for y = -4, 4 do
  3229.             local pos = {x = m.x + x, y = m.y + y, z = m.z, stackpos = 0}
  3230.             table.insert(t, pos)
  3231.             end
  3232.         end
  3233.  
  3234.     local function doCrushIce(cid, pos)
  3235.         if not isCreature(cid) then return true end
  3236.     doAreaCombatHealth(cid, ICEDAMAGE, pos, 0, -min, -max, 230)
  3237.     end
  3238.  
  3239.     local function doFallIce(cid, pos)
  3240.         if not isCreature(cid) then return true end
  3241.         local apos = pos
  3242.         local frompos = {x=apos.x-5,y=apos.y-4,z=apos.z}
  3243.         doSendDistanceShoot(frompos, pos, 28)
  3244.         addEvent(doCrushIce, 385, cid, pos)
  3245.     end
  3246.  
  3247.     for a = 1, #t do
  3248.         if #t >= 1 then
  3249.         local random = math.random(1, #t)
  3250.         addEvent(doFallIce, a * 24, cid, t[random])
  3251.         t = doRemoveElementFromTable(t, t[random])
  3252.         end
  3253.     end
  3254.  
  3255.     for randomic = 1, 128 do
  3256.         local randompos = {x=m.x+math.random(-5,5),y=m.y+math.random(-4,4),z=m.z}
  3257.         addEvent(doFallIce, randomic * math.random(25, 30), cid, randompos)
  3258.     end
  3259.  
  3260. elseif spell == "Air Cutter" then
  3261.  
  3262. local damagearea = {}
  3263. local effectpos = getThingPositionWithDebug(cid)
  3264. local effect = 255
  3265.  
  3266.     if mydir == 0 then
  3267.         effect = 128
  3268.         effectpos.x = effectpos.x + 1
  3269.         effectpos.y = effectpos.y - 1
  3270.         damagearea = acsn
  3271.     elseif mydir == 1 then
  3272.         effectpos.x = effectpos.x + 1
  3273.         effectpos.y = effectpos.y + 1
  3274.         effect = 129
  3275.         damagearea = acsn
  3276.     elseif mydir == 2 then
  3277.         effectpos.x = effectpos.x + 1
  3278.         effectpos.y = effectpos.y + 1
  3279.         effect = 131
  3280.         damagearea = acsn
  3281.     elseif mydir == 3 then
  3282.         effectpos.x = effectpos.x - 1
  3283.         effectpos.y = effectpos.y + 1
  3284.         effect = 130
  3285.         damagearea = acsn
  3286.     end
  3287.  
  3288.     local this = getThingPositionWithDebug(cid)
  3289.     this = getPosByDir(this, mydir)
  3290.  
  3291.     local function doCutAir()
  3292.         if not isCreature(cid) then return true end
  3293.     doSendMagicEffect(effectpos, effect)
  3294.     doAreaCombatHealth(cid, FLYDAMAGE, this, damagearea, -min, -max, 42)
  3295.     this = getPosByDir(this, mydir)
  3296.     effectpos = getPosByDir(effectpos, mydir)
  3297.     end
  3298.  
  3299.     for range = 0, 2 do
  3300.         addEvent(doCutAir, range * 350)
  3301.     end
  3302.  
  3303. elseif spell == "Silver Wind" then
  3304.  
  3305. local damagearea = {}
  3306. local effectpos = getThingPositionWithDebug(cid)
  3307. local effect = 255
  3308.  
  3309.     if mydir == 0 then
  3310.         effect = 128
  3311.         effectpos.x = effectpos.x + 1
  3312.         effectpos.y = effectpos.y - 1
  3313.         damagearea = acsn
  3314.     elseif mydir == 1 then
  3315.         effectpos.x = effectpos.x + 1
  3316.         effectpos.y = effectpos.y + 1
  3317.         effect = 129
  3318.         damagearea = acsn
  3319.     elseif mydir == 2 then
  3320.         effectpos.x = effectpos.x + 1
  3321.         effectpos.y = effectpos.y + 1
  3322.         effect = 131
  3323.         damagearea = acsn
  3324.     elseif mydir == 3 then
  3325.         effectpos.x = effectpos.x - 1
  3326.         effectpos.y = effectpos.y + 1
  3327.         effect = 130
  3328.         damagearea = acsn
  3329.     end
  3330.  
  3331.     local this = getThingPositionWithDebug(cid)
  3332.     this = getPosByDir(this, mydir)
  3333.  
  3334.     local function doCutAir()
  3335.         if not isCreature(cid) then return true end
  3336.     doSendMagicEffect(effectpos, effect)
  3337.     doAreaCombatHealth(cid, BUGDAMAGE, this, damagearea, -min, -max, 137)
  3338.     this = getPosByDir(this, mydir)
  3339.     effectpos = getPosByDir(effectpos, mydir)
  3340.     end
  3341.  
  3342.     for range = 0, 2 do
  3343.         addEvent(doCutAir, range * 350)
  3344.     end
  3345.  
  3346. elseif spell == "Ice Shard" then
  3347.  
  3348.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 28)
  3349.     doAreaCombatHealthAtDistance(cid, ICEDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 43)
  3350.  
  3351. elseif spell == "Shadow Ball" then
  3352.  
  3353.         doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 44)
  3354.         doAreaCombatHealthAtDistance(cid, GHOSTDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 140)
  3355.  
  3356. elseif spell == "Wood Hammer" then
  3357.  
  3358.     local pos = getThingPositionWithDebug(cid)
  3359.     local mainpos = getThingPositionWithDebug(cid)
  3360.  
  3361.     local a = {
  3362.     [1] = {x = pos.x, y = pos.y - 2, z = pos.z},
  3363.     [2] = {x = pos.x - 2, y = pos.y, z = pos.z},
  3364.     [3] = {x = pos.x, y = pos.y + 2, z = pos.z},
  3365.     [4] = {x = pos.x + 2, y = pos.y, z = pos.z},
  3366.     [5] = {x = pos.x, y = pos.y - 2, z = pos.z}}
  3367.     local b = {
  3368.     [1] = {x = pos.x - 1, y = pos.y, z = pos.z},
  3369.     [2] = {x = pos.x, y = pos.y + 1, z = pos.z},
  3370.     [3] = {x = pos.x + 1, y = pos.y, z = pos.z},
  3371.     [4] = {x = pos.x, y = pos.y + 1, z = pos.z},
  3372.     [5] = {x = pos.x - 1, y = pos.y, z = pos.z}}
  3373.     local c = {
  3374.     [1] = {x = pos.x, y = pos.y + 1, z = pos.z},
  3375.     [2] = {x = pos.x + 1, y = pos.y, z = pos.z},
  3376.     [3] = {x = pos.x, y = pos.y - 1, z = pos.z},
  3377.     [4] = {x = pos.x - 1, y = pos.y, z = pos.z},
  3378.     [5] = {x = pos.x, y = pos.y + 1, z = pos.z}}
  3379.  
  3380.     local function doWindVortex(cid, pos1, pos2)
  3381.         if not isCreature(cid) then return true end
  3382.         doSendDistanceShoot(pos1, pos2, 30)
  3383.         local effects = {CONST_ME_POFF, 3, 44}
  3384.         --doSendMagicEffect(pos1, effects[math.random(1, 3)])
  3385.     end
  3386.  
  3387.     for aaa = 0, 7 do
  3388.         for aa = 1, 4 do
  3389.             addEvent(doWindVortex, aa * 50 + aaa * 225, cid, a[aa], a[aa+1])
  3390.         end
  3391.     end
  3392.  
  3393.     for bbb = 0, 7 do
  3394.         for bb = 1, 4 do
  3395.             addEvent(doWindVortex, bb * 50 + bbb * 225, cid, b[bb], b[bb+1])
  3396.         end
  3397.     end
  3398.  
  3399.     for ccc = 0, 7 do
  3400.         for cc = 1, 4 do
  3401.             addEvent(doWindVortex, cc * 50 + ccc * 225, cid, c[cc], c[cc+1])
  3402.         end
  3403.     end
  3404.  
  3405.  
  3406.     local function doWindVortexDamage(cid, mainpos)
  3407.         if not isCreature(cid) then return true end
  3408.     doAreaCombatHealth(cid, GRASSDAMAGE, mainpos, woodhammer, -min, -max, 255)
  3409.     end
  3410.  
  3411.     for dmg = 1, 13 do
  3412.         addEvent(doWindVortexDamage, dmg * 150, cid, mainpos)
  3413.     end
  3414.  
  3415. elseif spell == "Powder Snow" then
  3416.  
  3417.     local posicao = getThingPositionWithDebug(cid)
  3418.  
  3419.     local function snowWind(params)
  3420.     if isCreature(params.cid) and isSightClear(posicao, params.ar, false) then
  3421.     doAreaCombatHealth(cid, ICEDAMAGE, params.ar, sand1, -min, -max, 17)
  3422.     end
  3423.     end
  3424.  
  3425.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  3426.  
  3427.     if a == 0 then
  3428.         for pw = 0, 2 do
  3429.             addEvent(snowWind, pw  * 650, {cid = cid, ar = {x=posicao.x, y=posicao.y-(pw+1), z=posicao.z}})
  3430.         end
  3431.     elseif a == 2 then
  3432.         for pw = 0, 2 do
  3433.             addEvent(snowWind, pw  * 650, {cid = cid, ar = {x=posicao.x, y=posicao.y+pw+1, z=posicao.z}})
  3434.         end
  3435.     elseif a == 1 then
  3436.         for pw = 0, 2 do
  3437.             addEvent(snowWind, pw  * 650, {cid = cid, ar = {x=posicao.x+(pw+1), y=posicao.y, z=posicao.z}})
  3438.         end
  3439.     elseif a == 3 then
  3440.         for pw = 0, 2 do
  3441.             addEvent(snowWind, pw  * 650, {cid = cid, ar = {x=posicao.x-(pw+1), y=posicao.y, z=posicao.z}})
  3442.         end
  3443.     end
  3444.  
  3445. elseif spell == "Ice Beam" then
  3446.  
  3447.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  3448.  
  3449.     if a == 0 then
  3450.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), wg1n, -min, -max, 99)
  3451.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), wg2n, -min, -max, 105)
  3452.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), wg3n, -min, -max, 103)
  3453.     elseif a == 2 then
  3454.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), wg1s, -min, -max, 98)
  3455.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), wg2s, -min, -max, 105)
  3456.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), wg3s, -min, -max, 102)
  3457.     elseif a == 1 then
  3458.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), wg1e, -min, -max, 96)
  3459.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), wg2e, -min, -max, 104)
  3460.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), wg3e, -min, -max, 100)
  3461.     elseif a == 3 then
  3462.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), wg1w, -min, -max, 97)
  3463.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), wg2w, -min, -max, 104)
  3464.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), wg3w, -min, -max, 101)
  3465.     end
  3466.  
  3467. elseif spell == "Icy Wind" then
  3468.  
  3469.     local target = getMasterTarget(cid)
  3470.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 28)
  3471.     doAreaCombatHealthAtDistance(cid, ICEDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 41)
  3472.  
  3473. elseif spell == "Lick" then
  3474.  
  3475.     local target = getMasterTarget(cid)
  3476.  
  3477.     doAreaCombatCondition(cid, getThingPositionWithDebug(target), 0, thunderwavecondition, 255)
  3478.     doAreaCombatHealth(cid, GHOSTDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 145)
  3479.  
  3480. elseif spell == "Clamp" then
  3481.  
  3482.     local function doClamp(cid, target, damage)
  3483.     if not isCreature(cid) or not isCreature(target) then return true end
  3484.     if damage then
  3485.         doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 68)
  3486.     else
  3487.         doSendMagicEffect(getThingPositionWithDebug(target), 111)
  3488.     end
  3489.     end
  3490.  
  3491.     local target = getMasterTarget(cid)
  3492.  
  3493.     for a = 0, 3 do
  3494.         if a == 3 then
  3495.             addEvent(doClamp, a * 75, cid, target, true)
  3496.         else
  3497.             addEvent(doClamp, a * 75, cid, target, false)
  3498.         end
  3499.     end
  3500.  
  3501. elseif spell == "Aurora Beam" then
  3502.  
  3503.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  3504.  
  3505.     if a == 0 then
  3506.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), auroran, -min, -max, 57)
  3507.     elseif a == 2 then
  3508.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), auroras, -min, -max, 58)
  3509.     elseif a == 1 then
  3510.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), aurorae, -min, -max, 234)
  3511.     elseif a == 3 then
  3512.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(cid), auroraw, -min, -max, 209)
  3513.     end
  3514.  
  3515. elseif spell == "Nightmare" then
  3516.  
  3517.     local target = getMasterTarget(cid)
  3518.  
  3519.     if not isSleeping(target) then
  3520.         doSendMagicEffect(getThingPositionWithDebug(target), 3)
  3521.         doSendAnimatedText(getThingPositionWithDebug(target), "FAIL", 155)
  3522.     return true
  3523.     end
  3524.  
  3525.     local function nightmare(target)
  3526.         if not isCreature(target) then return true end
  3527.         doSendMagicEffect(getThingPositionWithDebug(target), 139)
  3528.     end
  3529.  
  3530.     local function doNightmare(cid, target)
  3531.         if not isCreature(target) then return true end
  3532.         if not isCreature(cid) then return true end
  3533.         if not isSleeping(target) then return true end
  3534.         addEvent(nightmare, 0, target)
  3535.         addEvent(nightmare, 100, target)
  3536.         addEvent(nightmare, 200, target)
  3537.         doAreaCombatHealth(cid, NIGHTMAREDAMAGE, getThingPositionWithDebug(target), 0, -100, -100, 242)
  3538.         addEvent(doNightmare, 3000, cid, target)
  3539.     end
  3540.  
  3541.     nightmare(target)
  3542.     addEvent(doNightmare, 1000, cid, target)
  3543.  
  3544. elseif spell == "Healarea" then
  3545.  
  3546.     local hp = getSpecialAttack(cid) * 4 * healMultiplier
  3547.  
  3548.     doAreaCombatHealth(cid, HEALINGDAMAGE, getThingPositionWithDebug(cid), healarea, hp, hp, 12)
  3549.  
  3550.     local function doHeal(cid, amount)
  3551.         doCreatureAddHealth(cid, amount)
  3552.         doSendMagicEffect(getThingPositionWithDebug(cid), 12)
  3553.         doSendAnimatedText(getThingPositionWithDebug(cid), "+"..amount.."", 65)
  3554.     end
  3555.  
  3556.     doHeal(cid, hp)
  3557.  
  3558.     local areas = {}
  3559.  
  3560.     for xhp = -2, 2 do
  3561.         for yhp = -2, 2 do
  3562.             local pos = getThingPos(cid)
  3563.             pos.x = pos.x + xhp
  3564.             pos.y = pos.y + yhp
  3565.             local player = getTopCreature(pos).uid
  3566.                 if isCreature(player) and isPlayer(player) then
  3567.                     doHeal(player, hp)
  3568.                 end
  3569.         end
  3570.     end
  3571.  
  3572.     for thp = 0, 3 do
  3573.         local pos = getPosByDir(getThingPos(cid), thp, 3)
  3574.         local player = getTopCreature(pos).uid
  3575.             if isCreature(player) and isPlayer(player) then
  3576.                 doHeal(player, hp)
  3577.             end
  3578.     end
  3579.  
  3580. elseif spell == "Double Edge" or spell == "Double-edge" or spell == "Take Down" then
  3581.    
  3582.     doBodyPush(cid, target, true)
  3583.  
  3584.     local a = getCreatureHealth(target)
  3585.     local b = 0
  3586.  
  3587.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  3588.  
  3589.     if isCreature(target) and getCreatureHealth(target) > 0 then
  3590.         b = getCreatureHealth(target)
  3591.     end
  3592.  
  3593.     local hploss = math.floor((a - b) * 0.5)
  3594.  
  3595.     local function doRecoil(cid, hp)
  3596.         if not isCreature(cid) then return true end
  3597.         doCreatureAddHealth(cid, -hp)
  3598.         doSendAnimatedText(getThingPositionWithDebug(cid), "-"..hploss.."", 180)
  3599.         doSendMagicEffect(getThingPositionWithDebug(cid), 3)
  3600.     end
  3601.  
  3602.     addEvent(doRecoil, 400, cid, hploss)
  3603.  
  3604. elseif spell == "Sky Drop" then
  3605.  
  3606.     doCreatureAddCondition(cid, permanentinvisible)
  3607.     doSendMagicEffect(getThingPositionWithDebug(cid), 211)
  3608.     local mypos = getThingPositionWithDebug(cid)
  3609.     local topos = getThingPositionWithDebug(target)
  3610.     topos.y = topos.y - 7
  3611.     doSendDistanceShoot(getThingPositionWithDebug(cid), topos, 39)
  3612.  
  3613.         local function doReturn(cid, check, pos)
  3614.         if not isCreature(cid) then return true end
  3615.         local dmgpos = {}
  3616.             if check and isCreature(check) then
  3617.                 dmgpos = getThingPositionWithDebug(check)
  3618.             else
  3619.                 dmgpos = pos
  3620.             end
  3621.         doAreaCombatHealth(cid, FLYDAMAGE, dmgpos, 0, -min, -max, 42)
  3622.         doCreatureRemoveCondition(cid, CONDITION_INVISIBLE)
  3623.         doTeleportThing(cid, dmgpos, false)
  3624.         doCreatureSetLookDir(cid, 2)
  3625.         end
  3626.    
  3627.         local function dropBack(cid, target, pos)
  3628.         if not isCreature(cid) then return true end
  3629.         if not isCreature(target) then
  3630.         local bpos = pos
  3631.         bpos.y = bpos.y + 7
  3632.         doSendDistanceShoot(pos, bpos, 39)
  3633.         addEvent(doReturn, 450, cid, false, bpos)
  3634.         return true
  3635.         end
  3636.         doSendDistanceShoot(pos, getThingPositionWithDebug(target), 39)
  3637.         addEvent(doReturn, 450, cid, target, getThingPositionWithDebug(target))
  3638.         end
  3639.  
  3640.     addEvent(dropBack, 650, cid, target, topos)
  3641.  
  3642. elseif spell == "Sting Gun" then
  3643.  
  3644.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 13)
  3645.     doAreaCombatHealthAtDistance(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  3646.  
  3647. elseif spell == "Agility" then
  3648.  
  3649.     local a = getSpeed(cid)
  3650.     local b = a * 3
  3651.     local c = b - a
  3652.     setPlayerStorageValue(cid, 1003, b)
  3653.     doSendMagicEffect(getThingPositionWithDebug(cid), 220)
  3654.     doSendAnimatedText(getThingPositionWithDebug(cid), "+ SPEED", COLOR_GRASS)
  3655.  
  3656.     if getCreatureSpeed(cid) ~= 0 then
  3657.     doRegainSpeed(cid)
  3658.     end
  3659.  
  3660.         local function loseSpeed(cid, w)
  3661.             if not isCreature(cid) then return true end
  3662.         local j = getPlayerStorageValue(cid, 1003)
  3663.         setPlayerStorageValue(cid, 1003, j - w)
  3664.             if getCreatureSpeed(cid) ~= 0 then 
  3665.                 doRegainSpeed(cid)
  3666.             end
  3667.         end
  3668.  
  3669.     addEvent(loseSpeed, 8000, cid, c)
  3670.  
  3671. elseif spell == "Thunderbolt" or spell == "Thunder Bolt" then
  3672.  
  3673.         local function doThunderHit(cid, target)
  3674.             if not isCreature(target) or not isCreature(cid) then return true end
  3675.         doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 48)
  3676.         end
  3677.  
  3678.         local function doThunderFall(cid, frompos, target)
  3679.             if not isCreature(target) or not isCreature(cid) then return true end
  3680.         local pos = getThingPositionWithDebug(target)
  3681.         local ry = math.abs(frompos.y - pos.y)
  3682.         doSendDistanceShoot(frompos, getThingPositionWithDebug(target), 41)
  3683.         addEvent(doThunderHit, ry * 33, cid, target)
  3684.         end
  3685.  
  3686.         local function doThunderUp(cid, target)
  3687.             if not isCreature(target) or not isCreature(cid) then return true end
  3688.         local pos = getThingPositionWithDebug(target)
  3689.         local mps = getThingPositionWithDebug(cid)
  3690.         local xrg = math.floor((pos.x - mps.x) / 2)
  3691.         local topos = mps
  3692.         topos.x = topos.x + xrg
  3693.         local rd =  11
  3694.         topos.y = topos.y - rd
  3695.         doSendDistanceShoot(getThingPositionWithDebug(cid), topos, 41)
  3696.         addEvent(doThunderFall, rd * 49, cid, topos, target)
  3697.         end    
  3698.  
  3699.     local alvo = getMasterTarget(cid)
  3700.  
  3701.     for thnds = 0, 2 do
  3702.         addEvent(doThunderUp, thnds * 155, cid, alvo)
  3703.     end
  3704.  
  3705. elseif spell == "Faint Attack" then
  3706.  
  3707.     local a = getThingPositionWithDebug(cid)
  3708.     local b = getClosestFreeTile(cid, getThingPositionWithDebug(target))
  3709.     local c = getCreatureLookDir(cid)
  3710.     doSendMagicEffect(a, 211)
  3711.     doTeleportThing(cid, b, false)
  3712.     doFaceCreature(cid, getThingPositionWithDebug(target))
  3713.  
  3714.         local function comeBack(cid, lastpos, lastld)
  3715.             if not isCreature(cid) then return true end
  3716.         doSendMagicEffect(getThingPositionWithDebug(cid), 211)
  3717.         doTeleportThing(cid, lastpos, false)
  3718.         doCreatureSetLookDir(cid, lastld)
  3719.         end
  3720.  
  3721.     doAreaCombatHealth(cid, DARKDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 208)
  3722.     addEvent(comeBack, 200, cid, a, c)
  3723.  
  3724. elseif spell == "Fissure" then
  3725.  
  3726.     local aa = isCreature(getMasterTarget(cid)) and getDirectionTo(getThingPositionWithDebug(cid), getThingPositionWithDebug(target)) or getCreatureLookDir(cid)
  3727.     local bb = getFaceOpposite(aa)
  3728.     local back = {}
  3729.     local front = {}
  3730.     local apos = getThingPositionWithDebug(cid)
  3731.  
  3732.     local aae = {
  3733.     [NORTH] = {varx = 0, vary = -1},
  3734.     [SOUTH] = {varx = 0, vary = 1},
  3735.     [EAST] = {varx = 1, vary = 0},
  3736.     [WEST] = {varx = -1, vary = 0},
  3737.     [NORTHEAST] = {varx = 1, vary = -1},
  3738.     [NORTHWEST] = {varx = -1, vary = -1},
  3739.     [SOUTHEAST] = {varx = 1, vary = 1},
  3740.     [SOUTHWEST] = {varx = -1, vary = 1}}
  3741.  
  3742.     local varx = aae[bb].varx
  3743.     local vary = aae[bb].vary
  3744.     local xvar = aae[aa].varx
  3745.     local yvar = aae[aa].vary
  3746.  
  3747.     for c = 1, 6 do
  3748.         local addpos = {x=apos.x+(varx*c),y=apos.y+(vary*c),z=apos.z}
  3749.         table.insert(back, addpos)
  3750.     end
  3751.  
  3752.     for d = 1, 6 do
  3753.         local addpos = {x=apos.x+(xvar*d),y=apos.y+(yvar*d),z=apos.z}
  3754.         table.insert(front, addpos)
  3755.     end
  3756.  
  3757.         local function doFissure(cid, pos)
  3758.         doSendMagicEffect({x=pos.x+1,y=pos.y+1,z=pos.z}, 127)
  3759.         if not isCreature(cid) then return true end
  3760.         doAreaCombatHealth(cid, GROUNDDAMAGE, pos, 0, -min, -max, 255)
  3761.         end
  3762.  
  3763.     for times = 0, 2 do
  3764.     for e = 1, 6 do
  3765.         addEvent(doFissure, e * 145 + times * 400, cid, front[e])
  3766.         addEvent(doFissure, e * 145 + times * 400, cid, back[e])
  3767.     end
  3768.     end
  3769.  
  3770. elseif spell == "Lava Plume" then
  3771.  
  3772.     doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 237)
  3773.  
  3774. elseif spell == "Magma Storm" then
  3775.  
  3776.     local t = {}
  3777.     local m = getThingPositionWithDebug(cid)
  3778.         for x = -4, 4 do
  3779.             for y = -4, 4 do
  3780.             local pos = {x = m.x + x, y = m.y + y, z = m.z, stackpos = 0}
  3781.             table.insert(t, pos)
  3782.             end
  3783.         end
  3784.  
  3785.     local function doExplodeFire(cid, pos)
  3786.         if not isCreature(cid) then return true end
  3787.     doAreaCombatHealth(cid, FIREDAMAGE, pos, 0, -min, -max, 35)
  3788.     end
  3789.  
  3790.     local function doFallFire(cid, pos)
  3791.         if not isCreature(cid) then return true end
  3792.         local apos = pos
  3793.         local frompos = {x=apos.x-4,y=apos.y-3,z=apos.z}
  3794.         doSendDistanceShoot(frompos, pos, 3)
  3795.         addEvent(doExplodeFire, 385, cid, pos)
  3796.     end
  3797.  
  3798.     for a = 1, #t do
  3799.         if #t >= 1 then
  3800.         local random = math.random(1, #t)
  3801.         addEvent(doFallFire, a * 24, cid, t[random])
  3802.         t = doRemoveElementFromTable(t, t[random])
  3803.         end
  3804.     end
  3805.  
  3806.     for randomic = 1, 128 do
  3807.         local randompos = {x=m.x+math.random(-3,3),y=m.y+math.random(-3,3),z=m.z}
  3808.         addEvent(doFallFire, randomic * math.random(25, 30), cid, randompos)
  3809.     end
  3810.  
  3811. elseif spell == "Leaf Blade" then
  3812.  
  3813. local damagearea = {}
  3814. local effectpos = getThingPositionWithDebug(cid)
  3815. local effect = 255
  3816. local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  3817.  
  3818.     if a == 0 then
  3819.         effect = 128
  3820.         effectpos.x = effectpos.x + 1
  3821.         effectpos.y = effectpos.y - 1
  3822.         damagearea = wingdn
  3823.     elseif a == 1 then
  3824.         effectpos.x = effectpos.x + 1
  3825.         effectpos.y = effectpos.y + 1
  3826.         effect = 129
  3827.         damagearea = wingde
  3828.     elseif a == 2 then
  3829.         effectpos.x = effectpos.x + 1
  3830.         effectpos.y = effectpos.y + 1
  3831.         effect = 131
  3832.         damagearea = wingds
  3833.     elseif a == 3 then
  3834.         effectpos.x = effectpos.x - 1
  3835.         effectpos.y = effectpos.y + 1
  3836.         effect = 130
  3837.         damagearea = wingdw
  3838.     end
  3839.  
  3840.         doSendMagicEffect(effectpos, effect)
  3841.         doAreaCombatHealth(cid, GRASSDAMAGE, getThingPositionWithDebug(cid), damagearea, -min, -max, 54)
  3842.  
  3843. elseif spell == "Glaciate" then
  3844.  
  3845.     doCreatureSetNoMove(target, true)
  3846.     doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 230)
  3847.  
  3848.         local function doReturn(cid)
  3849.             if not isCreature(cid) then return true end
  3850.         doCreatureSetNoMove(cid, false)
  3851.         end
  3852.  
  3853.     addEvent(doReturn, 2000, target)
  3854.  
  3855. elseif spell == "Icicle Crash" then
  3856.  
  3857.     local pos = getThingPositionWithDebug(target)
  3858.     pos.x = pos.x -2
  3859.     pos.y = pos.y -6
  3860.  
  3861.     doSendDistanceShoot(pos, getThingPositionWithDebug(target), 35)
  3862.  
  3863.         local function doIcicleDamage(cid, target)
  3864.             if not isCreature(cid) or not isCreature(target) then return true end
  3865.         doAreaCombatHealth(cid, ICEDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 255)
  3866.         local pos = getThingPositionWithDebug(target)
  3867.         doSendMagicEffect(pos, 52)
  3868.         end
  3869.  
  3870.     addEvent(doIcicleDamage, 350, cid, target)
  3871.  
  3872. elseif spell == "Shadow Punch" then
  3873.  
  3874.     local pos = getThingPositionWithDebug(target)
  3875.     doSendMagicEffect(pos, 112)
  3876.  
  3877.         local function doPunch(cid, target)
  3878.             if not isCreature(cid) or not isCreature(target) then return true end
  3879.         doAreaCombatHealth(cid, GHOSTDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 255)
  3880.         local pos = getThingPositionWithDebug(target)
  3881.         pos.x = pos.x + 1
  3882.         doSendMagicEffect(pos, 208)
  3883.         end
  3884.  
  3885.     addEvent(doPunch, 600, cid, target)
  3886.  
  3887. elseif spell == "Dark Pulse" then
  3888.  
  3889.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 20)
  3890.     doAreaCombatHealthAtDistance(cid, DARKDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 39)
  3891.  
  3892. elseif spell == "Shadow Sneak" then
  3893.  
  3894.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 20)
  3895.     doAreaCombatHealthAtDistance(cid, DARKDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 250)
  3896.  
  3897. elseif spell == "Shadow Claw" then
  3898.  
  3899.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 6)
  3900.     doAreaCombatHealthAtDistance(cid, DARKDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 214)
  3901.  
  3902. elseif spell == "Shadow Storm" then
  3903.  
  3904.     local t = {}
  3905.     local m = getThingPositionWithDebug(cid)
  3906.         for x = -5, 5 do
  3907.             for y = -5, 5 do
  3908.             local pos = {x = m.x + x, y = m.y + y, z = m.z, stackpos = 0}
  3909.             table.insert(t, pos)
  3910.             end
  3911.         end
  3912.  
  3913.     local function doShadowDamage(cid, pos)
  3914.         if not isCreature(cid) then return true end
  3915.     doAreaCombatHealth(cid, GHOSTDAMAGE, pos, 0, -min, -max, 255)
  3916.         local mpos = pos
  3917.         mpos.x = mpos.x + 1
  3918.         doSendMagicEffect(mpos, 140)
  3919.     end
  3920.  
  3921.     local function doFallShadow(cid, pos)
  3922.         if not isCreature(cid) then return true end
  3923.         local apos = pos
  3924.         local frompos = {x=apos.x-5,y=apos.y-4,z=apos.z}
  3925.         doSendDistanceShoot(frompos, pos, 18)
  3926.         addEvent(doShadowDamage, 385, cid, pos)
  3927.     end
  3928.  
  3929.     for a = 1, #t do
  3930.         if #t >= 1 then
  3931.         local random = math.random(1, #t)
  3932.         addEvent(doFallShadow, a * 24, cid, t[random])
  3933.         t = doRemoveElementFromTable(t, t[random])
  3934.         end
  3935.     end
  3936.  
  3937.     for randomic = 1, 128 do
  3938.         local randompos = {x=m.x+math.random(-4,4),y=m.y+math.random(-4,4),z=m.z}
  3939.         addEvent(doFallShadow, randomic * math.random(25, 30), cid, randompos)
  3940.     end
  3941.  
  3942. elseif spell == "Guillotine" then
  3943.  
  3944.     local random = getPokemonLevel(cid) - getPokemonLevel(target)
  3945.  
  3946.     if math.random(1, 100) >= random or getPokemonLevel(cid) < getPokemonLevel(target) then
  3947.         doSendAnimatedText(getThingPositionWithDebug(cid), "FAIL", 215)
  3948.     return true
  3949.     end
  3950.  
  3951.     if getCreatureName(cid) == "Kingler" then
  3952.         doSendMagicEffect(getThingPositionWithDebug(target), 225)
  3953.     elseif getCreatureName(cid) == "Pinsir" then
  3954.         local pos1 = getThingPositionWithDebug(target)
  3955.         local pos2 = getThingPositionWithDebug(target)
  3956.         pos1.x = pos1.x - 2
  3957.         pos2.x = pos2.x + 2
  3958.         doSendDistanceShoot(pos1, pos2, 0)
  3959.         doSendDistanceShoot(pos2, pos1, 0)
  3960.     end
  3961.  
  3962.     doAreaCombatHealth(cid, GUILLOTINEDAMAGE, getThingPositionWithDebug(target), 0, -10, -10, 255)
  3963.  
  3964. elseif spell == "Volt Tackle" then
  3965.  
  3966.     doAreaCombatHealth(cid, ELECTRICDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 48)
  3967.  
  3968. elseif spell == "Hyper Voice" then
  3969.  
  3970.     local effect = 22
  3971.  
  3972.         local function doHyperVoice(cid, area)
  3973.         if not isCreature(cid) then return true end
  3974.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), area, -min, -max, effect)
  3975.         end
  3976.  
  3977.     local areas = {hv1, hv2, hv3, hv4, hv5}
  3978.  
  3979.     for go = 0, 4 do
  3980.         addEvent(doHyperVoice, go * 220, cid, areas[go+1])
  3981.     end
  3982.  
  3983. elseif spell == "Power Wave" then
  3984.  
  3985.     local effect = 21
  3986.  
  3987.         local function doHyperVoice(cid, area)
  3988.         if not isCreature(cid) then return true end
  3989.         doAreaCombatHealth(cid, PSYCHICDAMAGE, getThingPositionWithDebug(cid), area, -min, -max, effect)
  3990.         end
  3991.  
  3992.     local areas = {hv1, hv2, hv3, hv4, hv5}
  3993.  
  3994.     for go = 0, 4 do
  3995.         addEvent(doHyperVoice, go * 220, cid, areas[go+1])
  3996.     end
  3997.  
  3998. elseif spell == "Amnesia" or spell == "Psychic Up" then
  3999.  
  4000.     if spell == "Amnesia" then
  4001.         doSendMagicEffect(getThingPositionWithDebug(cid), 179)
  4002.     else
  4003.         doSendMagicEffect(getThingPositionWithDebug(cid), 134)
  4004.     end
  4005.  
  4006.     doSendAnimatedText(getThingPositionWithDebug(cid), "+ SP.ATK", COLOR_PSYCHIC)
  4007.  
  4008.     local function doReduceSpAtk(cid, qnt)
  4009.         if not isCreature(cid) then return true end
  4010.         local a = getSpecialAttack(cid)
  4011.         setPlayerStorageValue(cid, 1005, a - qnt)
  4012.     end
  4013.    
  4014.     local function doDoubleSpAtk(cid)
  4015.         if not isCreature(cid) then return true end
  4016.         local a = getSpecialAttack(cid)
  4017.         setPlayerStorageValue(cid, 1005, a * 2)
  4018.         local b = getSpecialAttack(cid)
  4019.         local c = b - a
  4020.     addEvent(doReduceSpAtk, 7500, cid, c)
  4021.     end
  4022.  
  4023.     doDoubleSpAtk(cid)
  4024.  
  4025. elseif spell == "Karate Chop" then
  4026.  
  4027.     local pos = getThingPositionWithDebug(target)
  4028.     local x = getPosByDir(getThingPositionWithDebug(target), math.random(4, 7))
  4029.     doSendDistanceShoot(x, pos, 26)
  4030.     doAreaCombatHealth(cid, FIGHTINGDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 3)
  4031.  
  4032. elseif spell == "Ground Kick" then
  4033.  
  4034.     local t = {}
  4035.     local p = getThingPositionWithDebug(cid)
  4036.     local b = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  4037.  
  4038.     if b == NORTH then
  4039.         for k = -1, 1 do
  4040.             local pos = {x = p.x - k, y = p.y - 1, z = p.z}
  4041.             table.insert(t, pos)
  4042.         end
  4043.     elseif b == SOUTH then
  4044.         for k = -1, 1 do
  4045.             local pos = {x = p.x - k, y = p.y + 1, z = p.z}
  4046.             table.insert(t, pos)
  4047.         end
  4048.     elseif b == EAST then
  4049.         for k = -1, 1 do
  4050.             local pos = {x = p.x + 1, y = p.y + k, z = p.z}
  4051.             table.insert(t, pos)
  4052.         end
  4053.     elseif b == WEST then
  4054.         for k = -1, 1 do
  4055.             local pos = {x = p.x - 1, y = p.y + k, z = p.z}
  4056.             table.insert(t, pos)
  4057.         end
  4058.     end
  4059.  
  4060.     local function doKickPos(cid, pos)
  4061.         if not isCreature(cid) then return true end
  4062.         doAreaCombatHealth(cid, FIGHTDAMAGE, pos, 0, -min, -max, 113)
  4063.     end
  4064.  
  4065.     for kicks = 1, 3 do
  4066.         addEvent(doKickPos, kicks * 220, cid, t[kicks])
  4067.     end
  4068.  
  4069. elseif spell == "Cross Chop" then
  4070.  
  4071.     local t = {}
  4072.     table.insert(t, getPosByDir(getThingPositionWithDebug(target), NORTHEAST))
  4073.     table.insert(t, getPosByDir(getThingPositionWithDebug(target), SOUTHWEST))
  4074.  
  4075.     for a = 1, 2 do
  4076.         doSendDistanceShoot(t[a], getThingPositionWithDebug(target), 26)
  4077.     end
  4078.  
  4079.     doAreaCombatHealth(cid, FIGHTINGDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 112)
  4080.  
  4081. elseif spell == "Fist Machine" then
  4082.  
  4083.     local mpos = getThingPositionWithDebug(cid)
  4084.     local b = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  4085.     local effect = 0
  4086.     local xvar = 0
  4087.     local yvar = 0
  4088.     local area = {}
  4089.  
  4090.     if b == SOUTH then
  4091.         effect = 218
  4092.         yvar = 2
  4093.         area = fmn
  4094.     elseif b == NORTH then
  4095.         effect = 217
  4096.         area = fms
  4097.     elseif b == WEST then
  4098.         effect = 216
  4099.         area = fmw
  4100.     elseif b == EAST then
  4101.         effect = 215
  4102.         xvar = 2
  4103.         area = fme
  4104.     end
  4105.  
  4106.     mpos.x = mpos.x + xvar
  4107.     mpos.y = mpos.y + yvar
  4108.  
  4109.     doSendMagicEffect(mpos, effect)
  4110.     doAreaCombatHealth(cid, FIGHTINGDAMAGE, getThingPositionWithDebug(cid), area, -min, -max, 255)
  4111.  
  4112. elseif spell == "Grass Knot" then
  4113.  
  4114.     doAreaCombatHealth(cid, GRASSDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 45)
  4115.  
  4116. elseif spell == "Bone Club" then
  4117.  
  4118.     doAreaCombatHealth(cid, GROUNDDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 228)
  4119.  
  4120. elseif spell == "Bonemerang" then
  4121.  
  4122.     local pos = getThingPositionWithDebug(cid)
  4123.     local b = isCreature(getMasterTarget(cid)) and getDirectionTo(getThingPositionWithDebug(cid), getThingPositionWithDebug(target)) or getCreatureLookDir(cid)
  4124.     local t = {}
  4125.  
  4126.     local signal = {
  4127.     [NORTH] = {0,  -1},
  4128.     [SOUTH] = {0,  1},
  4129.     [EAST] = {1,  0},
  4130.     [WEST] = {-1,  0},
  4131.     [SOUTHEAST] = {1,  1},
  4132.     [SOUTHWEST] = {-1,  1},
  4133.     [NORTHWEST] = {-1,  -1},
  4134.     [NORTHEAST] = {1,  -1}}
  4135.  
  4136.     for range = 1, 5 do
  4137.         local add = getThingPositionWithDebug(cid)
  4138.         add.x = add.x + signal[b][1] * range
  4139.         add.y = add.y + signal[b][2] * range
  4140.         table.insert(t, add)
  4141.     end
  4142.  
  4143.         local function doBoomerang(cid, pos)
  4144.             if not isCreature(cid) then return true end
  4145.         doAreaCombatHealth(cid, GROUNDDAMAGE, pos, 0, -min, -max, 227)
  4146.         end
  4147.  
  4148.     for throw = 1, 5 do
  4149.         addEvent(doBoomerang, (throw - 1) * 200, cid, t[throw])
  4150.     end
  4151.  
  4152.     for back = -5, -1 do
  4153.         local k = -back
  4154.         addEvent(doBoomerang, math.abs(k - 5) * 200 + 1000, cid, t[k])
  4155.     end
  4156.  
  4157. elseif spell == "Super Vines" then
  4158.  
  4159.     doCreatureSetLookDir(cid, 2)
  4160.     local a = getCreatureSpeed(cid)
  4161.     doChangeSpeed(cid, -a)
  4162.  
  4163.     local effect = 0
  4164.     local pos = getThingPositionWithDebug(cid)
  4165.     pos.x = pos.x + 1
  4166.     pos.y = pos.y + 1
  4167.  
  4168.     if getCreatureOutfit(cid).lookType == 369 then
  4169.         effect = 213
  4170.     else
  4171.         effect = 229
  4172.     end
  4173.  
  4174.     doSendMagicEffect(pos, effect)
  4175.     doAreaCombatHealth(cid, GRASSDAMAGE, getThingPositionWithDebug(cid), splash, -min, -max, 255)
  4176.  
  4177.     local function nois(cid, s)
  4178.         if not isCreature(cid) then return true end
  4179.     doChangeSpeed(cid, s)
  4180.     end
  4181.  
  4182.     addEvent(nois, 200, cid, a)
  4183.  
  4184. elseif spell == "Electric Field" then
  4185.  
  4186.     local t = {}
  4187.     local m = getThingPositionWithDebug(cid)
  4188.         for x = -3, 3 do
  4189.             for y = -3, 3 do
  4190.             local pos = {x = m.x + x, y = m.y + y, z = m.z}
  4191.             table.insert(t, pos)
  4192.             end
  4193.         end
  4194.  
  4195.     local function doElectricAttack(cid, pos)
  4196.         if not isCreature(cid) then return true end
  4197.         doAreaCombatHealth(cid, ELECTRICDAMAGE, pos, 0, -min, -max, 48)
  4198.         doSendDistanceShoot(pos, {x=pos.x,y=pos.y-8,z=pos.z}, 41)
  4199.     end
  4200.  
  4201.     for b = 1, 3 do
  4202.     for a = 1, #t do
  4203.         if #t >= 1 then
  4204.         local random = math.random(1, #t)
  4205.         addEvent(doElectricAttack, 25 * a, cid, t[random])
  4206.         t = doRemoveElementFromTable(t, t[random])
  4207.         end
  4208.     end
  4209.     end
  4210.  
  4211. elseif spell == "Rain Dance" then
  4212.  
  4213.     local t = {}
  4214.     local m = getThingPositionWithDebug(cid)
  4215.         for x = -4, 4 do
  4216.             for y = -3, 3 do
  4217.             local pos = {x = m.x + x, y = m.y + y, z = m.z}
  4218.             table.insert(t, pos)
  4219.             end
  4220.         end
  4221.  
  4222.     local function doElectricAttack(cid, pos)
  4223.         if not isCreature(cid) then return true end
  4224.         doAreaCombatHealth(cid, WATERDAMAGE, pos, 0, -min, -max, 68)
  4225.         doSendDistanceShoot(pos, {x=pos.x,y=pos.y-8,z=pos.z}, 2)
  4226.     end
  4227.  
  4228.     for b = 1, 3 do
  4229.     for a = 1, #t do
  4230.         if #t >= 1 then
  4231.         local random = math.random(1, #t)
  4232.         addEvent(doElectricAttack, 25 * a, cid, t[random])
  4233.         t = doRemoveElementFromTable(t, t[random])
  4234.         end
  4235.     end
  4236.     end
  4237.  
  4238. elseif spell == "Electric Storm" then
  4239.  
  4240.     local t = {}
  4241.     local m = getThingPositionWithDebug(cid)
  4242.         for x = -5, 5 do
  4243.             for y = -5, 5 do
  4244.             local pos = {x = m.x + x, y = m.y + y, z = m.z, stackpos = 0}
  4245.             table.insert(t, pos)
  4246.             end
  4247.         end
  4248.  
  4249.     local function doThunderAttack(cid, pos)
  4250.         if not isCreature(cid) then return true end
  4251.     doAreaCombatHealth(cid, ELECTRICDAMAGE, pos, 0, -min, -max, 48)
  4252.     end
  4253.  
  4254.     local function doFallThunder(cid, pos)
  4255.         if not isCreature(cid) then return true end
  4256.         local apos = pos
  4257.         local frompos = {x=apos.x-5,y=apos.y-4,z=apos.z}
  4258.         doSendDistanceShoot(frompos, pos, 41)
  4259.         addEvent(doThunderAttack, 385, cid, pos)
  4260.     end
  4261.  
  4262.     for a = 1, #t do
  4263.         if #t >= 1 then
  4264.         local random = math.random(1, #t)
  4265.         addEvent(doFallThunder, a * 24, cid, t[random])
  4266.         t = doRemoveElementFromTable(t, t[random])
  4267.         end
  4268.     end
  4269.  
  4270.     for randomic = 1, 128 do
  4271.         local randompos = {x=m.x+math.random(-4,4),y=m.y+math.random(-4,4),z=m.z}
  4272.         addEvent(doFallThunder, randomic * math.random(25, 30), cid, randompos)
  4273.     end
  4274.  
  4275. elseif spell == "Thunder" then
  4276.  
  4277.     local function doThunder(cid, area, pos)
  4278.         if not isCreature(cid) then return true end
  4279.         doAreaCombatHealth(cid, ELECTRICDAMAGE, pos, area, -min, -max, 48)
  4280.     end
  4281.  
  4282.     local pos = getThingPositionWithDebug(cid)
  4283.     local areas = {destruct1, destruct2, destruct3}
  4284.  
  4285.     for go = 0, 2 do
  4286.         addEvent(doThunder, go * 250, cid, areas[go+1], pos)
  4287.     end
  4288.  
  4289. elseif spell == "Strangling Tweezers" then
  4290.  
  4291.     local function doStrangle(cid, target, damage)
  4292.         if not isCreature(cid) or not isCreature(target) then return true end
  4293.         local pos = getThingPositionWithDebug(target)
  4294.         local oos = getThingPositionWithDebug(target)
  4295.         pos.x = pos.x + 1
  4296.         oos.x = oos.x - 1
  4297.         doSendDistanceShoot(oos, getThingPositionWithDebug(target), 38)
  4298.         doSendDistanceShoot(pos, getThingPositionWithDebug(target), 38)
  4299.         if damage then
  4300.             doAreaCombatHealth(cid, BUGDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 160)
  4301.         end
  4302.     end
  4303.  
  4304.     for times = 0, 23 do
  4305.         if isInArray({5, 10, 15, 20}, times) then
  4306.             addEvent(doStrangle, times * 70, cid, target, true)
  4307.         else
  4308.             addEvent(doStrangle, times * 70, cid, target, false)
  4309.         end
  4310.     end
  4311.  
  4312. elseif spell == "Bubblebeam" then
  4313.  
  4314.     local p = getThingPositionWithDebug(cid)
  4315.  
  4316.     local function doBubblebeam(cid, area)
  4317.         if not isCreature(cid) or not isSightClear(p, area, false) then return true end
  4318.     doSendDistanceShoot(p, area, 2)
  4319.     doAreaCombatHealth(cid, WATERDAMAGE, area, sand1, -min, -max, 25)
  4320.     end
  4321.  
  4322.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  4323.  
  4324.     if a == 0 then
  4325.         for b = 0, 4 do
  4326.             local pos = {x = p.x, y = p.y - (b+1), z = p.z}
  4327.             addEvent(doBubblebeam, b * 100, cid, pos)
  4328.         end
  4329.     elseif a == 2 then
  4330.         for b = 0, 4 do
  4331.             local pos = {x = p.x, y = p.y + (b+1), z = p.z}
  4332.             addEvent(doBubblebeam, b * 100, cid, pos)
  4333.         end
  4334.     elseif a == 1 then
  4335.         for b = 0, 4 do
  4336.             local pos = {x = p.x + b + 1, y = p.y, z = p.z}
  4337.             addEvent(doBubblebeam, b * 100, cid, pos)
  4338.         end
  4339.     elseif a == 3 then
  4340.         for b = 0, 4 do
  4341.             local pos = {x = p.x - (b+1), y = p.y, z = p.z}
  4342.             addEvent(doBubblebeam, b * 100, cid, pos)
  4343.         end
  4344.     end
  4345.  
  4346. elseif spell == "Mortal Gas" then
  4347.  
  4348.     local v1 = (15 + getPokemonLevel(cid)) * 5
  4349.         setPlayerStorageValue(cid, 919231, v1)
  4350.     local v3 = getPokemonLevel(cid) / 10 + 5
  4351.  
  4352.     doAreaCombatHealth(cid, POISONDAMAGE, getThingPositionWithDebug(cid), bomb2, -min, -max, 114)
  4353.     doAreaCombatHealth(cid, POISON_POWDERDAMAGE, getThingPositionWithDebug(cid), bomb2, -v3, -v3, 255)
  4354.  
  4355. elseif spell == "Focus" or spell == "Concentration" or spell == "Calm Mind" or spell == "Meditate" then
  4356.  
  4357.     local effect = 0
  4358.     local turns = getPokemonLevel(cid) / 5
  4359.  
  4360.     if spell == "Focus" then
  4361.         effect = 134
  4362.     elseif spell == "Concentration" then
  4363.         effect = 220
  4364.     else
  4365.         effect = 134
  4366.     end
  4367.  
  4368.     doFocus(cid, turns * 2, effect, getPlayerStorageValue(cid, 253))
  4369.  
  4370. elseif spell == "Fear" then
  4371.  
  4372.     local rounds  = math.random(2, 5)
  4373.         rounds = rounds + getPokemonLevel(cid) / 20
  4374.     addEvent(doAdvancedFear, 600, target, rounds, getPlayerStorageValue(target, 3894), cid)
  4375.  
  4376.     doSendAnimatedText(getThingPositionWithDebug(target), "SCARED", COLOR_GHOST)
  4377.  
  4378. elseif spell == "Poison Jab" then
  4379.  
  4380.     local t = {SOUTHWEST, WEST, NORTHWEST, NORTH}
  4381.  
  4382.     local function doJab(cid, target, dir)
  4383.         if not isCreature(cid) or not isCreature(target) then return true end
  4384.     doSendDistanceShoot(getPosByDir(getThingPositionWithDebug(target), dir), getThingPositionWithDebug(target), 20)
  4385.     doAreaCombatHealth(cid, POISONDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 114)
  4386.     end
  4387.  
  4388.     for a = 1, #t do
  4389.         addEvent(doJab, a * 45, cid, target, t[a])
  4390.     end
  4391.  
  4392. elseif spell == "Ground Shaker" then
  4393.  
  4394.     local function doShakeGround(cid)
  4395.         if not isCreature(cid) then return true end
  4396.     doAreaCombatHealth(cid, GROUNDDAMAGE, getThingPositionWithDebug(cid), gsarea, -min, -max, 118)
  4397.     end
  4398.  
  4399.     for times = 0, 27 do
  4400.         addEvent(doShakeGround, times * 300, cid)
  4401.     end
  4402.  
  4403. elseif spell == "Great Love" then
  4404.  
  4405.     local function doShakeGround(cid)
  4406.         if not isCreature(cid) then return true end
  4407.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(cid), glarea, -min, -max, 147)
  4408.     end
  4409.  
  4410.     for times = 0, 15 do
  4411.         addEvent(doShakeGround, times * 300, cid)
  4412.     end
  4413.  
  4414. elseif spell == "Earthquake" then
  4415.  
  4416.     local t = {}
  4417.     local m = getThingPositionWithDebug(cid)
  4418.         for x = -5, 5 do
  4419.             for y = -4, 4 do
  4420.             local pos = {x = m.x + x, y = m.y + y, z = m.z, stackpos = 0}
  4421.                 if getTileThingByPos(pos).itemid > 0 then
  4422.                     table.insert(t, pos)
  4423.                 end
  4424.             end
  4425.         end
  4426.  
  4427.     local function doEarthquake(cid, pos)
  4428.         if not isCreature(cid) then return true end
  4429.     if not isSightClear(getThingPositionWithDebug(cid), pos, false) then return true end
  4430.     if not canWalkOnPos(pos, false, false, false, false, true) then return true end
  4431.     doAreaCombatHealth(cid, GROUNDDAMAGE, pos, 0, -min, -max, 255)
  4432.     doSendMagicEffect({x = pos.x + 1, y = pos.y + 1, z = pos.z}, 127)
  4433.     end
  4434.  
  4435.     for a = 1, #t do
  4436.         if #t >= 1 then
  4437.         local random = math.random(1, #t)
  4438.         addEvent(doEarthquake, a * 24, cid, t[random])
  4439.         t = doRemoveElementFromTable(t, t[random])
  4440.         end
  4441.     end
  4442.  
  4443. elseif spell == "Surf" then
  4444.  
  4445.     local t = {}
  4446.     local m = getThingPositionWithDebug(cid)
  4447.         for x = -6, 6 do
  4448.             for y = -5, 5 do
  4449.             local pos = {x = m.x + x, y = m.y + y, z = m.z, stackpos = 0}
  4450.                 if getTileThingByPos(pos).itemid > 0 then
  4451.                     table.insert(t, pos)
  4452.                 end
  4453.             end
  4454.         end
  4455.  
  4456.     local function doEarthquake(cid, pos)
  4457.         if not isCreature(cid) then return true end
  4458.     if not isSightClear(getThingPositionWithDebug(cid), pos, false) then return true end
  4459.     if not canWalkOnPos(pos, false, false, false, false, true) then return true end
  4460.     doAreaCombatHealth(cid, WATERDAMAGE, pos, 0, -min, -max, 255)
  4461.     doSendMagicEffect({x = pos.x + 1, y = pos.y + 1, z = pos.z}, 246)
  4462.     end
  4463.  
  4464.     for a = 1, #t do
  4465.         if #t >= 1 then
  4466.         local random = math.random(1, #t)
  4467.         addEvent(doEarthquake, a * 24, cid, t[random])
  4468.         t = doRemoveElementFromTable(t, t[random])
  4469.         end
  4470.     end
  4471.  
  4472. elseif spell == "Eruption" then
  4473.  
  4474.     local pos = getThingPositionWithDebug(cid)
  4475.  
  4476.     local function doSendBubble(cid, pos)
  4477.         if not isCreature(cid) then return true end
  4478.         doSendDistanceShoot(getThingPositionWithDebug(cid), pos, 3)
  4479.         doSendMagicEffect(pos, 237)
  4480.         doAreaCombatHealth(cid, FIREDAMAGE, pos, 0, -min, -max, 5)
  4481.     end
  4482.  
  4483.     for b = 1, 3 do
  4484.         for a = 1, 20 do
  4485.             local lugar = {x = pos.x + math.random(-4, 4), y = pos.y + math.random(-3, 3), z = pos.z}
  4486.             addEvent(doSendBubble, a * 75, cid, lugar)
  4487.         end
  4488.     end
  4489.  
  4490.  
  4491. elseif spell == "Water Spout" then
  4492.  
  4493.     local pos = getThingPositionWithDebug(cid)
  4494.  
  4495.     local function doSendBubble(cid, pos)
  4496.         if not isCreature(cid) then return true end
  4497.         doSendDistanceShoot(getThingPositionWithDebug(cid), pos, 2)
  4498.         doSendMagicEffect(pos, 53)
  4499.         doAreaCombatHealth(cid, WATERDAMAGE, pos, 0, -min, -max, 53)
  4500.     end
  4501.  
  4502.     for b = 1, 3 do
  4503.         for a = 1, 20 do
  4504.             local lugar = {x = pos.x + math.random(-4, 4), y = pos.y + math.random(-3, 3), z = pos.z}
  4505.             addEvent(doSendBubble, a * 75, cid, lugar)
  4506.         end
  4507.     end
  4508.  
  4509.  
  4510. elseif spell == "Cross Poison" then
  4511.  
  4512.     local a = getThingPositionWithDebug(target)
  4513.     local b = {}
  4514.     doSendDistanceShoot(getPosByDir(getPosByDir(getThingPositionWithDebug(target), NORTHWEST), NORTHWEST), getPosByDir(getThingPositionWithDebug(target), SOUTHEAST), 20)
  4515.     doSendDistanceShoot(getPosByDir(getPosByDir(getThingPositionWithDebug(target), NORTHEAST), NORTHEAST), getPosByDir(getThingPositionWithDebug(target), SOUTHWEST), 20)
  4516.     doSendDistanceShoot(getPosByDir(getPosByDir(getThingPositionWithDebug(target), SOUTHWEST), SOUTHWEST), getPosByDir(getThingPositionWithDebug(target), NORTHEAST), 20)
  4517.     doSendDistanceShoot(getPosByDir(getPosByDir(getThingPositionWithDebug(target), SOUTHEAST), SOUTHEAST), getPosByDir(getThingPositionWithDebug(target), NORTHWEST), 20)
  4518.     doSendMagicEffect(a, 114)
  4519.     doAreaCombatHealth(cid, POISONDAMAGE, a, 0, -min, -max, 114)
  4520.  
  4521. elseif spell == "Seismic Clash" then
  4522.  
  4523.     local posicao = getThingPositionWithDebug(cid)
  4524.        
  4525.     local function clash(params)
  4526.     if isCreature(cid) and isSightClear(posicao, params.ar, false) then
  4527.     doAreaCombatHealth(cid, GROUNDDAMAGE, params.ar, whirl3, -min, -max, 255)
  4528.     doAreaCombatHealth(cid, null, params.ar, params.br, 0, 0, 127)
  4529.     end
  4530.     end
  4531.  
  4532.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  4533.  
  4534.     if a == 0 then
  4535.         for time = 0, 6 do
  4536.             addEvent(clash, time * 120, {cid = cid, ar = {x=posicao.x, y=posicao.y-(time+1), z=posicao.z}, br = clasheffectn})
  4537.         end
  4538.     elseif a == 2 then
  4539.         for time = 0, 6 do
  4540.             addEvent(clash, time * 120, {cid = cid, ar = {x=posicao.x, y=posicao.y+(time+1), z=posicao.z}, br = clasheffects})
  4541.         end
  4542.     elseif a == 1 then
  4543.         for time = 0, 6 do
  4544.             addEvent(clash, time * 120, {cid = cid, ar = {x=posicao.x+(time+1), y=posicao.y, z=posicao.z}, br = clasheffecte})
  4545.         end
  4546.     elseif a == 3 then
  4547.         for time = 0, 6 do
  4548.             addEvent(clash, time * 120, {cid = cid, ar = {x=posicao.x-(time+1), y=posicao.y, z=posicao.z}, br = clasheffectw})
  4549.         end
  4550.     end
  4551.  
  4552. elseif spell == "Lovely Kiss" then
  4553.  
  4554.     if getPokemonGender(cid) == getPokemonGender(target) then
  4555.         doSendMagicEffect(getThingPositionWithDebug(target), 3)
  4556.         doSendAnimatedText(getThingPositionWithDebug(target), "FAIL", COLOR_PINK)  
  4557.     return true
  4558.     end
  4559.  
  4560.     local v1 = math.random(4, 7)
  4561.     local v2 = v1 + getPokemonLevel(cid) / 20
  4562.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 16)
  4563.     doAreaCombatHealth(cid, SLEEP_POWDERDAMAGE, getThingPositionWithDebug(target), 0, -v1, -v2, 147)
  4564.  
  4565. elseif spell == "Sweet Kiss" then
  4566.  
  4567.     if getPokemonGender(cid) == getPokemonGender(target) then
  4568.         doSendMagicEffect(getThingPositionWithDebug(target), 3)
  4569.         doSendAnimatedText(getThingPositionWithDebug(target), "FAIL", COLOR_PINK)  
  4570.     return true
  4571.     end
  4572.  
  4573.     local target = getMasterTarget(cid)
  4574.     local rounds = math.random(4, 7)
  4575.     rounds = rounds + math.floor(getPokemonLevel(cid) / 35)
  4576.  
  4577.     doSendMagicEffect(getThingPositionWithDebug(target), 171)
  4578.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 32)
  4579.     addEvent(doAdvancedConfuse, 700, target, rounds, getPlayerStorageValue(target, 3891))
  4580.  
  4581. elseif spell == "Metronome" then
  4582.  
  4583.     local spells = {
  4584.     'Magma Storm',
  4585.     'Eruption',
  4586.     'Psychic',
  4587.     'Psyusion',
  4588.     'Surf',
  4589.     'Sandstorm',
  4590.     'Thunder',
  4591.     'Electric Storm',
  4592.     'Great Love',
  4593.     'Windstorm',
  4594.     'Leaf Storm',
  4595.     'Magical Leaf',
  4596.     'Poison Gas',
  4597.     'Blizzard',
  4598.     'Shadow Storm',
  4599.     'Spacial Rend',
  4600.     'Power Wave',
  4601.     }
  4602.  
  4603.     local random = math.random(1, #spells)
  4604.  
  4605.     local randommove = spells[random]
  4606.     local pos = getThingPositionWithDebug(cid)
  4607.     pos.y = pos.y - 1
  4608.  
  4609.     doSendMagicEffect(pos, 161)
  4610.  
  4611.         local function doUseMetronome(cid, spell)
  4612.             if not isCreature(cid) then return true end
  4613.             docastspell(cid, spell)
  4614.                 if isSummon(cid) then
  4615.                     doCreatureSay(cid, ""..string.upper(spell).."!", TALKTYPE_MONSTER)
  4616.                 end
  4617.         end
  4618.  
  4619.     addEvent(doUseMetronome, 890, cid, randommove)
  4620.  
  4621. elseif spell == "Secret Power" then
  4622.  
  4623.     local spells = {
  4624.     'Falling Rocks', 'Ancient Power', 'Earthquake', 'Ground Shaker',
  4625.     'Epicenter', 'Falling Rocks', 'Great Love',
  4626.     }
  4627.  
  4628.     local random = math.random(1, #spells)
  4629.  
  4630.     local randommove = spells[random]
  4631.     local pos = getThingPositionWithDebug(cid)
  4632.     pos.y = pos.y - 1
  4633.  
  4634.     doSendMagicEffect(pos, 254)
  4635.  
  4636.         local function doUseMetronome(cid, spell)
  4637.             if not isCreature(cid) then return true end
  4638.             docastspell(cid, spell)
  4639.                 if isSummon(cid) then
  4640.                     doCreatureSay(cid, ""..string.upper(spell).."!", TALKTYPE_MONSTER)
  4641.                 end
  4642.         end
  4643.  
  4644.     addEvent(doUseMetronome, 890, cid, randommove)
  4645.  
  4646. elseif spell == "Foresight" then
  4647.  
  4648.     local spells = {
  4649.     'Fire Punch', 'Ice Punch', 'Thunder Punch', 'Shadow Punch',
  4650.     'Fire Kick', 'Ice Kick', 'Thunder Kick',
  4651.     }
  4652.  
  4653.     local random = math.random(1, #spells)
  4654.  
  4655.     local randommove = spells[random]
  4656.     local pos = getThingPositionWithDebug(cid)
  4657.     pos.y = pos.y - 1
  4658.  
  4659.     doSendMagicEffect(pos, 211)
  4660.  
  4661.         local function doUseMetronome(cid, spell)
  4662.             if not isCreature(cid) then return true end
  4663.             docastspell(cid, spell)
  4664.                 if isSummon(cid) then
  4665.                     doCreatureSay(cid, ""..string.upper(spell).."!", TALKTYPE_MONSTER)
  4666.                 end
  4667.         end
  4668.  
  4669.     addEvent(doUseMetronome, 890, cid, randommove)
  4670.  
  4671. elseif spell == "Roar Of Time" then
  4672.  
  4673.     local spells = {
  4674.     'Rooar Of Time', 'Rooar Of Time', 'Rooar Of Time', 'Rooar Of Time',
  4675.     'Rooar Of Time', 'Rooar Of Time', 'Rooar Of Time',
  4676.     'Rooar Of Time',
  4677.     'Rooar Of Time',
  4678.     }
  4679.  
  4680.     local random = math.random(1, #spells)
  4681.  
  4682.     local randommove = spells[random]
  4683.     local pos = getThingPositionWithDebug(cid)
  4684.     pos.y = pos.y - 1
  4685.  
  4686.     doSendMagicEffect(pos, 211)
  4687.  
  4688.         local function doUseMetronome(cid, spell)
  4689.             if not isCreature(cid) then return true end
  4690.             docastspell(cid, spell)
  4691.                 if isSummon(cid) then
  4692.                 end
  4693.         end
  4694.  
  4695.     addEvent(doUseMetronome, 890, cid, randommove)
  4696.  
  4697. elseif spell == "Blast Burn" then
  4698.  
  4699.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 3)
  4700.     doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 237)
  4701.  
  4702.     local function doSendEffect(target, direction)
  4703.         if not isCreature(target) then return true end
  4704.         doSendMagicEffect(getPosByDir(getThingPositionWithDebug(target), direction), 219)
  4705.     end
  4706.  
  4707.     local dir = {SOUTH, WEST, NORTH, EAST}
  4708.  
  4709.     for a = 1, 4 do
  4710.         addEvent(doSendEffect, 200 + a * 120, target, dir[a])
  4711.     end
  4712.  
  4713. elseif spell == "Frenzy Plant" then
  4714.  
  4715.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 8)
  4716.     doAreaCombatHealth(cid, GRASSDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 239)
  4717.  
  4718.     local function doSendEffect(target, direction)
  4719.         if not isCreature(target) then return true end
  4720.         doSendMagicEffect(getPosByDir(getThingPositionWithDebug(target), direction), 45)
  4721.     end
  4722.  
  4723.     local dir = {SOUTH, WEST, NORTH, EAST}
  4724.  
  4725.     for a = 1, 4 do
  4726.         addEvent(doSendEffect, 200 + a * 120, target, dir[a])
  4727.     end
  4728.  
  4729. elseif spell == "Mimic" then
  4730.  
  4731.     doSendMagicEffect(getThingPositionWithDebug(cid), 132)
  4732.  
  4733.     local function doCopyAndCast(cid, target)
  4734.         if not isCreature(cid) or not isCreature(target) then return true end
  4735.         local spell = getPlayerStorageValue(target, 877)
  4736.             if spell == -1 then doSendAnimatedText(getThingPositionWithDebug(cid), "FAIL", 215) return true end
  4737.             docastspell(cid, spell)
  4738.                 if isSummon(cid) then
  4739.                     doCreatureSay(cid, ""..string.upper(spell).."!", TALKTYPE_MONSTER)
  4740.                 end
  4741.     end
  4742.  
  4743.     addEvent(doCopyAndCast, 700, cid, target)
  4744.  
  4745. elseif spell == "Gastro Acid" then
  4746.  
  4747.     local pos = getThingPositionWithDebug(target)
  4748.     local t = {}
  4749.     local function doGastro(cid, pos, main)
  4750.         if not isCreature(cid) then return true end
  4751.         if main then
  4752.             local highpos = getThingPositionWithDebug(pos)
  4753.             highpos.y = highpos.y - 3
  4754.             doSendDistanceShoot(highpos, getThingPositionWithDebug(pos), 14)
  4755.             doAreaCombatHealth(cid, POISONDAMAGE, getThingPositionWithDebug(pos), 0, -min, -max, 20)
  4756.         else
  4757.             doAreaCombatHealth(cid, POISONDAMAGE, pos, 0, -min*2, -max*2, 20)
  4758.         end
  4759.     end
  4760.  
  4761.     for a = 0, 3 do
  4762.         local targetpos = getPosByDir(getThingPositionWithDebug(target), a)
  4763.         local highpos = getPosByDir(getThingPositionWithDebug(target), a)
  4764.         highpos.y = highpos.y - 3
  4765.         doSendDistanceShoot(highpos, targetpos, 14)
  4766.         addEvent(doGastro, 220, cid, targetpos)
  4767.         addEvent(doGastro, a * 75, cid, target, true)
  4768.     end
  4769.  
  4770. elseif spell == "Sand Tomb" then
  4771.  
  4772.     local pos = getThingPositionWithDebug(target)
  4773.     local t = {}
  4774.     local function doGastro(cid, pos, main)
  4775.         if not isCreature(cid) then return true end
  4776.         if main then
  4777.             local highpos = getThingPositionWithDebug(pos)
  4778.             highpos.y = highpos.y - 3
  4779.             doSendDistanceShoot(highpos, getThingPositionWithDebug(pos), 22)
  4780.             doAreaCombatHealth(cid, GROUNDDAMAGE, getThingPositionWithDebug(pos), 0, -min, -max, 85)
  4781.         else
  4782.             doAreaCombatHealth(cid, GROUNDDAMAGE, pos, 0, -min*2, -max*2, 34)
  4783.         end
  4784.     end
  4785.  
  4786.     for a = 0, 3 do
  4787.         local targetpos = getPosByDir(getThingPositionWithDebug(target), a)
  4788.         local highpos = getPosByDir(getThingPositionWithDebug(target), a)
  4789.         highpos.y = highpos.y - 3
  4790.         doSendDistanceShoot(highpos, targetpos, 22)
  4791.         addEvent(doGastro, 220, cid, targetpos)
  4792.         addEvent(doGastro, a * 75, cid, target, true)
  4793.     end
  4794.  
  4795. elseif spell == "Fury Cutter" then
  4796.  
  4797.     local function doCut(cid, target, turn)
  4798.         if not isCreature(cid) or not isCreature(target) then return true end
  4799.         if getDistanceBetween(getThingPositionWithDebug(cid), getThingPositionWithDebug(target)) >= 3 then return true end
  4800.         if turn < 1 then return true end
  4801.         doAreaCombatHealth(cid, BUGDAMAGE, getThingPositionWithDebug(target), 0, -min/turn, -max/turn, 141)
  4802.         addEvent(doCut, 285, cid, target, turn - 1)
  4803.     end
  4804.  
  4805.     doCut(cid, target, 10)
  4806.  
  4807. elseif spell == "Egg Bomb" then
  4808.  
  4809.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 12)
  4810.     doAreaCombatHealthAtDistance(cid, NORMALDAMAGE, getThingPositionWithDebug(target), oathzinho, -min, -max, 3)
  4811.  
  4812. elseif spell == "Earth Power" then
  4813.  
  4814.     local t = {}
  4815.     local p = getThingPositionWithDebug(cid)
  4816.     local b = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  4817.  
  4818.     if b == NORTH then
  4819.         for k = -1, 1 do
  4820.             local pos = {x = p.x - k, y = p.y - 1, z = p.z}
  4821.             table.insert(t, pos)
  4822.         end
  4823.     elseif b == SOUTH then
  4824.         for k = -1, 1 do
  4825.             local pos = {x = p.x - k, y = p.y + 1, z = p.z}
  4826.             table.insert(t, pos)
  4827.         end
  4828.     elseif b == EAST then
  4829.         for k = -1, 1 do
  4830.             local pos = {x = p.x + 1, y = p.y + k, z = p.z}
  4831.             table.insert(t, pos)
  4832.         end
  4833.     elseif b == WEST then
  4834.         for k = -1, 1 do
  4835.             local pos = {x = p.x - 1, y = p.y + k, z = p.z}
  4836.             table.insert(t, pos)
  4837.         end
  4838.     end
  4839.  
  4840.     local function doEarthPower(cid, pos)
  4841.         if not isCreature(cid) then return true end
  4842.         doAreaCombatHealth(cid, GROUNDDAMAGE, pos, 0, -min, -max, 255)
  4843.         local a = {x=pos.x+1,y=pos.y+1,z=pos.z}
  4844.         doSendMagicEffect(a, 235)
  4845.         --doSendDistanceShoot(pos, {x=pos.x,y=pos.y-6,z=pos.z}, 42)    
  4846.     end
  4847.  
  4848.     for times = 1, 3 do
  4849.         doEarthPower(cid, t[times])
  4850.     end
  4851.  
  4852. elseif spell == "Magnitude" then
  4853.  
  4854.     local t = {}
  4855.     local m = getThingPositionWithDebug(cid)
  4856.     local target = 0
  4857.         for x = -4, 4 do
  4858.             for y = -4, 4 do
  4859.             local pos = {x = m.x + x, y = m.y + y, z = m.z, stackpos = 0}
  4860.             table.insert(t, pos)
  4861.             end
  4862.         end
  4863.  
  4864.     local mag = {4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 10}
  4865.     local magnitude = math.random(4, 10)--mag[math.random(#mag)]
  4866.  
  4867.     doSendAnimatedText(getThingPositionWithDebug(cid), magnitude, COLOR_GROUND)
  4868.  
  4869.     local rate = magnitude - 3
  4870.  
  4871.     local function doCrackGround(cid, posa, checkone, checktwo, target)
  4872.         if not isCreature(cid) then return true end
  4873.     local pos = {}
  4874.     if checkone and isCreature(target) then
  4875.         pos = getThingPositionWithDebug(target)
  4876.     else
  4877.         pos = posa
  4878.     end
  4879.         if checktwo and isCreature(target) and getTopCreature(pos).uid == target then
  4880.         return true
  4881.         end
  4882.     doAreaCombatHealth(cid, GROUNDDAMAGE, pos, 0, -min*rate, -max*rate, 255)
  4883.     local a = {x=pos.x+1,y=pos.y+1,z=pos.z}
  4884.     doSendMagicEffect(a, 127)
  4885.     end
  4886.  
  4887.     if isCreature(getMasterTarget(cid)) and getDistanceBetween(getThingPositionWithDebug(getMasterTarget(cid)), m) <= 7 then
  4888.         target = getMasterTarget(cid)
  4889.         local n = getThingPositionWithDebug(target)
  4890.         local npos = {x = n.x, y = n.y, z = n.z, stackpos = 0}
  4891.         magnitude = magnitude - 1
  4892.         addEvent(doCrackGround, 1050, cid, npos, true, false, target)
  4893.     end
  4894.  
  4895.     for this = 1, magnitude do
  4896.     local random = math.random(1, #t)
  4897.     addEvent(doCrackGround, 1050, cid, t[random], false, true, target)
  4898.     t = doRemoveElementFromTable(t, t[random])
  4899.     end
  4900.  
  4901. elseif spell == "Pay Day" then
  4902.  
  4903.         local function doThunderHit(cid, target)
  4904.             if not isCreature(target) or not isCreature(cid) then return true end
  4905.         doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 3)
  4906.         end
  4907.  
  4908.         local function doThunderFall(cid, frompos, target)
  4909.             if not isCreature(target) or not isCreature(cid) then return true end
  4910.         local pos = getThingPositionWithDebug(target)
  4911.         local ry = math.abs(frompos.y - pos.y)
  4912.         doSendDistanceShoot(frompos, getThingPositionWithDebug(target), 37)
  4913.         addEvent(doThunderHit, ry * 33, cid, target)
  4914.         end
  4915.  
  4916.         local function doThunderUp(cid, target)
  4917.             if not isCreature(target) or not isCreature(cid) then return true end
  4918.         local pos = getThingPositionWithDebug(target)
  4919.         local mps = getThingPositionWithDebug(cid)
  4920.         local xrg = math.floor((pos.x - mps.x) / 2)
  4921.         local topos = mps
  4922.         topos.x = topos.x + xrg
  4923.         local rd =  11
  4924.         topos.y = topos.y - rd
  4925.         doSendDistanceShoot(getThingPositionWithDebug(cid), topos, 37)
  4926.         addEvent(doThunderFall, rd * 49, cid, topos, target)
  4927.         end    
  4928.  
  4929.     local alvo = getMasterTarget(cid)
  4930.  
  4931.     for thnds = 0, 2 do
  4932.         addEvent(doThunderUp, thnds * 155, cid, alvo)
  4933.     end
  4934.  
  4935. elseif spell == "Mimic Wall" then
  4936.  
  4937.     if hasMimicWall(cid) then
  4938.     local health = getSpecialAttack(cid) * 2
  4939.     setPlayerStorageValue(cid, 878, getPlayerStorageValue(cid, 878) + health)
  4940.     return true end
  4941.  
  4942.     local function doCreateWall(cid)
  4943.         if not isCreature(cid) then return true end
  4944.         local health = getSpecialAttack(cid) * 2
  4945.         setPlayerStorageValue(cid, 878, health)
  4946.             if getCreatureLookDir(cid) == SOUTH or getCreatureLookDir(cid) == NORTH then
  4947.                 doCreateItem(11439, 1, getThingPositionWithDebug(cid))
  4948.             else
  4949.                 doCreateItem(11440, 1, getThingPositionWithDebug(cid))
  4950.             end
  4951.     end
  4952.  
  4953.     local function doEndWallTime(cid)
  4954.         if not isCreature(cid) then return true end
  4955.         setPlayerStorageValue(cid, 878, -1)
  4956.     local b = getTileItemById(getThingPositionWithDebug(cid), 11440)
  4957.     if b.uid > 1 then doRemoveItem(b.uid, 1) end
  4958.     local c = getTileItemById(getThingPositionWithDebug(cid), 11439)
  4959.     if c.uid > 1 then doRemoveItem(c.uid, 1) end   
  4960.         doSendMagicEffect(getThingPositionWithDebug(cid), 3)
  4961.     end
  4962.  
  4963.     doSendMagicEffect(getThingPositionWithDebug(cid), 135)
  4964.  
  4965.         addEvent(doCreateWall, 650, cid)
  4966.         addEvent(doEndWallTime, 17 * 1000, cid)
  4967.  
  4968. elseif spell == "Counter" then
  4969.  
  4970.     setPlayerStorageValue(cid, 879, 1)
  4971.     doSendMagicEffect(getThingPositionWithDebug(cid), 55)
  4972.  
  4973. elseif spell == "Spacial Rend" then
  4974.  
  4975.     for a = -6, 6 do
  4976.         for b = -5, 5 do
  4977.         local pos = getThingPositionWithDebug(cid)
  4978.         local place = {x=pos.x+a,y=pos.y+b,z=pos.z}
  4979.         doSendDistanceShoot(getThingPositionWithDebug(cid), place, 31)
  4980.         end
  4981.     end
  4982.  
  4983.     doAreaCombatHealth(cid, DRAGONDAMAGE, getThingPositionWithDebug(cid), grassarea, -min, -max, 255)
  4984.  
  4985. elseif spell == "Overheat" then
  4986.  
  4987.     for a = -5, 5 do
  4988.         for b = -4, 4 do
  4989.         local pos = getThingPositionWithDebug(cid)
  4990.         local place = {x=pos.x+a,y=pos.y+b,z=pos.z}
  4991.         doSendDistanceShoot(getThingPositionWithDebug(cid), place, 3)
  4992.         end
  4993.     end
  4994.  
  4995.     doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(cid), grassarea, -min, -max, 255)
  4996.  
  4997. elseif spell == "Rooar Of Time" then
  4998.  
  4999.     for a = -5, 5 do
  5000.         for b = -3, 3 do
  5001.         local pos = getThingPositionWithDebug(cid)
  5002.         local place = {x=pos.x+a,y=pos.y+b,z=pos.z}
  5003.         doSendDistanceShoot(getThingPositionWithDebug(cid), place, 0)
  5004.         end
  5005.     end
  5006.  
  5007.     doAreaCombatHealth(cid, DRAGONDAMAGE, getThingPositionWithDebug(cid), grassarea, -min, -max, 255)
  5008.  
  5009. elseif spell == "Mind Blast" then
  5010.  
  5011.     local function doFindMind(cid, pos, target, effect, distance)
  5012.         if not isCreature(target) then return true end
  5013.         if not isCreature(cid) then return true end
  5014.         if getDistanceBetween(getThingPositionWithDebug(target), pos) == 0 then
  5015.             local bonus = distance * 0.34 + 0.76
  5016.             doAreaCombatHealth(cid, PSYCHICDAMAGE, getThingPositionWithDebug(target), 0, -min * bonus, -max * bonus, 242)
  5017.         return true
  5018.         end
  5019.     doSendMagicEffect(pos, effect)
  5020.     local dir = getDirectionTo(pos, getThingPositionWithDebug(target))
  5021.         if dir >= 4 then
  5022.             dir = randomdiagonaldir[dir][math.random(1, 2)]
  5023.         end
  5024.     local a = getPosByDir(pos, dir)
  5025.     local nextef = 133
  5026.         if effect == 133 then
  5027.             nextef = 136
  5028.         end
  5029.     addEvent(doFindMind, 175, cid, a, target, nextef, distance + 1)
  5030.     end
  5031.  
  5032.     doFindMind(cid, getThingPositionWithDebug(cid), getMasterTarget(cid), 133, 0)
  5033.  
  5034. elseif spell == "Future Sight" then
  5035.  
  5036.     local function doFutureSight(cid, target)
  5037.         if not isCreature(cid) or not isCreature(target) then return true end
  5038.     doAreaCombatHealth(cid, PSYCHICDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 134)
  5039.     end
  5040.  
  5041.     doSendMagicEffect(getThingPositionWithDebug(cid), 220)
  5042.  
  5043.     addEvent(doFutureSight, 2500, cid, target)
  5044.  
  5045. elseif spell == "Shell Smash" then
  5046.    
  5047.     doBodyPush(cid, target, true)
  5048.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 118)
  5049.  
  5050. elseif spell == "Heat Wave" then
  5051.  
  5052.     local posicao = getThingPositionWithDebug(cid)
  5053.  
  5054.     local function hw(params)
  5055.     if isCreature(params.cid) and isSightClear(posicao, params.ar, false) then
  5056.     doAreaCombatHealth(cid, FIREDAMAGE, params.ar, whirl3, -min, -max, 237)
  5057.     end
  5058.     end
  5059.  
  5060.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  5061.  
  5062.     if a == 0 then
  5063.         for b = 0, 4 do
  5064.             addEvent(hw, 200 * b, {cid = cid, ar = {x=posicao.x, y=posicao.y-(b+1), z=posicao.z}})
  5065.         end
  5066.     elseif a == 2 then
  5067.         for b = 0, 4 do
  5068.             addEvent(hw, 200 * b, {cid = cid, ar = {x=posicao.x, y=posicao.y+(b+1), z=posicao.z}})
  5069.         end
  5070.     elseif a == 1 then
  5071.         for b = 0, 4 do
  5072.             addEvent(hw, 200 * b, {cid = cid, ar = {x=posicao.x+(1+b), y=posicao.y, z=posicao.z}})
  5073.         end
  5074.     elseif a == 3 then
  5075.         for b = 0, 4 do
  5076.             addEvent(hw, 200 * b, {cid = cid, ar = {x=posicao.x-(1+b), y=posicao.y, z=posicao.z}})
  5077.         end
  5078.     end
  5079.  
  5080. elseif spell == "Hydro Cannon" then
  5081.  
  5082.     local posicao = getThingPositionWithDebug(cid)
  5083.  
  5084.     local function hp(params)
  5085.     if isCreature(params.cid) and isSightClear(posicao, params.ar, false) then
  5086.     doAreaCombatHealth(cid, WATERDAMAGE, params.ar, whirl3, -min, -max, 68)
  5087.     end
  5088.     end
  5089.  
  5090.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  5091.  
  5092.     if a == 0 then
  5093.         for b = 0, 5 do
  5094.             addEvent(hp, 100 * b, {cid = cid, ar = {x=posicao.x, y=posicao.y-(b+1), z=posicao.z}})
  5095.         end
  5096.     elseif a == 2 then
  5097.         for b = 0, 5 do
  5098.             addEvent(hp, 100 * b, {cid = cid, ar = {x=posicao.x, y=posicao.y+(b+1), z=posicao.z}})
  5099.         end
  5100.     elseif a == 1 then
  5101.         for b = 0, 5 do
  5102.             addEvent(hp, 100 * b, {cid = cid, ar = {x=posicao.x+(1+b), y=posicao.y, z=posicao.z}})
  5103.         end
  5104.     elseif a == 3 then
  5105.         for b = 0, 5 do
  5106.             addEvent(hp, 100 * b, {cid = cid, ar = {x=posicao.x-(1+b), y=posicao.y, z=posicao.z}})
  5107.         end
  5108.     end
  5109.  
  5110. elseif spell == "Frost Attack" then
  5111.  
  5112.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(getMasterTarget(cid)), 28)
  5113.     doAreaCombatHealthAtDistance(cid, ICEDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), bomb, -min, -max, 43)
  5114.  
  5115. elseif spell == "Frost Breath" then
  5116.  
  5117.     local posicao = getThingPositionWithDebug(cid)
  5118.  
  5119.     local function fb(params)
  5120.     if isCreature(params.cid) and isSightClear(posicao, params.ar, false) then
  5121.     doAreaCombatHealth(cid, ICEDAMAGE, params.ar, sand1, -min, -max, 52)
  5122.     end
  5123.     end
  5124.  
  5125.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  5126.  
  5127.     if a == 0 then
  5128.         for b = 0, 5 do
  5129.             addEvent(fb, 120 * b, {cid = cid, ar = {x=posicao.x, y=posicao.y-(b+1), z=posicao.z}})
  5130.         end
  5131.     elseif a == 2 then
  5132.         for b = 0, 5 do
  5133.             addEvent(fb, 120 * b, {cid = cid, ar = {x=posicao.x, y=posicao.y+(b+1), z=posicao.z}})
  5134.         end
  5135.     elseif a == 1 then
  5136.         for b = 0, 5 do
  5137.             addEvent(fb, 120 * b, {cid = cid, ar = {x=posicao.x+(1+b), y=posicao.y, z=posicao.z}})
  5138.         end
  5139.     elseif a == 3 then
  5140.         for b = 0, 5 do
  5141.             addEvent(fb, 120 * b, {cid = cid, ar = {x=posicao.x-(1+b), y=posicao.y, z=posicao.z}})
  5142.         end
  5143.     end
  5144.  
  5145. elseif spell == "Psystrike" then
  5146.  
  5147.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 30)
  5148.     doAreaCombatHealthAtDistance(cid, PSYCHICDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 242)
  5149.  
  5150. elseif spell == "Psycho Flash" then
  5151.  
  5152.     doAreaCombatHealth(cid, PSYCHICDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 136)
  5153.     local rounds = math.random(6, 10)
  5154.     rounds = rounds + math.floor(getPokemonLevel(cid) / 15)
  5155.     doAdvancedBlind(target, rounds, getPlayerStorageValue(target, 3890), 133)
  5156.  
  5157. elseif spell == "Electro Ball" then
  5158.  
  5159.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 40)
  5160.     doAreaCombatHealthAtDistance(cid, ELECTRICDAMAGE, getThingPositionWithDebug(target), bomb, -min, -max, 48)
  5161.  
  5162. elseif spell == "Metal Claw" then
  5163.  
  5164.     doAreaCombatHealth(cid, STEELDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 160)
  5165.  
  5166. elseif spell == "Vital Throw" then
  5167.  
  5168.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 26)
  5169.     doAreaCombatHealth(cid, FIGHTDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 112)
  5170.  
  5171. elseif spell == "Seismic Toss" then
  5172.  
  5173.         local function doHit(cid, target)
  5174.             if not isCreature(target) or not isCreature(cid) then return true end
  5175.         doAreaCombatHealth(cid, SEISMICTOSSDAMAGE, getThingPositionWithDebug(target), 0, -10, -10, 3)
  5176.         end
  5177.  
  5178.         local function doTossFall(cid, frompos, target)
  5179.             if not isCreature(target) or not isCreature(cid) then return true end
  5180.         local pos = getThingPositionWithDebug(target)
  5181.         local ry = math.abs(frompos.y - pos.y)
  5182.         doSendDistanceShoot(frompos, getThingPositionWithDebug(target), 11)
  5183.         addEvent(doHit, ry * 40, cid, target)
  5184.         end
  5185.  
  5186.         local function doTossUp(cid, target)
  5187.             if not isCreature(target) or not isCreature(cid) then return true end
  5188.         local pos = getThingPositionWithDebug(target)
  5189.         local mps = getThingPositionWithDebug(cid)
  5190.         local xrg = math.floor((pos.x - mps.x) / 2)
  5191.         local topos = mps
  5192.         topos.x = topos.x + xrg
  5193.         local rd =  11
  5194.         topos.y = topos.y - rd
  5195.         doSendDistanceShoot(getThingPositionWithDebug(cid), topos, 11)
  5196.         addEvent(doTossFall, rd * 49, cid, topos, target)
  5197.         end    
  5198.  
  5199.     local alvo = getMasterTarget(cid)
  5200.        
  5201.     doTossUp(cid, alvo)
  5202.  
  5203. elseif spell == "Rock Blast" then
  5204.  
  5205.     doAreaCombatHealth(cid, ROCKDAMAGE, getThingPositionWithDebug(cid), rockblast, -min, -max, 255)
  5206.  
  5207.     local pos = getThingPositionWithDebug(cid)
  5208.  
  5209.     local function doSendRock(cid, pos)
  5210.         if not isCreature(cid) then return true end
  5211.     doSendDistanceShoot(getThingPositionWithDebug(cid), pos, 11)
  5212.     addEvent(doSendMagicEffect, getDistanceBetween(getThingPositionWithDebug(cid), pos) * 54, pos, 118)
  5213.     end
  5214.  
  5215.     for a = 1, 120 do
  5216.         local lugar = {x = pos.x + math.random(-4, 4), y = pos.y + math.random(-4, 4), z = pos.z}
  5217.         addEvent(doSendRock, a * 2, cid, lugar)
  5218.     end
  5219.  
  5220. elseif spell == "Submission" then
  5221.  
  5222.     local a = getPosByDir(getThingPositionWithDebug(target), getFaceOpposite(getCreatureLookDir(target)))
  5223.     local b = getClosestFreeTile(cid, a)
  5224.     doTeleportThing(cid, b, false)
  5225.     doSendMagicEffect(getThingPositionWithDebug(cid), 211)
  5226.     doFaceCreature(cid, getThingPositionWithDebug(target))
  5227.     doAreaCombatHealth(cid, FIGHTINGDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 112)
  5228.  
  5229. elseif spell == "Close Combat" then
  5230.  
  5231.     local a = getCreatureSpeed(target)
  5232.     local b = getCreatureSpeed(cid)
  5233.     doTeleportThing(cid, getThingPositionWithDebug(target), false)
  5234.     doSendMagicEffect(getThingPositionWithDebug(cid), 211)
  5235.     doChangeSpeed(cid, -b)
  5236.     doChangeSpeed(target, -a)
  5237.  
  5238.     local function reputSpeed(cid, delta)
  5239.         if not isCreature(cid) then return true end
  5240.         if getCreatureSpeed(cid) > 0 then return true end
  5241.     doChangeSpeed(cid, delta)
  5242.     end
  5243.  
  5244.     local function doCloseCombat(cid, target, finish)
  5245.         if not isCreature(cid) or not isCreature(target) or finish then
  5246.         reputSpeed(cid, b)
  5247.         addEvent(reputSpeed, 400, target, a)
  5248.         return true end
  5249.     doSendMagicEffect(getThingPositionWithDebug(cid), CONST_ME_POFF)
  5250.     doAreaCombatHealth(cid, FIGHTDAMAGE, getThingPositionWithDebug(cid), 0, -min, -max, math.random(112, 113))
  5251.     end
  5252.  
  5253.     for dk = 1, 6 do
  5254.         if dk == 6 then
  5255.             addEvent(doCloseCombat, dk * 175, cid, target, true)
  5256.         else
  5257.             addEvent(doCloseCombat, dk * 175, cid, target)
  5258.         end
  5259.     end
  5260.  
  5261. elseif spell == "Squisky Licking" then
  5262.  
  5263.  
  5264.     local function doLick(cid, target)
  5265.     if not isCreature(cid) or not isCreature(target) then return true end
  5266.     doAreaCombatCondition(cid, getThingPositionWithDebug(target), 0, thunderwavecondition, 255)
  5267.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 145)
  5268.     end
  5269.  
  5270.     for a = 0, 4 do
  5271.         addEvent(doLick, a * 350, cid, target)
  5272.     end
  5273.  
  5274. elseif spell == "Crusher Stomp" then
  5275.  
  5276.     doSendMagicEffect(getThingPositionWithDebug(target), 118)
  5277.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(target), powdersc, -min, -max, 235)
  5278.  
  5279. elseif spell == "Ancient Power" then
  5280.  
  5281. local posicao = getThingPositionWithDebug(cid)
  5282.  
  5283.     local function fireBlast(cid, area1, area2, effect, area3)
  5284.         if not isCreature(cid) then return true end
  5285.         if not isSightClear(posicao, area1, false) then return true end
  5286.         if isSleeping(cid) then return false end
  5287.         if getPlayerStorageValue(cid, 3894) >= 1 then return true end
  5288.         doAreaCombatHealth(cid, null, area1, 0, -min, -max, effect)
  5289.             if area2.x ~= getThingPositionWithDebug(cid).x or area2.y ~= getThingPositionWithDebug(cid).y then
  5290.                 doAreaCombatHealth(cid, null, area2, area3, -min, -max, 137)
  5291.             end
  5292.         doAreaCombatHealth(cid, ROCKDAMAGE, area1, area3, -min, -max, 137)
  5293.     end
  5294.  
  5295.     local m = isCreature(target) and getCreatureDirectionToTarget(cid, target) or getCreatureLookDir(cid)
  5296.  
  5297.     if m == 0 then
  5298.         for a = 0, 5 do
  5299.             addEvent(fireBlast, 300 * a, cid, {x = posicao.x, y = posicao.y - (a + 1), z = posicao.z}, {x = posicao.x, y = posicao.y - a, z = posicao.z}, 18, whirl3)
  5300.         end
  5301.     elseif m == 2 then
  5302.         for a = 0, 5 do
  5303.             addEvent(fireBlast, 300 * a, cid, {x = posicao.x, y = posicao.y + (a + 1), z = posicao.z}, {x = posicao.x, y = posicao.y + a, z = posicao.z}, 18, whirl3)
  5304.         end
  5305.     elseif m == 1 then
  5306.         for a = 0, 5 do
  5307.             addEvent(fireBlast, 300 * a, cid, {x = posicao.x + a + 1, y = posicao.y, z = posicao.z}, {x = posicao.x + a, y = posicao.y, z = posicao.z}, 18, whirl3)
  5308.         end
  5309.     elseif m == 3 then
  5310.         for a = 0, 5 do
  5311.             addEvent(fireBlast, 300 * a, cid, {x = posicao.x - (a + 1), y = posicao.y, z = posicao.z}, {x = posicao.x - a, y = posicao.y, z = posicao.z}, 18, whirl3)
  5312.         end
  5313.     end
  5314.    
  5315. elseif spell == "Water Pledge" then
  5316.  
  5317.     local function doPledge(cid)
  5318.         if not isCreature(cid) then return true end
  5319.     local a = getPosByDir(getThingPositionWithDebug(cid), NORTH)
  5320.     local b = getPosByDir(getThingPositionWithDebug(cid), WEST)
  5321.     local c = getPosByDir(getThingPositionWithDebug(cid), SOUTH)
  5322.     local d = getPosByDir(getThingPositionWithDebug(cid), EAST)
  5323.         doSendDistanceShoot(a, b, 2)
  5324.         doSendDistanceShoot(b, c, 2)
  5325.         doSendDistanceShoot(c, d, 2)
  5326.         doSendDistanceShoot(d, a, 2)
  5327.     doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(cid), splash, -min, -max, 255)
  5328.     end
  5329.  
  5330.     for a = 0, 3 do
  5331.         addEvent(doPledge, a * 215, cid)
  5332.     end
  5333.  
  5334. elseif spell == "Water Oath" then
  5335.  
  5336.     local t = {}
  5337.  
  5338.     for a = 0, 3 do
  5339.         local a = getPosByDir(getThingPositionWithDebug(target), a)
  5340.         table.insert(t, a)
  5341.     end
  5342.  
  5343.     local frompos = getThingPositionWithDebug(target)
  5344.         frompos.y = frompos.y - 4
  5345.  
  5346.     for b = 1, #t do
  5347.         doSendDistanceShoot(frompos, t[b], 2)
  5348.     end
  5349.  
  5350.     doSendDistanceShoot(frompos, getThingPositionWithDebug(target), 2)
  5351.  
  5352.     doAreaCombatHealth(cid, WATERDAMAGE, getThingPositionWithDebug(target), oathzinho, -min, -max, 68)
  5353.  
  5354. elseif spell == "Thrash" then
  5355.  
  5356.     local function doThrash(cid, target, go, turn, pos)
  5357.         if not isCreature(cid) or not isCreature(target) then
  5358.         doRegainSpeed(cid)
  5359.         doRegainSpeed(target)
  5360.         return true
  5361.         end
  5362.         if go then
  5363.             local a = getPosByDir(getThingPositionWithDebug(target), getDirectionTo(getThingPositionWithDebug(cid), getThingPositionWithDebug(target)))
  5364.             doChangeSpeed(cid, -getCreatureSpeed(cid))
  5365.             doChangeSpeed(target, -getCreatureSpeed(target))
  5366.             doChangeSpeed(cid, 800)
  5367.             doTeleportThing(cid, getThingPositionWithDebug(target))
  5368.             doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(getMasterTarget(cid)), 0, -min, -max, 3)
  5369.             doChangeSpeed(cid, -800)
  5370.             addEvent(doThrash, 175, cid, target, false, turn - 1, a)
  5371.         else
  5372.             doChangeSpeed(cid, 800)
  5373.             doTeleportThing(cid, pos)
  5374.             doRegainSpeed(cid)
  5375.             doRegainSpeed(target)
  5376.                 if turn > 0 then
  5377.                     addEvent(doThrash, 175, cid, target, true, turn)
  5378.                 else
  5379.                     doRegainSpeed(cid)
  5380.                     doRegainSpeed(target)
  5381.                     addEvent(doAdvancedConfuse, 350, cid, 4, getPlayerStorageValue(target, 3891))
  5382.                     local b = getThingPositionWithDebug(cid)
  5383.                     addEvent(doSendAnimatedText, 300, b, "CONFUSED", 210)
  5384.                 end
  5385.         end
  5386.     end
  5387.  
  5388.     doThrash(cid, target, true, 3) 
  5389.  
  5390. elseif spell == "Reflect" then
  5391.  
  5392.     doSendMagicEffect(getThingPositionWithDebug(cid), 135)
  5393.  
  5394.     if getPlayerStorageValue(cid, 34) > 0 then
  5395.         setPlayerStorageValue(cid, 34, getPlayerStorageValue(cid, 34) + 9)
  5396.     return true
  5397.     end
  5398.  
  5399.     setPlayerStorageValue(cid, 34, 9)
  5400.  
  5401.     local function doEndReflect(cid)
  5402.         if not isCreature(cid) then return true end
  5403.         if getPlayerStorageValue(cid, 34) == 0 then
  5404.             doSendAnimatedText(getThingPositionWithDebug(cid), "BREAK", 180)
  5405.         return true
  5406.         end
  5407.     setPlayerStorageValue(cid, 34, getPlayerStorageValue(cid, 34) - 1)
  5408.     addEvent(doEndReflect, 500, cid)
  5409.     end
  5410.  
  5411.     addEvent(doEndReflect, 500, cid)
  5412.  
  5413. elseif spell == "Dragon Breath" then
  5414.  
  5415.     local posicao = getThingPositionWithDebug(cid)
  5416.        
  5417.     local function wwind(params)
  5418.     if isCreature(cid) and isSightClear(posicao, params.ar, false) then
  5419.     doAreaCombatHealth(cid, DRAGONDAMAGE, params.ar, params.br, -min, -max, 117)
  5420.     end
  5421.     end
  5422.  
  5423.     local a = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  5424.  
  5425.     if a == 0 then
  5426.         addEvent(wwind, 0, {cid = cid, ar = {x=posicao.x, y=posicao.y-1, z=posicao.z}, br = sand1})
  5427.         addEvent(wwind, 350, {cid = cid, ar = {x=posicao.x, y=posicao.y-2, z=posicao.z}, br = whirl3})
  5428.         addEvent(wwind, 700, {cid = cid, ar = {x=posicao.x, y=posicao.y-3, z=posicao.z}, br = whirl3})
  5429.         addEvent(wwind, 1050, {cid = cid, ar = {x=posicao.x, y=posicao.y-4, z=posicao.z}, br = whirl5})
  5430.         addEvent(wwind, 1400, {cid = cid, ar = {x=posicao.x, y=posicao.y-5, z=posicao.z}, br = whirl5})
  5431.     elseif a == 2 then
  5432.         addEvent(wwind, 0, {cid = cid, ar = {x=posicao.x, y=posicao.y+1, z=posicao.z}, br = sand1})
  5433.         addEvent(wwind, 350, {cid = cid, ar = {x=posicao.x, y=posicao.y+2, z=posicao.z}, br = whirl3})
  5434.         addEvent(wwind, 700, {cid = cid, ar = {x=posicao.x, y=posicao.y+3, z=posicao.z}, br = whirl3})
  5435.         addEvent(wwind, 1050, {cid = cid, ar = {x=posicao.x, y=posicao.y+4, z=posicao.z}, br = whirl5})
  5436.         addEvent(wwind, 1400, {cid = cid, ar = {x=posicao.x, y=posicao.y+5, z=posicao.z}, br = whirl5})
  5437.     elseif a == 1 then
  5438.         addEvent(wwind, 0, {cid = cid, ar = {x=posicao.x+1, y=posicao.y, z=posicao.z}, br = sand1})
  5439.         addEvent(wwind, 350, {cid = cid, ar = {x=posicao.x+2, y=posicao.y, z=posicao.z}, br = whirl32})
  5440.         addEvent(wwind, 700, {cid = cid, ar = {x=posicao.x+3, y=posicao.y, z=posicao.z}, br = whirl32})
  5441.         addEvent(wwind, 1050, {cid = cid, ar = {x=posicao.x+4, y=posicao.y, z=posicao.z}, br = whirl52})
  5442.         addEvent(wwind, 1400, {cid = cid, ar = {x=posicao.x+5, y=posicao.y, z=posicao.z}, br = whirl52})
  5443.     elseif a == 3 then
  5444.         addEvent(wwind, 0, {cid = cid, ar = {x=posicao.x-1, y=posicao.y, z=posicao.z}, br = sand1})
  5445.         addEvent(wwind, 350, {cid = cid, ar = {x=posicao.x-2, y=posicao.y, z=posicao.z}, br = whirl32})
  5446.         addEvent(wwind, 700, {cid = cid, ar = {x=posicao.x-3, y=posicao.y, z=posicao.z}, br = whirl32})
  5447.         addEvent(wwind, 1050, {cid = cid, ar = {x=posicao.x-4, y=posicao.y, z=posicao.z}, br = whirl52})
  5448.         addEvent(wwind, 1400, {cid = cid, ar = {x=posicao.x-5, y=posicao.y, z=posicao.z}, br = whirl52})
  5449.     end
  5450.  
  5451. elseif spell == "Flare Blitz" then
  5452.  
  5453.     doAreaCombatHealth(cid, FIREDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 6)
  5454.  
  5455. elseif spell == "Seed Bomb" then
  5456.  
  5457.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 1)
  5458.     doAreaCombatHealthAtDistance(cid, GRASSDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 45)
  5459.  
  5460. elseif spell == "Magical Leaves" then
  5461.  
  5462.     local function doIt(cid, target, x, y)
  5463.         if not isCreature(cid) or not isCreature(target) then return true end
  5464.         local a = getThingPositionWithDebug(target)
  5465.         local pos = {x = a.x + x, y = a.y + y, z = a.z}
  5466.         doAreaCombatHealth(cid, GRASSDAMAGE, pos, 0, -min, -max, 255)
  5467.         doSendDistanceShoot({x = pos.x, y = pos.y - 1, z = pos.z}, {x = pos.x - 1, y = pos.y, z = pos.z}, 21)
  5468.         doSendDistanceShoot({x = pos.x - 1, y = pos.y, z = pos.z}, {x = pos.x, y = pos.y + 1, z = pos.z}, 21)
  5469.         doSendDistanceShoot({x = pos.x, y = pos.y + 1, z = pos.z}, {x = pos.x + 1, y = pos.y, z = pos.z}, 21)
  5470.         doSendDistanceShoot({x = pos.x + 1, y = pos.y, z = pos.z}, {x = pos.x, y = pos.y - 1, z = pos.z}, 21)
  5471.     end
  5472.  
  5473.     local regions = {
  5474.     [1] = {-1, 0},
  5475.     [2] = {0, -1},
  5476.     [3] = {1, 0},
  5477.     [4] = {0, 1},
  5478.     [5] = {0, 0}}
  5479.  
  5480.     local function doHurt(cid, target)
  5481.     doMagicalFlower(target, true)
  5482.     for tk = 1, 5 do
  5483.         for a = 0, 2 do
  5484.             addEvent(doIt, a * 185, cid, target, regions[tk][1], regions[tk][2])
  5485.             if a == 2 then
  5486.                 addEvent(doMagicalFlower, a * 184, target)
  5487.             end
  5488.         end
  5489.     end
  5490.     end
  5491.  
  5492.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 21)
  5493.     addEvent(doHurt, getDistanceBetween(getThingPositionWithDebug(cid), getThingPositionWithDebug(target)) * 60, cid, target)
  5494.  
  5495. elseif spell == "Tidal Wave" then
  5496.  
  5497.     local posicao = getThingPositionWithDebug(cid)
  5498.  
  5499.     local function doSurf(cid, area1, area2, effect)
  5500.         if not isCreature(cid) then return true end
  5501.         if not isSightClear(posicao, area1, false) then return true end
  5502.         doAreaCombatHealth(cid, null, area1, whirl5, -min, -max, effect)
  5503.             if area2.x ~= getThingPositionWithDebug(cid).x or area2.y ~= getThingPositionWithDebug(cid).y then
  5504.                 doAreaCombatHealth(cid, null, area2, whirl5, -min, -max, 68)
  5505.             end
  5506.         doAreaCombatHealth(cid, WATERDAMAGE, area1, whirl5, -min, -max, 68)
  5507.     end
  5508.  
  5509.     local n = isCreature(getMasterTarget(cid)) and getCreatureDirectionToTarget(cid, getMasterTarget(cid)) or getCreatureLookDir(cid)
  5510.  
  5511.     if n == 0 then
  5512.         for a = 0, 6 do
  5513.             addEvent(doSurf, 300 * a, cid, {x = posicao.x, y = posicao.y - (a + 1), z = posicao.z}, {x = posicao.x, y = posicao.y - a, z = posicao.z}, 66)
  5514.         end
  5515.     elseif n == 2 then
  5516.         for a = 0, 6 do
  5517.             addEvent(doSurf, 300 * a, cid, {x = posicao.x, y = posicao.y + (a + 1), z = posicao.z}, {x = posicao.x, y = posicao.y + a, z = posicao.z}, 64)
  5518.         end
  5519.     elseif n == 1 then
  5520.         for a = 0, 6 do
  5521.             addEvent(doSurf, 300 * a, cid, {x = posicao.x + a + 1, y = posicao.y, z = posicao.z}, {x = posicao.x + a, y = posicao.y, z = posicao.z}, 67)
  5522.         end
  5523.     elseif n == 3 then
  5524.         for a = 0, 6 do
  5525.             addEvent(doSurf, 300 * a, cid, {x = posicao.x - (a + 1), y = posicao.y, z = posicao.z}, {x = posicao.x - a, y = posicao.y, z = posicao.z}, 65)
  5526.         end
  5527.     end
  5528.  
  5529. elseif spell == "Epicenter" then
  5530.  
  5531.     local function doShake(cid, pos)
  5532.         if not isCreature(cid) then return true end
  5533.         doAreaCombatHealth(cid, GROUNDDAMAGE, pos, 0, -min, -max, 255)
  5534.         doSendMagicEffect({x=pos.x+1,y=pos.y+1,z=pos.z}, 127)
  5535.     end
  5536.  
  5537.     local function getDifBetween(pos1, pos2)
  5538.         local a = pos1.x - pos2.x
  5539.         local b = pos1.y - pos2.y
  5540.         return math.abs(a) + math.abs(b)
  5541.     end
  5542.  
  5543.     local t = {}
  5544.  
  5545.     for x = -6, 6 do
  5546.         for y = -6, 6 do
  5547.         local a = getThingPositionWithDebug(cid)
  5548.         a.x = a.x + x
  5549.         a.y = a.y + y
  5550.         table.insert(t, a)
  5551.         end
  5552.     end
  5553.  
  5554.  
  5555.     local pos = getThingPositionWithDebug(cid)
  5556.     local delay = 0
  5557.  
  5558.     for go = 1, #t do
  5559.         if getDirectionTo(pos, t[go]) <= 3 then
  5560.             delay = 0
  5561.         else
  5562.             if math.abs(t[go].x - pos.x) == math.abs(t[go].y - pos.y) then
  5563.                 delay = 300
  5564.             else
  5565.                 delay = 450
  5566.             end
  5567.         end
  5568.         if delay >= 0  then
  5569.         addEvent(doShake, getDistanceBetween(pos, t[go]) * 120 + delay, cid, t[go])
  5570.         end
  5571.     end
  5572.  
  5573. elseif spell == "Stone Edge" then
  5574.  
  5575.     local signal = {
  5576.     [NORTH] = {1, 0},
  5577.     [SOUTH] = {1, 0},
  5578.     [EAST] = {0, 1},
  5579.     [WEST] = {0, 1},
  5580.     [NORTHEAST] = {-1, -1},
  5581.     [NORTHWEST] = {1, -1},
  5582.     [SOUTHEAST] = {-1, 1}, 
  5583.     [SOUTHWEST] = {-1, -1}}
  5584.  
  5585.     local a = getDirectionTo(getThingPositionWithDebug(cid), getThingPositionWithDebug(target))
  5586.     local pos1 = getThingPositionWithDebug(target)
  5587.     local pos2 = getThingPositionWithDebug(target)
  5588.     pos1.x = pos1.x + signal[a][1] * 5
  5589.     pos1.y = pos1.y + signal[a][2] * 5
  5590.     pos2.x = pos2.x + signal[a][1] * -5
  5591.     pos2.y = pos2.y + signal[a][2] * -5
  5592.  
  5593.     doSendDistanceShoot(pos1, getThingPositionWithDebug(target), 11)
  5594.     doSendDistanceShoot(pos2, getThingPositionWithDebug(target), 11)
  5595.  
  5596.     local function doDamage(cid, target)
  5597.         if not isCreature(cid) or not isCreature(target) then return true end
  5598.     doAreaCombatHealth(cid, ROCKDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 44)
  5599.     end
  5600.  
  5601.     addEvent(doDamage, 300, cid, target)
  5602.    
  5603. elseif spell == "Night Shade" then
  5604.  
  5605.     doSendDistanceShoot(getThingPositionWithDebug(cid), getThingPositionWithDebug(target), 18)
  5606.     doAreaCombatHealthAtDistance(cid, GHOSTDAMAGE, getThingPositionWithDebug(target), star, -min, -max, 208)
  5607.  
  5608. elseif spell == "Razor Wind" then
  5609.  
  5610.     local signal = {
  5611.     [NORTH] = {0, -1},
  5612.     [SOUTH] = {0, 1},
  5613.     [EAST] = {1, 0},
  5614.     [WEST] = {-1, 0},
  5615.     [NORTHEAST] = {1, -1},
  5616.     [NORTHWEST] = {-1, -1},
  5617.     [SOUTHEAST] = {1, 1},  
  5618.     [SOUTHWEST] = {-1, 1}}
  5619.  
  5620.     local a = isCreature(target) and getDirectionTo(getThingPositionWithDebug(cid), getThingPositionWithDebug(target)) or getCreatureLookDir(cid)
  5621.     local t = {}
  5622.  
  5623.     for b = 1, 5 do
  5624.         local pos = getThingPositionWithDebug(cid)
  5625.         pos.x = pos.x + signal[a][1] * b
  5626.         pos.y = pos.y + signal[a][2] * b
  5627.             if canWalkOnPos(pos, false, true, true, true, false) and isSightClear(getThingPositionWithDebug(cid), pos, false) then
  5628.                 table.insert(t, pos)
  5629.             end
  5630.     end
  5631.  
  5632.     if #t <= 0 then
  5633.         doAreaCombatHealth(cid, FLYINGDAMAGE, getPosByDir(getThingPositionWithDebug(cid), a), 0, -min, -max, 42)
  5634.     return true
  5635.     end
  5636.  
  5637.     local effect = 27
  5638.  
  5639.     if not getCreatureCondition(cid, CONDITION_OUTFIT) and getCreatureOutfit(cid).lookType ~= 366 then
  5640.         effect = 29
  5641.     end
  5642.  
  5643.     doSendDistanceShoot(getThingPositionWithDebug(cid), t[#t], effect)
  5644.  
  5645.     local function doRazorWind(cid, pos)
  5646.         if not isCreature(cid) then return true end
  5647.         if not getCreatureCondition(cid, CONDITION_INVISIBLE) then return true end
  5648.         doAreaCombatHealth(cid, FLYINGDAMAGE, pos, 0, -min, -max, 42)
  5649.     end
  5650.  
  5651.     local function doAppear(cid, pos)
  5652.         if not isCreature(cid) then return true end
  5653.     doRemoveCondition(cid, CONDITION_INVISIBLE)
  5654.     doTeleportThing(cid, pos, false)
  5655.     end
  5656.  
  5657.     doCreatureAddCondition(cid, permanentinvisible)
  5658.  
  5659.     for c = 1, #t do
  5660.         addEvent(doRazorWind, 65 * c, cid, t[c])
  5661.     end
  5662.         addEvent(doAppear, (90 - (#t * 6)) * #t, cid, t[#t])
  5663.    
  5664. elseif spell == "Swords Dance" then
  5665.  
  5666.     local function doWingAttack(cid, a, damage)
  5667.         local damagearea = {}
  5668.         local effectpos = getThingPositionWithDebug(cid)
  5669.         local effect = 255
  5670.     if a == 0 then
  5671.         effect = 128
  5672.         effectpos.x = effectpos.x + 1
  5673.         effectpos.y = effectpos.y - 1
  5674.         damagearea = wingdn
  5675.     elseif a == 1 then
  5676.         effectpos.x = effectpos.x + 2
  5677.         effectpos.y = effectpos.y + 1
  5678.         effect = 129
  5679.         damagearea = wingde
  5680.     elseif a == 2 then
  5681.         effectpos.x = effectpos.x + 1
  5682.         effectpos.y = effectpos.y + 2
  5683.         effect = 131
  5684.         damagearea = wingds
  5685.     elseif a == 3 then
  5686.         effectpos.x = effectpos.x - 1
  5687.         effectpos.y = effectpos.y + 1
  5688.         effect = 130
  5689.         damagearea = wingdw
  5690.     end
  5691.         doSendMagicEffect(effectpos, effect)
  5692.         if damage then
  5693.         doAreaCombatHealth(cid, FLYINGDAMAGE, getThingPositionWithDebug(cid), damagearea, -min, -max, CONST_ME_NONE)
  5694.         end
  5695.     end
  5696.  
  5697.     local dire = getCreatureLookDir(cid)
  5698.     local cpos = getThingPositionWithDebug(cid)
  5699.     local outfit = {}
  5700.         outfit.lookType = 496
  5701.  
  5702.     if getCreatureOutfit(cid).lookType ~= 366 then
  5703.         outfit.lookType = 849
  5704.     end
  5705.  
  5706.     doSetCreatureOutfit(cid, outfit, -1)
  5707.  
  5708.     local function doDance(cid, dir, damage)
  5709.         if not isCreature(cid) then return true end
  5710.     doCreatureSetLookDir(cid, dir)
  5711.     doWingAttack(cid, dir, damage)
  5712.     end
  5713.  
  5714.     for times = 0, 20 do
  5715.         for directions = 0, 3 do
  5716.             addEvent(doDance, times * 300, cid, directions, true)
  5717.         end
  5718.     end
  5719.  
  5720.     local function doChangeO(cid, dir, pos)
  5721.     if not isCreature(cid) then return true end
  5722.     doRemoveCondition(cid, CONDITION_OUTFIT)
  5723.         if getThingPositionWithDebug(cid).x == pos.x and getThingPositionWithDebug(cid).y == pos.y then
  5724.             doCreatureSetLookDir(cid, dir)
  5725.         end
  5726.     end
  5727.  
  5728.     addEvent(doChangeO, 20 * 300 + 10, cid, dire, cpos)
  5729.  
  5730. elseif spell == "Dance Scizor" then
  5731.  
  5732.     local function doWingAttack(cid, a, damage)
  5733.         local damagearea = {}
  5734.         local effectpos = getThingPositionWithDebug(cid)
  5735.         local effect = 255
  5736.     if a == 0 then
  5737.         effect = 236
  5738.         effectpos.x = effectpos.x + 1
  5739.         effectpos.y = effectpos.y - 1
  5740.         damagearea = wingdn
  5741.     elseif a == 1 then
  5742.         effectpos.x = effectpos.x + 2
  5743.         effectpos.y = effectpos.y + 1
  5744.         effect = 232
  5745.         damagearea = wingde
  5746.     elseif a == 2 then
  5747.         effectpos.x = effectpos.x + 1
  5748.         effectpos.y = effectpos.y + 2
  5749.         effect = 233
  5750.         damagearea = wingds
  5751.     elseif a == 3 then
  5752.         effectpos.x = effectpos.x - 1
  5753.         effectpos.y = effectpos.y + 1
  5754.         effect = 224
  5755.         damagearea = wingdw
  5756.     end
  5757.         doSendMagicEffect(effectpos, effect)
  5758.         if damage then
  5759.         doAreaCombatHealth(cid, FLYINGDAMAGE, getThingPositionWithDebug(cid), damagearea, -min, -max, CONST_ME_NONE)
  5760.         end
  5761.     end
  5762.  
  5763.     local dire = getCreatureLookDir(cid)
  5764.     local cpos = getThingPositionWithDebug(cid)
  5765.     local outfit = {}
  5766.         outfit.lookType = 496
  5767.  
  5768.     if getCreatureOutfit(cid).lookType ~= 366 then
  5769.         outfit.lookType = 918
  5770.     end
  5771.  
  5772.     doSetCreatureOutfit(cid, outfit, -1)
  5773.  
  5774.     local function doDance(cid, dir, damage)
  5775.         if not isCreature(cid) then return true end
  5776.     doCreatureSetLookDir(cid, dir)
  5777.     doWingAttack(cid, dir, damage)
  5778.     end
  5779.  
  5780.     for times = 0, 20 do
  5781.         for directions = 0, 3 do
  5782.             addEvent(doDance, times * 300, cid, directions, true)
  5783.         end
  5784.     end
  5785.  
  5786.     local function doChangeO(cid, dir, pos)
  5787.     if not isCreature(cid) then return true end
  5788.     doRemoveCondition(cid, CONDITION_OUTFIT)
  5789.         if getThingPositionWithDebug(cid).x == pos.x and getThingPositionWithDebug(cid).y == pos.y then
  5790.             doCreatureSetLookDir(cid, dir)
  5791.         end
  5792.     end
  5793.  
  5794.     addEvent(doChangeO, 20 * 300 + 10, cid, dire, cpos)
  5795.  
  5796. elseif spell == "Rest" then
  5797.  
  5798.     local function doRecoverOverTime(cid, turn)
  5799.         if not isCreature(cid) then return true end
  5800.         if not isSleeping(cid) then return true end
  5801.         if turn > 100 then return true end
  5802.         local percent = math.floor(getCreatureMaxHealth(cid) / 100)
  5803.         doCreatureAddHealth(cid, percent)
  5804.         addEvent(doRecoverOverTime, 100, cid, turn + 1)
  5805.     end
  5806.  
  5807.     doSleep(cid, 12, true)
  5808.     doRecoverOverTime(cid, 0)
  5809.  
  5810. elseif spell == "Stickslash" then
  5811.  
  5812.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 212)
  5813.    
  5814. elseif spell == "Elemental Hands" then
  5815.  
  5816. if getCreatureOutfit(cid).lookType == 1301 then
  5817. return doPlayerSendTextMessage(getCreatureMaster(cid), MESSAGE_STATUS_CONSOLE_BLUE, "Your pokemon doesn't recognize this move.")
  5818. end        --proteçao pra n usar o move com o shiny hitmonchan com outfit diferente da do elite monchan do PO...
  5819.  
  5820. local e = getCreatureMaster(cid)
  5821. local name = getItemAttribute(getPlayerSlotItem(e, 8).uid, "poke")
  5822. local hands = getItemAttribute(getPlayerSlotItem(e, 8).uid, "hands")
  5823.  
  5824.        if hands == 4 then
  5825.        doItemSetAttribute(getPlayerSlotItem(e, 8).uid, "hands", 0)
  5826.        doSendMagicEffect(getThingPositionWithDebug(cid), hitmonchans[name][0].eff)
  5827.        doSetCreatureOutfit(cid, {lookType = hitmonchans[name][0].out}, -1)
  5828.        else
  5829.        doItemSetAttribute(getPlayerSlotItem(e, 8).uid, "hands", hands+1)
  5830.        doSendMagicEffect(getThingPositionWithDebug(cid), hitmonchans[name][hands+1].eff)
  5831.        doSetCreatureOutfit(cid, {lookType = hitmonchans[name][hands+1].out}, -1)
  5832.        end
  5833.  
  5834. elseif spell == "Stickmerang" then
  5835.  
  5836.     local pos = getThingPositionWithDebug(cid)
  5837.     local b = isCreature(getMasterTarget(cid)) and getDirectionTo(getThingPositionWithDebug(cid), getThingPositionWithDebug(target)) or getCreatureLookDir(cid)
  5838.     local t = {}
  5839.  
  5840.     local signal = {
  5841.     [NORTH] = {0,  -1},
  5842.     [SOUTH] = {0,  1},
  5843.     [EAST] = {1,  0},
  5844.     [WEST] = {-1,  0},
  5845.     [SOUTHEAST] = {1,  1},
  5846.     [SOUTHWEST] = {-1,  1},
  5847.     [NORTHWEST] = {-1,  -1},
  5848.     [NORTHEAST] = {1,  -1}}
  5849.  
  5850.     for range = 1, 5 do
  5851.         local add = getThingPositionWithDebug(cid)
  5852.         add.x = add.x + signal[b][1] * range
  5853.         add.y = add.y + signal[b][2] * range
  5854.         table.insert(t, add)
  5855.     end
  5856.  
  5857.         local function doBoomerang(cid, pos)
  5858.             if not isCreature(cid) then return true end
  5859.         doAreaCombatHealth(cid, NORMALDAMAGE, pos, 0, -min, -max, 212)
  5860.         end
  5861.  
  5862.     for throw = 1, 5 do
  5863.         addEvent(doBoomerang, (throw - 1) * 200, cid, t[throw])
  5864.     end
  5865.  
  5866.     for back = -5, -1 do
  5867.         local k = -back
  5868.         addEvent(doBoomerang, math.abs(k - 5) * 200 + 1000, cid, t[k])
  5869.     end
  5870.  
  5871. elseif spell == "Comet Punch" then
  5872.  
  5873.     local pos = getThingPositionWithDebug(target)
  5874.     pos.y = pos.y - 5
  5875.     doSendDistanceShoot(pos, getThingPositionWithDebug(target), 26)
  5876.  
  5877.     local function doPunchie(cid, target)
  5878.         if not isCreature(cid) or not isCreature(target) then return true end
  5879.         doAreaCombatHealth(cid, FIGHTDAMAGE, getThingPositionWithDebug(target), 0, -min, -max, 3)
  5880.     end
  5881.  
  5882.     addEvent(doPunchie, const_distance_delay * 5, cid, target)
  5883. end
  5884. return true
  5885. end
Advertisement
Add Comment
Please, Sign In to add comment