Light sources (in-game)

Discuss coding questions, pull requests, and implementation details.
User avatar
pango
Posts: 2607
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Light sources (in-game)

Post by pango »

You're welcome :)
I actually like where you placed the test inside EquipItem(), in case of issue I'd better have a stack split for nothing that some item unequipped for nothing.
Maybe the check in SplitStack() that the item is indeed part of the container can catch stupid bugs later and can stay in, but other than that I'm totally fine with your fix.

Code: Select all

diff --git a/Assets/Scripts/Game/Items/ItemCollection.cs b/Assets/Scripts/Game/Items/ItemCollection.cs
index 64ecf818..63a18e53 100644
--- a/Assets/Scripts/Game/Items/ItemCollection.cs
+++ b/Assets/Scripts/Game/Items/ItemCollection.cs
@@ -260,7 +260,7 @@ namespace DaggerfallWorkshop.Game.Items
         /// <param name="numberToPick">Number of items to pick</param>
         public DaggerfallUnityItem SplitStack(DaggerfallUnityItem stack, int numberToPick) 
         {
-            if (!stack.IsAStack() || numberToPick < 1 || numberToPick > stack.stackCount)
+            if (!stack.IsAStack() || numberToPick < 1 || numberToPick > stack.stackCount || !Contains(stack))
                 return null;
             if (numberToPick == stack.stackCount)
                 return stack;
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

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

Re: Light sources (in-game)

Post by Hazelnut »

I agree, have added that check into my PR. Thanks!
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

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

Re: Light sources (in-game)

Post by Hazelnut »

pango wrote: Fri Nov 02, 2018 9:45 am Real life candles can last for hours, but they don't give out much light, the flame is small...
If they're cheap, and since they don't weight much either, they could be "last resort" kind of light source.
Yeah, got some more time tonight and this has been bugging me - candles should last longer but be dimmer. Original post updated. (again)
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
pango
Posts: 2607
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Light sources (in-game)

Post by pango »

So cool, thanks! :D
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
King of Worms
Posts: 3432
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Re: Light sources (in-game)

Post by King of Worms »

Hazelnut you are on fire, thanks for all of your latest additions!!

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

Re: Light sources (in-game)

Post by Hazelnut »

Thanks KoW, I've been having fun with it all as you can tell. This was achieved with very little code added too, I like finding elegant ways of doing things within the existing DFU framework.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

MrDowntempo
Posts: 38
Joined: Fri Sep 15, 2017 4:01 pm

Re: Light sources (in-game)

Post by MrDowntempo »

Since these aren't in Vanilla anyway, can we have a little fun and add a flicker effect to the light of candles?

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

Re: Light sources (in-game)

Post by Hazelnut »

I'm using a flickering effect to give a visual indication that the light source is about to run out, and I feel a constant flicker would make that much less noticeable. Be easy to make a mod to do this if you really want to, or use the light spell as that moves around giving a flicker effect.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
pango
Posts: 2607
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Light sources (in-game)

Post by pango »

Some feedback about that feature:
- light duration feels okay to me. Either way now you have to raid local shops for light sources before going into a dungeon, estimating how long you'll probably be in, or over-provision your wagon, if you can afford it... Good stuff.
- there's currently modal messages when light goes on or off, is it just for debugging stage? I think transient messages should be sufficient;
- when any menu is open, player torch goes on behind the menu, I don't see the purpose so I assume this is a bug;
- I think I got "your candle died out" message once after reloading a gamesave in Castle Daggerfall, having just died in the depths of a dungeon, I need to reproduce the issue. But maybe that's something to be expected right now.
I haven't played with lanterns much yet, need to do that.
I'd also like to start a character from scratch to see how hard it is with dark dungeons and now light sources. For a minute I had the idea that maybe one could take a log from the campfire in Privateer's Hold cavern as a torch, but that would be too abstruse...

I also wish the monsters would pay more attention to what's going on around them in general. Right now they often don't care if you're fighting one of their fellow creature in the same room, or bang a door like a madman nearby... Going around in a dark dungeon with a torch in hand is probably not very discreet either. But one feature at a time!
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

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

Re: Light sources (in-game)

Post by Hazelnut »

pango wrote: Sat Nov 03, 2018 6:34 pm - there's currently modal messages when light goes on or off, is it just for debugging stage? I think transient messages should be sufficient;
Transient messages don't work when UI windows are open. Without these messages there's no feedback so they may be clunky, but that's DF UI for you.
- when any menu is open, player torch goes on behind the menu, I don't see the purpose so I assume this is a bug;
No, not a bug - no fuel is used as time is stopped.
- I think I got "your candle died out" message once after reloading a gamesave in Castle Daggerfall, having just died in the depths of a dungeon, I need to reproduce the issue. But maybe that's something to be expected right now.
I will take a look at this, maybe this is possible since the behaviour class is not reset at all currently.
I haven't played with lanterns much yet, need to do that.
I'd also like to start a character from scratch to see how hard it is with dark dungeons and now light sources. For a minute I had the idea that maybe one could take a log from the campfire in Privateer's Hold cavern as a torch, but that would be too abstruse...
I think starting equipment should include 5 torches and a couple of candles if this option is selected - good point. Will work on that. :) This should be enough for any players unless it's their first time in PH, but they can always switch the option off if they are having problems so I think that's okay.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

Post Reply