Extended information for attack results

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
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Extended information for attack results

Post by Gambit37 »

Two optional parameters on dsb_attack_text would be great, so something like:

Code: Select all

dsb_attack_text("TEXT", [duration], [other])
Then in sys_render_attack_result I could just test the value of [other] and respond to it with my own functionality.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Extended information for attack results

Post by Sophia »

I revisited this issue in DSB 0.73 and added significantly more flexibility.

DSB 0.73 adds dsb_attack_info which takes a table as a parameter, as well as a ttl. The table is passed to sys_render_attack_result which has been rewritten in 0.73 to pass any table parameters passed via dsb_attack_info on to h_render_attack_info so you can render them however you like.

For example, if you use the following h_render_attack_info function:

Code: Select all

function h_render_attack_info(bmp, attack_table)
	if (attack_table.graphic) then
		dsb_bitmap_draw(attack_table.graphic, bmp, 0, 0, false)
	end
end
Then this code would flash a picture of Mophus (the horror...) for 5 ticks.

Code: Select all

dsb_attack_info({ graphic = gfx.port_mophus }, 5)
If a text property is defined, it will render that text (just like "can't reach" or "need ammo") on top of everything else.

Code: Select all

dsb_attack_info({ graphic = gfx.port_mophus, text = "IT'S MOPHUS" }, 5)
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Extended information for attack results

Post by Gambit37 »

Oooh, nice, that's very flexible. Thanks for improving this. 👍
Post Reply