Don't Starve Together

Don't Starve Together

Caster(Fate/Stay Night)
Hydrologist 24 Apr, 2016 @ 11:53pm
Assassin attacking non-monster mobs
Hey there,

So I was trying to fix Assassin not attacking non-monsters. I don't know if you've since figured it out yourself, but I think I found out how:

On line 94 of summonassassin.lua in NormalRetargetFn(inst):

return guy:HasTag("monster") and guy.components.health and not guy.components.health:IsDead()

The 'animal' tag isn't being checked here, so Assassin isn't ever going to target anything other than monsters.

I added some code to check whether the player is also targeting an animal, since just changing the code to

return (guy:HasTag("monster") or guy:HasTag("animal")) and guy.components.health and not guy.components.health:IsDead()

causes Assassin to attack all animals on sight, even passive ones. Problem is, this is my first time messing with DST mods, so I haven't been able to find a good way to reference the player's instance to access their target.

I tried inst.components.follower.leader.components.combat.target, but that seems to lack the combat field (game crashes with an error indicating that 'combat' is a nil value).

So far, I've managed to get Assassin working with the player targeting system by hacking in an 'owner' variable borrowed from Abigail's code, but I haven't figured out how to get that variable to persist between server stops and starts. Without it, the game will just crash once an animal comes near Assassin since 'owner' is nil after a restart.

I hope I could help a little in diagnosing the problem. Thanks a lot for the mod, it's been great fun playing with it.

Cheers,

Silky