Jump to content

[Help Request] How to make Koalefants follow


Recommended Posts

I hope it's okay that I made a new thread since it's sort of a different request, but if not I will happily delete it and continue my other thread.

 

That being said, I managed to get the code for the sanity perk near koalefants to work... Next on my list is to make koalefants follow when the character is wearing the hat I created.

 

The hat is already in game and currently only gives a sanity boost (which I can remove), but how would I go about scripting it so the koalefant will follow when she's wearing the hat?

 

I was thinking something along the lines of how the Spider Hat works, where the spiders will follow and attack whatever you attack, but doesn't perish. Any help would be great :D

 

Meanwhile, I'm going to go butcher some codes to see if I can figure it out myself :p

Link to comment
Share on other sites

You are going to have to modify the koalefant.lua, adding:

inst:AddComponent("follower")

Then, copy the spider hat spider() in hats.lua, with all its functions (spider_enable, spider_update, ...), and rename "spider" for "koalefant" (possibly removing other things like AddTag("monster") so other things don't attack you).

 

Lastly you will have to edit the koalefant brain to add:

Follow(self.inst, function() return self.inst.components.follower.leader end, MIN_FOLLOW_DIST, TARGET_FOLLOW_DIST, MAX_FOLLOW_DIST)

But I'm not sure how to edit a brain without overriding the entire file.

Link to comment
Share on other sites

You are going to have to modify the koalefant.lua, adding:

inst:AddComponent("follower")

Then, copy the spider hat spider() in hats.lua, with all its functions (spider_enable, spider_update, ...), and rename "spider" for "koalefant" (possibly removing other things like AddTag("monster") so other things don't attack you).

 

Lastly you will have to edit the koalefant brain to add:

Follow(self.inst, function() return self.inst.components.follower.leader end, MIN_FOLLOW_DIST, TARGET_FOLLOW_DIST, MAX_FOLLOW_DIST)

But I'm not sure how to edit a brain without overriding the entire file.

 

Thank you so much for the response. I have a couple questions, if you don't mind!

 

Am I adding the spider hat from the hats.lua to the koalefant.lua? Or to the hat that I've already created?

 

I just tried adding the spider hat thing to the hat I've already created and the koalefant still runs away.

 

I'll include my files here so hopefully someone can tell me what I'm doing wrong (which is probably a lot, since I have no idea what I'm doing).

 

Please, feel free to pull this apart and tell me I'm an idiot lol

 

koalefantbrain.luaaza_hat.luakoalefant.lua

Edited by lozersneeze
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...