Attaching an instance to the party

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. You may Image to help finance the hosting costs of this forum.
Post Reply
User avatar
Parallax
DMwiki contributor
Posts: 424
Joined: Mon Aug 28, 2006 7:56 pm
Location: Back in New Jersey

Attaching an instance to the party

Post 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!
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post 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.
User avatar
Parallax
DMwiki contributor
Posts: 424
Joined: Mon Aug 28, 2006 7:56 pm
Location: Back in New Jersey

Post by Parallax »

Pretty neat, thank you!
Post Reply