Jump to content

Recommended Posts

I would like to have a character refuse to attack mobs with certain tags, 

I have an 'if' 'else' statement for damage multiplication depending on tags, but is there a way to make the character tell the player he won't do attack, and refuse to go attack it?

Link to comment
https://forums.kleientertainment.com/forums/topic/85203-refusal-to-attack/
Share on other sites

local function DoAttack(inst, data)
	if data.target and data.target:HasTag("whatever_you_want_here_idk_it_could_be_pigs_or_spiders_I_dont_judge") then
			inst.sg:GoToState("idle")
	end
end


--put this in your masterpostinit
inst:ListenForEvent("doattack", DoAttack)

I just took a guess, have no idea if this works or not. If it doesn't work I'll give you a better function when I get back from work,

It hasn't worked for me : / just got home and tried it It crashed and gave me an error about data not being defined

Edit: It doesn't crash anymore, but the character still attacks and does damage.

 

Edited by TagumonYatsuray
Update

Lets do a little debugging to find out if its being called correctly.

In that code snippet above, can you replace  inst:GoToState("idle")   with   print("DONT SWING") 

now launch a game and press Ctrl-L and try and attack an animal with one of those tags listed. if "DONT SWING" shows up, then we know its getting called right. But if not, then we need to look elsewhere for the problem

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...