• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[vJASS] UnitStripHeroLevel is bugged, anyone know fixes?

Status
Not open for further replies.
Level 31
Joined
Jul 10, 2007
Messages
6,306
JASS:
struct tester extends array
    private static unit u
    private static unit u2
    private static method ts takes nothing returns nothing
        call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,R2S(GetWidgetLife(u))+"=="+R2S(GetWidgetLife(u2)))
    endmethod
    private static method r takes nothing returns boolean
        call ReviveHero(u,GetWidgetX(u),GetWidgetY(u),false)
        call SetWidgetLife(u,GetUnitState(u,UNIT_STATE_MAX_LIFE))
        return false
    endmethod
    private static method onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer l=1000
        set u = CreateUnit(Player(0), 'Hpal', GetStartLocationX(0), GetStartLocationY(0), 0)
        set u2 = CreateUnit(Player(0), 'Hpal', GetStartLocationX(0)+128, GetStartLocationY(0), 0)
        call TriggerRegisterUnitEvent(t,u,EVENT_UNIT_DEATH)
        call TriggerAddCondition(t,Condition(function thistype.r))
        call SetHeroLevel(u,l,false)
        call UnitStripHeroLevel(u,l)
        call SetWidgetLife(u2,GetUnitState(u2,UNIT_STATE_MAX_LIFE)/2)
        call SetWidgetLife(u,GetUnitState(u,UNIT_STATE_MAX_LIFE)/2)
        call TimerStart(CreateTimer(),1,true,function thistype.ts)
        set t=null
    endmethod
endstruct
 
Last edited:

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
If you set gameplay constant Life Regeneration gained per Strength point to 0.00 everything woks fine.
So it seems that (by default 0.05 per str point) every time you call that function, engine calculates the -regeneration gained; formula should be somewhat like:

str pts gained * constant LR per str point = regeneration >>>>> since you reduce the amount of levels it will be: regeneration gained * (-1)
 
I also noticed this bug. It happens with Mana and RegenMana too.

I made test some time ago (and without a good engine for getting states : I only looked the values on the unit's life-bar) but I thought the drop was independant of game constants, only dependant of str/int per level.

Also the Skill points are not well removed : 1 level drop => 1 point drop (if it was used, it lowers the level of a spell). It doesn't fit when there are more levels than cumulated spell levels.

Good luck fixing this function. I personnaly just avoid using it.
 
Status
Not open for further replies.
Top