scottschiller / ArmorAlley

A browser-based interpretation of Armor Alley, a combat strategy game originally released in 1990 for the Macintosh and MS-DOS PCs.
https://armor-alley.net/
Other
96 stars 26 forks source link

Question: Bullet speed, trajectory, and enemy AI helicopter behaviour? #20

Open supercom32 opened 5 months ago

supercom32 commented 5 months ago

Hi again,

After spending some time playing with the new 25% camera fix, I started to notice that bullets behave kind of strange. When moving forward, machine gun bullets travel out at an impressive speed and distance. However, when moving backwards, bullets travel extremely slowly and only cover a very a short distance. This makes combat flying backwards almost impossible against enemy helicopters as your shots don't really travel any meaningful distance at all. Meanwhile, the enemies machine gun has no issues firing forward to reach you.

I guess this also leads into my second question: Is there a reason why the AI enemy helicopter has a propensity to just kamikaze you, instead of trying to dodge you and have a proper dog fight? In the original game, the AI actively tries to avoid crashing into you and you have to engage in dog fights, or be extremely careful and deliberate in order kamikaze the CPU. This CPU unwillingness to preserve their own life is exacerbated by the fact that often they will choose to hide in clouds (for long periods of time) and just wait for you to approach so they can make a deadly assault which almost always ends with an unavoidable collision.

These behaviors could be designed as intended, or perhaps omissions, or even unintended/WIP. I figured I'd just bring them up as a discussion in case it was not on anyone's radar.

scottschiller commented 5 months ago

I noted a shift in some of the velocities after the 25% buffer change, also. Gunfire, bombs and certain trajectories are relative to the helicopter speed and may need some adjustment. Initially, my version didn't account for the angle of the chopper, nor trajectory as I recall.

While more "accurate", it may be best to have gunfire always travel at a reasonable speed away from the helicopter - as noted when flying backwards and being chased, the enemy has the clear advantage. I need to review, but I think the original game has somewhat less trajectory and also ensures that ammo fired while facing backwards moves away from the chopper at a reasonable speed.

The AI is "rudimentary" at best and there is much left to be desired, I left a number of disclaimers when I first wrote these bits in the code. 😅 The AI doesn't have a mode where it tries to crash into you, but that can happen if you get in its way at certain times.

The "AI" modes, roughly, are:

supercom32 commented 5 months ago

Hi again,

Thanks for the kind reply. Ah, I figured as much for the AI. I think the emerging behavior is probably a result of "target player and get within firing range" and the fact that it inherently implies that the CPU must align itself to you (For machine guns), and then travel at velocity to chase you. This basically makes the CPU like a missile since it will follow you and maintain altitude until it kills you or hits you? 😅 (Usually ends up hitting you). The hiding in the cloud mechanic is interesting (dodging missile locks!), but the CPU sometimes commits to it for a really long time, almost like it's trying to camp you. A workaround I started doing is randomly spraying a cloud with machine gun fire just to check, but it's kind of annoying having to exhaustively check each cloud at distance for this.

As for ordinance fire speed and velocity, It probably would be fair to say they need to be adjusted. When trying to go in for a bombing run, the bombs just fling wildly forward or backwards until your almost stationary and dropping them down vertically. So if you try to go in for a fast strafe and retreat (to avoid missile fire for example), it's extremely hard to predict where they'll land. I don't think the original game had this much sensitivity to angles and such.

Anyway, thanks for your time. I really do appreciate your care and dedication to this otherwise amazing port!

PS: Random thought. Maybe this could be ported to run under Electron so that it could be a stand-alone binary for Linux/Windows/Mac, etc? 🤔 Another random thought, is shrapnel supposed to be as explosive as it appears? 😄 It seems like as soon as a crash or explosion happens, the entire screen is filled with an overly enthusiastic amount shrapnel which makes it really hard to avoid. Looks really cool, but I always seem to end up smoking afterwards since there's so much of it flying all in directions. Maybe the 25% screen change also effects how they fly?

scottschiller commented 5 months ago

Thanks for the feedback. I've had a lot of folks find and enjoy playing this one. There are tons of little details in the original - so any time someone recalls some aspect of gameplay that doesn't feel right, I try to go back and review.

The AI could use improvement. I recall the enemy sort of flies in a sine wave pattern and sometimes jumps vertically to avoid stuff, I have a note to try that at some point. The enemy also can drop paratroopers to guard against smart missiles and/or your gunfire, I have not yet implemented that. I don't recall if the original game did this on easier levels, or later on in harder missions etc.

The "AI" rolls the dice on a timer to choose the next strategy, and it may be that it repeatedly gets "hide in a cloud." I can improve this by at least forcing it to choose a different strategy.

Bomb velocity feels too fast with the 25% change. It was simply calculated based on the helicopter's horizontal velocity, vX * 0.75 - I've tested it at 0.5 and it's looking better.

Shrapnel may be a bit aggressive, I will review. I recall helicopter explosions being very dangerous in the original, similar to how you mention. The chopper would often move up vertically on the last frame when I was bombing from above, and shrapnel would fly upward and outward, fast. Hard to avoid getting hit!

Someone mentioned Electron or an app, then it could be on Steam - that could be another project, perhaps. It's not the same, but you should be able to "install" the game from within Chrome per PWA (web app) standards and then it can have its own icon on your desktop etc.

scottschiller commented 1 month ago

I forgot to reference this in a recent commit, but I've started to revamp the enemy "AI" and the latest is now live for evaluation.

A round-up of the latest changes are also in CHANGELOG.TXT. I have a ton of updates since the last "official" release, all of which is live - I am hoping to wrap everything up and push a formal update with a demo video and walk-through, etc., by end of year.

I've been reading up on using vectors, and steering behaviours for "autonomous agents" which have shaped this work. This is still an early work in progress, but I think it's an improvement on the prior behaviour.

The enemy chopper now flies with a sine wave pattern when wandering. As previously, it will randomly decide to target a tank, cloud, balloon, or you (the human player) at a fixed interval. I'm working on making it smarter about pursuit, and dodging obstacles, gunfire and bombs.

I've got a number of other tactics I may implement: dropping paratroopers to confuse smart missiles (and/or shooting them down), bombing or shooting other vehicles, and so on. The game could become really tough if the enemy chopper starts defending its base more aggressively, so it may be a delicate balance. I'll probably implement the smarter stuff only in extreme mode to begin with.

In the original game, the chopper would sometimes make a beeline for your end bunker and drop paratroopers. If successful, I think you lost all funds and then you didn't earn any more until you recapture it - which can be done via tank if you got one on order before losing funds, or, dropping paratroopers of your own and hoping for the best. Rough stuff. 😅

supercom32 commented 1 month ago

Ah this is great news. I’m hopeful that the AI will be less frustrating this time around. In the previous version, it seemed like the AI was always trying to match your altitude to fire at you. This meant that if you attempted to dodge, the AI would adjust its height to keep attacking, leaving you with limited options. Essentially, you could either collide, shoot back harder (and race for a win), or try to escape by turning around and running—though that often led to losing anyway, since the AI keeps attempting to match your altitude as it chases.