Codelyy Posted May 28, 2015 Share Posted May 28, 2015 I'm making a sort of test character that has a perk where she won't get attack by monsters however have an idea of how to code that into my character so i was wondering if anyone would like to give me a simple code to make monsters avoid my character. Another thing that i would love to be added but doesn't have to be is the monsters afraid animation is played when my character gets close. It would mean a lot if someone helped me with this :3 Link to comment https://forums.kleientertainment.com/forums/topic/54499-character-perk-help/ Share on other sites More sharing options...
Crestonia Posted May 28, 2015 Share Posted May 28, 2015 I don't know how to code for all monsters to not be aggressive to your character, however, I do know how to do this with Tallbirds. Would you like to know? Link to comment https://forums.kleientertainment.com/forums/topic/54499-character-perk-help/#findComment-641487 Share on other sites More sharing options...
Codelyy Posted May 28, 2015 Author Share Posted May 28, 2015 I don't know how to code for all monsters to not be aggressive to your character, however, I do know how to do this with Tallbirds. Would you like to know?Yes please :3 Link to comment https://forums.kleientertainment.com/forums/topic/54499-character-perk-help/#findComment-641552 Share on other sites More sharing options...
Isosurface Posted May 28, 2015 Share Posted May 28, 2015 You can use something like this: AddBrainPostInit(monster_prefab, function(self) GLOBAL.table.insert(self.bt.root.children, NUM, GLOBAL.RunAway(self.inst, tag, SEE_PLAYER_DIST, STOP_RUN_DIST))end) monster_prefab is the prefab name of monster.NUM is the position in the table where you insert this flee behaviour. This number also decides the priority.tag is a unique tag you attach to your character using inst:AddTag( ). Some mobs don't have a flee animation, forcing them to flee will result in weird/broken animation. Link to comment https://forums.kleientertainment.com/forums/topic/54499-character-perk-help/#findComment-641557 Share on other sites More sharing options...
Crestonia Posted May 28, 2015 Share Posted May 28, 2015 @codelyoko373In your character's prefab, put inst:AddTag("tallbird") under the local common_postinit. In your character's modmain, putAddPrefabPostInit("tallbird", function(inst) local old_sfn = inst.components.combat.SuggestTarget inst.components.combat.SuggestTarget = function(self, target) if target and target:HasTag("tallbird") then if target.components.combat.target ~= self.inst then return end end return old_sfn(self, target) endend)I put that under everything else in the modmain and it worked for me. I hope I helped! Link to comment https://forums.kleientertainment.com/forums/topic/54499-character-perk-help/#findComment-641615 Share on other sites More sharing options...
Codelyy Posted May 28, 2015 Author Share Posted May 28, 2015 You can use something like this: AddBrainPostInit(monster_prefab, function(self) GLOBAL.table.insert(self.bt.root.children, NUM, GLOBAL.RunAway(self.inst, tag, SEE_PLAYER_DIST, STOP_RUN_DIST))end) monster_prefab is the prefab name of monster.NUM is the position in the table where you insert this flee behaviour. This number also decides the priority.tag is a unique tag you attach to your character using inst:AddTag( ). Some mobs don't have a flee animation, forcing them to flee will result in weird/broken animation. Would this code still be active if the character attacked the monster told to not attack. Since what i would like is the monster not to attack at first sight but if the character attacks then the monster will Link to comment https://forums.kleientertainment.com/forums/topic/54499-character-perk-help/#findComment-641686 Share on other sites More sharing options...
Isosurface Posted May 28, 2015 Share Posted May 28, 2015 I have not tried that before, but what you should do probably is inserting the RunAway node after the ChaseAndAttack node, using an appropriate NUM value. Have a look at koalefant brain file to see how it's structured. Link to comment https://forums.kleientertainment.com/forums/topic/54499-character-perk-help/#findComment-641714 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now