• 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!

Help with animations (Sprites)

demon088

#088 in the Horde
Joined
Jun 17, 2009
Messages
248
Solutions
3
Reaction score
29
Location
Hell
Hello Otland!
I need help with animation spriting. It ocurrs that we added some large animation for custom spells. The problem is that the area of effect is lower than the animation, as result it looks pretty wierd. Example:
anima.png
The blue square represents the area where the spell is acting, and as you can see, the animation seems to be higher than the real area. We have tried modyfing features on the ObjectBuilder, but we couldn't solve it yet. Do you guys have any idea what could be wrong?

Also the Offset function doesnt do anything... well, nothing I can see when reloading spells.

Captura de pantalla 2020-10-04 220304.png
Thanks for your help!

EDIT: SOLUTION
I'm using this script to center correctly an animation greater than 32x32. Thanks @BulawOw!

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
function onGetFormulaValues(player, level, maglevel)
    local min = (level / 3) + (maglevel * 1.9)
    local max = (level + 7) + (maglevel * 2.1)
    return -min, -max
end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onCastSpell(cid, var)
local pos = cid:getTarget():getPosition()
    pos.x = pos.x + 1
    pos.y = pos.y + 1
    pos:sendMagicEffect(178) -- THIS IS MY CUSTOM ANIMATION ID
    return doCombat(cid, combat, var)
end
This is how it is working with this script
anima.png
 
Last edited:
Solution
U need to add offset to the spell effect im pretty sure its just gonna look like that in ur case


Lua:
local pos = creature:getPosition() -- First u getting the position
    pos.x = pos.x + 1
    pos.y = pos.y + 1 -- then u setting the offset

--And after that u sending that effect on the pos
    pos:sendMagicEffect(effect)
Tinkering with the offset should do it. You have to compile and restart the client when testing it.
 
U need to add offset to the spell effect im pretty sure its just gonna look like that in ur case


Lua:
local pos = creature:getPosition() -- First u getting the position
    pos.x = pos.x + 1
    pos.y = pos.y + 1 -- then u setting the offset

--And after that u sending that effect on the pos
    pos:sendMagicEffect(effect)
 
Last edited:
Solution
Post the spell file

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREATTACK)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)

function onCastSpell(cid, var)
fcharges = getPlayerStorageValue(cid,10076)
        if fcharges > 4 then
           doPlayerSendCancel(cid,"This spell cannot charge more than 5 flaming charges. You have " .. fcharges .. " flaming charges.")
function onGetFormulaValues(player, level, maglevel)
    local min = (level / 3) + (maglevel * 1.9)
    local max = (level + 7) + (maglevel * 2.1)
    return -min, -max
end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
else
setPlayerStorageValue(cid,10076, getPlayerStorageValue(cid, 10076) + 1)   
           doPlayerSendTextMessage(cid, 19, "Charging: You have " .. getPlayerStorageValue(cid, 10076) .. " flaming charges.")
function onGetFormulaValues(player, level, maglevel)
    local min = (level / 3) + (maglevel * 1.9)
    local max = (level + 7) + (maglevel * 2.1)
    return -min, -max
end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
end
    return doCombat(cid, combat, var)
end
U need to add offset to the spell effect im pretty sure its just gonna look like that in ur case


Lua:
local pos = creature:getPosition() -- First u getting the target position
    pos.x = pos.x + 1
    pos.y = pos.y + 1 -- then u setting the offset

--And after that u sending that effect on the pos
    pos:sendMagicEffect(effect)
I will give it a try and repost.
 
So cleaned your code a bit.

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREATTACK)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
combat:setArea({
{0, 0, 0},
{0, 1, 0},
{0, 0, 0}
})

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 3) + (maglevel * 1.9)
    local max = (level + 7) + (maglevel * 2.1)
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    local fcharges = getPlayerStorageValue(cid,10076)
    
    if fcharges > 4 then
        doPlayerSendCancel(cid,"This spell cannot charge more than 5 flaming charges. You have " .. fcharges .. " flaming charges.")
    else
        setPlayerStorageValue(cid,10076, getPlayerStorageValue(cid, 10076) + 1)   
        doPlayerSendTextMessage(cid, 19, "Charging: You have " .. getPlayerStorageValue(cid, 10076) .. " flaming charges.")
    end
    return doCombat(cid, combat, var)
end
 
U need to add offset to the spell effect im pretty sure its just gonna look like that in ur case


Lua:
local pos = creature:getPosition() -- First u getting the position
    pos.x = pos.x + 1
    pos.y = pos.y + 1 -- then u setting the offset

--And after that u sending that effect on the pos
    pos:sendMagicEffect(effect)
I couldn't make the script work with this feature. The script just stops working and prompt is showing creature is a nil value. I have just added your feature within Function onCast, I tried in many places but couldn't make it work.
So cleaned your code a bit.

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREATTACK)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
combat:setArea({
{0, 0, 0},
{0, 1, 0},
{0, 0, 0}
})

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 3) + (maglevel * 1.9)
    local max = (level + 7) + (maglevel * 2.1)
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    local fcharges = getPlayerStorageValue(cid,10076)
  
    if fcharges > 4 then
        doPlayerSendCancel(cid,"This spell cannot charge more than 5 flaming charges. You have " .. fcharges .. " flaming charges.")
    else
        setPlayerStorageValue(cid,10076, getPlayerStorageValue(cid, 10076) + 1) 
        doPlayerSendTextMessage(cid, 19, "Charging: You have " .. getPlayerStorageValue(cid, 10076) .. " flaming charges.")
    end
    return doCombat(cid, combat, var)
end
Thank you for you help, I will be cleaning my other attack scripts like this one. However I have not achieved the correct positioning of the new animation...
 
Offsets in object builder are in pixels and they are offseting to the left and up. I don't understand why is this limited to additive values so you can't center effects that are bigger than 32x32.
1601913135592.png
 
Well i showed u example from my script u just need to adapt it to you'rs
Instead of creature do cid
 
Well i showed u example from my script u just need to adapt it to you'rs
Instead of creature do cid
For a better understanding, how can I set the animation to appear around the target?
I tried with cid:getPosition, but the animation appears centered but over my character. Is there something like target:getPosition? I tried with others but sent me nil value as well.
EDIT: Okay so I found the correct coding for the positioning you were talking about. And now it is working fine.
anima.png
Here's the script if someone else have a similiar problem:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
function onGetFormulaValues(player, level, maglevel)
    local min = (level / 3) + (maglevel * 1.9)
    local max = (level + 7) + (maglevel * 2.1)
    return -min, -max
end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onCastSpell(cid, var)
local pos = cid:getTarget():getPosition()
    pos.x = pos.x + 1
    pos.y = pos.y + 1
    pos:sendMagicEffect(178) -- THIS IS MY CUSTOM ANIMATION ID
    return doCombat(cid, combat, var)
end
Post automatically merged:

Offsets in object builder are in pixels and they are offseting to the left and up. I don't understand why is this limited to additive values so you can't center effects that are bigger than 32x32.
View attachment 50418
In that case, do I need to modify Texture properties within Object Builder? I will need to make experiments as we don't have much experience with this kind of spriting.
 

Attachments

Last edited:
Back
Top