Jump to content

Recommended Posts

So I have a custom weapon set up. When I use it, it makes the swinging sound and swinging animation.

I need it to do neither of those. He needs to just stand there in idle animation when the weapon is used like nothing happened. 

Is there an easy way to do that? Or are all weapon components hard coded to play those animations and sound effects when used?

I already tried setting his animation state to idle and killing all sound when the weapon is used, but it doesn't seem to have any effect.

Thanks in advance for any help!

If you could somehow listen for the character trying to attack, you could push the idle state and still execute the buffered action.

Or you could try making a custom action (which probably requires a custom component on the weapon).

Yeah I have no idea.

Your issue is that the ATTACK action is attached to specific stategraphes which handles the animation.

You could create a new action which would be a copy of the ATTACK action but attached to a SG playing no animation. Then you do a ACTIONS.ATTACK = ACTIONS.MYNEWACTION in the onequip function (do not forget to restore the original ACTIONS.ATTACK in the onunequip function)

If you need more details just ask.

Edited by ZupaleX

Your issue is that the ATTACK action is attached to specific stategraphes which handles the animation.

You could create a new action which would be a copy of the ATTACK action but attached to a SG playing no animation. Then you do a ACTIONS.ATTACK = ACTIONS.MYNEWACTION in the onequip function (do not forget to restore the original ACTIONS.ATTACK in the onunequip function)

If you need more details just ask.

 

Actually, no stategraph stuff is needed for a new action if said action is instant. All actions I ever made in my mods are instant. (eventhough they usually send the character to a fancy state)

@pickleplayer Are you perhaps trying to use the weapon component to do something other than attacking things? I can't think of why a weapon wouldn't use some sort of animation. Take a look at the ranged/magic weapons' code too if you're making something similar to them.

Your issue is that the ATTACK action is attached to specific stategraphes which handles the animation.

You could create a new action which would be a copy of the ATTACK action but attached to a SG playing no animation. Then you do a ACTIONS.ATTACK = ACTIONS.MYNEWACTION in the onequip function (do not forget to restore the original ACTIONS.ATTACK in the onunequip function)

If you need more details just ask.

 

Actually, now that I think about it, it would be nice if it was preformed instantly. But if its easier to do without it, then it's fine with a delay. I can probably mess with that in the stategraph myself.

 

Alright, so I've set up a custom stategraph for my character with a state that functions like the "attack" state but without the sound or animation called "specialattack, but I guess I'm not very good with setting up actions.

 

I already had a code in place for my custom item that replaces the action string from "attack" to "scare" when mousing over enemies while its equipped, so I just pasted it in that, but it doesn't seem to work.

 

I just kinda slapped it on the bottom of the function, but I really wasn't sure where else to put it.

local function onequip(inst, owner)	print("EQUIP ME")	function owner:ActionStringOverride(bufaction)		if bufaction.action == ACTIONS.ATTACK then			--print("I AM THE ATTACK")			return "Scare"		end	end	ACTIONS.ATTACK = ACTIONS.SPECIALATTACKend

(theres also one for unequipping)

 

The custom state in the stategraph doesn't activate at all on attack, since I put a print function in it, and it doesn't show up in the console on attack.

@pickleplayer Are you perhaps trying to use the weapon component to do something other than attacking things? I can't think of why a weapon wouldn't use some sort of animation. Take a look at the ranged/magic weapons' code too if you're making something similar to them.

 

Oh, there is an animation. But it needs to happen after the confirmed hit. (which it does)

So now there's two animations, and it looks a bit silly d:

 

and yes, I've studied the staff.lua code extensively. It's very useful. 

@pickleplayer Have you seen these examples? Contains useful code for modifying stategraphs and making custom actions (as well as many other things). It's generally what I refer to when deciding how to implement something.

 

Oh wow, that really is useful! This will help a lot! I haven't seen that yet, thanks!

oh man, just spent a few hours messing around with this with new components and actions and all I did was mess everything up.

Forget this custom component and stategraph stuff, the "weapon" component is connected to like everything in the game, and it removes the functionality if it's no longer considered a "weapon"

 

 

The solution I gave you works quite well and easily. That's how I did the first time I wanted to modify the attack animation when wielding a specific item. It is not really clean but it's probably the most straight forward.

I tried that, but like I said above, it seems to remove most of its functionality when I did. At least, it did for mine. Mine is actually has a SetRange and a SetOnAttack function, and both of those stop working when I set its action to anything other than ATTACK. I'm guessing It's either because SetRange and SetOnAttack are only set to work with ATTACK actions, or I'm just have no idea what I'm doing and I'm setting it up wrong.

Ah but I did not say to remove the weapon component. Actually if you decide to go for overriding the ACTIONS.ATTACK n the onequip and restoring it in the onunequip you probably do not even need a dummy component. Just write your action, attach it to your stategraph, add an action handler and it should be enough. Then if you want your action to be immediate you do not even need a SG.

Ah but I did not say to remove the weapon component. Actually if you decide to go for overriding the ACTIONS.ATTACK n the onequip and restoring it in the onunequip you probably do not even need a dummy component. Just write your action, attach it to your stategraph, add an action handler and it should be enough. Then if you want your action to be immediate you do not even need a SG.

 

Oh, alright, I hadn't had the weapon component on for most of my tests.

 

Okay so I set up the action like this in the modmain

local Action = GLOBAL.Actionlocal ActionHandler = GLOBAL.ActionHandlerlocal SPECIALATTACK = Action(2, true)   --same as attack actionSPECIALATTACK.str = "Special Attack"SPECIALATTACK.id = "SPECIALATTACK"SPECIALATTACK.fn = function(act)	print("LIGHTNING BOLT not really")	if act.target.components.combat and act.target.components.locomotor then     --also copied from the attack action        act.doer.components.combat:SetTarget(act.target)        --act.doer.components.combat:TryAttack()        return true    endendAddAction(SPECIALATTACK)AddStategraphActionHandler("wilson", ActionHandler(SPECIALATTACK, "specialattack"))

And it successfully prints the line to the console on attack when the item is equiped. (It doesn't disable on unequip, but I'll worry about that later)

 

However, I still have a function the needs to be called on hit that isn't called. Well, it's still called, but just not instantly. It's called from the still existing slower weapon

 

I've been using  inst.components.weapon:SetOnAttack(ScareFearCore)   in my weapon's file

 

I need that ScareFearCore function to be called via the special attack, and I can't just replace it with SetOnSpecialAttack.

Edited by pickleplayer

I am not sure I understand properly.

Did you define a state "specialattack"? I believe you did since you call it in your AddStategraphActionHandler.

Well then, in your SPECIALATTACK.fn, add the function you want to call when you attack, and put the PerformBufferedAction at frame 0 in the timeline of your state "specialattack".

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
×
  • Create New...