• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[Trigger] Unit Spawner / Count units for spawn

Status
Not open for further replies.
Level 5
Joined
Feb 5, 2021
Messages
89
Alright, if the title didn't confuse you then let me explain to confusion, cause i have been fiddling with this for several hours now and to no avail :)

For starters (im aware that theres a unit group leak), but what i essentially want to happen is that i have 2 teams where it selects one from each team to have units spawned depending on which buildings they have built and also how many units from that type of building and every unit spawned has to be added to a unit group where i can change the newly spawned minions to have health and damage and stuff like that changed depending on various other circumstances, but right now my biggest issue is with the whole "selecting building X from player Y" and spawning "XY" amount of Z unit and then add it to a unit group (where i can just destroy the unit group after)

Any ideas on how to improve this (this has like 2 different spawners but i feel like both is really useless)

i also tried making some sort of index of all the units i want spawned but that just looks like a mess trying to update every single "amount of unit X for player Y" every time it runs if i end up with 200+ units and buildings.

Thank you for your time and i am sorry for the wall of text / context :)

EDIT: Forgot to add that it will also select all of the units for a player and send them on their way to the enemy, both new and old so its all fine and dandy there (but can probably get optimised).

  • StartSpawn
    • Events
    • Conditions
    • Actions
      • Set VariableSet Attackers[1] = (Random player from Playing[1])
      • Set VariableSet Attackers[2] = (Random player from Playing[2])
      • For each (Integer A) from 1 to 2, do (Actions)
        • Loop - Actions
          • Set VariableSet SelectedTeam = (Integer A)
          • For each (Integer Barracks) from 1 to (Number of living Barracks units owned by Attackers[SelectedTeam]), do (Actions)
            • Loop - Actions
              • Unit - Create 1 Soldier for SelectedNeutral[SelectedTeam] at SelectedSpawn[SelectedTeam] facing Default building facing degrees
              • Unit Group - Add (Last created unit) to AttackUnitStats
          • For each (Integer ShootingRange) from 1 to (Number of living Shooting Range units owned by Attackers[SelectedTeam]), do (Actions)
            • Loop - Actions
              • Unit - Create 1 Rifleman for SelectedNeutral[SelectedTeam] at SelectedSpawn[SelectedTeam] facing Default building facing degrees
              • Unit Group - Add (Last created unit) to AttackUnitStats
          • Unit - Create (Number of living Workshop units owned by Attackers[SelectedTeam]) Mortar Team for SelectedNeutral[SelectedTeam] at SelectedSpawn[SelectedTeam] facing Default building facing degrees
          • Unit - Create (Number of living Factory units owned by Attackers[SelectedTeam]) Tank for SelectedNeutral[SelectedTeam] at SelectedSpawn[SelectedTeam] facing Default building facing degrees
          • Set VariableSet Attaack = (Units owned by SelectedNeutral[SelectedTeam].)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SelectedNeutral[SelectedTeam] Equal to Player 7 (Green)
            • Then - Actions
              • Unit Group - Pick every unit in Attaack and do (Actions)
                • Loop - Actions
                  • Unit - Order (Picked unit) to Attack-Move To SelectedSpawn[2]
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SelectedNeutral[SelectedTeam] Equal to Player 8 (Pink)
                • Then - Actions
                  • Unit Group - Pick every unit in Attaack and do (Actions)
                    • Loop - Actions
                      • Unit - Order (Picked unit) to Attack-Move To SelectedSpawn[1]
                • Else - Actions
          • Custom script: call DestroyGroup(udg_Attaack)
 
Status
Not open for further replies.
Top