Transform system [table included]

Discussion in 'GlobalEvents, Spells & CreatureEvents' started by Erexo, Sep 11, 2013.

  1. Erexo

    Erexo Kage

    Joined:
    Mar 27, 2010
    Messages:
    619
    Likes Received:
    57
    Best Answers:
    0
    Hello,
    I would like to present my very own `transform system`, useful for OTS like Naruto/DB or other.
    Its not very advanced, but Ive made it handy and simple to edit.

    First of all, put a table in libs, contains all info about transforms.

    Code (Lua):
    1. Trans = {
    2. -- Goku Transforms
    3. {["voc"] = 1, ["newVoc"] = 2, ["looktype"] = 5, ["revertLooktype"] = 4, ["level"] = 50, ["rage"] = 3, ["kiToTrans"] = 10, ["addHp"] = 200, ["addKi"] = 150, ["effectOn"] = 236, ["aura"] = 0, ["constant"] = false},
    4. {["voc"] = 2, ["newVoc"] = 3, ["looktype"] = 6, ["revertLooktype"] = 5, ["level"] = 130, ["rage"] = 5, ["kiToTrans"] = 50, ["addHp"] = 450, ["addKi"] = 300, ["effectOn"] = 236, ["aura"] = 0, ["constant"] = false},
    5. {["voc"] = 3, ["newVoc"] = 4, ["looktype"] = 7, ["revertLooktype"] = 6, ["level"] = 180, ["rage"] = 8, ["kiToTrans"] = 100, ["addHp"] = 1600, ["addKi"] = 900, ["effectOn"] = 236, ["aura"] = 104, ["constant"] = false},
    6. {["voc"] = 4, ["newVoc"] = 5, ["looktype"] = 8, ["revertLooktype"] = 7, ["level"] = 270, ["rage"] = 12, ["kiToTrans"] = 150, ["addHp"] = 2900, ["addKi"] = 2700, ["effectOn"] = 236, ["aura"] = 104, ["constant"] = false},
    7. {["voc"] = 5, ["newVoc"] = 6, ["looktype"] = 10, ["revertLooktype"] = 8, ["level"] = 350, ["rage"] = 15, ["kiToTrans"] = 200, ["addHp"] = 4000, ["addKi"] = 4000, ["effectOn"] = 236, ["aura"] = 105, ["constant"] = false}
    8. }
    So, as you can see it seems to be messy.

    Code (Lua):
    1. voc = from vocation
    2. newVoc = to vocation
    3. looktype = new outfit
    4. revertLooktype = current outfit
    5. level = lvl needed to transform
    6. rage = soul needed to transform (you can disable it, just type 0)
    7. kiToTrans = mana to transform
    8. addHp = maxHp added when you transform
    9. addKi = maxMana added
    10. effectOn = magic effect when you use transform
    11. aura = magic effect when you have current transform (can be disabled, just type 0)
    12. constant = if transform is constant (when it is, player dont lose transform/outfit and maxHp/Mana, and cannot use revert)
    13.  

    Lets check code now:

    spells.xml
    Code (XML):
    1. <instant name="Transform" words="transform" lvl="1" mana="0" aggressive="0" selftarget="1" exhaustion="1000" exhaustionType="2" event="script" value="Transform.lua"/>
    2. <instant name="Revert" words="revert" lvl="1" mana="0" aggressive="0" selftarget="1" exhaustion="1000" exhaustionType="2" event="script" value="Revert.lua"/>
    transform.lua
    Code (Lua):
    1. function onCastSpell(cid, var)
    2.  
    3.         for i = 1, #Trans do
    4.             if getPlayerVocation(cid) == Trans[i].voc then
    5.                 if getPlayerLevel(cid) >= Trans[i].level then
    6.                     if getPlayerSoul(cid) >= Trans[i].rage then
    7.                         if getPlayerMana(cid) >= Trans[i].kiToTrans then
    8.                             if(Trans[i].constant) then
    9.                                 doCreatureChangeOutfit(cid, {lookType=Trans[i].looktype})
    10.                             else
    11.                                 doSetCreatureOutfit(cid, {lookType=Trans[i].looktype}, -1)
    12.                             end
    13.                                 --doPlayerAddSoul(cid, -Trans[i].rage)
    14.                                 setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + Trans[i].addHp)
    15.                                 setCreatureMaxMana(cid, getCreatureMaxMana(cid) + Trans[i].addKi)
    16.                                 doCreatureAddHealth(cid, Trans[i].addHp)
    17.                                 doCreatureAddMana(cid, Trans[i].addKi)
    18.                          
    19.                                 doSendMagicEffect(getCreaturePosition(cid), Trans[i].effectOn)
    20.                                 doPlayerSendCancel(cid,"You have transformed.")
    21.                                 doPlayerSetVocation(cid,Trans[i].newVoc)
    22.                          
    23.                                 return true
    24.                         else
    25.                             doPlayerSendCancel(cid, "You need " .. Trans[i].kiToTrans .. " KI to transform!")
    26.                             doSendMagicEffect(getCreaturePosition(cid), 2)
    27.                             return true
    28.                         end    
    29.                     else
    30.                         doPlayerSendCancel(cid, "You need " .. Trans[i].rage .. " rage to transform!")
    31.                         doSendMagicEffect(getCreaturePosition(cid), 2)
    32.                         return true
    33.                     end
    34.                 else
    35.                     doPlayerSendCancel(cid, "You need " .. Trans[i].level .. " level to transform!")
    36.                     doSendMagicEffect(getCreaturePosition(cid), 2)
    37.                     return true
    38.                 end
    39.             end
    40.         end
    41.  
    42.     doPlayerSendCancel(cid, "You cannot transform.")
    43.     doSendMagicEffect(getCreaturePosition(cid), 2)
    44.     return true
    45. end

    revert.lua
    Code (Lua):
    1. function onCastSpell(cid, var)
    2.  
    3.         for i = 1, #Trans do
    4.             if getPlayerVocation(cid) == Trans[i].newVoc then
    5.                 if not Trans[i].constant then
    6.                     if (getCreatureHealth(cid) > Trans[i].addHp) and (getCreatureMana(cid) > Trans[i].addKi) then
    7.  
    8.                         doPlayerSetVocation(cid,Trans[i].voc)
    9.                         doCreatureChangeOutfit(cid, {lookType=Trans[i].revertLooktype})
    10.                         doSendMagicEffect(getCreaturePosition(cid), 6)
    11.                         doPlayerSendCancel(cid,"You have reverted.")
    12.                  
    13.                         setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) - Trans[i].addHp)
    14.                         setCreatureMaxMana(cid, getCreatureMaxMana(cid) - Trans[i].addKi)
    15.                         doCreatureAddHealth(cid, -Trans[i].addHp, false)
    16.                         doCreatureAddMana(cid, -Trans[i].addKi, false)
    17.                         return true
    18.                     else
    19.                         doPlayerSendCancel(cid, "You do not have enough health or ki.")
    20.                         doSendMagicEffect(getCreaturePosition(cid), 2)
    21.                         return true
    22.                     end
    23.                 else
    24.                     --doPlayerSendCancel(cid, "You cannot revert.")
    25.                     --doSendMagicEffect(getCreaturePosition(cid), 2)
    26.                     return true
    27.                 end
    28.             end
    29.         end
    30.  
    31.     doPlayerSendCancel(cid, "You cannot revert.")
    32.     doSendMagicEffect(getCreaturePosition(cid), 2)
    33.     return true
    34. end


    globalevents.xml
    Code (XML):
    1. <globalevent name="TransformEffects" interval="2" event="script" value="TransformEffects.lua"/>
    TransformEffects.lua
    Code (Lua):
    1. function onThink(interval, lastExecution, thinkInterval)
    2. local players = {}
    3. for _, i in pairs(getPlayersOnline()) do
    4.     table.insert(players, i)
    5. end
    6. -------------
    7.  
    8.     for k, v in pairs(players) do
    9.         for i = 1, #Trans do
    10.             if (Trans[i].newVoc == getPlayerVocation(v)) then
    11.                     if Trans[i].aura > 0 then
    12.                         doSendMagicEffect(getCreaturePosition(v), Trans[i].aura)
    13.                     end
    14.              
    15.                     doPlayerAddMana(v, -20, false)
    16.             end
    17.         end
    18.  
    19.     end
    20. return true
    21. end
    Also you can use this modification instead of mine globalevent.
    Script is not very advanced, wrote it some time ago.
    That `if/if/if/if/if` ladder looks really bad ^^

    Thats all, you dont have to modify anything in code, but if you want to...
    Tested on TFS 0.3.6pl1

    Post any bugs/suggestions :)

    Greetings,
    Erexo.
     
    Syryniss, televolt and Fresh like this.
  2. gratuit

    gratuit New Member

    Joined:
    Sep 14, 2013
    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    I am going to start this thread off with some Banksy Pics I had on my computer. If you don't know who he is then you might have been living under a rock and should check out his work on the home page and online. Regarder Prisoners en ligne gratuit
     
  3. beliar34

    beliar34 Member

    Joined:
    Feb 28, 2012
    Messages:
    243
    Likes Received:
    6
    Best Answers:
    8
    isnt work on tfs 3.5.0 ;( transform work but when i logout health dont delete
     
  4. Anyjia

    Anyjia KillaBeez

    Joined:
    Jun 10, 2007
    Messages:
    185
    Likes Received:
    34
    Best Answers:
    0
    did you ever solve this error? please share if so.
     
  5. Nouel

    Nouel New Member

    Joined:
    Feb 9, 2016
    Messages:
    16
    Likes Received:
    1
    Best Answers:
    0
    were in lib ?
     
  6. Goblin King

    Goblin King New Member

    Joined:
    Feb 6, 2017
    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    I suggest to make 1.x version of this script because this may be one of most useful scripts. Every db/naruto server is based on transform script!
     

Share This Page

Loading...