Permalink
Browse files

bugfix: monster in shadow couldn't see heroes

  • Loading branch information...
1 parent 61f4c69 commit 302d666b4a6809e2fc64953859b234ade07ba5a1 @Mikolaj Mikolaj committed Apr 6, 2011
Showing with 8 additions and 5 deletions.
  1. +5 −4 src/Perception.hs
  2. +3 −1 src/StrategyState.hs
View
@@ -51,10 +51,11 @@ actorSeesLoc = actorPrLoc pvisible
actorReachesLoc = actorPrLoc preachable
-- Not quite correct if FOV not symmetric (Shadow).
-actorSeesActor :: Actor -> Actor -> Loc -> Loc -> Perceptions -> Actor -> Bool
-actorSeesActor actor1 actor2 loc1 loc2 per pl =
- actorSeesLoc actor1 loc2 per pl ||
- actorSeesLoc actor2 loc1 per pl
+actorReachesActor :: Actor -> Actor -> Loc -> Loc -> Perceptions -> Actor
+ -> Bool
+actorReachesActor actor1 actor2 loc1 loc2 per pl =
+ actorReachesLoc actor1 loc2 per pl ||
+ actorReachesLoc actor2 loc1 per pl
perception_ :: State -> Perceptions
perception_ state@(State { splayer = pl,
@@ -35,7 +35,9 @@ strategy actor
-- If no heroes on the level, monsters go at each other. TODO: let them
-- earn XP by killing each other to make this dangerous to the player.
foe = if L.null hs then ms else hs
- foeVisible = L.filter (\ (a, l) -> actorSeesActor a actor l me per pl) foe
+ -- We assume monster sight is actually infravision, so light has no effect.
+ foeVisible = L.filter (\ (a, l) ->
+ actorReachesActor a actor l me per pl) foe
foeDist = L.map (\ (_, l) -> (distance (me, l), l)) foeVisible
-- If the player is a monster, monsters spot and attack him when adjacent.
ploc = mloc (getPlayerBody state)

0 comments on commit 302d666

Please sign in to comment.