Bad Willow

Customizing Worldgen of Volcano and Caves

Recommended Posts

Bad Willow    19

20211021195900-1.jpg
I am working on hamlet volcano/caves mod and I'm trying to retain certain balances of Hamlet, for example, the scarcity of spider drops. I would like to customize the volcanoes and the caves generated and resize them. I was trying to use the SaveGameIndex:GetOriginOfTravel function to determine whether the current cave is generated by a hamlet world, but I discovered that, during worldgen, SaveGameIndex doesn't exit. So how would I tell the worldgen, upon spelunking or upon climbing the volcano, to generate a world with different presets?

Share this post


Link to post
Share on other sites
Bad Willow    19

So I am trying to do a level post init that'll swap out the starting task for my mini-volcano task, but the same problem that the SaveGameIndex isn't available and I do not know what other way you can pass a "hamlet" tag down that'll be accessible during world gen.

Share this post


Link to post
Share on other sites
Bad Willow    19

I have found an imperfect solution, adding volcano level # 2 to the level list, and overriding the volcano prefab so that you're sent level 2. i'm testing it rn... hopefully it works!

Share this post


Link to post
Share on other sites
Bad Willow    19

It did work. If you're also looking to solve this problem I have something like this

AddPrefabPostInit("porkland", function(world)	
	local Index = _G.SaveGameIndex
	local EnterWorld = Index.EnterWorld
	Index.EnterWorld = function(self, world, ...)
		if world ~= "volcano" then return EnterWorld(self, world, ...) end 
		local modes = Index.data.slots[Index.current_slot].modes 
		if not modes.volcano then modes.volcano = {} end 
		modes.volcano.world = 2
		if not modes.volcano.current_level then modes.volcano.current_level = {} end 
		modes.volcano.current_level[1] = 2
		modes.volcano.current_cave = 1
		
		return EnterWorld(self, world, ...) 
	end 
end)

 

Share this post


Link to post
Share on other sites
Unnat7    15

Hello,

Will the codes work for ROG as well? if I just replace "porkland" by "survival" and,

I tried to make the ROG season to transfer to the volcano but i don't know what to replace the 'Plateau()' with, and the other stuff you explained it in one of your other posts, it is kinda complex and I can't make it to work with the ROG seasons ,could you just share one that i can use  for my mod mentioned below

And the last thing, how do i make it so that the Summer season = Dry season, like the volcano eruptions and fog covering the screen happen in the summer because there is no dry season in ROG

 

I think this is your mod and you explained it here but i just couldn't understand how you did it (or i'm just to lazy to try)

 

 

And here are a few peeks to my mod

Spoiler

1234292476_2021-11-0222_40_23-Greenshot.thumb.png.1fe1e2089bc99a449432d1098c248ac3.png

i have made a compilation of mod which adds a lot of qols and DST-ish content into a basic ROG world ,you can now also craft boats and SW stuff in ROG, it adds the oasis biome (which is still incomplete) and of course a fully functional oasis lake, makes the dragonfly a raid boss and more rewarding to kill and adds beequeen, adds metors and..... I think that's enough for a peek ,I would be releasing the mod (beta) probably this or the next week but you can try it out by this => A_Custom_Mod.zip

Edit:- Forgot to mention that you need to change the game preset to 'custom mod' in the world settings before creating a world else you will get a normal ROG worldgen

WARNING:- There are a Looooot of Bugs

Genuinely speaking the mod is still not completed, I have yet to implement more features and there are a ton of bugs, so just play it for fun don't make a megabase or stuff because the mod might get some serious changes upon official release

And thanks to the authors I borrowed some codes from, all credits to them

 

Sorry if i'm asking for too much but my collage has started and I don't get enough time to test out stuff and play around with it that's why I thought asking someone who knows about the coding (more than me) would be a better idea, and i'm also in a hurry to complete/release the mod i'm working on so that people can have a better don't starve experience

 

...#NoLife

Edited by Unnat7

Share this post


Link to post
Share on other sites
Bad Willow    19

it's fine! let me re explain what I did more clearly!

the code I have in the other post is the code for a component that I added to the player. Because the data for the player is always reloaded when you world hop, you can use an added component to remember what world your player came from. I checked whether it was from one of the "main worlds", hamlet, shipwrecked, or rog, and then checked whether the new world is a "minor world", such as the volcano and the caves. And when both conditions are met I overwrite the current season setting with the season setting of the main world.

There is one bit I did that I did not mention, it is that I completely overwrote the seasonmanager component. If you check the component, you'll see that the component returns seasonmanager_pork if it's porkland, and so forth. When the game adds the season component to the world, the "world traveller" component hasn't loaded yet, so the game woudn't know which season mode it should go for. And if you check theseasonmanager_pork, you discover that the seasonmanager_pork actually contains seasons for all three season modes!!!! so I forced it to always return seasonmanager_pork.

If you check the prefab files of the worlds, which are porkland, shipwrecked, and forest, you'll see that each of them calls a function in the season manager to set the season mode, the function for porkland is Plateau, the one for shipwrecked is Tropical. Hence the bit with Plateau()

Share this post


Link to post
Share on other sites
Unnat7    15

Thanks!

That just means i'll have to borrow some codes from your mod and make it ROG compatible, but this helped a lot!

And what do you think about the mod that I have made? I know it's buggy but i'm on it and the only thing left from me to do is to add the sandstorm mechanic which is really hard considering i have no experience in coding 

For that I wanted to ask you some other things I do not know how to fix

1. The game is not showing the crafting recipe for any custom made structure, like at all (any recipes that has "name_placer" in it's crafting recipe codes)

2. How can i make it so that whenever the player is near a (custom made) prefab the game would put a overlay on the screen, I was thinking about using playerprox component for this but I don't know how can I do that 

maybe something like this

Spoiler

local function SandOverlay()

--i don't know what to put in here

end

 

local function OnFindFire(inst, firePos)
    inst:PushEvent("putoutfire", {firePos = firePos})
end

 

local function fn()

    inst:AddTag("NOCLICK")

    inst:AddTag("NOBLOCK")

    inst:AddComponent("playerprox")
    inst.components.playerprox:SetOnPlayerNear(SandOverlay)
    inst.components.playerprox:SetDist(15, 20)
    inst.components.playerprox.period = 1 -- I don't think I need this

    inst:AddComponent("firedetector")
    inst.components.firedetector:SetOnFindFireFn(OnFindFire)

end

 

Yeah, i'm gonna distribute these prefabs in the oasis biome to give it the sandstorm-ish effect, but I don't have a better idea, unless someone can figure out how to make the DST sandstorm's codes compatible for my for mod

Thanks in Advance!

 

 

...#NoLife

Edited by Unnat7
  • Thanks 1

Share this post


Link to post
Share on other sites
Bad Willow    19

yeah its fine you can use the code. i'm glad it works for you.

concerning the recipes, there's a difference between the recipe classes of the different DLCs, either starting with shipwrecked or starting with hamlet, the recipe class takes the "game mode" parameter. so when you're defining recipes without checking what recipe class is receiving the arguments, your argumetns end up getting displaced. you can check the recipe.lua (recipe in the singular) files and compare them between the base game, and the various DLCs. so if you are preparing a mod for compatibility, you would need to check whether to define a recipe with game mode or without. an example of this, I remember, is in the wagstaff prefab. when the tinkering items were defined, the prefab checks for whether a DLC is enabled, and then calls the recipe function in two different manners depending on the DLC.

As for the overlay... I don't know much. I would suggest figuring out how other overlays work out, maybe checking how the wagstaff goggles give overlays, maybe it's just a tag, and then doing a content search in the scripts folder to see how the tag is actually used.

 

good luck!!

Edited by Bad Willow

Share this post


Link to post
Share on other sites
KXWl1    9
On 11/12/2021 at 12:28 PM, Unnat7 said:

Thanks!

That just means i'll have to borrow some codes from your mod and make it ROG compatible, but this helped a lot!

And what do you think about the mod that I have made? I know it's buggy but i'm on it and the only thing left from me to do is to add the sandstorm mechanic which is really hard considering i have no experience in coding 

For that I wanted to ask you some other things I do not know how to fix

1. The game is not showing the crafting recipe for any custom made structure, like at all (any recipes that has "name_placer" in it's crafting recipe codes)

2. How can i make it so that whenever the player is near a (custom made) prefab the game would put a overlay on the screen, I was thinking about using playerprox component for this but I don't know how can I do that 

maybe something like this

  Reveal hidden contents

local function SandOverlay()

--i don't know what to put in here

end

 

local function OnFindFire(inst, firePos)
    inst:PushEvent("putoutfire", {firePos = firePos})
end

 

local function fn()

    inst:AddTag("NOCLICK")

    inst:AddTag("NOBLOCK")

    inst:AddComponent("playerprox")
    inst.components.playerprox:SetOnPlayerNear(SandOverlay)
    inst.components.playerprox:SetDist(15, 20)
    inst.components.playerprox.period = 1 -- I don't think I need this

    inst:AddComponent("firedetector")
    inst.components.firedetector:SetOnFindFireFn(OnFindFire)

end

 

Yeah, i'm gonna distribute these prefabs in the oasis biome to give it the sandstorm-ish effect, but I don't have a better idea, unless someone can figure out how to make the DST sandstorm's codes compatible for my for mod

Thanks in Advance!

 

 

...#NoLife

Hi, Unnat7! I want to add your friend in steam (If not, it's okay), I would like to give you some of DST bosses (bee queen, dragonfly in lava pond and so on) ' code (these code are not mine!). By the way, thank you for using my code (my steam name is WL) and making singleplayer DS more alive! I hope to get your reply!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now