This commit is contained in:
2022-06-19 22:46:50 +01:00
parent b3c6944693
commit 8d457033a2
17 changed files with 33 additions and 33 deletions
+1 -1
View File
@@ -211,7 +211,7 @@ unsafeBlinkAction cr w
$ inverseShockwaveAt cpos 40 2 2 w $ inverseShockwaveAt cpos 40 2 2 w
| otherwise = w | otherwise = w
& blinkActionFail cr & blinkActionFail cr
& creatures . ix cid . crState . crDamage .:~ & creatures . ix cid . crState . csDamage .:~
Damage ENTERREMENT 10000 mwp mwp mwp NoDamageEffect Damage ENTERREMENT 10000 mwp mwp mwp NoDamageEffect
where where
success = fromMaybe True $ do success = fromMaybe True $ do
+1 -1
View File
@@ -92,7 +92,7 @@ followImpulse cr w imp = case imp of
cid = _crID cr cid = _crID cr
posFromID cid' = _crPos $ _creatures w IM.! cid' posFromID cid' = _crPos $ _creatures w IM.! cid'
rr a = randomR (-a,a) $ _randGen w rr a = randomR (-a,a) $ _randGen w
hitCr i = (creatures . ix i . crState . crDamage hitCr i = (creatures . ix i . crState . csDamage
.:~ Damage BLUNT 100 cpos (posFromID i) (posFromID i) NoDamageEffect .:~ Damage BLUNT 100 cpos (posFromID i) (posFromID i) NoDamageEffect
) )
. soundStart (CrSound cid) cpos hitS Nothing . soundStart (CrSound cid) cpos hitS Nothing
+1 -1
View File
@@ -12,7 +12,7 @@ import Data.Maybe
useItem :: Creature -> World -> World useItem :: Creature -> World -> World
useItem cr' w = fromMaybe (f w) $ do useItem cr' w = fromMaybe (f w) $ do
cr <- w ^? creatures . ix (_crID cr') cr <- w ^? creatures . ix (_crID cr')
it <- cr ^? crInv . ix (_crInvSel cr) it <- cr ^? crInv . ix (_crInvSel cr)
return $ itemEffect cr it w return $ itemEffect cr it w
where where
+7 -7
View File
@@ -37,7 +37,7 @@ barrel = defaultInanimate
, color (greyN 0.5) $ circleSolid 8 , color (greyN 0.5) $ circleSolid 8
] ]
, _crState = defaultState , _crState = defaultState
{_crSpState = Barrel [] {_csSpState = Barrel []
} }
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)] , _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
} }
@@ -51,7 +51,7 @@ explosiveBarrel = defaultInanimate
. upperPrismPoly 20 . upperPrismPoly 20
$ polyCirc 4 10 $ polyCirc 4 10
, _crState = defaultState , _crState = defaultState
{_crSpState = Barrel [] {_csSpState = Barrel []
} }
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)] , _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
,_crApplyDamage = \_ _ -> id ,_crApplyDamage = \_ _ -> id
@@ -68,7 +68,7 @@ updateExpBarrel cr w
| otherwise = makeExplosionAt (_crPos cr) $ stopSounds w & creatures . at (_crID cr) .~ Nothing | otherwise = makeExplosionAt (_crPos cr) $ stopSounds w & creatures . at (_crID cr) .~ Nothing
where where
g = _randGen w g = _randGen w
damages = _crDamage $ _crState cr damages = _csDamage $ _crState cr
pierceSparks :: [World -> World] pierceSparks :: [World -> World]
pierceSparks pierceSparks
= zipWith4 (\p a -> createBarrelSpark (_crPos cr +.+ p) (a + argV p) (Just $ _crID cr)) = zipWith4 (\p a -> createBarrelSpark (_crPos cr +.+ p) (a + argV p) (Just $ _crID cr))
@@ -76,10 +76,10 @@ updateExpBarrel cr w
as = randomRs (-0.7,0.7) g as = randomRs (-0.7,0.7) g
colids = randomRs (0,11) g colids = randomRs (0,11) g
times = randomRs (2,5) g times = randomRs (2,5) g
poss = _piercedPoints $ _crSpState $ _crState cr poss = _piercedPoints $ _csSpState $ _crState cr
newCr = Just $ applyFuseDamage $ set (crState . crDamage) [] $ damToExpBarrel damages cr newCr = Just $ applyFuseDamage $ set (crState . csDamage) [] $ damToExpBarrel damages cr
applyFuseDamage cr' = cr' & crHP %~ applyFuseDamage cr' = cr' & crHP %~
subtract (length . _piercedPoints . _crSpState $ _crState cr') subtract (length . _piercedPoints . _csSpState $ _crState cr')
hiss | null poss = id hiss | null poss = id
| otherwise = soundMultiFrom [BarrelHiss 0,BarrelHiss 1] (_crPos cr) foamSprayLoopS (Just 1) | otherwise = soundMultiFrom [BarrelHiss 0,BarrelHiss 1] (_crPos cr) foamSprayLoopS (Just 1)
stopSounds = stopSoundFrom (BarrelHiss 0) . stopSoundFrom (BarrelHiss 1) stopSounds = stopSoundFrom (BarrelHiss 0) . stopSoundFrom (BarrelHiss 1)
@@ -93,7 +93,7 @@ damToExpBarrel ds cr = foldr damToExpBarrel' (foldr damToExpBarrel' cr pierceDam
damToExpBarrel' :: Damage -> Creature -> Creature damToExpBarrel' :: Damage -> Creature -> Creature
damToExpBarrel' dm cr = case _dmType dm of damToExpBarrel' dm cr = case _dmType dm of
PIERCING -> over (crState . crSpState . piercedPoints) ((:) $ int -.- _crPos cr) PIERCING -> over (crState . csSpState . piercedPoints) ((:) $ int -.- _crPos cr)
$ cr & crHP -~ div amount 200 $ cr & crHP -~ div amount 200
POISONDAM -> cr POISONDAM -> cr
SPARKING -> cr SPARKING -> cr
+1 -1
View File
@@ -211,7 +211,7 @@ deadRot :: Creature -> Shape -> Shape
deadRot cr = overPosSH (Q.rotateToZ d) deadRot cr = overPosSH (Q.rotateToZ d)
where where
d = maybe (V3 1 0 0) (addZ 0 . unitVectorAtAngle . subtract (_crDir cr+pi)) d = maybe (V3 1 0 0) (addZ 0 . unitVectorAtAngle . subtract (_crDir cr+pi))
(damageDirection . _crDamage $ _crState cr) (damageDirection . _csDamage $ _crState cr)
scalp :: Creature -> Shape scalp :: Creature -> Shape
{-# INLINE scalp #-} {-# INLINE scalp #-}
+6 -5
View File
@@ -81,10 +81,11 @@ checkDeath cr w
removecr removecr
| _crID cr == 0 = (creatures . ix (_crID cr) . crUpdate .~ const id) | _crID cr == 0 = (creatures . ix (_crID cr) . crUpdate .~ const id)
. (creatures . ix (_crID cr) . crPict .~ const mempty) . (creatures . ix (_crID cr) . crPict .~ const mempty)
. (creatures . ix (_crID cr) . crHP .~ 0) -- hack to get around player creature being killed but left with more than 0 hp . (creatures . ix (_crID cr) . crHP .~ 0)
-- hack to get around player creature being killed but left with more than 0 hp
| otherwise = creatures . at (_crID cr) .~ Nothing | otherwise = creatures . at (_crID cr) .~ Nothing
corpseOrGib :: Creature -> World -> World corpseOrGib :: Creature -> World -> World
corpseOrGib cr w = case maxDamageType (_crDamage (_crState cr)) of corpseOrGib cr w = case maxDamageType (_csDamage (_crState cr)) of
Just (FLAMING,_) -> w & plNew corpses cpID (thecorpse & cpPict %~ fmap scorchSPic) Just (FLAMING,_) -> w & plNew corpses cpID (thecorpse & cpPict %~ fmap scorchSPic)
Just (ELECTRICAL,_) -> w & plNew corpses cpID thecorpse Just (ELECTRICAL,_) -> w & plNew corpses cpID thecorpse
Just (POISONDAM,_) -> w & plNew corpses cpID (thecorpse & cpPict %~ fmap poisonSPic) Just (POISONDAM,_) -> w & plNew corpses cpID (thecorpse & cpPict %~ fmap poisonSPic)
@@ -139,21 +140,21 @@ internalUpdate cr = creatures . ix (_crID cr) %~
-- | Drop items according to the creature state. -- | Drop items according to the creature state.
-- TODO make sure this doesn't mess up any ItemPosition -- TODO make sure this doesn't mess up any ItemPosition
dropByState :: Creature -> World -> World dropByState :: Creature -> World -> World
dropByState cr w = foldr (dropItem cr) w $ case cr ^. crState . crDropsOnDeath of dropByState cr w = foldr (dropItem cr) w $ case cr ^. crState . csDropsOnDeath of
DropAll -> IM.keys $ _crInv cr DropAll -> IM.keys $ _crInv cr
DropSpecific xs -> xs DropSpecific xs -> xs
DropAmount n -> take n $ evalState (shuffle $ IM.keys $ _crInv cr) (_randGen w) DropAmount n -> take n $ evalState (shuffle $ IM.keys $ _crInv cr) (_randGen w)
clearDamage :: Creature -> World -> World clearDamage :: Creature -> World -> World
clearDamage cr w = w clearDamage cr w = w
& creatures . ix (_crID cr) . crState . crDamage .~ [] & creatures . ix (_crID cr) . crState . csDamage .~ []
doDamage :: Creature -> World -> World doDamage :: Creature -> World -> World
doDamage cr w = w doDamage cr w = w
& applyPastDamages cr & applyPastDamages cr
& _crApplyDamage cr dams cr & _crApplyDamage cr dams cr
where where
dams = _crDamage $ _crState cr dams = _csDamage $ _crState cr
-- TODO generalise shake to arbitrary damage amounts -- TODO generalise shake to arbitrary damage amounts
applyPastDamages :: Creature -> World -> World applyPastDamages :: Creature -> World -> World
+1 -1
View File
@@ -8,7 +8,7 @@ import LensHelp
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
damageCrWall :: Damage -> Either Creature Wall -> World -> World damageCrWall :: Damage -> Either Creature Wall -> World -> World
damageCrWall dt (Left cr) = creatures . ix (_crID cr) . crState . crDamage .:~ dt damageCrWall dt (Left cr) = creatures . ix (_crID cr) . crState . csDamage .:~ dt
damageCrWall dt (Right wl) = damageWall dt wl damageCrWall dt (Right wl) = damageWall dt wl
damageDirection :: [Damage] -> Maybe Float damageDirection :: [Damage] -> Maybe Float
+3 -4
View File
@@ -1341,10 +1341,9 @@ isMovementDam dm = case _dmType dm of
_ -> False _ -> False
data CreatureState = CrSt data CreatureState = CrSt
{ _crDamage :: [Damage] { _csDamage :: [Damage]
-- , _crPastDamage :: V.Vector [Damage] , _csSpState :: CrSpState
, _crSpState :: CrSpState , _csDropsOnDeath :: CreatureDropType
, _crDropsOnDeath :: CreatureDropType
} }
data EffectArguments data EffectArguments
+3 -3
View File
@@ -148,10 +148,10 @@ yourDefaultStrideLength = 40
defaultState :: CreatureState defaultState :: CreatureState
defaultState = CrSt defaultState = CrSt
{ _crDamage = [] { _csDamage = []
-- , _crPastDamage = V.fromList $ replicate 20 [] -- , _crPastDamage = V.fromList $ replicate 20 []
, _crSpState = GenCr , _csSpState = GenCr
, _crDropsOnDeath = DropAll , _csDropsOnDeath = DropAll
} }
defaultEquipment :: Item defaultEquipment :: Item
@@ -21,7 +21,7 @@ doDamages :: (Particle -> Point2 -> [Damage])
-> World -> World
-> World -> World
doDamages fdm (p,thhit) bt = case thhit of doDamages fdm (p,thhit) bt = case thhit of
Left cr -> creatures . ix (_crID cr) . crState . crDamage .++~ dams Left cr -> creatures . ix (_crID cr) . crState . csDamage .++~ dams
Right wl -> wallDamages %~ IM.insertWith (++) (_wlID wl) dams Right wl -> wallDamages %~ IM.insertWith (++) (_wlID wl) dams
where where
dams = fdm bt p dams = fdm bt p
+1 -1
View File
@@ -42,7 +42,7 @@ drawGib x pr = flesh <> skin
addCrGibs :: Creature -> World -> World addCrGibs :: Creature -> World -> World
addCrGibs cr w = case damageDirection $ _crDamage $ _crState cr of addCrGibs cr w = case damageDirection $ _csDamage $ _crState cr of
Nothing -> w Nothing -> w
& addGibAt 25 (_skinHead skin) cpos & addGibAt 25 (_skinHead skin) cpos
& addGibsAt 3 7 (_skinLower skin) cpos & addGibsAt 3 7 (_skinLower skin) cpos
+1 -1
View File
@@ -29,7 +29,7 @@ fallSmallBounceDamage pr w = w
| _pjPosZ pr < 25 = creatures %~ fmap dodamage' | _pjPosZ pr < 25 = creatures %~ fmap dodamage'
| otherwise = id | otherwise = id
dodamage' cr dodamage' cr
| dist (_crPos cr) p < _crRad cr + 5 = cr & crState . crDamage | dist (_crPos cr) p < _crRad cr + 5 = cr & crState . csDamage
.:~ Damage CRUSHING (floor . (*10) . max 0 . subtract 5 . abs $ _pjVelZ pr) (p -.- v) p (p +.+ v) NoDamageEffect .:~ Damage CRUSHING (floor . (*10) . max 0 . subtract 5 . abs $ _pjVelZ pr) (p -.- v) p (p +.+ v) NoDamageEffect
| otherwise = cr | otherwise = cr
+1 -1
View File
@@ -62,7 +62,7 @@ armouredChasers = do
let theCrits = zipWith3 (\p a c -> sPS p a (PutCrit c)) ps as cs let theCrits = zipWith3 (\p a c -> sPS p a (PutCrit c)) ps as cs
treeFromPost [corridor,corridor] <$> (randomMediumRoom <&> rmPmnts %~ (++ theCrits)) treeFromPost [corridor,corridor] <$> (randomMediumRoom <&> rmPmnts %~ (++ theCrits))
where where
cs = (armourChaseCrit & crState . crDropsOnDeath .~ DropSpecific [0]) cs = (armourChaseCrit & crState . csDropsOnDeath .~ DropSpecific [0])
: replicate 4 chaseCrit : replicate 4 chaseCrit
randomMediumRoom :: RandomGen g => State g Room randomMediumRoom :: RandomGen g => State g Room
+1 -1
View File
@@ -29,7 +29,7 @@ centerVaultExplosiveExit = do
[sPS (V2 0 110) 0 $ PutCrit explosiveBarrel [sPS (V2 0 110) 0 $ PutCrit explosiveBarrel
,sPS (V2 5 115) 0 $ PutCrit explosiveBarrel ,sPS (V2 5 115) 0 $ PutCrit explosiveBarrel
,sPS (V2 0 120) 0 $ PutCrit explosiveBarrel ,sPS (V2 0 120) 0 $ PutCrit explosiveBarrel
,sPS (V2 0 0) 0 $ PutCrit (cr & crState . crDropsOnDeath .~ DropAll) ,sPS (V2 0 0) 0 $ PutCrit (cr & crState . csDropsOnDeath .~ DropAll)
] ]
centerVaultRoom 120 120 50 <&> rmPmnts %~ (extraPS ++) centerVaultRoom 120 120 50 <&> rmPmnts %~ (extraPS ++)
--r <- centerVaultRoom 120 120 50 <&> rmPmnts %~ (extraPS ++) --r <- centerVaultRoom 120 120 50 <&> rmPmnts %~ (extraPS ++)
+1 -1
View File
@@ -14,6 +14,6 @@ damThingHitWith
-> World -> World
-> World -> World
damThingHitWith partDT sp ep mayEiCrWl = case mayEiCrWl of damThingHitWith partDT sp ep mayEiCrWl = case mayEiCrWl of
Just (hitp,Left cr) -> creatures . ix (_crID cr) . crState . crDamage .:~ partDT sp hitp ep Just (hitp,Left cr) -> creatures . ix (_crID cr) . crState . csDamage .:~ partDT sp hitp ep
Just (hitp,Right wl) -> damageWall (partDT sp hitp ep) wl Just (hitp,Right wl) -> damageWall (partDT sp hitp ep) wl
Nothing -> id Nothing -> id
+2 -2
View File
@@ -67,7 +67,7 @@ mvShockwave is w pt
hitBlocks = wallsOnCirc p rad $ wallsNearPoint p w hitBlocks = wallsOnCirc p rad $ wallsNearPoint p w
damCr cr damCr cr
| _crID cr `elem` is || dist (_crPos cr) p >= rad + _crRad cr = cr | _crID cr `elem` is || dist (_crPos cr) p >= rad + _crRad cr = cr
| otherwise = cr & crState . crDamage .:~ | otherwise = cr & crState . csDamage .:~
Damage PUSHDAM dam cpos cpos cpos Damage PUSHDAM dam cpos cpos cpos
(PushBackDamage (25 * push *.* squashNormalizeV (_crPos cr -.- p))) (PushBackDamage (25 * push *.* squashNormalizeV (_crPos cr -.- p)))
where where
@@ -107,7 +107,7 @@ moveInverseShockwave w pt
hitBlocks = wallsOnCirc p rad $ wallsNearPoint p w hitBlocks = wallsOnCirc p rad $ wallsNearPoint p w
damCr cr damCr cr
| dist (_crPos cr) p >= rad + _crRad cr = cr | dist (_crPos cr) p >= rad + _crRad cr = cr
| otherwise = cr & crState . crDamage .:~ | otherwise = cr & crState . csDamage .:~
Damage PUSHDAM 1 cpos cpos cpos (PushBackDamage $ 25 *.* squashNormalizeV (p -.- cpos)) Damage PUSHDAM 1 cpos cpos cpos (PushBackDamage $ 25 *.* squashNormalizeV (p -.- cpos))
where where
cpos = _crPos cr cpos = _crPos cr
+1 -1
View File
@@ -232,7 +232,7 @@ cloudPoisonDamage c w = w & creatures %~ flip (foldr (IM.adjust doDam)) damagedC
where where
damagedCrs = IM.keys $ IM.filter f $ creaturesNearPoint clpos w damagedCrs = IM.keys $ IM.filter f $ creaturesNearPoint clpos w
f cr = dist3 (addZ 20 $ _crPos cr) (_clPos c) < _crRad cr + _clRad c + 10 f cr = dist3 (addZ 20 $ _crPos cr) (_clPos c) < _crRad cr + _clRad c + 10
doDam cr = cr & crState . crDamage .:~ Damage POISONDAM 1 clpos clpos clpos NoDamageEffect doDam cr = cr & crState . csDamage .:~ Damage POISONDAM 1 clpos clpos clpos NoDamageEffect
clpos = stripZ $ _clPos c clpos = stripZ $ _clPos c
incBall :: RandomGen g => Point2 -> State g Particle incBall :: RandomGen g => Point2 -> State g Particle