• 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.

Moving units away with a dynamic value depending on unit size

Status
Not open for further replies.
Level 9
Joined
May 21, 2014
Messages
580
The trigger:

  • Close Horizontal Gate 1st tier
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Close
      • (Unit-type of (Casting unit)) Equal to Gate (horizontal,open)
    • Actions
      • Set ClosingHorizontalGate1stPoint = (Position of (Casting unit))
      • Set ClosingHorizontalGate1stRegion = (Region centered at ClosingHorizontalGate1stPoint with size (ValueHorizontalGateWidth, ValueHorizontalGateHeight))
      • Set ClosingHorizontalGate1stGroup = (Units in ClosingHorizontalGate1stRegion matching ((Matching unit) Not equal to (Casting unit)))
      • Unit Group - Pick every unit in ClosingHorizontalGate1stGroup and do (Actions)
        • Loop - Actions
          • Set ClosingHorizontalGate1stPUPos = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Angle from ClosingHorizontalGate1stPoint to ClosingHorizontalGate1stPUPos) Greater than or equal to 0.00
                  • (Angle from ClosingHorizontalGate1stPoint to ClosingHorizontalGate1stPUPos) Less than 180.00
            • Then - Actions
              • Unit - Move (Picked unit) instantly to (ClosingHorizontalGate1stPUPos offset by 100.00 towards 90.00 degrees)
            • Else - Actions
              • Unit - Move (Picked unit) instantly to (ClosingHorizontalGate1stPUPos offset by 100.00 towards 270.00 degrees)
          • Custom script: call RemoveLocation(udg_ClosingHorizontalGate1stPUPos)
          • Custom script: set udg_ClosingHorizontalGate1stPUPos = null
      • Custom script: call RemoveRect(udg_ClosingHorizontalGate1stRegion)
      • Custom script: set udg_ClosingHorizontalGate1stRegion = null
      • Custom script: call DestroyGroup(udg_ClosingHorizontalGate1stGroup)
      • Custom script: set udg_ClosingHorizontalGate1stGroup = null
      • Custom script: call RemoveLocation(udg_ClosingHorizontalGate1stPoint)
      • Custom script: set udg_ClosingHorizontalGate1stPoint = null
      • Unit - Replace (Casting unit) with a Gate (horizontal,close) using The old unit's relative life and mana
      • Unit Group - Add (Last replaced unit) to PlayerUnits
      • Unit Group - Add (Last replaced unit) to Walls
      • Player Group - Pick every player in PlayerGroupUser and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) is selected by (Picked player)) Equal to True
            • Then - Actions
              • Selection - Add (Last replaced unit) to selection for (Picked player)
            • Else - Actions
I have a trigger which enables Gates to be opened or closed.
Closed gates have a pathing and collision, while open gates do not.

Without the trigger above, the the gates cannot be opened (obviously), AND...
If there is a unit within the opened gate and the gate is commanded to close, and the said unit blocks the pathing of the Closed Gate object, then the gate will move forcefully to another position.

With the tirgger above, I picked units one by one within the pathing of the gate, and Moved them outwards before replacing the gate to a closed one.
The trigger works, but for larger units, the trigger fails.
It seems that the value I specify in the offset value is not enough.

I want the offset value to be variable; I want it to depend on how big the unit is. The bigger the unit, the farther it gets sent away just for the sake the gate wont be moved from its position.

How can I do this? Is there really no way but to use a Hashtable to store EVERY POSSIBLE unit that I have in my map?
 
Level 9
Joined
May 21, 2014
Messages
580
Level 15
Joined
Aug 14, 2007
Messages
936
Use the check function with a greater area check, something close to 250 or 300. It is for memory check, the problem with larger units are the collision size and when the gate itself has a huge collision, it will be further to higher collision targets, you might want to increase. For example, if the Gate has 250 collision push with the large within having 100, the total area check needed is 355 because that 5 matters.
 
Level 9
Joined
May 21, 2014
Messages
580
Use the check function with a greater area check, something close to 250 or 300. It is for memory check, the problem with larger units are the collision size and when the gate itself has a huge collision, it will be further to higher collision targets, you might want to increase. For example, if the Gate has 250 collision push with the large within having 100, the total area check needed is 355 because that 5 matters.

You, sir, are completely right. 5 isn't even enough. it's more than 100! Because the units that are clumped together are still destroying the gate's position.
 
Level 6
Joined
May 20, 2014
Messages
228
If you cba indexing/setting custom values for every unit, could you not just check if units are within some range of the gate and if true, don't close the gate and send a message that the units are too close to the gate?

Easier method but meh.
 
Level 9
Joined
May 21, 2014
Messages
580
If you cba indexing/setting custom values for every unit, could you not just check if units are within some range of the gate and if true, don't close the gate and send a message that the units are too close to the gate?

Easier method but meh.

I already have thought of this and implementing it now.
Because if I did the original method, gate abuse will be done and can be used to ward off enemies.

The problem persists though. Because of varying collisions, the gate fails to stay at the same position (or in the current implementation as stated by alright, the message check fails and moves the gate away).

I still have to place values for each unit depending on collision.

edit: alright fixed. +rep to all.
 
Last edited:
Status
Not open for further replies.
Top