Jump to content

Question About Modding Character Naughtiness Rate


Recommended Posts

I don't have too much experience with lua, but I'm working on a character and I'm trying to mod him to have a larger naughtiness value added than default upon killing mobs.

 

I've looked a bit in the kramped component script and I understand that mobs have a fixed level of naughtiness associated with them, but I was wondering if I could somehow reference this script in my character's prefab script and modify the values by a multiplier or by redefining them somehow.

 

Any help would be appreciated!

Link to comment
Share on other sites

@MidnightTM

 

See if this works.

local function custom_kramp(self)	local function custom_onkilledother(victim)		-- Change the values in here as you like		if victim and victim.prefab then			if victim.prefab == "pigman" then				if not victim.components.werebeast or not victim.components.werebeast:IsInWereState() then					self:OnNaughtyAction(3)				end			elseif victim.prefab == "babybeefalo" then				self:OnNaughtyAction(6)			elseif victim.prefab == "teenbird" then				self:OnNaughtyAction(2)			elseif victim.prefab == "smallbird" then				self:OnNaughtyAction(6)			elseif victim.prefab == "beefalo" then				self:OnNaughtyAction(4)			elseif victim.prefab == "crow" then				self:OnNaughtyAction(1)			elseif victim.prefab == "robin" then				self:OnNaughtyAction(2)			elseif victim.prefab == "robin_winter" then				self:OnNaughtyAction(2)			elseif victim.prefab == "butterfly" then				self:OnNaughtyAction(1)			elseif victim.prefab == "rabbit" then				self:OnNaughtyAction(1)			elseif victim.prefab == "tallbird" then				self:OnNaughtyAction(2)			elseif victim.prefab == "bunnyman" then				self:OnNaughtyAction(3)			elseif victim.prefab == "penguin" then				self:OnNaughtyAction(2)			end		end	end	-- Change "your_character" to the name of your character's prefab	if self.inst.prefab == "your_character" then		self.onkilledother = custom_onkilledother	endendAddComponentPostInit("kramped", custom_kramp)

Remember to change "your_character" accordingly.

 

Link to comment
Share on other sites

@Blueberrys

 

Sorry, I'm still a huge noob to this. Would this go directly into my character's script, or into a new prefab? I placed it in my character's script and it printed:

 

"Orphaned unnamed resource. This resource must have used Add( resource ) to insert itself into the manager."

about the AddComponentPostInit line I'm guessing. I appreciate the help!

Link to comment
Share on other sites

It would probably be a lot easier for you to modify the 'total naughtiness'  you can earn before krampus shows up instead of editing all the individual values.

 

From what I can tell the Krampus threshold is a fixed value within the tuning script with a value of 30. Same goes for the variance, at 20. Within the kramped script itself, all of the values for killing certain mobs are fixed as well. That being said, I've never scripted in lua or for this game, so there might be some way to alter these values for my character that I don't know of.

 

I'm trying to avoid editing the kramped script itself, although it certainly would be nice if I could have some sort of naughtymult variable in kramped that would be factored in to the OnNaughtyAction function.

 

Link to comment
Share on other sites

Sorry, I'm still a huge noob to this. Would this go directly into my character's script, or into a new prefab? I placed it in my character's script and it printed:

The code would go in your modmain.lua, inside your mod's root folder. "..\mods\Your_Mod_Name\modmain.lua"

 

 

From what I can tell the Krampus threshold is a fixed value within the tuning script with a value of 30. Same goes for the variance, at 20. Within the kramped script itself, all of the values for killing certain mobs are fixed as well. That being said, I've never scripted in lua or for this game, so there might be some way to alter these values for my character that I don't know of.

You can actually override the tuning variables. Inside your modmain.lua, include these lines:

TUNING = GLOBAL.TUNINGTUNING.KRAMPUS_THRESHOLD = 30TUNING.KRAMPUS_THRESHOLD_VARIANCE = 20

Replace 30 and 20 to whatever values you want to give them.

 

Decreasing these values would be the equivalent of increasing all the individual naughtiness values by a fixed ratio. Vice versa for increasing them.

For example, if you wanted to double the naughty points your character receives for each killing, just half these values (15 and 10).

 

You can make them specific to your character by surrounding it with an if statement, like so:

TUNING = GLOBAL.TUNINGif GLOBAL.GetPlayer() and GLOBAL.GetPlayer().prefab == "your_character_prefab_name" then    TUNING.KRAMPUS_THRESHOLD = 30    TUNING.KRAMPUS_THRESHOLD_VARIANCE = 20end
I'm trying to avoid editing the kramped script itself, although it certainly would be nice if I could have some sort of naughtymult variable in kramped that would be factored in to the OnNaughtyAction function.

Using the code provided above, you won't be changing the original file at all. It simply overrides it during gameplay and can be disabled by disabling your mod. Additionally, it should be fairly compatible with other mods because it doesn't override the entire file, only a specific portion of it. The if statements checking your player's prefab also makes it possible to keep your mod activated without breaking other characters' functionality.

 

As for a multiplier, you could make your own.

TUNING.KRAMPUS_MULTIPLIER = 2TUNING.KRAMPUS_VARIANCE_MULTIPLIER = 1.5...TUNING.KRAMPUS_THRESHOLD = 30 * TUNING.KRAMPUS_MULTIPLIERTUNING.KRAMPUS_THRESHOLD_VARIANCE = 20 * TUNING.KRAMPUS_VARIANCE_MULTIPLIER
Link to comment
Share on other sites

@Blueberrys

 

Thanks for all the help! I actually fiddled around with a new component script and managed to figure out a way to implement what I wanted. I made a component script that was essentially a copy of kramped that would call kramped's functions with different values.

 

I think your implementation is a lot simpler though!

Link to comment
Share on other sites

@MidnightTM, oh. Hmm. Are you going to name it "kramped.lua" and put it inside your "..\mod_name\scripts\components" folder? That will likely cause a lot of incompatibilities (with other mods, and probably also original characters). I'd highly recommend that you try to use modmain.lua to override things instead.

If you really want to change each kill points value individually, try the first code I provided. I didn't test it myself, but it's a good starting point.

 

Link to comment
Share on other sites

@Blueberrys

 

I named it "naughty" and put it with my character's components scripts. I don't think I'll go with it though, editing modmain seems like a more robust solution.

 

And out of curiosity, would you happen to know what impact this has on DST's krampus threshold? Will changing my character's threshold change the threshold for the entire server?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...