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

Shared Upgrade building

Status
Not open for further replies.
Level 5
Joined
Jun 13, 2012
Messages
113
So im trying to work on a trigger that allows me to select an upgrade from an allied or neutral passive structure.

Ive used charged gold and lumber ability and tried to trigger it, but for some reason, the ability doesn't count as an ability

This is my current trigger for the ability

Test
Events
Unit - A unit Begins casting an ability
Conditions
Actions
Unit - Order Blacksmith 0086 <gen> to research Iron Plating (1)

I removed the condition caz i thought that may have been the issue, but its not. The Blacksmith has select units as its ability so that is able to share its abilities with allies. So when i get a unit close by and select the ability it minus gold and lumber but the upgrade trigger didn't go off and no upgrades have been made.

Ive tried this using any other units ability and the research issue order works.

Does the gold and lumber ability count as an ability? if not what event can i use for it, or is there an alternative way to do this kind of trigger?
 
Last edited:
Have you tried to cast the ability yourself before you do it with triggers? You should try casting it first manually, then if the structure successfully casted the ability then you can use triggers to cast the ability.

Maybe the ability is needs mana to cast? Did you add the ability to the structure or you probably missed it?
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
It counts as an ability. The only problem is on your code,
'Begins casting an ability' event plus the ability you're working on is instant, have no cooldown or mana.
That makes the event bug.
Use the generic 'starts the effect of an ability' event for this as it can determine if the ability's effect is executed properly.
Of course, you must refer the ability using 'ability being cast' condition. So that the actions can only run on the specified ability.
 
Level 5
Joined
Jun 13, 2012
Messages
113
It counts as an ability. The only problem is on your code,
'Begins casting an ability' event plus the ability you're working on is instant, have no cooldown or mana.
That makes the event bug.
Use the generic 'starts the effect of an ability' event for this as it can determine if the ability's effect is executed properly.
Of course, you must refer the ability using 'ability being cast' condition. So that the actions can only run on the specified ability.

OH thank you, its working
 
Level 5
Joined
Jun 13, 2012
Messages
113
OH thank you, its working

I have another question now, so the trigger is working which is awesome. Now the new issue I have is that, how can i make a trigger in which the player who uses the ability will have the dummy unit produce and upgrade?
For example:

Blacksmith is owned by player 2. I click Charge lumber and gold, the dummy blacksmith owned by player 1 red will then upgrade iron forged swords.

I can't seem to think of a way to make this work, as I can't just make 1 structure do an upgrade as other players need to be able too as well.
 
Level 5
Joined
Jun 13, 2012
Messages
113
Instead of spawning dummy units to research just use this

  • Player - Set the current research level of Iron Forged Swords to 1 for Player 1 (Red)

That is helpful, thank you. But now im still stuck with what conditions to use.

upload_2020-2-24_9-48-51.png



This trigger only works for player 1 red, the way i want my trigger to work, is trying to make it work with other players. I cant use owner of casting unit as the owner of the blacksmith is player 2. So is there a way to make a condition that works like:

If a player clicks on Iron plating - Set the current research level of iron plating to 1 for that player
 
Instead of using abilities why not use mercenary dummy units? When the neutral mercenary building builds a mercenary unit the created unit should be removed immediately and then research the thing.

I made a test map, check if this is what you need. Just add more players if you want other players to have their upgrades researched too.

  • Research
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Sold unit)) Equal to Research Iron Plating
        • Then - Actions
          • Unit - Remove (Sold unit) from the game
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Iron Forged Swords for Player 1 (Red)) Less than (Max research level of Iron Forged Swords for Player 1 (Red))
            • Then - Actions
              • Player - Set the current research level of Iron Forged Swords to ((Current research level of Iron Forged Swords for Player 1 (Red)) + 1) for Player 1 (Red)
              • Game - Display to (All players) the text: Research complete!
              • Game - Display to (All players) the text: (Current Level: + (String((Current research level of Iron Forged Swords for Player 1 (Red)))))
            • Else - Actions
              • Game - Display to (All players) the text: Research already at...
        • Else - Actions
wc3scrnshot_022420_231338_01-png.347954
 

Attachments

  • WC3ScrnShot_022420_231338_01.png
    WC3ScrnShot_022420_231338_01.png
    2 MB · Views: 58
  • testmap.w3x
    18 KB · Views: 20
Level 5
Joined
Jun 13, 2012
Messages
113
Instead of using abilities why not use mercenary dummy units? When the neutral mercenary building builds a mercenary unit the created unit should be removed immediately and then research the thing.

I made a test map, check if this is what you need. Just add more players if you want other players to have their upgrades researched too.

  • Research
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Sold unit)) Equal to Research Iron Plating
        • Then - Actions
          • Unit - Remove (Sold unit) from the game
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Iron Forged Swords for Player 1 (Red)) Less than (Max research level of Iron Forged Swords for Player 1 (Red))
            • Then - Actions
              • Player - Set the current research level of Iron Forged Swords to ((Current research level of Iron Forged Swords for Player 1 (Red)) + 1) for Player 1 (Red)
              • Game - Display to (All players) the text: Research complete!
              • Game - Display to (All players) the text: (Current Level: + (String((Current research level of Iron Forged Swords for Player 1 (Red)))))
            • Else - Actions
              • Game - Display to (All players) the text: Research already at...
        • Else - Actions
wc3scrnshot_022420_231338_01-png.347954




Hmm, is there away to increase the amount of stocks the unit has in the merc camp? was thinking about increasing so it would be the same level as the upgrade.

So level 1= 1 stock 2 = 2 stock

Any trig for that?


Also, the only issue i have is not being able to increase the amount it costs for the upgrade. So level 1 5 gold level 2 7 gold etc
 
Last edited:
Here, made some few adjustments, all the stuffs are in the trigger, you don't have to adjust the dummy units' stocks. This should work exactly like what you described.

NOTE! Do not add the level 1 unit to the marketplace in the object manager, the trigger below adds the level 1 unit to the marketplace in map init trigger, see below. The level 1 unit will not be removed if you add the level 1 unit in the object manager instead of adding it with triggers.

  • Research Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- --------
      • -------- Add the first upgrade (dummy unit) to the marketplace --------
      • Neutral Building - Add Research Iron Plating (Level 1) to MERCENARYHOUSETEST (Ashenvale) 0000 <gen> with 1 in stock and a max stock of 1
  • Research Upgrade
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • -------- --------
      • -------- Include all upgrade (dummy units) in the condition --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Sold unit)) Equal to Research Iron Plating (Level 1)
              • (Unit-type of (Sold unit)) Equal to Research Iron Plating (Level 2)
              • (Unit-type of (Sold unit)) Equal to Research Iron Plating (Level 3)
        • Then - Actions
          • -------- --------
          • -------- Upgrade to be researched --------
          • Set TempTech = Iron Forged Swords
          • -------- --------
          • -------- This condition checks if the upgrade still needs to be researched --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of TempTech for Player 1 (Red)) Less than (Max research level of TempTech for Player 1 (Red))
            • Then - Actions
              • -------- --------
              • -------- Research the upgrade --------
              • Set TempInt = ((Current research level of TempTech for Player 1 (Red)) + 1)
              • Player - Set the current research level of TempTech to TempInt for Player 1 (Red)
              • -------- --------
              • -------- Note the player --------
              • Game - Display to (All players) the text: Research complete!
              • Game - Display to (All players) the text: (Current Level: + (String((Current research level of TempTech for Player 1 (Red)))))
              • -------- --------
              • -------- Remove level 1 and add level 2 unit in the marketplace --------
              • -------- Do not adjust the tempint here! --------
              • Set TempInt = ((Current research level of TempTech for Player 1 (Red)) + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Sold unit)) Equal to Research Iron Plating (Level 1)
                • Then - Actions
                  • Neutral Building - Remove (Unit-type of (Sold unit)) from (Selling unit)
                  • Neutral Building - Add Research Iron Plating (Level 2) to (Selling unit) with TempInt in stock and a max stock of TempInt
                • Else - Actions
                  • -------- --------
                  • -------- Remove level 2 and add level 3 unit in the marketplace --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Sold unit)) Equal to Research Iron Plating (Level 2)
                    • Then - Actions
                      • Neutral Building - Remove (Unit-type of (Sold unit)) from (Selling unit)
                      • Neutral Building - Add Research Iron Plating (Level 3) to (Selling unit) with TempInt in stock and a max stock of TempInt
                    • Else - Actions
                      • -------- --------
                      • -------- This is the max, just remove the unit --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Unit-type of (Sold unit)) Equal to Research Iron Plating (Level 3)
                        • Then - Actions
                          • Neutral Building - Remove (Unit-type of (Sold unit)) from (Selling unit)
                        • Else - Actions
            • Else - Actions
              • Game - Display to (All players) the text: Research already at...
          • -------- Remove the dummy unit --------
          • -------- --------
          • Set TempInt = 0
          • Unit - Remove (Sold unit) from the game
        • Else - Actions
WC3ScrnShot_022520_015355_01.png

WC3ScrnShot_022520_015357_02.png

WC3ScrnShot_022520_015359_03.png

WC3ScrnShot_022520_015401_04.png
 

Attachments

  • testmap.w3x
    19.6 KB · Views: 27
Last edited:
Level 5
Joined
Jun 13, 2012
Messages
113
Here, made some few adjustments, all the stuffs are in the trigger, you don't have to adjust the dummy units' stocks. This should work exactly like what you described.

NOTE! Do not add the level 1 unit to the marketplace in the object manager, the trigger below adds the level 1 unit in the market during map init, see below. The level 1 unit will not be removed if you add the level 1 unit in the object manager instead of adding it with triggers.

  • Research Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- --------
      • -------- Add the first upgrade (dummy unit) to the marketplace --------
      • Neutral Building - Add Research Iron Plating (Level 1) to MERCENARYHOUSETEST (Ashenvale) 0000 <gen> with 1 in stock and a max stock of 1
  • Research Upgrade
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • -------- --------
      • -------- Include all upgrade (dummy units) in the condition --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Sold unit)) Equal to Research Iron Plating (Level 1)
              • (Unit-type of (Sold unit)) Equal to Research Iron Plating (Level 2)
              • (Unit-type of (Sold unit)) Equal to Research Iron Plating (Level 3)
        • Then - Actions
          • -------- --------
          • -------- Upgrade to be researched --------
          • Set TempTech = Iron Forged Swords
          • -------- --------
          • -------- This condition checks if the upgrade still needs to be researched --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of TempTech for Player 1 (Red)) Less than (Max research level of TempTech for Player 1 (Red))
            • Then - Actions
              • -------- --------
              • -------- Research the upgrade --------
              • Set TempInt = ((Current research level of TempTech for Player 1 (Red)) + 1)
              • Player - Set the current research level of TempTech to TempInt for Player 1 (Red)
              • -------- --------
              • -------- Note the player --------
              • Game - Display to (All players) the text: Research complete!
              • Game - Display to (All players) the text: (Current Level: + (String((Current research level of TempTech for Player 1 (Red)))))
              • -------- --------
              • -------- Remove level 1 and add level 2 unit in the marketplace --------
              • -------- Do not adjust the tempint here! --------
              • Set TempInt = ((Current research level of TempTech for Player 1 (Red)) + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Sold unit)) Equal to Research Iron Plating (Level 1)
                • Then - Actions
                  • Neutral Building - Remove (Unit-type of (Sold unit)) from (Selling unit)
                  • Neutral Building - Add Research Iron Plating (Level 2) to (Selling unit) with TempInt in stock and a max stock of TempInt
                • Else - Actions
                  • -------- --------
                  • -------- Remove level 2 and add level 3 unit in the marketplace --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Sold unit)) Equal to Research Iron Plating (Level 2)
                    • Then - Actions
                      • Neutral Building - Remove (Unit-type of (Sold unit)) from (Selling unit)
                      • Neutral Building - Add Research Iron Plating (Level 3) to (Selling unit) with TempInt in stock and a max stock of TempInt
                    • Else - Actions
                      • -------- --------
                      • -------- This is the max, just remove the unit --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Unit-type of (Sold unit)) Equal to Research Iron Plating (Level 3)
                        • Then - Actions
                          • Neutral Building - Remove (Unit-type of (Sold unit)) from (Selling unit)
                        • Else - Actions
            • Else - Actions
              • Game - Display to (All players) the text: Research already at...
          • -------- Remove the dummy unit --------
          • -------- --------
          • Set TempInt = 0
          • Unit - Remove (Sold unit) from the game
        • Else - Actions

Thanks for the trigger, it works as i intended it to. 1 issue not with the trigger but the max level on my upgrade is lv 100, does that mean i have to create 100 versions of that dummy unit
 
Last edited:
Status
Not open for further replies.
Top