Detecting weather and clothing

Discuss modding questions and implementation details.
Post Reply
User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Detecting weather and clothing

Post by Ralzar »

So I'm attempting to make a temperature mod. I've got most of it working, but I got really stuck on trying to find some way to have the mod give buffs/debuffs based on weather. Because I can't seem to figure out how weather works.

Anyone have any pointers about how to do this? I am assuming that there is something I could use here for either a bool or a switch function?


The other thing is clothing. I haven't started looking at this yet, but I'm betting I'll run into the same problem there. How can I detect if a character is wearing a cloak in one or both cloak "slots" on the paperdoll?

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Detecting weather and clothing

Post by BadLuckBurt »

The WeatherManager class has these properties:

Code: Select all

        public bool IsRaining { get; private set; }

        public bool IsStorming { get; private set; }

        public bool IsSnowing { get; private set; }

        public bool IsOvercast { get; private set; }
Looking at some of the code, you should be able to get these values by calling:

Code: Select all

[s]bool isRaining = DaggerfallWorkshop.Game.GameManager.Instance.WeatherManager.IsRaining;[/s]
or you could read it directly without assigning it to a variable. The GameManager seems to be a global object so you should have access to that already.
Last edited by BadLuckBurt on Sun Nov 24, 2019 6:03 pm, edited 1 time in total.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Detecting weather and clothing

Post by Ralzar »

BadLuckBurt wrote: Sun Nov 24, 2019 5:09 pm The WeatherManager class has these properties:

Code: Select all

        public bool IsRaining { get; private set; }

        public bool IsStorming { get; private set; }

        public bool IsSnowing { get; private set; }

        public bool IsOvercast { get; private set; }
Looking at some of the code, you should be able to get these values by calling:

Code: Select all

bool isRaining = DaggerfallWorkshop.Game.GameManager.Instance.WeatherManager.isRaining;
or you could read it directly without assigning it to a variable. The GameManager seems to be a global object so you should have access to that already.
That is pretty much what I expected to be able to do, but I get this back from VS and Unity:

"Type `DaggerfallWorkshop.Game.WeatherManager' does not contain a definition for `isRaining' and no extension method `isRaining' of type `DaggerfallWorkshop.Game.WeatherManager' could be found. Are you missing an assembly reference?"

Edit: Oh what the hell? I think I suddenly got it to work. Have to test a bit more.

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Detecting weather and clothing

Post by Ralzar »

Yep, it works now. No idea what made the difference as I literally copy-pasted from your post and got that error. Then when I started removing "isRaining" I suddenly got all the weather properties as suggestions. After that it just worked :D

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Detecting weather and clothing

Post by BadLuckBurt »

Ralzar wrote: Sun Nov 24, 2019 5:51 pm Yep, it works now. No idea what made the difference as I literally copy-pasted from your post and got that error. Then when I started removing "isRaining" I suddenly got all the weather properties as suggestions. After that it just worked :D
Yeah, I made a mistake in my example. I put 'isRaining' instead of 'IsRaining'. Derp :lol:
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
Hazelnut
Posts: 3016
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Detecting weather and clothing

Post by Hazelnut »

You copy pasted a lower case i instead of upper I.

Bert must be a trickster, lol. :D
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Detecting weather and clothing

Post by Ralzar »

Figured out the cloak detection after a lot of trial and error :D

Code: Select all

var cloak1 = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.Cloak1);
var cloak2 = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.Cloak2);
if (cloak1 != null || cloak2 != null)
{}

Post Reply