Friday, July 26, 2019

Things coming along, zones can be started/shutdown as needed

In 0.7.10 I'm now finishing the feature where zone servers can be automatically started and stopped as needed.  A while back I had implemented automatically starting zone servers when a player travels from one zone to the next, but it was never used because when you first log in the login server and the login client scenes still assumed the needed zone server was online.  So up until now all implemented zones have always been started and kept running.  This has limited further implementation of more zones. 

Currently there are 5 zones implemented, covering the entire British Isles region.  My development test server is an 8 core FX CPU, which can support running around 6 zones at most at the same time.  5 works better though.  So I've been maxed out in what I can test before pushing to the live server.  The live server has 16 opteron cores which each core is better performing, so it can probably support around 16 or more zones, but I don't do initial testing on that server.  The live server cluster will eventually have more servers added as well.  I'm targeting roughly 50 concurrent zones when the game goes public, maybe more. 

But these new changes are the most important step for adding new surrounding zones.  So now, when the master server starts up it automatically starts expected high traffic zones only, which are the national capitals.  Currently that is just London (zone 0).  Then as needed other zones are spun up.  When a zone is idle with no players for 30 minutes, it reports this to the master server.  If the master server is in the normal auto mode, it then tells the zone server to spin down.  Later when a player needs that zone again the master server will spin it back up. 

So after this functionality is all tested, this will allow me to expand the game to further areas.  The plan is to do northern Europe, the Mediterranean, out into the Atlantic, and down the African coast, eventually getting to India.  That will be a pretty large area and cover over half of the nations.  Then tackle east Asia and the American east coast to finish adding all nations.  After that it will just be a process of finishing the entire world map. 

Monday, July 22, 2019

Broadsides now implemented

In 0.7.8 you can now fire a broadside either port or starboard using the buttons on the cannon tab in the bottom left.  When you fire a broadside you do not need to be looking down the sights of the cannons on that side of the ship.  You can even be in 3rd person camera mode when doing so. 

How this works is you have to go to Battle Sails.  After 6 seconds at Battle Sails the broadside activation buttons become available.  When you fire a broadside all cannons are fired parallel to the sea, straight left or straight right from the ship.  If you are aiming the cannons, your aim is ignored.  You cannot manually fire cannons on that side of the ship until the broadside has completed. 

Cannons are fired in highly rapid succession, much faster than manual fire.  If your ship has multiple gun decks on each side, ALL GUN DECKS ARE FIRED AT THE SAME TIME.  The ships with 3 gun decks on each side get the most benefit from this.  Even on the largest ships, all guns are typically fired in around 1.5 seconds.  Ships with fewer guns even faster. 

The biggest negative is since you cannot aim guns up/down, ships with guns mounted high above the water may shoot over small ships.  In that case you should continue firing cannons manually instead of using a broadside.  Firing a broadside is most effective against larger ships.  Large Frigates vs large Frigates, or between Ships of the Line. 

Wednesday, July 17, 2019

Faction Warfare

Now that the nationality system is largely in place, the AI ships' behavior is going to be changed for 0.7.6 to take advantage of this.  Up until now the AI attacks any players, and are all of the Pirate faction.  Starting in 0.7.6 the AI will instead find targets based on relations, including targeting other AI. 

As far as the Pirate faction, you won't notice any change, since Pirates are at war by default with all nations.  What will be interesting is AI will be implemented for other nations, not just pirates.  Most of the AI ships in high populated areas, such as the English Channel, will be replaced with ships relevant to the area, such as Britain and France.  More remote areas will continue to primarily have Pirates.  

Part of the fun will be that Britain and France will often be in conflict, as they were historically.  You'll get to watch these AI fight each other, participate in it yourself, if chased by Pirates you'll see them come to your rescue if you're in range.  Going to make for a much more lively world, where things are happening on their own that you can join in, rather than all the content revolving around the players.  

Thursday, July 11, 2019

Flotillas and Taking Prizes

Flotilla Basics

The plan now is to add a pretty fun feature called Flotillas.  These will be AI ships owned by the player, which follow the player around.  Effectively these allow the player to lead their own mini fleet.  This can be a force multiplier for players who wish to play solo, as well as allow for much larger squadrons of players. 

The entire feature isn't planned out yet, but the idea now is that the number of flotilla ships a player can control will be based on their Command skill level.  Maxing out at around 3 AI ships. 

Taking Prizes

This feature will also be the key for capturing ships.  There has been a plan to add boarding enemy ships, but without a way to take control of the ship the only options from a successful boarding would be to take the cargo and release the ship or scuttle the ship.  I wasn't happy with this, because historically boarded ships were often taken as a prize. 

So the plan now will be that flotilla AI ships will need to be ships the player's character has sufficient skills to operate themselves.  Bonuses from the character's skills will not be applied to flotilla ships (so they will operate like all AI ships as if they have no skills).  A boarded ship taken as a prize will follow the same rules.  Once successfully boarded you will get several options:

  • Take any/all cargo and fittings
  • Release the ship
  • Scuttle the ship
  • Take as a prize

To take a ship as a prize requires the player's character to have skills to operate that ship.  All surviving crew will be pressed into your service.  I'm probably going to include an option to transfer crew at this point to/from the prize ship.  Any fittings which the player's character does not have skills for will be transferred to the ship's cargo.  For example, if you take a prize ship with guns you don't have skills for, they will be removed from the ship's fittings and end up in the cargo hold.  The prize ship then gets added to your flotilla.  You won't be able to take a prize ship if it would exceed your flotilla limit. 

More Flotilla Stuff

Flotillas will not allow the player to directly control the ships, but will allow some general orders, such as to follow you or attack enemies.  Otherwise the ships will generally run themselves like any other AI ship.  They will need to be fed with ammunition, and can be sunk, like any other ship.  When the player joins a squadron with other players, flotilla ships will also join the squadron. 

Flotillas can be used in a variety of ways.  Certain ship types are not recommended to sail solo.  The most obvious examples are Carracks which lack the firepower to defend themselves and often carry a large amount of valuable cargo, and Ships of the Line which are vulnerable to swarms of smaller vessels.  A flotilla makes these ships more practical for solo players. 

You can sail a Carrack full of cargo and have several Frigates or Corvettes in your flotilla as escort.  Or you sail one of the Frigates and let the AI play online trucker simulator with the Carrack.  Similarly you can sail your Ship of the Line with Frigate and Corvette escorts.  When capturing of cities is eventually added, I imagine flotillas full of Gunboats (such as Ironclads) will be popular for their defense. 

One additional benefit of a flotilla is when sailing solo and your ship is sunk, you get placed into a dinghy and must return to a city to grab a real ship.  Instead you will be transferred to another ship in your flotilla if available.  This helps you stay in the fight longer, and allows the possibility of scooping up your own loot. 

Well, I'm pretty excited about this feature, and expect to have it implemented within the next month or two after the nationality system.  I'm hoping this helps Broadside: Perilous Waters stand out against other similar games. 

Wednesday, July 10, 2019

Nationality

So I wanted to implement different colors in the minimap for ships which are friendly, part of your squadron, at war with, etc, but realized I need to fully implement the faction relation system first.  So I've started working on that at this point. 

The way you get assigned a faction, or referred to as "nationality" or "nation" in game, is when you create your character you choose your character's nationality.  Then there is the simple concept of "effective nationality" which is displayed in the Character Info window when viewing a character.  Basically, if you are a member of a trade company, your effective nationality is the trade company's nationality.  Otherwise it is your character's nationality.  So at any point you wish you align your character with another nationality, you just need to join a trade company of that nationality. 

The various nations though will have relations with each other, from friendly to at war.  Players will be able to attack any ship of a nationality they are at war with at any time, while attacking a ship of a friendly nationality will be more restricted (haven't decided on the specifics of this restriction yet, but most likely your cannonballs just will have no effect in some zones, like near major ports, but still debating whether to go Eve Online style and just have a mass of AI attack you or otherwise have some other negative effect). 

These relations will be set by the developers, and used as special events to stir the pot a bit to have a little fun with when they change.  Britain and France will often be at war, but this can periodically change.  Everyone will be at war with the pirates most of the time, but a nation could theoretically be at peace temporarily with the pirates, making even AI pirates no longer attack those players. 

After this system is fully implemented, then I can get back to my original task of the minimap colors :)

Tuesday, July 9, 2019

0.7.3 is out

Another relatively small list of changes for a new build to get it out quickly.  Primarily this was done to reduce the AI ships attacking the new player spawn area near London.  But the major features added are the wind directions now change instead of always coming from the south west, and the squadron chat box has been implemented. 

Thursday, July 4, 2019

Increased update rate

Released 0.7.2 with just a change to increase the server send rate for updating the position of ships and cannon balls.  This smooths out the previous jitters you'd see with ships moving. 

Wednesday, July 3, 2019

0.7.1 now live

Version 0.7.1 is now live, with lots of bug fixes, network improvements to protect against problem network packets, an important ship speed bug fix, small feature improvements, a refactoring to improve script performance, and more challenging AI spawns.  The squadron and private chat features didn't make it in yet, as well as coloring the minimap ship icons, but they will be in a future build. 

There was enough work already in this that I thought it was worth releasing without those additional features ready though. 

Tuesday, July 2, 2019

Cleaning up some technical debt

Well, there's been a growing problem that has finally been resolved with about 8 hours of work.  That problem is the GetComponent call, or more specifically bad early design resulting in the overuse of it.

So somewhere around 1/3 of the code in this game sits on two GameObjects, which are core to the function of the game.  There is the Player GameObject, which handles authentication, represents your character, and contains all of the client to zone server RPC's.  Then there is the Ship GameObject, of which there are various versions of it, representing of course the ships themselves.  Pretty much all of the code related to the ships is attached to these Ship objects (more code than you'd think).

The problem was that the main reference on the client to the Player GameObject was to the GameObject itself.  This created a problem because whenever something like a UI window needed to talk to the Player GameObject it needed to do something like this:

PlayerObject.GetComponent<Player>().DoSomethingCool();

I tried to limit the number of these calls, and cache the reference in other scripts sometimes, but these GetComponet calls were still all over the place.  To make maters worse, even the scripts on the Player object itself when needing to talk to other scripts on the same object would usually use GetComponet as well.  This was all done early on for expediency of development, but since GetComponent is a relatively expensive call compared to using a cached reference, this is a performance problem.

Even worse though was the Player script maintains a reference to the player's Ship GameObject the same way.  Now there are a ton of scripts attached to the ships, and several months ago I created a ShipComponents.cs script which has references to all the other scripts on the ship, and every ship script has a referernce to ShipComponents, so there was no problem there.  But since your ship can sink or be swapped out in a city, I can't just cache a reference to components on the ship.  I have to check all the time if the ship has changed in various scripts and then update cached references.  This gets expensive.

Stuff like this was happening, and sometimes a lot worse:

PlayerObject.GetComponent<Player>().ShipObject.GetComponent<ShipComponents>().ShipMovementComponent.TurnOrSomething();

So long story short, I went and added references in Player.cs to all other Player object components, and the reverse as well.  I then changed the main reference to the Player GameObject maintained to a reference directly to Player.cs.  Then I changed the ShipObject reference that is maintained in Player.cs to a reference to its ShipComponents.cs script.  This cut down around 95% of the GetComponent calls related to these two GameObjects.

This resulted in close to a thousand lines of code rewritten carefully to avoid breaking any existing functionality to fix this issue. 

Yeah!!! :p