• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Fixing transform effect position.

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
873
Solutions
2
Reaction score
49
Hi
i have problem with transform effect position, it look like this
Untitled.png

And should look like this
Untitled1.png

Transform.lua
Code:
function onSay(player, words, param)
    local pid = player:getId()
   
    local TRANS = transform[player:getVocation():getId()]
   
    if not TRANS then
        player:sendCancelMessage("You cannot transform.")
        return false
    end
    if player:getLevel() < TRANS.level then
        player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.")
        return false
    end
    if player:getSoul() < TRANS.rage then
        player:sendCancelMessage("You need "..TRANS.rage.." to transform.")
        return false
    end
    if player:getMana() < TRANS.mana then
        player:sendCancelMessage("You need "..TRANS.mana.." to transform.")
        return false
    end
   
    local outfit = player:getOutfit()
    outfit.lookType = TRANS.looktype
   
    if TRANS.constant then
        player:setOutfit(outfit)
    else
        player:setOutfit(outfit, false)
    end
   
    player:addSoul(-TRANS.rage)
    player:setMaxHealth(player:getMaxHealth() + TRANS.addHealth)
    player:setMaxMana(player:getMaxMana() + TRANS.addMana)
    player:getPosition():sendMagicEffect(TRANS.effect)
    player:setVocation(TRANS.newVoc)
    player:save()
    return false
end
I'm pretty sure that i have to edit getPosition, but i'm thinking, what if i in future will want to make transform effect that takes 32x32 so it will be fucked up again because now my effect take x128 i think. So what you think guys?
 
Solution
Code:
function onSay(player, words, param)
    local kurwa_gdzie_jest_efekt = Position(player:getPosition().x + 1, player:getPosition().y, player:getPosition().z)
    local pid = player:getId()

    local TRANS = transform[player:getVocation():getId()]

    if not TRANS then
        player:sendCancelMessage("You cannot transform.")
        return false
    end
    if player:getLevel() < TRANS.level then
        player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.")
        return false
    end
    if player:getSoul() < TRANS.rage then
        player:sendCancelMessage("You need "..TRANS.rage.." to transform.")
        return false
    end
    if player:getMana() < TRANS.mana then...
I can help bud im the one that made the code for you in the first place.

Okay so type the size of pixle for effect, 32, 64, 96, 128....They have to be divisible by 32.

Lua:
transform = {
[1] = {voc = 1, newVoc = 5, from_looktype = 2, looktype = 3, level = 50, rage = 3, mana = 10, addHealth = 2500, addMana = 2500, size = 32, effect = 79, aura = nil, constant = false}
}


Lua:
function onSay(player, words, param)
    local pid = player:getId()
 
    local TRANS = transform[player:getVocation():getId()]
 
    if not TRANS then
        player:sendCancelMessage("You cannot transform.")
        return false
    end
    if player:getLevel() < TRANS.level then
        player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.")
        return false
    end
    if player:getSoul() < TRANS.rage then
        player:sendCancelMessage("You need "..TRANS.rage.." to transform.")
        return false
    end
    if player:getMana() < TRANS.mana then
        player:sendCancelMessage("You need "..TRANS.mana.." to transform.")
        return false
    end
 
    local outfit = player:getOutfit()
    outfit.lookType = TRANS.looktype
 
    if TRANS.constant then
        player:setOutfit(outfit)
    else
        player:setOutfit(outfit, false)
    end
 
    player:addSoul(-TRANS.rage)
    player:setMaxHealth(player:getMaxHealth() + TRANS.addHealth)
    player:setMaxMana(player:getMaxMana() + TRANS.addMana)
 
    local size = (TRANS.size - 32) / 32
    local pos = player:getPosition()
    if size > 0 then
        local newPos = Position({x = pos.x + size, y = pos.y + size, z = pos.z})
        newPos:sendMagicEffect(TRANS.effect)
        else
        player:getPosition():sendMagicEffect(TRANS.effect)
    end
    player:setVocation(TRANS.newVoc)
    player:save()
    return false
end
 
Last edited:
I can help bud im the one that made the code for you in the first place.

Okay so type the size of pixle for effect, 32, 64, 96, 128....They have to be divisible by 32.

Lua:
transform = {
[1] = {voc = 1, newVoc = 5, from_looktype = 2, looktype = 3, level = 50, rage = 3, mana = 10, addHealth = 2500, addMana = 2500, size = 32, effect = 79, aura = nil, constant = false}
}


Lua:
function onSay(player, words, param)
    local pid = player:getId()
 
    local TRANS = transform[player:getVocation():getId()]
 
    if not TRANS then
        player:sendCancelMessage("You cannot transform.")
        return false
    end
    if player:getLevel() < TRANS.level then
        player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.")
        return false
    end
    if player:getSoul() < TRANS.rage then
        player:sendCancelMessage("You need "..TRANS.rage.." to transform.")
        return false
    end
    if player:getMana() < TRANS.mana then
        player:sendCancelMessage("You need "..TRANS.mana.." to transform.")
        return false
    end
 
    local outfit = player:getOutfit()
    outfit.lookType = TRANS.looktype
 
    if TRANS.constant then
        player:setOutfit(outfit)
    else
        player:setOutfit(outfit, false)
    end
 
    player:addSoul(-TRANS.rage)
    player:setMaxHealth(player:getMaxHealth() + TRANS.addHealth)
    player:setMaxMana(player:getMaxMana() + TRANS.addMana)
 
    local size = (TRANS.size - 32) / 32
    local pos = player:getPosition()
    if size > 0 then
        local newPos = {x = pos.x + size, y = pos.y + size, z = pos.z}
        newPos:sendMagicEffect(TRANS.effect)
        else
        player:getPosition():sendMagicEffect(TRANS.effect)
    end
    player:setVocation(TRANS.newVoc)
    player:save()
    return false
end
Yea i remember :d
Untitled.png
 
I have a bit of a hack for situations like this with larger effects. Wrote a wrapper for send magic effect:

0.3.X:
Lua:
function doEff(position, number, offsetx, offsety)
    if offsetx ~= nil then
        position.x = position.x + offsetx
    end
    if offsety ~= nil then
        position.y = position.y + offsety
    end
    doSendMagicEffect(position, number)
end

I haven't written code for new TFS, so this 1.X spitball below might need a change or two to work properly, but I guess it should be something like this:
Lua:
function Position:doEff(number, offsetx, offsety)
    if offsetx ~= nil then
        self.x = self.x + offsetx
    end
    if offsety ~= nil then
        self.y = self.y + offsety
    end
    self:sendMagicEffect(number)
end

Not only is it easier to write doEff instead of doSendMagicEffect every time, but also it allows you to quickly offset the effect position when necessary.

With the above in mind, you can do something like:

Lua:
local vocSettings = {
    [vocationID] = {effectNumber = 100, offsetx = 2, offsety = 1},
    [vocationID] = {effectNumber = 124, offsetx = 0, offsety = 0},
    -- ... fill the table and the values to your needs.
}
if vocSettings[getPlayerVocation(cid)] then
    doEff(getThingPos(cid), vocSettings[getPlayerVocation(cid)].effectNumber, vocSettings[getPlayerVocation(cid)].offsetx, vocSettings[getPlayerVocation(cid)].offsety)
end

Which will produce a different effect depending on player's vocation, with the specified effect ID and offsets for that vocation exclusively.

Once again, I'm a noob with 1.X TFS code so I'm not gonna try to translate this, I guess you can do it yourself if you grasped any lua knowledge while editing the distro you're working with.
 
I have a bit of a hack for situations like this with larger effects. Wrote a wrapper for send magic effect:

0.3.X:
Lua:
function doEff(position, number, offsetx, offsety)
    if offsetx ~= nil then
        position.x = position.x + offsetx
    end
    if offsety ~= nil then
        position.y = position.y + offsety
    end
    doSendMagicEffect(position, number)
end

I haven't written code for new TFS, so this 1.X spitball below might need a change or two to work properly, but I guess it should be something like this:
Lua:
function Position:doEff(number, offsetx, offsety)
    if offsetx ~= nil then
        self.x = self.x + offsetx
    end
    if offsety ~= nil then
        self.y = self.y + offsety
    end
    self:sendMagicEffect(number)
end

Not only is it easier to write doEff instead of doSendMagicEffect every time, but also it allows you to quickly offset the effect position when necessary.

With the above in mind, you can do something like:

Lua:
local vocSettings = {
    [vocationID] = {effectNumber = 100, offsetx = 2, offsety = 1},
    [vocationID] = {effectNumber = 124, offsetx = 0, offsety = 0},
    -- ... fill the table and the values to your needs.
}
if vocSettings[getPlayerVocation(cid)] then
    doEff(getThingPos(cid), vocSettings[getPlayerVocation(cid)].effectNumber, vocSettings[getPlayerVocation(cid)].offsetx, vocSettings[getPlayerVocation(cid)].offsety)
end

Which will produce a different effect depending on player's vocation, with the specified effect ID and offsets for that vocation exclusively.

Once again, I'm a noob with 1.X TFS code so I'm not gonna try to translate this, I guess you can do it yourself if you grasped any lua knowledge while editing the distro you're working with.
dunno i dont get any errors or warning but it doesn't change anything
 
dunno i dont get any errors or warning but it doesn't change anything

Did you translate the other function to your TFS?
It probably won't work if you just paste it like this, and as I noted up there, I'm not experienced with this new tfs so I may have written something in a way it's not supposed to be.

In 0.3.6 it works fine. If any other reader on this thread can translate my post up above to new TFS functions, please do.
Lua:
    for i = 1, 5 do
        addEvent(function()
            doEff(getThingPos(cid), 5+i, i, i)
            chat(cid, "Offset X: " ..i.. " Y: " ..i.. ".")
        end, i*500)
    end

HqhAGSq.gif
 
Did you translate the other function to your TFS?
It probably won't work if you just paste it like this, and as I noted up there, I'm not experienced with this new tfs so I may have written something in a way it's not supposed to be.

In 0.3.6 it works fine. If any other reader on this thread can translate my post up above to new TFS functions, please do.
Lua:
    for i = 1, 5 do
        addEvent(function()
            doEff(getThingPos(cid), 5+i, i, i)
            chat(cid, "Offset X: " ..i.. " Y: " ..i.. ".")
        end, i*500)
    end

HqhAGSq.gif
Yea i didn't translated. Well i suck penis with tfs 1.x because i did pretty much nothing with lua at this point all i have is transform system by "Itutorial" and one npc and that's it. So i'm not able to translate that code to 1.x
 
"I suck penis" lets try to keep that out of the forums. No, im not telling you to keep it out, just asking. I would advise you to learn some lua.

Add this to your global.lua or you can create a lib file in your libs folder and link the file in lib.lua
Lua:
function Position:doEff(number, offsetx, offsety)
    if offsetx ~= nil then
        self.x = self.x + offsetx
    end
    if offsety ~= nil then
        self.y = self.y + offsety
    end
    self:sendMagicEffect(number)
end

In this code change vocationID to the id of the vocation it pertains to.
Lua:
local vocSettings = {
    [vocationID] = {effectNumber = 100, offsetx = 2, offsety = 1},
    [vocationID] = {effectNumber = 124, offsetx = 0, offsety = 0},
    -- ... fill the table and the values to your needs.
}
function onSay(player, words, param)
    local pid = player:getId()
    local TRANS = transform[player:getVocation():getId()]
    if not TRANS then
        player:sendCancelMessage("You cannot transform.")
        return false
    end
    if player:getLevel() < TRANS.level then
        player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.")
        return false
    end
    if player:getSoul() < TRANS.rage then
        player:sendCancelMessage("You need "..TRANS.rage.." to transform.")
        return false
    end
    if player:getMana() < TRANS.mana then
        player:sendCancelMessage("You need "..TRANS.mana.." to transform.")
        return false
    end
    local outfit = player:getOutfit()
    outfit.lookType = TRANS.looktype
    if TRANS.constant then
        player:setOutfit(outfit)
    else
        player:setOutfit(outfit, false)
    end
    player:addSoul(-TRANS.rage)
    player:setMaxHealth(player:getMaxHealth() + TRANS.addHealth)
    player:setMaxMana(player:getMaxMana() + TRANS.addMana)
    local size = (TRANS.size - 32) / 32
    local pos = player:getPosition()
    if vocSettings[getPlayerVocation(cid)] then
        doEff(getThingPos(cid), vocSettings[getPlayerVocation(cid)].effectNumber, vocSettings[getPlayerVocation(cid)].offsetx, vocSettings[getPlayerVocation(cid)].offsety)
    end
    player:setVocation(TRANS.newVoc)
    player:save()
    return false
end
 
"I suck penis" lets try to keep that out of the forums. No, im not telling you to keep it out, just asking. I would advise you to learn some lua.

Add this to your global.lua or you can create a lib file in your libs folder and link the file in lib.lua
Lua:
function Position:doEff(number, offsetx, offsety)
    if offsetx ~= nil then
        self.x = self.x + offsetx
    end
    if offsety ~= nil then
        self.y = self.y + offsety
    end
    self:sendMagicEffect(number)
end

In this code change vocationID to the id of the vocation it pertains to.
Lua:
local vocSettings = {
    [vocationID] = {effectNumber = 100, offsetx = 2, offsety = 1},
    [vocationID] = {effectNumber = 124, offsetx = 0, offsety = 0},
    -- ... fill the table and the values to your needs.
}
function onSay(player, words, param)
    local pid = player:getId()
    local TRANS = transform[player:getVocation():getId()]
    if not TRANS then
        player:sendCancelMessage("You cannot transform.")
        return false
    end
    if player:getLevel() < TRANS.level then
        player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.")
        return false
    end
    if player:getSoul() < TRANS.rage then
        player:sendCancelMessage("You need "..TRANS.rage.." to transform.")
        return false
    end
    if player:getMana() < TRANS.mana then
        player:sendCancelMessage("You need "..TRANS.mana.." to transform.")
        return false
    end
    local outfit = player:getOutfit()
    outfit.lookType = TRANS.looktype
    if TRANS.constant then
        player:setOutfit(outfit)
    else
        player:setOutfit(outfit, false)
    end
    player:addSoul(-TRANS.rage)
    player:setMaxHealth(player:getMaxHealth() + TRANS.addHealth)
    player:setMaxMana(player:getMaxMana() + TRANS.addMana)
    local size = (TRANS.size - 32) / 32
    local pos = player:getPosition()
    if vocSettings[getPlayerVocation(cid)] then
        doEff(getThingPos(cid), vocSettings[getPlayerVocation(cid)].effectNumber, vocSettings[getPlayerVocation(cid)].offsetx, vocSettings[getPlayerVocation(cid)].offsety)
    end
    player:setVocation(TRANS.newVoc)
    player:save()
    return false
end
Effect do not appear now.
 
offset option? what does it do?
An offset will load an image in this case, lets say that there is a space between your image and the left edge of the image and you want to load your image as close to the edge as possible so if there was 10 pixels between your image and its left side you would set the offset to 10 in x.
 
Back
Top