Skip to content
Faraj edited this page Sep 17, 2026 · 7 revisions

Description

The Knife is the simplest weapon in the game using quick directional stabs with a small rectangular hitbox.

Implementation

KnifeWeaponComponent extends WeaponComponent but introduces its own specific variables corresponding to the duration of the attack, the size of the hitbox, and the reach of the hitbox. These variables are to differentiate weapon subclasses and give unique properties and gameplay feel to each.

Upgrade

Upgrading the knife does not change the stab. It makes the existing stab hit harder and unlocks a heavy attack on K: a flurry of two quick slashes followed by a finishing stab. The player chooses which to use — J for the fast single poke, K for a committed three-hit combo.

Upgrade state lives in WeaponUpgradeComponent on the player rather than in the knife, and the bonuses are applied when a strike resolves its damage and cooldown. The shared WeaponStatsComponent is never edited, so upgrading the knife cannot buff the Sword or Bow. See Weapon Upgrades for the shared system.

What the upgrade grants:

  • Light attack (J): the same stab, hitbox and reach, dealing ×1.2 damage.
  • Heavy attack (K): a three-hit flurry — a 70° slash right to left, the same slash back left to right 0.15 s later, then a finishing stab 0.15 s after that. Each slash deals ×0.6 damage and the finisher twice a slash.
  • Sprite: every strike, light or heavy, is drawn with a fancier gold-guard blade cut from the same sprite sheet.

Only the finisher knocks back, at 1.5× the weapon's knockback. The slashes deliberately have none, so an enemy stays in reach of all three hits instead of being pushed out after the first. Each strike's hitbox expires before the next one spawns, so an enemy can never be hit twice by one strike.

The flurry is aimed where the player faced when K was pressed, and keeps that aim even if they turn mid-combo, though they can still walk. Unequipping the knife mid-flurry — from the hotbar or the weapon command — cancels any strikes still queued, so they never fire later when the knife comes back.

A heavy attack sets the shared cooldown to ×3, so the flurry cannot be spammed and a stab cannot be chained straight out of one. The cooldown can never be shorter than the combo itself, so an attack-speed buff can never start a second flurry while one is still running.

Without the upgrade the knife behaves exactly as it did in Sprint 1, and K does nothing but play the attack sound.

Unit Tests

KnifeWeaponComponentTest covers the knife in both states.

Unupgraded, it covers the short-lived hitbox that follows the wielder without sweeping, hitbox sizing and transposition for horizontal and vertical attacks, snapping a diagonal facing to the nearest cardinal direction, sprite rotation along the stab, damage scaling from the wielder's base attack, and the stab always expiring before the next one can spawn. Two further tests pin the knife to its Sprint 1 behaviour: K spawns nothing and starts no cooldown while unupgraded, and the base sprite is used.

Upgraded, it covers the boosted stab damage, the flurry's order and geometry (opening slash right to left with no knockback, reverse slash, then the finisher with double damage and the only knockback, and nothing after it), the aim staying locked to where the flurry began, queued strikes spawning in front of the player rather than on top of them, every strike fading with the player while invisible, unequipping mid-combo cancelling the rest, the tripled cooldown, the cooldown floor under attack-speed buffs, and the upgraded sprite being used for the stab and every flurry strike.

SweepComponentTest covers the arc interpolation the slashes are built on, and WeaponUpgradeComponentTest and UpgradeCommandTest cover the shared upgrade system and the QA command. See the Weapons Test Plan for the full table.

How to Test

Run the game, open the debug terminal (F1), type weapon knife and press Enter to equip the knife. Type debug on to see hitbox outlines, then close the terminal (F1). Move with WASD, stab with J and heavy attack with K.

Unupgraded. A small hitbox and knife sprite appear just in front of the player, pointing the way they face, and move with them for the stab's duration. Enemies take damage and die at zero health. Spamming J never stacks two stabs on top of each other. Pressing K plays the attack sound but spawns nothing, since the heavy attack is locked until the knife is upgraded.

Upgraded. Reopen the terminal and type upgrade knife to apply the upgrade immediately — no pickup or shop needed. Stab with J: the same stab, now drawn with the gold-guard blade and killing enemies in fewer hits. Press K next to an enemy: the knife slashes across the front of the player, back the other way, then stabs forward — and only that final stab knocks the enemy back, so all three hits land. Press K and turn immediately: every strike keeps the direction you were facing when you pressed it. Watch the player through the combo: no sprite ever flashes on top of them between strikes. Press K then switch weapons on the hotbar straight away: the remaining strikes never appear, even after switching back.

Reverting. Type upgrade knife off and attack again. The Sprint 1 stab, sprite and damage return, and K goes back to playing only the attack sound — confirming the upgrade is fully reversible and the base knife is untouched.

AI Declaration

This page was written with LLM assistance (Claude Code on Opus 5), generated from the knife implementation and its test suite, and reviewed before publishing.

Table of Contents

Home

Test Plan

Team 2

Features

Components
Player
Items and Inventory
Enemies
Interactable NPCs
Cutscenes and Dialogue
Music
Bosses
Rooms
Weapons
Abilities & Spells
Game Screens and Areas
Dungeons

Game Engine

Getting Started

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally