[21] Belmart, Shops, And Bartering

10/27/2020, 07:10pm

Antorum has shops now! This feature was done a couple months ago, but I was too busy to write a new dev log, so here it is now. I also needed a place to actually put merchants/shopkeepers, so I started building the first town on the island: Belmart.

There are plenty of art assets that need to be finished and work to be done on that front, but I'm pretty happy with the town layout and the small marketplace area. There's a few merchants here for players to purchase primitive gear and weapons, as well as useful items such as cookware and ingredients. The idea is that players can get well enough equipped here to allow safe travel to the more difficult areas.

Any entity can be made into a shop by adding a ShopComponent to them, and making sure they have an InteractableComponent which supports bartering. Here is the entity definition for a fish merchant:

id = 13 [networked] [info] name = "Fishmonger" description = "A fish trader." model_id = 1 [transform] [npc] sayings = ["Fish here! Getcha fish here!", "Fine fish!", "Get your fresh catch 'ere!", "Selling fish over 'ere!"] should_wander = false [interactable] interactions = ["barter", "walk-to", "examine"] [movement] [shop] items = ["groofish", "blue-skipper"] buys_items = true sells_items = true

You can't barter with other players yet, but I'll add that eventually. It's just not a very fun feature to work on when I'm the only person wandering around.

The bartering system was a complex bit of work. I don't know why I decided to make such a complicated interface for it, but I guess I was feeling inspired by Fallout and other RPGs with similar interfaces. Five new packets were added to support all this, and existing entity sync packets were updated to support the new component.

Server - 0x2B - Barter Open inv_values_len: ulong (8 bytes) inv_values: list (? bytes) bag_slot: u8 (1 byte) item_value: i32 (4 bytes) shop_items_len: ulong (8 bytes) shop_items: list (? bytes) resource_id: i64 (8 bytes) quantity: u16 (2 bytes) value: i32 (4 bytes) shop_name: string (? bytes) Client - 0x2C - Barter Close Request status: u8 (1 byte) Server - 0x2D - Barter Close status: u8 (1 byte) Client - 0x2E - Barter Move Item Request src_area: u8 (1 byte) src_slot: u8 (1 byte) quantity: u16 (2 bytes) Server - 0x2F - Barter Move Item new_shopper_coin_offer: i32 (4 bytes) new_shop_coin_offer: i32 (4 bytes) src_area: u8 (1 byte) src_slot: u8 (1 byte) dest_slot: u8 (1 byte) quantity: u16 (2 bytes)

I also added some giant crabs to the beach areas. After all, the game is (mostly) written in Rust. Gotta pay respect to Ferris.

- Declan (@dooskington)