Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

barbilou

Need help with friendly mobs

Recommended Posts

barbilou    1

Hello! I've been working on a mod for a while now and need help updating it with one of its main traits: which is that catcoons are friendly to the character.

First is: how do I make it so that, once I get near a catcoon, it will automatically follow me around? I'm looking for a similar behaviour as what spiders do with Webber, except without the need of feeding them to be domesticated.

And second is: how do I make it so that, in case I kill one of them, I lose sanity? I tried to copy Wormwood's sanity loss from killing plants and all but it was a mess-

Thanks in advance ;_;

Share this post


Link to post
Share on other sites
penguin0616    1101

I suggest that for the catcoon follower part, you take a look at the spiderhat prefab. Equipping it causes nearby spiders to become your followers while the hat is equipped.

As for the kill, you could listen to the killed event on the player. Here's a rough example that may/may not work. It'll require editing either way though, since GetPlayer() should be replaced assuming you put this in the character prefab.

-- whether this works is entirely luck, i'm going off of memory here
GetPlayer():ListenForEvent("killed", function(inst, data)
    if data.prefab == "catcoon" then
      inst.components.sanity:DoDelta(-10)
    end
end)

 

Share this post


Link to post
Share on other sites