WubbleWubble Posted March 31, 2017 Share Posted March 31, 2017 Hiya there, I was looking for some help with a character I'm creating. He's gonna be sort of a therapist character, increasing sanity of nearby people. But, I also want it to be that insanity sort of rubs off on him. Like, making it so that if he's near someone who's below, let's say, 50% sanity, then he will start to lose sanity. How would I go about doing this? Link to comment Share on other sites More sharing options...
Hineios Posted March 31, 2017 Share Posted March 31, 2017 I would suggest you take a look at this function: TheSim:FindEntities(x, y, z, radius, musttags, canttags, mustoneoftags) Since every player has the tag "player" you could use this to find players around your character. Link to comment Share on other sites More sharing options...
WubbleWubble Posted March 31, 2017 Author Share Posted March 31, 2017 Thank you, is there anyway to check if the players around him are insane? Link to comment Share on other sites More sharing options...
CarlZalph Posted March 31, 2017 Share Posted March 31, 2017 (edited) 13 hours ago, WubbleWubble said: Hiya there, I was looking for some help with a character I'm creating. He's gonna be sort of a therapist character, increasing sanity of nearby people. But, I also want it to be that insanity sort of rubs off on him. Like, making it so that if he's near someone who's below, let's say, 50% sanity, then he will start to lose sanity. How would I go about doing this? 5 hours ago, WubbleWubble said: Thank you, is there anyway to check if the players around him are insane? inst:DoPeriodicTask( 1.0, function(inst) local x, y, z = inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x, y, z, 4.0, {"player"}, {"playerghost"}) local selfsanity = 1 for _,v in pairs(ents) do if v~=inst then v.components.sanity:DoDelta(1) if v.components.sanity:IsCrazy() then selfsanity = selfsanity - 1 end end end inst.components.sanity:DoDelta(selfsanity) end ) I commented out the 50% sanity thing and have the sane portion. This would be in the master_postinit callback. 4.0 = radius of effect, and is 1 turf square in size for relative dimension comparing. Edited March 31, 2017 by CarlZalph 'he' usage unclear, changed specification to mean 'other person' Link to comment Share on other sites More sharing options...
WubbleWubble Posted March 31, 2017 Author Share Posted March 31, 2017 Thank you! It worked like a charm! Link to comment Share on other sites More sharing options...
CarlZalph Posted March 31, 2017 Share Posted March 31, 2017 1 hour ago, WubbleWubble said: Thank you! It worked like a charm! I changed some stuff around, code you're using is going to make the 'patient' lose sanity instead of the 'doctor'. Link to comment Share on other sites More sharing options...
WubbleWubble Posted April 1, 2017 Author Share Posted April 1, 2017 Thank you! On another note, do you think any of you could help me make the sanity aura silent? It makes the depleting noise every time Link to comment 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