Custom Damage Types (DSB 0.78+)
Posted: Tue Sep 29, 2020 1:06 am
As of DSB 0.78 you'll be able to add custom damage types. In your custom Lua scripts you'll need to add code like:
This increases the total number of damage types to 4 (health, stamina, mana, and our new type) and adds a new damage type, "psychic," to the dtype table with id 3. (health has id 0, stamina has id 1, and mana has id 2)
If you provide a suitable image, DSB will automatically draw it, when you invoke it with code like:
The easiest way to have your image drawn is to extend the default DSB damage images. Add a fourth image of equal width and height below the first three and DSB will automatically draw it.
You can do this for however many new damage types you want to add, for example:
If you need the default images to modify, here they are:


However, you can also use a purely custom renderer, if you'd like. Take a look at h_damage_popup in base/hooks.lua for details.
Code: Select all
inventory_info.damage_types = 4
inventory_info.dtype.psychic = 3
If you provide a suitable image, DSB will automatically draw it, when you invoke it with code like:
Code: Select all
dsb_damage_popup(ppos, inventory_info.dtype.psychic, damage_amount)
You can do this for however many new damage types you want to add, for example:
Code: Select all
inventory_info.damage_types = 5
inventory_info.dtype.psychic = 3
inventory_info.dtype.something_else = 4


However, you can also use a purely custom renderer, if you'd like. Take a look at h_damage_popup in base/hooks.lua for details.