Add squash when receiving blunt damage

This commit is contained in:
2021-05-03 16:33:06 +02:00
parent 6e6757499c
commit b826299cbd
5 changed files with 32 additions and 36 deletions
+1 -1
View File
@@ -229,7 +229,7 @@ chaseAI w (f,g') cr =
cpos = _crPos cr cpos = _crPos cr
damageYou = over (creatures . ix 0 . crState . crDamage) addDam damageYou = over (creatures . ix 0 . crState . crDamage) addDam
. soundOnce (fromIntegral hitSound) . soundOnce (fromIntegral hitSound)
addDam dams = (( Blunt 100 cpos cpos cpos ) : dams ) addDam dams = (( Blunt 100 cpos ypos ypos ) : dams )
ypos = _crPos $ you w ypos = _crPos $ you w
combinedRad = _crRad cr + _crRad (you w) combinedRad = _crRad cr + _crRad (you w)
(a,g) = randomR (-0.2,0.2) g' (a,g) = randomR (-0.2,0.2) g'
+27 -23
View File
@@ -43,7 +43,7 @@ spawnerCrit :: Creature
spawnerCrit = defaultCreature spawnerCrit = defaultCreature
{ _crUpdate = stateUpdate $ spawnerAI chaseCrit { _crUpdate = stateUpdate $ spawnerAI chaseCrit
, _crHP = 300 , _crHP = 300
, _crPict = enemyPict blue , _crPict = basicCrPict blue
, _crState = defaultState {_goals = [[WaitFor 0]] , _crState = defaultState {_goals = [[WaitFor 0]]
} }
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)] , _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
@@ -53,7 +53,7 @@ smallChaseCrit = defaultCreature
{ _crUpdate = stateUpdate chaseAI { _crUpdate = stateUpdate chaseAI
, _crHP = 1 , _crHP = 1
, _crRad = 4 , _crRad = 4
, _crPict = enemyPict green , _crPict = basicCrPict green
, _crState = defaultState {_goals = [[Wait]] , _crState = defaultState {_goals = [[Wait]]
,_faction = ChaseCritters} ,_faction = ChaseCritters}
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)] , _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
@@ -63,7 +63,7 @@ chaseCrit :: Creature
chaseCrit = defaultCreature chaseCrit = defaultCreature
{ _crUpdate = stateUpdate chaseAI { _crUpdate = stateUpdate chaseAI
, _crHP = 300 , _crHP = 300
, _crPict = enemyPict green , _crPict = basicCrPict green
, _crState = defaultState {_goals = [[Wait]] , _crState = defaultState {_goals = [[Wait]]
,_faction = ChaseCritters} ,_faction = ChaseCritters}
, _crInv = IM.empty , _crInv = IM.empty
@@ -72,7 +72,7 @@ armourChaseCrit :: Creature
armourChaseCrit = defaultCreature armourChaseCrit = defaultCreature
{ _crUpdate = stateUpdate chaseAI { _crUpdate = stateUpdate chaseAI
, _crHP = 300 , _crHP = 300
, _crPict = enemyPict green , _crPict = basicCrPict green
, _crState = defaultState {_goals = [[Wait]]} , _crState = defaultState {_goals = [[Wait]]}
, _crInv = IM.fromList , _crInv = IM.fromList
[(0,frontArmour) [(0,frontArmour)
@@ -81,7 +81,7 @@ armourChaseCrit = defaultCreature
} }
miniGunCrit :: Creature miniGunCrit :: Creature
miniGunCrit = defaultCreature miniGunCrit = defaultCreature
{ _crPict = enemyPict red { _crPict = basicCrPict red
, _crUpdate = stateUpdate miniAI , _crUpdate = stateUpdate miniAI
, _crInv = IM.fromList [(0,miniGun)] , _crInv = IM.fromList [(0,miniGun)]
, _crInvSel = 0 , _crInvSel = 0
@@ -91,7 +91,7 @@ miniGunCrit = defaultCreature
} }
longCrit :: Creature longCrit :: Creature
longCrit = defaultCreature longCrit = defaultCreature
{ _crPict = enemyPict red { _crPict = basicCrPict red
, _crUpdate = stateUpdate sniperAI , _crUpdate = stateUpdate sniperAI
, _crInv = IM.fromList [(0,longGun),(1,medkit 100)] , _crInv = IM.fromList [(0,longGun),(1,medkit 100)]
, _crInvSel = 0 , _crInvSel = 0
@@ -101,7 +101,7 @@ longCrit = defaultCreature
} }
multGunCrit :: Creature multGunCrit :: Creature
multGunCrit = defaultCreature multGunCrit = defaultCreature
{ _crPict = enemyPict red { _crPict = basicCrPict red
, _crUpdate = stateUpdate (twitchMissAI 300 350) , _crUpdate = stateUpdate (twitchMissAI 300 350)
, _crInv = IM.fromList [(0,multGun),(1,medkit 100)] , _crInv = IM.fromList [(0,multGun),(1,medkit 100)]
, _crInvSel = 0 , _crInvSel = 0
@@ -111,7 +111,7 @@ multGunCrit = defaultCreature
} }
launcherCrit :: Creature launcherCrit :: Creature
launcherCrit = defaultCreature launcherCrit = defaultCreature
{ _crPict = enemyPict red { _crPict = basicCrPict red
, _crUpdate = stateUpdate (launcherAI 150 200) , _crUpdate = stateUpdate (launcherAI 150 200)
, _crInv = IM.fromList [(0,launcher)] , _crInv = IM.fromList [(0,launcher)]
, _crInvSel = 0 , _crInvSel = 0
@@ -121,7 +121,7 @@ launcherCrit = defaultCreature
} }
spreadGunCrit :: Creature spreadGunCrit :: Creature
spreadGunCrit = defaultCreature spreadGunCrit = defaultCreature
{ _crPict = enemyPict red { _crPict = basicCrPict red
, _crUpdate = stateUpdate chargeAI , _crUpdate = stateUpdate chargeAI
, _crInv = IM.fromList [(0,spreadGun),(1,medkit 100)] , _crInv = IM.fromList [(0,spreadGun),(1,medkit 100)]
, _crInvSel = 0 , _crInvSel = 0
@@ -131,7 +131,7 @@ spreadGunCrit = defaultCreature
} }
pistolCrit :: Creature pistolCrit :: Creature
pistolCrit = defaultCreature pistolCrit = defaultCreature
{ _crPict = enemyPict red { _crPict = basicCrPict red
, _crUpdate = stateUpdate (dodgeAI 150 200) , _crUpdate = stateUpdate (dodgeAI 150 200)
, _crInv = IM.fromList [(0,pistol),(1,medkit 100)] , _crInv = IM.fromList [(0,pistol),(1,medkit 100)]
, _crInvSel = 0 , _crInvSel = 0
@@ -141,7 +141,7 @@ pistolCrit = defaultCreature
} }
autoCrit :: Creature autoCrit :: Creature
autoCrit = defaultCreature autoCrit = defaultCreature
{ _crPict = enemyPict red { _crPict = basicCrPict red
--, _crUpdate = checkDeadStopSound n . shooterFootsteps n . makeStateAI autoShooterAI n --, _crUpdate = checkDeadStopSound n . shooterFootsteps n . makeStateAI autoShooterAI n
, _crUpdate = stateUpdate basicShooterAI , _crUpdate = stateUpdate basicShooterAI
--, _crUpdate = shooterFootsteps n . makeStateAI autoShooterAI n --, _crUpdate = shooterFootsteps n . makeStateAI autoShooterAI n
@@ -250,11 +250,11 @@ startCr = defaultCreature
, _crOldPos = (0,0) , _crOldPos = (0,0)
, _crDir = 0 , _crDir = 0
, _crID = 0 , _crID = 0
, _crPict = basicCrPict $ greyN 0.8 , _crPict = basicCrPict $ black
, _crUpdate = stateUpdate yourControl , _crUpdate = stateUpdate yourControl
, _crRad = 10 , _crRad = 10
, _crMass = 10 , _crMass = 10
, _crHP = 1000 , _crHP = 1000000
, _crMaxHP = 1500 , _crMaxHP = 1500
, _crInv = startInventory , _crInv = startInventory
, _crCorpse = onLayer CorpseLayer $ color (greyN 0.5) $ pictures [color (greyN 0.8) $ circleSolid 10, circLine 10] , _crCorpse = onLayer CorpseLayer $ color (greyN 0.5) $ pictures [color (greyN 0.8) $ circleSolid 10, circLine 10]
@@ -287,9 +287,6 @@ startInventory = IM.fromList (zip [0..20]
smokeGenGun = effectGun "smoke" $ \_ -> spawnSmokeAtCursor smokeGenGun = effectGun "smoke" $ \_ -> spawnSmokeAtCursor
enemyPict :: Color -> Creature -> Picture
enemyPict col = equipOnTop $ sizeEnemy (light $ light $ light $ light col)
sizeEnemy col cr sizeEnemy col cr
| pdam > 200 = color red $ circleSolid $ _crRad cr | pdam > 200 = color red $ circleSolid $ _crRad cr
| pdam > 100 = color white $ circleSolid $ _crRad cr | pdam > 100 = color white $ circleSolid $ _crRad cr
@@ -297,17 +294,24 @@ sizeEnemy col cr
| otherwise = pictures [color col $ circleSolid $ _crRad cr | otherwise = pictures [color col $ circleSolid $ _crRad cr
, circLine $ _crRad cr ] , circLine $ _crRad cr ]
where where
pdam = _crPastDamage $ _crState cr pdam = sum $ concatMap (map _dmAmount) $ _crPastDamage $ _crState cr
sizeColEnemy r col = pictures [color col $ circleSolid r, circLine r] sizeColEnemy r col = pictures [color col $ circleSolid r, circLine r]
basicCrPict :: Color -> Creature -> Picture basicCrPict :: Color -> Creature -> Picture
basicCrPict col cr = pictures [ onLayer CrLayer naked , drawEquipment cr] basicCrPict col cr = pictures [ onLayer CrLayer $ bluntScale naked , drawEquipment cr]
where where
cdir = _crDir cr
naked | pdam > 200 = color red $ circleSolid $ _crRad cr naked | pdam > 200 = color red $ circleSolid $ _crRad cr
| pdam > 100 = color white $ circleSolid $ _crRad cr | pdam > 100 = color white $ circleSolid $ _crRad cr
| mod pdam 2 == 1 = color white $ circleSolid $ _crRad cr | otherwise = pictures [color col' $ circleSolid $ _crRad cr, circLine $ _crRad cr]
-- | crDam > _crHP cr && odd (crDam - _crHP cr) pastDams = _crPastDamage $ _crState cr
-- = [color white $ circleSolid $ _crRad cr] pdam = sum $ concatMap (map _dmAmount) $ pastDams
| otherwise = pictures [color col $ circleSolid $ _crRad cr, circLine $ _crRad cr] col' = light . light . light $ light col
pdam = _crPastDamage $ _crState cr bluntDam :: Maybe Point2
bluntDam = find isBluntDam (concat pastDams) >>= (\dm -> (-.-) <$> dm ^? dmFrom <*> dm ^? dmTo)
bluntScale = case fmap argV bluntDam of
Just a -> rotate (a + cdir) . scale 0.8 1.2 . rotate (negate $ cdir + a)
_ -> id
isBluntDam (Blunt {}) = True
isBluntDam _ = False
+2 -10
View File
@@ -42,7 +42,7 @@ stateUpdate u w (f,g) cr =
in case u w (f,g'') cr' of in case u w (f,g'') cr' of
((f',g') , maybeCr) -> ( (invSideEff cr . movementSideEff cr . deathEff . f' ((f',g') , maybeCr) -> ( (invSideEff cr . movementSideEff cr . deathEff . f'
, g') , g')
, fmap (updateReloadCounter . reducePastDamage . doDamage) , fmap (updateReloadCounter . doDamage)
$ crOrCorpse =<< maybeCr $ crOrCorpse =<< maybeCr
) )
where where
@@ -81,7 +81,7 @@ crFriction :: Creature -> Point2 -> Point2
crFriction cr vel = (0,0) crFriction cr vel = (0,0)
doDamage :: Creature -> Creature doDamage :: Creature -> Creature
doDamage cr = set (crState . crDamage) [] $ over (crState . crPastDamage) (+ hpLost) doDamage cr = set (crState . crDamage) [] $ over (crState . crPastDamage) (take 20 . (dams :) )
damagedCr damagedCr
where where
dams = _crDamage $ _crState cr dams = _crDamage $ _crState cr
@@ -93,14 +93,6 @@ doDamage cr = set (crState . crDamage) [] $ over (crState . crPastDamage) (+ hpL
sumDamage :: Creature -> DamageType -> Int -> Int sumDamage :: Creature -> DamageType -> Int -> Int
sumDamage cr dm x = x + _dmAmount dm sumDamage cr dm x = x + _dmAmount dm
reducePastDamage :: Creature -> Creature
reducePastDamage = over (crState . crPastDamage) rdpdam
where rdpdam x | x > 500 = x - 55
| x > 200 = x - 25
| x > 20 = x - 5
| x > 0 = x - 1
| otherwise = 0
movementSideEff :: Creature -> World -> World movementSideEff :: Creature -> World -> World
movementSideEff cr w movementSideEff cr w
| hasJetPack | hasJetPack
+1 -1
View File
@@ -12,7 +12,7 @@ data CreatureState = CrSt
, _stance :: Stance , _stance :: Stance
, _faction :: Faction , _faction :: Faction
, _crDamage :: [DamageType] , _crDamage :: [DamageType]
, _crPastDamage :: Int , _crPastDamage :: [[DamageType]]
, _crSpState :: CrSpState , _crSpState :: CrSpState
, _crDropsOnDeath :: CreatureDropType , _crDropsOnDeath :: CreatureDropType
, _crIsAnimate :: Bool , _crIsAnimate :: Bool
+1 -1
View File
@@ -92,7 +92,7 @@ defaultState = CrSt
, _stance = Stance {_carriage=Walking 0 0,_posture=AtEase} , _stance = Stance {_carriage=Walking 0 0,_posture=AtEase}
, _faction = NoFaction , _faction = NoFaction
, _crDamage = [] , _crDamage = []
, _crPastDamage = 0 , _crPastDamage = []
, _crSpState = GenCr , _crSpState = GenCr
, _crDropsOnDeath = DropAmount 1 , _crDropsOnDeath = DropAmount 1
, _crIsAnimate = True , _crIsAnimate = True