Cleanup
This commit is contained in:
@@ -23,7 +23,7 @@ updateExpBarrel cr w
|
|||||||
| otherwise = makeExplosionAt (_crPos cr) 0 $ stopSounds w & cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
|
| otherwise = makeExplosionAt (_crPos cr) 0 $ stopSounds w & cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
|
||||||
where
|
where
|
||||||
g = _randGen w
|
g = _randGen w
|
||||||
damages = _csDamage $ _crState cr
|
damages = cr ^. crDamage
|
||||||
pierceSparks :: [World -> World]
|
pierceSparks :: [World -> World]
|
||||||
pierceSparks =
|
pierceSparks =
|
||||||
zipWith
|
zipWith
|
||||||
@@ -32,7 +32,7 @@ updateExpBarrel cr w
|
|||||||
as
|
as
|
||||||
as = randomRs (-0.7, 0.7) g
|
as = randomRs (-0.7, 0.7) g
|
||||||
poss = _piercedPoints $ _barrelType $ _crType cr
|
poss = _piercedPoints $ _barrelType $ _crType cr
|
||||||
newCr = Just $ applyFuseDamage $ set (crState . csDamage) [] $ damsToExpBarrel damages cr
|
newCr = Just $ applyFuseDamage $ set crDamage [] $ damsToExpBarrel damages cr
|
||||||
applyFuseDamage cr' =
|
applyFuseDamage cr' =
|
||||||
cr' & crHP
|
cr' & crHP
|
||||||
%~ subtract (length . _piercedPoints . _barrelType $ _crType cr')
|
%~ subtract (length . _piercedPoints . _barrelType $ _crType cr')
|
||||||
|
|||||||
+1
-1
@@ -175,7 +175,7 @@ setFromToDams bu p = case _buPayload bu of
|
|||||||
|
|
||||||
damageThingHit :: Bullet -> (Point2, Either Creature Wall) -> World -> World
|
damageThingHit :: Bullet -> (Point2, Either Creature Wall) -> World -> World
|
||||||
damageThingHit bu (p, crwl) = case crwl of
|
damageThingHit bu (p, crwl) = case crwl of
|
||||||
Left cr -> cWorld . lWorld . creatures . ix (_crID cr) . crState . csDamage .++~ dams
|
Left cr -> cWorld . lWorld . creatures . ix (_crID cr) . crDamage .++~ dams
|
||||||
-- Right wl -> cWorld . lWorld . wallDamages %~ IM.insertWith (++) (_wlID wl) dams
|
-- Right wl -> cWorld . lWorld . wallDamages %~ IM.insertWith (++) (_wlID wl) dams
|
||||||
-- hopefully the following doesn't introduce a space leak
|
-- hopefully the following doesn't introduce a space leak
|
||||||
Right wl -> cWorld . lWorld . wallDamages . at (_wlID wl) . non mempty <>~ dams
|
Right wl -> cWorld . lWorld . wallDamages . at (_wlID wl) . non mempty <>~ dams
|
||||||
|
|||||||
@@ -67,8 +67,7 @@ unsafeBlinkAction cr w
|
|||||||
| otherwise =
|
| otherwise =
|
||||||
w
|
w
|
||||||
& blinkActionFail cr
|
& blinkActionFail cr
|
||||||
& cWorld . lWorld . creatures . ix cid . crState . csDamage
|
& cWorld . lWorld . creatures . ix cid . crDamage .:~ Enterrement 100000000
|
||||||
.:~ Enterrement 100000000
|
|
||||||
where
|
where
|
||||||
success = fromMaybe True $ do
|
success = fromMaybe True $ do
|
||||||
wl <- snd $ collidePointWallsFilter (const True) mwp cpos w
|
wl <- snd $ collidePointWallsFilter (const True) mwp cpos w
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ followImpulse cr w imp = case imp of
|
|||||||
posFromID cid' = w ^?! cWorld . lWorld . creatures . ix cid' . crPos
|
posFromID cid' = w ^?! cWorld . lWorld . creatures . ix cid' . crPos
|
||||||
rr a = randomR (- a, a) $ _randGen w
|
rr a = randomR (- a, a) $ _randGen w
|
||||||
hitCr i =
|
hitCr i =
|
||||||
( cWorld . lWorld . creatures . ix i . crState . csDamage
|
( cWorld . lWorld . creatures . ix i . crDamage
|
||||||
.:~ Blunt 100 (posFromID i) (posFromID i-cpos)-- (PushBackDamage 5)
|
.:~ Blunt 100 (posFromID i) (posFromID i-cpos)-- (PushBackDamage 5)
|
||||||
)
|
)
|
||||||
. soundStart (CrSound cid) cpos hitS Nothing
|
. soundStart (CrSound cid) cpos hitS Nothing
|
||||||
|
|||||||
@@ -19,10 +19,6 @@ barrel =
|
|||||||
defaultInanimate
|
defaultInanimate
|
||||||
{ _crHP = 500
|
{ _crHP = 500
|
||||||
, _crType = BarrelCrit PlainBarrel
|
, _crType = BarrelCrit PlainBarrel
|
||||||
, _crState =
|
|
||||||
defaultState
|
|
||||||
-- { _csSpState = Barrel []
|
|
||||||
-- }
|
|
||||||
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
|
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,10 +27,6 @@ explosiveBarrel =
|
|||||||
defaultInanimate
|
defaultInanimate
|
||||||
{ _crHP = 400
|
{ _crHP = 400
|
||||||
, _crType = BarrelCrit (ExplosiveBarrel [])
|
, _crType = BarrelCrit (ExplosiveBarrel [])
|
||||||
, _crState =
|
|
||||||
defaultState
|
|
||||||
-- { _csSpState = Barrel []
|
|
||||||
-- }
|
|
||||||
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
|
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
|
||||||
}
|
}
|
||||||
-- & crMaterial .~ Crystal
|
-- & crMaterial .~ Crystal
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ launcherCrit :: Creature
|
|||||||
launcherCrit =
|
launcherCrit =
|
||||||
defaultCreature
|
defaultCreature
|
||||||
{ _crInv = IM.fromList [(0, rLauncher)]
|
{ _crInv = IM.fromList [(0, rLauncher)]
|
||||||
, _crState = defaultState
|
|
||||||
, _crHP = 300
|
, _crHP = 300
|
||||||
}
|
}
|
||||||
-- & crType . skinUpper .~ lightx4 red
|
-- & crType . skinUpper .~ lightx4 red
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ deadRot cr = overPosSH (Q.rotateToZ d)
|
|||||||
maybe
|
maybe
|
||||||
(V3 1 0 0)
|
(V3 1 0 0)
|
||||||
(addZ 0 . unitVectorAtAngle . subtract (_crDir cr + pi))
|
(addZ 0 . unitVectorAtAngle . subtract (_crDir cr + pi))
|
||||||
(damageDirection . _csDamage $ _crState cr)
|
(damageDirection $ _crDamage cr)
|
||||||
|
|
||||||
scalp :: Creature -> Shape
|
scalp :: Creature -> Shape
|
||||||
{-# INLINE scalp #-}
|
{-# INLINE scalp #-}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ checkDeath :: Creature -> World -> World
|
|||||||
checkDeath cr w
|
checkDeath cr w
|
||||||
| _crHP cr > 0 =
|
| _crHP cr > 0 =
|
||||||
w
|
w
|
||||||
& cWorld . lWorld . creatures . ix (_crID cr) . crState . csDamage .~ []
|
& cWorld . lWorld . creatures . ix (_crID cr) . crDamage .~ []
|
||||||
| _crHP cr <= -200 =
|
| _crHP cr <= -200 =
|
||||||
w
|
w
|
||||||
& dropByState cr -- the order of
|
& dropByState cr -- the order of
|
||||||
@@ -86,7 +86,7 @@ checkDeath cr w
|
|||||||
& addCrGibs cr
|
& addCrGibs cr
|
||||||
| _crHP cr > -200 && _crDeathTimer cr < 5 =
|
| _crHP cr > -200 && _crDeathTimer cr < 5 =
|
||||||
w
|
w
|
||||||
& cWorld . lWorld . creatures . ix (_crID cr) . crState . csDamage .~ []
|
& cWorld . lWorld . creatures . ix (_crID cr) . crDamage .~ []
|
||||||
& cWorld . lWorld . creatures . ix (_crID cr) . crDeathTimer +~ 1
|
& cWorld . lWorld . creatures . ix (_crID cr) . crDeathTimer +~ 1
|
||||||
| otherwise =
|
| otherwise =
|
||||||
w
|
w
|
||||||
@@ -104,7 +104,7 @@ checkDeath cr w
|
|||||||
|
|
||||||
-- could look at the amount of damage here (given by maxDamage) too
|
-- could look at the amount of damage here (given by maxDamage) too
|
||||||
corpseOrGib :: Creature -> World -> World
|
corpseOrGib :: Creature -> World -> World
|
||||||
corpseOrGib cr = case cr ^? crState . csDamage . to maxDamageType . _Just . _1 of
|
corpseOrGib cr = case cr ^? crDamage . to maxDamageType . _Just . _1 of
|
||||||
Just CookingDamage -> plNew (cWorld . lWorld . corpses) cpID (thecorpse & cpSPic %~ scorchSPic)
|
Just CookingDamage -> plNew (cWorld . lWorld . corpses) cpID (thecorpse & cpSPic %~ scorchSPic)
|
||||||
Just PoisonDamage -> plNew (cWorld . lWorld . corpses) cpID (thecorpse & cpSPic %~ poisonSPic)
|
Just PoisonDamage -> plNew (cWorld . lWorld . corpses) cpID (thecorpse & cpSPic %~ poisonSPic)
|
||||||
Just PhysicalDamage | _crPastDamage cr > 200 -> addCrGibs cr
|
Just PhysicalDamage | _crPastDamage cr > 200 -> addCrGibs cr
|
||||||
@@ -134,7 +134,7 @@ dropByState cr w = foldl' (flip (dropItem cr)) w $ IM.keys $ _crInv cr
|
|||||||
doDamage :: Creature -> World -> World
|
doDamage :: Creature -> World -> World
|
||||||
doDamage cr = applyPastDamages cr . applyCreatureDamage dams cr
|
doDamage cr = applyPastDamages cr . applyCreatureDamage dams cr
|
||||||
where
|
where
|
||||||
dams = _csDamage $ _crState cr
|
dams = cr ^. crDamage
|
||||||
|
|
||||||
-- TODO generalise shake to arbitrary damage amounts
|
-- TODO generalise shake to arbitrary damage amounts
|
||||||
applyPastDamages :: Creature -> World -> World
|
applyPastDamages :: Creature -> World -> World
|
||||||
|
|||||||
+2
-2
@@ -20,11 +20,11 @@ import FoldableHelp
|
|||||||
damageCrWlID :: Damage -> CrWlID -> World -> World
|
damageCrWlID :: Damage -> CrWlID -> World -> World
|
||||||
damageCrWlID dam = \case
|
damageCrWlID dam = \case
|
||||||
NothingID -> id
|
NothingID -> id
|
||||||
CrID cid -> cWorld . lWorld . creatures . ix cid . crState . csDamage .:~ dam
|
CrID cid -> cWorld . lWorld . creatures . ix cid . crDamage .:~ dam
|
||||||
WlID wlid -> cWorld . lWorld . wallDamages %~ IM.insertWith (++) wlid [dam]
|
WlID wlid -> cWorld . lWorld . wallDamages %~ IM.insertWith (++) wlid [dam]
|
||||||
|
|
||||||
damageCrWl :: Damage -> Either Creature Wall -> World -> World
|
damageCrWl :: Damage -> Either Creature Wall -> World -> World
|
||||||
damageCrWl dt (Left cr) = cWorld . lWorld . creatures . ix (_crID cr) . crState . csDamage .:~ dt
|
damageCrWl dt (Left cr) = cWorld . lWorld . creatures . ix (_crID cr) . crDamage .:~ dt
|
||||||
damageCrWl dt (Right wl) = cWorld . lWorld . wallDamages %~ IM.insertWith (++) (_wlID wl) [dt]
|
damageCrWl dt (Right wl) = cWorld . lWorld . wallDamages %~ IM.insertWith (++) (_wlID wl) [dt]
|
||||||
|
|
||||||
-- could sort for damage amount as well
|
-- could sort for damage amount as well
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ data Creature = Creature
|
|||||||
, _crInv :: IM.IntMap Item
|
, _crInv :: IM.IntMap Item
|
||||||
, _crManipulation :: Manipulation
|
, _crManipulation :: Manipulation
|
||||||
, _crEquipment :: M.Map EquipSite Int
|
, _crEquipment :: M.Map EquipSite Int
|
||||||
, _crState :: CreatureState
|
, _crDamage :: [Damage]
|
||||||
, _crPastDamage :: Int
|
, _crPastDamage :: Int
|
||||||
, _crStance :: Stance
|
, _crStance :: Stance
|
||||||
, _crActionPlan :: ActionPlan
|
, _crActionPlan :: ActionPlan
|
||||||
|
|||||||
@@ -10,18 +10,6 @@ import Control.Lens
|
|||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
import Data.Aeson.TH
|
import Data.Aeson.TH
|
||||||
import qualified Data.IntSet as IS
|
import qualified Data.IntSet as IS
|
||||||
import Dodge.Data.Damage
|
|
||||||
|
|
||||||
data CreatureState = CrSt
|
|
||||||
{ _csDamage :: [Damage]
|
|
||||||
-- , _csSpState :: CrSpState
|
|
||||||
}
|
|
||||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
|
||||||
|
|
||||||
--data CrSpState
|
|
||||||
-- = Barrel -- {_piercedPoints :: [Point2]}
|
|
||||||
-- | GenCr
|
|
||||||
-- deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
|
||||||
|
|
||||||
data Faction
|
data Faction
|
||||||
= GenericFaction Int
|
= GenericFaction Int
|
||||||
@@ -44,10 +32,6 @@ data CrGroup
|
|||||||
| ShieldGroup
|
| ShieldGroup
|
||||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
|
|
||||||
makeLenses ''CreatureState
|
|
||||||
--makeLenses ''CrSpState
|
|
||||||
makeLenses ''CrGroup
|
makeLenses ''CrGroup
|
||||||
--deriveJSON defaultOptions ''CrSpState
|
|
||||||
deriveJSON defaultOptions ''Faction
|
deriveJSON defaultOptions ''Faction
|
||||||
deriveJSON defaultOptions ''CrGroup
|
deriveJSON defaultOptions ''CrGroup
|
||||||
deriveJSON defaultOptions ''CreatureState
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ defaultCreature =
|
|||||||
, _crInv = IM.empty
|
, _crInv = IM.empty
|
||||||
, _crManipulation = Manipulator SelNothing
|
, _crManipulation = Manipulator SelNothing
|
||||||
-- , _crInvCapacity = 25
|
-- , _crInvCapacity = 25
|
||||||
, _crState = defaultState
|
, _crDamage = []
|
||||||
-- , _crCorpse = MakeDefaultCorpse
|
-- , _crCorpse = MakeDefaultCorpse
|
||||||
-- , _crMaterial = Flesh
|
-- , _crMaterial = Flesh
|
||||||
, _crPastDamage = 0
|
, _crPastDamage = 0
|
||||||
@@ -108,10 +108,10 @@ defaultAimingCrit = defaultCreature
|
|||||||
yourDefaultStrideLength :: Int
|
yourDefaultStrideLength :: Int
|
||||||
yourDefaultStrideLength = 40
|
yourDefaultStrideLength = 40
|
||||||
|
|
||||||
defaultState :: CreatureState
|
--defaultState :: CreatureState
|
||||||
defaultState =
|
--defaultState =
|
||||||
CrSt
|
-- CrSt
|
||||||
{ _csDamage = []
|
-- { _csDamage = []
|
||||||
-- , _csSpState = GenCr
|
---- , _csSpState = GenCr
|
||||||
-- , _csDropsOnDeath = DropAll
|
---- , _csDropsOnDeath = DropAll
|
||||||
}
|
-- }
|
||||||
|
|||||||
@@ -126,4 +126,4 @@ damageWlCircle :: Damage -> IM.IntMap [Damage] -> (Point2, Wall) -> IM.IntMap [D
|
|||||||
damageWlCircle dam wls (_, wl) = wls & at (_wlID wl) . non mempty .:~ dam
|
damageWlCircle dam wls (_, wl) = wls & at (_wlID wl) . non mempty .:~ dam
|
||||||
|
|
||||||
damageCrCircle :: Damage -> IM.IntMap Creature -> (Point2, Creature) -> IM.IntMap Creature
|
damageCrCircle :: Damage -> IM.IntMap Creature -> (Point2, Creature) -> IM.IntMap Creature
|
||||||
damageCrCircle dam crs (_, cr) = crs & ix (_crID cr) . crState . csDamage .:~ dam
|
damageCrCircle dam crs (_, cr) = crs & ix (_crID cr) . crDamage .:~ dam
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ updateFlame w pt
|
|||||||
(crsHitRadial ep r w)
|
(crsHitRadial ep r w)
|
||||||
r = flameSize pt
|
r = flameSize pt
|
||||||
damcr w' (_, cr) =
|
damcr w' (_, cr) =
|
||||||
w' & cWorld . lWorld . creatures . ix (_crID cr) . crState . csDamage
|
w' & cWorld . lWorld . creatures . ix (_crID cr) . crDamage
|
||||||
.:~ Flaming 1
|
.:~ Flaming 1
|
||||||
damwl w' (_, wl) =
|
damwl w' (_, wl) =
|
||||||
w' & cWorld . lWorld . wallDamages . at (_wlID wl)
|
w' & cWorld . lWorld . wallDamages . at (_wlID wl)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ aGib =
|
|||||||
}
|
}
|
||||||
|
|
||||||
addCrGibs :: Creature -> World -> World
|
addCrGibs :: Creature -> World -> World
|
||||||
addCrGibs cr = case damageDirection $ _csDamage $ _crState cr of
|
addCrGibs cr = case damageDirection $ _crDamage cr of
|
||||||
Nothing ->
|
Nothing ->
|
||||||
addGibAt 25 (_skinHead skin) cpos
|
addGibAt 25 (_skinHead skin) cpos
|
||||||
. addGibsAt 3 7 (_skinLower skin) cpos
|
. addGibsAt 3 7 (_skinLower skin) cpos
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ fallSmallBounceDamage pr w =
|
|||||||
| otherwise = id
|
| otherwise = id
|
||||||
dodamage' cr
|
dodamage' cr
|
||||||
| dist (_crPos cr) p < crRad (cr ^. crType) + 5 =
|
| dist (_crPos cr) p < crRad (cr ^. crType) + 5 =
|
||||||
cr & crState . csDamage
|
cr & crDamage
|
||||||
.:~ Crushing (floor . (* 10) . max 0 . subtract 5 . abs $ _prVelZ pr) v
|
.:~ Crushing (floor . (* 10) . max 0 . subtract 5 . abs $ _prVelZ pr) v
|
||||||
--(p -.- v) p (p +.+ v)
|
--(p -.- v) p (p +.+ v)
|
||||||
| otherwise = cr
|
| otherwise = cr
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ moveShockwave w sw
|
|||||||
-- this is not expansive enough
|
-- this is not expansive enough
|
||||||
damCr cr
|
damCr cr
|
||||||
| _crID cr `elem` is || dist (_crPos cr) p >= rad + crRad (cr ^. crType) = cr
|
| _crID cr `elem` is || dist (_crPos cr) p >= rad + crRad (cr ^. crType) = cr
|
||||||
| otherwise =
|
| otherwise = cr & crDamage .:~ Explosive dam p
|
||||||
cr & crState . csDamage
|
|
||||||
.:~ Explosive dam p
|
|
||||||
|
|
||||||
--where
|
--where
|
||||||
-- cpos = _crPos cr
|
-- cpos = _crPos cr
|
||||||
@@ -61,9 +59,7 @@ moveInverseShockwave w sw
|
|||||||
-- 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 ^. crType) = cr
|
| dist (_crPos cr) p >= rad + crRad (cr ^. crType) = cr
|
||||||
| otherwise =
|
| otherwise = cr & crDamage .:~ Explosive 1 p
|
||||||
cr & crState . csDamage
|
|
||||||
.:~ Explosive 1 p
|
|
||||||
|
|
||||||
--where
|
--where
|
||||||
-- cpos = _crPos cr
|
-- cpos = _crPos cr
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ cloudPoisonDamage c w = w & dodamagesto (filter f $ crsNearPoint clpos w)
|
|||||||
dodamagesto :: [Creature] -> World -> World
|
dodamagesto :: [Creature] -> World -> World
|
||||||
dodamagesto scrs mcrs = foldl' (flip doDam) mcrs scrs
|
dodamagesto scrs mcrs = foldl' (flip doDam) mcrs scrs
|
||||||
doDam cr =
|
doDam cr =
|
||||||
cWorld . lWorld . creatures . ix (_crID cr) . crState . csDamage
|
cWorld . lWorld . creatures . ix (_crID cr) . crDamage .:~ Poison 1
|
||||||
.:~ Poison 1
|
|
||||||
f cr = dist3 (addZ 20 $ _crPos cr) (_clPos c) < crRad (cr ^. crType) + _clRad c + 10
|
f cr = dist3 (addZ 20 $ _crPos cr) (_clPos c) < crRad (cr ^. crType) + _clRad c + 10
|
||||||
clpos = stripZ $ _clPos c
|
clpos = stripZ $ _clPos c
|
||||||
|
|||||||
@@ -15,6 +15,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) -> cWorld . lWorld . creatures . ix (_crID cr) . crState . csDamage .:~ partDT sp hitp ep
|
Just (hitp, Left cr) -> cWorld . lWorld . creatures . ix (_crID cr) . crDamage .:~ 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
|
||||||
|
|||||||
Reference in New Issue
Block a user