LambdaHack-0.2.8: A roguelike game engine in early and active development

Safe HaskellNone




Actors in the game: heroes, monsters, etc. No operation in this module involves the State or Action type.


Actor identifiers and related operations

data ActorId Source

A unique identifier of an actor in the dungeon.

monsterGenChance :: Int -> Int -> Int -> Rnd BoolSource

Chance that a new monster is generated. Currently depends on the number of monsters already present, and on the level. In the future, the strength of the character and the strength of the monsters present could further influence the chance, and the chance could also affect which monster is generated. How many and which monsters are generated will also depend on the cave kind used to build the level.

partActor :: Ops ActorKind -> Actor -> PartSource

The part of speech describing the actor.

The Actor type

data Actor Source

Actor properties that are changing throughout the game. If they are dublets of properties from ActorKind, they are usually modified temporarily, but tend to return to the original value from ActorKind over time. E.g., HP.




bkind :: !(Id ActorKind)

the kind of the actor

bsymbol :: !(Maybe Char)

individual map symbol

_bname :: !(Maybe Text)

individual name

bcolor :: !(Maybe Color)

individual map color

bspeed :: !(Maybe Speed)

individual speed

bhp :: !Int

current hit points

bpath :: !(Maybe [Vector])

path the actor is forced to travel

bpos :: !Point

current position

boldpos :: !Point

previous position

blid :: !LevelId

current level

bbag :: !ItemBag

items carried

binv :: !ItemInv

map from letters to items

bletter :: !InvChar

next inventory letter

btime :: !Time

absolute time of next action

bwait :: !Time

last bracing expires at this time

bfid :: !FactionId

to which faction the actor belongs

bproj :: !Bool

is a projectile? (shorthand only, this can be deduced from bkind)

actorTemplate :: Id ActorKind -> Maybe Char -> Maybe Text -> Maybe Color -> Maybe Speed -> Int -> Maybe [Vector] -> Point -> LevelId -> Time -> FactionId -> Bool -> ActorSource

A template for a new non-projectile actor.

timeAddFromSpeed :: Ops ActorKind -> Actor -> Time -> TimeSource

Add time taken by a single step at the actor's current speed.

braced :: Actor -> Time -> BoolSource

Whether an actor is braced for combat this turn.

unoccupied :: [Actor] -> Point -> BoolSource

Checks for the presence of actors in a position. Does not check if the tile is walkable.

heroKindId :: Ops ActorKind -> Id ActorKindSource

The unique kind of heroes.

projectileKindId :: Ops ActorKind -> Id ActorKindSource

The unique kind of projectiles.

actorSpeed :: Ops ActorKind -> Actor -> SpeedSource

Access actor speed, individual or, otherwise, stock.

Inventory management

newtype InvChar Source




invChar :: Char

type ItemDict = EnumMap ItemId ItemSource

All items in the dungeon (including in actor inventories), indexed by item identifier.

type ItemRev = HashMap Item ItemIdSource

Reverse item map, for item creation, to keep items and item identifiers in bijection.

assignLetter :: ItemId -> Maybe InvChar -> Actor -> Maybe InvCharSource

Assigns a letter to an item, for inclusion in the inventory of a hero. Tries to to use the requested letter, if any.


type ActorDict = EnumMap ActorId ActorSource

All actors on the level, indexed by actor identifier.

smellTimeout :: TimeSource

How long until an actor's smell vanishes from a tile.

mapActorItems_ :: Monad m => (ItemId -> Int -> m a) -> Actor -> m ()Source