Tunic damage editing?

Started by YoshiMario2000, June 07, 2015, 11:23:02 PM

Previous topic - Next topic
would it be possible to change how much damage the player takes based on tunic level?
Because sifting though solarus DX's fires shows that the sword has damage variants.
Is the tunic connected to that?
This signature was way too long before, but now it's short!
Also, I am Still Alive!
On ad Off I go!

Do you ever get the feeling that the fandom of a product(s) ruin the potential that you could have had to enjoy the product?

By default, the damage are calculated via the formula

damage of the enemy / tunic level.

You can override this effect by using the event http://www.solarus-games.org/doc/latest/lua_api_hero.html#lua_api_hero_on_taking_damage (Example in use : https://github.com/Renkineko/solarus-nrfh/blob/master/data/physical_condition.lua#L95 where the shield level is also defensive and the damage are tripled if the hero is in a custom state : frozen).

So, If I wanted to Make Tunic levels 1-4 a "set" and tunic levels 5-8 a "set" (using "set" as gender or character change(like Pokemon))

I would probably want to do:
function hero:on_taking_damage(in_damage)
local damage = in_damage

if hero:get_tunic_sprite_id() > 4 then
  damage = damage / 2
end

if damage == 0 then
  return
end

Right?

Sourcing this from the 2nd link you gave me.
This signature was way too long before, but now it's short!
Also, I am Still Alive!
On ad Off I go!

Do you ever get the feeling that the fandom of a product(s) ruin the potential that you could have had to enjoy the product?

Right, I think it should work :) You can also make the formula more automatic by using the floor method :


local damage_divider = math.floor(hero:get_tunic_sprite_id() / 4)
if damage_divider == 0 then
  damage_divider = 1
end
damage = damage / damage_divider


It's the same principle than my shield divider. This way, you can use set 9-12, 13-16 etc. without modify your code :)