Author Topic: Tunic damage editing?  (Read 1665 times)

YoshiMario2000

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Tunic damage editing?
« 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?
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?

Renkineko

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Re: Tunic damage editing?
« Reply #1 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).

YoshiMario2000

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: Tunic damage editing?
« Reply #2 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:
Code: [Select]
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?

Renkineko

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Re: Tunic damage editing?
« Reply #3 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 :

Code: [Select]
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 :)