• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[Trigger] Unit movement issue

Status
Not open for further replies.
Level 10
Joined
Sep 29, 2006
Messages
447
Basically, I want to make it so that so long as a hero remains within a certain distance from the "cage" in my map, the cage will be controlled by that team and will move toward the goal. The only problem with my trigger is that the cage will only move as long as ALL heroes of a team are near the cage. I just want to make it so that only ONE hero needs to be near the cage to make it move. Here's my trigger:

  • gain ownership
    • Events
      • Time - CageMoverTimer expires
    • Conditions
      • RedOwnsCage Equal to False
      • GreenOwnsCage Equal to False
    • Actions
      • Unit Group - Pick every unit in RedHeroGroup and do (Actions)
        • Loop - Actions
          • Set TempPoint = (Position of Cage)
          • Set TempPoint2 = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • (Distance between TempPoint and TempPoint2) Less than or equal to CageCapRadius
            • Then - Actions
              • Set RedOwnsCage = True
              • Unit - Change ownership of Cage to Player 1 (Red) and Change color
              • Unit - Order Cage to Move To RedCircleOfPower
            • Else - Actions
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Custom script: call RemoveLocation(udg_TempPoint2)
      • Unit Group - Pick every unit in GreenHeroGroup and do (Actions)
        • Loop - Actions
          • Set TempPoint = (Position of Cage)
          • Set TempPoint2 = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • (Distance between TempPoint and TempPoint2) Less than or equal to CageCapRadius
            • Then - Actions
              • Set GreenOwnsCage = True
              • Unit - Change ownership of Cage to Player 7 (Green) and Change color
              • Unit - Order Cage to Move To GreenCircleOfPower
            • Else - Actions
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Custom script: call RemoveLocation(udg_TempPoint2)

I'm aware that the problem is that I pick every unit in the unit group, but I don't know how to pick each unit individually and then check to see if any of them are the proper distance. I know I would need to use "Or" and "And" statements, but can't seem to figure out the right way to do it.



+rep for the help.
 
You can change the Unit - Unit within Range event. Then check triggering unit's owner and adjust the cage's movement and ownership accordingly.
 
You can change the Unit - Unit within Range event. Then check triggering unit's owner and adjust the cage's movement and ownership accordingly.

I was using that, but then there were some issues where if a hero owning the cage died, and an opposing hero was already in the radius, the cage wouldn't change ownership, but I was able to resolve it. Thank you.
 
Every few milliseconds do:

set SomeGlobalUnitGroup=Group all units in range of (Current location of Cage); Range= Your Range
Custom Script: If FirstOfGroup(udg_SomeGlobalUnitGroup)!=null then
--------- Move Cage ---------
Optional: Custom Script: else
Optional: ------- Dont Move Cage --------
Custom Script: endif
 
Status
Not open for further replies.
Back
Top