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

Damage Unit Problem

Level 1
Joined
Jan 9, 2024
Messages
2
Hello , sorry my english in not good
I'm using YDWE and I have a problem in my map , I've created an item and every 1 second it shoots a fire ball to a random nearby enemy unit and damage all units passes through.
I want it to damage each unit once and so I created a loop trigger for each player but the problem is it only works for "Player 1" correctly.
When "Player 1" has the item , it will damage each unit once but when other players have the item , it damages each unit multiple times.

  • Blazing Ball
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Loop the integer A from 1 to 5
        • Loop - Actions
          • If-Then-Else
            • If - Conditions
              • ((PlayerHero[Loop Integer A [R]] Health is greater than zero) Equal to True) and (((PlayerHero[Loop Integer A [R]] held by Blazing Ball) is held) Equal to True)
            • Then - Actions
              • If-Then-Else
                • If - Conditions
                  • (Number of units in (All units with a radius of 750.00 and a center of (PlayerHero[Loop Integer A [R]] location) that satisfy ((((Matching unit) Health is greater than zero) Equal to True) and (((Matching unit) is the hostile unit of (PlayerHero[Loop Integer Greater than or equal to 1
                • Then - Actions
                  • Group - Clear all units in BlazingBallGroupDmged[Loop Integer A [R]]
                  • Set BlazingBallUnit[Loop Integer A [R]] = PlayerHero[Loop Integer A [R]]
                  • Set BlazingBallTarget[Loop Integer A [R]] = (A randomly selected unit in (All units with a radius of 750.00 and a center of (PlayerHero[Loop Integer A [R]] location) that satisfy ((((Matching unit) Health is greater than zero) Equal to True) and (((Matching unit) is the hostile unit of (PlayerHero[Loop
                  • Unit - Create 1 Blazing Flame Dummy for (PlayerHero[Loop Integer A [R]] owner) at (PlayerHero[Loop Integer A [R]] location), facing (BlazingBallTarget[Loop Integer A [R]] location)
                  • Set BlazingBallDummy[Loop Integer A [R]] = (Last unit created)
                  • Unit - Set the custom value of (Last unit created) to Loop Integer A [R]
                  • Unit - Delete 0.50 after (Last unit created) seconds
                  • [System] - Command (Last unit created) to jump in the direction of (PlayerHero[Loop Integer A [R]] to BlazingBallTarget[Loop Integer A [R]] angle), the distance is 750.00, the duration is 0.50, the refresh cycle is 0.02, the maximum height is 0.00, which causes damage to passing enemies Value 0.00, add special effect chest to the enemy's Holy Light Void.mdx.
                • Else - Actions
                  • Do nothing
            • Else - Actions
              • Do nothing
  • Blazing Ball Dmg
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Loop the integer A from 1 to 5
        • Loop - Actions
          • If-Then-Else
            • If - Conditions
              • (BlazingBallDummy[Loop Integer A [R]] owner) Equal to (player Loop Integer A [R])
            • Then - Actions
              • Set BlazingBallGroup[Loop Integer A [R]] = (All units with a radius of 120.00 and a center of (BlazingBallDummy[Loop Integer A [R]] location) that satisfy ((((Matching unit) Health is greater than zero) Equal to True) and (((Matching unit) is the hostile unit of (BlazingBallDummy[Loop Integer A [R]] o
              • Group - Select all units in BlazingBallGroup[Loop Integer A [R]] to perform actions
                • Loop - Actions
                  • If-Then-Else
                    • If - Conditions
                      • ((Select unit) in BlazingBallGroupDmged[Loop Integer A [R]]) Equal to True
                    • Then - Actions
                      • Do nothing
                    • Else - Actions
                      • Unit - Command PlayerHero[Loop Integer A [R]] to cause (Select unit) damage to 4500.00, attack type: Normal damage type: Normal
                      • Special Effect - Create and bind special effects to chest to (Select unit), use model: Abilities\Spells\Items\AIfb\AIfbSpecialArt.mdl
                      • Special Effect - Delete 0.50 after (The last special effect created) seconds
                      • Group - Add (Select unit) to BlazingBallGroupDmged[Loop Integer A [R]]
            • Else - Actions
              • Do nothing
 

Attachments

  • Frozen Council Survival.w3x
    339.8 KB · Views: 2

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,871
Hello, I think your problem is because Unit Group arrays need to be initialized. Change the Size to a value like this:
1723756739347.png


Also, I recommend using Player Group variables and Unit Group variables instead of a For Loop when making triggers that work for multiple players. This is because you can control who is in the group, so if a Player left the game, isn't playing, or never picked a hero in the first place you can exclude them from your triggers. Here's an example:
  • Player Setup
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Set Users_Playing = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))
  • Player Picks Hero
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • ((Trained unit) is A Hero) Equal to True
      • ((Owner of (Trained unit)) is in Users_Playing) Equal to True
    • Actions
      • Set PN = (Player number of (Owner of (Trained unit)))
      • Set Users_Hero[PN] = (Trained unit)
      • Unit Group - Add Users_Hero[PN] to Users_Heroes
  • Player Leaves Game
    • Events
      • Player - Player 1 (Red) leaves the game
      • Player - Player 2 (Blue) leaves the game
      • Player - Player 3 (Teal) leaves the game
      • Player - Player 4 (Purple) leaves the game
      • Player - Player 5 (Yellow) leaves the game
    • Conditions
    • Actions
      • Set PN = (Player number of (Triggering player))
      • Player Group - Remove (Triggering player) from Users_Playing
      • Unit Group - Remove Users_Hero[PN] from Users_Heroes
  • Example 1
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in Users_Playing and do (Actions)
        • Loop - Actions
          • Set PN = (Player number of (Picked player))
          • Hero - Add 50 experience to Users_Hero[PN], Show level-up graphics
  • Example 2
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Users_Heroes and do (Actions)
        • Loop - Actions
          • Hero - Add 50 experience to (Picked unit), Show level-up graphics
The two Example triggers will only ever work for ACTIVE players. This means if you're playing singleplayer your triggers will exclude Players 2 -> 5.

1723757427760.png
 
Last edited:
Top