Add airlocks
This commit is contained in:
@@ -67,13 +67,15 @@ explosiveBarrel :: Creature
|
||||
explosiveBarrel = defaultInanimate
|
||||
{ _crUpdate = updateExpBarrel
|
||||
, _crHP = 400
|
||||
, _crPict = \ _ -> onLayer CrLayer $ pictures [ color orange $ circleSolid 10
|
||||
, color red $ circleSolid 8
|
||||
]
|
||||
, _crState = defaultState {_goals = [[Wait]]
|
||||
,_faction = ChaseCritters
|
||||
,_crSpState = Barrel []
|
||||
}
|
||||
, _crPict = \ _ -> onLayer CrLayer $ pictures
|
||||
[ color red $ circleSolid 8
|
||||
, color orange $ circleSolid 10
|
||||
]
|
||||
, _crState = defaultState
|
||||
{_goals = [[Wait]]
|
||||
,_faction = ChaseCritters
|
||||
,_crSpState = Barrel []
|
||||
}
|
||||
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
|
||||
,_crApplyDamage = \_ c -> (id, c)
|
||||
}
|
||||
|
||||
+15
-12
@@ -46,18 +46,20 @@ stateUpdate u w (f,g) cr =
|
||||
$ crOrCorpse =<< maybeCr
|
||||
)
|
||||
where
|
||||
crOrCorpse cr | cr ^. crHP > 0 = Just cr
|
||||
| otherwise = Nothing
|
||||
deathEff | cr ^.crHP > 0 = id
|
||||
| otherwise = stopSoundFrom (CrWeaponSound (_crID cr))
|
||||
. over decorations addCorpse
|
||||
. dropByState cr
|
||||
crOrCorpse cr
|
||||
| cr ^. crHP > 0 = Just cr
|
||||
| otherwise = Nothing
|
||||
deathEff
|
||||
| cr ^.crHP > 0 = id
|
||||
| otherwise = stopSoundFrom (CrWeaponSound (_crID cr))
|
||||
. over decorations addCorpse
|
||||
. dropByState cr
|
||||
crBeforeDeath = colCrWall w $ cr
|
||||
addCorpse = insertNewKey $ uncurry translate (_crOldPos cr)
|
||||
$ rotate (_crDir cr)
|
||||
(_crCorpse cr)
|
||||
|
||||
-- | Drop items accoring to the creature state.
|
||||
-- | Drop items according to the creature state.
|
||||
dropByState :: Creature -> World -> World
|
||||
dropByState cr w = foldr (copyItemToFloor cr) w is
|
||||
where
|
||||
@@ -81,11 +83,12 @@ crFriction cr vel = (0,0)
|
||||
doDamage :: Creature -> Creature
|
||||
doDamage cr = set (crState . crDamage) [] $ over (crState . crPastDamage) (+ hpLost)
|
||||
damagedCr
|
||||
where dams = _crDamage $ _crState cr
|
||||
startHP = _crHP cr
|
||||
damagedCr = snd $ (_crApplyDamage cr) dams cr
|
||||
afterHP = _crHP damagedCr
|
||||
hpLost = startHP - afterHP -- note this can be negative
|
||||
where
|
||||
dams = _crDamage $ _crState cr
|
||||
startHP = _crHP cr
|
||||
damagedCr = snd $ (_crApplyDamage cr) dams cr
|
||||
afterHP = _crHP damagedCr
|
||||
hpLost = startHP - afterHP -- note this can be negative
|
||||
|
||||
sumDamage :: Creature -> DamageType -> Int -> Int
|
||||
sumDamage cr dm x = x + _dmAmount dm
|
||||
|
||||
@@ -16,8 +16,6 @@ import qualified Data.Set as S
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import System.Random
|
||||
|
||||
|
||||
|
||||
yourControl :: World -> (World -> World,StdGen) -> Creature -> ((World -> World,StdGen), Maybe Creature)
|
||||
yourControl w (f,g) cr = ( (updateUsingInput . f, g)
|
||||
, Just . crAutoReload . mouseActionsCr (_mouseButtons w) $ wasdWithAiming w speed strafeSpeed 0 cr
|
||||
|
||||
Reference in New Issue
Block a user