LambdaHack-0.11.0.0: A game engine library for tactical squad ASCII roguelike dungeon crawlers
Safe HaskellNone
LanguageHaskell2010

Game.LambdaHack.Common.ActorState

Description

Operations on the Actor type, and related, that need the State type, but not our custom monad types.

Synopsis

Documentation

calculateTotal :: FactionId -> State -> (ItemBag, Int) Source #

Calculate loot's worth for a given faction.

itemPrice :: Int -> ItemKind -> Int Source #

Price an item, taking count into consideration.

mapActorItems_ :: Monad m => (CStore -> ItemId -> ItemQuant -> m ()) -> Actor -> State -> m () Source #

memActor :: ActorId -> LevelId -> State -> Bool Source #

Checks if the actor is present on the current level. The order of argument here and in other functions is set to allow

b <- getsState (memActor a)

getLocalTime :: LevelId -> State -> Time Source #

Get current time from the dungeon data.

lidFromC :: Container -> State -> LevelId Source #

Determine the dungeon level of the container. If the item is in the shared stash, the level depends on which actor asks, not where the stash is located physically.

anyFoeAdj :: ActorId -> State -> Bool Source #

Require that any non-dying foe is adjacent. We include even projectiles that explode when stricken down, because they can be caught and then they don't explode, so it makes sense to focus on handling them. If there are many projectiles in a single adjacent position, we only test the first one, the one that would be hit in melee (this is not optimal if the actor would need to flee instead of meleeing, but fleeing with *many* projectiles adjacent is a possible waste of a move anyway).

inMelee :: ActorMaxSkills -> FactionId -> LevelId -> State -> Bool Source #

Check if any non-dying foe is adjacent to any of our normal actors and either can harm them via melee or can attack from a distance. Otherwise no point meleeing him. Projectiles are ignored, because they are not actively attempted to melee, see meleeAny. This is regardless of whether our actor can melee or just needs to flee, in which case alert is needed so that he is not slowed down by others. However, if our actor can't move nor melee, no real combat is taking place. This is needed only by AI and computed as lazily as possible.