constant function UnholyAbil takes nothing returns integer
return 'A000' // Custom Unholy Aura ( -0.01 MS "Bonus" )
endfunction
constant function UnholyBuff takes nothing returns integer
return 'BUau' // Unholy Aura buff (default)
endfunction
function AddAbilityWithDelay takes nothing returns nothing
local integer i = 0
loop
exitwhen udg_NMS_index == 0
call UnitAddAbility(udg_NMS_unit[i], udg_NMS_abil[i])
set udg_NMS_index = udg_NMS_index - 1
set udg_NMS_abil[i] = udg_NMS_abil[udg_NMS_index]
set udg_NMS_unit[i] = udg_NMS_unit[udg_NMS_index]
set i = i + 1
endloop
endfunction
function NMSKeepFormation takes nothing returns boolean
local unit u = GetTriggerUnit()
if GetUnitAbilityLevel(u, UnholyAbil()) > 0 then
// Avoiding infinite loops
call DisableTrigger( GetTriggeringTrigger() )
// Remove ability and buff from the unit
call UnitRemoveAbility(u, UnholyAbil())
call UnitRemoveAbility(u, UnholyBuff())
// Re-order
call IssuePointOrderById(u, GetIssuedOrderId(), GetOrderPointX(), GetOrderPointY())
// Add ability to the unit
set udg_NMS_unit[udg_NMS_index] = u
set udg_NMS_abil[udg_NMS_index] = UnholyAbil()
set udg_NMS_index = udg_NMS_index + 1
call TimerStart(udg_NMS_timer, .03, false, function AddAbilityWithDelay) // I tried with 0.025*, sometimes it works. (*EDIT: I, previously, said "0.25")
call EnableTrigger( GetTriggeringTrigger() )
endif
set u = null
return false
endfunction
//===========================================================================
function InitTrig_Keep_Formation takes nothing returns nothing
local trigger kform = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(kform, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerAddCondition(kform, Condition(function NMSKeepFormation))
set kform = null
endfunction