Jump to content

Recommended Posts

I'm trying to create a character mod about a vampire. In this mod I'd like it so that my character takes damage from the sun based on the phase of the day (zero at night) and based on the rain wetness calculation. I'm trying to find where the rain wetness calculation is in the game files and have been, so far, unsuccessful. But I mainly want to fix the problem with the health drain based on phase. I've tried getting the data based on the inst:WatchWorldState("phase", sunhurt) in my character's master_postinit. Which only triggered when the phase changed (which was expected but still disappointing). I've tried to write a function calling the phase with the GLOBAL.TheWorld.state.phase but I'm not sure of a call to the function that'll trigger (though maybe when the hunger drain tick happens would be ideal). I've tried to set a negative health regen that only changes when the phase changes but it will stick me on the loading screen without an error message. And it likely wouldn't change dynamically with equipping wetness protection items or standing under trees. Is there a call function I could use to try deal set damage based on the phase and wetness protection occasionally? Or is there a better way to go about this? I'm fairly new to modding so I would appreciate more in depth explanations.

I've figured out that I tried negative health regeneration wrong. It should be inst.components.health:StartRegen(ammount, wait (in seconds), false). I've also found out that when it's in your_character.lua you can't add "GLOBAL." in front of the TheWorld.state.phase variable. I've also found the inst:DoPeriodicTask(tick (in seconds), function) call function to change the health drain dynamically. I managed to find the wetness .lua file in the game files which is called "moisture.lua". I can't load in as the character with the new wetness calcualtion (while raining) and I can't figure out why. Here is the damage variable I have using just the wetness calc. What's wrong with it? (It's currently not affecting anything, just setting the sundamage variable)

    local sundamage =
        (   self.inst.components.sheltered ~= nil and
            self.inst.components.sheltered.sheltered and
            self.inst.components.sheltered.waterproofness or 0
        ) +
        (   self.inst.components.inventory ~= nil and
            self.inst.components.inventory:GetWaterproofness() or 0
        ) +
        (
            waterproofnessmodifiers:Get() or 0
        )
Edited by PROfessor13

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
×
  • Create New...