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

How to make upgrades purchasable in shop?

Status
Not open for further replies.
Level 7
Joined
Jul 1, 2008
Messages
1,025
Hi there, I'd like to know how I can make upgrades purchasable from a shop, EG: Player can buy "Improved Weapons" upgrade from a Goblin Merchant and he now has this upgrade for all his units just like how normal upgrades work.

How can I do this?
 
Level 18
Joined
May 11, 2012
Messages
2,103
or you make item named ''Improved Weapons'', add the upgrade to the units you want to have ''Improved Weapons'' and when you buy it, just set the level of the upgrade to what u want for the owner of buying unit or triggering unit = same...
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Here's a test map using unit as a dummy to an "Upgrade".

The test map has 3-level Upgrade that increases the Rifleman range up to 1000 starting from 400, each increment is +200 range.
 

Attachments

  • Dummy Upgrade.w3x
    17 KB · Views: 91
Level 7
Joined
Jul 1, 2008
Messages
1,025
Thanks Defskull but since starting this thread I've worked out a different way of doing it by ordering a dummy unit to research the upgrade for the player. This has the benefit of playing the research complete sound and message without me having to trigger it.

It works except for when the player already has max research level (in this case 5), I want the player to get their gold refunded and a message played to them but for some reason my trigger isnt working?

  • Purple Researches Iron Forged Swords
    • Events
      • Unit - A unit owned by Player 4 (Purple) Acquires an item
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to (==) |cfffae805SOLDIER UPGRADE:|r Improved Weapons
          • (Current research level of Improved Weapons - [|cffffcc00Level 1|r] for TriggeringPlayer) Less than (<) 5
        • Then - Actions
          • Set PurpleUpgradeCentre = Upgrade Centre 0624 <gen>
          • Unit - Order PurpleUpgradeCentre to research Improved Weapons - [|cffffcc00Level 1|r]
        • Else - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Improved Weapons - [|cffffcc00Level 1|r] for TriggeringPlayer) Greater than or equal to (>=) 5
            • Then - Actions
              • Set TriggeringPlayer = (Owner of (Triggering unit))
              • Player - Add 150 to TriggeringPlayer Current gold
              • Player Group - Add TriggeringPlayer to MessagePlayerGroup
              • Game - Display to MessagePlayerGroup the text: Already at max Leve...
              • Player Group - Remove TriggeringPlayer from MessagePlayerGroup
            • Else - Actions
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Because you already put the first condition, try to delete the second branch condition, the;
  • (Current research level of Improved Weapons - [|cffffcc00Level 1|r] for TriggeringPlayer) Greater than or equal to (>=) 5
And try this instead;
  • Purple Researches Iron Forged Swords
    • Events
      • Unit - A unit owned by Player 4 (Purple) Acquires an item
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to (==) |cfffae805SOLDIER UPGRADE:|r Improved Weapons
          • (Current research level of Improved Weapons - [|cffffcc00Level 1|r] for TriggeringPlayer) Equal to 5
        • Then - Actions
          • -------- REFUND HERE --------
        • Else - Actions
          • -------- DO YOUR UPGRADES HERE --------
          • Else - Actions
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
What do you meant by "attempt" ?
When it doesn't hit the Condition, it won't even try to research the upgrade.
And nothing happens if the Player "tries" to research an upgrade that already is on maxed level, so what to worry ?


Ah I get it :)

That is why you should use my method, it works flawlessly for all players.

OR, you can change the Event to A unit Sells an item.

But I'd prefer Sells unit, why ?
Because the unit can still buy the upgrade even though it has full inventory, unlike item, you need to allocate at least 1 empty slot for the item to take space.
Use unit.
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
@defskull: your And condition indicates that if the item picked up isn't the upgrade item or the upgrade level is != 5, the unit will execute the Else block (upgrade in this case). To fix the issue, do it like this:

Event: Picks up item
Condition: item is the upgrade one
Action:
If level of upgrade < max then
+ Upgrade
Else
+ Refund
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
Uhm what do you mean? I may be misunderstanding something here because I am judging purely from your above code block.

edit
Oh I get it that wasn't yours. Right right. I am using a phone so ofc I can't test your map and then I misread the replies. My bad :p

@OP: Yeah just go with defskull's method.
 
Level 7
Joined
Jul 1, 2008
Messages
1,025
Thanks guys, with your guidance I manged to get it working, this code seems to work well and also makes it easy to add new upgrades for this player in this way without having to create loads of integers or triggers. I can just create a trigger for each player:

  • Untitled Trigger 001
    • Events
      • Unit - A unit owned by Player 4 (Purple) Acquires an item
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to (==) |cfffae805SOLDIER UPGRADE:|r Improved Armour
        • Then - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Improved Armour - [|cffffcc00Level 1/5|r] for TriggeringPlayer) Equal to (==) 5
            • Then - Actions
              • Set TriggeringPlayer = (Owner of (Triggering unit))
              • Player - Add 400 to TriggeringPlayer Current gold
              • Player Group - Add TriggeringPlayer to DropItemPlayerGroup
              • Game - Display to DropItemPlayerGroup the text: Already at max Leve...
              • Player Group - Remove TriggeringPlayer from DropItemPlayerGroup
            • Else - Actions
              • Set PurpleUpgradeCentre = Upgrade Centre 0624 <gen>
              • Unit - Order PurpleUpgradeCentre to research Improved Armour - [|cffffcc00Level 1/5|r]
              • Set PurpleStanding = (PurpleStanding + 1)
              • Set TriggeringPlayer = (Owner of (Triggering unit))
              • Player Group - Add TriggeringPlayer to DropItemPlayerGroup
              • Game - Display to DropItemPlayerGroup the text: |cffffcc00 + 1 Stan...
              • Player Group - Remove TriggeringPlayer from DropItemPlayerGroup
        • Else - Actions
 
Status
Not open for further replies.
Top