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

Market ability

This bundle is marked as awaiting update. A staff member has requested changes to it before it can be approved.
LordHatchet95 presents:

Market System v1.0

This market system allows the 4 races to buy or sell lumber in exchange of a fluctuating amount of gold from their main Halls.

The more you purchase, the more expensive it becomes.
The more you sell, the less amount of gold you receive per sale.
This system has an upper and lower limit.
This system can be used in both Classic and Reforged modes, since there's no external models or textures involved.
This can also be used in either Melee, Altered Melee or Custom Maps, as long as it works with 2 resources.

Inspiration: Age of Empires 2

Screenshots:




INITIALIZATION:
  • StartupMarket
    • Events
      • Time - Elapsed game time is 0.10 seconds
    • Conditions
    • Actions
      • -------- VARIABLES --------
      • -------- INITIAL COSTS --------
      • -------- Costs will vary on purchase and sale --------
      • Set VariableSet lumber_cost_buy = 125
      • Set VariableSet lumber_cost_sell = 75
      • -------- CONSTANTS --------
      • Set VariableSet lumber_const = 100
      • -------- FLUCTUATIONS (INCREASE/DECREASE) --------
      • -------- NEVER make fluctuations bigger than minimum cost --------
      • Set VariableSet lumber_cost_fluctuation = 2
      • -------- LOWER AND UPPER COST LIMITS --------
      • Set VariableSet lumber_cost_min = 18
      • Set VariableSet lumber_cost_max = 350
      • -------- DESCRIPTIONS IN-GAME --------
      • Quest - Create a Required quest titled Market with the description The market works as..., using icon path ReplaceableTextures\CommandButtons\BTNAmbush.blp
      • Quest - Create a Required quest titled Credits with the description Made by LordHatchet..., using icon path ReplaceableTextures\CommandButtons\BTNSpy.blp
SELLING:
  • MarketSellLumber
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Sell Lumber
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • lumber_cost_sell Less than or equal to ((Owner of (Casting unit)) Current lumber)
        • Then - Actions
          • Player - Set (Owner of (Casting unit)).Current lumber to (((Owner of (Casting unit)) Current lumber) - lumber_const)
          • Player - Add lumber_cost_sell to (Owner of (Casting unit)).Current gold
          • Game - Display to (Player group((Owner of (Casting unit)))) for 4.00 seconds the text: (You sold + ((String(lumber_const)) + ( lumber by + ((String(lumber_cost_sell)) + gold.))))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • lumber_cost_sell Greater than lumber_cost_min
            • Then - Actions
              • Set VariableSet lumber_cost_sell = (lumber_cost_sell - lumber_cost_fluctuation)
              • Set VariableSet lumber_cost_buy = (lumber_cost_buy - lumber_cost_fluctuation)
            • Else - Actions
        • Else - Actions
          • Game - Display to (Player group((Owner of (Casting unit)))) for 4.00 seconds the text: Not enough lumber t...
BUYING:
  • MarketBuyLumber
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Buy Lumber
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • lumber_cost_buy Less than or equal to ((Owner of (Casting unit)) Current gold)
        • Then - Actions
          • Player - Add 100 to (Owner of (Casting unit)).Current lumber
          • Player - Set (Owner of (Casting unit)).Current gold to (((Owner of (Casting unit)) Current gold) - lumber_cost_buy)
          • Game - Display to (Player group((Owner of (Casting unit)))) for 4.00 seconds the text: (You bought + ((String(lumber_const)) + ( lumber by + ((String(lumber_cost_buy)) + gold.))))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • lumber_cost_buy Less than lumber_cost_max
            • Then - Actions
              • Set VariableSet lumber_cost_sell = (lumber_cost_sell + lumber_cost_fluctuation)
              • Set VariableSet lumber_cost_buy = (lumber_cost_buy + lumber_cost_fluctuation)
            • Else - Actions
        • Else - Actions
          • Game - Display to (Player group((Owner of (Casting unit)))) for 4.00 seconds the text: Not enough gold for...
PRICE CHECK:
The following repeats per player... if there's a better way to make it, feel free to tell me.
  • MarketPricesCheck1
    • Events
      • Player - Player 1 (Red) types a chat message containing -market as An exact match
    • Conditions
    • Actions
      • Game - Display to Player Group - Player 1 (Red) for 5.00 seconds the text: ((String(lumber_const)) + ( lumber cost on purchase: + (String(lumber_cost_buy))))
      • Game - Display to Player Group - Player 1 (Red) for 5.00 seconds the text: ((String(lumber_const)) + ( lumber cost on sale: + (String(lumber_cost_sell))))
  • Created the map.
  • Added Buy Lumber and Sell Lumber to each race's main halls.
  • Made prices fluctuate according to purchases and sales.
  • Added upper limits and lower limits to prevent negative values or excessive inflation of prices.
  • Added a command to check prices: -market
  • Made all the values into variable for easier modification.

  1. Have enabled "Automatically create unknown variables while pasting trigger data" in preferences. (Or just skip this)
  2. Copy and paste the abilites "Buy Lumber" and "Sell Lumber" in the object editor.
  3. Copy and paste the variables (if the above option is disabled) and the triggers from where it says "Copy everything below".
  4. ONLY modify the "StartupMarket" trigger if you want to. The other ones should NEVER be modified. (unless modifying them to be adapted to different resources)
  5. Add or modify the MarketPricesCheck#" (# = player number) according to the amount of players you'll need.
  6. Give credits to me, the creator.
Previews
Contents

Market ability (Map)

Reviews
Wrda
I know why you made the comment "NEVER make fluctuations bigger than minimum cost". The solution for that is to use Maths - Min and Max. For MarketSellLumber trigger: Set VariableSet lumber_cost_sell = (lumber_cost_sell - lumber_cost_fluctuation) Set...
Level 19
Joined
Jul 12, 2010
Messages
1,713
PRICE CHECK:
The following repeats per player... if there's a better way to make it, feel free to tell me.
  • MarketPricesCheck1
    • Events
      • Player - Player 1 (Red) types a chat message containing -market as An exact match
      • Player - Player 2 (Blue) types a chat message containing -market as An exact match
      • Player - Player 3 (Teal) types a chat message containing -market as An exact match
      • Player - Player 4 (Purple) types a chat message containing -market as An exact match
    • Conditions
    • Actions
      • Game - Display to (Player group((Triggering player))) for 5.00 seconds the text: ((String(lumber_const)) + ( lumber cost on purchase: + (String(lumber_cost_buy))))
      • Game - Display to (Player group((Triggering player))) for 5.00 seconds the text: ((String(lumber_const)) + ( lumber cost on sale: + (String(lumber_cost_sell))))
OR the Events can be added at map init faster/easier with a loop if you don't want to do it manually for 24 players
  • -------- LOOP ALL PLAYERS --------
  • For each (Integer i) from 1 to 24, do (Actions)
    • Loop - Actions
      • Trigger - Add to MarketPricesCheck1 <gen> the event (Player - (Player(i)) types a chat message containing -market as An exact match)
Other than that seems like a good system to have in a map. :thumbs_up:
 

Wrda

Spell Reviewer
Level 25
Joined
Nov 18, 2012
Messages
1,864
I know why you made the comment "NEVER make fluctuations bigger than minimum cost". The solution for that is to use Maths - Min and Max.
For MarketSellLumber trigger:
  • Set VariableSet lumber_cost_sell = (lumber_cost_sell - lumber_cost_fluctuation)
  • Set VariableSet lumber_cost_buy = (lumber_cost_buy - lumber_cost_fluctuation)
->
  • Set VariableSet lumber_cost_sell = (Max(lumber_cost_min, (lumber_cost_sell - lumber_cost_fluctuation)))
  • Set VariableSet lumber_cost_buy = (Max(lumber_cost_min, (lumber_cost_buy - lumber_cost_fluctuation)))
In MarketBuyLumber trigger, it's the same logic, but you use Min instead.


If lumber_cost_sell reaches the lumber_cost_min value or lumber_cost_buy reaches the lumber_cost_buy value, the player's resources are still depleted and earned. Moving the condition to the first if condition solves this, e.g.:

  • MarketSellLumber
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Sell Lumber
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • lumber_cost_sell Less than or equal to ((Owner of (Casting unit)) Current lumber)
          • lumber_cost_sell Greater than lumber_cost_min
        • Then - Actions
          • Player - Set (Owner of (Casting unit)).Current lumber to (((Owner of (Casting unit)) Current lumber) - lumber_const)
          • Player - Add lumber_cost_sell to (Owner of (Casting unit)).Current gold
          • Game - Display to (Player group((Owner of (Casting unit)))) for 4.00 seconds the text: (You sold + ((String(lumber_const)) + ( lumber by + ((String(lumber_cost_sell)) + gold.))))
          • Set VariableSet lumber_cost_sell = (lumber_cost_sell - lumber_cost_fluctuation)
          • Set VariableSet lumber_cost_buy = (lumber_cost_buy - lumber_cost_fluctuation)
        • Else - Actions
          • Game - Display to (Player group((Owner of (Casting unit)))) for 4.00 seconds the text: Not enough lumber t...
Same thing applies to MarketBuyLumber.
For the "not enough lumber" or "gold" messages, you'll need an additional condition on the else block checking player's specific resource.

Player - Add 100 to (Owner of (Casting unit)).Current lumber is being used on MarketBuyLumber instead of using lumber_const.
Player group (Owner of casting unit) leaks a player group, need to clear the leaks.
Is this command supposed to be for all players in the map? I'd suggest picking all players and adding the chat event to a new trigger (can be either an existing one like MarketPricesCheck1) which will contain the display messages with values for the triggering player. Also making the string command not hardcoded to "-market" would be nice. Note that Player Group - Player 1 (Red) in market prices check doesn't leak at all.

It's a modest system for GUI, which is nice. Needs some fixes still.
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
Using the "new" natives you may be able to adjust the actual Gold/Lumber costs on the Charge Gold/Lumber ability via triggers. You could also potentially adjust the Tooltip of the ability to reflect the current market prices. This would rid the need of the chat command as everything can be handled on the Ability itself.
 
I may have to fix it after the second half of december... kinda ran out of time for some homeworks and an exam due to wasting it like a f:angry:ing idiot ;_;

It's a modest system for GUI, which is nice. Needs some fixes still.
Kinda basic, yes... which makes it very easy to implement, actually. Also with how easy it was to make this small market system, I'm surprised there was none of this kind in the spells section :confused:2
 

Wrda

Spell Reviewer
Level 25
Joined
Nov 18, 2012
Messages
1,864
Also with how easy it was to make this small market system, I'm surprised there was none of this kind in the spells section :confused:2
Usually when something is too simple then it isn't even worth to upload it. Example: a "system" that kills units when they enter x region.
Well, I assure you that it's not your case.
 
Top