Solarus-Games English Forum

Solarus => Development => Topic started by: YoshiMario2000 on June 07, 2015, 11:23:02 PM

Title: Tunic damage editing?
Post by: YoshiMario2000 on June 07, 2015, 11:23:02 PM
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?
Title: Re: Tunic damage editing?
Post by: Renkineko on June 08, 2015, 07:22:55 AM
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).
Title: Re: Tunic damage editing?
Post by: YoshiMario2000 on June 11, 2015, 01:03:50 AM
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.
Title: Re: Tunic damage editing?
Post by: Renkineko on June 11, 2015, 07:43:55 AM
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 :)