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 --------
-------- 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.
Have enabled "Automatically create unknown variables while pasting trigger data" in preferences. (Or just skip this)
Copy and paste the abilites "Buy Lumber" and "Sell Lumber" in the object editor.
Copy and paste the variables (if the above option is disabled) and the triggers from where it says "Copy everything below".
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)
Add or modify the MarketPricesCheck#" (# = player number) according to the amount of players you'll need.
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...
Is this feature not sufficient for spell submissions?
(Genuine question as I regularly post the triggers/code and find it tedious.) View attachment 392869
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.
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.
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.
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
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.