Ghost_starved Posted May 12, 2021 Share Posted May 12, 2021 (edited) I was given the code by a good person and I am very grateful to him. But! it does not work if there are caves in the world and can this be eliminated (One of my friends said that we need to check the caves) how to make it? Edited May 12, 2021 by Ghost_starved Link to comment https://forums.kleientertainment.com/forums/topic/129894-checking-caves/ Share on other sites More sharing options...
Wonderlarr Posted May 12, 2021 Share Posted May 12, 2021 4 minutes ago, Ghost_starved said: I was given the code by a good person and I am very grateful to him. But! it does not work if there are caves in the world and can this be eliminated (One of my friends said that we need to check the caves) how to make it? Usually when code doesn't work with caves, that means it's not coded properly for a server, which means it probably won't work with multiple players on a server without caves. What kindof error are you getting specifically. 1 Link to comment https://forums.kleientertainment.com/forums/topic/129894-checking-caves/#findComment-1459625 Share on other sites More sharing options...
Ghost_starved Posted May 12, 2021 Author Share Posted May 12, 2021 13 minutes ago, TheSkylarr said: Usually when code doesn't work with caves, that means it's not coded properly for a server, which means it probably won't work with multiple players on a server without caves. What kindof error are you getting specifically. just a bug and disconnection of the game. (If you know, can you suggest the code instead of what I was given before?) Recovering the sanity of a webber if he is next to my character Link to comment https://forums.kleientertainment.com/forums/topic/129894-checking-caves/#findComment-1459627 Share on other sites More sharing options...
Wonderlarr Posted May 12, 2021 Share Posted May 12, 2021 4 hours ago, Ghost_starved said: just a bug and disconnection of the game. (If you know, can you suggest the code instead of what I was given before?) Recovering the sanity of a webber if he is next to my character Can you send me what you were given before? Link to comment https://forums.kleientertainment.com/forums/topic/129894-checking-caves/#findComment-1459697 Share on other sites More sharing options...
Ghost_starved Posted May 13, 2021 Author Share Posted May 13, 2021 6 hours ago, TheSkylarr said: Can you send me what you were given before? 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) Link to comment https://forums.kleientertainment.com/forums/topic/129894-checking-caves/#findComment-1459785 Share on other sites More sharing options...
Ghost_starved Posted May 13, 2021 Author Share Posted May 13, 2021 I have a second one, but it just gives sanity and does not regenerate local function WebberSanityAura(inst) local x,y,z = inst.Transform:GetWorldPosition() local pt = inst:GetPosition() local range = 10 -- range of ability local SANITYREGAIN = 7 -- Amount of Sanity regained to Webber per tick local tagz = { "_combat"} local canttagz = {"structure"} local check = TheSim:FindEntities(pt.x,pt.y,pt.z, range, tagz, canttagz) for _,ent in ipairs(check) do if not ent.components.health:IsDead() and ent.prefab == "webber" then ent.components.sanity:DoDelta(SANITYREGAIN) if ent.components.combat then ent.components.combat:SuggestTarget(inst) end end end end local function maincheck(inst) if not inst.components.health:IsDead() and not inst:HasTag("playerghost") and not inst:HasTag("playermonster") then WebberSanityAura(inst) end end -- 1 time interval between every tick (seconds-ish, it's not 100% accurate) inst:DoPeriodicTask(2, maincheck, nil, inst) end can it be made regenerative? Link to comment https://forums.kleientertainment.com/forums/topic/129894-checking-caves/#findComment-1459862 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