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!
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==039;N004039; then
set x=GetRectCenterX(gg_rct_Water_Boss)
set y=GetRectCenterY(gg_rct_Water_Boss)
elseif i==039;N008039; then
set x=GetRectCenterX(gg_rct_Air_Boss)
set y=GetRectCenterY(gg_rct_Air_Boss)
elseif i==039;N010039; 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