Jump to content

[Mod Release] Mod Optimizations and Options


Recommended Posts

LINK: http://steamcommunity.com/sharedfiles/filedetails/?id=385300215

 

As of right now, the mod will balance the modded characters you tell it to, and balance leveling mechanics on them if they exist. ( to do: add leveling to all supported characters ).

 

When I balance a character, I try to keep the modders idea in his character. Is his character supossed to be fast? better at night? carnivore? played during night?

 

Also an option to give players a specific number of grass, flint, twigs, logs, and 1 thermal stone.

 

Started on this mod a week ago, when Kuldiin, I and others thought that some modded characters were unbalanced, and some were even uninteresting.

So I looked for a week on the forums, reading through (mostly) simplex's and rezecib's answers to topics, and here we are! Got to say I love these forums though.

 

Full description on the workshop.

 

Special thanks to:

Rezecib and Simplex for their help on the forums.

Ryuushu for solving a 3 day headache on how to code a specific part of my mod.

Josde for the amazing mod image.

Kuldiin for getting me to make this mod.

 

 

Any ideas/feedback/crash reports/opinions, message me, comment here or on the workshop.

Edited by DrSmugleaf
Link to comment
Share on other sites

Edit: Think it might of been me capitalizing the function wrong like a flippin idiot... Checking right now

 

@rezecib Edit: No, the final name is not DrSmugTech DevBuild, thats just something I use to tell apart the version I develop from the released one.

 

The new update includes the name change among other things. However, im encountering a crash where my mod wont recognize that a function exists:
 
Crash Image: http://puu.sh/fo6xZ/55c42ab50b.jpg
Log: http://pastebin.com/UM1hAvj9
 
What I'm trying to do is make a function that adds leveling to a character if you add that function to the character, and for it to read the stats it needs from the function that balances the character.

The purpose of this is to not have the same piece of code over, and over again everywhere, and to prepare it for the upcoming characters im planning to balance in the next, next update.
 
Relevant code:

Leveling function: ( I have tried adding and removing locals and parenthesis everywhere, among with inst's, and nothing seems to work )

function addLevelingSystem(inst)--[[Parameters to use:local changeHealth = local changeHunger = local changeSanity = local changeDamage = local changeInsulation = local levelNerf = local foodtypeLeveling = 	local foodType = ORlocal foodprefabLeveling = 	local foodPrefab1 = 	local foodPrefab2 = 	local foodPrefab3 = 	local foodPrefab4 = 	local foodPrefab5 = OR	local function newEat(inst, food)		oldEat(inst, food)	if food and food.components.edible and food.components.edible.foodtype=="MEAT" then		newUpg(inst)	end	endlocal InitialMaxHealth = local InitialMaxHunger = local InitialMaxSanity = --local InitialMaxDamage = local InitialMaxInsulation = local FinalMaxHealth = local FinalMaxHunger = local FinalMaxSanity = --local FinalMaxDamage = local FinalMaxInsulation = ]]if levelSetting > 0 then		if levelSetting == 1 then		maxUpgrades = 30+levelNerf -- Normal	elseif levelSetting == 2 then		maxUpgrades = 50+levelNerf -- Hard	elseif levelSetting == 420 then		maxUpgrades = 250+levelNerf -- WHAT?	end				local function applyUpgrades(inst)		local upgrades = math.min(inst.level, maxUpgrades) 		local hunger_percent = inst.components.hunger:GetPercent()		local health_percent = inst.components.health:GetPercent()		local sanity_percent = inst.components.sanity:GetPercent()				if changeHealth == 1 then		inst.components.health.maxhealth = math.ceil (InitialMaxHealth + upgrades * (FinalMaxHealth - InitialMaxHealth) / max_upgrades)				end		if changeHunger == 1 then		inst.components.hunger.max = math.ceil (InitialMaxHunger + upgrades * (FinalMaxHunger - InitialMaxHunger) / max_upgrades)		end		if changeSanity == 1 then		inst.components.sanity.max = math.ceil (InitialMaxSanity + upgrades * (FinalMaxSanity - InitialMaxSanity) / max_upgrades)		end		--[[if changeDamage == 1 then		inst.components.combat.damagemultiplier = math.ceil (InitialMaxDamage + upgrades * (FinalMaxDamage - InitialMaxDamage) / max_upgrades)		end]]		-- Doesn't work		if changeInsulation == 1 then		inst.components.temperature.inherentinsulation = math.ceil (InitialMaxInsulation + upgrades * (FinalMaxInsulation - InitialMaxInsulation) / max_upgrades)		end				inst.components.talker:Say("Level : ".. (inst.level))		if inst.level > math.ceil (maxUpgrades-1) then			inst.components.talker:Say("Level : Max!")		end			inst.components.hunger:SetPercent(hunger_percent)		inst.components.health:SetPercent(health_percent)		inst.components.sanity:SetPercent(sanity_percent)	end			if foodtypeLeveling == 1 then		local function oneat(inst, food)			if food and food.components.edible and food.components.edible.foodtype=="foodToLevelUp" then				inst.level = inst.level + 1				applyUpgrades(inst)				inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")			end		end	end		if foodprefabLeveling == 1 then		local function oneat(inst, food)			if food and food.components.edible and food.prefab == "foodPrefab1" or food.prefab == "foodPrefab2" or food.prefab == "foodPrefab3" or food.prefab == "foodPrefab4" or food.prefab == "foodPrefab5" then				inst.level = inst.level + 1				applyUpgrades(inst)				inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")			end		end	end		local function onpreload(inst, data)		if data then			if data.level then				inst.level = data.level				applyUpgrades(inst)				if data.health and data.health.health then inst.components.health.currenthealth = data.health.health end				if data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger end				if data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current end				inst.components.health:DoDelta(0)				inst.components.hunger:DoDelta(0)				inst.components.sanity:DoDelta(0)			end		end	end		local function onsave(inst, data)		data.level = inst.level		data.charge_time = inst.charge_time	end		inst.level = 0	inst.components.eater:SetOnEatFn(oneat)	applyUpgrades(inst)			inst.OnSave = onsave	inst.OnPreLoad = onpreloadendend

 


 
 
Adding the balancing woodie function:
local function balanceWoodieStats(inst)addLevelingToCharacter = 1	--Parameters to use:	local changeHealth = 1	local changeHunger = 1	local changeSanity = 1	local changeDamage = 0	local changeInsulation = 0	local levelNerf = 0	local foodtypeLeveling = 0		local foodType = noType	local foodprefabLeveling = 1		local foodPrefab1 = butterflymuffin		local foodPrefab2 = noPrefab		local foodPrefab3 = noPrefab		local foodPrefab4 = noPrefab		local foodPrefab5 = noPrefab			local InitialMaxHealth = 75	local InitialMaxHunger = 100	local InitialMaxSanity = 100	--local InitialMaxDamage = 0	local InitialMaxInsulation = 0	local FinalMaxHealth = 175	local FinalMaxHunger = 200	local FinalMaxSanity = 175	--local FinalMaxDamage = 0	local FinalMaxInsulation = 0if addLevelingToCharacter == 1 then	addlevelingSystem(inst)endend

 


 
 
Adding it to woodie:
		if GLOBAL.KnownModIndex:IsModEnabled(GLOBAL.KnownModIndex:GetModActualName("Woodie for DST")) then			if woodieBalanced == 1 then					AddPrefabPostInit("woodie", balanceWoodieStats)				print("Balancing PrzemoLSZ's Woodie")			else				print("Ignoring PrszemoLSZ's Woodie")			end		end

 



Again, tried adding and removing everything everywhere, for example the if check to add the leveling system, or removing local on the function on the top.

 

 

Edit: First post made to ask for help hype.

Edited by DrSmugleaf
Link to comment
Share on other sites

@DrSmugleaf, line 600, addlevelingSystem(inst). You put a lower case L instead of a upper case one like you did in your function definition. :razz:

 

Yea, figured that out just now... I should be banned from coding!

 

Anyway, different error now, complains about levelNerf being nil, fixed it and now it doesnt load anything... Bet it's me ******* up another capital somewhere.

 

Funny thing is Woodie says "Level: 0", but other than that nothing works.

Edited by DrSmugleaf
Link to comment
Share on other sites

@DrSmugleaf, hm, isn't it because you defined every variable in balanceWoodieStats as local variables?

That way, they can't be accessed from outside the function, even if you call addLevelingSystem from inside of it.

What I'd suggest is bundling up all those variables in a table, let's say woodieStats, then passing it to  addLevelingSystem as an argument. You could then access the content of the table with stats.<variable_name> inside addLevelingSystem.

local function balanceWoodieStats(inst) addLevelingToCharacter = 1    local woodieStats = {        changeHealth = 1,        -- etc...    } if addLevelingToCharacter == 1 then    addlevelingSystem(inst, woodieStats) -- pass the table as an argumentend end
function addLevelingSystem(inst, stats)    local changeHealth = stats.changeHealth    -- do your magicend
Edited by Jjmarco
Link to comment
Share on other sites

@Jjmarco, didn't even know that was a thing!

Did that, getting the following error:

 

Image: http://puu.sh/fosxN/c6e65ad308.jpg

Log: http://pastebin.com/ynYR1hYW

 

Relevant code:

 

 

Add Leveling System:

local function addLevelingSystem(inst, stats) -- to do, fix max_upgrades to maxUpgrades--[[Parameters to use:local changeHealth = local changeHunger = local changeSanity = local changeDamage = local changeInsulation = local levelNerf = local foodtypeLeveling = 	local foodType = ORlocal foodprefabLeveling = 	local foodPrefab1 = 	local foodPrefab2 = 	local foodPrefab3 = 	local foodPrefab4 = 	local foodPrefab5 = OR	local function newEat(inst, food)		oldEat(inst, food)	if food and food.components.edible and food.components.edible.foodtype=="MEAT" then		newUpg(inst)	end	endlocal InitialMaxHealth = local InitialMaxHunger = local InitialMaxSanity = --local InitialMaxDamage = local InitialMaxInsulation = local FinalMaxHealth = local FinalMaxHunger = local FinalMaxSanity = --local FinalMaxDamage = local FinalMaxInsulation = ]]local changeHealth = stats.changeHealthlocal changeHunger = stats.changeHungerlocal changeSanity = stats.changeSanitylocal changeDamage = stats.changeDamagelocal changeInsulation = stats.changeInsulationlocal levelNerf = stats.levelNerflocal foodtypeLeveling = stats.foodtypeLeveling	local foodType = stats.foodTypelocal foodprefabLeveling = stats.foodprefabLeveling	local foodPrefab1 = stats.foodPrefab1	local foodPrefab2 = stats.foodPrefab2	local foodPrefab3 = stats.foodPrefab3	local foodPrefab4 = stats.foodPrefab4	local foodPrefab5 = stats.foodPrefab5local InitialMaxHealth = stats.InitialMaxHealthlocal InitialMaxHunger = stats.InitialMaxHungerlocal InitialMaxSanity = stats.InitialMaxSanity--local InitialMaxDamage = stats.InitialMaxDamagelocal InitialMaxInsulation = stats.InitialMaxInsulationlocal FinalMaxHealth = stats.FinalMaxHealthlocal FinalMaxHunger = stats.FinalMaxHungerlocal FinalMaxSanity = stats.FinalMaxSanity--local FinalMaxDamage = stats.FinalMaxDamagelocal FinalMaxInsulation = stats.FinalMaxInsulationif levelSetting > 0 then		levelNerf = 0		if levelSetting == 1 then		maxUpgrades = 30+levelNerf -- Normal	elseif levelSetting == 2 then		maxUpgrades = 50+levelNerf -- Hard	elseif levelSetting == 420 then		maxUpgrades = 250+levelNerf -- WHAT?	end				local function applyUpgrades(inst)		local upgrades = math.min(inst.level, maxUpgrades) 		local hunger_percent = inst.components.hunger:GetPercent()		local health_percent = inst.components.health:GetPercent()		local sanity_percent = inst.components.sanity:GetPercent()				if changeHealth == 1 then		inst.components.health.maxhealth = math.ceil (InitialMaxHealth + upgrades * (FinalMaxHealth - InitialMaxHealth) / maxUpgrades)				end		if changeHunger == 1 then		inst.components.hunger.max = math.ceil (InitialMaxHunger + upgrades * (FinalMaxHunger - InitialMaxHunger) / maxUpgrades)		end		if changeSanity == 1 then		inst.components.sanity.max = math.ceil (InitialMaxSanity + upgrades * (FinalMaxSanity - InitialMaxSanity) / maxUpgrades)		end		--[[if changeDamage == 1 then		inst.components.combat.damagemultiplier = math.ceil (InitialMaxDamage + upgrades * (FinalMaxDamage - InitialMaxDamage) / maxUpgrades)		end]]		-- Doesn't work		if changeInsulation == 1 then		inst.components.temperature.inherentinsulation = math.ceil (InitialMaxInsulation + upgrades * (FinalMaxInsulation - InitialMaxInsulation) / maxUpgrades)		end				inst.components.talker:Say("Level : ".. (inst.level))		if inst.level > math.ceil (maxUpgrades-1) then			inst.components.talker:Say("Level : Max!")		end			inst.components.hunger:SetPercent(hunger_percent)		inst.components.health:SetPercent(health_percent)		inst.components.sanity:SetPercent(sanity_percent)	end			if foodtypeLeveling == 1 then		local function oneat(inst, food)			if food and food.components.edible and food.components.edible.foodtype=="foodToLevelUp" then				inst.level = inst.level + 1				applyUpgrades(inst)				inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")			end		end	end		if foodprefabLeveling == 1 then		local function oneat(inst, food)			if food and food.components.edible and food.prefab == "foodPrefab1" then -- or food.prefab == "foodPrefab2" or food.prefab == "foodPrefab3" or food.prefab == "foodPrefab4" or food.prefab == "foodPrefab5" then				inst.level = inst.level + 1				applyUpgrades(inst)				inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")			end		end	end		local function onpreload(inst, data)		if data then			if data.level then				inst.level = data.level				applyUpgrades(inst)				if data.health and data.health.health then inst.components.health.currenthealth = data.health.health end				if data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger end				if data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current end				inst.components.health:DoDelta(0)				inst.components.hunger:DoDelta(0)				inst.components.sanity:DoDelta(0)			end		end	end		local function onsave(inst, data)		data.level = inst.level		data.charge_time = inst.charge_time	end		inst.level = 0	inst.components.eater:SetOnEatFn(oneat)	applyUpgrades(inst)			inst.OnSave = onsave	inst.OnPreLoad = onpreloadendend

 

 

Balancing Woodie Stats:

local function balanceWoodieStats(inst)	--inst.components.health:SetMaxHealth(75)	--inst.components.hunger:SetMax(100)	--inst.components.sanity:SetMax(75)	--Parameters to use:		local woodieStats = {							changeHealth =  1,							changeHunger =  1,							changeSanity =  1,							changeDamage =  0,							changeInsulation =  0,							levelNerf =  0,							foodtypeLeveling =  0,							foodType =  noType,							foodprefabLeveling =  1,							foodPrefab1 =  butterflymuffin,							foodPrefab2 =  noPrefab,							foodPrefab3 =  noPrefab,							foodPrefab4 =  noPrefab,							foodPrefab5 =  noPrefab,															InitialMaxHealth =  75,							InitialMaxHunger =  100,							InitialMaxSanity =  100,							InitialMaxDamage =  0,							InitialMaxInsulation =  0,							FinalMaxHealth =  175,							FinalMaxHunger =  200,							FinalMaxSanity =  175,							FinalMaxDamage =  0,							FinalMaxInsulation =  0,						},	addLevelingSystem(inst, woodieStats)	end

 

 

Adding it to Woodie:

		if GLOBAL.KnownModIndex:IsModEnabled(GLOBAL.KnownModIndex:GetModActualName("Woodie for DST")) then			if woodieBalanced == 1 then					AddPrefabPostInit("woodie", balanceWoodieStats)				print("Balancing PrzemoLSZ's Woodie")			else				print("Ignoring PrszemoLSZ's Woodie")			end		end

Link to comment
Share on other sites

@Jjmarco, you are correct, no longer crashing! Thanks a lot! I just took klei's modinfo to see how you would go about putting commas where, guess it screwed me over.

 

It changes the health, hunger and sanity, however it doesn't make woodie level up, I think it may be because of the extra prefabs I have on foodprefab2 to 5? Going to try removing that and see how it goes.

 

Edit: No, it isn't, I already removed that before.

Edited by DrSmugleaf
Link to comment
Share on other sites

@DrSmugleaf, There are multiple reasons actually.

Firt off, your oneat function is defined as local inside of a block, an if block. Local variables/functions in Lua can't be accessed outside of the block they were defined in. Either you define the variable outside of the if block, like so:

local oneat -- define an empty variableif foodprefabLeveling == 1 then        oneat = function(inst, food) -- put this function inside of it            if food and food.components.edible and food.prefab == "foodPrefab1" then -- or food.prefab == "foodPrefab2" or food.prefab == "foodPrefab3" or food.prefab == "foodPrefab4" or food.prefab == "foodPrefab5" then                inst.level = inst.level + 1                applyUpgrades(inst)                inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")            end        end    end

Put local oneat above all instances where it could get modified.

 

Or you could put the if elsewhere:

if foodprefabLeveling or foodtypeLeveling then    inst.components.eater:SetOnEatFn(oneat)end

As a side note, you don't need to add "== 1" after the variables while comparing. They're implicit. I suggest also changing 1 and 0 with true and false, respectively. It doesn't change the result, but it's a bit more readable (for me, anyway).

 

Secondly, you are comparing the food prefabs with the wrong strings, I think what you wanted to do was more something like this:

if food and food.components.edible and food.prefab == foodPrefab1.prefab then or food.prefab == foodPrefab2.prefab or food.prefab == foodPrefab3.prefab or food.prefab == foodPrefab4.prefab or food.prefab == foodPrefab5.prefab then   -- stuff end

It may also be a good idea to check if the foodPrefab variables exist before trying to compare them, but let's see if this works first.

Edited by Jjmarco
Link to comment
Share on other sites

@Jjmarco, these are the things I never figured out by poking around the code of every mod known to man!

 

Right so, list of things:

 

Tried to define oneat where it could get modified, not sure if that worked so changed it for now and removed the ifs.

Removed the ==1's

Changed 1 and 0 with true and false.

Tried your third piece of code, but I think you put the then in the wrong place, either way itd throw a "foodPrefab2 is nil" and crash, so yes, need to check for that, commented that out just for now and left foodPrefab1 only.

 

Also I (think?) the way I want to do it is this way:

if food and food.components.edible and food.prefab == foodPrefab1 then --or food.prefab == foodPrefab2 or food.prefab == foodPrefab3 or food.prefab == foodPrefab4 or food.prefab == foodPrefab5 then

Without the .prefabs in the end, those didn't seem to work, as when it was with the .prefab it showed this error when eating butterflymuffins: http://puu.sh/foG0p/b5ad2ee958.jpg

 

 

Then it complained about applyupgrades(inst) being nil, so I removed the local.

 

I then tried to add comas to in woodieStats to foodPrefab1 = "butterflymuffin", and that then didnt crash but didn't level up either. Was using the formula with foodPrefab1.prefab, changed it to not have .prefab in the end and

 

And here we are! Doesnt crash, changes base stats but doesn't level up.

 

Edit:

@Jjmarco, Well, you are a ******* genius, it works! This is the very, very messy code if anyone has the same problem and wants to go through the same struggle or figure it out:

 

Leveling code:

local function addLevelingSystem(inst, stats) -- to do, fix max_upgrades to maxUpgrades--[[Parameters to use:local changeHealth = local changeHunger = local changeSanity = local changeDamage = local changeInsulation = local levelNerf = local foodtypeLeveling = 	local foodType = ORlocal foodprefabLeveling = 	local foodPrefab1 = 	local foodPrefab2 = 	local foodPrefab3 = 	local foodPrefab4 = 	local foodPrefab5 = OR	local function newEat(inst, food)		oldEat(inst, food)	if food and food.components.edible and food.components.edible.foodtype=="MEAT" then		newUpg(inst)	end	endlocal InitialMaxHealth = local InitialMaxHunger = local InitialMaxSanity = --local InitialMaxDamage = local InitialMaxInsulation = local FinalMaxHealth = local FinalMaxHunger = local FinalMaxSanity = --local FinalMaxDamage = local FinalMaxInsulation = ]]local changeHealth = stats.changeHealthlocal changeHunger = stats.changeHungerlocal changeSanity = stats.changeSanitylocal changeDamage = stats.changeDamagelocal changeInsulation = stats.changeInsulationlocal levelNerf = stats.levelNerflocal foodtypeLeveling = stats.foodtypeLeveling	local foodType = stats.foodTypelocal foodprefabLeveling = stats.foodprefabLeveling	local foodPrefab1 = stats.foodPrefab1	local foodPrefab2 = stats.foodPrefab2	local foodPrefab3 = stats.foodPrefab3	local foodPrefab4 = stats.foodPrefab4	local foodPrefab5 = stats.foodPrefab5local InitialMaxHealth = stats.InitialMaxHealthlocal InitialMaxHunger = stats.InitialMaxHungerlocal InitialMaxSanity = stats.InitialMaxSanity--local InitialMaxDamage = stats.InitialMaxDamagelocal InitialMaxInsulation = stats.InitialMaxInsulationlocal FinalMaxHealth = stats.FinalMaxHealthlocal FinalMaxHunger = stats.FinalMaxHungerlocal FinalMaxSanity = stats.FinalMaxSanity--local FinalMaxDamage = stats.FinalMaxDamagelocal FinalMaxInsulation = stats.FinalMaxInsulation--if levelSetting > 0 then		--if levelSetting == 1 then	local max_upgrades = 30--+levelNerf -- Normal	--elseif levelSetting == 2 then		--max_upgrades = 50+levelNerf -- Hard	--elseif levelSetting == 420 then		--max_upgrades = 250+levelNerf -- WHAT?	--end				function applyupgrades(inst)		local upgrades = math.min(inst.level, max_upgrades) 		local hunger_percent = inst.components.hunger:GetPercent()		local health_percent = inst.components.health:GetPercent()		local sanity_percent = inst.components.sanity:GetPercent()				if changeHealth then		inst.components.health.maxhealth = math.ceil (InitialMaxHealth + upgrades * (FinalMaxHealth - InitialMaxHealth) / max_upgrades)				end		if changeHunger then		inst.components.hunger.max = math.ceil (InitialMaxHunger + upgrades * (FinalMaxHunger - InitialMaxHunger) / max_upgrades)		end		if changeSanity then		inst.components.sanity.max = math.ceil (InitialMaxSanity + upgrades * (FinalMaxSanity - InitialMaxSanity) / max_upgrades)		end		--[[if changeDamage == 1 then		inst.components.combat.damagemultiplier = math.ceil (InitialMaxDamage + upgrades * (FinalMaxDamage - InitialMaxDamage) / max_upgrades)		end]]		-- Doesn't work		if changeInsulation then		inst.components.temperature.inherentinsulation = math.ceil (InitialMaxInsulation + upgrades * (FinalMaxInsulation - InitialMaxInsulation) / max_upgrades)		end				inst.components.talker:Say("Level : ".. (inst.level))				if inst.level > math.ceil (max_upgrades-1) then			inst.components.talker:Say("Level : Max!")		end			inst.components.hunger:SetPercent(hunger_percent)		inst.components.health:SetPercent(health_percent)		inst.components.sanity:SetPercent(sanity_percent)	end		--[[	if foodtypeLeveling then		local function oneat(inst, food)			if food and food.components.edible and food.components.edible.foodtype=="foodToLevelUp" then				inst.level = inst.level + 1				applyupgrades(inst)				inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")			end		end	end]]		--local oneat	--if foodprefabLeveling then		function oneat(inst, food)			if food and food.components.edible and food.prefab == foodPrefab1 then --or food.prefab == foodPrefab2.prefab or food.prefab == foodPrefab3.prefab or food.prefab == foodPrefab4.prefab or food.prefab == foodPrefab5.prefab then				inst.level = inst.level + 1				applyupgrades(inst)				inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")			end		end	--end		local function onpreload(inst, data)		if data then			if data.level then				inst.level = data.level				applyupgrades(inst)				if data.health and data.health.health then inst.components.health.currenthealth = data.health.health end				if data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger end				if data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current end				inst.components.health:DoDelta(0)				inst.components.hunger:DoDelta(0)				inst.components.sanity:DoDelta(0)			end		end	end		local function onsave(inst, data)		data.level = inst.level		data.charge_time = inst.charge_time	end		inst.level = 0	inst.components.eater:SetOnEatFn(oneat)	applyupgrades(inst)			inst.OnSave = onsave	inst.OnPreLoad = onpreloadend

 

 

Balance Woodie Stats:

 

local function balanceWoodieStats(inst)	--inst.components.health:SetMaxHealth(75)	--inst.components.hunger:SetMax(100)	--inst.components.sanity:SetMax(75)	--Parameters to use:		local woodieStats = {							changeHealth =  true,							changeHunger =  true,							changeSanity =  true,							changeDamage =  false,							changeInsulation =  false,							levelNerf =  0,							--foodtypeLeveling =  0,							--foodType =  noType,							foodprefabLeveling =  true,							foodPrefab1 =  "butterflymuffin",							--foodPrefab2 =  noPrefab,							--foodPrefab3 =  noPrefab,							--foodPrefab4 =  noPrefab,							--foodPrefab5 =  noPrefab,															InitialMaxHealth =  75,							InitialMaxHunger =  100,							InitialMaxSanity =  100,							InitialMaxDamage =  0,							InitialMaxInsulation =  0,							FinalMaxHealth =  175,							FinalMaxHunger =  200,							FinalMaxSanity =  175,							FinalMaxDamage =  0,							FinalMaxInsulation =  0,						}	addLevelingSystem(inst, woodieStats)	end

 

Thank you so very much for your help!

Going to work on publishing the update soon if I dont fall asleep before that. Again, thanks a lot, learned a lot from this too, the things I couldn't learn easily from looking through other mods!

 

 

Edit2: Only thing left is the multiple prefabs for food thing and requiring them so it doesnt throw a nil, and the ifs for which leveling system to use, but even then, good enough for now, thanks a lot!

Edited by DrSmugleaf
Link to comment
Share on other sites

@DrSmugleaf, Glad I could help :-)

If you want, I can take your code and work on making it more robust and less messy. I can see a lot of pieces of code being portiential sources of errors in the future. And also making it a bit more readable for you.

It's always a pleasure helping people make their mods.

 

Not right now though, right now I think I'm going to get some sleep (It's 2 in the morning where I live!).

Link to comment
Share on other sites

@DrSmugleaf, Glad I could help :-)

If you want, I can take your code and work on making it more robust and less messy. I can see a lot of pieces of code being portiential sources of errors in the future. And also making it a bit more readable for you.

It's always a pleasure helping people make their mods.

 

Not right now though, right now I think I'm going to get some sleep (It's 2 in the morning where I live!).

 

@Jjmarco,

Same for me, 2AM here.

While it'd be nice to have you helping on the overall code, I really like the experience of programming a mod from the beggining, though you can always give tips on how to improve it! Don't know really, its the first time I have been involved in making a mod in any game, and this game specifically made me want to make a mod for it because both the developers and modding community on the forums seemed really good.

 

I did start making the mod with the help of a friend. Lets just say that died quickly, he was way better than me at coding so it ended up in a I-copy-paste-your-code situation, and also personal issues, so as soon as that died I moved on to doing it by myself just by looking at the base game, other mods and the forums.

 

By potential sources of errors in the future, I imagine you mean when the game updates? Or when I modify things about it? The mod right now is just a deal of adding 4 functions and then repeating the same code over and over again, for each character that I support. The one thing I see breaking easily is if mods change names ingame, since I use this to check for enabled characters:

if GLOBAL.KnownModIndex:IsModEnabled(GLOBAL.KnownModIndex:GetModActualName("") then

If you mean things such as checking for prefabs and things of sorts before executing the code so it doesn't crash ( like simplex seems to do, because a friend tried really hard at crashing one of his mods and he didn't manage to do it, but then again thats simplex, so hey ), then that'd probably be fun to do, as I dont have much of an idea on the matter.

 

I have to say that, surprisingly, balancing the characters is a big part of the mod (which is to say that it's way harder than I expected), I usually have myself or friends play characters for a while and then give me their opinions on them, as I dont have anyone or a group doing that for me. Mainly the reason I have a separate config option per character, so people can just disable them if I suck at my job.

 

So to recap, im unsure about the offer, but im obviously biased since I already had a bad experience related to multiple people coding. If it's something that won't be like "okay so this works because it works, let's move on and leave it copypaste'd there" then I'd be happy with it, because I'd actually learn how to do it, and the mod becomes better at the same time! (Edit: Which is to say I'd learn how to properly code **** for less headaches in the future, which is a pretty good thing) So lets just discuss that when it isn't...like...2AM.

 

For now, just going to update the mod if I manage to stay awake for 10 more minutes.

Edited by DrSmugleaf
Link to comment
Share on other sites

  • Developer

This thread is full of win! I love seeing great collaboration like this. :D

 

@DrSmugleaf, regarding the mod name changing, you should be safe to use the downloaded directory name "workshop-361336115". That number is the Steam ID for the mod (in this case, the hunt mod) and won't change unless the mod is deleted and re-uploaded. I also have no plans to change that folder name structure, as a bunch of our code already relies on it and I haven't seen any compelling reason to change it.

Link to comment
Share on other sites

This thread is full of win! I love seeing great collaboration like this. :grin:

 

@DrSmugleaf, regarding the mod name changing, you should be safe to use the downloaded directory name "workshop-361336115". That number is the Steam ID for the mod (in this case, the hunt mod) and won't change unless the mod is deleted and re-uploaded. I also have no plans to change that folder name structure, as a bunch of our code already relies on it and I haven't seen any compelling reason to change it.

 

@PeterA, I had no idea and that is really, really helpful! I was mostly worried about mod's like Crash Bandicoot, where the name was "Crash Bandicoot 2.0.0", but that just fixes everything!

So if I'm not mistaken I would do:

if GLOBAL.KnownModIndex:IsModEnabled(GLOBAL.KnownModIndex:GetModActualName("workshop-361336115")) then

I also love these collaborations and have seen them a lot on these forums, another reason I really like them!

 

Edit: Also, I noticed if you edit a post the likes on it reset, I find that funny as yours reset as soon as I edited it. Klei please fix?

Edited by DrSmugleaf
Link to comment
Share on other sites

@DrSmugleaf, Oh no no. I won't make you copy and paste stuff. That's the opposite of learning. I can understand why you quickly ended collaboration with your friend.

What I had in mind was tweaking your code and then add comments everywhere I did a change, so you can understand why I did it.

But I can just give you tips, that's fine too. It's probably better that way, as keeping your code personal and getting your own coding style is important in the process of learning programmation.

 


By potential sources of errors in the future, I imagine you mean when the game updates? Or when I modify things about it? The mod right now is just a deal of adding 4 functions and then repeating the same code over and over again, for each character that I support. The one thing I see breaking easily is if mods change names ingame, since I use this to check for enabled characters: ? 1 if GLOBAL.KnownModIndex:IsModEnabled(GLOBAL.KnownModIndex:GetModActualName("") then If you mean things such as checking for prefabs and things of sorts before executing the code so it doesn't crash ( like simplex seems to do, because a friend tried really hard at crashing one of his mods and he didn't manage to do it, but then again thats simplex, so hey ), then that'd probably be fun to do, as I dont have much of an idea on the matter.

 

Yes, that is more or less what I meant by potential errors. For the GetMod issue, it's better if you get the mod from its Workshop ID, which never changes. I think you can do that, I'm not sure. PeterA beat me to it! :grin:

When working with entities, and especially their associated components, it's always good pratice to check if: 1) the entity does exist if there is ambiguity on that in the way your code works, 2) it has the components you are trying to work with. It's not a necessity if you are sure the entity will always exist.

I have also a few suggestions on how to make you code more efficient and more clear, but let's get at that later. (Zzzzz...)

 

I have to say that, surprisingly, balancing the characters is a big part of the mod (which is to say that it's way harder than I expected), I usually have myself or friends play characters for a while and then give me their opinions on them, as I dont have anyone or a group doing that for me. Mainly the reason I have a separate config option per character, so people can just disable them if I suck at my job.

 

That's a good practice. Always give your mod failsafes like this, so it's still useable if it gets broken in some way (e.g., an update).

 

Anyway, I'll be glad to help you improve your programmation skills.

As someone who is pretty much autodidact, I know how it's hard to get the hang of it. :-)

(Do I sound pretentious here?)

 

 

Edited by Jjmarco
Link to comment
Share on other sites

@DrSmugleaf, Oh no no. I won't make you copy and paste stuff. That's the opposite of learning. I can understand why you quickly ended collaboration with your friend

 

@Jjmarco

If you already understand that then we are pretty much set!

But for now, sleeps. If I manage to finish this update and publish it. Maybe. Sometime.

 

It's also useful that I have a friend who runs a server (Kuldiin), that way we usually find bugs before it affects a lot of people.

Link to comment
Share on other sites

The things I have most problem with is changing an item (though I just poked around and didn't really test anything extensively) and mitsuru's stats.

 

For now I'm trying to make it so Faroz's glasses and Woodie's axe can only be used by their owners.

I looked at the Invader Zim mod by Purswader that makes it so only zim can use his pak, and found this:

 

local function onequip(inst, owner) 	if owner:HasTag("zim") then     owner.AnimState:OverrideSymbol("swap_body", "swap_pak", "pak")    owner.AnimState:OverrideSymbol("swap_body", "swap_pak", "swap_body")    --owner.components.inventory:SetOverflow(inst)    inst.components.container:Open(owner)	inst.components.equippable.walkspeedmult = TUNING.CANE_SPEED_MULT	inst.components.dapperness.dapperness = ((TUNING.DAPPERNESS_MED*2))    else		inst.components.equippable.walkspeedmult = 1		inst.components.dapperness.dapperness = 0	endend

 

He also doesn't seem to have a function for "ondrop", unlike faroz glasses or woodie's axe, so It'd be interesting if somehow I could remove that. Though I'm not sure how Woodie's beaver form would react to an item not being able to be dropped, if it would flip out or just drop it regardless.

Does this mean zim doesn't drop his pak when he dies? Because that would be amazing then, as thats one of the things im trying to accomplish.

Either faroz's glasses and woodie's axe (and really any other items I encounter, like crash bandicoot's aku aku) not doing anything for not those characters (which would make them stealable by the same players regardless, or just make the player lose that item forever, so thats my least favorite approach), or make them not be able to be dropped ever. If it's the first approach, then add a recipe for those items too, since they are going to be useless for characters that aren't them anyways, just in case the player loses the item.

 

And then, on his character's (izim.lua) master_postinit:

 

	inst:AddTag("zim")	inst:AddComponent("reader")

 

No idea what the reader component does by the way, sounds like something to notepad-search-in-files.

I have added the tag Insomniac to michael the fox specifically before, with just "inst:AddTag("insomniac")".

 

 

Poked around a bit trying to replicate that with faroz's glasses, but couldn't manage to, way I tried was the same as other characters but instead applying the change to faruz_gls.lua instead of faroz.lua with AddPrefabPostInit.

 

Going to try tomorrow again as I just focused more on getting starting item's amount separated by item type, and managed to first try, but fucked up the config like an idiot so wasted like 2 hours trying to fix it, when the only thing to fix was me not properly loading the config... I know im da best.

 

 

 

Also another thing is movement speed, and damage. When I tried to change mitsuru's stats, everything but damage changed, and when I tried to set her hp really low (lvl 1: 45, max lvl: 90) the stats just reset until I set them higher. I'm not even sure if my insulation change is applying either since I haven't tested.

Her damage also seemed bugged? She appeared to have more than 2.0x damage (5 unarmed hits to kill spider, 2 batbat hits, 2 spear hits, 1 hambat hit), and also seemed to ignore my damage change, as to test I tried to change it to 0.1 at lvl 1, but in her code it says:

 

local function applyupgrades(inst)	local max_upgrades = 30	local upgrades = math.min(inst.level, max_upgrades)	inst.components.combat.damagemultiplier = math.ceil (1.1 + upgrades / 60) --10

 

The rest is pretty much the same as all the other mods made by sollyz and haruz, which by the way I don't like his/her approach to leveling, I think it was in sollyz the author had --220 next to the hp amount, and it was in fact something else. Reason why I use this instead: (and really I recommend anyone to do it this way, the code does the math for you! unless I'm missing something I don't think this way of doing leveling has any flaws)

inst.components.health.maxhealth = math.ceil (InitialMaxHealth + upgrades * (FinalMaxHealth - InitialMaxHealth) / maxUpgrades)	

Also makes it so instead of more levels = more stats, more levels = slower but the same stats. Just so I can balance mitsuru since she levels up by eating CARROTS, and such.

 

 

So off that tangent now, I removed my code that changed mitsuru's damage, and her damage was the same, not even 1.1 at lvl 1 like it said, but 5-hitting spiders unarmed. I thought damage was nerfed in DST? Or is it mob health that got nerfed? Or both, so when you set the damage to 1.1, like mitsuru does, its in fact much higher? No idea why mitsuru ignored my damage change too.

 

Makes me worried that because of that drok's, michael's and wark's damage change on my code isnt applying either (though I probably overnerfed michael and wark, but whats what the modder gets for making the character so flippin fast).

 

 

Other than that the only problem I have is with sollyz's, mitsuru's, faroz's and haruz's leveling, as it already exists I don't know if I can change what they level with, as when I tried it would change back and forth between both leveling systems when I ate whats specified on my code to level up or on the character's. Thats why I implemented levelNerf, to make mitsuru's level cap 50 higher to everyone else, and haruz's 25 higher.

 

Another thing is I looked at how Seras does leveling for mobs as thats something I want to implement with Woodie and probably many others, and my god it looks complicated. Don't know if I will even be able to put that into my addLevelingSystem function, though thats just a case of trying.

 

And before I forget, one last thing I'm having struggles with is with characters that listen to events like day/dusk/night/full moon and maybe summer/winter, for example Hella Merdurial and Sollyz. I imagine I would just do something similar like I do to override sollyz's, haruz's and mitsuru's leveling? Because really, I see no way to balance Hella Merdurial other than constantly setting her hp to 1 if I can't modify that.

 

 

TL;DR

Changing items, either make them only usable by owner and craftable, or undroppable even when dying. Tried a minimal amount, failed, will try tomorrow again.

Reader component. No idea what it does, haven't looked up with notepad yet, will tomorrow.

Setting a character's stats too low makes it not set them at all. Happened with Mitsuru at 45 hp at lvl 1.

Damage being bugged. Tried, failed with mitsuru specifically.

Movement speed. Haven't tried.

No idea if me changing insulation does anything (because bloody hell mitsuru has 900 insulation by default at max lvl). Done, no idea if it works, haven't tested.

Modifying existing leveling, specifically item to level up with. Tried, failed.

Experience/slaying based system, like Seras. Haven't tried.

Changing what a character does day/dusk/night summer/winter or modifying what they do if they already do something. (Already know how it's done by looking at other mods, just don't know if I can modify existing mechanisms) Haven't tried.

Edited by DrSmugleaf
Link to comment
Share on other sites

@DrSmugleaf, if you want to check to see if my mod is active all you have to do is look for inst.components.crystallizable on the pond instance. This is the component which dictates whether ice will grow now. 

 

Looking at how difficult ice is to break with your mod I don't think I need to change anything, as only sollyz levels up with fish anyways.

Link to comment
Share on other sites

@DrSmugleaf, I've changed the mechanic slightly once summer starts, but it is still difficult during winter. Hoping to receive feedback on the difficulty of the mod soon as the sole purpose of it was to create a fully balanced mod instead of easy mode modification. 

 

Oh, I see, I'll look into it after I get the new leveling system going then.

 

As for anyone who can/wants to help: ( Inb4 I fucked up another capital )

Still struggling with modifying existing items, but that aside:

Trying to make the third leveling system, which is an experience based one with monster-killing instead of a level based one when you eat items, like WX-78's. It should also be able to handle items too I imagine, apart from just mob killing.

 

Basicly I went into Seras' coding and found a bunch of code that makes her level up when she kills pigs/krampus/players, so I tried to replicate it, and failed horribly! Trying to apply it to Woodie right now.

When it didn't work at first, I tried to remove the lines to check if something exists, as I don't know if I'm doing it right for example:

if baseHealth and healthPerLevel then	currentHealth = baseHealth + level * healthPerLevelend

Then I noticed I wasn't applying the stats anywhere, so changed it to:

--if baseHealth and healthPerLevel then	currentHealth = baseHealth + level * healthPerLevel	inst.components.health.maxhealth = currentHealth--end

In the end I just went around Seras' code, but I'm really at a loss, since I don't understand some of the things there. This is how the code is right now, doesn't crash, but doesn't do anything either:

 

 

Adding the leveling function

local function addExperienceSystem(inst, stats)local baseHealth = stats.baseHealthlocal baseHunger = stats.baseHungerlocal baseSanity = stats.baseSanitylocal baseWalkspeed = stats.baseWalkspeedlocal baseRunspeed = stats.baseRunspeedlocal baseDamage = stats.baseDamagelocal baseInsulation = stats.baseInsulationlocal healthPerLevel = stats.healthPerLevellocal hungerPerLevel = stats.hungerPerLevellocal sanityPerLevel = stats.sanityPerLevellocal walkspeedPerLevel = stats.walkspeedPerLevellocal runspeedPerLevel = stats.runspeedPerLevellocal damagePerLevel = stats.damagePerLevellocal insulationPerLevel = stats.insulationPerLevellocal mobToKill1 = stats.mobToKill1local mobToKill2 = stats.mobToKill2local mobToKill3 = stats.mobToKill3local experiencePerMobKill1 = stats.experiencePerMobKill1local experiencePerMobKill2 = stats.experiencePerMobKill2local experiencePerMobKill3 = stats.experiencePerMobKill3local commentOnLevelup = stats.commentOnLeveluplocal commentOnKill = stats.commentOnKilllocal maxLevel = stats.maxLevellocal level = 0	--if levelNerf then		--local maxLevel = stats.maxLevel + levelNerf	--else		local maxLevel = stats.maxLevel	--end	local function onExperienceGain(inst)		--if inst.experience <= maxLevel * 1000 then			level = inst.experience / 1000						--if baseHealth and healthPerLevel then				currentHealth = baseHealth + level * healthPerLevel				inst.components.health.maxhealth = currentHealth			--end						--if baseHunger and hungerPerLevel then				currentHunger = baseHunger + level * hungerPerLevel				inst.components.hunger.max = currentHunger			--end						--if baseSanity and sanityPerLevel then				currentSanity = baseSanity + level * sanityPerLevel				inst.components.sanity.max = currentSanity			--end						--[[if baseWalkspeed and walkspeedPerLevel then				currentWalkspeed = baseWalkspeed + level * walkspeedPerLevel			end						if baseRunspeed and runspeedPerLevel then				currentRunspeed = baseRunspeed + level * runspeedPerLevel			end						if baseDamage and damagePerLevel then				currentDamage = baseDamage + level * damagePerLevel			end						if baseInsulation and insulationPerLevel then				currentInsulation = baseInsulation + level * insulationPerLevel			end]]					--else			--level = maxLevel		--end				--[[if baseHealth and healthPerLevel then		inst.components.health.maxhealth = currentHealth		end				if baseHunger and hungerPerLevel then		inst.components.hunger.max = currentHunger		end				if baseSanity and sanityPerLevel then		inst.components.sanity.max = currentSanity		end				if base]]	end		local function entitydeathfn(inst, data)		if data.cause == inst.prefab then					--if mobToKill1 then				if data.inst.prefab == mobToKill1 then					print("Experience lvl system: Killed " .. mobToKill1)					inst.experience = inst.experience + experiencePerMobKill1				end							--[[elseif mobToKill2 then				if data.inst.prefab == mobToKill2 then					print("Experience lvl system: Killed " .. mobToKill2)					inst.experience = inst.experience + experiencePerMobKill2				end							elseif mobToKill3 then				if data.inst.prefab == MobToKill3 then					print("Experience lvl system: Killed " .. mobToKill3)					inst.experience = inst.experience + experiencePerMobKill3				end			end]]		onExperienceGain(inst)		end	end		local function updatestats(inst)		local health_percent = inst.components.health:GetPercent()		local hunger_percent = inst.components.hunger:GetPercent()		local sanity_percent = inst.components.sanity:GetPercent()				inst.components.health:SetPercent(health_percent)		inst.components.hunger:SetPercent(hunger_percent)		inst.components.sanity:SetPercent(sanity_percent)	end		local function onsave(inst, data)	    data.experience = inst.experience	end		local function onpreload(inst, data)	    if data ~= nil and data.experience ~= nil then			inst.experience = data.experience			local health_percent = inst.components.health:GetPercent()			local hunger_percent = inst.components.hunger:GetPercent()			local sanity_percent = inst.components.sanity:GetPercent()			onExperienceGain(inst)			inst.components.health:SetPercent(health_percent)			inst.components.hunger:SetPercent(hunger_percent)			inst.components.sanity:SetPercent(sanity_percent)		end	end		local function master_postinit(inst)	    inst.experience = 0	  	updatestats(inst)  	    inst:ListenForEvent("entity_death", function(world, data) entitydeathfn(inst, data) end, TheWorld)  	  	inst.OnSave = onsave  	inst.OnPreLoad = onpreload	    return inst		endend

 

 

Balancing Woodie function:

 

local function balanceWoodieStats(inst)	local woodieStats =	{					baseHealth = 75,					baseHunger = 100,					baseSanity = 100,												healthPerLevel = 5,					hungerPerLevel = 2,					sanityPerLevel = 5,												mobToKill = "spider",					experiencePerMobKill1 = 1000,					maxLevel = 10,				}		addExperienceSystem(inst, woodieStats)	end

 

 

Adding it to Woodie:

 

		if GLOBAL.KnownModIndex:IsModEnabled("workshop-384633033") then			if woodieBalanced == 1 then					AddPrefabPostInit("woodie", balanceWoodieStats)				print("Balancing PrzemoLSZ's Woodie")			else				print("Ignoring PrszemoLSZ's Woodie")			end		end

Link to comment
Share on other sites

For now I'm trying to make it so Faroz's glasses and Woodie's axe can only be used by their owners.

I looked at the Invader Zim mod by Purswader that makes it so only zim can use his pak, and found this:

 

local function onequip(inst, owner) 	if owner:HasTag("zim") then     owner.AnimState:OverrideSymbol("swap_body", "swap_pak", "pak")    owner.AnimState:OverrideSymbol("swap_body", "swap_pak", "swap_body")    --owner.components.inventory:SetOverflow(inst)    inst.components.container:Open(owner)	inst.components.equippable.walkspeedmult = TUNING.CANE_SPEED_MULT	inst.components.dapperness.dapperness = ((TUNING.DAPPERNESS_MED*2))    else		inst.components.equippable.walkspeedmult = 1		inst.components.dapperness.dapperness = 0	endend

 

He also doesn't seem to have a function for "ondrop", unlike faroz glasses or woodie's axe, so It'd be interesting if somehow I could remove that. Though I'm not sure how Woodie's beaver form would react to an item not being able to be dropped, if it would flip out or just drop it regardless.

Does this mean zim doesn't drop his pak when he dies? Because that would be amazing then, as thats one of the things im trying to accomplish.

Either faroz's glasses and woodie's axe (and really any other items I encounter, like crash bandicoot's aku aku) not doing anything for not those characters (which would make them stealable by the same players regardless, or just make the player lose that item forever, so thats my least favorite approach), or make them not be able to be dropped ever. If it's the first approach, then add a recipe for those items too, since they are going to be useless for characters that aren't them anyways, just in case the player loses the item.

 

If you want character specific items to never be dropped, be it at death (ghosts have a inventory, it's just hidden, so it will keep the item forever) or specifically by the player, you can first add a tag to that item, such as "undroppable", then you have to change the Inventory:DropItem method to never drop items with this tag. There are two different approaches for this:

 

- The "require" approach: you first use the require function of Lua to store the Inventory class into a variable, then you keep a backup of the DropItem method, and finally you override the method itself:

-- You may need to access require from the GLOBAL scope (if you are working in the modmain, for instance), in which case substitute require with GLOBAL.requirelocal Inventory = require "components/inventory"local DropItem_base = Inventory.DropItem -- store the default functionfunction Inventory:DropItem(item, ...)    if item:HasTag("undroppable") then        return false -- if the item has the tag, do nothing    else        return DropItem_base(self, item, ...) -- otherwise, use default execution        -- self must be passed to the function, because it's not directly called from a component.    endend-- The "..." essentially contains all the other arguments passed down to the function, which we don't all need here. It can be used to pass those arguments to the default function.

- The "API-friendly" approach: it's basically the same as above, but with the usage of AddComponentPostInit (or AddClassPostConstruct):

AddComponentPostInit("inventory", function(self)    local DropItem_base = self.DropItem -- store the default function    function self:DropItem(item, ...)        if item:HasTag("undroppable") then            return false -- if the item has the tag, do nothing        else            return DropItem_base(self, item, ...) -- otherwise, use default execution        end    endend)

 

This can be applied to any other method of any other components/widgets/classes/etc. of which you want to change the behavior. Just make sure to always call the default function so you don't break the game.

I personally prefer the require approach, but it's your call which one to use, as they are nearly identical.

 

And then, on his character's (izim.lua) master_postinit:

 

	inst:AddTag("zim")	inst:AddComponent("reader")

 

No idea what the reader component does by the way, sounds like something to notepad-search-in-files.

I have added the tag Insomniac to michael the fox specifically before, with just "inst:AddTag("insomniac")".

 

 

The reader component just makes the character able to read (i.e., use) Wickerbottom's books.

 

Also another thing is movement speed, and damage. When I tried to change mitsuru's stats, everything but damage changed, and when I tried to set her hp really low (lvl 1: 45, max lvl: 90) the stats just reset until I set them higher. I'm not even sure if my insulation change is applying either since I haven't tested.

Her damage also seemed bugged? She appeared to have more than 2.0x damage (5 unarmed hits to kill spider, 2 batbat hits, 2 spear hits, 1 hambat hit), and also seemed to ignore my damage change, as to test I tried to change it to 0.1 at lvl 1, but in her code it says:

 

local function applyupgrades(inst)	local max_upgrades = 30	local upgrades = math.min(inst.level, max_upgrades)	inst.components.combat.damagemultiplier = math.ceil (1.1 + upgrades / 60) --10

 

The rest is pretty much the same as all the other mods made by sollyz and haruz, which by the way I don't like his/her approach to leveling, I think it was in sollyz the author had --220 next to the hp amount, and it was in fact something else. Reason why I use this instead: (and really I recommend anyone to do it this way, the code does the math for you! unless I'm missing something I don't think this way of doing leveling has any flaws)

inst.components.health.maxhealth = math.ceil (InitialMaxHealth + upgrades * (FinalMaxHealth - InitialMaxHealth) / maxUpgrades)	

Also makes it so instead of more levels = more stats, more levels = slower but the same stats. Just so I can balance mitsuru since she levels up by eating CARROTS, and such.

 

 

So off that tangent now, I removed my code that changed mitsuru's damage, and her damage was the same, not even 1.1 at lvl 1 like it said, but 5-hitting spiders unarmed. I thought damage was nerfed in DST? Or is it mob health that got nerfed? Or both, so when you set the damage to 1.1, like mitsuru does, its in fact much higher? No idea why mitsuru ignored my damage change too.

 

Makes me worried that because of that drok's, michael's and wark's damage change on my code isnt applying either (though I probably overnerfed michael and wark, but whats what the modder gets for making the character so flippin fast).

 

 

About the damage multiplier, I tested changing the damage multiplier of my character in game, and I was able to kill a spider in 5 hits unarmed. Though it's weird that it didn't change when you changed the base damage multiplier. Not sure why. I'm also not sure why putting maxhealth too low does nothing.

I need to see you code on this.

 

For the rest, I need to look at those characters' code, to know how they work, see why you can't change some things.

Edited by Jjmarco
Link to comment
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
 Share

×
×
  • Create New...