TFS 1.X+ Spell collision system

Discussion in 'Support' started by Decodde, Oct 9, 2018.

  1. Decodde

    Decodde New Member

    Joined:
    Oct 8, 2018
    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trying update the spell collision system made by ramza, to work with tfs 1.3


    spells.lua
    Code (Text):
    1. function checkColision(cid)   -- Function by Ramza (Ricardo Ianelli)
    2.   if getCreatureTarget(cid) ~= 0 then
    3.      setPlayerStorageValue(cid, 9001, 'casting')
    4.    
    5.  
    6.      local ppos, enemy = getCreaturePosition(cid), getCreatureTarget(cid)
    7.      local epos = getCreaturePosition(enemy)
    8.    
    9.  
    10.      if getPlayerStorageValue(enemy, 9001) == 'casting' and getCreatureTarget(enemy) == cid then
    11.         setPlayerStorageValue(enemy, 9001, 'colision')
    12.         setPlayerStorageValue(cid, 9001, 'colision')
    13.         if ppos.x > epos.x and ppos.y > epos.y then
    14.            cpos = {x = ppos.x - ((ppos.x - epos.x) / 2), y = ppos.y - ((ppos.y - epos.y) / 2), z = ppos.z}
    15.         elseif ppos.x > epos.x and ppos.y < epos.y then
    16.            cpos = {x = ppos.x - ((ppos.x - epos.x) / 2), y = epos.y - ((epos.y - ppos.y) / 2), z = ppos.z}
    17.         elseif ppos.x < epos.x and ppos.y < epos.y then
    18.            cpos = {x = epos.x - ((epos.x - ppos.x) / 2), y = epos.y - ((epos.y - ppos.y) / 2), z = ppos.z}
    19.         elseif ppos.x < epos.x and ppos.y > epos.y then
    20.            cpos = {x = epos.x - ((epos.x - ppos.x) / 2), y = ppos.y - ((ppos.y - epos.y) / 2), z = ppos.z}
    21.         end
    22.      
    23.         doSendDistanceShoot(ppos, cpos, CONST_ANI_ENERGY)
    24.         doSendDistanceShoot(epos, cpos, CONST_ANI_ENERGYBALL)
    25.        
    26.         local value = math.random(1, 3)
    27.         doSendMagicEffect(cpos, 27+value)            
    28.         return true
    29.      else
    30.         return false
    31.      end
    32.   end
    33.  
    34. end

    death_strike.lua
    Code (Text):
    1. local combat = Combat()
    2. combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
    3. combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
    4. combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
    5. combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)
    6.  
    7.  
    8. local function spell(cid, var)
    9.   if getPlayerStorageValue(cid, 9001) ~= 'colision' then
    10.      doCreatureSay(cid, 'Strike!', TALKTYPE_ORANGE_1)
    11.      setPlayerStorageValue(cid, 9001, nil)
    12.      return doCombat(cid, combat, var)
    13.   end
    14. end
    15.  
    16.  
    17. function onCastSpell(cid, var)
    18.     checkColision(cid)
    19.     doCreatureSay(cid, 'Energy...', TALKTYPE_ORANGE_1)
    20.     addEvent(spell, 2000, cid, var)
    21. end

    Got that error on console each time i cast the spell:
    wt.png
     
  2. Bogart

    Bogart ...has super panda powers

    Joined:
    Jun 21, 2009
    Messages:
    7,974
    Likes Received:
    538
    Best Answers:
    21
    Code (Lua):
    1. local combat = Combat()
    2. combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
    3. combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
    4. combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
    5. combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)
    6.  
    7.  
    8. local function spell(cid, var)
    9.     if Player(cid) then
    10.         if getPlayerStorageValue(cid, 9001) ~= 'colision' then
    11.             doCreatureSay(cid, 'Strike!', TALKTYPE_ORANGE_1)
    12.             setPlayerStorageValue(cid, 9001, nil)
    13.             return doCombat(cid, combat, var)
    14.         end
    15.     end
    16. end
    17.  
    18.  
    19. function onCastSpell(cid, var)
    20.     checkColision(cid)
    21.     doCreatureSay(cid, 'Energy...', TALKTYPE_ORANGE_1)
    22.     addEvent(spell, 2000, Player(cid):getId(), var)
    23. end
     
    Last edited: Oct 9, 2018
  3. Westwol

    Westwol New Member

    Joined:
    Sep 19, 2018
    Messages:
    15
    Likes Received:
    4
    Best Answers:
    0
    Storages in TFS 1.3 does not work with strings anymore.
     
  4. Decodde

    Decodde New Member

    Joined:
    Oct 8, 2018
    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    @Bogart


    I edit to your code, and stopped the errors in console, but the spell not working as intended:


    The original script they colide
     
  5. Bogart

    Bogart ...has super panda powers

    Joined:
    Jun 21, 2009
    Messages:
    7,974
    Likes Received:
    538
    Best Answers:
    21
    Code (Text):
    1.  
    2. local casting = 1
    3. local colision = 2
    4.  
    5. function checkColision(cid)   -- Function by Ramza (Ricardo Ianelli)
    6.   if getCreatureTarget(cid) ~= 0 then
    7.      setPlayerStorageValue(cid, 9001, casting)
    8.    
    9.  
    10.      local ppos, enemy = getCreaturePosition(cid), getCreatureTarget(cid)
    11.      local epos = getCreaturePosition(enemy)
    12.    
    13.  
    14.      if getPlayerStorageValue(enemy, 9001) == casting and getCreatureTarget(enemy) == cid then
    15.         setPlayerStorageValue(enemy, 9001, colision)
    16.         setPlayerStorageValue(cid, 9001, colision)
    17.         if ppos.x > epos.x and ppos.y > epos.y then
    18.            cpos = {x = ppos.x - ((ppos.x - epos.x) / 2), y = ppos.y - ((ppos.y - epos.y) / 2), z = ppos.z}
    19.         elseif ppos.x > epos.x and ppos.y < epos.y then
    20.            cpos = {x = ppos.x - ((ppos.x - epos.x) / 2), y = epos.y - ((epos.y - ppos.y) / 2), z = ppos.z}
    21.         elseif ppos.x < epos.x and ppos.y < epos.y then
    22.            cpos = {x = epos.x - ((epos.x - ppos.x) / 2), y = epos.y - ((epos.y - ppos.y) / 2), z = ppos.z}
    23.         elseif ppos.x < epos.x and ppos.y > epos.y then
    24.            cpos = {x = epos.x - ((epos.x - ppos.x) / 2), y = ppos.y - ((ppos.y - epos.y) / 2), z = ppos.z}
    25.         end
    26.      
    27.         doSendDistanceShoot(ppos, cpos, CONST_ANI_ENERGY)
    28.         doSendDistanceShoot(epos, cpos, CONST_ANI_ENERGYBALL)
    29.        
    30.         local value = math.random(1, 3)
    31.         doSendMagicEffect(cpos, 27+value)          
    32.         return true
    33.      else
    34.         return false
    35.      end
    36.   end
    37.  
    38. end
    39.  
    40. local combat = Combat()
    41. combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
    42. combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
    43. combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
    44. combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)
    45.  
    46.  
    47. local function spell(cid, var)
    48.   if getPlayerStorageValue(cid, 9001) ~= 2 then
    49.      doCreatureSay(cid, 'Strike!', TALKTYPE_ORANGE_1)
    50.      setPlayerStorageValue(cid, 9001, 0)
    51.      return doCombat(cid, combat, var)
    52.   end
    53. end
    54.  
    55.  
    56. function onCastSpell(cid, var)
    57.     checkColision(cid)
    58.     doCreatureSay(cid, 'Energy...', TALKTYPE_ORANGE_1)
    59.     addEvent(spell, 2000, cid.uid, var)
    60. end
     
  6. Decodde

    Decodde New Member

    Joined:
    Oct 8, 2018
    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    @Bogart hey bro thank ya for the help but still not working, i changed to the code you post

    energy_strike.lua
    Code (Text):
    1. local combat = Combat()
    2. combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
    3. combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
    4. combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
    5. combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)
    6. local function spell(cid, var)
    7.   if getPlayerStorageValue(cid, 9001) ~= 2 then
    8.      doCreatureSay(cid, 'Strike!', TALKTYPE_ORANGE_1)
    9.      setPlayerStorageValue(cid, 9001, 0)
    10.      return doCombat(cid, combat, var)
    11.   end
    12. end
    13. function onCastSpell(cid, var)
    14.     checkColision(cid)
    15.     doCreatureSay(cid, 'Energy...', TALKTYPE_ORANGE_1)
    16.     addEvent(spell, 2000, cid.uid, var)
    17. end
    spells.lua
     

    Attached Files:

    Last edited: Oct 9, 2018
  7. Decodde

    Decodde New Member

    Joined:
    Oct 8, 2018
    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0

Share This Page

Loading...