Jump to content

How to make the change of stategraph only works on a specific character?


Recommended Posts

I need to make some changes for my character on the SGWilson and SGWilson_client stategraphs.I saw some tutorials and other mods.They just use the function AddStategraphPostInit to change the stategraph.And obviously it changes stategraphs of all characters.If other characters change same places it will lead to conflicts.That's what I don't want to happen.So,is there any way to avoid affecting others when making changes on stategraphs only work for my character?Really appreciate it if somebody could help me.

Link to comment
Share on other sites

I have made some changes for stategraph in order to change animation for specific weapon. I have just added tag to the weapon and inside stategraph function looked for that tag. Take a look, I am terrible person to explain things.

local function avtofir(sg) 
 local _onenter = sg.states["attack"].onenter 

	sg.states["attack"].onenter = function(inst) 
		_onenter(inst) 
	
		local equip = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
		local cooldown = inst.components.combat.min_attack_period + 300 * FRAMES
		
		if equip ~= nil and equip:HasTag("sprayer") then		
				inst.AnimState:PlayAnimation("ngnt")
		end	
			cooldown = math.max(cooldown, 300 * FRAMES)		
	end
end

AddStategraphPostInit("wilson", avtofir)

tag is called "sprayer".

Cheers!

Link to comment
Share on other sites

On 4/23/2021 at 6:40 PM, Yakuzashi said:

I have made some changes for stategraph in order to change animation for specific weapon. I have just added tag to the weapon and inside stategraph function looked for that tag. Take a look, I am terrible person to explain things.


local function avtofir(sg) 
 local _onenter = sg.states["attack"].onenter 

	sg.states["attack"].onenter = function(inst) 
		_onenter(inst) 
	
		local equip = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
		local cooldown = inst.components.combat.min_attack_period + 300 * FRAMES
		
		if equip ~= nil and equip:HasTag("sprayer") then		
				inst.AnimState:PlayAnimation("ngnt")
		end	
			cooldown = math.max(cooldown, 300 * FRAMES)		
	end
end

AddStategraphPostInit("wilson", avtofir)

tag is called "sprayer".

Cheers!

Thanks.It gives me some ideas.

Link to comment
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
 Share

×
  • Create New...