Hero Revive Issues...

Jonnycakes

New Member
Reaction score
6
I have a trigger that periodically revives neutral hero units (there are 4 in total), and it isn't working properly for one of the heroes. There is one other hero that it wasn't working for, but when I changed it's stat "Combat-death type" from "Can't raise, does decay" to "Can raise, doesn't decay", it started reviving (this is after I copy-pasted the unit with a different ID. Also, the other units' death types are "Can't raise, does decay" and the revive works for them).

Those fixes don't work for this hero, though. I have tested this fairly extensively, and I am sure that the revive function is being called, the revive location is correct, the unit type is correct, and the unit variable I am using is not null at the time of the revive. The thing that is puzzling here is that the trigger works for 3 out of the 4 heroes, and there should be nothing different in each case other than the unit ID! In fact, all of the heroes were originally copy-pasted from the same base unit. Has anyone else had this bug before/know what is going on?

EDIT: Solved!

JASS:
scope boss initializer init

globals
    public group boss=CreateGroup()
endglobals

private function nothostile takes nothing returns boolean
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO)
endfunction

private function actions takes nothing returns nothing
    local integer i
    local unit u
    local real x
    local real y

    loop
        set u=FirstOfGroup(boss)//When a boss dies, it is added to this group. It is then revived periodically.
        exitwhen u==null        
        call GroupRemoveUnit(boss, u)
        set i=GetUnitTypeId(u)
        if i=='N004' then
            set x=GetRectCenterX(gg_rct_Water_Boss)
            set y=GetRectCenterY(gg_rct_Water_Boss)
        elseif i=='N008' then
            set x=GetRectCenterX(gg_rct_Air_Boss)
            set y=GetRectCenterY(gg_rct_Air_Boss)
        elseif i=='N010' then //this is the unit type that doesn't work. It functions exactly like the others, so I am pretty confident it isn't a problem with my trigger.
            set x=GetRectCenterX(gg_rct_Fire_Boss)
            set y=GetRectCenterY(gg_rct_Fire_Boss)
        else
            set x=GetRectCenterX(gg_rct_Earth_Boss)
            set y=GetRectCenterY(gg_rct_Earth_Boss)
        endif
        call ReviveHero(u, x, y, true)
    endloop
    
endfunction

//===========================================================================
private function init takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterTimerEvent(t, 10., true)
    call TriggerAddAction(t, function actions)
endfunction

endscope
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Why not simply create a completely new unit, with the same unit-type as the dead one ? :eek:
 

Rushhour

New Member
Reaction score
46
Better compare IsUnitType() to false and true, it doesn't return the correct value for some unit types, but I can't remember which work.

And try what happens if you do all that revival stuff in a ForGroup() callback.
 

Jonnycakes

New Member
Reaction score
6
@Komagtion-I suppose that would work (as the unit creation is not a problem, just the revival, partially), but I would really like to not resort to that.

@Rushhour-I am pretty sure the issue isn't the IsUnitType() condition-the function runs when it should, it just doesn't revive the hero. The trigger works, but for one specific kind of unit it doesn't for some reason. I don't think altering the trigger will do any good, as I am sure that the trigger is trying to revive a unit of the correct type at the correct location, but the hero just isn't being revived somehow.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
@ Rushhour: It's the native [Ljass]IsUnit()[/ljass] that needs to be checked for true/false :p

@ Jonnycakes: Have you maybe tried to simply make another trigger which kills that specific unit, and then revives it ? :eek:
If that doesn't work, then there's some internal problem, otherwise it's most likely the trigger :D
 

Jonnycakes

New Member
Reaction score
6
Internal problem for sure. Just tested with another trigger per your suggestion-it works for the water boss but not the fire one (which is the one that has the problem). Any ideas on how to fix this?

EDIT: Problem solved-I copied another unit and changed its stats, and now it works...stupid world editor.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top