VERY weird bug with ReviveHero ?!

Komaqtion

You can change this now in User CP.
Reaction score
469
Hello :D

I was just making a very small revive "system" for a friend, and I've noticed that the function [ljass]ReviveHero[/ljass] doesn't seem to work (?!)

I use this small function (At the moment, it is supposed to be a lot bigger, but when not even this works I wonder...) to revive the hero:

JASS:
    private function Actions takes nothing returns nothing
        local unit u = GetTriggerUnit()
        local player p = GetOwningPlayer( u )
        
        //call ReviveData.create( u, p )
        
        call BJDebugMsg( "Works !" )
        
        call TriggerSleepAction( 5. )
        
        call BJDebugMsg( "Works now too !" )
        call BJDebugMsg( GetHeroProperName( u ) )
        
        call ReviveHero( u, GetStartLocationX( GetPlayerStartLocation( p ) ), GetStartLocationY( GetPlayerStartLocation( p ) ), false )
        call ReviveHero( u, 0., 0., false )
        
        if ReviveHero( u, GetStartLocationX( GetPlayerStartLocation( p ) ), GetStartLocationY( GetPlayerStartLocation( p ) ), false ) then
            call BJDebugMsg( &quot;It should work ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite3" alt=":(" title="Frown    :(" loading="lazy" data-shortname=":(" />&quot; )
        endif
        
        set u = null
        set p = null
    endfunction


And the first three messages shows, and the proper name it correct, but the hero isn't revived and the last message isn't shown ?!

Anyone have experienced this very weird bug ? :S

EDIT: I now use this to revive the hero, but it doesn't work either...

JASS:
    function CountTownhalls takes nothing returns boolean
        
        if IsUnitType( GetFilterUnit(), UNIT_TYPE_TOWNHALL ) and GetWidgetLife( GetFilterUnit() ) &gt;= .405 then
            set udg_townHall = true
        endif
        
        return false
    endfunction
    
    function CheckTownhalls takes unit u returns boolean
        local player p = GetOwningPlayer( u )
        
        //call BJDebugMsg( &quot;Works !&quot; )
        
        call GroupEnumUnitsOfPlayer( udg_TempGroup, p, Filter( function CountTownhalls ) )
        
        return udg_townHall
    endfunction


     function Conditions takes nothing returns boolean
        //call BJDebugMsg( &quot;Works !&quot; )
        return CheckTownhalls( GetTriggerUnit() ) and IsUnitType( GetTriggerUnit(), UNIT_TYPE_HERO ) == true
    endfunction
 
 
    function Actions takes nothing returns nothing
        local unit u = GetTriggerUnit()
        local player p = GetOwningPlayer( u )
        
        //call ReviveData.create( u, p )
        
        call BJDebugMsg( &quot;Works !&quot; )
        
        call TriggerSleepAction( 5. )
        
        call BJDebugMsg( &quot;Works now too !&quot; )
        call BJDebugMsg( GetHeroProperName( u ) )
        
        call ReviveHero( u, GetStartLocationX( GetPlayerStartLocation( p ) ), GetStartLocationY( GetPlayerStartLocation( p ) ), false )
        call ReviveHero( u, 0., 0., false )
        
        if ReviveHero( u, GetStartLocationX( GetPlayerStartLocation( p ) ), GetStartLocationY( GetPlayerStartLocation( p ) ), false ) then
            call BJDebugMsg( &quot;It should work ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite3" alt=":(" title="Frown    :(" loading="lazy" data-shortname=":(" />&quot; )
        endif
        
        set u = null
        set p = null
    endfunction

    function InitTrig_Untitled_Trigger_003 takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
        call TriggerAddCondition( t, Condition( function Conditions ) )
        call TriggerAddAction( t, function Actions )
    endfunction


And I've disabled vJass syntax, just to be on the safe side :D
 

BlackRose

Forum User
Reaction score
239
What you talking about? It works... [for me]

Also wouldn't it be more logical to check if the unit is alive, rather then to check if ReviveHero() returned true or false?

JASS:
function CountTownhalls takes nothing returns boolean
    if IsUnitType( GetFilterUnit(), UNIT_TYPE_TOWNHALL ) and GetWidgetLife( GetFilterUnit() ) &gt;= .405 then
        set udg_townHall = true
        return true
    endif
    return false
endfunction

function CheckTownhalls takes unit u returns boolean        
    call GroupEnumUnitsOfPlayer( udg_TempGroup, GetOwningPlayer( u ), Filter( function CountTownhalls ) )
    return udg_townHall
endfunction

function Conditions takes nothing returns boolean
    return CheckTownhalls( GetTriggerUnit() ) and IsUnitType( GetTriggerUnit(), UNIT_TYPE_HERO )
endfunction

function Actions takes nothing returns nothing
    local unit u   = GetTriggerUnit()
    local player p = GetOwningPlayer( u )
    local real x   = GetStartLocationX( GetPlayerStartLocation( p ) )
    local real y   = GetStartLocationY( GetPlayerStartLocation( p ) )
        
    call BJDebugMsg( &quot;Before wait works.&quot; )
    
    call TriggerSleepAction( 5.00 )
    
    call BJDebugMsg( &quot;Hero is existent:&quot; )
    call BJDebugMsg( GetHeroProperName( u ) )
    
    call ReviveHero( u, x, y, false )
    
    if IsUnitType( u, UNIT_TYPE_DEAD ) == false then
        call BJDebugMsg( &quot;ReviveHero() did work.&quot; )
    endif
    
    set u = null
    set p = null
endfunction

function InitTrig_InitTrig takes nothing returns nothing
    local trigger t = CreateTrigger()
    set udg_TempGroup = CreateGroup()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Actions )
endfunction
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Probably XD
Thanks anyways, and I'll just have to make a new map and test it out :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top