eezstreet Posted April 24, 2016 Posted April 24, 2016 The Trading system in Jedi Knight Galaxies is divided into three distinct categories, all of which use the same code/packets sent across the network: Trade between two players, Shop Trade (purchasing items from a vendor), and Container Trade (grabbing items out of a container). The common thread between these three interactions is that they involve sharing an item between two entities. Let's start with Trade between two players. When a character wishes to trade with another player (the exact mechanism hasn't been determined, but it will probably be a console command that can be bound to a key, or pressing USE on someone), it will first send an IPT_TRADEOPEN packet, with optionally the items that they want to trade with the other player. This gets sent to both clients, not just the one who initiated the trade, because the other player may not be in a proper place to trade (they may be trading with someone else, for instance). The client will need to notify the server if they wish to cancel the trade, and the server will send the other client an IPT_TRADECANCEL packet. When either client adds an item to the trade window, they will notify the server. An IPT_TRADE packet is sent to both clients (and not predicted by the player who placed the item in the trade window) because not all items are tradeable. In the trade window there is a text field for credits to transfer. When the client has finished editing this box, they tell the server, and an IPT_TRADECREDITS is sent to the other client. When a player is ready to trade, an IPT_TRADEREADY is sent to the other client, UNLESS both players are ready, in which case an IPT_TRADETRANS is sent to both clients, and the trade is over. Next is Shop Trade. This is fairly straightforward. The server will send an IPT_TRADEOPEN with all of the items that the shop has. The client tells the server when the shop window has closed on their end. If the shop must be forcibly closed for whatever reason (such as the player dying), an IPT_TRADECANCEL is sent to the client. If the shop updates, the client will be notified with an IPT_TRADE packet. When the player buys an item, it is sent with an IPT_TRADESINGLE packet. Last is Container Trade. It's basically the same as Shop Trade in terms of what gets networked, however for all IPT_TRADESINGLE packets, the credit bits are not set. Smoo and Futuza like this
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now