SecretlyAPotato

Can you override spellcasting animation?

Recommended Posts

Monti18    404

Depends on which spellcasting animation you want to override.

ActionHandler(ACTIONS.CASTSPELL,
        function(inst, action)
            return action.invobject ~= nil
                and ((action.invobject:HasTag("gnarwail_horn") and "play_gnarwail_horn")
                    or (action.invobject:HasTag("guitar") and "play_strum")
                    or (action.invobject:HasTag("cointosscast") and "cointosscastspell")
                    or (action.invobject:HasTag("quickcast") and "quickcastspell")
                    or (action.invobject:HasTag("veryquickcast") and "veryquickcastspell")
                    )
                or "castspell"
        end),

This is the actionhandler that gives back which animation should be played.

local function ChangeSpellAnim(self)
	local old_actionhandler_spell = self.actionhandlers[GLOBAL.ACTIONS.CASTSPELL].deststate
	self.actionhandlers[GLOBAL.ACTIONS.CASTSPELL].deststate = function(inst,action,...)
		if action.invobject then
			return "play_gnarwail_horn"
		end
	end
end

AddStategraphPostInit("wilson", ChangeSpellAnim)
AddStategraphPostInit("wilson_client", ChangeSpellAnim)

This will replace all castspell animations with the gnarwail horn animation. Change it to your liking :)

  • Like 2

Share this post


Link to post
Share on other sites
19 hours ago, Monti18 said:

Depends on which spellcasting animation you want to override.


ActionHandler(ACTIONS.CASTSPELL,
        function(inst, action)
            return action.invobject ~= nil
                and ((action.invobject:HasTag("gnarwail_horn") and "play_gnarwail_horn")
                    or (action.invobject:HasTag("guitar") and "play_strum")
                    or (action.invobject:HasTag("cointosscast") and "cointosscastspell")
                    or (action.invobject:HasTag("quickcast") and "quickcastspell")
                    or (action.invobject:HasTag("veryquickcast") and "veryquickcastspell")
                    )
                or "castspell"
        end),

This is the actionhandler that gives back which animation should be played.


local function ChangeSpellAnim(self)
	local old_actionhandler_spell = self.actionhandlers[GLOBAL.ACTIONS.CASTSPELL].deststate
	self.actionhandlers[GLOBAL.ACTIONS.CASTSPELL].deststate = function(inst,action,...)
		if action.invobject then
			return "play_gnarwail_horn"
		end
	end
end

AddStategraphPostInit("wilson", ChangeSpellAnim)
AddStategraphPostInit("wilson_client", ChangeSpellAnim)

This will replace all castspell animations with the gnarwail horn animation. Change it to your liking :)

Why thank you good sir! Now, I'm still very new to modding, so quick question. Do I put this in the modmain or my item prefab?

edit: On second thought let me just experiment first and I'll ask for help if I need it

Edited by SecretlyAPotato

Share this post


Link to post
Share on other sites
Monti18    404

It's always better to test it out first, that's the way you get better :D

Sure, just ask away if you need help :)

  • Like 1

Share this post


Link to post
Share on other sites
14 hours ago, Monti18 said:

It's always better to test it out first, that's the way you get better :D

Sure, just ask away if you need help :)

I appreciate the help, I really do. Anyway, because I assume it completely replaces the anim for all items that use it, I put the code in my modmain, and...

[string "../mods/DeadCells_Mod/modmain.lua"]:173: attempt to call global 'ActionHandler' (a nil value)

Also, sorry for the late responses I've got a bit going on. And also I forget to do things.

Share this post


Link to post
Share on other sites
Monti18    404

Don't worry about late responses, happens to me too :D

Did you copy the first paragraph in your modmain? This was just copy and pasted from the Wilson stategraph file to show you how the actionhandler decides which animation it will play. You don't need to copy this into the modmain, you just need the second parapgraph, this one, in the modmain:

local function ChangeSpellAnim(self)
	local old_actionhandler_spell = self.actionhandlers[GLOBAL.ACTIONS.CASTSPELL].deststate
	self.actionhandlers[GLOBAL.ACTIONS.CASTSPELL].deststate = function(inst,action,...)
		if action.invobject then
			return "play_gnarwail_horn"
		end
	end
end

AddStategraphPostInit("wilson", ChangeSpellAnim)
AddStategraphPostInit("wilson_client", ChangeSpellAnim)

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now