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

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Server.HandleEffectM

Contents

- Internal operations

Description

Handle effects. They are most often caused by requests sent by clients but sometimes also caused by projectiles or periodically activated items.

Synopsis

- data UseResult
  - = UseDud
  - | UseId
  - | UseUp
- data EffToUse
  - = EffBare
  - | EffBareAndOnCombine
  - | EffOnCombine
- data EffApplyFlags = EffApplyFlags {
  - effToUse :: EffToUse
  - effVoluntary :: Bool
  - effUseAllCopies :: Bool
  - effKineticPerformed :: Bool
  - effActivation :: ActivationFlag
  - effMayDestroy :: Bool
  }
- applyItem :: MonadServerAtomic m => ActorId -> ItemId -> CStore -> m ()
- cutCalm :: MonadServerAtomic m => ActorId -> m ()
- kineticEffectAndDestroy :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ActorId -> ItemId -> Container -> m UseResult
- effectAndDestroyAndAddKill :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ActorId -> ItemId -> Container -> ItemFull -> m UseResult
- itemEffectEmbedded :: MonadServerAtomic m => EffToUse -> Bool -> ActorId -> LevelId -> Point -> ItemId -> m UseResult
- highestImpression :: MonadServerAtomic m => Actor -> m (Maybe (FactionId, Int))
- dominateFidSfx :: MonadServerAtomic m => ActorId -> ActorId -> ItemId -> FactionId -> m Bool
- dropAllEquippedItems :: MonadServerAtomic m => ActorId -> Actor -> m ()
- pickDroppable :: MonadStateRead m => Bool -> ActorId -> Actor -> m Container
- consumeItems :: MonadServerAtomic m => ActorId -> EnumMap CStore ItemBag -> [(CStore, (ItemId, ItemFull))] -> m ()
- dropCStoreItem :: MonadServerAtomic m => Bool -> Bool -> CStore -> ActorId -> Actor -> Int -> ItemId -> ItemQuant -> m UseResult
- applyKineticDamage :: MonadServerAtomic m => ActorId -> ActorId -> ItemId -> m Bool
- refillHP :: MonadServerAtomic m => ActorId -> ActorId -> Int64 -> m ()
- effectAndDestroy :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ItemId -> Container -> ItemFull -> m UseResult
- imperishableKit :: ActivationFlag -> ItemFull -> Bool
- itemEffectDisco :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ItemId -> ContentId ItemKind -> ItemKind -> Container -> [Effect] -> m UseResult
- effectSem :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ItemId -> Container -> Effect -> m UseResult
- effectBurn :: MonadServerAtomic m => Dice -> ActorId -> ActorId -> ItemId -> m UseResult
- effectExplode :: MonadServerAtomic m => m () -> GroupName ItemKind -> ActorId -> ActorId -> Container -> m UseResult
- effectRefillHP :: MonadServerAtomic m => Int -> ActorId -> ActorId -> ItemId -> m UseResult
- effectRefillCalm :: MonadServerAtomic m => m () -> Int -> ActorId -> ActorId -> m UseResult
- effectDominate :: MonadServerAtomic m => ActorId -> ActorId -> ItemId -> m UseResult
- dominateFid :: MonadServerAtomic m => FactionId -> ActorId -> ActorId -> m ()
- effectImpress :: MonadServerAtomic m => (Effect -> m UseResult) -> m () -> ActorId -> ActorId -> m UseResult
- effectPutToSleep :: MonadServerAtomic m => m () -> ActorId -> m UseResult
- effectYell :: MonadServerAtomic m => m () -> ActorId -> m UseResult
- effectSummon :: MonadServerAtomic m => GroupName ItemKind -> Dice -> ItemId -> ActorId -> ActorId -> ActivationFlag -> m UseResult
- effectAscend :: MonadServerAtomic m => (Effect -> m UseResult) -> m () -> Bool -> ActorId -> ActorId -> Container -> m UseResult
- findStairExit :: MonadStateRead m => FactionId -> Bool -> LevelId -> Point -> m Point
- switchLevels1 :: MonadServerAtomic m => (ActorId, Actor) -> m (Maybe ActorId)
- switchLevels2 :: MonadServerAtomic m => LevelId -> Point -> (ActorId, Actor) -> Maybe Time -> Maybe Time -> Maybe ActorId -> m ()
- effectEscape :: MonadServerAtomic m => m () -> ActorId -> ActorId -> m UseResult
- effectParalyze :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult
- paralyze :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult
- effectParalyzeInWater :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult
- effectInsertMove :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult
- effectTeleport :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult
- effectCreateItem :: MonadServerAtomic m => Maybe FactionId -> Maybe Int -> ActorId -> ActorId -> Maybe ItemId -> CStore -> GroupName ItemKind -> TimerDice -> m UseResult
- effectDestroyItem :: MonadServerAtomic m => m () -> Int -> Int -> CStore -> ActorId -> GroupName ItemKind -> m UseResult
- effectDropItem :: MonadServerAtomic m => m () -> ItemId -> Int -> Int -> CStore -> GroupName ItemKind -> ActorId -> m UseResult
- effectConsumeItems :: MonadServerAtomic m => m () -> ItemId -> ActorId -> [(Int, GroupName ItemKind)] -> [(Int, GroupName ItemKind)] -> m UseResult
- effectRecharge :: MonadServerAtomic m => Bool -> m () -> ItemId -> Int -> Dice -> ActorId -> m UseResult
- effectPolyItem :: MonadServerAtomic m => m () -> ItemId -> ActorId -> m UseResult
- effectRerollItem :: MonadServerAtomic m => m () -> ItemId -> ActorId -> m UseResult
- effectDupItem :: MonadServerAtomic m => m () -> ItemId -> ActorId -> m UseResult
- effectIdentify :: MonadServerAtomic m => m () -> ItemId -> ActorId -> m UseResult
- identifyIid :: MonadServerAtomic m => ItemId -> Container -> ContentId ItemKind -> ItemKind -> m ()
- effectDetect :: MonadServerAtomic m => m () -> DetectKind -> Int -> ActorId -> Container -> m UseResult
- effectDetectX :: MonadServerAtomic m => DetectKind -> (Point -> Bool) -> ([Point] -> m Bool) -> m () -> Int -> ActorId -> m UseResult
- effectSendFlying :: MonadServerAtomic m => m () -> ThrowMod -> ActorId -> ActorId -> Container -> Maybe Bool -> m UseResult
- sendFlyingVector :: MonadServerAtomic m => ActorId -> ActorId -> Container -> Maybe Bool -> m Vector
- effectApplyPerfume :: MonadServerAtomic m => m () -> ActorId -> m UseResult
- effectAtMostOneOf :: MonadServerAtomic m => (Effect -> m UseResult) -> [Effect] -> m UseResult
- effectOneOf :: MonadServerAtomic m => (Effect -> m UseResult) -> [Effect] -> m UseResult
- effectAndEffect :: MonadServerAtomic m => (Effect -> m UseResult) -> ActorId -> Effect -> Effect -> m UseResult
- effectAndEffectSem :: MonadServerAtomic m => (Effect -> m UseResult) -> Effect -> Effect -> m UseResult
- effectOrEffect :: MonadServerAtomic m => (Effect -> m UseResult) -> FactionId -> Effect -> Effect -> m UseResult
- effectSeqEffect :: MonadServerAtomic m => (Effect -> m UseResult) -> [Effect] -> m UseResult
- effectWhen :: MonadServerAtomic m => (Effect -> m UseResult) -> ActorId -> Condition -> Effect -> ActivationFlag -> m UseResult
- effectUnless :: MonadServerAtomic m => (Effect -> m UseResult) -> ActorId -> Condition -> Effect -> ActivationFlag -> m UseResult
- effectIfThenElse :: MonadServerAtomic m => (Effect -> m UseResult) -> ActorId -> Condition -> Effect -> Effect -> ActivationFlag -> m UseResult
- effectVerbNoLonger :: MonadServerAtomic m => Bool -> m () -> ActorId -> m UseResult
- effectVerbMsg :: MonadServerAtomic m => m () -> ActorId -> m UseResult
- effectVerbMsgFail :: MonadServerAtomic m => m () -> ActorId -> m UseResult

# Documentation

data UseResult Source #

Constructors

UseDud |
UseId |
UseUp |

#### Instances

Instances details

Eq UseResult Source # |
Instance details Defined in Game.LambdaHack.Server.HandleEffectM Methods (==) :: UseResult -> UseResult -> Bool Source # (/=) :: UseResult -> UseResult -> Bool Source #
Ord UseResult Source # |

Instance details

Defined in Game.LambdaHack.Server.HandleEffectM

Methods

compare :: UseResult -> UseResult -> Ordering Source #

(<) :: UseResult -> UseResult -> Bool Source #

(<=) :: UseResult -> UseResult -> Bool Source #

(>) :: UseResult -> UseResult -> Bool Source #

(>=) :: UseResult -> UseResult -> Bool Source #

max :: UseResult -> UseResult -> UseResult Source #

min :: UseResult -> UseResult -> UseResult Source #

data EffToUse Source #

Constructors

EffBare |
EffBareAndOnCombine |
EffOnCombine |

#### Instances

Instances details

Eq EffToUse Source # |
Instance details Defined in Game.LambdaHack.Server.HandleEffectM Methods (==) :: EffToUse -> EffToUse -> Bool Source # (/=) :: EffToUse -> EffToUse -> Bool Source #

data EffApplyFlags Source #

Constructors

EffApplyFlags |

Fields

- effToUse :: EffToUse
- effVoluntary :: Bool
- effUseAllCopies :: Bool
- effKineticPerformed :: Bool
- effActivation :: ActivationFlag
- effMayDestroy :: Bool

applyItem :: MonadServerAtomic m => ActorId -> ItemId -> CStore -> m () Source #

cutCalm :: MonadServerAtomic m => ActorId -> m () Source #

kineticEffectAndDestroy :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ActorId -> ItemId -> Container -> m UseResult Source #

effectAndDestroyAndAddKill :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ActorId -> ItemId -> Container -> ItemFull -> m UseResult Source #

itemEffectEmbedded :: MonadServerAtomic m => EffToUse -> Bool -> ActorId -> LevelId -> Point -> ItemId -> m UseResult Source #

highestImpression :: MonadServerAtomic m => Actor -> m (Maybe (FactionId, Int)) Source #

dominateFidSfx :: MonadServerAtomic m => ActorId -> ActorId -> ItemId -> FactionId -> m Bool Source #

dropAllEquippedItems :: MonadServerAtomic m => ActorId -> Actor -> m () Source #

Drop all actor's equipped items.

pickDroppable :: MonadStateRead m => Bool -> ActorId -> Actor -> m Container Source #

consumeItems :: MonadServerAtomic m => ActorId -> EnumMap CStore ItemBag -> [(CStore, (ItemId, ItemFull))] -> m () Source #

dropCStoreItem :: MonadServerAtomic m => Bool -> Bool -> CStore -> ActorId -> Actor -> Int -> ItemId -> ItemQuant -> m UseResult Source #

Drop a single actor's item (though possibly multiple copies). Note that if there are multiple copies, at most one explodes to avoid excessive carnage and UI clutter (let's say, the multiple explosions interfere with each other or perhaps larger quantities of explosives tend to be packaged more safely). Note also that `OnSmash` effects are activated even if item discharged.

# Internal operations

applyKineticDamage :: MonadServerAtomic m => ActorId -> ActorId -> ItemId -> m Bool Source #

refillHP :: MonadServerAtomic m => ActorId -> ActorId -> Int64 -> m () Source #

effectAndDestroy :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ItemId -> Container -> ItemFull -> m UseResult Source #

imperishableKit :: ActivationFlag -> ItemFull -> Bool Source #

itemEffectDisco :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ItemId -> ContentId ItemKind -> ItemKind -> Container -> [Effect] -> m UseResult Source #

The source actor affects the target actor, with a given item. If any of the effects fires up, the item gets identified. Even using raw damage (beating the enemy with the magic wand, for example) identifies the item. This means a costly `UpdDiscover` is processed for each random timeout weapon hit and for most projectiles, but at least not for most explosion particles nor plain organs. And if not needed, the `UpdDiscover` are eventually not sent to clients. So, enemy missiles that hit us are no longer mysterious until picked up, which is for the better, because the client knows their charging status and so can generate accurate messages in the case when not recharged. This also means that thrown consumables in flasks sturdy enough to cause damage are always identified at hit, even if no effect activated. So throwing them at foes is a better identification method than applying.

Note that if we activate a durable non-passive item, e.g., a spiked shield, from the ground, it will get identified, which is perfectly fine, until we want to add sticky armor that can't be easily taken off (and, e.g., has some maluses).

effectSem :: MonadServerAtomic m => EffApplyFlags -> ActorId -> ActorId -> ItemId -> Container -> Effect -> m UseResult Source #

Source actor affects target actor, with a given effect and it strength. Both actors are on the current level and can be the same actor. The item may or may not still be in the container.

effectBurn :: MonadServerAtomic m => Dice -> ActorId -> ActorId -> ItemId -> m UseResult Source #

effectExplode :: MonadServerAtomic m => m () -> GroupName ItemKind -> ActorId -> ActorId -> Container -> m UseResult Source #

effectRefillHP :: MonadServerAtomic m => Int -> ActorId -> ActorId -> ItemId -> m UseResult Source #

effectRefillCalm :: MonadServerAtomic m => m () -> Int -> ActorId -> ActorId -> m UseResult Source #

effectDominate :: MonadServerAtomic m => ActorId -> ActorId -> ItemId -> m UseResult Source #

dominateFid :: MonadServerAtomic m => FactionId -> ActorId -> ActorId -> m () Source #

effectImpress :: MonadServerAtomic m => (Effect -> m UseResult) -> m () -> ActorId -> ActorId -> m UseResult Source #

effectPutToSleep :: MonadServerAtomic m => m () -> ActorId -> m UseResult Source #

effectYell :: MonadServerAtomic m => m () -> ActorId -> m UseResult Source #

effectSummon :: MonadServerAtomic m => GroupName ItemKind -> Dice -> ItemId -> ActorId -> ActorId -> ActivationFlag -> m UseResult Source #

effectAscend :: MonadServerAtomic m => (Effect -> m UseResult) -> m () -> Bool -> ActorId -> ActorId -> Container -> m UseResult Source #

findStairExit :: MonadStateRead m => FactionId -> Bool -> LevelId -> Point -> m Point Source #

switchLevels1 :: MonadServerAtomic m => (ActorId, Actor) -> m (Maybe ActorId) Source #

switchLevels2 :: MonadServerAtomic m => LevelId -> Point -> (ActorId, Actor) -> Maybe Time -> Maybe Time -> Maybe ActorId -> m () Source #

effectEscape :: MonadServerAtomic m => m () -> ActorId -> ActorId -> m UseResult Source #

The faction leaves the dungeon.

effectParalyze :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult Source #

Advance target actor time by this many time clips. Not by actor moves, to hurt fast actors more.

paralyze :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult Source #

effectParalyzeInWater :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult Source #

Advance target actor time by this many time clips. Not by actor moves, to hurt fast actors more. Due to water, so resistable.

effectInsertMove :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult Source #

Give target actor the given number of tenths of extra move. Don't give an absolute amount of time units, to benefit slow actors more.

effectTeleport :: MonadServerAtomic m => m () -> Dice -> ActorId -> ActorId -> m UseResult Source #

Teleport the target actor. Note that projectiles can be teleported, too, for extra fun.

effectCreateItem :: MonadServerAtomic m => Maybe FactionId -> Maybe Int -> ActorId -> ActorId -> Maybe ItemId -> CStore -> GroupName ItemKind -> TimerDice -> m UseResult Source #

effectDestroyItem :: MonadServerAtomic m => m () -> Int -> Int -> CStore -> ActorId -> GroupName ItemKind -> m UseResult Source #

Make the target actor destroy items in a store from the given group. The item that caused the effect itself is *not* immune, because often the item needs to destroy itself, e.g., to model wear and tear. In such a case, the item may need to be identified, in a container, when it no longer exists, at least in the container. This is OK. Durable items are not immune, unlike the tools in `ConsumeItems`.

effectDropItem :: MonadServerAtomic m => m () -> ItemId -> Int -> Int -> CStore -> GroupName ItemKind -> ActorId -> m UseResult Source #

Make the target actor drop items in a store from the given group. The item that caused the effect itself is immune (any copies).

effectConsumeItems :: MonadServerAtomic m => m () -> ItemId -> ActorId -> [(Int, GroupName ItemKind)] -> [(Int, GroupName ItemKind)] -> m UseResult Source #

Make the target actor destroy the given items, if all present, or none at all, if any is missing. To be used in crafting. The item that caused the effect itself is not considered (any copies).

effectRecharge :: MonadServerAtomic m => Bool -> m () -> ItemId -> Int -> Dice -> ActorId -> m UseResult Source #

effectPolyItem :: MonadServerAtomic m => m () -> ItemId -> ActorId -> m UseResult Source #

effectRerollItem :: MonadServerAtomic m => m () -> ItemId -> ActorId -> m UseResult Source #

effectDupItem :: MonadServerAtomic m => m () -> ItemId -> ActorId -> m UseResult Source #

effectIdentify :: MonadServerAtomic m => m () -> ItemId -> ActorId -> m UseResult Source #

identifyIid :: MonadServerAtomic m => ItemId -> Container -> ContentId ItemKind -> ItemKind -> m () Source #

effectDetect :: MonadServerAtomic m => m () -> DetectKind -> Int -> ActorId -> Container -> m UseResult Source #

effectDetectX :: MonadServerAtomic m => DetectKind -> (Point -> Bool) -> ([Point] -> m Bool) -> m () -> Int -> ActorId -> m UseResult Source #

effectSendFlying :: MonadServerAtomic m => m () -> ThrowMod -> ActorId -> ActorId -> Container -> Maybe Bool -> m UseResult Source #

Send the target actor flying like a projectile. If the actors are adjacent, the vector is directed outwards, if no, inwards, if it's the same actor, boldpos is used, if it can't, a random outward vector of length 10 is picked.

sendFlyingVector :: MonadServerAtomic m => ActorId -> ActorId -> Container -> Maybe Bool -> m Vector Source #

effectApplyPerfume :: MonadServerAtomic m => m () -> ActorId -> m UseResult Source #

effectAtMostOneOf :: MonadServerAtomic m => (Effect -> m UseResult) -> [Effect] -> m UseResult Source #

effectOneOf :: MonadServerAtomic m => (Effect -> m UseResult) -> [Effect] -> m UseResult Source #

effectAndEffect :: MonadServerAtomic m => (Effect -> m UseResult) -> ActorId -> Effect -> Effect -> m UseResult Source #

effectAndEffectSem :: MonadServerAtomic m => (Effect -> m UseResult) -> Effect -> Effect -> m UseResult Source #

effectOrEffect :: MonadServerAtomic m => (Effect -> m UseResult) -> FactionId -> Effect -> Effect -> m UseResult Source #

effectSeqEffect :: MonadServerAtomic m => (Effect -> m UseResult) -> [Effect] -> m UseResult Source #

effectWhen :: MonadServerAtomic m => (Effect -> m UseResult) -> ActorId -> Condition -> Effect -> ActivationFlag -> m UseResult Source #

effectUnless :: MonadServerAtomic m => (Effect -> m UseResult) -> ActorId -> Condition -> Effect -> ActivationFlag -> m UseResult Source #

effectIfThenElse :: MonadServerAtomic m => (Effect -> m UseResult) -> ActorId -> Condition -> Effect -> Effect -> ActivationFlag -> m UseResult Source #

effectVerbNoLonger :: MonadServerAtomic m => Bool -> m () -> ActorId -> m UseResult Source #

effectVerbMsg :: MonadServerAtomic m => m () -> ActorId -> m UseResult Source #

effectVerbMsgFail :: MonadServerAtomic m => m () -> ActorId -> m UseResult Source #