Twitter  Facebook  YouTube  E-Mail  RSS
The One Man MMO Project
The story of a lone developer's quest to build an online world :: MMO programming, design, and industry commentary
Resource Fields
By Robert Basler on 2016-03-19 12:48:54
Homepage: email:one at onemanmmo dot com

This is a shot of the new resource fields in an experimental biome that probably will likely never otherwise see the light of day but I thought the shot turned out quite pretty.

[Resource Field in "Glassed" experimental biome]

The original design for resource harvesting was a lot simpler than what I ended up with. I wanted a nice looking field of crystals with a crystal formation and steam geyser at the centre, harvesters to go to the field, wander around for a while filling up their tanks, then drive back to the refinery. I wanted two types of resources, one worth twice what the other is. I wanted large resource fields spread out throughout the map that show up on the world map and give people fortunes to fight over. I also wanted smaller player-specific fields that don't show on the map and give players a nearby source of money. I planned to render the fields using the same particle system that does the game's flowers. The resource field itself would be purely decorative needing just the number of resources in the field to be replicated to clients. Under the covers the harvester would simply drive near the field, tell the server it was nearby, the server would validate its position then set up a timer. The harvester would wait until the server gave it the OK to leave, then do more or less the same thing at the refinery. Resource fields could grow or shrink over time and if depleted, pop up in a new location.

Much of this was already implemented when the plan started to fall apart. I found some sugar crystals I grew with my daughter a few years back. The sugar crystals were translucent and sparkled in sunlight. I really liked the look of them and I wanted Miranda's resource fields to sparkle. There was no way to get interesting and correct sparkles with particle billboard crystals so I realized I'd need to 3D model the crystals. I also remembered that one aspect of resource fields that affected gameplay was that while vehicles can drive across them, you can't build a building on them. If resource fields were going to have a physical effect on the map for players, then the full details of the field layout needed to be replicated perfectly to everyone who saw them.

Since every entity in the game needs to have an owner, and there are going to be tens of thousands of resource fields on the map, I needed to have a way to have more than one server operate all those resource fields. I created a tool to divide up the map and modified the simulation server to load some special users to manage all the resource fields. It was funny the first time a resource field showed up on the client because the resource field owner user showed up on the list of visible players. I had to modify the player list specially to ignore those players.

The in-game map now shows large resource fields as little red and blue boxes within map grid squares. Resource fields aren't mapped exactly, players will have to go to the square and find the field.

[Map showing large Resource Fields]

Debugging the resource fields I found some bugs in very old code. When Miranda's server sends updates to players it does quite a bit of work to make the data as small as possible. To save doing that work over and over for everyone interested in each unit every update, the results are saved in a cache which as it turns out had a limit of 96 bytes per component. Resource fields have a worst-case of about 500 bytes (usually they're much smaller) so it didn't take long for one to break that limit. That cache had been working flawlessly for three years, so I had to spend several hours reading over all the replication code to figure out how it all worked again. The big upside is that the cache is now much more memory-efficient, which is always a big win for server code.

Resource Fields ended up taking much more effort than I originally planned but I think the gameplay and rendering improvements were worth all the extra hours modifying the collision system, setting up rendering for procedurally generated crystals, making extensive changes to the map and simulation servers, finding a procedure to lay out the resource fields in a visually interesting way, making nice-looking art for the crystals and other field elements, shrinking the volume of data that makes up each field to a manageable size, and more - there are a lot of reasons it took six weeks.

So next I'll be working on getting the harvester AI working. I have it partly coded already so fingers crossed that goes faster.

By Luke Thorne on 2016-03-19 18:01:35
Homepage: email:lukeypukey36 at gmail dot com
Hey Robert, it is great to hear an update! loving the resources and ideas. I like the sound of a nice sparkly effect on the resource fields. Looking forward to a public test :p. thanks again for the update :).
By Sutekh on 2016-07-27 08:34:14
Homepage: email:
"Under the covers the harvester would simply drive near the field, tell the server it was nearby, the server would validate its position then set up a timer. The harvester would wait until the server gave it the OK to leave, then do more or less the same thing at the refinery. Resource fields could grow or shrink over time and if depleted, pop up in a new location."

Simple timer may be insufficient for harvesting. What about scenarios where my harvester comes under attack and I withdraw it from the field prior to complete fill - does the harvester reset to empty? Or I'm juuuust short of some purchase and want my harvester to grab a tiny bit, then dump in the refinery. Both these scenarios happened in C&C games all the time. I'd think it's important to be able to have partially filled harvesters.

Also avoids a "duplication" bug. Send enough harvesters to the same field. It has enough to fill 1 (or more) harvesters, but not all of them. All pass some sort of resources-available-nearby check and start their timer. All complete their timer and are full. Ex: Field has 200 resources remaining, harvesters can hold 100 each. Send 15 harvesters. Each sees > 100 and starts up. Timers complete. Field drops from 200 to 0 resources, and 15 harvesters hold 100 resources. Your double entry bookkeeping screams at the imbalance.
By Robert Basler on 2016-07-28 09:42:10
Homepage: email:one at onemanmmo dot com
In the final design, partially filled harvesters can happen. While there is still a timer to tell the harvester when to leave, if the field is low on resources the timer is shortened, also the player can tell it to leave and it will leave with a partial load. There's no danger of resource duplication.

New Comment

Cookie Warning

We were unable to retrieve our cookie from your web browser. If pressing F5 once to reload this page does not get rid of this message, please read this to learn more.

You will not be able to post until you resolve this problem.

Comment (You can use HTML, but please double-check web link URLs and HTML tags!)
Your Name
Homepage (optional, don't include http://)
Email (optional, but automatically spam protected so please do)
Plastic or paper? (What's this?)

  Admin Log In

[The Imperial Realm :: Miranda] [Blog] [Gallery] [About]
Terms Of Use & Privacy Policy