JaccK1618 Posted June 22, 2021 Share Posted June 22, 2021 1st question: how do I add tumbleweed loot and where do I put it in the code? 2nd: is there a line of code that will make all nearby mobs wake up? If so, where do I put that line? Thanks in advance. Link to comment https://forums.kleientertainment.com/forums/topic/131068-tumbleweed-loot-and-waking-up-nearby-mobs/ Share on other sites More sharing options...
HarryPPP Posted June 22, 2021 Share Posted June 22, 2021 (edited) About the Tumbleweed, I'm not quite sure, but I can help with the wake up mobs feature. This function should wake up everything in the selected range. local CANT_TAGS = { "test_tag", -- Having said tags will cause the function to fail. } local RANGE = 8 -- The range. local function WakeUp(source, range, cant_tags) local x, y, z = source.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x, y, z, range, nil, cant_tags) -- Find all entities in said range, ignoring the ones with the CANT_TAGS. for i, v in ipairs(ents) do -- For each entity found, do: if v.components.sleeper ~= nil and v.components.sleeper:IsAsleep() then -- Sleeper is used for creatures such as Hounds, Pigs... v.components.sleeper:WakeUp() elseif v.components.grogginess ~= nil and v.components.grogginess:IsKnockedOut() then -- Grogginess is used mainly for players. v.components.grogginess:ComeTo() end end end You can call this function from inside the Lua file using: WakeUp(inst, RANGE, CANT_TAGS) (This example implies that you are trying to make a prefab with it. If it's not, then you would need to get an entity other than "inst" to serve as the focus point. You could also modify the function a bit to get world coordinates, rather than using another entity as the reference point.) Edited June 22, 2021 by HarryPPP 1 Link to comment https://forums.kleientertainment.com/forums/topic/131068-tumbleweed-loot-and-waking-up-nearby-mobs/#findComment-1471323 Share on other sites More sharing options...
Monti18 Posted June 22, 2021 Share Posted June 22, 2021 As an answer to your first question, you can have a look at this mod to see how they did. They copied the MakeLoot function and replaced the original with their version with more trinkets. Another way to do it would be to change the inst.loot table after it was filled and then have a chance that one or more items are replaced by the item you want. 2 Link to comment https://forums.kleientertainment.com/forums/topic/131068-tumbleweed-loot-and-waking-up-nearby-mobs/#findComment-1471333 Share on other sites More sharing options...
JaccK1618 Posted June 22, 2021 Author Share Posted June 22, 2021 38 minutes ago, HarryPPP said: About the Tumbleweed, I'm not quite sure, but I can help with the wake up mobs feature. This function should wake up everything in the selected range. local CANT_TAGS = { "test_tag", -- Having said tags will cause the function to fail. } local RANGE = 8 -- The range. local function WakeUp(source, range, cant_tags) local x, y, z = source.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x, y, z, range, nil, cant_tags) -- Find all entities in said range, ignoring the ones with the CANT_TAGS. for i, v in ipairs(ents) do -- For each entity found, do: if v.components.sleeper ~= nil and v.components.sleeper:IsAsleep() then -- Sleeper is used for creatures such as Hounds, Pigs... v.components.sleeper:WakeUp() elseif v.components.grogginess ~= nil and v.components.grogginess:IsKnockedOut() then -- Grogginess is used mainly for players. v.components.grogginess:ComeTo() end end end You can call this function from inside the Lua file using: WakeUp(inst, RANGE, CANT_TAGS) (This example implies that you are trying to make a prefab with it. If it's not, then you would need to get an entity other than "inst" to serve as the focus point. You could also modify the function a bit to get world coordinates, rather than using another entity as the reference point.) So do I use both of these? Where do I put them? Link to comment https://forums.kleientertainment.com/forums/topic/131068-tumbleweed-loot-and-waking-up-nearby-mobs/#findComment-1471340 Share on other sites More sharing options...
JaccK1618 Posted June 22, 2021 Author Share Posted June 22, 2021 3 hours ago, HarryPPP said: About the Tumbleweed, I'm not quite sure, but I can help with the wake up mobs feature. This function should wake up everything in the selected range. local CANT_TAGS = { "test_tag", -- Having said tags will cause the function to fail. } local RANGE = 8 -- The range. local function WakeUp(source, range, cant_tags) local x, y, z = source.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x, y, z, range, nil, cant_tags) -- Find all entities in said range, ignoring the ones with the CANT_TAGS. for i, v in ipairs(ents) do -- For each entity found, do: if v.components.sleeper ~= nil and v.components.sleeper:IsAsleep() then -- Sleeper is used for creatures such as Hounds, Pigs... v.components.sleeper:WakeUp() elseif v.components.grogginess ~= nil and v.components.grogginess:IsKnockedOut() then -- Grogginess is used mainly for players. v.components.grogginess:ComeTo() end end end You can call this function from inside the Lua file using: WakeUp(inst, RANGE, CANT_TAGS) (This example implies that you are trying to make a prefab with it. If it's not, then you would need to get an entity other than "inst" to serve as the focus point. You could also modify the function a bit to get world coordinates, rather than using another entity as the reference point.) It's not working, I don't think I put it in the right spots. Alright it does work, had to bump up range. Link to comment https://forums.kleientertainment.com/forums/topic/131068-tumbleweed-loot-and-waking-up-nearby-mobs/#findComment-1471392 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