Devlog - Now Whip it! Into Shape!
The latest update to the Beaumont Engine is an incredibly heavy one, having taken the most work out of anything I've done so far. But it's also one of the most impactful additions to the engine: the attack system.
Mid-Attack Stance Transition:
The engine now supports the ability to stand / crouch mid attack - but only during the first few frames of the player's animation. This allows players to change the height of their attack before they're locked in, providing additional precision when attacking or dodging in combat.
Although it's subtle, it allows combat to feel more smooth & dynamic while still preserving the action commitment of classic CV games.

Advanced Melee Hitbox Generation:
The whip now generates a brief hitbox behind the player during the start of their attack. This was absent in the old engine (which only created a hitbox on the final frame).
This is accomplished by manually changing the position & size of a single active hitbox that is present during every frame of the attack animation - and is unique to each melee weapon.
The old engine didn't create a single active hitbox. Instead, it creates a hitbox (predetermined height / length) that only lives for 2 steps when the whip is fully extended. This results in a lot of overlapping hitboxes in order to make sure the hitbox stays active & moves with the player.

Anyway, this manually adjusted hitbox during every frame doesn't make a big difference, but is a neat quirk seen in CV: Bloodlines and can hit enemies that attack from behind. I may still tweak the actual position a bit, but it's very useful to have this tech as a designer.
However, this new attack system is more reliant on frame data. It MAY not properly function if played at low FPS. Hopefully no one will ever play this with a chugging frame rate...
The "melee weapon" frame data is defined in the Create Event, then the "owned" hitbox has its position updated in the Step Event based on that frame data. The idea behind this sytem is that every weapon will generate this hitbox object and enemies will detect damage from this hitbox object rather than the various weapon objects themselves.

Sword Attack:
Remember when I said hitbox generation was unique to each melee weapon? That's because we have a short-ranged sword attack now (doesn't play nice at 12 gamespeed fps).
The sword uses the same button as the whip, but is currently faster and shorter.

Sub-Weapons:
I've also implemented three of the basic sub-weapons: dagger, axe, and boomerang.
In my old engine, sub-weapons were their own hitbox... But now, like the melee weapons, they all create ( o_player_weapon_hitbox ). The hitbox follows the sub-weapon, deals damage, and signals to the weapon that it has been hit and should destroy itself. This is efficient because it means enemies only need to detect the single hitbox object for damage calculation, but may be less efficient because now the sub-weapon requires a signal from the hitbox to know it's hit something. I don't yet know how to feel about this.
Anyway, I've implemented a neat (purely cosmetic) feature from BS:CotM2...
Unlike main-weapons, which spawn on Frame 0 of the attack animation now, sub-weapons still only spawn on the final frame. But sprites will now be drawn during first two frames of the animation - so you can actually see the weapon in Elayne's hand prior to its actual spawning.

Actual Attack State:
The old engine had multiple attack states depending on context, such as: whip stand, whip jump, whip crouch, whip stairs, subweapon crouch, etc. This resulted in a lot of repeat code, and would require even more variants of the attack state if additional contexts were made.
For now, however, I have only ONE attack state. This attack state is responsible for both the whip & sub-weapon, and will change its behavior based on whether the player is jumping or crouched. As a result, its script can be plugged into ANY state and function immediately. For example, simply calling ( scr_player_initiate_attack ) in the Rope State will allow an attack.
For context, I NEVER had the ability to attack on ropes before now. It just works. Re-using the whip logic also means that sub-weapons can be used while crouched now too.

Process:
Attacking is a much more complex system in my new engine, however, requiring multiple steps to function. I have a script for weapon data, containing method variables & structs to define the parameters of each weapon.

Then the player initiates an attack via button input, which runs a script that reads the structs containing the previously defined weapon data. Some extra code runs, like determining if the player can afford the attack cost and whether the weapon spawn limit has been met. Then we can transition into the Attack State.

Once in the Attack State, we do a few more checks & calculations to determine if the player is crouched, jumping, etc. Allow the player to quickly change stances if desired. THEN we finally can create the attack object (whip, sword, boomerang, axe, etc). We can then check if players have grounded (allows player to transition from jump attack to stand attack in the same state) and return to the previously saved state once the animation has finished.

Boy, that was a lot of work! This attack script interacts with so many different states too, from basic navigation to the hurt state. There's a lot of opportunity for jank, so it's taken the better part of a week or two just to create this one system. Even just making sub-weapon swapping in the new engine became harder because of how weapon data is defined now. The whip is also no longer PART of the player sprite, it's a separate object now too. More work!
It's interesting how this system is looking to be a mix of elements across CV1, SCV4, RoB, and Bloodlines. I wasn't expecting to allow crouch sub-weapons, it just happened to be included.
Don't forget to eat & sleep.





