Need Help converting two old spells to tfs 1.2

Discussion in 'Support' started by Lopaskurwa, Sep 23, 2018.

  1. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    465
    Likes Received:
    12
    Best Answers:
    2
  2. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    465
    Likes Received:
    12
    Best Answers:
    2
  3. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    465
    Likes Received:
    12
    Best Answers:
    2
    b u m p
     
  4. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    465
    Likes Received:
    12
    Best Answers:
    2
  5. Sarah Wesker

    Sarah Wesker S.E ©

    Joined:
    Mar 16, 2017
    Messages:
    296
    Likes Received:
    133
    Best Answers:
    20
    Spell 1
    Code (Text):
    1.  
    2. local combat = Combat()
    3. combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
    4. combat:setParameter(COMBAT_PARAM_EFFECT, 10)
    5. combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 3)
    6. function onGetFormulaValues(player, level, maglevel)
    7.     local min = (level / 5) + (maglevel * 5.5) + 25
    8.     local max = (level / 5) + (maglevel * 11) + 50
    9.     return -min, -max
    10. end
    11.  
    12. combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
    13.  
    14. local repeatCombats = 5
    15. local executeSpell = function(cid, variant)
    16.     local creature = Creature(cid)
    17.     if creature then
    18.         combat:execute(creature, variant)
    19.     end
    20. end
    21.  
    22. function onCastSpell(creature, variant)
    23.     local ret = combat:execute(creature, variant)
    24.     if ret then
    25.         for current = 1, (repeatCombats-1) do
    26.             addEvent(executeSpell, 300 * current, creature:getId(), variant)
    27.         end
    28.     end
    29.     return ret
    30. end
    31.  
     
    Last edited: Oct 1, 2018
    Lopaskurwa likes this.
  6. StreamSide

    StreamSide Joseluis Gonzalez

    Joined:
    Aug 31, 2007
    Messages:
    2,977
    Likes Received:
    672
    Best Answers:
    17
    this will only execute it one time or nay? maybe I do not understand spells at all
     
    Lopaskurwa and Sarah Wesker like this.
  7. Sarah Wesker

    Sarah Wesker S.E ©

    Joined:
    Mar 16, 2017
    Messages:
    296
    Likes Received:
    133
    Best Answers:
    20
  8. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    465
    Likes Received:
    12
    Best Answers:
    2
    Works fine but doesnt do any dmg tho ;D
     
    Sarah Wesker likes this.
  9. Sarah Wesker

    Sarah Wesker S.E ©

    Joined:
    Mar 16, 2017
    Messages:
    296
    Likes Received:
    133
    Best Answers:
    20
    Lopaskurwa likes this.
  10. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    465
    Likes Received:
    12
    Best Answers:
    2
  11. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    465
    Likes Received:
    12
    Best Answers:
    2
  12. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    465
    Likes Received:
    12
    Best Answers:
    2
  13. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    465
    Likes Received:
    12
    Best Answers:
    2
  14. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    465
    Likes Received:
    12
    Best Answers:
    2
  15. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    465
    Likes Received:
    12
    Best Answers:
    2
  16. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    465
    Likes Received:
    12
    Best Answers:
    2
  17. Lopaskurwa

    Lopaskurwa Member

    Joined:
    Oct 6, 2017
    Messages:
    465
    Likes Received:
    12
    Best Answers:
    2
    After a lot of tutorial i managed to understand spells. So i finally made it.
    If you want to use it.
    Code (Lua):
    1.  
    2. local combat = Combat()
    3. combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
    4. combat:setArea(createCombatArea(AREA_BEAMFOUR))
    5.  
    6. function onGetFormulaValues(cid, level, maglevel)
    7.     min = -((level / 5) + (maglevel * 1.8) + 11)
    8.     max = -((level / 5) + (maglevel * 3) + 19)
    9.     return min, max
    10. end
    11.  
    12. combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
    13.  
    14. function onCastSpell(cid, var)
    15.     local player = Player(cid)
    16.     local playerPos = player:getPosition()
    17.     local playerDir = player:getDirection()
    18.  
    19.     if playerDir == NORTH then
    20.         Position(playerPos.x + 2, playerPos.y - 1, playerPos.z):sendMagicEffect(243)
    21.     elseif playerDir == SOUTH then
    22.         Position(playerPos.x + 2, playerPos.y + 5, playerPos.z):sendMagicEffect(243)
    23.     elseif playerDir == WEST then
    24.         Position(playerPos.x - 1, playerPos.y + 2, playerPos.z):sendMagicEffect(243)
    25.     elseif playerDir == EAST then
    26.         Position(playerPos.x + 5, playerPos.y + 2, playerPos.z):sendMagicEffect(243)
    27.     end
    28.  
    29.     return combat:execute(cid, var)
    30. end
    data/spells/lib/spells.lua add
    Code (Lua):
    1.  
    2. AREA_BEAMFOUR = {
    3. {1,1,1},
    4. {1,1,1},
    5. {1,1,1},
    6. {1,3,1}
    7. }
     
    Mr Trala likes this.

Share This Page

Loading...