Add shareware support and spawn correctly for difficulty levels
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
abstract class MapObjectId {
|
||||
import 'package:wolf_dart/classes/cardinal_direction.dart';
|
||||
import 'package:wolf_dart/features/difficulty/difficulty.dart';
|
||||
|
||||
abstract class MapObject {
|
||||
// --- Player Spawns ---
|
||||
static const int playerNorth = 19;
|
||||
static const int playerEast = 20;
|
||||
@@ -12,7 +15,7 @@ abstract class MapObjectId {
|
||||
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 dogFoodDecoration = 29;
|
||||
static const int whiteColumn = 30;
|
||||
static const int pottedPlant = 31;
|
||||
static const int blueSkeleton = 32;
|
||||
@@ -25,12 +28,12 @@ abstract class MapObjectId {
|
||||
static const int emptyCage = 39;
|
||||
static const int cageWithSkeleton = 40;
|
||||
static const int bones = 41;
|
||||
static const int goldenKeybowl = 42; // Decorative only
|
||||
static const int goldenKeyBowl = 42;
|
||||
|
||||
// --- Collectibles & Items ---
|
||||
// --- Collectibles ---
|
||||
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 bed = 45;
|
||||
static const int basket = 46;
|
||||
static const int food = 47;
|
||||
static const int medkit = 48;
|
||||
@@ -43,62 +46,110 @@ abstract class MapObjectId {
|
||||
static const int crown = 55;
|
||||
static const int extraLife = 56;
|
||||
|
||||
// --- More Decorations ---
|
||||
static const int bloodPool = 57;
|
||||
// --- Environmental ---
|
||||
static const int bloodPoolSmall = 57;
|
||||
static const int barrel = 58;
|
||||
static const int well = 59;
|
||||
static const int emptyWell = 60;
|
||||
static const int wellFull = 59;
|
||||
static const int wellEmpty = 60;
|
||||
static const int bloodPoolLarge = 61;
|
||||
static const int flag = 62;
|
||||
static const int callanard = 63; // Aardwolf sign / hidden message
|
||||
static const int aardwolfSign = 63;
|
||||
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;
|
||||
// --- Logic & Triggers ---
|
||||
static const int pushwallTrigger = 98;
|
||||
static const int secretExitTrigger = 99;
|
||||
static const int normalExitTrigger = 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;
|
||||
// --- Enemy Base IDs (Easy, North) ---
|
||||
static const int _guardBase = 108;
|
||||
static const int _officerBase = 126; // WL6 only
|
||||
static const int _ssBase = 144; // WL6 only
|
||||
static const int _dogBase = 162;
|
||||
static const int _mutantBase = 180; // Episode 2+
|
||||
|
||||
// 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)
|
||||
// Bosses (Shared between WL1 and WL6)
|
||||
static const int bossHansGrosse = 214;
|
||||
|
||||
// WL6 Exclusive Bosses
|
||||
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;
|
||||
static const int bossTransGrosse = 216;
|
||||
static const int bossUbermutant = 217;
|
||||
static const int bossDeathKnight = 218;
|
||||
static const int bossMechaHitler = 219;
|
||||
static const int bossHitlerGhost = 220;
|
||||
static const int bossGretelGrosse = 221;
|
||||
static const int bossGiftmacher = 222;
|
||||
static const int bossFettgesicht = 223;
|
||||
|
||||
// --- Enemy Range Constants ---
|
||||
static const int guardStart = 108;
|
||||
static const int officerStart = 126;
|
||||
static const int ssStart = 144;
|
||||
static const int dogStart = 162;
|
||||
static const int mutantStart = 180;
|
||||
|
||||
/// Returns true if the object ID exists in the Shareware version.
|
||||
static bool isSharewareCompatible(int id) {
|
||||
// WL1 only had Guards (108-125), Dogs (162-179), and Hans Grosse (214)
|
||||
if (id >= 126 && id < 162) return false; // No Officers or SS
|
||||
if (id >= 180 && id < 214) return false; // No Mutants
|
||||
if (id > 214) return false; // No other bosses
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Resolves which enemy type a map ID belongs to.
|
||||
static String getEnemyType(int id) {
|
||||
if (id >= 108 && id <= 125) return "Guard";
|
||||
if (id >= 126 && id <= 143) return "Officer";
|
||||
if (id >= 144 && id <= 161) return "SS";
|
||||
if (id >= 162 && id <= 179) return "Dog";
|
||||
if (id >= 180 && id <= 197) return "Mutant";
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
/// Checks if an object should be spawned based on chosen difficulty.
|
||||
static bool shouldSpawn(int id, Difficulty selectedDifficulty) {
|
||||
if (id < 108 || id > 213) return true; // Items/Players/Bosses always spawn
|
||||
|
||||
// Enemy blocks are 18 IDs wide (e.g., 108-125 for Guards)
|
||||
int relativeId = (id - 108) % 18;
|
||||
|
||||
// 0-3: Easy, 4-7: Medium, 8-11: Hard
|
||||
if (relativeId < 4) return true; // Easy spawns on everything
|
||||
if (relativeId < 8) {
|
||||
return selectedDifficulty != Difficulty.canIPlayDaddy; // Medium/Hard
|
||||
}
|
||||
if (relativeId < 12) {
|
||||
return selectedDifficulty == Difficulty.iAmDeathIncarnate; // Hard only
|
||||
}
|
||||
|
||||
// 12-15 are typically "Ambush" versions of the Easy/Medium/Hard guards
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Determines the spawn orientation of an enemy or player.
|
||||
/// Determines the spawn orientation of an enemy or player.
|
||||
static double getAngle(int id) {
|
||||
// Player spawn angles
|
||||
switch (id) {
|
||||
case playerNorth:
|
||||
return CardinalDirection.north.radians;
|
||||
case playerEast:
|
||||
return CardinalDirection.east.radians;
|
||||
case playerSouth:
|
||||
return CardinalDirection.south.radians;
|
||||
case playerWest:
|
||||
return CardinalDirection.west.radians;
|
||||
}
|
||||
|
||||
if (id < 108 || id > 213) return 0.0;
|
||||
|
||||
// Enemy directions are mapped in groups of 4
|
||||
return CardinalDirection.fromEnemyIndex(id - 108).radians;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user