Transform system [table included]

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

  1. Erexo

    Erexo Kage

    Joined:
    Mar 27, 2010
    Messages:
    596
    Likes Received:
    50
    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 (Text):
    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 (Text):
    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 (Text):
    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 (Text):
    1.  
    2. function onCastSpell(cid, var)
    3.  
    4.         for i = 1, #Trans do
    5.             if getPlayerVocation(cid) == Trans[i].voc then
    6.                 if getPlayerLevel(cid) >= Trans[i].level then
    7.                     if getPlayerSoul(cid) >= Trans[i].rage then
    8.                         if getPlayerMana(cid) >= Trans[i].kiToTrans then
    9.                             if(Trans[i].constant) then
    10.                                 doCreatureChangeOutfit(cid, {lookType=Trans[i].looktype})
    11.                             else
    12.                                 doSetCreatureOutfit(cid, {lookType=Trans[i].looktype}, -1)
    13.                             end
    14.                                 --doPlayerAddSoul(cid, -Trans[i].rage)
    15.                                 setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + Trans[i].addHp)
    16.                                 setCreatureMaxMana(cid, getCreatureMaxMana(cid) + Trans[i].addKi)
    17.                                 doCreatureAddHealth(cid, Trans[i].addHp)
    18.                                 doCreatureAddMana(cid, Trans[i].addKi)
    19.                          
    20.                                 doSendMagicEffect(getCreaturePosition(cid), Trans[i].effectOn)
    21.                                 doPlayerSendCancel(cid,"You have transformed.")
    22.                                 doPlayerSetVocation(cid,Trans[i].newVoc)
    23.                          
    24.                                 return true
    25.                         else
    26.                             doPlayerSendCancel(cid, "You need " .. Trans[i].kiToTrans .. " KI to transform!")
    27.                             doSendMagicEffect(getCreaturePosition(cid), 2)
    28.                             return true
    29.                         end      
    30.                     else
    31.                         doPlayerSendCancel(cid, "You need " .. Trans[i].rage .. " rage to transform!")
    32.                         doSendMagicEffect(getCreaturePosition(cid), 2)
    33.                         return true
    34.                     end
    35.                 else
    36.                     doPlayerSendCancel(cid, "You need " .. Trans[i].level .. " level to transform!")
    37.                     doSendMagicEffect(getCreaturePosition(cid), 2)
    38.                     return true
    39.                 end
    40.             end
    41.         end  
    42.  
    43.     doPlayerSendCancel(cid, "You cannot transform.")
    44.     doSendMagicEffect(getCreaturePosition(cid), 2)
    45.     return true
    46. end

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


    globalevents.xml
    Code (Text):
    1. <globalevent name="TransformEffects" interval="2" event="script" value="TransformEffects.lua"/>
    TransformEffects.lua
    Code (Text):
    1.  
    2. function onThink(interval, lastExecution, thinkInterval)
    3. local players = {}
    4. for _, i in pairs(getPlayersOnline()) do
    5.     table.insert(players, i)
    6. end
    7. -------------
    8.  
    9.     for k, v in pairs(players) do
    10.         for i = 1, #Trans do
    11.             if (Trans[i].newVoc == getPlayerVocation(v)) then
    12.                     if Trans[i].aura > 0 then
    13.                         doSendMagicEffect(getCreaturePosition(v), Trans[i].aura)
    14.                     end
    15.              
    16.                     doPlayerAddMana(v, -20, false)
    17.             end
    18.         end
    19.  
    20.     end
    21. return true
    22. 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.
     
    Last edited: Sep 11, 2013
    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:
    162
    Likes Received:
    2
    Best Answers:
    0
    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...