[Solved] Upgrade From Triggers

Status
Not open for further replies.
Level 11
Joined
Dec 16, 2017
Messages
418
Hello guys, how can i turn this into an easier way to involve in more upgrades? What i was thinking to work, doesn't go as i wanted..I wanted to use 20 levels of this [Unit Training] and how can i do it with a loop from like 1 to 20 use the upgrade equal to the loop of 1 20.. or something like that
  • Unit Training
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Unit Training
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UnitTraining Equal to 0
            • Then - Actions
              • Set UnitTraining = 1
              • Player - Set the current research level of Units Training Stats to 1 for Player 11 (Dark Green)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • UnitTraining Equal to 1
                • Then - Actions
                  • Set UnitTraining = 2
                  • Player - Set the current research level of Units Training Stats to 2 for Player 11 (Dark Green)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • UnitTraining Equal to 2
                    • Then - Actions
                      • Set UnitTraining = 3
                      • Player - Set the current research level of Units Training Stats to 3 for Player 11 (Dark Green)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • UnitTraining Equal to 3
                        • Then - Actions
                          • Set UnitTraining = 4
                          • Player - Set the current research level of Units Training Stats to 4 for Player 11 (Dark Green)
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • UnitTraining Equal to 4
                            • Then - Actions
                              • Set UnitTraining = 5
                              • Player - Set the current research level of Units Training Stats to 5 for Player 11 (Dark Green)
                              • Neutral Building - Remove Unit Training from all marketplaces
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • UnitTraining Equal to 5
                                • Then - Actions
                                  • Game - Display to (All players) the text: Unit Training is at...
                                  • Player - Add 5 to (Owner of (Triggering unit)) Current lumber
                                • Else - Actions
                                  • Do nothing
        • Else - Actions
          • Do nothing
 
Level 13
Joined
Feb 5, 2018
Messages
567
  • Unit Training
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Unit Training
    • Actions
      • -------- Player_Number = Integer Variable --------
      • Set VariableSet Player_Number = (Player number of (Owner of (Triggering unit)))
      • -------- Upgrade_Integer = Integer Variable with Array --------
      • Set VariableSet Updrage_Integer[Player_Number] = (Updrage_Integer[Player_Number] + 1)
      • -------- Could store the owner into a player variable, but it's not propably needed --------
      • Player - Set the current research level of Unit Training to Updrage_Integer[Player_Number] for (Owner of (Triggering unit))
Here you go. :) Indexing is good in things like this, better than to loop over multiple if/then/else actions.
 
Level 11
Joined
Dec 16, 2017
Messages
418
Thanks a lot !
As for player number, i need the upgrade to be done just for player 11, no matter who buys from his team, as he is the "defender" player, and his allies can buy upgrades for his units, i will just set player 11 or it's not even needed?
Like this:
  • UnitTraining2
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Units Trainig Stats
    • Actions
      • Set UnitTraining = (UnitTraining + 1)
      • Player - Set the current research level of Units Training Stats to UnitTraining for Player 11 (Dark Green)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UnitTraining Equal to 20
        • Then - Actions
          • Neutral Building - Remove Units Trainig Stats from all marketplaces
        • Else - Actions
I have 20 levels to this Upgrade, how can i make it when it becomes to 20, to be unable to be purchased and item removed, it's ok like this? Even if the item is sold by Player 11 building and not a neutral building?
 
Last edited:
Level 13
Joined
Feb 5, 2018
Messages
567
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Unit_Training Greater than or equal to 20
    • Then - Actions
      • Neutral Building - Remove Unit Training from all marketplaces
    • Else - Actions
Add this to after this
Player - Set the current research level of Units Training Stats to UnitTraining for Player 11 (Dark Green)
 
Level 11
Joined
Dec 16, 2017
Messages
418
It will be deleted from the marketplace even if the shop it is into, is of an allied and not a neutral passive?
Also, for spawning units, i can apply the same structure?If so, how can i add more units? for example lvl 1 i want 2 archers, at lvl 3 upgrade i want 3 archers
  • Night Elven Force
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Night Elven Force
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UnitTraining Equal to 0
        • Then - Actions
          • Unit - Create 1 Huntress (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceMeleeOriginMid <gen>) facing 270.00 degrees
          • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginLeft <gen>) facing 270.00 degrees
          • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginRight <gen>) facing 270.00 degrees
          • Set FriendlyTempGroup = (Units in FriendlyForceOrigin <gen> owned by Player 11 (Dark Green))
          • Unit Group - Pick every unit in FriendlyTempGroup and do (Actions)
            • Loop - Actions
              • Unit - Order (Picked unit) to Attack-Move To (Center of IntroCimArchimondeSpawn <gen>)
          • Custom script: call DestroyGroup (udg_FriendlyTempGroup)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UnitTraining Equal to 1
            • Then - Actions
              • Unit - Create 1 Huntress (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceMeleeOriginLeft <gen>) facing 270.00 degrees
              • Unit - Create 1 Huntress (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceMeleeOriginRight <gen>) facing 270.00 degrees
              • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginLeft <gen>) facing 270.00 degrees
              • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginRight <gen>) facing 270.00 degrees
              • Set FriendlyTempGroup = (Units in FriendlyForceOrigin <gen> owned by Player 11 (Dark Green))
              • Unit Group - Pick every unit in FriendlyTempGroup and do (Actions)
                • Loop - Actions
                  • Unit - Order (Picked unit) to Attack-Move To (Center of IntroCimArchimondeSpawn <gen>)
              • Custom script: call DestroyGroup (udg_FriendlyTempGroup)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • UnitTraining Equal to 2
                • Then - Actions
                  • Unit - Create 1 Huntress (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceMeleeOriginLeft <gen>) facing 270.00 degrees
                  • Unit - Create 1 Huntress (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceMeleeOriginRight <gen>) facing 270.00 degrees
                  • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginLeft <gen>) facing 270.00 degrees
                  • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginMid <gen>) facing 270.00 degrees
                  • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginRight <gen>) facing 270.00 degrees
                  • Set FriendlyTempGroup = (Units in FriendlyForceOrigin <gen> owned by Player 11 (Dark Green))
                  • Unit Group - Pick every unit in FriendlyTempGroup and do (Actions)
                    • Loop - Actions
                      • Unit - Order (Picked unit) to Attack-Move To (Center of IntroCimArchimondeSpawn <gen>)
                  • Custom script: call DestroyGroup (udg_FriendlyTempGroup)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • UnitTraining Equal to 3
                    • Then - Actions
                      • Unit - Create 1 Huntress (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceMeleeOriginLeft <gen>) facing 270.00 degrees
                      • Unit - Create 1 Huntress (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceMeleeOriginRight <gen>) facing 270.00 degrees
                      • Unit - Create 1 Dryad (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceOriginFlankLeft <gen>) facing 270.00 degrees
                      • Unit - Create 1 Dryad (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceOriginFlankRight <gen>) facing 270.00 degrees
                      • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginLeft <gen>) facing 270.00 degrees
                      • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginMid <gen>) facing 270.00 degrees
                      • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginRight <gen>) facing 270.00 degrees
                      • Set FriendlyTempGroup = (Units in FriendlyForceOrigin <gen> owned by Player 11 (Dark Green))
                      • Unit Group - Pick every unit in FriendlyTempGroup and do (Actions)
                        • Loop - Actions
                          • Unit - Order (Picked unit) to Attack-Move To (Center of IntroCimArchimondeSpawn <gen>)
                      • Custom script: call DestroyGroup (udg_FriendlyTempGroup)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • UnitTraining Equal to 4
                        • Then - Actions
                          • Unit - Create 1 Huntress (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceMeleeOriginLeft <gen>) facing 270.00 degrees
                          • Unit - Create 1 Huntress (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceMeleeOriginMid <gen>) facing 270.00 degrees
                          • Unit - Create 1 Huntress (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceMeleeOriginRight <gen>) facing 270.00 degrees
                          • Unit - Create 1 Dryad (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceOriginFlankLeft <gen>) facing 270.00 degrees
                          • Unit - Create 1 Dryad (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceOriginFlankRight <gen>) facing 270.00 degrees
                          • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginLeft <gen>) facing 270.00 degrees
                          • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginMid <gen>) facing 270.00 degrees
                          • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginRight <gen>) facing 270.00 degrees
                          • Set FriendlyTempGroup = (Units in FriendlyForceOrigin <gen> owned by Player 11 (Dark Green))
                          • Unit Group - Pick every unit in FriendlyTempGroup and do (Actions)
                            • Loop - Actions
                              • Unit - Order (Picked unit) to Attack-Move To (Center of IntroCimArchimondeSpawn <gen>)
                          • Custom script: call DestroyGroup (udg_FriendlyTempGroup)
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • UnitTraining Equal to 5
                            • Then - Actions
                              • Unit - Create 1 Huntress (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceMeleeOriginLeft <gen>) facing 270.00 degrees
                              • Unit - Create 1 Mountain Giant (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceMeleeOriginMid <gen>) facing 270.00 degrees
                              • Unit - Create 1 Huntress (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceMeleeOriginRight <gen>) facing 270.00 degrees
                              • Unit - Create 1 Dryad (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceOriginFlankLeft <gen>) facing 270.00 degrees
                              • Unit - Create 1 Dryad (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceOriginFlankRight <gen>) facing 270.00 degrees
                              • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginLeft <gen>) facing 270.00 degrees
                              • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginMid <gen>) facing 270.00 degrees
                              • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginRight <gen>) facing 270.00 degrees
                              • Set FriendlyTempGroup = (Units in FriendlyForceOrigin <gen> owned by Player 11 (Dark Green))
                              • Unit Group - Pick every unit in FriendlyTempGroup and do (Actions)
                                • Loop - Actions
                                  • Unit - Order (Picked unit) to Attack-Move To (Center of IntroCimArchimondeSpawn <gen>)
                              • Custom script: call DestroyGroup (udg_FriendlyTempGroup)
                            • Else - Actions
                              • Do nothing
 
Last edited:
Level 13
Joined
Feb 5, 2018
Messages
567
It will be deleted from the marketplace even if the shop it is into, is of an allied and not a neutral passive?

I am not sure you might need to add the item to the market place on the beginning with triggers in order for it to be removed. This is how it works with custom units at least, if you want to remove them.

Don't use do nothing in ur if/then/else triggers, it just uses up data for nothing.

I personally prefer using if/then/else triggers like this:

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Unit_Training Equal to 1
    • Then - Actions
      • -------- Spawn 3 units --------
    • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Unit_Training Equal to 2
    • Then - Actions
      • -------- Spawn 4 units --------
    • Else - Actions
Unless you really need the else action to filter out unwanted units for example.
 
Level 11
Joined
Dec 16, 2017
Messages
418
Thanks a lot, i will add it with triggers than
And if i want the same units to be spawned, i just do if unit training less than or equal to 20
then spawn 4 units?
  • Items Upgrade
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Neutral Building - Add Units Training Stats to NEHall with 1 in stock and a max stock of 20
  • Night Elven Force
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Night Elven Force
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UnitTraining Less than or equal to 20
        • Then - Actions
          • Unit - Create 1 Huntress (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceMeleeOriginMid <gen>) facing 270.00 degrees
          • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginLeft <gen>) facing 270.00 degrees
          • Unit - Create 1 Archer (Mortal Force) for Player 11 (Dark Green) at (Center of FriendlyForceRangedOriginRight <gen>) facing 270.00 degrees
          • Set FriendlyTempGroup = (Units in FriendlyForceOrigin <gen> owned by Player 11 (Dark Green))
          • Unit Group - Pick every unit in FriendlyTempGroup and do (Actions)
            • Loop - Actions
              • Unit - Order (Picked unit) to Attack-Move To (Center of IntroCimArchimondeSpawn <gen>)
          • Custom script: call DestroyGroup (udg_FriendlyTempGroup)
        • Else - Actions
 
Level 13
Joined
Feb 5, 2018
Messages
567
I meant your if/then/else code for the units were fine, but I would just differ them so they are not all inside of the same loop :D

If you want to use it with just less then or equal to 20 it is also fine.

OR

  • Night Elven Force
    • Events
    • Conditions
    • Actions
      • -------- You could add some sort of formula for units spawned --------
      • Set VariableSet Archer_Integer = (Archer_Integer + (UnitTraining - 1))
      • Unit - Create Archer_Integer Archer for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
 
Level 11
Joined
Dec 16, 2017
Messages
418
Thanks a lot for this !
Yeah, i understand it, if they are in the same loop, it always checks for lvl 1 2 3 etc, until it finds the next part that is used right?
If i just do like you showed me earlier with each if/then/else, it directly goes for the part that is about to be used, it doesn't check for lv 1 2 3, it goes directly for 4, right? Damn, i did a lot of these things in my map triggers without knowing xD
 
Status
Not open for further replies.
Top