Page 1 of 1

Attaching an instance to the party

Posted: Tue Jun 03, 2008 4:42 pm
by Parallax
What is the least trouble-prone, least headache-inducing way to temporarily make an instance stay on the same tile as the party (move with the party when it changes tile for any reason, including walking, falling dow a pit, taking stairs, getting teleported, acts of code, etc...) while changing the base code as little as possible?

The objective is to create an overlay like the ones in CSBWin, using a custom haze that is only visible when the party stands on it (and has a front0 view that displays the overlay.) If there is a better way to make overlays in DSB, I'm open to hearing about that as well.

Note: the overlay would need to be applied when the party does certain things (say, for instance, when a particular spell is cast) and would be removed under some conditions (time deadline in general, but anything is possible). Consequently, the property is not confined to a given area of the dungeon, and I am not going to tile the entire dungeon with the custom haze!

Posted: Tue Jun 03, 2008 7:05 pm
by Sophia
Well, to make an instance move with the party, you could always override sys_party_move. However, in this case, there's a better way. :)

What you really want is a party condition.

Code: Select all

C_NEW_COND = dsb_add_condition(PARTY, nil, gfx.overlay, update_freq, update_func)
When this condition is set, gfx.overlay will be drawn on top of the party's viewport. The overlay includes support for alpha channels if you want transparent parts.

Also, every update_freq tick, it will execute update_func. If you don't need an update, just set update to 0 and the function to nil.

To set (that is, "enable") the condition, do:

Code: Select all

dsb_set_condition(PARTY, C_NEW_COND, value)
Value is a "strength" for the condition. If value is 0, the condition is cleared.

This is how poisoning, magic shields, etc. are handled. Check base/conditions.lua for more information.

Posted: Tue Jun 03, 2008 8:00 pm
by Parallax
Pretty neat, thank you!