• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Complex Retreat and Respawn system bugg

Status
Not open for further replies.
Level 10
Joined
Nov 24, 2010
Messages
546
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.

  • 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 --------
              • -------- --------
          • 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
  • 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
  • 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
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())
  • 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
  • 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
  • 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
          • -------- -------------------------------------------------------------------------------- --------
          • -------- Clearing leaks --------
          • -------- -------------------------------------------------------------------------------- --------
          • Custom script: call RemoveLocation(udg_p)
          • Custom script: set u = null
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Time - Every 0.05 seconds of game time
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)
I advise staying away from this system as much as possible. Iterating through every unit on the map 20 times a second is not a good foundation for a map.
 
Level 10
Joined
Nov 24, 2010
Messages
546
Yes you are right, but half of system works such greatly (retreat) and there is none better here around I think, and I can't make one myslef beacuse lack of knowledge. Maybe if I could find good separate respawn and retreat system... but I browsed spells section and there is anything and also requests are not usually completed, especially such complex.

EDIT:
This systems DO NOT cause any laggs...
 
Level 12
Joined
Mar 28, 2005
Messages
160
it is incredibly difficult to take a GUI system and adapt it for your map - at least for me - too hard to read IMO, especially when its got pseudo JASS sprinkled in

if you say what it is you want, people can help you create it to fir your needs - your OP description doesn't quite cut it

from what you are saying - it sounds like you want a system that will respawn certain units every so often, make them run away when the get weak, and restore hp when they go back to the base??
 
Level 10
Joined
Nov 24, 2010
Messages
546
Nope, each unit on map he it's original place spot. And let's say if that unit dies, it respawn after X seconds on it's original spot. Each unit has specific original spot. This is respawn system.

Evade system is, when unit goes X range from it's original spot it "evades" issuing it going back to it's original spot restoring HP, Mana and cooldowns. ( basically, it means when player try to run away from combat, it's oponent restore everything, oponent = computer creep (neutral hostile))
 
Level 12
Joined
Mar 28, 2005
Messages
160
ok well to respawn units - when they are first spawned, save to them(in one of the many available ways) this loc - so when they can die, you can start a timer that expires after X duration, and respawn the unit at this saved loc

for evasion, this stored spot we just talked about, periodically check each unit in the map, and compare its current spot to this origin spot - if they are too far away, order them back to this original spot - your check keeps running so when this distance is smaller then whatever value you want, restore their HP and such
 
In addition to DSG statement, 0.05 for every unit on the map lags...
My EngageSystem is capable for units to retreat...

The idea behind a respawn system is just like This but be warned that this is NOT compatible with UnitIndexer and other systems that uses custom data of a unit...

Some of my spells have respawn systems in it, check it out...
 
Status
Not open for further replies.
Top