Add shareware support and spawn correctly for difficulty levels

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-14 17:01:01 +01:00
parent 690ac1e7e6
commit 278c73a256
19 changed files with 383 additions and 238 deletions

View File

@@ -30,8 +30,24 @@ abstract class Weapon {
this.isAutomatic = true,
});
int get currentSprite =>
state == WeaponState.idle ? idleSprite : fireFrames[frameIndex];
int getCurrentSpriteIndex(int maxSprites) {
int baseSprite = state == WeaponState.idle
? idleSprite
: fireFrames[frameIndex];
// Retail VSWAP typically has exactly 436 sprites (indices 0 to 435).
// The 20 weapon sprites are ALWAYS placed at the very end of the sprite block.
// This dynamically aligns the base index to the end of any VSWAP file!
int dynamicOffset = 436 - maxSprites;
int calculatedIndex = baseSprite - dynamicOffset;
// Safety check!
if (calculatedIndex < 0 || calculatedIndex >= maxSprites) {
print("WARNING: Weapon sprite index $calculatedIndex out of bounds!");
return 0;
}
return calculatedIndex;
}
void releaseTrigger() {
_triggerReleased = true;