Guest User

Untitled

a guest
Feb 3rd, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.69 KB | None | 0 0
  1. local AREA_CROSS6X6 = {
  2.     {0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
  3.     {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0},
  4.     {0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0},
  5.     {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0},
  6.     {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},
  7.     {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
  8.     {1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1},
  9.     {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
  10.     {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},
  11.     {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0},
  12.     {0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0},
  13.     {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0},
  14.     {0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}
  15. }
  16.  
  17. function getPosByArea(area, topleftpos)
  18.     arr = {}
  19.     for y, a in pairs(area) do
  20.         arr[y] = {}
  21.         for x, tile in pairs(a) do
  22.             if isInArray({1,3}, tile) then
  23.             arr[y][x] = {x=(x-1)+topleftpos.x, y=(y-1)+topleftpos.y, z=topleftpos.z}
  24.             end
  25.         end
  26.     end
  27.     return arr
  28. end
  29.  
  30. function onCastSpell(cid, var)
  31. for _,pos in ipairs(getPosByArea(AREA_CROSS6X6), getThingPos(cid)) do
  32.     local f, formula = (getPlayerLevel(cid) + getPlayerMagLevel(cid))*2.5, math.random(f*0.9,f*1.1)
  33.     doSendMagicEffect(pos, CONST_ME_FIREAREA)
  34.     if isCreature(getThingFromPos(pos).uid) then
  35.         if isPlayer(getThingFromPos(pos).uid) then
  36.             doTargetCombatHealth(cid, getThingFromPos(pos).uid, COMBAT_PHYSICALDAMAGE, -formula, -formula, CONST_ME_NONE)
  37.         elseif isMonster(getThingFromPos(pos).uid) then
  38.             doCreatureAddHealth(getThingFromPos(pos).uid, getCreatureHealth(getThingFromPos(pos).uid) >= formula and -formula or getCreatureHealth(getThingFromPos(pos).uid))
  39.         end
  40.         doSendAnimatedText(pos, getCreatureHealth(getThingFromPos(pos).uid) >= formula and formula or getCreatureHealth(getThingFromPos(pos).uid), TEXTCOLOR_RED)
  41.     end
  42. end
  43. return true
  44. end
Advertisement
Add Comment
Please, Sign In to add comment