Hey guys,
This system was not done by me so I don't understand alot of things there.
System is used to retreat ( restore HP/Mana/CD of units wich goes X range of their original position) and respawn creeps. Retreat parts works 100% unbuggy and fine but problem is with respawn system. Point is when my hero is in combat and it's time to respawn dead unit, it respawn at position of my hero. Allthough if I am not in combat respawn system works fine. So I can't detect that baddie bugg. Here are triggers. By this way I would like to also request good GUI friendly respawn system, maybe I would be able to separate Retreat and Respawn triggers from themselfs.
This system was not done by me so I don't understand alot of things there.
System is used to retreat ( restore HP/Mana/CD of units wich goes X range of their original position) and respawn creeps. Retreat parts works 100% unbuggy and fine but problem is with respawn system. Point is when my hero is in combat and it's time to respawn dead unit, it respawn at position of my hero. Allthough if I am not in combat respawn system works fine. So I can't detect that baddie bugg. Here are triggers. By this way I would like to also request good GUI friendly respawn system, maybe I would be able to separate Retreat and Respawn triggers from themselfs.
-
Is Unit Moving
-
Events
- Time - Every 0.05 seconds of game time
- Game - UnitIndexEvent becomes Equal to 1.00
- Game - UnitIndexEvent becomes Equal to 2.00
- Conditions
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- UnitIndexEvent Equal to 1.00
-
Then - Actions
- -------- --------
- -------- The next conditions let you filter out unwanted units --------
- -------- --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Default movement speed of UDexUnits[UDex]) Not equal to 0.00
-
Then - Actions
- -------- --------
- -------- Register the indexed unit to the list --------
- -------- --------
- Set UMovPrev[UMovNext[0]] = UDex
- Set UMovNext[UDex] = UMovNext[0]
- Set UMovNext[0] = UDex
- Custom script: set udg_UnitMovingX[udg_UDex] = GetUnitX(udg_UDexUnits[udg_UDex])
- Custom script: set udg_UnitMovingY[udg_UDex] = GetUnitY(udg_UDexUnits[udg_UDex])
-
Else - Actions
- -------- --------
- -------- The unit will not be registered --------
- -------- --------
-
If - Conditions
- Custom script: elseif udg_UnitIndexEvent == 2 then
- Custom script: if udg_UMovPrev[udg_UDex] != 0 or udg_UMovNext[0] == udg_UDex then
- -------- --------
- -------- Unregister the deindexed unit from the list --------
- -------- --------
- Set UnitMoving[UDex] = False
- Set UMovNext[UMovPrev[UDex]] = UMovNext[UDex]
- Set UMovPrev[UMovNext[UDex]] = UMovPrev[UDex]
- Set UMovPrev[UDex] = 0
- Custom script: endif
-
Else - Actions
- Set UDex = UMovNext[0]
- Custom script: loop
- Custom script: exitwhen udg_UDex == 0
- Custom script: set udg_TempX = GetUnitX(udg_UDexUnits[udg_UDex])
- Custom script: set udg_TempY = GetUnitY(udg_UDexUnits[udg_UDex])
- -------- --------
- -------- Check if unit's coordinates have changed --------
- -------- --------
- Custom script: if udg_TempX != udg_UnitMovingX[udg_UDex] or udg_TempY != udg_UnitMovingY[udg_UDex] then
- Set UnitMovingX[UDex] = TempX
- Set UnitMovingY[UDex] = TempY
- Custom script: if not udg_UnitMoving[udg_UDex] then
- -------- --------
- -------- The unit has started moving, fire event for UDex --------
- -------- --------
- Set UnitMoving[UDex] = True
- Set UnitMovingEvent = 1.00
- Set UnitMovingEvent = 0.00
- Custom script: endif
- Custom script: elseif udg_UnitMoving[udg_UDex] then
- -------- --------
- -------- The unit has stopped moving, fire event for UDex --------
- -------- --------
- Set UnitMoving[UDex] = False
- Custom script: if GetUnitTypeId(udg_UDexUnits[udg_UDex]) != 0 then //To prevent firing when the unit decays/gets removed
- Set UnitMovingEvent = 2.00
- Set UnitMovingEvent = 0.00
- Custom script: endif
- Custom script: endif
- Set UDex = UMovNext[UDex]
- Custom script: endloop
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Events
-
GetCreep
-
Events
- Time - Every 0.05 seconds of game time
- Conditions
-
Actions
- Custom script: set bj_wantDestroyGroup = true
-
Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is A structure) Not equal to True) and ((((Matching unit) is alive) Equal to True) and ((Owner of (Matching unit)) Equal to Neutral Hostile)))) and do (Actions)
-
Loop - Actions
- Set key = (Custom value of (Picked unit))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- UnitMoving[key] Equal to True
- ((Picked unit) is in EvadeGroup) Not equal to True
-
Then - Actions
- Unit Group - Add (Picked unit) to EvadeGroup
- Trigger - Turn on EvadeSystem <gen>
- Else - Actions
-
If - Conditions
-
Loop - Actions
-
Events
-
GetInitloc
-
Events
- Time - Elapsed game time is 1.00 seconds
- Conditions
-
Actions
- Set RespawnTime = 185.00
- Set EvadeDist = 550.00
- Set EvadeDelay = 1.00
- Custom script: set bj_wantDestroyGroup = true
-
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
-
Loop - Actions
- Set key = (Custom value of (Picked unit))
- Custom script: set udg_x[udg_key] = GetUnitX(GetEnumUnit())
- Custom script: set udg_y[udg_key] = GetUnitY(GetEnumUnit())
- Set time[key] = RespawnTime
-
Loop - Actions
- Custom script: call DestroyTrigger(GetTriggeringTrigger())
-
Events
-
GetLoc
-
Events
- Unit - A unit enters (Playable map area)
- Conditions
-
Actions
- Set key = (Custom value of (Triggering unit))
- Custom script: set udg_x[udg_key] = GetUnitX(GetTriggerUnit())
- Custom script: set udg_y[udg_key] = GetUnitY(GetTriggerUnit())
- Set time[key] = RespawnTime
-
Events
-
UnitRespawn
-
Events
- Unit - A unit Dies
-
Conditions
- ((Triggering unit) is A Hero) Not equal to True
- (Owner of (Triggering unit)) Equal to Neutral Hostile
-
Actions
- Custom script: local integer i = GetUnitUserData(GetTriggerUnit())
- Custom script: local integer id = GetUnitTypeId(GetTriggerUnit())
- Custom script: local player p = GetOwningPlayer(GetTriggerUnit())
- Set key = (Custom value of (Triggering unit))
- Wait time[key] seconds
- Custom script: set udg_key = i
- Custom script: set bj_lastCreatedUnit = CreateUnit(p, id, udg_x[udg_key], udg_y[udg_key], bj_UNIT_FACING)
- Custom script: set udg_key = GetUnitUserData(bj_lastCreatedUnit)
- Custom script: set udg_x[udg_key] = GetUnitX(bj_lastCreatedUnit)
- Custom script: set udg_y[udg_key] = GetUnitY(bj_lastCreatedUnit)
- Custom script: set p = null
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Owner of (Triggering unit)) Equal to Neutral Hostile
-
Then - Actions
- Unit Group - Remove (Triggering unit) from EvadeGroup
- Else - Actions
-
If - Conditions
-
Events
-
EvadeSystem
-
Events
- Time - Every 0.15 seconds of game time
- Conditions
-
Actions
-
Unit Group - Pick every unit in EvadeGroup and do (Actions)
-
Loop - Actions
- Custom script: local unit u = GetEnumUnit()
- Custom script: local integer key = GetUnitUserData(u)
- Custom script: local real dx = GetUnitX(u) - udg_x[key]
- Custom script: local real dy = GetUnitY(u) - udg_y[key]
- -------- -------------------------------------------------------------------------------- --------
- -------- Check if calculations should be started --------
- -------- -------------------------------------------------------------------------------- --------
- Custom script: if udg_UnitMoving[key] and not udg_OnEvade[key] then
- -------- -------------------------------------------------------------------------------- --------
- -------- If unit pass the conditions, count distance --------
- -------- -------------------------------------------------------------------------------- --------
- Custom script: if SquareRoot(dx * dx + dy * dy) >= udg_EvadeDist then
- Custom script: call IssuePointOrderById(u, 851986, udg_x[key], udg_y[key])
- Custom script: set udg_OnEvade[key] = true
- Custom script: set udg_p = Location(GetUnitX(u), GetUnitY(u))
- -------- -------------------------------------------------------------------------------- --------
- -------- If greater than constant global EvadeDist then start 'evade' event --------
- -------- -------------------------------------------------------------------------------- --------
- Unit - Make (Picked unit) Invulnerable
- -------- -------------------------------------------------------------------------------- --------
- -------- Creating floating text --------
- -------- -------------------------------------------------------------------------------- --------
- Floating Text - Create floating text that reads Evade at p with Z offset 0.00, using font size 9.00, color (100.00%, 100.00%, 0.00%), and 0.00% transparency
- Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 3.40 seconds
- Floating Text - Change the fading age of (Last created floating text) to 2.70 seconds
- Custom script: endif
- -------- -------------------------------------------------------------------------------- --------
- -------- Check if unit in is 'evade' state --------
- -------- -------------------------------------------------------------------------------- --------
- Custom script: elseif udg_OnEvade[key] then
- -------- -------------------------------------------------------------------------------- --------
- -------- Additional action to prefent unit from avoiding 'evade state' --------
- -------- -------------------------------------------------------------------------------- --------
- Custom script: if GetUnitCurrentOrder(u) != 851986 then
- Custom script: call IssuePointOrderById(u, 851986, udg_x[key], udg_y[key])
- Custom script: endif
- -------- -------------------------------------------------------------------------------- --------
- -------- If delay if enought, unit is restored --------
- -------- -------------------------------------------------------------------------------- --------
- Custom script: if udg_OnDelay[key] >= udg_EvadeDelay and not udg_UnitMoving[key] then
- Unit - Make (Picked unit) Vulnerable
- Unit - Reset ability cooldowns for (Picked unit)
- Custom script: call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_MAX_LIFE))
- Custom script: call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MAX_MANA))
- Custom script: set udg_OnEvade[key] = false
- Custom script: set udg_OnDelay[key] = 0
- Custom script: call GroupRemoveUnit(udg_EvadeGroup, u)
- -------- -------------------------------------------------------------------------------- --------
- -------- If not, delay will be increased --------
- -------- -------------------------------------------------------------------------------- --------
- Custom script: elseif not udg_UnitMoving[key] then
- Custom script: set udg_OnDelay[key] = udg_OnDelay[key] + 0.1
- Custom script: endif
- Custom script: endif
- -------- -------------------------------------------------------------------------------- --------
- -------- Check if unit is dead to remove it from group --------
- -------- -------------------------------------------------------------------------------- --------
- Custom script: if GetWidgetLife(u) < 0.405 then
- Custom script: call GroupRemoveUnit(udg_EvadeGroup, u)
- Custom script: endif
- -------- -------------------------------------------------------------------------------- --------
- -------- Check if group is empty, if so stop the function --------
- -------- -------------------------------------------------------------------------------- --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (EvadeGroup is empty) Equal to True
-
Then - Actions
- Trigger - Turn off (This trigger)
- Else - Actions
-
If - Conditions
- -------- -------------------------------------------------------------------------------- --------
- -------- Clearing leaks --------
- -------- -------------------------------------------------------------------------------- --------
- Custom script: call RemoveLocation(udg_p)
- Custom script: set u = null
-
Loop - Actions
-
Unit Group - Pick every unit in EvadeGroup and do (Actions)
-
Events