Ghost_starved Posted May 7, 2021 Share Posted May 7, 2021 Explain how to make Webber restore his sanity when he is next to my character Link to comment Share on other sites More sharing options...
Gleenus Posted May 7, 2021 Share Posted May 7, 2021 5 minutes ago, Ghost_starved said: Explain how to make Webber restore his sanity when he is next to my character Take a look in Walter's code He restore sanity when get close to trees Copy the code, change trees to your character Link to comment Share on other sites More sharing options...
Ghost_starved Posted May 7, 2021 Author Share Posted May 7, 2021 14 minutes ago, Gleenus said: Take a look in Walter's code He restore sanity when get close to trees Copy the code, change trees to your character local function UpdateTreeSanityGain(inst) local x, y, z = inst.Transform:GetWorldPosition() local num_trees = #TheSim:FindEntities(x, y, z, TUNING.WALTER_TREE_SANITY_RADIUS, REQUIRED_TREE_TAGS, EXCLUDE_TREE_TAGS) inst._tree_sanity_gain = num_trees >= TUNING.WALTER_TREE_SANITY_THRESHOLD and TUNING.WALTER_TREE_SANITY_BONUS or 0 end . This ? It's just then I don't quite understand how to change it Link to comment Share on other sites More sharing options...
Ghost_starved Posted May 8, 2021 Author Share Posted May 8, 2021 16 hours ago, Gleenus said: Take a look in Walter's code He restore sanity when get close to trees Copy the code, change trees to your character I just love it when they answer me 1 time and then without acknowledgments of life Link to comment Share on other sites More sharing options...
Gleenus Posted May 8, 2021 Share Posted May 8, 2021 2 hours ago, Ghost_starved said: I just love it when they answer me 1 time and then without acknowledgments of life Bro, I'm not a frequent forum user, since I have work to do I already gave you the perfect example to do what you asked 18 hours ago, Ghost_starved said: local function UpdateTreeSanityGain(inst) local x, y, z = inst.Transform:GetWorldPosition() local num_trees = #TheSim:FindEntities(x, y, z, TUNING.WALTER_TREE_SANITY_RADIUS, REQUIRED_TREE_TAGS, EXCLUDE_TREE_TAGS) inst._tree_sanity_gain = num_trees >= TUNING.WALTER_TREE_SANITY_THRESHOLD and TUNING.WALTER_TREE_SANITY_BONUS or 0 end . This ? It's just then I don't quite understand how to change it If you are not familiar with modding, you need to start with simpler things I would recommend some videos, but they are in Portuguese Download mods from other people, read how they code things You want to look for something around the player? search for mods that look for items around the player In this function you get the player position, you look for entities with REQUIRED_TAGS and without EXCLUDE_TAGS in a RADIUS around the player Then you count the #number of entities found If this value is higher than a THRESHOLD, you return a sanity aura bonus Just read it calmly, try to change the values and the tables, see what is changed in the game Or you want to someone in forum write your code? (You asked for a rude answer) Did you tried to implement a hard copy of Walter function in your character before "demand" for more answers? Did you changed any value on that to see what happens? 2 Link to comment Share on other sites More sharing options...
Ghost_starved Posted May 9, 2021 Author Share Posted May 9, 2021 On 5/8/2021 at 3:12 PM, Gleenus said: Bro, I'm not a frequent forum user, since I have work to do I already gave you the perfect example to do what you asked If you are not familiar with modding, you need to start with simpler things I would recommend some videos, but they are in Portuguese Download mods from other people, read how they code things You want to look for something around the player? search for mods that look for items around the player In this function you get the player position, you look for entities with REQUIRED_TAGS and without EXCLUDE_TAGS in a RADIUS around the player Then you count the #number of entities found If this value is higher than a THRESHOLD, you return a sanity aura bonus Just read it calmly, try to change the values and the tables, see what is changed in the game Or you want to someone in forum write your code? (You asked for a rude answer) Did you tried to implement a hard copy of Walter function in your character before "demand" for more answers? Did you changed any value on that to see what happens? Well, personally, it seems to me that this is not such a rude answer. I asked a lot on the forum where they gave me 1 answer and then there was a complete ignorance of my existence. I ransacked the entire steam workshop 2 times (this is not a joke) (this is how I wrote the character code) Regarding moding, I'm not a very experienced person, and that's all that remains to be done .-. However, I did not find any examples with this code. And this code with Walter is not clear enough. Anyway, I'm sorry if I offended you. Link to comment Share on other sites More sharing options...
Gleenus Posted May 10, 2021 Share Posted May 10, 2021 7 hours ago, Ghost_starved said: Well, personally, it seems to me that this is not such a rude answer. I asked a lot on the forum where they gave me 1 answer and then there was a complete ignorance of my existence. I ransacked the entire steam workshop 2 times (this is not a joke) (this is how I wrote the character code) Regarding moding, I'm not a very experienced person, and that's all that remains to be done .-. However, I did not find any examples with this code. And this code with Walter is not clear enough. Anyway, I'm sorry if I offended you. You want to Webber restore sanity when its close to your character, the proper way to do it is by adding to Webber prefab (post init) the same function that Walter uses to get sanity from trees, but instead for checking for tree tags, look for a tag that only exists on your character On your character prefab function (fn), add the tag line inst:AddTag("webberlovemyprettycharacter") Now on your modmain: local function IsMyPrettyCharacterNearby(inst) local x, y, z = inst.Transform:GetWorldPosition() local num_char = #GLOBAL.TheSim:FindEntities(x, y, z, 10, {"webberlovemyprettycharacter"}) -- Here I'm using a radius equal to 10 if num_char > 0 then inst.num_char=1 else inst.num_char=0 end return 0 -- num_char is 1 if there is at least 1 of yourcharacter nearby, else is 0 end local function CustomSanityFn(inst, dt) return inst.num_char*500 -- a lot of sanity end AddPrefabPostInit("webber",function(inst) inst.num_char=0 inst._update_character_sanity_task = inst:DoPeriodicTask(3, IsMyPrettyCharacterNearby) -- One verification every 3 seconds inst.components.sanity.custom_rate_fn = CustomSanityFn end) 1 Link to comment Share on other sites More sharing options...
Ghost_starved Posted May 10, 2021 Author Share Posted May 10, 2021 thanks :3 Link to comment Share on other sites More sharing options...
Ghost_starved Posted May 10, 2021 Author Share Posted May 10, 2021 14 hours ago, Gleenus said: You want to Webber restore sanity when its close to your character, the proper way to do it is by adding to Webber prefab (post init) the same function that Walter uses to get sanity from trees, but instead for checking for tree tags, look for a tag that only exists on your character On your character prefab function (fn), add the tag line inst:AddTag("webberlovemyprettycharacter") Now on your modmain: local function IsMyPrettyCharacterNearby(inst) local x, y, z = inst.Transform:GetWorldPosition() local num_char = #GLOBAL.TheSim:FindEntities(x, y, z, 10, {"webberlovemyprettycharacter"}) -- Here I'm using a radius equal to 10 if num_char > 0 then inst.num_char=1 else inst.num_char=0 end return 0 -- num_char is 1 if there is at least 1 of yourcharacter nearby, else is 0 end local function CustomSanityFn(inst, dt) return inst.num_char*500 -- a lot of sanity end AddPrefabPostInit("webber",function(inst) inst.num_char=0 inst._update_character_sanity_task = inst:DoPeriodicTask(3, IsMyPrettyCharacterNearby) -- One verification every 3 seconds inst.components.sanity.custom_rate_fn = CustomSanityFn end) Logs indicate error 223 lines (inst.components.sanity.custom_rate_fn = CustomSanityFn) Link to comment Share on other sites More sharing options...
Gleenus Posted May 10, 2021 Share Posted May 10, 2021 3 minutes ago, Ghost_starved said: Logs indicate error 223 lines (inst.components.sanity.custom_rate_fn = CustomSanityFn) I gave you a nearly code base (in plain text), that I just copy from Walter's code Now I think you can debug it Read the error, look in the line, make some changes, see what happens btw you telling "223" doen't mean a thing without a full log and all your mod files 1 Link to comment Share on other sites More sharing options...
Ghost_starved Posted May 10, 2021 Author Share Posted May 10, 2021 (edited) 7 minutes ago, Gleenus said: I gave you a nearly code base (in plain text), that I just copy from Walter's code Now I think you can debug it Read the error, look in the line, make some changes, see what happens btw you telling "223" doen't mean a thing without a full log and all your mod files Thank you so much :з Edited May 10, 2021 by Ghost_starved Link to comment Share on other sites More sharing options...
Ghost_starved Posted May 12, 2021 Author Share Posted May 12, 2021 On 5/10/2021 at 7:36 PM, Gleenus said: I gave you a nearly code base (in plain text), that I just copy from Walter's code Now I think you can debug it Read the error, look in the line, make some changes, see what happens btw you telling "223" doen't mean a thing without a full log and all your mod files Can you tell me how you can add a check to the caves? When you start a server with caves and select a webber, the game breaks, but if you play without caves everything is fine 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