Custom animations effecting all mods. Need Help.

DBL-DTheWise

Newbie
Jul 27, 2025
2
0
30
I was hoping I could get some help with a strange issue I've encountered while creating a custom character. As a heads up, this is my first time modding for any game and my coding experience is very minimal. I've created a custom Donkey Kong and have made custom animations and functions thanks to the available resources on the official Github and YouTube videos by Garrulous64 and Q10isarobot. Unfortunately, the custom animations are replacing the animations of all characters not just my DK. My main.lua and animations.lua files are inside this specific mod's folder and not the general mods folder.


To paraphrase, how would I be able to apply my custom animations only to the DK I created instead of every character in the game ([CS] characters included)?

Here is the code I'm using used for animations:

LUA:
local function mario_update(m)

    if m.character.type == CT_DKB64 then
       
        if m.marioObj.header.gfx.animInfo.animID == MARIO_ANIM_IDLE_HEAD_LEFT then
            smlua_anim_util_set_animation(m.marioObj, "dkb64_animIdleHeadLeft")
        end
   
        if m.marioObj.header.gfx.animInfo.animID == MARIO_ANIM_IDLE_HEAD_RIGHT then
            smlua_anim_util_set_animation(m.marioObj, "dkb64_animIdleHeadRight")
        end

        if m.marioObj.header.gfx.animInfo.animID == MARIO_ANIM_IDLE_HEAD_CENTER then
            smlua_anim_util_set_animation(m.marioObj, "dkb64_animIdleHeadCenter")
        end

        if m.marioObj.header.gfx.animInfo.animID == MARIO_ANIM_SINGLE_JUMP then
            smlua_anim_util_set_animation(m.marioObj, "dkb64_animSingleJump")
        end

        if m.marioObj.header.gfx.animInfo.animID == MARIO_ANIM_GENERAL_FALL then
            smlua_anim_util_set_animation(m.marioObj, "dkb64_animGeneralFall")
        end

        if m.marioObj.header.gfx.animInfo.animID == MARIO_ANIM_GENERAL_LAND then
            smlua_anim_util_set_animation(m.marioObj, "dkb64_animGeneralLand")
        end

        if m.marioObj.header.gfx.animInfo.animID == MARIO_ANIM_LAND_FROM_SINGLE_JUMP then
            smlua_anim_util_set_animation(m.marioObj, "dkb64_animLandFromSingleJump")
        end

        if m.marioObj.header.gfx.animInfo.animID == MARIO_ANIM_SLOW_LEDGE_GRAB then
            smlua_anim_util_set_animation(m.marioObj, "dkb64_animSlowLedgeGrab")
        end

        if m.marioObj.header.gfx.animInfo.animID == MARIO_ANIM_RUNNING then
            smlua_anim_util_set_animation(m.marioObj, "dkb64_animRunning")  
        end

        if m.marioObj.header.gfx.animInfo.animID == MARIO_ANIM_STOP_CROUCHING then
            smlua_anim_util_set_animation(m.marioObj, "dkb64_animStopCrouching")
        end

        if m.marioObj.header.gfx.animInfo.animID == MARIO_ANIM_START_CROUCHING then
            smlua_anim_util_set_animation(m.marioObj, "dkb64_animStartCrouching")
        end

        if m.marioObj.header.gfx.animInfo.animID == MARIO_ANIM_CROUCHING then
            smlua_anim_util_set_animation(m.marioObj, "dkb64_animCrouching")
        end

        if m.marioObj.header.gfx.animInfo.animID == MARIO_ANIM_SKID_ON_GROUND then
            smlua_anim_util_set_animation(m.marioObj, "dkb64_animSkidOnGround")
        end

        if m.marioObj.header.gfx.animInfo.animID == MARIO_ANIM_STOP_SKID then
            smlua_anim_util_set_animation(m.marioObj, "dkb64_animStopSkid")
        end
    end
end

Any help or insight will be greatly appreciated.
 
I JUST fixed this issue myself. Here's my Code.

Code:
-- This table contains ALL my animations
local amyAnimTable = {
    [MARIO_ANIM_IDLE_HEAD_LEFT] = "amy_idle",
    [MARIO_ANIM_IDLE_HEAD_RIGHT] = "amy_idle",
    [MARIO_ANIM_IDLE_HEAD_CENTER] = "amy_idle",
    [MARIO_ANIM_FIRST_PERSON] = "amy_first_person",
}

-- This function replaces ANY animation that needs replacing using the table above
local function amy_update(m)
    --Animation Replacements
    if amyAnimTable[m.marioObj.header.gfx.animInfo.animID] then
        smlua_anim_util_set_animation(m.marioObj, amyAnimTable[m.marioObj.header.gfx.animInfo.animID])
    end
end

-- This function calls the first function (not sure why I don't just put them together)
-- but it uses "obj_has_model_extended" to check to see if your actually using the Donkey Kong model
local function mario_update(m)
    --if m.playerIndex ~= 0 then return end
    if obj_has_model_extended(m.marioObj, E_MODEL_AMYROSE) ~= 0 then
        amy_update(m)
    end
end

hook_event(HOOK_MARIO_UPDATE, mario_update)

-- note: Inside "mario_update" you'll notice I commented out "if m.playerIndex ~= 0 then return end"
-- because I don't know what that actually dose and my game works without it.

I am VERY new to this myself, so I've been modeling my code off of the Cream the Rabbit's mod.
I hope this helps :)
 
Thanks for the information! Unfortunately, adding your suggestion to my code didn't change anything. I've replaced the model information to work with my variables but everyone is still running around like a gorilla. Here is the code as I entered it just in case you notice anything wrong.

LUA:
local function mario_update(m)
    -- if m.playerIndex ~= 0 then return end
    if dkb64AnimTable[m.marioObj.header.gfx.animInfo.animID] then
        smlua_anim_util_set_animation(m.marioObj, dkb64AnimTable[m.marioObj.header.gfx.animInfo.animID])
    end
    if obj_has_model_extended(m.marioObj, E_MODEL_DKB64) ~= 0 then
        mario_update(m)
    end
end
hook_event(HOOK_MARIO_UPDATE, mario_update)

Strangely enough, even my custom moves are spilling over to other characters. I think my issue might be deeper than I first thought.
 
Code:
local function mario_update(m)
    -- if m.playerIndex ~= 0 then return END
    if dkb64AnimTable[m.marioObj.header.gfx.animInfo.animId] and obj_has_model_extended(m.marioObj, E_MODEL_DKB64) ~= 0 then
        smlua_anim_util_set_animation(m.marioObj, dkb64AnimTable[m.marioObj.header.gfx.animInfo.animId])
    end
end
hook_event(HOOK_MARIO_UPDATE, mario_update)

Try this.
At any rate, the animation changing code needs to be IN the "obj_has_model_extended" if statement. Your function seems to be calling itself. Most programing languages I work with will crash when we do that.

Hope that works
 
Last edited:

Users who are viewing this thread