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

Trade System

Status
Not open for further replies.
Level 8
Joined
May 21, 2019
Messages
435
There's a bunch of ways that this could be done.
First, you gotta decide what you wanna use as input. A trade building with spells? Chat commands? Dialog buttons?
Lets say that you go with chat command.
Then you'd have to decide the usability flow of a trade. This could be open trading with any players in your team, or a specific offer to a specific team member. The ladder is probably simpler to develop, so lets say you go with that.
So, lets say that player 1 red wants to trade 500 lumber for 1000 gold to his ally, player 2 blue.
The chat command that starts it, could be something like: "/trade 2 500 L 1000 G"
If you break that into space separated substrings, you have player 1 wanting to trade with player 2, his offer (500), of the currency "Lumber"(L) for 1000 of the currency "Gold"(G).
This trade request is then saved using 1 of a variety of methods, such as a hashtable, dynamic arrays, or etc.
Then player 2 has to either accept or decline the trade offer, either by referring to it using a trade ID, or by causing the system itself to only allow 1 active offer at a time.
Then, if player 2 should decide to accept this trade, the trade system should attempt to complete it, checking the required conditions first. This should probably include checking to see if the players actually have the required resources.

That's just 1 example of how this can be done. It's also possible to use a shop building as the interface. This would make the system much simpler to learn for the players, but would likely limit its flexibility, or be clunky to use for specific trade requests.

Another option is an "auction house" type deal, where you deposit X amount of resources to a listing with Y as the unit price. Then people can buy out your listed resources in whatever quantity they might want.
 
Level 8
Joined
May 21, 2019
Messages
435
The use "/" is the worst possible idea for a game command for anything, it is reserved for wc3 standard commands...
You might as well search around because this topic has been asked a lot.
Good point. Will keep it in mind.
I recall that using "-" has some issues too, or at least used to have back in the day, as that's the keyboard shortcut to slowing down the game speed in singleplayer.
I guess starting with a "." would work nicely.
 
Status
Not open for further replies.
Top