Jump to content

Recommended Posts

I've been poking around some old code of mine, making updates and general improvements, and I found this in the hound's updated combat AI for target sharing.  The rest of the code basically says 'is this hound's leader a player', 'is the target a hound tamer', 'is the target a follower of your leader', but then this comes up.

				-- Prevents players and companions from being shared as a target.  --Note: Redundant?
				if target:HasTag("player")
				or target:HasTag("companion")
				then
					local houndtamer = GLOBAL.FindEntity(inst, 20, function(guy)
						return guy:HasTag("houndtamer")
					end)
					if houndtamer ~= nil then
						return
					end
				end

It happens if the target is a player or companion, but what is it doing?  I think it checks if there are any hound tamers on the server, and if there are the hound won't attack the target.  Am I understanding this code correctly?  With all my other checks this comes across as extremely strange and redundant.  I can't even imagine under what circumstances this would apply, so I'm trying to figure out what it applies to.

Link to comment
https://forums.kleientertainment.com/forums/topic/127471-return-guy/
Share on other sites

@penguin0616
Huh, weird..  So,,  If a hound tamer is nearby, the hound (which is already known to be following a player) won’t attack players or companions.  It seems really redundant to me.

I’ll review the code again later, maybe I’m overlooking something.
I spent tonight reviewing the code, cleaning it up, and now players can’t attack Trained hounds, and even pigmen will ignore them unless a fight breaks out!  :)

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