(fixed) Illlumulets and mysterious lights

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
Remy
Craftsman
Posts: 111
Joined: Wed Sep 05, 2007 5:24 pm
Contact:

(fixed) Illlumulets and mysterious lights

Post by Remy »

I discovered a wierd occurance, by complete accident. I was putting together a collection of champions, but forgot to set the light level for the level (in DDM, of course). I noticed when I started the game, though, that the light level wasn't completely dark. The source of the light turned out to be an illumulet that was in the inventory (being worn) by a champion still in a mirror.

I'm trying to think of a way to fix this. The obvious solution, to do a check to make sure the champion is in the party before applying the light bonus, doesn't work, because if the player picks the champion, the 'to_neck' event won't be called again, so the illumulet would be "broken" until it's taken off and put back on.

The other possible way is to place events on hold until a champion is added to the party, but I really don't know how difficult that would be. Also, items that alter stats wouldn't be applied until after the champion is choosen - I personally don't see that as a huge problem (and in fact, the player will get more accurate stats when examining a champion in a mirror), but I don't remember if FTL DM did it this way or not.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

Ooh, this one's a bit nasty.

I wouldn't discount the obvious solution, though. :)

I think the best solution is to do exactly that, and to get around the illumulet being broken, we do exactly what needs to be done. I'll modify the engine slightly-- when a character joins or leaves the party, all of his/her items will be "picked up" in the old state and "dropped" again immediately in the new one.
For example, when you choose a champion, the (unlit) illumulet will be "picked up" inside the mirror (no change in state) and then immediately "dropped" again, only this time, the game will tell the instance that it's outside the mirror-- and it will begin casting light.

Putting events on hold until the champion is added would be kind of a mess, and would require a much more complicated, uglier sys_inventory, because you'd still want to execute fit_* functions, obviously!
Remy
Craftsman
Posts: 111
Joined: Wed Sep 05, 2007 5:24 pm
Contact:

Post by Remy »

... because you'd still want to execute fit_* functions, obviously!
I keep forgetting that those can be functions now...

And just a fun fact, I realized this error also appears in Theron's Quest (that's how I discovered it in DSB - I was doing a conversion), and I did a quick test in CSBwin, and it's there as well. So, I'm going to assume it's been around since the original DM.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

Oh, well, if DM gets it wrong too, maybe it's more authentic to leave it... :wink:

Just kidding: I already fixed it.
The solution is that any item that modifies the global gamestate (that is, more than just the current champion), should enclose its actions in the following block of code.

Code: Select all

if (dsb_char_ppos(char)) ... end
What this will do is prevent the code from being executed unless the character has a party position-- that is, in the party.

The fix I applied above will, when the character is added to the party, call of the from_* functions with dsb_char_ppos returning nil (that is, "picking up" everything inside the mirror) and then calling all of the to_* functions with it set to the new ppos. ("Putting down" everything back outside)
Post Reply