Thursday, 31 December 2020

That Was The Year That Was: Space Year 2020

 Space year 2020: Expectation Versus Reality ...

I had been having considerable trouble getting my AI aircraft to intersect with the correct aiming point for landing rounds on a moving target. This is once again ... maths ... having to take into account shooter velocity in 3D, target velocity, projectile velocity, projectile inherited velocity from shooter and unth being stuff of a general persuasion. What appeared to happen was that the AI was happy to blaze away and surround the target without particularly trying to hit the bit in the middle ... you know, the actual target area ...

It was only after three attempts and scrounging some code that I noticed my dot product of the forward vector (which is a thing honest) was giving lot's of decimal nines whilst my theoretical aiming reticle had considerably less decimal places. Paying more attention to forVecDot seems to be a better idea, though I still feel the aimpoint is being over inherited with velocity in some manner ...

Cue a test dogfight, the first 2 minutes of which are letting the Ai shoot me down, and the rest are me blasting their wings up to depreciate their turning ability and make them easier to catch. The Ai has no particular tactics right now, just to try and turn on to the target and get up close and try not to overshoot if possible. 

 Machine guns go brrrrrr

In other news I fixed the issue of the AI wandering off due to realizing that positive pitch and yaw dot products required negative maneuvering inputs ...

I've also been thinking about adding Ace Combat 7 style hi-G turns, but as a Stall Turn, hit decelerate when turning and maneuverability increases in exchange for massive air resistance and speed loss. Anyway, that would be something for later.

Over Xmas I did a cheap single malt taste test, and here are the results:

Asda Extra Special Speyside *the only one not aged 12 years so not actually that special really* had a big flavour up front with a fairly high alcohol hit but not much on the back end (ooh err missus). 20 quid.

Tesco 12 Year Old Speyside was very smooth, low alcohol hit but warming all the way down. Kind of an easy drinking "session" whisky if ever there was one, but a thin in body compared to more expensive named malts. 23 quid.

Co-Op 12 Year Old was big on flavours coming from oak bourbon casks and had a fairly strong alcohol hit with a lingering finish. 26 quid.


So, that was the year that was. The Tokyo Olympics never did happen but it was more due to a sniffle than a bang ...

As soon as the UK announced lockdown and everyone must stay indoors my usually peaceful hiking track on a wet Wednesday was full of bastards that would not normally be there, ruining my usually quiet half-marathon oxygen intake.

So, yeah, Merry Christmas and a Happy New Year you Lurgy Poxxed Koofers.

over 9000 hours in MS Paint for extra festivitinesses ...

Monday, 30 November 2020

Damageable Areas And Wonky Maths

 I had been coding an external camera. Move it horizontally and it would extend out and wrap around so you could view all the way from the front. Vertical worked in the same manner except it stopped directly above or below so the whole scene didn't appear upside down. Then I merged the two together and everything kind of broke. In retrospect this probably due to me fixating over the Y value of the movement  of the camera whilst ignoring both the mvoement distance and actual camera rotation. This appears to have led it to wander off when both x and y values exceed 0.5f.

Having previously coded a hitbox solution for individual areas of the airframe, I had tied all of that together with damageable modifiers for how perfromance of the aircraft would deteriorate. Damaged wings reduce maneuverability, damaged engine losses speed and acceleration, etc, etc. I added a HUD element so that the player could visually see the state of the aircraft with a total airframe health bar for overall damage.

Aircraft systems on the lower right, radar to go lower left

There was a minor conundrum with weapons and their placement on the model. I was considering adding extra variables to weaponImage code so that a gun could fire from up to 3 seperate points from an aircraft with their own particle emitters and fx. In the end I simply added a gun to each of the relevant aresa and had them synchronize to fire alternatively.

Guns go brrrrrr ... and in order

I started to figure out AI and which tasks they should be concentrating on in some sort of order of importance. At the top of all of these is not stalling because falling out of the sky due to making a dumb maneuver at low speed would be considered bad and also rather embarrassing. I'm developing a skill system for AI pilots where lower skill will mean being more reactive and higher skills more proactive. This can be used for simple and obvious things like taking an aiming line ahead of a moving target, to how to respond to and evade an attacker, turning from the role of defender to aggressor, such as pulling up, rolling and reducing speed all together to get the opponent to fly past - and so we are back to not stalling.

Speaking of stalling, I have been contemplating adding a high-G turn or stall turn maneauver, where rapidly losing speed when decelerating boosts maneuverability - with the ever present danger of pushing it too far and stalling.

So next up, code some basic AI that can be able to perform a basic Combat Air Patrol, move to a location and circle that area, do some basic dogfighting with an opponent and the such like. Also need to code a radar. I have a few code examples from this, including the 3D style radar from Elite, but think that I will probably stick with a top-down type like Ace Combat 7.

Saturday, 31 October 2020

A Change Is As Good As A Rest

 Happy Halloween, how is perpetual house arrest working out for you?

So we've got a little saying "in them there these here parts": A change is as good as a rest, so here is DIY Ace Combat 1930s style. This whole thing came from an idea I had for a steam/dieselpunk story many, many moons ago for Victoriana sci-fi with cloud cities, battleship dirigibles and '30-40s aircraft. Over the years I have amassed data on the aspects and real world values of various aircraft from 1930-1940s and condensed them into something that might be useable gamewise.

Needing a break from super head-pattable fluffy eared waifus character modeling which I really don't like, I embarked on creating an action based Ace Combat 7 style aeroplane game. First up I checked out all the previous flying vehicle resources which ... were not particularly great, but did give me some pointers on how vehicles are supposed to work ... and the answer to that is that they are entirely physics based. Now considering that some of this stuff dates all the way back to the early 2000s, I expect that was very revolutionary at the time (see Dead Red Redemption 2 for physics based locomotion and a budget of 160 million USD).

So it was time to boot up Visual Studio and hard code it in good old C++. Now there was a time, not very long ago, that I trembled in fear at the thought of doing anything in C++ that didn't involve me copy and pasting some half broken crap off the stackoverflow site.

You tell 'em Aragorn, son of Arathorn

The stock flight model was frankly appalling, so I set about rewriting it from scratch. Gravity turned out to be a weird and thorny problem, as anyone hit by a falling apple can testify to, so I simplified that with a "going down fast, going up slow" methodology and if you were going straight and fast ignore it. Of course that meant that going straight and slow would be a problem so I introduced a vaguely realistic - but always siding on fun to get away from simulation - stalling system.

Gradually over the course of the month I built up a new physics based flight model based upon the concept of fun trumps boring simulation. I was aiming for something in an action style concept that mixed Ace Combat 7 and  Freespace 1/2 (so spaceships with gravity if you will).

Cue, lots of physics as me having to look up the "maths is fun!" (narrator: it isn't) and "improve your GCSE maths!" websites to get a refresher on Cosine ... and it turned out that I mostly wanted Tangents anyway ... Now I vaguely remember all this stuff from the '80s but because of large class sizes I got stuck down in Set 5 and needed a +90% score to pass the final exam - which I did - in your face education system :P

With a working and fun, physics based flight model I proceeded to create the HUD system, with all feedback and warnings. I created a primary and secondary guns system with heat buildup, stoppages due to overheat and cooldown system. The last really awkward thing to do was make a unique area damage system, so if the wings started to get shot up, maneuvering would become harder, engine damage decreased thrust and speed, etc, etc. In the end this didn't end up being as difficult as I thought it would.

Speaking fo the HUD, I came up with system that can change the entire scheme for whatever the player prefers. Even if it's bloody awful.

 I rewrote bullet fall so projectiles only begin to fail to gravity halfway through their lifetime, and then lose momentum quickly. Stock code has them losing height immediately which just seems weird having used high velocity rifles in a former existance.

In deferrence to the previously mentioned Freespace games of the '90s I added an afterburner/jet/turbo boost which I guess back in WW2 was called "War Emergency Power (WEP)" though it acts more like a Freespace turbo jet for a limited time whilst consuming energy and has to be recharged. I have 3 distinct classes of aircraft, their names based on old cavalry types for fighters, interceptors and strike aircraft, and they all handle their WEP differently, as they do with their maneuvering at speed.

There was some ancient code resource from 2004 which nearly worked out of the box 16 years later. From this I coded a few new functions to make life easier, and lo and behold, not only could I get a callback for damagable areas but I could shoot through the main collision box it it wasn't part of the mesh model. Why is this a big thing? Because  the engine uses a singular collision system for speed - eg internet packets, which obviously you want to keep as small possible and nothing really gets smaller than a 6 sided cube because you only have to send the data of 3 lengths (in your face Ramesses! Don't @ me about pyramids also being 3 lengths, you still only get half the area). This meant that all collisions were based on this surrounding boundary box. But with extra hitboxes I can keep the overall simple and fast collision system for things like movement and disassociate it for more complex things like bullets flying through it but not hitting the actual model - which looks weird.

So, next up for dieselpunk aircraft action is to refine the damage modeling and make it actually playable. I did have a quick dogfight with an empty vehicle last night and "zoom and boom" was quite fun - but I really need to sort out a moveable camera system to look around and radar because once they go off screen it took ages to find them again.

Anyhow, ladies and gentlefolks, for your delications, some video, featuring an airplane model I swiped from some modders site for a long defunct flight simulator I have never heard of, so that isn't my work.

So, what's all this for? It's for a secondary project that I can flit between the two without vegetating once one gets overwhelming or just a plain pain in the old arserinho. Cute catgirl swag 'em up will return, it's pretty much fully coded and only needs some user friendly stuff for a limited playable release but it also needs a huge amount of character modeling on top the huge amount of modeling it has already had - so here is my extra project to break up the monotomy, and as I said at the top of the page; a change is as good as a rest, and it's a lot more productive.

That was the month that was. Hope you enjoy lockdown 2 covid bugaloo.