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

Sequence Animation Generator

bayview

Banned User
Joined
Jan 25, 2018
Messages
611
Solutions
25
Reaction score
324
I really don't have the time to rewrite this and its built in a separate framework than that of TFS but I figured its useful to whomever would like to make simple animation sequences for their special effects with spells or attacks...

I thought about rebuilding it so it used keyframes as entire area but currently it only uses one position per frame.

Please excuse the poorly written code :p I wrote it when I was 1st learning lua and the love2d framework.

What does this do? It creates a table of tables which correspond to the entire width and height of the default game window.
Lua:
animation = {
    {1, 1}, -- index 1
    {2, 2}, -- index 2
    {3, 3}, -- index 3
    {4, 3}, -- index 4
    {5, 3}, -- index 5
    {6, 3}, -- index 6
    {7, 3}, -- index 7
    {8, 3}, -- index 8
    {10, 3}, -- index 9
    {10, 5}, -- index 10
    {10, 7}, -- index 11
    {10, 9}, -- index 12
    {10, 10}, -- index 13
    {10, 12}, -- index 14
    {10, 13}, -- index 15
    {8, 13}, -- index 16
    {7, 13}, -- index 17
}
Which then can be added to this script.
Lua:
local grid =
{
    --   1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -- 1
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -- 2
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -- 3
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -- 4
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -- 5
        {0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0}, -- 6
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -- 7
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -- 8
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -- 9
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -- 10
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -- 11
}
function deepcopy(orig)
    local orig_type = type(orig)
    local copy
    if orig_type == 'table' then
        copy = {}
        for orig_key, orig_value in next, orig, nil do
            copy[deepcopy(orig_key)] = deepcopy(orig_value)
        end
        setmetatable(copy, deepcopy(getmetatable(orig)))
    else -- number, string, boolean, etc
        copy = orig
    end
    return copy
end
function setSequence(t, d)
    local x = {}
    for n = 1, #d do
        x[n] = deepcopy(t)
    end
    for i = 1, #x do
        x[i][d[i][1]][d[i][2]] = 1
    end
    return x
end
And then you can call it via spell (just an example)
Lua:
local areaSequence = setSequence(grid, animation)
local combat = {}
for x = 1, #areaSequence do
    combat[x] = Combat()
    combat[x]:setParameter(COMBAT_PARAM_TYPE, COMBAT_NONE)
    combat[x]:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
    combat[x]:setArea(createCombatArea(areaSequence[x]))
end
local int = 1000
local xcute, xtime = 10, 500
function onCastSpell(creature, variant, isHotkey)
    for f = 1, xcute do
        addEvent(function()
            for n = 1, #areaSequence do
                addEvent(function(cid, var, i)
                    local c = Creature(cid)
                    if c then
                        if combat[i] then
                            combat[i]:execute(c, var)
                        end
                    end
                end, n * int, creature:getId(), variant, n
                )
            end
        end, f * xtime)
    end
    return true
end

You will need to download and install love2d for your platform (Mac, Windows or Linux) to run this tiny program. If you want it to run without using batch file then just rename the extension from zip to love.

I was using spell creator, the one found here on otland but idk i figured screw i should work on the program i wanted to make, this is a test of loading the sprite animations.
I am only loading 7 animation sequences and just to see if they lag at all, they automatically load from the effects directory.

They are the png files you get when you export a sprite.

Making progress, added a grid for clarity
progress.png
 

Attachments

  • Spell-Animation-Creator.zip
    5.4 KB · Views: 35 · VirusTotal
Last edited by a moderator:
Well made a small change to the code for saving the file.
Lua:
function saveAnimation(file)
    if ANIME and next(ANIME) then
        local fileEx = file
        if fileEx then
            fileEx = io.open(fileEx, "w+")
            fileEx:write("animation = {\n")
                for i, v in pairs(ANIME) do
                    fileEx:write("\t{"..v[1]..", "..v[2].."}, -- index "..i.."\n")
                end
            fileEx:write("}")
            fileEx:close()
            DATA = DATA .." ".. file .. ' created, with '..(#ANIME)..' seqeunces.\n'
            return
        end
    end
    DATA = DATA .. " " .. file .. ' not created, table empty!\n'
    return
end

Ok so I update the source because I couldn't find the original code I had with the grid.
grid.png

Here is the updated source

I am going to work on it more and add in layers and such or instead of just 1 position I'll eventually add in entire areas.

If you don't want to download the file then you can just update this function.
Lua:
function drawMapWindow()
--print(#pixels[layer])
    for z = 1, #pixels do
        for x = 0, #pixels[layer] do -- only draw the current layer
            for y = 0, #pixels[layer][x] do
                if ((x * imgscale) + interfaceborder) <= c.windowwidth and ( (y * imgscale) + interfaceborder) <= 700 then
                    love.graphics.setColor(unpack(pixels[layer][x][y])) -- pink
                    love.graphics.rectangle("fill", ((x) * imgscale)+c.tile_wd, ((y) * imgscale)+c.tile_yd, imgscale, imgscale) -- draws the grid of pink boxes
                    love.graphics.setColor(0,0,0) -- black
                    love.graphics.rectangle("line", ((x) * imgscale)+c.tile_wd, ((y) * imgscale)+c.tile_yd, imgscale, imgscale) -- draws grid lines
                    if x == math.floor(#pixels[layer] / 2) and y == math.floor(#pixels[layer][x] / 2) then
                        love.graphics.setColor(0,0,0) -- black
                        love.graphics.rectangle("fill", ((x) * imgscale)+c.tile_wd, ((y) * imgscale)+c.tile_yd, imgscale, imgscale) -- draws black box center of the grid
                    end
                end
            end
        end
    end
    return false
end
 

Attachments

  • Spell Animation Creator-v-1-1.zip
    5.4 KB · Views: 16 · VirusTotal
Last edited by a moderator:
I did not understand how to assemble the structure. Can you help? Where do I put the functions and generated code?
Thank's
 
Back
Top