- Joined
- Feb 9, 2009
- Messages
- 1,790
Things that would improve this submission.
- delete melee initialization
- remove paladin abilities
(1 ratings)
Done and doneThings that would improve this submission.
- delete melee initialization
- remove paladin abilities
Thanks for the review. Even when following your instructions I couldn't get the defend ability to reflect again for a non-hero unit after its revived. I debug printed and the unit revived trigger does execute but even removing and re-adding the ability then seemingly won't fix it. Also for the record its DeathEvent = 2.0Mandatory: If the disabled trigger "Jedi Reflection Defend Unit Revived" is supposed to be when a unit is reicarnated or animated dead etc, then use DeathEvent 0.50, according to the GUI Unit Event. (I know since it's on your to do list )
I would make the special effect that is created on the success of deflection configurable, since one might not even use the one from the Defend Ability.
Using the default Defend ability might not be a good idea if one is already using that. Making it a custom one is safer. Also, I was attempting to find the configuration where you defined the variable DEFEND_ID and then realised you used the initial value. The problem with this is when one wants to copy only the version they're interested in, the variable is either in one folder or the other, not both. An initialization trigger would still be better in this case for the configuration, in both versions.
Also since this requires GUI Unit Event, Damage Engine, Missiles (also MissileEffect - MissileUtils isn't actually required), these also use Alloc, WorldBounds and TimerUtils. They should be in a "Requirements" folder. So it would look like this:
Requirements:
- [the libraries I just mentioned]
- Jedi Reflection (uses defend ability)
- triggers
- Jedi Reflection (Pure JASS)
- triggers
The user can then remove theversion he doesn't want, and then it's easy to copy paste.
Not critical: "Jedi Reflection Reflect Defend Version" and "Jedi Reflection JASS" trigger's indention appears to be slightly off when declaring the struct and the "endstruct" part.
"Jedi Reflection Defend Unit Ready" trigger is in JASS, I don't understand why others like "Jedi Reflection Defend Hero Revived" aren't.
All in all, it's a simple and cool idea, despite having its limitations.
Fix the mandatory ones and it's certain approval.
scope JediReflectionDefend
globals
private string DEFEND_FX = "Abilities\\Spells\\Human\\Defend\\DefendCaster.mdl" //Effect to play when a non ranged piercing attack is deflected
public Table Hash
endglobals
public function callback takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local unit u = Hash.unit[id]
call IssueImmediateOrder(u, "defend" )
call PauseTimer(t)
call DestroyTimer(t)
call Hash.unit.remove(id)
set u = null
set t = null
endfunction
private static method onInit takes nothing returns nothing
local trigger t= CreateTrigger()
call TriggerRegisterVariableEvent(t, "udg_PreDamageEvent", EQUAL, 1.00)
call TriggerAddCondition(t,Condition(function thistype.ReflectCondition))
call TriggerAddAction(t,function thistype.ReflectAction)
set t=null
set Hash = Table.create()
set udg_DEFEND_ID = 'A000' //Change this to your defend ability rawcode
endmethod
function Trig_Jedi_Reflection_Defend_Unit_Revived_Actions takes nothing returns nothing
local timer t = CreateTimer()
set JediReflectionDefend_Hash.unit[GetHandleId(t)] = udg_UDexUnits[udg_UDex]
call TimerStart(t, 0., false, function JediReflectionDefend_callback)
set t = null
endfunction
Yes, you are right. I failed to read the corresponding line of the DeathEvent.Also for the record its DeathEvent = 2.0
//===========================================================================
function UnitEventDestroyGroup takes integer i returns nothing
if udg_CargoTransportGroup[i] != null then
call DestroyGroup(udg_CargoTransportGroup[i])
set udg_CargoTransportGroup[i] = null
endif
endfunction
function UnitEventCheckAfter takes nothing returns nothing
local integer id = 0
local unit u
loop
set id = udg_CheckDeathList[id]
exitwhen id == 0
set udg_UDex = id
set u = udg_UDexUnits[id]
if udg_IsUnitNew[id] then
//The unit was just created.
set udg_IsUnitNew[id] = false
set udg_UnitIndexEvent = 1.50 //New event requested by SpellBound to detect when unit fully enters scope.
set udg_UnitIndexEvent = 0.00
elseif udg_IsUnitTransforming[id] then
//Added 21 July 2017 to fix the issue re-adding this ability in the same instant
set udg_UnitTypeEvent = 0.00
set udg_UnitTypeEvent = 1.00
set udg_UnitTypeOf[id] = GetUnitTypeId(u) //Set this afterward as otherwise the user won't know what the previous unittype was.
set udg_IsUnitTransforming[id] = false
call UnitAddAbility(u, udg_DetectTransformAbility)
elseif udg_IsUnitAlive[id] then
//The unit has started reincarnating.
set udg_IsUnitReincarnating[id] = true
set udg_IsUnitAlive[id] = false
set udg_DeathEvent = 0.50
set udg_DeathEvent = 0.00
elseif GetUnitTypeId(u) != 0 and not IsUnitType(u, UNIT_TYPE_DEAD) then //with vJass, could just use UnitAlive instead of both of these values.
//Moved this code to fire after a 0 second timer instead.
set udg_IsUnitAlive[id] = true
set udg_DeathEvent = 2.00
set udg_DeathEvent = 0.00
set udg_IsUnitReincarnating[id] = false
endif
set udg_CheckDeathInList[id] = false
endloop
set u = null
//Empty the list
set udg_CheckDeathList[0] = 0
endfunction
function UnitEventCheckAfterProxy takes integer i returns nothing
if udg_CheckDeathList[0] == 0 then
call TimerStart(udg_CheckDeathTimer, 0.00, false, function UnitEventCheckAfter)
endif
if not udg_CheckDeathInList[i] then
set udg_CheckDeathList[i] = udg_CheckDeathList[0]
set udg_CheckDeathList[0] = i
set udg_CheckDeathInList[i] = true
endif
endfunction
function UnitEventOnUnload takes nothing returns nothing
local integer i = udg_UDex
call GroupRemoveUnit(udg_CargoTransportGroup[GetUnitUserData(udg_CargoTransportUnit[i])], udg_UDexUnits[i])
set udg_IsUnitBeingUnloaded[i] = true
set udg_CargoEvent = 0.00
set udg_CargoEvent = 2.00
set udg_CargoEvent = 0.00
set udg_IsUnitBeingUnloaded[i] = false
if not IsUnitLoaded(udg_UDexUnits[i]) or IsUnitType(udg_CargoTransportUnit[i], UNIT_TYPE_DEAD) or GetUnitTypeId(udg_CargoTransportUnit[i]) == 0 then
set udg_CargoTransportUnit[i] = null
endif
endfunction
function UnitEventOnDeath takes nothing returns boolean
local integer pdex = udg_UDex
set udg_UDex = GetUnitUserData(GetTriggerUnit())
if udg_UDex != 0 then
set udg_KillerOfUnit[udg_UDex] = GetKillingUnit() //Added 29 May 2017 for GIMLI_2
set udg_IsUnitAlive[udg_UDex] = false
set udg_DeathEvent = 0.00
set udg_DeathEvent = 1.00
set udg_DeathEvent = 0.00
set udg_KillerOfUnit[udg_UDex] = null
if udg_CargoTransportUnit[udg_UDex] != null then
call UnitEventOnUnload()
endif
endif
set udg_UDex = pdex
return false
endfunction
function UnitEventOnOrder takes nothing returns boolean
local integer pdex = udg_UDex
local unit u = GetFilterUnit()
local integer i = GetUnitUserData(u)
if i > 0 then
set udg_UDex = i
if GetUnitAbilityLevel(u, udg_DetectRemoveAbility) == 0 then
if not udg_IsUnitRemoved[i] then
set udg_IsUnitRemoved[i] = true
set udg_IsUnitAlive[i] = false
set udg_SummonerOfUnit[i] = null
//For backwards-compatibility:
set udg_DeathEvent = 0.00
set udg_DeathEvent = 3.00
set udg_DeathEvent = 0.00
//Fire deindex event for UDex:
set udg_UnitIndexEvent = 0.00
set udg_UnitIndexEvent = 2.00
set udg_UnitIndexEvent = 0.00
set udg_UDexNext[udg_UDexPrev[i]] = udg_UDexNext[i]
set udg_UDexPrev[udg_UDexNext[i]] = udg_UDexPrev[i]
// Recycle the index for later use
set udg_UDexUnits[i] = null
set udg_UDexPrev[i] = udg_UDexLastRecycled
set udg_UDexLastRecycled = i
call UnitEventDestroyGroup(i)
endif
elseif not udg_IsUnitAlive[i] then
if not IsUnitType(u, UNIT_TYPE_DEAD) then
call UnitEventCheckAfterProxy(i) //modified 22 Oct 2022 to ensure the unit is fully revived before firing the event.
endif
elseif IsUnitType(u, UNIT_TYPE_DEAD) then
if udg_IsUnitNew[i] then
//This unit was created as a corpse.
set udg_IsUnitAlive[i] = false
set udg_DeathEvent = 0.00
set udg_DeathEvent = 1.00
set udg_DeathEvent = 0.00
elseif udg_CargoTransportUnit[i] == null or not IsUnitType(u, UNIT_TYPE_HERO) then
//The unit may have just started reincarnating.
call UnitEventCheckAfterProxy(i)
endif
elseif GetUnitAbilityLevel(u, udg_DetectTransformAbility) == 0 and not udg_IsUnitTransforming[i] then
set udg_IsUnitTransforming[i] = true
call UnitEventCheckAfterProxy(i) //This block has been updated on 21 July 2017
endif
if udg_CargoTransportUnit[i] != null and not udg_IsUnitBeingUnloaded[i] and not IsUnitLoaded(u) or IsUnitType(u, UNIT_TYPE_DEAD) then
call UnitEventOnUnload()
endif
set udg_UDex = pdex
endif
set u = null
return false
endfunction
function UnitEventOnSummon takes nothing returns boolean
local integer pdex = udg_UDex
set udg_UDex = GetUnitUserData(GetTriggerUnit())
if udg_IsUnitNew[udg_UDex] then
set udg_SummonerOfUnit[udg_UDex] = GetSummoningUnit()
set udg_UnitIndexEvent = 0.00
set udg_UnitIndexEvent = 0.50
set udg_UnitIndexEvent = 0.00
endif
set udg_UDex = pdex
return false
endfunction
function UnitEventOnLoad takes nothing returns boolean
local integer pdex = udg_UDex
local integer i = GetUnitUserData(GetTriggerUnit())
local integer index
if i != 0 then
set udg_UDex = i
if udg_CargoTransportUnit[i] != null then
call UnitEventOnUnload()
endif
//Loaded corpses do not issue an order when unloaded, therefore must
//use the enter-region event method taken from Jesus4Lyf's Transport.
if not udg_IsUnitAlive[i] then
call SetUnitX(udg_UDexUnits[i], udg_WorldMaxX)
call SetUnitY(udg_UDexUnits[i], udg_WorldMaxY)
endif
set udg_CargoTransportUnit[i] = GetTransportUnit()
set index = GetUnitUserData(udg_CargoTransportUnit[i])
if udg_CargoTransportGroup[index] == null then
set udg_CargoTransportGroup[index] = CreateGroup()
endif
call GroupAddUnit(udg_CargoTransportGroup[index], udg_UDexUnits[i])
set udg_CargoEvent = 0.00
set udg_CargoEvent = 1.00
set udg_CargoEvent = 0.00
set udg_UDex = pdex
endif
return false
endfunction
function UnitEventEnter takes nothing returns boolean
local integer pdex = udg_UDex
local integer i = udg_UDexLastRecycled
local unit u = GetFilterUnit()
if udg_UnitIndexerEnabled and GetUnitAbilityLevel(u, udg_DetectRemoveAbility) == 0 then
//Generate a unique integer index for this unit
if i == 0 then
set i = udg_UDexMax + 1
set udg_UDexMax = i
else
set udg_UDexLastRecycled = udg_UDexPrev[i]
endif
//Link index to unit, unit to index
set udg_UDexUnits[i] = u
call SetUnitUserData(u, i)
//For backwards-compatibility, add the unit to a linked list
set udg_UDexNext[i] = udg_UDexNext[0]
set udg_UDexPrev[udg_UDexNext[0]] = i
set udg_UDexNext[0] = i
set udg_UDexPrev[i] = 0
set udg_CheckDeathInList[i] = false
call UnitAddAbility(u, udg_DetectRemoveAbility)
call UnitMakeAbilityPermanent(u, true, udg_DetectRemoveAbility)
call UnitAddAbility(u, udg_DetectTransformAbility)
set udg_UnitTypeOf[i] = GetUnitTypeId(u)
set udg_IsUnitNew[i] = true
set udg_IsUnitAlive[i] = true
set udg_IsUnitRemoved[i] = false
set udg_IsUnitReincarnating[i] = false
set udg_IsUnitPreplaced[i] = udg_IsUnitPreplaced[0] //Added 29 May 2017 for Spellbound
call UnitEventCheckAfterProxy(i)
//Fire index event for UDex
set udg_UDex = i
set udg_UnitIndexEvent = 0.00
set udg_UnitIndexEvent = 1.00
set udg_UnitIndexEvent = 0.00
else
set udg_UDex = GetUnitUserData(u)
if udg_CargoTransportUnit[udg_UDex] != null and not IsUnitLoaded(u) then
//The unit was dead, but has re-entered the map.
call UnitEventOnUnload()
endif
endif
set udg_UDex = pdex
set u = null
return false
endfunction
//===========================================================================
function UnitEventInit takes nothing returns nothing
local integer i = bj_MAX_PLAYER_SLOTS //update to make it work with 1.29
local player p
local trigger t = CreateTrigger()
local trigger load = CreateTrigger()
local trigger death = CreateTrigger()
local trigger summon = CreateTrigger()
local rect r = GetWorldBounds()
local region re = CreateRegion()
local boolexpr enterB = Filter(function UnitEventEnter)
local boolexpr orderB = Filter(function UnitEventOnOrder)
set udg_WorldMaxX = GetRectMaxX(r)
set udg_WorldMaxY = GetRectMaxY(r)
call RegionAddRect(re, r)
call RemoveRect(r)
call UnitEventDestroyGroup(0)
call UnitEventDestroyGroup(1)
set udg_CheckDeathList[0] = 0
set udg_UnitIndexerEnabled = true
call TriggerRegisterEnterRegion(CreateTrigger(), re, enterB)
call TriggerAddCondition(load, Filter(function UnitEventOnLoad))
call TriggerAddCondition(death, Filter(function UnitEventOnDeath))
call TriggerAddCondition(summon, Filter(function UnitEventOnSummon))
loop
set i = i - 1
set p = Player(i)
call SetPlayerAbilityAvailable(p, udg_DetectRemoveAbility, false)
call SetPlayerAbilityAvailable(p, udg_DetectTransformAbility, false)
call TriggerRegisterPlayerUnitEvent(summon, p, EVENT_PLAYER_UNIT_SUMMON, null)
call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_ISSUED_ORDER, orderB)
call TriggerRegisterPlayerUnitEvent(death, p, EVENT_PLAYER_UNIT_DEATH, null)
call TriggerRegisterPlayerUnitEvent(load, p, EVENT_PLAYER_UNIT_LOADED, null)
call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, p, enterB)
exitwhen i == 0
endloop
set summon = null
set death = null
set load = null
set re = null
set enterB = null
set orderB = null
set p = null
set r = null
set t = null
endfunction
function InitTrig_Unit_Event takes nothing returns nothing
endfunction
It appears not to even fire on resurrection anymore. It fires on death instead.Could you try this hotfix of Unit Event to see if this fixes the problem?
JASS://=========================================================================== function UnitEventDestroyGroup takes integer i returns nothing if udg_CargoTransportGroup[i] != null then call DestroyGroup(udg_CargoTransportGroup[i]) set udg_CargoTransportGroup[i] = null endif endfunction function UnitEventCheckAfter takes nothing returns nothing local integer i = 0 loop set i = udg_CheckDeathList[i] exitwhen i == 0 set udg_UDex = i if udg_IsUnitNew[i] then //The unit was just created. set udg_IsUnitNew[i] = false set udg_UnitIndexEvent = 1.50 //New event requested by SpellBound to detect when unit fully enters scope. set udg_UnitIndexEvent = 0.00 elseif udg_IsUnitTransforming[i] then //Added 21 July 2017 to fix the issue re-adding this ability in the same instant set udg_UnitTypeEvent = 0.00 set udg_UnitTypeEvent = 1.00 set udg_UnitTypeOf[i] = GetUnitTypeId(udg_UDexUnits[i]) //Set this afterward to give the user extra reference set udg_IsUnitTransforming[i] = false call UnitAddAbility(udg_UDexUnits[i], udg_DetectTransformAbility) elseif udg_IsUnitAlive[i] then //The unit has started reincarnating. set udg_IsUnitReincarnating[i] = true set udg_IsUnitAlive[i] = false set udg_DeathEvent = 0.50 set udg_DeathEvent = 0.00 else //Moved this code to fire after a 0 second timer instead. set udg_IsUnitAlive[i] = true set udg_DeathEvent = 0.00 set udg_DeathEvent = 2.00 set udg_DeathEvent = 0.00 set udg_IsUnitReincarnating[i] = false endif set udg_CheckDeathInList[i] = false endloop //Empty the list set udg_CheckDeathList[0] = 0 endfunction function UnitEventCheckAfterProxy takes integer i returns nothing if udg_CheckDeathList[0] == 0 then call TimerStart(udg_CheckDeathTimer, 0.00, false, function UnitEventCheckAfter) endif if not udg_CheckDeathInList[i] then set udg_CheckDeathList[i] = udg_CheckDeathList[0] set udg_CheckDeathList[0] = i set udg_CheckDeathInList[i] = true endif endfunction function UnitEventOnUnload takes nothing returns nothing local integer i = udg_UDex call GroupRemoveUnit(udg_CargoTransportGroup[GetUnitUserData(udg_CargoTransportUnit[i])], udg_UDexUnits[i]) set udg_IsUnitBeingUnloaded[i] = true set udg_CargoEvent = 0.00 set udg_CargoEvent = 2.00 set udg_CargoEvent = 0.00 set udg_IsUnitBeingUnloaded[i] = false if not IsUnitLoaded(udg_UDexUnits[i]) or IsUnitType(udg_CargoTransportUnit[i], UNIT_TYPE_DEAD) or GetUnitTypeId(udg_CargoTransportUnit[i]) == 0 then set udg_CargoTransportUnit[i] = null endif endfunction function UnitEventOnDeath takes nothing returns boolean local integer pdex = udg_UDex set udg_UDex = GetUnitUserData(GetTriggerUnit()) if udg_UDex != 0 then set udg_KillerOfUnit[udg_UDex] = GetKillingUnit() //Added 29 May 2017 for GIMLI_2 set udg_IsUnitAlive[udg_UDex] = false set udg_DeathEvent = 0.00 set udg_DeathEvent = 1.00 set udg_DeathEvent = 0.00 set udg_KillerOfUnit[udg_UDex] = null if udg_CargoTransportUnit[udg_UDex] != null then call UnitEventOnUnload() endif endif set udg_UDex = pdex return false endfunction function UnitEventOnOrder takes nothing returns boolean local integer pdex = udg_UDex local unit u = GetFilterUnit() local integer i = GetUnitUserData(u) if i > 0 then set udg_UDex = i if GetUnitAbilityLevel(u, udg_DetectRemoveAbility) == 0 then if not udg_IsUnitRemoved[i] then set udg_IsUnitRemoved[i] = true set udg_IsUnitAlive[i] = false set udg_SummonerOfUnit[i] = null //For backwards-compatibility: set udg_DeathEvent = 0.00 set udg_DeathEvent = 3.00 set udg_DeathEvent = 0.00 //Fire deindex event for UDex: set udg_UnitIndexEvent = 0.00 set udg_UnitIndexEvent = 2.00 set udg_UnitIndexEvent = 0.00 set udg_UDexNext[udg_UDexPrev[i]] = udg_UDexNext[i] set udg_UDexPrev[udg_UDexNext[i]] = udg_UDexPrev[i] // Recycle the index for later use set udg_UDexUnits[i] = null set udg_UDexPrev[i] = udg_UDexLastRecycled set udg_UDexLastRecycled = i call UnitEventDestroyGroup(i) endif elseif not udg_IsUnitAlive[i] then if not IsUnitType(u, UNIT_TYPE_DEAD) then call UnitEventCheckAfterProxy(i) //modified 22 Oct 2022 to ensure the unit is fully revived before firing the event. endif elseif IsUnitType(u, UNIT_TYPE_DEAD) then if udg_IsUnitNew[i] then //This unit was created as a corpse. set udg_IsUnitAlive[i] = false set udg_DeathEvent = 0.00 set udg_DeathEvent = 1.00 set udg_DeathEvent = 0.00 elseif udg_CargoTransportUnit[i] == null or not IsUnitType(u, UNIT_TYPE_HERO) then //The unit may have just started reincarnating. call UnitEventCheckAfterProxy(i) endif elseif GetUnitAbilityLevel(u, udg_DetectTransformAbility) == 0 and not udg_IsUnitTransforming[i] then set udg_IsUnitTransforming[i] = true call UnitEventCheckAfterProxy(i) //This block has been updated on 21 July 2017 endif if udg_CargoTransportUnit[i] != null and not udg_IsUnitBeingUnloaded[i] and not IsUnitLoaded(u) or IsUnitType(u, UNIT_TYPE_DEAD) then call UnitEventOnUnload() endif set udg_UDex = pdex endif set u = null return false endfunction function UnitEventOnSummon takes nothing returns boolean local integer pdex = udg_UDex set udg_UDex = GetUnitUserData(GetTriggerUnit()) if udg_IsUnitNew[udg_UDex] then set udg_SummonerOfUnit[udg_UDex] = GetSummoningUnit() set udg_UnitIndexEvent = 0.00 set udg_UnitIndexEvent = 0.50 set udg_UnitIndexEvent = 0.00 endif set udg_UDex = pdex return false endfunction function UnitEventOnLoad takes nothing returns boolean local integer pdex = udg_UDex local integer i = GetUnitUserData(GetTriggerUnit()) local integer index if i != 0 then set udg_UDex = i if udg_CargoTransportUnit[i] != null then call UnitEventOnUnload() endif //Loaded corpses do not issue an order when unloaded, therefore must //use the enter-region event method taken from Jesus4Lyf's Transport. if not udg_IsUnitAlive[i] then call SetUnitX(udg_UDexUnits[i], udg_WorldMaxX) call SetUnitY(udg_UDexUnits[i], udg_WorldMaxY) endif set udg_CargoTransportUnit[i] = GetTransportUnit() set index = GetUnitUserData(udg_CargoTransportUnit[i]) if udg_CargoTransportGroup[index] == null then set udg_CargoTransportGroup[index] = CreateGroup() endif call GroupAddUnit(udg_CargoTransportGroup[index], udg_UDexUnits[i]) set udg_CargoEvent = 0.00 set udg_CargoEvent = 1.00 set udg_CargoEvent = 0.00 set udg_UDex = pdex endif return false endfunction function UnitEventEnter takes nothing returns boolean local integer pdex = udg_UDex local integer i = udg_UDexLastRecycled local unit u = GetFilterUnit() if udg_UnitIndexerEnabled and GetUnitAbilityLevel(u, udg_DetectRemoveAbility) == 0 then //Generate a unique integer index for this unit if i == 0 then set i = udg_UDexMax + 1 set udg_UDexMax = i else set udg_UDexLastRecycled = udg_UDexPrev[i] endif //Link index to unit, unit to index set udg_UDexUnits[i] = u call SetUnitUserData(u, i) //For backwards-compatibility, add the unit to a linked list set udg_UDexNext[i] = udg_UDexNext[0] set udg_UDexPrev[udg_UDexNext[0]] = i set udg_UDexNext[0] = i set udg_UDexPrev[i] = 0 set udg_CheckDeathInList[i] = false call UnitAddAbility(u, udg_DetectRemoveAbility) call UnitMakeAbilityPermanent(u, true, udg_DetectRemoveAbility) call UnitAddAbility(u, udg_DetectTransformAbility) set udg_UnitTypeOf[i] = GetUnitTypeId(u) set udg_IsUnitNew[i] = true set udg_IsUnitAlive[i] = true set udg_IsUnitRemoved[i] = false set udg_IsUnitReincarnating[i] = false set udg_IsUnitPreplaced[i] = udg_IsUnitPreplaced[0] //Added 29 May 2017 for Spellbound call UnitEventCheckAfterProxy(i) //Fire index event for UDex set udg_UDex = i set udg_UnitIndexEvent = 0.00 set udg_UnitIndexEvent = 1.00 set udg_UnitIndexEvent = 0.00 else set udg_UDex = GetUnitUserData(u) if udg_CargoTransportUnit[udg_UDex] != null and not IsUnitLoaded(u) then //The unit was dead, but has re-entered the map. call UnitEventOnUnload() endif endif set udg_UDex = pdex set u = null return false endfunction //=========================================================================== function UnitEventInit takes nothing returns nothing local integer i = bj_MAX_PLAYER_SLOTS //update to make it work with 1.29 local player p local trigger t = CreateTrigger() local trigger load = CreateTrigger() local trigger death = CreateTrigger() local trigger summon = CreateTrigger() local rect r = GetWorldBounds() local region re = CreateRegion() local boolexpr enterB = Filter(function UnitEventEnter) local boolexpr orderB = Filter(function UnitEventOnOrder) set udg_WorldMaxX = GetRectMaxX(r) set udg_WorldMaxY = GetRectMaxY(r) call RegionAddRect(re, r) call RemoveRect(r) call UnitEventDestroyGroup(0) call UnitEventDestroyGroup(1) set udg_CheckDeathList[0] = 0 set udg_UnitIndexerEnabled = true call TriggerRegisterEnterRegion(CreateTrigger(), re, enterB) call TriggerAddCondition(load, Filter(function UnitEventOnLoad)) call TriggerAddCondition(death, Filter(function UnitEventOnDeath)) call TriggerAddCondition(summon, Filter(function UnitEventOnSummon)) loop set i = i - 1 set p = Player(i) call SetPlayerAbilityAvailable(p, udg_DetectRemoveAbility, false) call SetPlayerAbilityAvailable(p, udg_DetectTransformAbility, false) call TriggerRegisterPlayerUnitEvent(summon, p, EVENT_PLAYER_UNIT_SUMMON, null) call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_ISSUED_ORDER, orderB) call TriggerRegisterPlayerUnitEvent(death, p, EVENT_PLAYER_UNIT_DEATH, null) call TriggerRegisterPlayerUnitEvent(load, p, EVENT_PLAYER_UNIT_LOADED, null) call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, p, enterB) exitwhen i == 0 endloop set summon = null set death = null set load = null set re = null set enterB = null set orderB = null set p = null set r = null set t = null endfunction function InitTrig_Unit_Event takes nothing returns nothing endfunction
DoneThe changes are appreciated. The system works and is nice, despite the known limitations.
All I ask is to remove RegisterPlayerUnitEvent, SpellEffectEvent, Utilities and TimedHandles scripts since they're not used in any shape or form in your reflection system nor by the actual requirements for your system.
Also, as a precaution, you should mention that if one were to use the Defend ability version they would have to add that ability to the units that are able to reflect missiles (although this is already heavily implied).
Summing up, I will assume you will do that, meanwhile I approve.
Approved