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

Automatic Building research/upgrade

Status
Not open for further replies.
Level 5
Joined
Jan 23, 2020
Messages
86
I have a building that I need to upgrade every time a specific unit is killed. I got it to work, but it's not 100%.

Here is the trigger:

Code:
    Events
        Unit - A unit Dies
    Conditions
        (Level of Encounter Classification  for (Triggering unit)) Equal to 1
    Actions
        Set VariableSet PN = (Player number of (Owner of (Killing unit)))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Farm_Level[PN] Less than Farm_Total
            Then - Actions
                --------   --------
                Set VariableSet Farm_Level[PN] = (Farm_Level[PN] + 1)
                --------   --------
                Unit - Order Farm_Unit[PN] to train/upgrade to a Farm_Types[Farm_Level[PN]]
                Game - Display to (All players) the text: ((Name of (Player(PN))) + (  + (  + ((Name of Farm_Unit[PN]) + ( | Farm Level:  + (String(Farm_Level[PN])))))))
            Else - Actions

Here is an example of it not working for player RED:
1619534486925.png

1619534492409.png


As you can see the Farm Level exceeds the Farm_unit level, causing it to essentially get "stuck"
 
Level 4
Joined
Jun 28, 2012
Messages
23
What is your Farm_Total and where do you define it ?
Edit : See the bottom of this BBCODE to learn how to post your trigger like this
  • Events
    • Unit - A unit Dies
    • Conditions
      • (Level of Encounter Classification for (Triggering unit)) Equal to 1
    • Actions
      • Set VariableSet PN = (Player number of (Owner of (Killing unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Farm_Level[PN] Less than Farm_Total
        • Then - Actions
          • -------- --------
          • Set VariableSet Farm_Level[PN] = (Farm_Level[PN] + 1)
          • -------- --------
          • Unit - Order Farm_Unit[PN] to train/upgrade to a Farm_Types[Farm_Level[PN]]
          • Game - Display to (All players) the text: ((Name of (Player(PN))) + ( + ( + ((Name of Farm_Unit[PN]) + ( | Farm Level: + (String(Farm_Level[PN])))))))
        • Else - Actions
 
Level 5
Joined
Jan 23, 2020
Messages
86
Heres where they are defined:

  • Farm Setup
    • Events
    • Conditions
    • Actions
      • -------- Make sure to update this if you add more upgrades!!! --------
      • Set VariableSet Farm_Total = 36
      • -------- --------
      • Set VariableSet Farm_Gold_Rewards[0] = 0
      • Set VariableSet Farm_Gold_Rewards[1] = 1
      • Set VariableSet Farm_Gold_Rewards[2] = 2
      • Set VariableSet Farm_Gold_Rewards[3] = 3
      • Set VariableSet Farm_Gold_Rewards[4] = 4
      • Set VariableSet Farm_Gold_Rewards[5] = 5
      • Set VariableSet Farm_Gold_Rewards[6] = 6
      • Set VariableSet Farm_Gold_Rewards[7] = 7
      • Set VariableSet Farm_Gold_Rewards[8] = 8
      • Set VariableSet Farm_Gold_Rewards[9] = 9
      • Set VariableSet Farm_Gold_Rewards[10] = 10
      • Set VariableSet Farm_Gold_Rewards[11] = 11
      • Set VariableSet Farm_Gold_Rewards[12] = 12
      • Set VariableSet Farm_Gold_Rewards[13] = 13
      • Set VariableSet Farm_Gold_Rewards[14] = 14
      • Set VariableSet Farm_Gold_Rewards[15] = 15
      • Set VariableSet Farm_Gold_Rewards[16] = 16
      • Set VariableSet Farm_Gold_Rewards[17] = 17
      • Set VariableSet Farm_Gold_Rewards[18] = 18
      • Set VariableSet Farm_Gold_Rewards[19] = 19
      • Set VariableSet Farm_Gold_Rewards[20] = 20
      • Set VariableSet Farm_Gold_Rewards[21] = 21
      • Set VariableSet Farm_Gold_Rewards[22] = 22
      • Set VariableSet Farm_Gold_Rewards[23] = 23
      • Set VariableSet Farm_Gold_Rewards[24] = 24
      • Set VariableSet Farm_Gold_Rewards[25] = 25
      • Set VariableSet Farm_Gold_Rewards[26] = 26
      • Set VariableSet Farm_Gold_Rewards[27] = 27
      • Set VariableSet Farm_Gold_Rewards[28] = 28
      • Set VariableSet Farm_Gold_Rewards[29] = 29
      • Set VariableSet Farm_Gold_Rewards[30] = 30
      • Set VariableSet Farm_Gold_Rewards[31] = 31
      • Set VariableSet Farm_Gold_Rewards[32] = 32
      • Set VariableSet Farm_Gold_Rewards[33] = 33
      • Set VariableSet Farm_Gold_Rewards[34] = 34
      • Set VariableSet Farm_Gold_Rewards[35] = 35
      • Set VariableSet Farm_Gold_Rewards[36] = 36
      • -------- --------
      • Set VariableSet Farm_Soul_Rewards[0] = 0
      • Set VariableSet Farm_Soul_Rewards[1] = 1
      • Set VariableSet Farm_Soul_Rewards[2] = 2
      • Set VariableSet Farm_Soul_Rewards[3] = 4
      • Set VariableSet Farm_Soul_Rewards[4] = 6
      • Set VariableSet Farm_Soul_Rewards[5] = 8
      • Set VariableSet Farm_Soul_Rewards[6] = 10
      • Set VariableSet Farm_Soul_Rewards[7] = 12
      • Set VariableSet Farm_Soul_Rewards[8] = 14
      • Set VariableSet Farm_Soul_Rewards[9] = 16
      • Set VariableSet Farm_Soul_Rewards[10] = 18
      • Set VariableSet Farm_Soul_Rewards[11] = 20
      • Set VariableSet Farm_Soul_Rewards[12] = 22
      • Set VariableSet Farm_Soul_Rewards[13] = 24
      • Set VariableSet Farm_Soul_Rewards[14] = 26
      • Set VariableSet Farm_Soul_Rewards[15] = 28
      • Set VariableSet Farm_Soul_Rewards[16] = 30
      • Set VariableSet Farm_Soul_Rewards[17] = 32
      • Set VariableSet Farm_Soul_Rewards[18] = 34
      • Set VariableSet Farm_Soul_Rewards[19] = 36
      • Set VariableSet Farm_Soul_Rewards[20] = 38
      • Set VariableSet Farm_Soul_Rewards[21] = 40
      • Set VariableSet Farm_Soul_Rewards[22] = 42
      • Set VariableSet Farm_Soul_Rewards[23] = 44
      • Set VariableSet Farm_Soul_Rewards[24] = 46
      • Set VariableSet Farm_Soul_Rewards[25] = 48
      • Set VariableSet Farm_Soul_Rewards[26] = 50
      • Set VariableSet Farm_Soul_Rewards[27] = 52
      • Set VariableSet Farm_Soul_Rewards[28] = 54
      • Set VariableSet Farm_Soul_Rewards[29] = 56
      • Set VariableSet Farm_Soul_Rewards[30] = 58
      • Set VariableSet Farm_Soul_Rewards[31] = 62
      • Set VariableSet Farm_Soul_Rewards[32] = 64
      • Set VariableSet Farm_Soul_Rewards[33] = 66
      • Set VariableSet Farm_Soul_Rewards[34] = 68
      • Set VariableSet Farm_Soul_Rewards[35] = 70
      • Set VariableSet Farm_Soul_Rewards[36] = 75
      • -------- --------
      • Set VariableSet Farm_Types[0] = Trade Market
      • Set VariableSet Farm_Types[1] = Trade Market - Level 1
      • Set VariableSet Farm_Types[2] = Trade Market - Level 2
      • Set VariableSet Farm_Types[3] = Trade Market - Level 3
      • Set VariableSet Farm_Types[4] = Trade Market - Level 4
      • Set VariableSet Farm_Types[5] = Trade Market - Level 5
      • Set VariableSet Farm_Types[6] = Trade Market - Level 6
      • Set VariableSet Farm_Types[7] = Trade Market - Level 7
      • Set VariableSet Farm_Types[8] = Trade Market - Level 8
      • Set VariableSet Farm_Types[9] = Trade Market - Level 9
      • Set VariableSet Farm_Types[10] = Trade Market - Level 10
      • Set VariableSet Farm_Types[11] = Trade Market - Level 11
      • Set VariableSet Farm_Types[12] = Trade Market - Level 12
      • Set VariableSet Farm_Types[13] = Trade Market - Level 13
      • Set VariableSet Farm_Types[14] = Trade Market - Level 14
      • Set VariableSet Farm_Types[15] = Trade Market - Level 15
      • Set VariableSet Farm_Types[16] = Trade Market - Level 16
      • Set VariableSet Farm_Types[17] = Trade Market - Level 17
      • Set VariableSet Farm_Types[18] = Trade Market - Level 18
      • Set VariableSet Farm_Types[19] = Trade Market - Level 19
      • Set VariableSet Farm_Types[20] = Trade Market - Level 20
      • Set VariableSet Farm_Types[21] = Trade Market - Level 21
      • Set VariableSet Farm_Types[22] = Trade Market - Level 22
      • Set VariableSet Farm_Types[23] = Trade Market - Level 23
      • Set VariableSet Farm_Types[24] = Trade Market - Level 24
      • Set VariableSet Farm_Types[25] = Trade Market - Level 25
      • Set VariableSet Farm_Types[26] = Trade Market - Level 26
      • Set VariableSet Farm_Types[27] = Trade Market - Level 27
      • Set VariableSet Farm_Types[28] = Trade Market - Level 28
      • Set VariableSet Farm_Types[29] = Trade Market - Level 29
      • Set VariableSet Farm_Types[30] = Trade Market - Level 30
      • Set VariableSet Farm_Types[31] = Trade Market - Level 31
      • Set VariableSet Farm_Types[32] = Trade Market - Level 32
      • Set VariableSet Farm_Types[33] = Trade Market - Level 33
      • Set VariableSet Farm_Types[34] = Trade Market - Level 34
      • Set VariableSet Farm_Types[35] = Trade Market - Level 35
      • Set VariableSet Farm_Types[36] = Trade Market - Level 36
      • -------- --------
      • -------- --------
      • Set VariableSet Farm_Interval = 5.00
 
Level 4
Joined
Jun 28, 2012
Messages
23
Mmh might be something like the variables get updated too quick and the farm doesn't have time to upgrade so if it happens one time it's doomed.. Does it happen everytime or ?
Edit : Basically your farm variable goes from 2 to 4 in an instant but it just have time to upgrade to 3 and then it's fucked
 
Level 4
Joined
Jun 28, 2012
Messages
23
Well, might work but it's the hide the problem kind of solution..
You should check when you want to upgrade if the level of the farm is equal to the value of the variable first of all to avoid falling into this trap...
But then you have another problem, you missed an upgrade :
Solution :
Queue upgrade.
 
Level 5
Joined
Jan 23, 2020
Messages
86
I set the upgrade progress of the unit to 100%

  • Unit - Set Farm_Unit[PN] upgrade progress to 100%
Hopefully, that will fix the delay between setting the variable and the unit upgrade.
 
Status
Not open for further replies.
Top