• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Level Up System help

Status
Not open for further replies.
Level 3
Joined
Nov 28, 2010
Messages
42
Hello,

im creating a rpg and i want to implement a system that allows me to get skillpoints by levling up and spending them to increse different attributes (Health, Mana, Critchance etc.) through a dialog.

I set up the dialog and dialog buttons, ut now i have a problem. I used 1 skillpoint to increse my health by 50. My health went from 700 to 750. Now I used my second skillpoint again to increase my health by 50. This time it didnt change my health maximum.

I hope you guys can help me!

Thanks for reading!
 
Level 14
Joined
Oct 18, 2013
Messages
724
The health bonus ability doesn't work when you level it. I think you have to manually add that ability to the unit again for the lifegain to stack.
 
It's a long detail, but I'm certain you're using Add Max Health ability.
This ability is bugged when leveled up (search the forum, this is quite frequent to be discussed).

To bypass this, you need to use the bug/glitch of this ability, or search for a BonusMod. There's one written by Earth-Fury at WC3C and there's another one inside Custom Stat System made by Doomlord.

The glitch, if I recall is that when the ability is level up, it won't add the amount, but when removed, it subtract the correct amount.

Demo :
Level 1 : +20
Level 2 : +60

When you update the level, the ability will still grant 20 bonus health (instead of 60), but when you remove the ability <through triggers>, it will reduce the health by 60 (causing a loss of 40).

Mathematically, you can set the abilities to be in this order :
Level 1 : 0
Level 2 : -50
Level 3 : -100
And so on, and then add, set level of the ability (the amount of research + 1 <since level 1 = 0>) and then remove the ability from the unit.

Or, use a multiplication of 2 with about 12 abilities in total for each type, but that's another long story.
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
If you are lazy and just want it to work...
JASS:
globals
    integer udg_Max_Health_Bonus    = 'A000'
    integer udg_Max_Mana_Bonus      = 'A001'
endglobals





library maxstatsmodifier
    function AddMaxHealth takes unit whichUnit, integer amount returns nothing
        if amount == 0 or GetHandleId(whichUnit) == 0 then
            return
        endif
        
        loop
            exitwhen amount < 10000 and amount > -10000
            if amount < 0 then
                call UnitAddAbility(whichUnit, udg_Max_Health_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Health_Bonus, 11)
                call UnitRemoveAbility(whichUnit, udg_Max_Health_Bonus)
                
                set amount = amount + 10000
            else
                call UnitAddAbility(whichUnit, udg_Max_Health_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Health_Bonus, 6)
                call UnitRemoveAbility(whichUnit, udg_Max_Health_Bonus)
                
                set amount = amount - 10000
            endif
        endloop
        
        loop
            exitwhen amount < 1000 and amount > -1000
            if amount < 0 then
                call UnitAddAbility(whichUnit, udg_Max_Health_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Health_Bonus, 10)
                call UnitRemoveAbility(whichUnit, udg_Max_Health_Bonus)
                
                set amount = amount + 1000
            else
                call UnitAddAbility(whichUnit, udg_Max_Health_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Health_Bonus, 5)
                call UnitRemoveAbility(whichUnit, udg_Max_Health_Bonus)
                
                set amount = amount - 1000
            endif
        endloop
        
        loop
            exitwhen amount < 100 and amount > -100
            if amount < 0 then
                call UnitAddAbility(whichUnit, udg_Max_Health_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Health_Bonus, 9)
                call UnitRemoveAbility(whichUnit, udg_Max_Health_Bonus)
                
                set amount = amount + 100
            else
                call UnitAddAbility(whichUnit, udg_Max_Health_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Health_Bonus, 4)
                call UnitRemoveAbility(whichUnit, udg_Max_Health_Bonus)
                
                set amount = amount - 100
            endif
        endloop
        
        loop
            exitwhen amount < 10 and amount > -10
            if amount < 0 then
                call UnitAddAbility(whichUnit, udg_Max_Health_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Health_Bonus, 8)
                call UnitRemoveAbility(whichUnit, udg_Max_Health_Bonus)
                
                set amount = amount + 10
            else
                call UnitAddAbility(whichUnit, udg_Max_Health_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Health_Bonus, 3)
                call UnitRemoveAbility(whichUnit, udg_Max_Health_Bonus)
                
                set amount = amount - 10
            endif
        endloop
        
        loop
            exitwhen amount == 0
            if amount < 0 then
                call UnitAddAbility(whichUnit, udg_Max_Health_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Health_Bonus, 7)
                call UnitRemoveAbility(whichUnit, udg_Max_Health_Bonus)
                
                set amount = amount + 1
            else
                call UnitAddAbility(whichUnit, udg_Max_Health_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Health_Bonus, 2)
                call UnitRemoveAbility(whichUnit, udg_Max_Health_Bonus)
                
                set amount = amount - 1
            endif
        endloop
    endfunction
    function AddMaxMana takes unit whichUnit, integer amount returns nothing
        if amount == 0 or GetHandleId(whichUnit) == 0 then
            return
        endif
        
        loop
            exitwhen amount < 10000 and amount > -10000
            if amount < 0 then
                call UnitAddAbility(whichUnit, udg_Max_Mana_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Mana_Bonus, 11)
                call UnitRemoveAbility(whichUnit, udg_Max_Mana_Bonus)
                
                set amount = amount + 10000
            else
                call UnitAddAbility(whichUnit, udg_Max_Mana_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Mana_Bonus, 6)
                call UnitRemoveAbility(whichUnit, udg_Max_Mana_Bonus)
                
                set amount = amount - 10000
            endif
        endloop
        
        loop
            exitwhen amount < 1000 and amount > -1000
            if amount < 0 then
                call UnitAddAbility(whichUnit, udg_Max_Mana_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Mana_Bonus, 10)
                call UnitRemoveAbility(whichUnit, udg_Max_Mana_Bonus)
                
                set amount = amount + 1000
            else
                call UnitAddAbility(whichUnit, udg_Max_Mana_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Mana_Bonus, 5)
                call UnitRemoveAbility(whichUnit, udg_Max_Mana_Bonus)
                
                set amount = amount - 1000
            endif
        endloop
        
        loop
            exitwhen amount < 100 and amount > -100
            if amount < 0 then
                call UnitAddAbility(whichUnit, udg_Max_Mana_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Mana_Bonus, 9)
                call UnitRemoveAbility(whichUnit, udg_Max_Mana_Bonus)
                
                set amount = amount + 100
            else
                call UnitAddAbility(whichUnit, udg_Max_Mana_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Mana_Bonus, 4)
                call UnitRemoveAbility(whichUnit, udg_Max_Mana_Bonus)
                
                set amount = amount - 100
            endif
        endloop
        
        loop
            exitwhen amount < 10 and amount > -10
            if amount < 0 then
                call UnitAddAbility(whichUnit, udg_Max_Mana_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Mana_Bonus, 8)
                call UnitRemoveAbility(whichUnit, udg_Max_Mana_Bonus)
                
                set amount = amount + 10
            else
                call UnitAddAbility(whichUnit, udg_Max_Mana_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Mana_Bonus, 3)
                call UnitRemoveAbility(whichUnit, udg_Max_Mana_Bonus)
                
                set amount = amount - 10
            endif
        endloop
        
        loop
            exitwhen amount == 0
            if amount < 0 then
                call UnitAddAbility(whichUnit, udg_Max_Mana_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Mana_Bonus, 7)
                call UnitRemoveAbility(whichUnit, udg_Max_Mana_Bonus)
                
                set amount = amount + 1
            else
                call UnitAddAbility(whichUnit, udg_Max_Mana_Bonus)
                call SetUnitAbilityLevel(whichUnit, udg_Max_Mana_Bonus, 2)
                call UnitRemoveAbility(whichUnit, udg_Max_Mana_Bonus)
                
                set amount = amount - 1
            endif
        endloop
    endfunction
endlibrary

Create a trigger and convert it to custom text.
Then place that into that trigger (remove all stuff that was there before copy'n'paste.

Create two abilities based on Item Health Bonus and Item Mana Bonus:
BgkpVPT.png

Give each 11 levels and copy these values into it.
Then use [ctrl] + [d] and you will see a 4 character code in front of the names:
PiYkZL1.png

Set the two integers at the top of that trigger to those values.

If you havent got JNGP, then place the text in the header file and remove the library and global tags and the content of the global tags.
Then create two Global variables with the names "Max_Health_Bonus" and "Max_Mana_Bonus". (both of type ability)
And set those variables to the abilities you just made.

You can use a custom script to add life to a unit.
  • Actions
    • Set TempUnit[0] = (Leveling Hero)
    • Set TempReal[0] = 50.00
    • Custom script: call AddMaxHealth(udg_TempUnit[0], udg_TempReal[0])
(TempUnit and TempReal are array variables which you can use in all your scripts.
Ofcourse of type unit and type real.)
 
Level 12
Joined
May 22, 2015
Messages
1,051
You could also use a flat health bonus upgrade and increase the level as the player increases that attribute. It might not work depending on how the map is set up, but if each player only has one hero, it should be fine.
 
Status
Not open for further replies.
Top