Remove external corpses, handle them as creatures
This commit is contained in:
@@ -15,7 +15,7 @@ flockArmourChaseCrit :: Creature
|
||||
flockArmourChaseCrit =
|
||||
defaultCreature
|
||||
{ _crName = "armourChaseCrit"
|
||||
, _crHP = 300
|
||||
, _crHP = HP 300
|
||||
, _crInv = mempty
|
||||
-- IM.fromList
|
||||
-- [ --(0, frontArmour)
|
||||
|
||||
@@ -13,7 +13,7 @@ autoCrit :: Creature
|
||||
autoCrit =
|
||||
defaultCreature
|
||||
{ --_crInv = IM.fromList [(0, autoRifle)]
|
||||
_crHP = 300
|
||||
_crHP = HP 300
|
||||
-- , _crMvType = defaultAimMvType
|
||||
}
|
||||
-- & crType . skinUpper .~ lightx4 red
|
||||
|
||||
@@ -14,7 +14,7 @@ import Picture
|
||||
smallChaseCrit :: Creature
|
||||
smallChaseCrit =
|
||||
chaseCrit
|
||||
{ _crHP = 1
|
||||
{ _crHP = HP 1
|
||||
, _crInv = mempty
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ chaseCrit :: Creature
|
||||
chaseCrit =
|
||||
defaultCreature
|
||||
{ _crName = "chaseCrit"
|
||||
, _crHP = 150
|
||||
, _crHP = HP 150
|
||||
, _crInv = mempty
|
||||
, _crFaction = ColorFaction green
|
||||
, _crVocalization = chaseCritVocalization
|
||||
|
||||
@@ -33,5 +33,5 @@ applyPiercingDamage cr dm w
|
||||
|
||||
damageHP :: Creature -> Int -> World -> World
|
||||
damageHP cr x =
|
||||
(cWorld . lWorld . creatures . ix (_crID cr) . crHP -~ x)
|
||||
(cWorld . lWorld . creatures . ix (_crID cr) . crHP . _HP -~ x)
|
||||
. (cWorld . lWorld . creatures . ix (_crID cr) . crPain +~ x)
|
||||
|
||||
@@ -17,7 +17,7 @@ import Dodge.Default
|
||||
barrel :: Creature
|
||||
barrel =
|
||||
defaultInanimate
|
||||
{ _crHP = 500
|
||||
{ _crHP = HP 500
|
||||
, _crType = BarrelCrit PlainBarrel
|
||||
-- , _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
|
||||
}
|
||||
@@ -25,7 +25,7 @@ barrel =
|
||||
explosiveBarrel :: Creature
|
||||
explosiveBarrel =
|
||||
defaultInanimate
|
||||
{ _crHP = 400
|
||||
{ _crHP = HP 400
|
||||
, _crType = BarrelCrit (ExplosiveBarrel [])
|
||||
-- , _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ colorLamp ::
|
||||
Creature
|
||||
colorLamp col h =
|
||||
defaultInanimate
|
||||
{ _crHP = 100
|
||||
{ _crHP = HP 100
|
||||
, _crType = LampCrit h col Nothing
|
||||
-- , _crRad = 3
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ launcherCrit :: Creature
|
||||
launcherCrit =
|
||||
defaultCreature
|
||||
{ -- _crInv = IM.fromList [(0, rLauncher)]
|
||||
_crHP = 300
|
||||
_crHP = HP 300
|
||||
}
|
||||
-- & crType . skinUpper .~ lightx4 red
|
||||
-- & crType . humanoidAI .~ LauncherAI
|
||||
|
||||
@@ -13,7 +13,7 @@ ltAutoCrit :: Creature
|
||||
ltAutoCrit =
|
||||
defaultCreature
|
||||
{ --_crInv = IM.fromList [(0, autoPistol)]
|
||||
_crHP = 500
|
||||
_crHP = HP 500
|
||||
}
|
||||
-- & crType .~ LtAutoCrit
|
||||
-- & crType . humanoidAI .~ LtAutoAI
|
||||
|
||||
@@ -12,7 +12,7 @@ spreadGunCrit :: Creature
|
||||
spreadGunCrit =
|
||||
defaultCreature
|
||||
{ --_crInv = IM.fromList [(0, bangStick 6)]
|
||||
_crHP = 500
|
||||
_crHP = HP 500
|
||||
}
|
||||
-- & crType . humanoidAI .~ SpreadGunAI
|
||||
-- & crType . skinUpper .~ lightx4 red
|
||||
|
||||
@@ -10,7 +10,7 @@ import Picture
|
||||
swarmCrit :: Creature
|
||||
swarmCrit =
|
||||
defaultCreature
|
||||
{ _crHP = 1
|
||||
{ _crHP = HP 1
|
||||
-- , _crRad = 2
|
||||
, _crFaction = ColorFaction yellow
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import Color
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.List as List
|
||||
import Dodge.Barreloid
|
||||
import Dodge.Base.NewID
|
||||
--import Dodge.Base.NewID
|
||||
import Dodge.Corpse.Make
|
||||
import Dodge.Creature.Action
|
||||
import Dodge.Creature.Radius
|
||||
@@ -30,7 +30,8 @@ import ShapePicture.Data
|
||||
-- allow for knockbacks etc to be determined as well as intended movements
|
||||
updateCreature :: Creature -> World -> World
|
||||
updateCreature cr
|
||||
| _crZ cr < negate 100 = (tocr . crHP .~ negate 1) . destroyAllInvItems cr
|
||||
| null (cr ^? crHP . _HP) = id
|
||||
| _crZ cr < negate 100 = (tocr . crHP .~ CrIsPitted) . destroyAllInvItems cr
|
||||
| _crZ cr < 0 = (tocr . crZVel -~ 0.5) . (tocr . crZ +~ _crZVel cr)
|
||||
| otherwise = updateCreature' cr
|
||||
where
|
||||
@@ -69,44 +70,56 @@ checkDeath :: Int -> World -> World
|
||||
checkDeath cid w = maybe id checkDeath' (w ^? cWorld . lWorld . creatures . ix cid) w
|
||||
|
||||
checkDeath' :: Creature -> World -> World
|
||||
checkDeath' cr w
|
||||
| _crHP cr > 0 = w & tocr . crDamage .~ []
|
||||
| _crHP cr <= -200 = w
|
||||
& dropAll cr -- the order of
|
||||
& destroyCreature cr -- these is important
|
||||
& stopSoundFrom (CrWeaponSound (_crID cr) 0)
|
||||
& addCrGibs cr
|
||||
| _crHP cr > -200 && _crDeathTimer cr < 5 = w
|
||||
checkDeath' cr w = case cr ^. crHP of
|
||||
HP x | x > 0 -> w & tocr . crDamage .~ []
|
||||
HP x | x > -200 && _crDeathTimer cr < 5 -> w
|
||||
& tocr . crDamage .~ []
|
||||
& tocr . crDeathTimer +~ 1
|
||||
| otherwise = w
|
||||
HP x | x > -200 -> w
|
||||
& dropAll cr -- the order of
|
||||
& removecr -- these is important
|
||||
-- & removecr -- these is important
|
||||
& stopSoundFrom (CrWeaponSound (_crID cr) 0)
|
||||
& corpseOrGib cr
|
||||
HP _ -> w
|
||||
& dropAll cr -- the order of
|
||||
& tocr . crHP .~ CrIsGibs
|
||||
-- & destroyCreature cr -- these is important
|
||||
& stopSoundFrom (CrWeaponSound (_crID cr) 0)
|
||||
& addCrGibs cr
|
||||
_ -> w
|
||||
-- | otherwise = w
|
||||
-- & dropAll cr -- the order of
|
||||
-- & removecr -- these is important
|
||||
-- & stopSoundFrom (CrWeaponSound (_crID cr) 0)
|
||||
-- & corpseOrGib cr
|
||||
where
|
||||
tocr = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
removecr
|
||||
| _crID cr == 0 = id
|
||||
-- hack to get around player creature being killed but left with more than 0 hp
|
||||
| otherwise = cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
|
||||
-- removecr
|
||||
-- | _crID cr == 0 = id
|
||||
-- -- hack to get around player creature being killed but left with more than 0 hp
|
||||
-- | otherwise = cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
|
||||
|
||||
destroyCreature :: Creature -> World -> World
|
||||
destroyCreature cr
|
||||
| _crID cr == 0 = id
|
||||
-- cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ 0
|
||||
-- hack to get around player creature being killed but left with more than 0 hp
|
||||
| otherwise = cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
|
||||
--destroyCreature :: Creature -> World -> World
|
||||
--destroyCreature cr
|
||||
-- | _crID cr == 0 = id
|
||||
-- -- cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ 0
|
||||
-- -- hack to get around player creature being killed but left with more than 0 hp
|
||||
-- | otherwise = cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
|
||||
|
||||
-- could look at the amount of damage here (given by maxDamage) too
|
||||
corpseOrGib :: Creature -> World -> World
|
||||
corpseOrGib cr w = w & case cr ^? crDamage . to maxDamageType . _Just . _1 of
|
||||
Just CookingDamage -> addcorpse (thecorpse & cpSPic %~ scorchSPic)
|
||||
Just PoisonDamage -> addcorpse (thecorpse & cpSPic %~ poisonSPic)
|
||||
Just CookingDamage -> -- addcorpse (thecorpse & cpSPic %~ scorchSPic)
|
||||
sethp (CrIsCorpse $ scorchSPic thecorpse)
|
||||
Just PoisonDamage -> --addcorpse (thecorpse & cpSPic %~ poisonSPic)
|
||||
sethp (CrIsCorpse $ poisonSPic thecorpse)
|
||||
Just PhysicalDamage | _crPain cr > 200 -> addCrGibs cr
|
||||
_ -> addcorpse thecorpse
|
||||
. sethp CrIsGibs
|
||||
_ -> -- addcorpse thecorpse
|
||||
sethp (CrIsCorpse thecorpse)
|
||||
where
|
||||
addcorpse ctype = plNew (cWorld . lWorld . corpses) cpID ctype
|
||||
sethp x = cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ x
|
||||
-- addcorpse ctype = plNew (cWorld . lWorld . corpses) cpID ctype
|
||||
thecorpse = makeCorpse cr
|
||||
|
||||
scorchSPic :: SPic -> SPic
|
||||
|
||||
Reference in New Issue
Block a user