LambdaHack-0.11.0.1: A game engine library for tactical squad ASCII roguelike dungeon crawlers

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Common.Actor

Contents

- The`Acto`r type, its components and operations on them
- Assorted

Description

Actors in the game: heroes, monsters, etc.

Synopsis

- data Actor = Actor {
  - btrunk :: ItemId
  - bnumber :: Maybe Int
  - bhp :: Int64
  - bhpDelta :: ResDelta
  - bcalm :: Int64
  - bcalmDelta :: ResDelta
  - bpos :: Point
  - boldpos :: Maybe Point
  - blid :: LevelId
  - bfid :: FactionId
  - btrajectory :: Maybe ([Vector], Speed)
  - borgan :: ItemBag
  - beqp :: ItemBag
  - bweapon :: Int
  - bweapBenign :: Int
  - bwatch :: Watchfulness
  - bproj :: Bool
  }
- data ResDelta = ResDelta {
  - resCurrentTurn :: (Int64, Int64)
  - resPreviousTurn :: (Int64, Int64)
  }
- type ActorMaxSkills = EnumMap ActorId Skills
- data Watchfulness
  - = WWatch
  - | WWait Int
  - | WSleep
  - | WWake
- deltasSerious :: ResDelta -> Bool
- deltasSeriousThisTurn :: ResDelta -> Bool
- deltasHears :: ResDelta -> Bool
- deltaBenign :: ResDelta -> Bool
- deltaWasBenign :: ResDelta -> Bool
- actorCanMelee :: ActorMaxSkills -> ActorId -> Actor -> Bool
- actorCanMeleeToHarm :: ActorMaxSkills -> ActorId -> Actor -> Bool
- actorWorthChasing :: ActorMaxSkills -> ActorId -> Actor -> Bool
- actorWorthKilling :: ActorMaxSkills -> ActorId -> Actor -> Bool
- gearSpeed :: Skills -> Speed
- actorTemplate :: ItemId -> Maybe Int -> Int64 -> Int64 -> Point -> LevelId -> FactionId -> Bool -> Actor
- actorWaits :: Actor -> Bool
- actorWaitsOrSleeps :: Actor -> Bool
- actorDying :: Actor -> Bool
- hpTooLow :: Actor -> Skills -> Bool
- calmEnough :: Actor -> Skills -> Bool
- calmFull :: Actor -> Skills -> Bool
- hpFull :: Actor -> Skills -> Bool
- canSleep :: Skills -> Bool
- prefersSleep :: Skills -> Bool
- checkAdjacent :: Actor -> Actor -> Bool
- eqpOverfull :: Actor -> Int -> Bool
- eqpFreeN :: Actor -> Int
- getCarriedIidsAndTrunk :: Actor -> [ItemId]
- getCarriedIidCStore :: Actor -> [(ItemId, CStore)]
- type ActorDict = EnumMap ActorId Actor
- monsterGenChance :: AbsDepth -> AbsDepth -> Int -> Int -> Int
- smellTimeout :: Delta Time

# The`Acto`r type, its components and operations on them

data Actor Source #

Actor attributes that are changing throughout the game. If they appear to be dublets of aspects from actor kinds, e.g. HP, they may be results of casting the dice specified in their respective actor kind and/or may be modified temporarily, but return to the original value from their respective kind over time.

Other properties of an actor, in particular its current aspects, are derived from the actor's trunk, organs and equipment. A class of the aspects, the boolean ones, are called flags. Another class are skills. Stats are a subclass that determines if particular actions are permitted for the actor (or faction).

Constructors

Actor |

Fields

- btrunk :: ItemId

  the trunk organ of the actor's body

- bnumber :: Maybe Int

  continued team character identity index number in this game

- bhp :: Int64

  current hit points * 1M

- bhpDelta :: ResDelta

  HP delta this turn * 1M

- bcalm :: Int64

  current calm * 1M

- bcalmDelta :: ResDelta

  calm delta this turn * 1M

- bpos :: Point

  current position

- boldpos :: Maybe Point

  previous position, if any

- blid :: LevelId

  current level

- bfid :: FactionId

  faction the actor currently belongs to

- btrajectory :: Maybe ([Vector], Speed)

  trajectory the actor must travel and his travel speed

- borgan :: ItemBag

  organs

- beqp :: ItemBag

  personal equipment

- bweapon :: Int

  number of weapons among eqp and organs

- bweapBenign :: Int

  number of benign items among weapons

- bwatch :: Watchfulness

  state of the actor's watchfulness

- bproj :: Bool

  is a projectile? affects being able to fly through other projectiles, etc.

#### Instances

Instances details

Binary Actor Source # |
Instance details Defined in Game.LambdaHack.Common.Actor Methods put :: Actor -> Put Source # get :: Get Actor Source # putList :: [Actor] -> Put Source #
Generic Actor Source # |

Instance details

Defined in Game.LambdaHack.Common.Actor

Associated Types

type Rep Actor |

Instance details

Defined in Game.LambdaHack.Common.Actor

type Rep Actor = D1 ('MetaData "Actor" "Game.LambdaHack.Common.Actor" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "Actor" 'PrefixI 'True) ((((S1 ('MetaSel ('Just "btrunk") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ItemId) :*: S1 ('MetaSel ('Just "bnumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Int))) :*: (S1 ('MetaSel ('Just "bhp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int64) :*: S1 ('MetaSel ('Just "bhpDelta") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ResDelta))) :*: ((S1 ('MetaSel ('Just "bcalm") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int64) :*: S1 ('MetaSel ('Just "bcalmDelta") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ResDelta)) :*: (S1 ('MetaSel ('Just "bpos") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Point) :*: S1 ('MetaSel ('Just "boldpos") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Point))))) :*: (((S1 ('MetaSel ('Just "blid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 LevelId) :*: S1 ('MetaSel ('Just "bfid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 FactionId)) :*: (S1 ('MetaSel ('Just "btrajectory") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe ([Vector], Speed))) :*: S1 ('MetaSel ('Just "borgan") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ItemBag))) :*: ((S1 ('MetaSel ('Just "beqp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ItemBag) :*: S1 ('MetaSel ('Just "bweapon") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "bweapBenign") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: (S1 ('MetaSel ('Just "bwatch") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Watchfulness) :*: S1 ('MetaSel ('Just "bproj") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool)))))))

Methods

from :: Actor -> Rep Actor x Source #

to :: Rep Actor x -> Actor Source #

Show Actor Source # |
Instance details Defined in Game.LambdaHack.Common.Actor Methods showsPrec :: Int -> Actor -> ShowS Source # show :: Actor -> String Source # showList :: [Actor] -> ShowS Source #
Eq Actor Source # |
Instance details Defined in Game.LambdaHack.Common.Actor Methods (==) :: Actor -> Actor -> Bool Source # (/=) :: Actor -> Actor -> Bool Source #
type Rep Actor Source # |

Instance details

Defined in Game.LambdaHack.Common.Actor

type Rep Actor = D1 ('MetaData "Actor" "Game.LambdaHack.Common.Actor" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "Actor" 'PrefixI 'True) ((((S1 ('MetaSel ('Just "btrunk") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ItemId) :*: S1 ('MetaSel ('Just "bnumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Int))) :*: (S1 ('MetaSel ('Just "bhp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int64) :*: S1 ('MetaSel ('Just "bhpDelta") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ResDelta))) :*: ((S1 ('MetaSel ('Just "bcalm") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int64) :*: S1 ('MetaSel ('Just "bcalmDelta") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ResDelta)) :*: (S1 ('MetaSel ('Just "bpos") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Point) :*: S1 ('MetaSel ('Just "boldpos") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Point))))) :*: (((S1 ('MetaSel ('Just "blid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 LevelId) :*: S1 ('MetaSel ('Just "bfid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 FactionId)) :*: (S1 ('MetaSel ('Just "btrajectory") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe ([Vector], Speed))) :*: S1 ('MetaSel ('Just "borgan") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ItemBag))) :*: ((S1 ('MetaSel ('Just "beqp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ItemBag) :*: S1 ('MetaSel ('Just "bweapon") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "bweapBenign") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: (S1 ('MetaSel ('Just "bwatch") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Watchfulness) :*: S1 ('MetaSel ('Just "bproj") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool)))))))

data ResDelta Source #

Representation of recent changes to HP of Calm of an actor. This is reset every time the actor perfoms an action, so this is aggregated over actor turn (move), not time turn. The resource changes recorded in the tuple are, respectively, negative and positive.

Constructors

ResDelta |

Fields

- resCurrentTurn :: (Int64, Int64)

  resource change this move

- resPreviousTurn :: (Int64, Int64)

  resource change previous move

#### Instances

Instances details

Binary ResDelta Source # |
Instance details Defined in Game.LambdaHack.Common.Actor Methods put :: ResDelta -> Put Source # get :: Get ResDelta Source # putList :: [ResDelta] -> Put Source #
Generic ResDelta Source # |

Instance details

Defined in Game.LambdaHack.Common.Actor

Associated Types

type Rep ResDelta |

Instance details

Defined in Game.LambdaHack.Common.Actor

type Rep ResDelta = D1 ('MetaData "ResDelta" "Game.LambdaHack.Common.Actor" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "ResDelta" 'PrefixI 'True) (S1 ('MetaSel ('Just "resCurrentTurn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Int64, Int64)) :*: S1 ('MetaSel ('Just "resPreviousTurn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Int64, Int64))))

Methods

from :: ResDelta -> Rep ResDelta x Source #

to :: Rep ResDelta x -> ResDelta Source #

Show ResDelta Source # |
Instance details Defined in Game.LambdaHack.Common.Actor Methods showsPrec :: Int -> ResDelta -> ShowS Source # show :: ResDelta -> String Source # showList :: [ResDelta] -> ShowS Source #
Eq ResDelta Source # |
Instance details Defined in Game.LambdaHack.Common.Actor Methods (==) :: ResDelta -> ResDelta -> Bool Source # (/=) :: ResDelta -> ResDelta -> Bool Source #
type Rep ResDelta Source # |

Instance details

Defined in Game.LambdaHack.Common.Actor

type Rep ResDelta = D1 ('MetaData "ResDelta" "Game.LambdaHack.Common.Actor" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "ResDelta" 'PrefixI 'True) (S1 ('MetaSel ('Just "resCurrentTurn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Int64, Int64)) :*: S1 ('MetaSel ('Just "resPreviousTurn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Int64, Int64))))

type ActorMaxSkills = EnumMap ActorId Skills Source #

data Watchfulness Source #

Constructors

WWatch |
WWait Int |
WSleep |
WWake |

#### Instances

Instances details

Binary Watchfulness Source # |
Instance details Defined in Game.LambdaHack.Common.Actor Methods put :: Watchfulness -> Put Source # get :: Get Watchfulness Source # putList :: [Watchfulness] -> Put Source #
Generic Watchfulness Source # |

Instance details

Defined in Game.LambdaHack.Common.Actor

Associated Types

type Rep Watchfulness |

Instance details

Defined in Game.LambdaHack.Common.Actor

type Rep Watchfulness = D1 ('MetaData "Watchfulness" "Game.LambdaHack.Common.Actor" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) ((C1 ('MetaCons "WWatch" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WWait" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int))) :+: (C1 ('MetaCons "WSleep" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WWake" 'PrefixI 'False) (U1 :: Type -> Type)))

Methods

from :: Watchfulness -> Rep Watchfulness x Source #

to :: Rep Watchfulness x -> Watchfulness Source #

Show Watchfulness Source # |
Instance details Defined in Game.LambdaHack.Common.Actor Methods showsPrec :: Int -> Watchfulness -> ShowS Source # show :: Watchfulness -> String Source # showList :: [Watchfulness] -> ShowS Source #
Eq Watchfulness Source # |
Instance details Defined in Game.LambdaHack.Common.Actor Methods (==) :: Watchfulness -> Watchfulness -> Bool Source # (/=) :: Watchfulness -> Watchfulness -> Bool Source #
type Rep Watchfulness Source # |

Instance details

Defined in Game.LambdaHack.Common.Actor

type Rep Watchfulness = D1 ('MetaData "Watchfulness" "Game.LambdaHack.Common.Actor" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) ((C1 ('MetaCons "WWatch" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WWait" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int))) :+: (C1 ('MetaCons "WSleep" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WWake" 'PrefixI 'False) (U1 :: Type -> Type)))

deltasSerious :: ResDelta -> Bool Source #

deltasSeriousThisTurn :: ResDelta -> Bool Source #

deltasHears :: ResDelta -> Bool Source #

deltaBenign :: ResDelta -> Bool Source #

deltaWasBenign :: ResDelta -> Bool Source #

actorCanMelee :: ActorMaxSkills -> ActorId -> Actor -> Bool Source #

actorCanMeleeToHarm :: ActorMaxSkills -> ActorId -> Actor -> Bool Source #

actorWorthChasing :: ActorMaxSkills -> ActorId -> Actor -> Bool Source #

actorWorthKilling :: ActorMaxSkills -> ActorId -> Actor -> Bool Source #

gearSpeed :: Skills -> Speed Source #

The speed from organs and gear; being pushed is ignored.

actorTemplate :: ItemId -> Maybe Int -> Int64 -> Int64 -> Point -> LevelId -> FactionId -> Bool -> Actor Source #

actorWaits :: Actor -> Bool Source #

actorWaitsOrSleeps :: Actor -> Bool Source #

actorDying :: Actor -> Bool Source #

Projectile that ran out of steam or collided with obstacle, dies. Even if it pierced through an obstacle, but lost its payload while altering the obstacle during piercing, it dies, too.

hpTooLow :: Actor -> Skills -> Bool Source #

calmEnough :: Actor -> Skills -> Bool Source #

Check if actor calm enough to perform some actions.

If max Calm is zero, always holds, to permit removing disastrous equipped items, which would otherwise be stuck forever.

calmFull :: Actor -> Skills -> Bool Source #

hpFull :: Actor -> Skills -> Bool Source #

canSleep :: Skills -> Bool Source #

Has the skill and can wake up easily, so can sleep safely.

prefersSleep :: Skills -> Bool Source #

Can't loot, not too aggresive, so sometimes prefers to sleep instead of exploring.

checkAdjacent :: Actor -> Actor -> Bool Source #

eqpOverfull :: Actor -> Int -> Bool Source #

eqpFreeN :: Actor -> Int Source #

getCarriedIidsAndTrunk :: Actor -> [ItemId] Source #

getCarriedIidCStore :: Actor -> [(ItemId, CStore)] Source #

# Assorted

type ActorDict = EnumMap ActorId Actor Source #

All actors on the level, indexed by actor identifier.

monsterGenChance :: AbsDepth -> AbsDepth -> Int -> Int -> Int Source #

Chance, in parts per million, that a new monster is generated. Depends on the number of monsters already present, and on the level depth and its cave kind.

Note that sometimes monsters spawn in groups, increasing danger, but many monsters are generated asleep, decreasing initial danger.

smellTimeout :: Delta Time Source #

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