Working on fixing enemy identification
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:wolf_dart/classes/cardinal_direction.dart';
|
||||
import 'package:wolf_dart/features/difficulty/difficulty.dart';
|
||||
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
|
||||
|
||||
abstract class MapObject {
|
||||
// --- Player Spawns ---
|
||||
@@ -81,10 +82,10 @@ abstract class MapObject {
|
||||
|
||||
// --- Enemy Range Constants ---
|
||||
static const int guardStart = 108; // 108-143
|
||||
static const int officerStart = 144; // 144-179 (WL6)
|
||||
static const int ssStart = 180; // 180-215 (WL6)
|
||||
static const int officerStart = 144; // 144-179
|
||||
static const int ssStart = 180; // 180-215
|
||||
static const int dogStart = 216; // 216-251
|
||||
static const int mutantStart = 252; // 252-287 (WL6)
|
||||
static const int mutantStart = 252; // 252-287
|
||||
|
||||
// --- Missing Decorative Bodies ---
|
||||
static const int deadGuard = 124; // Decorative only in WL1
|
||||
@@ -112,6 +113,7 @@ abstract class MapObject {
|
||||
}
|
||||
|
||||
static double getAngle(int id) {
|
||||
// Player spawn
|
||||
switch (id) {
|
||||
case playerNorth:
|
||||
return CardinalDirection.north.radians;
|
||||
@@ -123,52 +125,34 @@ abstract class MapObject {
|
||||
return CardinalDirection.west.radians;
|
||||
}
|
||||
|
||||
// FIX: Expand the boundary to include ALL enemies (Dogs and Mutants)
|
||||
if (id < guardStart || id > (mutantStart + 35)) return 0.0;
|
||||
// Boss check
|
||||
if (id == bossHansGrosse) return 0.0;
|
||||
|
||||
int baseId;
|
||||
if (id >= mutantStart) {
|
||||
baseId = mutantStart;
|
||||
} else if (id >= dogStart) {
|
||||
baseId = dogStart;
|
||||
} else if (id >= ssStart) {
|
||||
baseId = ssStart;
|
||||
} else if (id >= officerStart) {
|
||||
baseId = officerStart;
|
||||
} else {
|
||||
baseId = guardStart;
|
||||
}
|
||||
final EnemyType? type = EnemyType.fromMapId(id);
|
||||
if (type == null) return 0.0; // Not a standard directional enemy
|
||||
|
||||
// FIX: Normalize patrolling enemies back to the standing block, THEN get the 4-way angle
|
||||
int directionIndex = ((id - baseId) % 18) % 4;
|
||||
// Normalize patrolling enemies back to the standing block, THEN get the
|
||||
// 4-way angle
|
||||
int directionIndex = ((id - type.mapBaseId) % 18) % 4;
|
||||
return CardinalDirection.fromEnemyIndex(directionIndex).radians;
|
||||
}
|
||||
|
||||
static bool shouldSpawn(int id, Difficulty selectedDifficulty) {
|
||||
// FIX: Expand the boundary so Dogs and Mutants aren't bypassing difficulty checks
|
||||
if (id < guardStart || id > (mutantStart + 35)) return true;
|
||||
EnemyType? type = EnemyType.fromMapId(id);
|
||||
|
||||
int baseId;
|
||||
if (id >= mutantStart) {
|
||||
baseId = mutantStart;
|
||||
} else if (id >= dogStart) {
|
||||
baseId = dogStart;
|
||||
} else if (id >= ssStart) {
|
||||
baseId = ssStart;
|
||||
} else if (id >= officerStart) {
|
||||
baseId = officerStart;
|
||||
} else {
|
||||
baseId = guardStart;
|
||||
}
|
||||
// If it's not a standard enemy (it's a decoration, boss, or player), spawn it
|
||||
if (type == null) return true;
|
||||
|
||||
int relativeId = (id - baseId) % 18;
|
||||
int offset = id - type.mapBaseId;
|
||||
int normalizedOffset = offset >= 18 ? offset - 18 : offset;
|
||||
|
||||
return switch (relativeId) {
|
||||
< 4 => true,
|
||||
< 8 => selectedDifficulty.level >= Difficulty.dontHurtMe.level,
|
||||
< 12 => selectedDifficulty.level >= Difficulty.bringEmOn.level,
|
||||
< 16 => selectedDifficulty.level >= Difficulty.iAmDeathIncarnate.level,
|
||||
_ => true,
|
||||
return switch (normalizedOffset) {
|
||||
< 4 => true, // Spawns on all difficulties
|
||||
< 8 => selectedDifficulty.level >= Difficulty.bringEmOn.level, // Normal
|
||||
< 16 =>
|
||||
selectedDifficulty.level >=
|
||||
Difficulty.iAmDeathIncarnate.level, // Hard & Ambush
|
||||
_ => true, // Dead bodies (decorations)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user