Add squash when receiving blunt damage

This commit is contained in:
jgk
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
damageYou = over (creatures . ix 0 . crState . crDamage) addDam
. soundOnce (fromIntegral hitSound)
addDam dams = (( Blunt 100 cpos cpos cpos ) : dams )
addDam dams = (( Blunt 100 cpos ypos ypos ) : dams )
ypos = _crPos $ you w
combinedRad = _crRad cr + _crRad (you w)
(a,g) = randomR (-0.2,0.2) g'
+27 -23
View File
@@ -43,7 +43,7 @@ spawnerCrit :: Creature
spawnerCrit = defaultCreature
{ _crUpdate = stateUpdate $ spawnerAI chaseCrit
, _crHP = 300
, _crPict = enemyPict blue
, _crPict = basicCrPict blue
, _crState = defaultState {_goals = [[WaitFor 0]]
}
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
@@ -53,7 +53,7 @@ smallChaseCrit = defaultCreature
{ _crUpdate = stateUpdate chaseAI
, _crHP = 1
, _crRad = 4
, _crPict = enemyPict green
, _crPict = basicCrPict green
, _crState = defaultState {_goals = [[Wait]]
,_faction = ChaseCritters}
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
@@ -63,7 +63,7 @@ chaseCrit :: Creature
chaseCrit = defaultCreature
{ _crUpdate = stateUpdate chaseAI
, _crHP = 300
, _crPict = enemyPict green
, _crPict = basicCrPict green
, _crState = defaultState {_goals = [[Wait]]
,_faction = ChaseCritters}
, _crInv = IM.empty
@@ -72,7 +72,7 @@ armourChaseCrit :: Creature
armourChaseCrit = defaultCreature
{ _crUpdate = stateUpdate chaseAI
, _crHP = 300
, _crPict = enemyPict green
, _crPict = basicCrPict green
, _crState = defaultState {_goals = [[Wait]]}
, _crInv = IM.fromList
[(0,frontArmour)
@@ -81,7 +81,7 @@ armourChaseCrit = defaultCreature
}
miniGunCrit :: Creature
miniGunCrit = defaultCreature
{ _crPict = enemyPict red
{ _crPict = basicCrPict red
, _crUpdate = stateUpdate miniAI
, _crInv = IM.fromList [(0,miniGun)]
, _crInvSel = 0
@@ -91,7 +91,7 @@ miniGunCrit = defaultCreature
}
longCrit :: Creature
longCrit = defaultCreature
{ _crPict = enemyPict red
{ _crPict = basicCrPict red
, _crUpdate = stateUpdate sniperAI
, _crInv = IM.fromList [(0,longGun),(1,medkit 100)]
, _crInvSel = 0
@@ -101,7 +101,7 @@ longCrit = defaultCreature
}
multGunCrit :: Creature
multGunCrit = defaultCreature
{ _crPict = enemyPict red
{ _crPict = basicCrPict red
, _crUpdate = stateUpdate (twitchMissAI 300 350)
, _crInv = IM.fromList [(0,multGun),(1,medkit 100)]
, _crInvSel = 0
@@ -111,7 +111,7 @@ multGunCrit = defaultCreature
}
launcherCrit :: Creature
launcherCrit = defaultCreature
{ _crPict = enemyPict red
{ _crPict = basicCrPict red
, _crUpdate = stateUpdate (launcherAI 150 200)
, _crInv = IM.fromList [(0,launcher)]
, _crInvSel = 0
@@ -121,7 +121,7 @@ launcherCrit = defaultCreature
}
spreadGunCrit :: Creature
spreadGunCrit = defaultCreature
{ _crPict = enemyPict red
{ _crPict = basicCrPict red
, _crUpdate = stateUpdate chargeAI
, _crInv = IM.fromList [(0,spreadGun),(1,medkit 100)]
, _crInvSel = 0
@@ -131,7 +131,7 @@ spreadGunCrit = defaultCreature
}
pistolCrit :: Creature
pistolCrit = defaultCreature
{ _crPict = enemyPict red
{ _crPict = basicCrPict red
, _crUpdate = stateUpdate (dodgeAI 150 200)
, _crInv = IM.fromList [(0,pistol),(1,medkit 100)]
, _crInvSel = 0
@@ -141,7 +141,7 @@ pistolCrit = defaultCreature
}
autoCrit :: Creature
autoCrit = defaultCreature
{ _crPict = enemyPict red
{ _crPict = basicCrPict red
--, _crUpdate = checkDeadStopSound n . shooterFootsteps n . makeStateAI autoShooterAI n
, _crUpdate = stateUpdate basicShooterAI
--, _crUpdate = shooterFootsteps n . makeStateAI autoShooterAI n
@@ -250,11 +250,11 @@ startCr = defaultCreature
, _crOldPos = (0,0)
, _crDir = 0
, _crID = 0
, _crPict = basicCrPict $ greyN 0.8
, _crPict = basicCrPict $ black
, _crUpdate = stateUpdate yourControl
, _crRad = 10
, _crMass = 10
, _crHP = 1000
, _crHP = 1000000
, _crMaxHP = 1500
, _crInv = startInventory
, _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
enemyPict :: Color -> Creature -> Picture
enemyPict col = equipOnTop $ sizeEnemy (light $ light $ light $ light col)
sizeEnemy col cr
| pdam > 200 = color red $ circleSolid $ _crRad cr
| pdam > 100 = color white $ circleSolid $ _crRad cr
@@ -297,17 +294,24 @@ sizeEnemy col cr
| otherwise = pictures [color col $ circleSolid $ _crRad cr
, circLine $ _crRad cr ]
where
pdam = _crPastDamage $ _crState cr
pdam = sum $ concatMap (map _dmAmount) $ _crPastDamage $ _crState cr
sizeColEnemy r col = pictures [color col $ circleSolid r, circLine r]
basicCrPict :: Color -> Creature -> Picture
basicCrPict col cr = pictures [ onLayer CrLayer naked , drawEquipment cr]
basicCrPict col cr = pictures [ onLayer CrLayer $ bluntScale naked , drawEquipment cr]
where
cdir = _crDir cr
naked | pdam > 200 = color red $ circleSolid $ _crRad cr
| pdam > 100 = color white $ circleSolid $ _crRad cr
| mod pdam 2 == 1 = color white $ circleSolid $ _crRad cr
-- | crDam > _crHP cr && odd (crDam - _crHP cr)
-- = [color white $ circleSolid $ _crRad cr]
| otherwise = pictures [color col $ circleSolid $ _crRad cr, circLine $ _crRad cr]
pdam = _crPastDamage $ _crState cr
| otherwise = pictures [color col' $ circleSolid $ _crRad cr, circLine $ _crRad cr]
pastDams = _crPastDamage $ _crState cr
pdam = sum $ concatMap (map _dmAmount) $ pastDams
col' = light . light . light $ light col
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
((f',g') , maybeCr) -> ( (invSideEff cr . movementSideEff cr . deathEff . f'
, g')
, fmap (updateReloadCounter . reducePastDamage . doDamage)
, fmap (updateReloadCounter . doDamage)
$ crOrCorpse =<< maybeCr
)
where
@@ -81,7 +81,7 @@ crFriction :: Creature -> Point2 -> Point2
crFriction cr vel = (0,0)
doDamage :: Creature -> Creature
doDamage cr = set (crState . crDamage) [] $ over (crState . crPastDamage) (+ hpLost)
doDamage cr = set (crState . crDamage) [] $ over (crState . crPastDamage) (take 20 . (dams :) )
damagedCr
where
dams = _crDamage $ _crState cr
@@ -93,14 +93,6 @@ doDamage cr = set (crState . crDamage) [] $ over (crState . crPastDamage) (+ hpL
sumDamage :: Creature -> DamageType -> Int -> Int
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 cr w
| hasJetPack
+1 -1
View File
@@ -12,7 +12,7 @@ data CreatureState = CrSt
, _stance :: Stance
, _faction :: Faction
, _crDamage :: [DamageType]
, _crPastDamage :: Int
, _crPastDamage :: [[DamageType]]
, _crSpState :: CrSpState
, _crDropsOnDeath :: CreatureDropType
, _crIsAnimate :: Bool
+1 -1
View File
@@ -92,7 +92,7 @@ defaultState = CrSt
, _stance = Stance {_carriage=Walking 0 0,_posture=AtEase}
, _faction = NoFaction
, _crDamage = []
, _crPastDamage = 0
, _crPastDamage = []
, _crSpState = GenCr
, _crDropsOnDeath = DropAmount 1
, _crIsAnimate = True