• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Trigger region move

Status
Not open for further replies.
Level 5
Joined
Feb 18, 2016
Messages
96
Hello
I need some help with triggers

I am trying to make a Region moves every .05 seconds to the position of a specific unit.
Also i need that if another unit enters this region kill both

Made those but did not work for me

  • Moving
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set PlayerHeroRegion1 = Region 026 <gen>
      • Region - Center PlayerHeroRegion1 on (Position of PlayerHero)

  • AAAGRUPO DISTANCIA 1
    • Events
      • Unit - A unit enters Region 026 <gen>
    • Conditions
    • Actions
      • Set Die = (Units in PlayerHeroRegion1)
      • Unit Group - Pick every unit in Die and do (Actions)
        • Loop - Actions
          • Unit - Cause (Entering unit) to damage circular area after 0.00 seconds of radius 100.00 at (Position of (Entering unit)), dealing 100000.00 damage of attack type Spells and damage type Magic
          • Unit - Remove (Entering unit) from the game
The region is not moving and if i stand where the region is it only removes entering unit and does not produce damage
 
Last edited:
Level 11
Joined
Dec 19, 2012
Messages
411
Because the event init region while map is loading, so any changes toward the region location after map loading will not affect the region original position.

You may replace it with periodically check if there present unit(s) within the range of playerHero, filter out unwanted unit and do the action
 
Level 39
Joined
Feb 27, 2007
Messages
4,994
To achieve this functionality you will need to have a periodic trigger that checks for units nearby the 'source' unit like so:
  • Moving
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Set TempPoint = (Position of PlayerHero)
      • Set Die = (Units within RADIUS of TempPoint)
      • Custom script: call RemoveLocation(udg_TempPoint) //this fixes the point memory leak, read about it if you don't understand
      • Unit Group - Pick every unit in Die and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked Unit)
          • If (All conditions are true) then do (then actions) else do (else actions)
            • If - Conditions
              • TempUnit not equal to PlayerHero
              • -------- check if they are owned by the right player, are not dead, whatever you need here --------
            • Then - Actions
              • Set TempPoint = Position of TempUnit
              • Unit - Cause TempUnit to damage circular area after 0.00 seconds of radius 100.00 at TempPoint, dealing 100000.00 damage of attack type Spells and damage type Magic
              • Unit - Remove TempUnit from the game
              • Custom script: call RemoveLocation(udg_TempPoint) //same here
            • Else - Actions
      • Custom script: call DestroyGroup(udg_Die) //this fixes the group memory leak
Also be warned that the "unit damage area" actions will damage all units in the radius regardless of whether or not they're owned by an enemy of the damaging unit.
 
Level 8
Joined
Jan 28, 2016
Messages
486
If it's for a specific unit, wouldn't it be easier to create a unit group and use that to loop through units in range every X seconds to determine if and when there is another unit nearby?


Edit: Pyro stole my thunder. :p

While I'm here, would it be better to clear the group instead of destroying it every 0.03 seconds?
 
Level 39
Joined
Feb 27, 2007
Messages
4,994
Edit: Pyro stole my thunder. :p
I got fast fingers bruh :D
While I'm here, would it be better to clear the group instead of destroying it every 0.03 seconds?
It would be better if you were using JASS, but when GUI does something like Set Die = (Units within RADIUS of TempPoint) it always creates a new group and assigns the variable to it. If you clear the group the only way to reuse it would be to add them one-by-one which GUI can't really do.
Why don't you use
  • Trigger - Add to Damage <gen> the event (Unit - A unit comes within 450.00 of PlayerHeroRegion1)
Yeah do that. I always forget that event exists.
 
Level 8
Joined
Jan 28, 2016
Messages
486
It would be better if you were using JASS, but when GUI does something like Set Die = (Units within RADIUS of TempPoint) it always creates a new group and assigns the variable to it. If you clear the group the only way to reuse it would be to add them one-by-one which GUI can't really do.

This is what happens when you create spells with Jass all the time; you forget how GUI works. -___-
 
Status
Not open for further replies.
Top