Transform system [table included]

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

  1. Erexo

    Erexo Kage

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

    Code:
    voc = from vocation
    newVoc = to vocation
    looktype = new outfit
    revertLooktype = current outfit
    level = lvl needed to transform
    rage = soul needed to transform (you can disable it, just type 0)
    kiToTrans = mana to transform
    addHp = maxHp added when you transform
    addKi = maxMana added
    effectOn = magic effect when you use transform
    aura = magic effect when you have current transform (can be disabled, just type 0)
    constant = if transform is constant (when it is, player dont lose transform/outfit and maxHp/Mana, and cannot use revert)
    

    Lets check code now:

    spells.xml
    Code:
    <instant name="Transform" words="transform" lvl="1" mana="0" aggressive="0" selftarget="1" exhaustion="1000" exhaustionType="2" event="script" value="Transform.lua"/>
    <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:
    function onCastSpell(cid, var)
    
            for i = 1, #Trans do
                if getPlayerVocation(cid) == Trans[i].voc then
                    if getPlayerLevel(cid) >= Trans[i].level then
                        if getPlayerSoul(cid) >= Trans[i].rage then
                            if getPlayerMana(cid) >= Trans[i].kiToTrans then
                                if(Trans[i].constant) then
                                    doCreatureChangeOutfit(cid, {lookType=Trans[i].looktype})
                                else
                                    doSetCreatureOutfit(cid, {lookType=Trans[i].looktype}, -1)
                                end
                                    --doPlayerAddSoul(cid, -Trans[i].rage)
                                    setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + Trans[i].addHp)
                                    setCreatureMaxMana(cid, getCreatureMaxMana(cid) + Trans[i].addKi)
                                    doCreatureAddHealth(cid, Trans[i].addHp)
                                    doCreatureAddMana(cid, Trans[i].addKi)
                              
                                    doSendMagicEffect(getCreaturePosition(cid), Trans[i].effectOn)
                                    doPlayerSendCancel(cid,"You have transformed.")
                                    doPlayerSetVocation(cid,Trans[i].newVoc)
                              
                                    return true
                            else
                                doPlayerSendCancel(cid, "You need " .. Trans[i].kiToTrans .. " KI to transform!")
                                doSendMagicEffect(getCreaturePosition(cid), 2)
                                return true
                            end      
                        else
                            doPlayerSendCancel(cid, "You need " .. Trans[i].rage .. " rage to transform!")
                            doSendMagicEffect(getCreaturePosition(cid), 2)
                            return true
                        end
                    else
                        doPlayerSendCancel(cid, "You need " .. Trans[i].level .. " level to transform!")
                        doSendMagicEffect(getCreaturePosition(cid), 2)
                        return true
                    end
                end
            end  
    
        doPlayerSendCancel(cid, "You cannot transform.")
        doSendMagicEffect(getCreaturePosition(cid), 2)
        return true
    end

    revert.lua
    Code:
    function onCastSpell(cid, var)
    
            for i = 1, #Trans do
                if getPlayerVocation(cid) == Trans[i].newVoc then
                    if not Trans[i].constant then
                        if (getCreatureHealth(cid) > Trans[i].addHp) and (getCreatureMana(cid) > Trans[i].addKi) then
    
                            doPlayerSetVocation(cid,Trans[i].voc)
                            doCreatureChangeOutfit(cid, {lookType=Trans[i].revertLooktype})
                            doSendMagicEffect(getCreaturePosition(cid), 6)
                            doPlayerSendCancel(cid,"You have reverted.")
                      
                            setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) - Trans[i].addHp)
                            setCreatureMaxMana(cid, getCreatureMaxMana(cid) - Trans[i].addKi)
                            doCreatureAddHealth(cid, -Trans[i].addHp, false)
                            doCreatureAddMana(cid, -Trans[i].addKi, false)
                            return true
                        else
                            doPlayerSendCancel(cid, "You do not have enough health or ki.")
                            doSendMagicEffect(getCreaturePosition(cid), 2)
                            return true
                        end
                    else
                        --doPlayerSendCancel(cid, "You cannot revert.")
                        --doSendMagicEffect(getCreaturePosition(cid), 2)
                        return true
                    end
                end
            end
    
        doPlayerSendCancel(cid, "You cannot revert.")
        doSendMagicEffect(getCreaturePosition(cid), 2)
        return true
    end


    globalevents.xml
    Code:
    <globalevent name="TransformEffects" interval="2" event="script" value="TransformEffects.lua"/>
    TransformEffects.lua
    Code:
    function onThink(interval, lastExecution, thinkInterval)
    local players = {}
    for _, i in pairs(getPlayersOnline()) do
        table.insert(players, i)
    end
    -------------
    
        for k, v in pairs(players) do
            for i = 1, #Trans do
                if (Trans[i].newVoc == getPlayerVocation(v)) then
                        if Trans[i].aura > 0 then
                            doSendMagicEffect(getCreaturePosition(v), Trans[i].aura)
                        end
                  
                        doPlayerAddMana(v, -20, false)
                end
            end
      
        end
    return true
    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
    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:
    159
    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:
    175
    did you ever solve this error? please share if so.
     
  5. Nouel

    Nouel New Member

    Joined:
    Feb 9, 2016
    Messages:
    15
    were in lib ?
     

Share This Page