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

What is the Issue with my Upgradable Spawn System?

Status
Not open for further replies.
Level 6
Joined
Feb 10, 2011
Messages
188
I have created a system that will spawn units based on a unit type, here is what the system does

1. Spawn a unit at an outpost if owned by a player (based on a variable(array) stored unit-type)
2. Spawned unit can be upgraded to another type of unit
3. Spawned unit can be upgraded to only affect the outpost where it is upgraded.

For the most part my system is working, The units spawn for correct player in accordance to outpost owner. The spawn unit can be upgraded, but the flaw is that once I upgrade one outpost's spawn unit, they are all upgraded.

How can I make it so that when a outpost upgrades the spawn unit, it only affect the upgrading outpost. Here are my triggers.

Note* SpawnUnit(1-5) Have been set to different Unit types in another trigger
Note2* My whole idea was use the customvalue of picked outpost an the index for the currently spawned unit.

  • Create Outpost
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set outpostUnitGroup = (Units of type Outpost)
      • Unit Group - Pick every unit in outpostUnitGroup and do (Actions)
        • Loop - Actions
          • Set tempUnit1 = (Picked unit)
          • Set tempPoint1 = (Position of tempUnit1)
          • Set tempPlayer1 = (Owner of tempUnit1)
          • Trigger - Add to Outpost Dies <gen> the event (Unit - tempUnit1 Dies)
          • Set real1 = (Random real number between -100.00 and 100.00)
          • Unit - Create 4 Barbarian for tempPlayer1 at (tempPoint1 offset by (real1, real1)) facing Default building facing degrees
          • Set spawnUnit[(Custom value of tempUnit1)] = |cffff7d00Light Legionnaire|r
          • Custom script: set udg_tempUnit1 = null
          • Custom script: set udg_tempPlayer1 = null
          • Custom script: call RemoveLocation( udg_tempPoint1 )
      • Custom script: call DestroyTrigger( GetTriggeringTrigger() )
  • Outpost Spawns Create
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in outpostUnitGroup and do (Actions)
        • Loop - Actions
          • Set tempUnit1 = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of tempUnit1) Not equal to Neutral Hostile
            • Then - Actions
              • Set tempPlayer1 = (Owner of tempUnit1)
              • Set tempPoint1 = (Position of tempUnit1)
              • Set tempPoint2 = (Rally-Point of tempUnit1 as a point)
              • Unit - Create 1 spawnUnit[(Custom value of tempUnit1)] for tempPlayer1 at tempPoint1 facing Default building facing degrees
              • Set tempUnit2 = (Last created unit)
              • Unit - Order tempUnit2 to Attack-Move To tempPoint2
              • Custom script: set udg_tempUnit2 = null
              • Custom script: set udg_tempPlayer1 = null
              • Custom script: call RemoveLocation( udg_tempPoint1 )
              • Custom script: call RemoveLocation( udg_tempPoint2 )
            • Else - Actions
          • Custom script: set udg_tempUnit1 = null
  • Outpost Spawns Change
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Outpost
    • Actions
      • Set tempUnit1 = (Triggering unit)
      • Set tempUnit2 = (Trained unit)
      • Unit - Remove tempUnit2 from the game
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of tempUnit2) Equal to |cffff7d00Cohort|r
        • Then - Actions
          • Set spawnUnit[(Custom value of tempUnit1)] = (Unit-type of tempUnit2)
        • Else - Actions
      • Custom script: set udg_tempUnit2 = null
 
Last edited:
Level 6
Joined
Feb 10, 2011
Messages
188
Why not use something like - pick every unit in outpost_group - if outpost = op_upgrade1...then create unit_upgrade1? And, then 2, 3, and so on?

I didnt think of trying this way, but it seems like it would be easy. Although I do have many different choices, what is a more efficient way.
 
Status
Not open for further replies.
Top