Tuesday, 31 August 2021

Takes Two To Tango With A Brief Debrief

Having mostly been a single player player ... stops, rereads that, nah we're good ... the concept of networking multiple clients wasn't something that I had particularly much experience with. This was most obvious when reviewing my C++ code and seeing that I had literally packed/unpacked everything of my custom aeronautVehicle class regardless of whether it required it or not. On further inspection only rigidBody attitude and whether it should be emitting vapour or not really needed to passed around every frame the engine updated. This could probably explain the jitteriness of Ai and other client aircraft movements.

Debugging ... (don't @ me!)

After quite a bit of faffing around I not only managed to get 4 player Co-Op mode working but had it so that other remote human clients could arrive after the mission had started, and replace the allied AI who had already spawned in their place. The Ai would smoothly disengage, move away and fade out before being deleted, hopefully out of view of other players.

Any later joining client would have to pick the remaining available flights/callsigns that human players were permitted at the briefing screen. Initially I had listed each and every callsign individually, but once I had the whole system up and running, I decided it would be better to simply list available wings and the number of taken and free roles within them. This would cut down on the possibility of scrolling through vast numbers of disabled buttons.

Co-Op Mode! Player 1 and 2 look at each other during a flypast.

The briefing screen also acted as a rather rudimentary lobby. Players could arrive and choose their flight roles, aircraft and paint job, and then wait for the server to fill. Once two or more players had arrived and selected their aircraft and were ready to sortie, a countdown timer would start and automatically trigger the mission so they weren't waiting around for ever. A lone player, waiting on the server on their own could start the mission with Ai wingmen, and future arriving players could drop in and drop out as replacement, as explained above.

One of the things which had proven to be an issue with the networking was briefing. Sending huge amounts of text over a client connection seems like rather a bad thing and I have been desperate not to abuse seven shades out of the commandToClient. This is the reason that I haven't got a large and indepth mission briefing description working yet. I am considering creating it as a seperate GUI file and sending that directly to the player in the same way mission download should work. I do however have a quick description of mission objectives created, pulling them directly out of the mission file.

Lies, Damn Lies And Statistics

 The post mission debriefing screen lists all the statistics that pertain to the player. All allied aircraft are listed as well as their victories, recorded as kills and assists, and their final state which descibes their damage. Added to this is the individual client's performance which ... when I iron out the bugs ... will list the types of kills and assists they scored as well as how accurate they were with their weapons. Right now ... it's a tad buggy ...

More Lies And Bugs Than Statistics ...

Here's a video of the old way I selected playable flights with the multiple buttons at the beginning, and shows how the briefing screen works for aircraft and paint scheme choice.

And so that was the month that was. August, it was wet and cold and not much of an end to summer. The summer fan is dismantled and stored for next year, and the Autumn duvet is already on the bed for maximum comfy.

Saturday, 31 July 2021

Selection Screen: Aircraft and Insignia

 What's a plane game without a pre-mission briefing and selection screen? Lacking that's what. So here it is.

Choose Your Fighter! Literally in this case ...

Here is where you get to choose stuff for the forthcoming mission. The overview screen is where the menu is, as well as a reminder of the mission objectives and the important specifications of the currently chosen aircraft, which boils down to maximum level speed, stall speed, and at what speed the ailerons completely lock-up and you wish you weren't in a 90 degree vertical dive whilst holding down the turbo button.

The aircraft selection screen details all pertinent statistics of the aircraft, displayed as a percentage bar based on the min-max of all other aircraft; 

(range max - range min) * (value - min value) / (max value - min value) + range min = percentage

All except, that is, for Lock Start which is based on percentage of Max Speed, and Lock End which is based on Max Speed * 2.

The Fastest Paint Job Changes In The West

The Insignia screen is where the player can choose their aircraft skin. I was going to call it Paint Job but insignia seemed more fitting. In fact I had a good trawl through the thesaurus for flag, badge and logo before deciding on insignia.

Any skin which can be carried over to other aircraft will be added to newly selected aircraft back in the Aircraft Selection Screen, or default to Dazzle Camo if not.

I am splitting aircraft up into distinct roles (fighter, interceptor, striker/bomber) which have differing effects for lock-up, turbo (WEP; War Emergency Power), stall turns, etc, and am naming these after cavalry units.

So, still to do for the pre-mission screen;

  • Create a Briefing overview where the player can select which aircraft they want to conduct the mission as. Different wings of aircraft will have different roles as mentioned above. Really hate escorting strike aircraft to attack a target? No problem, fly the strike aircraft and have the Ai do the escort mission. This style of play also lends itself rather well to online multiplayer co-op mode.
  • Create a Payload Selection screen that allows aircraft that have external hardpoints to fit bombs and rockets. Also need to create a system for the use of bombs and rockets, as we only have primary and secondary guns coded at the moment.
  • Integrate all of the player choices into the actual mission when it starts.

And here is the whole thing as it currently stands in video. There are three aircraft and about ten skins each.

And that was the month that was. It started with me in shorts getting sunburnt and has ended with me soaked to the skin and wearing a jumper. Classic British summer.

Wednesday, 30 June 2021

Events Dear Boy, Events

 So this month I have been coding a "Mission Events System" loosely based on how Descent: Freespace did it.

Chief amongst this creating a system that read all of the spawnPoint data which held all the info for various events, and anything inside the mission's own custom event file, then tried to organize all of that into something which wasn't gibberish.

I can give you a quick rundown ...

   //this is where the mission relevant data is started
   //all missions related events are controlled from here
   //before we spawn the player we need to load the MissionEventFile (MEF) and all it's functions
   //to do this we need to find out how many players we have
   //treat this number as 1 for single player game and start the mission with the first client joining
   //MissionEventFile holds the missionEventList (arrayObject) and all mission event functions
   //spawnPoints inside the missionEvents folder are for spawning and events
         //1 timed or immediate spawn from player arrival; 1 = spawn immediately
         //object that we should spawn near, if spawnDistance > 0; this overrides our spawnPoint location; defaults to player
         //distance from spawnNear object in kilometers;
      //dataBlock; <<<<< spawnDatablock
         //literally datablock name for player; eg: F11Goshawk, etc. Never AiF11Goshawk though, Ai gets added later
      //dataType; <<<<< spawnClass
         //type of datablock; eg: aeronautVehicle, etc. Never AiAeronautVehicle though, Ai gets added later
         //starting engine setting as F32, default 0.6
         //0 greenFor(neutral); 1 blueFor(ally); 2 redFor(enemy); 3 yellowFor(aggressor);
         //Ai skillLevel 1-10; modified with difficulty
         //name for vehicle or wing of aircraft based on wingNum and isWing number;
         //eg: solitary isWing0 "bob"
         //eg: isWing 2, wingNum 3 "bob3_2"
         //0 = no not a wing only 1 vehicle or was a wing which has already been reduced to 0
         //1+ = is a wing, this number goes down everytime the wing is destroyed
         //wings respawn with wingDelayMin/Max time when reduced to wingMin number of remaining aircraft
         //a new arrayObject is created for the wing and all aircraft are added to this from that wing
         //eg: callsign "bob", arrayObject "bob_wing"
         //number of aircraft in the wing
         //number of the aircraft spawned in a wing, ++ until > wingNum then back to 1; this is set by scripts not editor
         //minimum number in seconds for the wing to wait before spawning another wing and reducing isWing value by 1
         //maximum number in seconds for the wing to wait before spawning another wing and reducing isWing value by 1
         //number of surviving aircraft when a new wing will spawn with wingDelayMin/Max. Default is 0, but best set to 1;
         //mainTask; 0 do waypoints; 1 dogfight anything; 2 strike target; 3 escort;
         //object for mainTask, can be vehicle, arrayObject list of targets, waypoint or path
         //type of event to happen
            //onArrive - has spawned
            //onDepart - has departed
            //onDamagePercent - damage has gone below threshold
            //onDestroyed - uses callback onDisabled and onDestroyed for second check
            //onWaypoint - has moved to waypoint position
            //onPathComplete - has completed the total path
         //object id; eg: onWaypoint = waypoint id; default blank/0/"" is spawnDatablock's object
         //delay in seconds from the eventTrigger# being completed
         //result of the eventTrigger# occuring
            //script name; function to be activated from missionEventFile (MEF)
         //target of the event to do something, specifically used for spawn;
         //if no target then it should refer to a local wing or aircraft
         //eg: scorpio wing now spawns in 10 seconds due to eventTrigger1 "onWaypoint", eventObject1 "player", eventResult1 "spawn", eventDelay1 10, eventTarget1 scorpio wing
So that's my own comment notes in the file, though some of that has since been changed ... probably.

Part of this is "wings"; groups of aircraft that spawn together and can respawn in "waves" when their number has been depleted to a certain amount.

Contextual Messaging about Events in the top left

And what are events without victory and defeat conditions? Not very interesting that's what.

Events - hurray you didn't bugger it all up!

So with all of this in place it was time to create something which looked like a proper game mission. And here it is!

Here's a quick overview of what happens:

  • Victory Condition: All enemy are destroyed
  • Failure Condition: All allied reinforcements are destroyed
  • Player Spawns Event
  • First enemy wing SCORPIO spawns with a delay in response
  • Enemy wing SCORPIO is destroyed
  • Allied wing of reinforcements spawn in response to SCORPIO onDestroyed
  • Enemy wing LIBRA spawns after delay of reinforcements arriving. Also enemy wing TAURUS spawns with an even longer delay, near reinforcements.
  • After losing 3 out of 4 reinforcements I go and help out the last one before completing the mission.

In this playthrough the reinforcements were not very effective and got pounced on early by the enemy fighters, in other tests they accounted for some kills and assists.

When the mission is over status of all aircarft is printed to the console, detailing kills, assists, damage and the such. Eventually this will be part of a debriefing screen.

So that is the month that was. Roll on July.