. . . Posted September 15, 2016 Share Posted September 15, 2016 (edited) Hello, ! If someone can please explain to me what these codes do because i'm trying to make my entity follow my character nicely but it moves so random because I don't know what this code means so I keep adding random numbers ... !!! local MIN_FOLLOW_DIST = 20 local TARGET_FOLLOW_DIST = 5 local MAX_FOLLOW_DIST = 10 Follow(self.inst, GetLeader, MIN_FOLLOW, TARGET_FOLLOW, MAX_FOLLOW, true)), local MAX_WANDER_DIST = 666 Wander(self.inst, GetWanderPosition, MAX_WANDER_DIST) local RUN_AWAY_DIST = 10 local STOP_RUN_AWAY_DIST = 10 WhileNode(function() return self.inst.components.health:GetPercent() < 75 end, "LowHealth", RunAway(self.inst, "jesuschrist", RUN_AWAY_DIST, STOP_RUN_AWAY_DIST)), local MAX_CHASE_TIME = 0 ChaseAndAttack(self.inst, 999), If someone could tell me what these things do I really would appreciate it! I'm soooo tired of messing around with random numbers not knowing what i'm doing !!! Thank you so much for reading my question, have a wonderful day/night !!! Edited September 19, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/70157-solved-question-about-entity-brain/ Share on other sites More sharing options...
chromiumboy Posted September 16, 2016 Share Posted September 16, 2016 (edited) IIRC Min follow: how close a following entity is allowed to be to its target Max follow: how far an entity can be from its target before being forced to follow Target follow: when an entity starts to follow it'll pick a position this far away from its target and move to it (when it stops or its brain updates and it is too close or too far from the target it'll adjust its position) Max wander: how far it can wander from a known location (usually its home). Basically its able to roam anywhere in a circle centred on this location (radius of which is max wander) Run away dist: how close something scary can get before an entity runs away Stop run dist: when an entity starts to run it'll pick a point this far directly away and run to it Max chase time: how long (in seconds) an attacking entity will chase a target before giving up Edited September 16, 2016 by chromiumboy Link to comment https://forums.kleientertainment.com/forums/topic/70157-solved-question-about-entity-brain/#findComment-814241 Share on other sites More sharing options...
. . . Posted September 16, 2016 Author Share Posted September 16, 2016 (edited) @chromiumboy I'm gonna have to copy & paste that in a txt file then I never forget !! I can finally understand what i'm doing!! Thank you so much kind sir!!! @chromiumboy If I can just ask you 1 more question if you know please tell me if you don't then just tell me you don't ! So, my question is if I want to give some variance to my follower's follow dist & I make something like this & put it in its brain would it work? local function RandomFollowDistance(inst) inst:DoTaskInTime(1, function() if math.random() > 0.50 then inst.brain:ForceUpdate() local MAX_FOLLOW_DIST = 1 elseif math.random() > 0.33 then inst.brain:ForceUpdate() local MAX_FOLLOW_DIST = 5 elseif math.random() > 0.33 then inst.brain:ForceUpdate() local MAX_FOLLOW_DIST = 33 end end) end EDIT: It seems it doesn't work ... Would you know if something like this is possible? Maybe making my follower switch brains every couple seconds? Edited September 16, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/70157-solved-question-about-entity-brain/#findComment-814264 Share on other sites More sharing options...
Serpens Posted September 16, 2016 Share Posted September 16, 2016 (edited) I don't know much about what you are trying there, but I know that using "local" for the same variable more then once in the same function is evil (also don't know why, but it will always causes errors). so define your variable first and then write it without local before. And try to use intendtations.. local function RandomFollowDistance(inst) inst:DoTaskInTime(1, function() local MAX_FOLLOW_DIST = x -- replace x with a number of course if math.random() > 0.50 then inst.brain:ForceUpdate() MAX_FOLLOW_DIST = 1 elseif math.random() > 0.33 then inst.brain:ForceUpdate() MAX_FOLLOW_DIST = 5 elseif math.random() > 0.33 then inst.brain:ForceUpdate() MAX_FOLLOW_DIST = 33 end end) end if you already defined the local MAX_FOLLOW_DIST elsewehere in your script, outside of a function, then of course you don't need the "...= x" line, cause it is already defined as local. (only define a variable as local once!) edit: just some explanation about "local": If you write local test = 1 in your script, outside of any function, that means that this variable "test" will be accessable in your whole script, outside and inside of your functions of that script. But it won't be accessable in other scripts of course. If you write it instead inside of a function, that means that it will be only accessable in this specific function, not in other functions and not outside of functions. Edited September 16, 2016 by Serpens Link to comment https://forums.kleientertainment.com/forums/topic/70157-solved-question-about-entity-brain/#findComment-814393 Share on other sites More sharing options...
. . . Posted September 16, 2016 Author Share Posted September 16, 2016 2 hours ago, Serpens said: I don't know much about what you are trying there I'm trying to make my entity be a little more random (like a player) so I want to change it's follow distance every couple seconds but it seems it doesn't work .. I tried code like this but my follower never even activates this function? Do you maybe know how I can make this function activate for my entity every 5 seconds? local function RandomFollowDistance(inst) inst:DoTaskInTime(5, function() if math.random() > 0.50 then MAX_FOLLOW_DIST = 1 MAX_FOLLOW = 1 TARGET_FOLLOW_DIST = 1 MIN_FOLLOW_DIST = 1 MIN_FOLLOW = 1 TARGET_FOLLOW = 1 inst.brain:ForceUpdate() inst.components.talker:Say("Blah...") elseif math.random() > 0.33 then MAX_FOLLOW_DIST = 5 MAX_FOLLOW = 5 TARGET_FOLLOW_DIST = 5 MIN_FOLLOW_DIST = 5 MIN_FOLLOW = 5 TARGET_FOLLOW = 5 inst.brain:ForceUpdate() inst.components.talker:Say("Blah...") elseif math.random() > 0.33 then MAX_FOLLOW_DIST = 10 MAX_FOLLOW = 10 TARGET_FOLLOW_DIST = 10 MIN_FOLLOW_DIST = 10 MIN_FOLLOW = 10 TARGET_FOLLOW = 10 inst.brain:ForceUpdate() inst.components.talker:Say("Blah...") end end) end Link to comment https://forums.kleientertainment.com/forums/topic/70157-solved-question-about-entity-brain/#findComment-814441 Share on other sites More sharing options...
Serpens Posted September 16, 2016 Share Posted September 16, 2016 (edited) 13 minutes ago, SuperDavid said: I'm trying to make my entity be a little more random (like a player) so I want to change it's follow distance every couple seconds but it seems it doesn't work .. I tried code like this but my follower never even activates this function? Do you maybe know how I can make this function activate for my entity every 5 seconds? of course you have to call "RandomFollowDistance" at some point. for debuggin, so seeing if the function is called, you can also add "print" statements and see the logfile if it is printet (Or hit CTRL+L while ingame and playing as host, to see the logs ingame) Edited September 16, 2016 by Serpens Link to comment https://forums.kleientertainment.com/forums/topic/70157-solved-question-about-entity-brain/#findComment-814442 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