done implementing SHIELD_SLIME

This commit is contained in:
2025-02-15 13:00:23 +00:00
parent 66c60a490d
commit 0edeb65131
2 changed files with 50 additions and 2 deletions

View File

@@ -517,8 +517,54 @@ struct
EnemyPatch.withPatches (enemy, patches) EnemyPatch.withPatches (enemy, patches)
end end
fun getShieldOnPatches (player, enemy) =
if #platID player = #platID enemy then
[]
else
(* turn off shield if player moved to a different platform *)
[EnemyPatch.W_SHIELD_ON false]
fun getShieldOffPatches
(player, enemy, walls, wallTree, platforms, platformTree) =
let
val {x = ex, y = ey, facing = eFacing, platID = eID, ...} = enemy
val {x = px, y = py, platID = pID, ...} = player
val shouldTurnShieldOn =
eID = pID
andalso
case eFacing of
FACING_RIGHT => px > ex
| FACING_LEFT => px < ex
in
if shouldTurnShieldOn then
[EnemyPatch.W_SHIELD_ON true, EnemyPatch.W_X_AXIS STAY_STILL]
else
startPatrolPatches (player, enemy, wallTree, platformTree, [])
end
fun updateShieldSlime fun updateShieldSlime
(player, enemy, walls, wallTree, platforms, platformTree) = enemy (player, enemy, walls, wallTree, platforms, platformTree) =
let
val size = Constants.enemySize
val enemy = withDefaultYAxis enemy
val patches =
if #shieldOn enemy then
getShieldOnPatches (player, enemy)
else
getShieldOffPatches
(player, enemy, walls, wallTree, platforms, platformTree)
val enemy = EnemyPatch.withPatches (enemy, patches)
val patches = EnemyPhysics.getPhysicsPatches enemy
val enemy = EnemyPatch.withPatches (enemy, patches)
val patches = EnemyPhysics.getEnvironmentPatches
(enemy, walls, wallTree, platforms, platformTree)
in
EnemyPatch.withPatches (enemy, patches)
end
fun updateEnemyState fun updateEnemyState
(enemy, walls, wallTree, platforms, platformTree, player, graph) = (enemy, walls, wallTree, platforms, platformTree, player, graph) =

View File

@@ -86,7 +86,9 @@ struct
PATROL_SLIME => (0.5, 0.5, 1.0) PATROL_SLIME => (0.5, 0.5, 1.0)
| FOLLOW_SLIME => (1.0, 0.5, 0.5) | FOLLOW_SLIME => (1.0, 0.5, 0.5)
| STRAIGHT_BAT => (0.55, 0.55, 0.55) | STRAIGHT_BAT => (0.55, 0.55, 0.55)
| SHIELD_SLIME => (0.33, 0.33, 0.11) | SHIELD_SLIME =>
if #shieldOn enemy then (0.33, 0.33, 0.11)
else (0.5, 0.5, 1.0)
in in
if wratio < hratio then if wratio < hratio then
let let