• 🏆 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!

[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