Hero XP penalty upon death

Status
Not open for further replies.
Level 3
Joined
Apr 7, 2020
Messages
20
Hi all :)

I wanted to implement an experience penalty for dying in the game.

I have made an array where X is the hero's level and Y is the amount of xp necessary to reach that level. My idea was to create 2 triggers like this (Sorry I don't have the triggers at hand right now):

*****************************************************************************************************************************
Trigger 1:
Set XpTable[1] to 0
Set XpTable[2] to 200
Set XpTable[3] to 500
Etc.

Trigger 2:
Event: A unit is revived

Condition: reviving unit is a hero

Actions:
Set experience for reviving hero to value of Y for X = level of reviving unit
*****************************************************************************************************************************

The idea is that if you resurrect your hero, their Xp is reset to the minimal amount for that level, so they cannot lose a level, but they are more or less penalized, but it doesn't work. I don't know if there's a mistake in my code or if the game doesn't allow for heroes' Xp to go down instead of up?
 
Last edited:
It appears the SetHeroXP function cannot remove XP, only add. But you can use this line to remove a hero level and then use the SetHeroXP function to readd the necessary amount of XP.
  • Hero - Set (Reviving Hero) Hero-level to ((Hero level of (Reviving Hero)) - 1), Hide level-up graphics
If you put this line before your SetHeroXP line, it should work except for level 1 heroes.

You can also give the hero a Tome of Experience where you modified the ability to grant negative experience. That would also work for level 1 heroes.

And there might be an even easier solution.
 
Level 3
Joined
Apr 7, 2020
Messages
20
Hey, thanks for your response!

These aren't bad solutions, but the first one doesn't work for 1st level heroes as you mentionned, and the reviving hero has to relearn a skill upon coming back to life... Unless I create several variables to store the levels of each spell, but that becomes complicated if more than one hero dies.

The second solution seems better, but I don't see how you make the modified tome of xp remove exactly the right amount?

Could you explain the even easier solution you mention?

Thanks again anyway :)
 

Uncle

Warcraft Moderator
Level 69
Joined
Aug 10, 2018
Messages
7,174
If you keep your Experience Table at multiples of 100 then you could have an Experience Tome that gives -100 Exp. Then simply give the Hero X of these Tomes at once when de-leveling.

A Hero at level 1 will receive 2x Tomes (-200). A Hero at level 2 will receive 3x Tomes (-300):
  • Set XpTablePenalty[1] to 2
  • Set XpTablePenalty[2] to 3
  • Apply Xp Penalty
    • Events
      • Unit - A unit Finishes reviving
    • Conditions
    • Actions
      • Set XpHero = (Reviving Hero)
      • For each (Integer XpLoop) from 1 to XpTablePenalty[(Hero level of XpHero)], do (Actions)
        • Loop - Actions
          • Hero - Create Tome of Experience -100 and give it to XpHero
Alternatively, you could pull the classic "Not a bug but a feature." and say that Level 1 is free of this penalty. Or make it so that your Hero reaches Level 2 very early on.

Antares said that there MIGHT be an easier solution, not that there was one.
 
Last edited:

Uncle

Warcraft Moderator
Level 69
Joined
Aug 10, 2018
Messages
7,174
Great thanks!

Oops, yeah, sorry, I misread the ''might'' :gg:
I assumed that the Exp Tome thing worked when I posted that. After testing I found that it doesn't work if the Hero is at max level and it also breaks the Exp bar ui and fails to lower the Hero level.

Also, the Tomes are unnecessary, this Action works the same way:
  • Hero - Add -100 experience to Paladin 0000 <gen>, Hide level-up graphics
 
Last edited:
Level 3
Joined
Apr 7, 2020
Messages
20
That's perfect!

I just tested this:

Set XpPenatlyInteger = (XpTable(Hero level of (reviving hero)) - (Hero experience of (reviving hero))
Add XpPenaltyInteger to reviving hero.

That did it. Thanks people :thumbs_up:
 
Status
Not open for further replies.
Top