Jump to content

How to get custom creature to follow and fight for you.


Recommended Posts

I made a Tiny Box Tim for my Markiplier mod and had many bugs with him not following me if I left to the caves or died and revived at a touchstone or something... so if you have similar bugs insert this into your creature's prefab file not brain

 

inst:AddComponent("follower")
inst:DoPeriodicTask(1/10, function()
local player = GetPlayer()
if player and player.components.leader then
player.components.leader:AddFollower(inst)
end
end)
 
then further-more write this into your character's prefab name
(inside the fn function)
 
inst:AddComponent("leader")
 
unless you are making this creature for all characters then you will want to look into postinits...
Link to comment
Share on other sites

Now after MUCH toying and detective work in the data files, I got my creature to successfully follow me. Now I want it to fight for me. How would I do that?

Did you give the creature the combat component?

 

And put: 

        ChaseAndAttack(self.inst, 5),

in the brain's OnStart() function?

Link to comment
Share on other sites

 

then further-more write this into your character's prefab name
(inside the fn function)
 
inst:AddComponent("leader")
 
unless you are making this creature for all characters then you will want to look into postinits...

 

Nope, all the characters already have the leader component. Don't need to add that anywhere on the character.

Link to comment
Share on other sites

Did you give the creature the combat component?

 

And put: 

        ChaseAndAttack(self.inst, 5),

in the brain's OnStart() function?

I'm actually using your William mod to decipher which parts control combat, it's a bloody fantastic mod, and I'll try adding those lines.

Link to comment
Share on other sites

I'm actually using your William mod to decipher which parts control combat, it's a bloody fantastic mod, and I'll try adding those lines.

I've made and am making better.

 

The robots are just a modified Shadow Puppet (minions summoned by playable Maxwell) to have different functions. Looking through their coding would probably help alot.

Link to comment
Share on other sites

I've made and am making better.

 

The robots are just a modified Shadow Puppet (minions summoned by playable Maxwell) to have different functions. Looking through their coding would probably help alot.

It seems to work, but it does no damage, I assume I have to set the damage through. Also could I add you on steam if I have other coding questions, and also you seem like a pretty cool guy.

Link to comment
Share on other sites

It seems to work, but it does no damage, I assume I have to set the damage through. Also could I add you on steam if I have other coding questions, and also you seem like a pretty cool guy.

If you can handle my unstable brain, sure.

 

And yeah, pretty sure you need to set damage.

 

Also, make sure in the stategraph you have:

 

            inst.sg.statemem.target = inst.components.combat.target
            inst.components.combat:StartAttack()

 

    and

 

inst.components.combat:DoAttack(inst.sg.statemem.target)

Link to comment
Share on other sites

Question, how can I get my SG working to have my creature running correctly from all angles, Ex. changing to side running animation when running to the side. And attack animation for side too.

Link to comment
Share on other sites

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.

×
  • Create New...