Added a class to map object ids so they can be called by name

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-14 16:00:37 +01:00
parent dfc6a94e88
commit 690ac1e7e6
4 changed files with 128 additions and 31 deletions

View File

@@ -0,0 +1,104 @@
abstract class MapObjectId {
// --- Player Spawns ---
static const int playerNorth = 19;
static const int playerEast = 20;
static const int playerSouth = 21;
static const int playerWest = 22;
// --- Static Decorations ---
static const int waterPuddle = 23;
static const int greenBarrel = 24;
static const int chairTable = 25;
static const int floorLamp = 26;
static const int chandelier = 27;
static const int hangingSkeleton = 28;
static const int dogFood = 29; // Also used as decoration
static const int whiteColumn = 30;
static const int pottedPlant = 31;
static const int blueSkeleton = 32;
static const int vent = 33;
static const int kitchenCans = 34;
static const int exitSign = 35;
static const int brownPlant = 36;
static const int bowl = 37;
static const int armoredSuit = 38;
static const int emptyCage = 39;
static const int cageWithSkeleton = 40;
static const int bones = 41;
static const int goldenKeybowl = 42; // Decorative only
// --- Collectibles & Items ---
static const int goldKey = 43;
static const int silverKey = 44;
static const int bed = 45; // Bed is usually non-collectible but in this range
static const int basket = 46;
static const int food = 47;
static const int medkit = 48;
static const int ammoClip = 49;
static const int machineGun = 50;
static const int chainGun = 51;
static const int cross = 52;
static const int chalice = 53;
static const int chest = 54;
static const int crown = 55;
static const int extraLife = 56;
// --- More Decorations ---
static const int bloodPool = 57;
static const int barrel = 58;
static const int well = 59;
static const int emptyWell = 60;
static const int bloodPoolLarge = 61;
static const int flag = 62;
static const int callanard = 63; // Aardwolf sign / hidden message
static const int bonesAndSkull = 64;
static const int wallHanging = 65;
static const int stove = 66;
static const int spearRack = 67;
static const int vines = 68;
// --- Special Objects ---
static const int secretDoor = 98; // Often used for the Pushwall trigger
static const int elevatorToSecretLevel = 99;
static const int exitTrigger = 100;
// --- Enemies (Spawn Points) ---
// Guards
static const int guardEasyNorth = 108;
static const int guardEasyEast = 109;
static const int guardEasySouth = 110;
static const int guardEasyWest = 111;
// SS Guards
static const int ssEasyNorth = 124;
static const int ssEasyEast = 125;
static const int ssEasySouth = 126;
static const int ssEasyWest = 127;
// Dogs
static const int dogEasyNorth = 140;
static const int dogEasyEast = 141;
static const int dogEasySouth = 142;
static const int dogEasyWest = 143;
// Mutants
static const int mutantEasyNorth = 156;
static const int mutantEasyEast = 157;
static const int mutantEasySouth = 158;
static const int mutantEasyWest = 159;
// Officers
static const int officerEasyNorth = 172;
static const int officerEasyEast = 173;
static const int officerEasySouth = 174;
static const int officerEasyWest = 175;
// Bosses (Single spawn points)
static const int bossHansGrosse = 214;
static const int bossDrSchabbs = 215;
static const int bossFakeHitler = 216;
static const int bossMechaHitler = 217;
static const int bossOttoGiftmacher = 218;
static const int bossGretelGrosse = 219;
static const int bossGeneralFettgesicht = 220;
}

View File

@@ -1,6 +1,7 @@
import 'dart:math' as math; import 'dart:math' as math;
import 'package:wolf_dart/classes/matrix.dart'; import 'package:wolf_dart/classes/matrix.dart';
import 'package:wolf_dart/features/entities/map_objects.dart';
class Pushwall { class Pushwall {
int x; int x;
@@ -24,8 +25,7 @@ class PushwallManager {
for (int y = 0; y < objectGrid.length; y++) { for (int y = 0; y < objectGrid.length; y++) {
for (int x = 0; x < objectGrid[y].length; x++) { for (int x = 0; x < objectGrid[y].length; x++) {
// Map ID 98 in the object grid marks a pushwall! if (objectGrid[y][x] == MapObjectId.secretDoor) {
if (objectGrid[y][x] == 98) {
pushwalls['$x,$y'] = Pushwall(x, y, wallGrid[y][x]); pushwalls['$x,$y'] = Pushwall(x, y, wallGrid[y][x]);
} }
} }

View File

@@ -4,6 +4,7 @@ import 'package:wolf_dart/classes/coordinate_2d.dart';
import 'package:wolf_dart/features/entities/collectible.dart'; import 'package:wolf_dart/features/entities/collectible.dart';
import 'package:wolf_dart/features/entities/enemies/enemy.dart'; import 'package:wolf_dart/features/entities/enemies/enemy.dart';
import 'package:wolf_dart/features/entities/entity.dart'; import 'package:wolf_dart/features/entities/entity.dart';
import 'package:wolf_dart/features/entities/map_objects.dart';
import 'package:wolf_dart/features/weapon/weapon.dart'; import 'package:wolf_dart/features/weapon/weapon.dart';
import 'package:wolf_dart/features/weapon/weapons/chain_gun.dart'; import 'package:wolf_dart/features/weapon/weapons/chain_gun.dart';
import 'package:wolf_dart/features/weapon/weapons/knife.dart'; import 'package:wolf_dart/features/weapon/weapons/knife.dart';
@@ -131,18 +132,14 @@ class Player {
switch (item.type) { switch (item.type) {
case CollectibleType.health: case CollectibleType.health:
if (health >= 100) return false; if (health >= 100) return false;
// Map IDs 47 (Dog Food) and 48 (Medkit) heal(item.mapId == MapObjectId.dogFood ? 4 : 25);
heal(item.mapId == 47 ? 4 : 25);
pickedUp = true; pickedUp = true;
break; break;
case CollectibleType.ammo: case CollectibleType.ammo:
if (ammo >= 99) return false; if (ammo >= 99) return false;
int previousAmmo = ammo; int previousAmmo = ammo;
addAmmo(8); addAmmo(8);
// Auto-switch back to Pistol if holding Knife and just got ammo
if (currentWeapon is Knife && previousAmmo <= 0) { if (currentWeapon is Knife && previousAmmo <= 0) {
requestWeaponSwitch(WeaponType.pistol); requestWeaponSwitch(WeaponType.pistol);
} }
@@ -150,11 +147,11 @@ class Player {
break; break;
case CollectibleType.treasure: case CollectibleType.treasure:
if (item.mapId == 52) score += 100; if (item.mapId == MapObjectId.cross) score += 100;
if (item.mapId == 53) score += 500; if (item.mapId == MapObjectId.chalice) score += 500;
if (item.mapId == 54) score += 1000; if (item.mapId == MapObjectId.chest) score += 1000;
if (item.mapId == 55) score += 5000; if (item.mapId == MapObjectId.crown) score += 5000;
if (item.mapId == 56) { if (item.mapId == MapObjectId.extraLife) {
heal(100); heal(100);
addAmmo(25); addAmmo(25);
} }
@@ -162,31 +159,29 @@ class Player {
break; break;
case CollectibleType.weapon: case CollectibleType.weapon:
addAmmo(8); if (item.mapId == MapObjectId.machineGun) {
if (item.mapId == 50) {
// Machine Gun Pickup
if (weapons[WeaponType.machineGun] == null) { if (weapons[WeaponType.machineGun] == null) {
weapons[WeaponType.machineGun] = MachineGun(); weapons[WeaponType.machineGun] = MachineGun();
hasMachineGun = true; hasMachineGun = true;
} }
// The original game ALWAYS switches to a superior weapon on pickup addAmmo(8);
requestWeaponSwitch(WeaponType.machineGun); requestWeaponSwitch(WeaponType.machineGun);
pickedUp = true; pickedUp = true;
} }
if (item.mapId == 51) { if (item.mapId == MapObjectId.chainGun) {
// Chain Gun Pickup
if (weapons[WeaponType.chainGun] == null) { if (weapons[WeaponType.chainGun] == null) {
weapons[WeaponType.chainGun] = ChainGun(); weapons[WeaponType.chainGun] = ChainGun();
hasChainGun = true; hasChainGun = true;
} }
addAmmo(8);
requestWeaponSwitch(WeaponType.chainGun); requestWeaponSwitch(WeaponType.chainGun);
pickedUp = true; pickedUp = true;
} }
break; break;
case CollectibleType.key: case CollectibleType.key:
if (item.mapId == 43) hasGoldKey = true; if (item.mapId == MapObjectId.goldKey) hasGoldKey = true;
if (item.mapId == 44) hasSilverKey = true; if (item.mapId == MapObjectId.silverKey) hasSilverKey = true;
pickedUp = true; pickedUp = true;
break; break;
} }

View File

@@ -10,6 +10,7 @@ import 'package:wolf_dart/features/entities/door_manager.dart';
import 'package:wolf_dart/features/entities/enemies/enemy.dart'; import 'package:wolf_dart/features/entities/enemies/enemy.dart';
import 'package:wolf_dart/features/entities/entity.dart'; import 'package:wolf_dart/features/entities/entity.dart';
import 'package:wolf_dart/features/entities/entity_registry.dart'; import 'package:wolf_dart/features/entities/entity_registry.dart';
import 'package:wolf_dart/features/entities/map_objects.dart';
import 'package:wolf_dart/features/entities/pushwall_manager.dart'; import 'package:wolf_dart/features/entities/pushwall_manager.dart';
import 'package:wolf_dart/features/input/input_manager.dart'; import 'package:wolf_dart/features/input/input_manager.dart';
import 'package:wolf_dart/features/map/wolf_map.dart'; import 'package:wolf_dart/features/map/wolf_map.dart';
@@ -76,27 +77,24 @@ class _WolfRendererState extends State<WolfRenderer>
for (int x = 0; x < 64; x++) { for (int x = 0; x < 64; x++) {
int objId = objectLevel[y][x]; int objId = objectLevel[y][x];
if (objId >= 19 && objId <= 22) { if (objId >= MapObjectId.playerNorth &&
objId <= MapObjectId.playerWest) {
double spawnAngle = 0.0; double spawnAngle = 0.0;
switch (objId) { switch (objId) {
case 19: case MapObjectId.playerNorth:
spawnAngle = 3 * math.pi / 2; spawnAngle = 3 * math.pi / 2;
break; break;
case 20: case MapObjectId.playerEast:
spawnAngle = 0.0; spawnAngle = 0.0;
break; break;
case 21: case MapObjectId.playerSouth:
spawnAngle = math.pi / 2; spawnAngle = math.pi / 2;
break; break;
case 22: case MapObjectId.playerWest:
spawnAngle = math.pi; spawnAngle = math.pi;
break; break;
} }
player = Player( player = Player(x: x + 0.5, y: y + 0.5, angle: spawnAngle);
x: x + 0.5,
y: y + 0.5,
angle: spawnAngle,
);
} else { } else {
Entity? newEntity = EntityRegistry.spawn( Entity? newEntity = EntityRegistry.spawn(
objId, objId,
@@ -344,7 +342,7 @@ class _WolfRendererState extends State<WolfRenderer>
// Map ID 44 is usually the Ammo Clip in the Object Grid/Registry // Map ID 44 is usually the Ammo Clip in the Object Grid/Registry
Entity? droppedAmmo = EntityRegistry.spawn( Entity? droppedAmmo = EntityRegistry.spawn(
49, // The ID for an ammo clip collectible MapObjectId.ammoClip,
entity.x, entity.x,
entity.y, entity.y,
widget.difficulty.level, widget.difficulty.level,