Add in "linear" lWorld to separate time reversable worlds
This commit is contained in:
@@ -57,7 +57,7 @@ performAimAt cr w tcid p = ([TurnToward tpos aimSp], Just $ AimAt tcid tpos)
|
||||
Just f -> doFloatFloat f $ safeAngleVV (unitVectorAtAngle cdir) (tpos - cpos)
|
||||
Nothing -> error "creature without aiming type"
|
||||
tpos
|
||||
| canSee' = _crPos (_creatures (_cWorld w) IM.! tcid)
|
||||
| canSee' = w ^?! cWorld . lWorld . creatures . ix tcid . crPos
|
||||
| otherwise = p
|
||||
|
||||
performPathTo :: Creature -> World -> Point2 -> OutAction
|
||||
@@ -146,23 +146,23 @@ performAction cr w ac = case ac of
|
||||
|
||||
|
||||
setMinInvSize :: Int -> Creature -> World -> World
|
||||
setMinInvSize n cr = cWorld . creatures . ix (_crID cr) . crInvCapacity .~ n
|
||||
setMinInvSize n cr = cWorld . lWorld . creatures . ix (_crID cr) . crInvCapacity .~ n
|
||||
|
||||
-- maybe this should be removed...
|
||||
stripNoItems :: Creature -> World -> World
|
||||
stripNoItems cr =
|
||||
organiseInvKeys (_crID cr)
|
||||
. (cWorld . creatures . ix (_crID cr) . crInv %~ IM.mapMaybe Just)
|
||||
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv %~ IM.mapMaybe Just)
|
||||
|
||||
organiseInvKeys :: Int -> World -> World
|
||||
organiseInvKeys cid w =
|
||||
w & cWorld . creatures . ix cid
|
||||
w & cWorld . lWorld . creatures . ix cid
|
||||
%~ ( (crInvSel . iselPos .~ newSelKey)
|
||||
. (crInv .~ newInv)
|
||||
. (crInvSel . iselAction .~ NoInvSelAction)
|
||||
)
|
||||
where
|
||||
cr = _creatures (_cWorld w) IM.! cid
|
||||
cr = w ^?! cWorld . lWorld . creatures . ix cid-- _creatures (_cWorld w) IM.! cid
|
||||
pairs = IM.toList (_crInv cr)
|
||||
newSelKey = fromMaybe 0 $ findIndex ((== crSel cr) . fst) pairs
|
||||
newInv = IM.fromAscList $ zip [0 ..] $ map snd pairs
|
||||
@@ -216,8 +216,8 @@ sizeSelf x cr w
|
||||
Just $
|
||||
w
|
||||
& soundMultiFrom [TeleSound 0, TeleSound 1] cpos teleS Nothing
|
||||
& cWorld . distortions .:~ distortionBulge
|
||||
& cWorld . creatures . ix cid
|
||||
& cWorld . lWorld . distortions .:~ distortionBulge
|
||||
& cWorld . lWorld . creatures . ix cid
|
||||
%~ ( (crRad .~ 10 * x)
|
||||
. (crMvType . mvSpeed .~ yourDefaultSpeed * x)
|
||||
. (crStance . strideLength .~ ceiling (fromIntegral yourDefaultStrideLength * x))
|
||||
@@ -234,7 +234,7 @@ sizeSelf x cr w
|
||||
cpos = _crPos cr
|
||||
|
||||
pickUpItemID :: Int -> Int -> World -> World
|
||||
pickUpItemID cid flid w = pickUpItem cid (_floorItems (_cWorld w) IM.! flid) w
|
||||
pickUpItemID cid flid w = pickUpItem cid (w ^?! cWorld . lWorld . floorItems . ix flid) w
|
||||
|
||||
-- | Pick up a specific item.
|
||||
pickUpItem :: Int -> FloorItem -> World -> World
|
||||
|
||||
@@ -21,7 +21,7 @@ blinkActionMousePos cr w =
|
||||
w
|
||||
& soundMultiFrom [TeleSound 0, TeleSound 1] p3 teleS Nothing
|
||||
& blinkDistortions cpos p3
|
||||
& cWorld . creatures . ix cid . crPos .~ p3
|
||||
& cWorld . lWorld . creatures . ix cid . crPos .~ p3
|
||||
& blinkShockwave cid p3
|
||||
& inverseShockwaveAt cpos 40 2 2
|
||||
where
|
||||
@@ -38,7 +38,7 @@ blinkActionMousePos cr w =
|
||||
pushIntoMaybe (x,my) = (x,) <$> my
|
||||
|
||||
blinkDistortions :: Point2 -> Point2 -> World -> World
|
||||
blinkDistortions sp ep = cWorld . distortions .++~ distortionBulge
|
||||
blinkDistortions sp ep = cWorld . lWorld . distortions .++~ distortionBulge
|
||||
where
|
||||
distR = 120
|
||||
distortionBulge =
|
||||
@@ -57,13 +57,13 @@ unsafeBlinkAction cr w
|
||||
| success =
|
||||
soundMultiFrom [TeleSound 0, TeleSound 1] mwp teleS Nothing
|
||||
. blinkDistortions cpos mwp
|
||||
. set (cWorld . creatures . ix cid . crPos) mwp
|
||||
. set (cWorld . lWorld . creatures . ix cid . crPos) mwp
|
||||
. blinkShockwave cid mwp
|
||||
$ inverseShockwaveAt cpos 40 2 2 w
|
||||
| otherwise =
|
||||
w
|
||||
& blinkActionFail cr
|
||||
& cWorld . creatures . ix cid . crState . csDamage
|
||||
& cWorld . lWorld . creatures . ix cid . crState . csDamage
|
||||
.:~ Damage ENTERREMENT 10000 mwp mwp mwp NoDamageEffect
|
||||
where
|
||||
success = fromMaybe True $ do
|
||||
@@ -89,8 +89,8 @@ blinkActionFail ::
|
||||
blinkActionFail cr w =
|
||||
w
|
||||
& soundMultiFrom [TeleSound 0, TeleSound 1] p3 teleS Nothing
|
||||
& cWorld . distortions .:~ distortionBulge
|
||||
& cWorld . creatures . ix cid . crPos .~ p3
|
||||
& cWorld . lWorld . distortions .:~ distortionBulge
|
||||
& cWorld . lWorld . creatures . ix cid . crPos .~ p3
|
||||
& inverseShockwaveAt cpos 40 2 2
|
||||
where
|
||||
distR = 120
|
||||
|
||||
@@ -179,7 +179,7 @@ swarmUsingCenter updT upd w cr = case _targetCr $ _crIntention cr of
|
||||
Just tcr -> updT tcr cenp cr
|
||||
where
|
||||
cid = _crID cr
|
||||
cenp = _crGroupCenter $ _creatureGroups (_cWorld w) IM.! _crGroupID (_crGroup $ _creatures (_cWorld w) IM.! cid)
|
||||
cenp = _crGroupCenter $ _creatureGroups (_lWorld (_cWorld w)) IM.! _crGroupID (_crGroup $ _creatures (_lWorld (_cWorld w)) IM.! cid)
|
||||
|
||||
flockChaseTarget ::
|
||||
-- | Update with target
|
||||
@@ -194,7 +194,7 @@ flockChaseTarget updT upd w cr = case _targetCr $ _crIntention cr of
|
||||
Just tcr -> updT tcr crs cr
|
||||
where
|
||||
is = _swarm $ _crGroup cr
|
||||
crs = IM.restrictKeys (_creatures (_cWorld w)) is
|
||||
crs = IM.restrictKeys (w ^. cWorld . lWorld . creatures) is
|
||||
|
||||
flockPointTarget ::
|
||||
(Creature -> IM.IntMap Creature -> Creature -> Point2) ->
|
||||
@@ -208,7 +208,7 @@ flockPointTarget f targFunc w cr = case targFunc cr w of
|
||||
Just crTarg -> cr & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
|
||||
where
|
||||
is = _swarm $ _crGroup cr
|
||||
crs = IM.restrictKeys (_creatures (_cWorld w)) is
|
||||
crs = IM.restrictKeys (w ^. cWorld . lWorld . creatures) is
|
||||
p = f crTarg crs cr
|
||||
|
||||
flockToPointUsing ::
|
||||
@@ -220,7 +220,8 @@ flockToPointUsing pf mvf cr = reader $ \w -> case _targetCr $ _crIntention cr of
|
||||
Nothing -> cr
|
||||
Just tcr -> cr & crActionPlan . apImpulse .~ mvf ptarg cr tcr
|
||||
where
|
||||
cenp = _crGroupCenter $ _creatureGroups (_cWorld w) IM.! _crGroupID (_crGroup cr)
|
||||
cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter
|
||||
-- crGroupCenter $ _creatureGroups (_cWorld w) IM.! _crGroupID (_crGroup cr)
|
||||
ptarg = pf tcr cenp cr
|
||||
|
||||
flockToPointUsing' ::
|
||||
@@ -233,7 +234,7 @@ flockToPointUsing' pf mvf w cr = case _targetCr $ _crIntention cr of
|
||||
Nothing -> cr
|
||||
Just tcr -> cr & crActionPlan . apImpulse .~ mvf ptarg cr tcr
|
||||
where
|
||||
cenp = _crGroupCenter $ _creatureGroups (_cWorld w) IM.! _crGroupID (_crGroup cr)
|
||||
cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter
|
||||
ptarg = pf tcr cenp cr
|
||||
|
||||
flockFunc ::
|
||||
@@ -246,7 +247,7 @@ flockFunc f targFunc cr = reader $ \w -> case targFunc cr w of
|
||||
Nothing -> cr
|
||||
Just crTarg -> cr & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
|
||||
where
|
||||
cenp = _crGroupCenter $ _creatureGroups (_cWorld w) IM.! _crGroupID (_crGroup cr)
|
||||
cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter
|
||||
p = f crTarg cenp cr
|
||||
|
||||
flockCenterFunc ::
|
||||
@@ -259,7 +260,7 @@ flockCenterFunc f targFunc cr = reader $ \w -> case targFunc cr w of
|
||||
Nothing -> cr
|
||||
Just crTarg -> cr & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
|
||||
where
|
||||
cenp = _crGroupCenter $ _creatureGroups (_cWorld w) IM.! _crGroupID (_crGroup cr)
|
||||
cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter
|
||||
p = f crTarg cenp cr
|
||||
|
||||
flockPointTargetR ::
|
||||
@@ -273,7 +274,8 @@ flockPointTargetR f targFunc cr = reader $ \w -> case targFunc cr w of
|
||||
Just crTarg -> cr & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
|
||||
where
|
||||
is = _swarm $ _crGroup cr
|
||||
crs = IM.restrictKeys (_creatures (_cWorld w)) is
|
||||
--crs = IM.restrictKeys (_creatures (_cWorld w)) is
|
||||
crs = IM.restrictKeys (w ^. cWorld . lWorld . creatures) is
|
||||
p = f crTarg crs cr
|
||||
|
||||
meleeHeadingMove ::
|
||||
|
||||
@@ -20,7 +20,7 @@ applyCreatureDamage dms cr = case _crMaterial cr of
|
||||
defaultApplyDamage :: [Damage] -> Creature -> World -> World
|
||||
defaultApplyDamage ds cr w =
|
||||
foldl' (applyIndividualDamage cr) w ds'
|
||||
& cWorld . creatures . ix (_crID cr) %~ doPoisonDam
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) %~ doPoisonDam
|
||||
where
|
||||
(ps, ds') = partition isPoison ds
|
||||
isPoison Damage{_dmType = POISONDAM} = True
|
||||
@@ -31,15 +31,15 @@ defaultApplyDamage ds cr w =
|
||||
applyDamageEffect :: Damage -> DamageEffect -> Creature -> World -> World
|
||||
applyDamageEffect dm de cr = case de of
|
||||
PushDamage push pushexp pushRad ->
|
||||
cWorld . creatures . ix (_crID cr) . crPos .+.+~ pushAmount *.* squashNormalizeV (_crPos cr -.- fromDir)
|
||||
cWorld . lWorld . creatures . ix (_crID cr) . crPos .+.+~ pushAmount *.* squashNormalizeV (_crPos cr -.- fromDir)
|
||||
where
|
||||
pushAmount
|
||||
| dist (_crPos cr) fromDir == 0 = 0
|
||||
| otherwise = min 5 $ (push * 5 * pushRad / (dist (_crPos cr) fromDir * _crMass cr)) ** pushexp
|
||||
PushBackDamage pback ->
|
||||
cWorld . creatures . ix (_crID cr) . crPos .+.+~ (pback / _crMass cr) *.* (_dmTo dm -.- fromDir)
|
||||
cWorld . lWorld . creatures . ix (_crID cr) . crPos .+.+~ (pback / _crMass cr) *.* (_dmTo dm -.- fromDir)
|
||||
TorqueDamage rot ->
|
||||
cWorld . creatures . ix (_crID cr) . crDir +~ rot
|
||||
cWorld . lWorld . creatures . ix (_crID cr) . crDir +~ rot
|
||||
NoDamageEffect -> id
|
||||
where
|
||||
fromDir = _dmFrom dm
|
||||
@@ -64,7 +64,7 @@ applyPiercingDamage cr dm
|
||||
|
||||
damageHP :: Creature -> Int -> World -> World
|
||||
damageHP cr x =
|
||||
cWorld . creatures . ix (_crID cr)
|
||||
cWorld . lWorld . creatures . ix (_crID cr)
|
||||
%~ ( (crHP -~ x)
|
||||
. (crPastDamage +~ x)
|
||||
)
|
||||
|
||||
@@ -16,7 +16,6 @@ import Dodge.FloatFunction
|
||||
import Dodge.RandImpulse
|
||||
import Dodge.SoundLogic
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import System.Random
|
||||
|
||||
@@ -25,7 +24,7 @@ impulsiveAIBefore ::
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
impulsiveAIBefore f cr w = g w & cWorld . creatures . ix (_crID cr) .~ cr'
|
||||
impulsiveAIBefore f cr w = g w & cWorld . lWorld . creatures . ix (_crID cr) .~ cr'
|
||||
where
|
||||
(g, cr') = followImpulses w $ f w cr
|
||||
|
||||
@@ -80,10 +79,10 @@ followImpulse cr w imp = case imp of
|
||||
cpos = _crPos cr
|
||||
cdir = _crDir cr
|
||||
cid = _crID cr
|
||||
posFromID cid' = _crPos $ _creatures (_cWorld w) IM.! cid'
|
||||
posFromID cid' = w ^?! cWorld . lWorld . creatures . ix cid' . crPos
|
||||
rr a = randomR (- a, a) $ _randGen w
|
||||
hitCr i =
|
||||
( cWorld . creatures . ix i . crState . csDamage
|
||||
( cWorld . lWorld . creatures . ix i . crState . csDamage
|
||||
.:~ Damage BLUNT 100 cpos (posFromID i) (posFromID i) NoDamageEffect
|
||||
)
|
||||
. soundStart (CrSound cid) cpos hitS Nothing
|
||||
|
||||
@@ -21,11 +21,11 @@ import qualified SDL
|
||||
|
||||
useItem :: Creature -> World -> World
|
||||
useItem cr' w = fromMaybe (f w) $ do
|
||||
cr <- w ^? cWorld . creatures . ix (_crID cr')
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix (_crID cr')
|
||||
it <- cr ^? crInv . ix (crSel cr)
|
||||
return $ itemEffect cr it w
|
||||
where
|
||||
f = cWorld . creatures . ix (_crID cr') . crHammerPosition .~ HammerDown
|
||||
f = cWorld . lWorld . creatures . ix (_crID cr') . crHammerPosition .~ HammerDown
|
||||
|
||||
itemEffect :: Creature -> Item -> World -> World
|
||||
itemEffect cr it w = case it ^. itUse of
|
||||
@@ -41,7 +41,7 @@ itemEffect cr it w = case it ^. itUse of
|
||||
hammerTest f = case _crHammerPosition cr of
|
||||
HammerUp -> f w
|
||||
_ -> w & setuhamdown
|
||||
setuhamdown = cWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
||||
setuhamdown = cWorld . lWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
||||
doequipmentchange =
|
||||
setuhamdown $
|
||||
hammerTest
|
||||
@@ -51,7 +51,7 @@ itemEffect cr it w = case it ^. itUse of
|
||||
|
||||
tryReload :: Creature -> Item -> World -> (World -> World) -> World -> World
|
||||
tryReload cr it w f
|
||||
| _crID cr == _yourID (_cWorld w) && itNeedsLoading it && _mouseButtons w M.!? SDL.ButtonLeft == Just False =
|
||||
| _crID cr == (w ^. cWorld . lWorld . yourID) && itNeedsLoading it && _mouseButtons w M.!? SDL.ButtonLeft == Just False =
|
||||
crToggleReloading cr
|
||||
| otherwise =
|
||||
(runIdentity . pointerToItemLocation (_itLocation it) (return . (itUse . heldHammer .~ HammerDown)))
|
||||
@@ -64,7 +64,7 @@ itNeedsLoading it = _laLoaded ic == 0 || not (_laPrimed ic)
|
||||
|
||||
activateEquipmentAt :: RightButtonOptions -> Creature -> World -> World
|
||||
activateEquipmentAt rbo cr =
|
||||
cWorld . creatures . ix (_crID cr) %~ case (rbo ^? opActivateEquipment . activateEquipment, rbo ^? opActivateEquipment . deactivateEquipment) of
|
||||
cWorld . lWorld . creatures . ix (_crID cr) %~ case (rbo ^? opActivateEquipment . activateEquipment, rbo ^? opActivateEquipment . deactivateEquipment) of
|
||||
(Just i, _) -> crLeftInvSel ?~ i
|
||||
(_, Just _) -> crLeftInvSel .~ Nothing
|
||||
_ -> id
|
||||
@@ -102,7 +102,7 @@ toggleEquipmentAt rbops invid cr w = case rbops ^? opAllocateEquipment of
|
||||
& onremove itm cr
|
||||
Nothing -> error "tried to toggle equipment whilst not prepared"
|
||||
where
|
||||
crpoint = cWorld . creatures . ix (_crID cr)
|
||||
crpoint = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
itmat i = _crInv cr IM.! i
|
||||
itm = itmat (crSel cr)
|
||||
onequip itm' = useE ((_eeOnEquip . _equipEffect . _itUse) itm') itm'
|
||||
@@ -122,7 +122,7 @@ useLeftItem cid w
|
||||
. useL f itm cr
|
||||
$ w
|
||||
where
|
||||
cr = _creatures (_cWorld w) IM.! cid
|
||||
cr = w ^?! cWorld . lWorld . creatures . ix cid-- _creatures (_cWorld w) IM.! cid
|
||||
itmIsConsumable =
|
||||
isJust (cr ^? crInv . ix (crSel cr) . itUse . cUse)
|
||||
itmIsEquipable =
|
||||
|
||||
@@ -99,7 +99,7 @@ chaseCritAwarenessUpdate w cr = case _cpAttention $ _crPerception cr of
|
||||
replicate numjits [RandomImpulse thejitter]
|
||||
++ [[ChangeStrategy $ CloseToMelee 0]]
|
||||
)
|
||||
, AimAt 0 (_crPos $ _creatures (_cWorld w) IM.! 0)
|
||||
, AimAt 0 (w ^?! cWorld . lWorld . creatures . ix 0 . crPos) --_crPos $ _creatures (_cWorld w) IM.! 0)
|
||||
]
|
||||
| otherwise = id
|
||||
|
||||
@@ -152,7 +152,7 @@ newExtraAwareness cr w cid
|
||||
| otherwise = Just . Suspicious $ doFloatFloat (_viFOV vi) ang * doFloatFloat (_viDist vi) d * awakeLevelPerception cr
|
||||
where
|
||||
vi = _cpVision $ _crPerception cr
|
||||
tpos = _crPos $ _creatures (_cWorld w) IM.! cid
|
||||
tpos = w ^?! cWorld . lWorld . creatures . ix cid . crPos -- _crPos $ _creatures (_cWorld w) IM.! cid
|
||||
cpos = _crPos cr
|
||||
ang = angleVV (unitVectorAtAngle (_crDir cr)) (tpos - cpos)
|
||||
d = dist tpos cpos
|
||||
|
||||
@@ -27,8 +27,8 @@ creatureDisplayText w cr =
|
||||
w
|
||||
cr
|
||||
where
|
||||
campos = w ^. cWorld . cwCam . cwcViewFrom
|
||||
theScale = 0.15 / (w ^. cWorld . cwCam . cwcZoom)
|
||||
campos = w ^. cWorld . lWorld . cwCam . cwcViewFrom
|
||||
theScale = 0.15 / (w ^. cWorld . lWorld . cwCam . cwcZoom)
|
||||
cpos = _crPos cr
|
||||
v = cpos -.- campos
|
||||
(V2 x y) = campos +.+ v +.+ _crRad cr *.* normalizeV v
|
||||
|
||||
@@ -26,7 +26,6 @@ import Dodge.Data.World
|
||||
import Dodge.Zoning.Creature
|
||||
import FoldableHelp
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
overrideMeleeCloseTarget :: Creature -> Creature
|
||||
overrideMeleeCloseTarget cr = maybe cr (tryMeleeAttack cr) (_targetCr $ _crIntention cr)
|
||||
@@ -192,7 +191,7 @@ targetYouWhenCognizant :: World -> Creature -> Creature
|
||||
targetYouWhenCognizant w cr = case cr ^? crPerception . cpAwareness . ix 0 of
|
||||
-- so this caused a space leak: be careful with ?~
|
||||
-- consider changing targeted creature to be just an index
|
||||
Just (Cognizant _) -> _creatures (_cWorld w) IM.! 0 `seq` cr & crIntention . targetCr ?~ _creatures (_cWorld w) IM.! 0
|
||||
Just (Cognizant _) -> (w ^?! cWorld . lWorld . creatures . ix 0) `seq` cr & crIntention . targetCr ?~ (w ^?! cWorld . lWorld . creatures . ix 0)
|
||||
_ -> cr & crIntention . targetCr .~ Nothing
|
||||
|
||||
searchIfDamaged :: Creature -> Creature
|
||||
|
||||
@@ -3,7 +3,6 @@ module Dodge.Creature.SetTarget where
|
||||
|
||||
import Control.Lens
|
||||
import Dodge.Data.World
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
-- | Assumes that you are id 0: if creature is cognizant of you, sets you as target
|
||||
targetYouWhenCognizant ::
|
||||
@@ -11,5 +10,6 @@ targetYouWhenCognizant ::
|
||||
Creature ->
|
||||
Creature
|
||||
targetYouWhenCognizant w cr = case cr ^? crPerception . cpAwareness . ix 0 of
|
||||
Just (Cognizant _) -> cr & crIntention . targetCr ?~ _creatures (_cWorld w) IM.! 0
|
||||
--Just (Cognizant _) -> cr & crIntention . targetCr ?~ _creatures (_cWorld w) IM.! 0
|
||||
Just (Cognizant _) -> cr & crIntention . targetCr ?~ (w ^?! cWorld . lWorld . creatures . ix 0)
|
||||
_ -> cr & crIntention . targetCr .~ Nothing
|
||||
|
||||
+16
-16
@@ -37,7 +37,7 @@ foldCr ::
|
||||
World
|
||||
foldCr xs cr w = foldl' f w xs
|
||||
where
|
||||
f w' g = case w' ^? cWorld . creatures . ix (_crID cr) of
|
||||
f w' g = case w' ^? cWorld . lWorld . creatures . ix (_crID cr) of
|
||||
Just cr' -> g cr' w'
|
||||
Nothing -> w'
|
||||
|
||||
@@ -85,16 +85,16 @@ checkDeath cr w
|
||||
where
|
||||
removecr
|
||||
| _crID cr == 0 =
|
||||
(cWorld . creatures . ix (_crID cr) . crType .~ NonDrawnCreature)
|
||||
. (cWorld . creatures . ix (_crID cr) . crHP .~ 0)
|
||||
(cWorld . lWorld . creatures . ix (_crID cr) . crType .~ NonDrawnCreature)
|
||||
. (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 . creatures . at (_crID cr) .~ Nothing
|
||||
| otherwise = cWorld . lWorld . creatures . at (_crID cr) .~ Nothing
|
||||
|
||||
corpseOrGib :: Creature -> World -> World
|
||||
corpseOrGib cr w = case maxDamageType (_csDamage (_crState cr)) of
|
||||
Just (FLAMING, _) -> w & plNew (cWorld . corpses) cpID (thecorpse & cpSPic %~ scorchSPic)
|
||||
Just (ELECTRICAL, _) -> w & plNew (cWorld . corpses) cpID thecorpse
|
||||
Just (POISONDAM, _) -> w & plNew (cWorld . corpses) cpID (thecorpse & cpSPic %~ poisonSPic)
|
||||
Just (FLAMING, _) -> w & plNew (cWorld . lWorld . corpses) cpID (thecorpse & cpSPic %~ scorchSPic)
|
||||
Just (ELECTRICAL, _) -> w & plNew (cWorld . lWorld . corpses) cpID thecorpse
|
||||
Just (POISONDAM, _) -> w & plNew (cWorld . lWorld . corpses) cpID (thecorpse & cpSPic %~ poisonSPic)
|
||||
_
|
||||
| _crPastDamage cr > 200 ->
|
||||
w & addCrGibs cr
|
||||
@@ -105,7 +105,7 @@ corpseOrGib cr w = case maxDamageType (_csDamage (_crState cr)) of
|
||||
w
|
||||
& bloodPuddleAt cpos
|
||||
& bloodPuddleAt cpos
|
||||
& plNew (cWorld . corpses) cpID thecorpse
|
||||
& plNew (cWorld . lWorld . corpses) cpID thecorpse
|
||||
where
|
||||
cpos = _crPos cr
|
||||
thecorpse = makeDefaultCorpse cr
|
||||
@@ -132,7 +132,7 @@ bloodPuddleAt p w =
|
||||
w
|
||||
& snd
|
||||
. plNewID
|
||||
(cWorld . decorations)
|
||||
(cWorld . lWorld . decorations)
|
||||
(color (dark $ dark red) . setDepth 01 . uncurryV translate (p +.+ q) $ circleSolid 10)
|
||||
& randGen .~ g
|
||||
where
|
||||
@@ -140,7 +140,7 @@ bloodPuddleAt p w =
|
||||
|
||||
internalUpdate :: Creature -> World -> World
|
||||
internalUpdate cr =
|
||||
cWorld . creatures . ix (_crID cr)
|
||||
cWorld . lWorld . creatures . ix (_crID cr)
|
||||
%~ ( (crHammerPosition %~ moveHammerUp)
|
||||
. stepReloading
|
||||
. updateMovement
|
||||
@@ -158,7 +158,7 @@ dropByState cr w = foldr (dropItem cr) w $ case cr ^. crState . csDropsOnDeath o
|
||||
clearDamage :: Creature -> World -> World
|
||||
clearDamage cr w =
|
||||
w
|
||||
& cWorld . creatures . ix (_crID cr) . crState . csDamage .~ []
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) . crState . csDamage .~ []
|
||||
|
||||
doDamage :: Creature -> World -> World
|
||||
doDamage cr w =
|
||||
@@ -173,15 +173,15 @@ applyPastDamages :: Creature -> World -> World
|
||||
applyPastDamages cr w
|
||||
| _crPastDamage cr > 200 =
|
||||
let (p, g) = runState (randInCirc 3) (_randGen w)
|
||||
in w & cWorld . creatures . ix (_crID cr) %~ (crMvBy p . (crPastDamage -~ 100))
|
||||
in w & cWorld . lWorld . creatures . ix (_crID cr) %~ (crMvBy p . (crPastDamage -~ 100))
|
||||
& randGen .~ g
|
||||
| _crPastDamage cr > 20 =
|
||||
let (p, g) = runState (randInCirc 2) (_randGen w)
|
||||
in w & cWorld . creatures . ix (_crID cr) %~ (crMvBy p . (crPastDamage -~ 10))
|
||||
in w & cWorld . lWorld . creatures . ix (_crID cr) %~ (crMvBy p . (crPastDamage -~ 10))
|
||||
& randGen .~ g
|
||||
| _crPastDamage cr > 0 =
|
||||
let (p, g) = runState (randInCirc 1) (_randGen w)
|
||||
in w & cWorld . creatures . ix (_crID cr) %~ (crMvBy p . (crPastDamage -~ 1))
|
||||
in w & cWorld . lWorld . creatures . ix (_crID cr) %~ (crMvBy p . (crPastDamage -~ 1))
|
||||
& randGen .~ g
|
||||
| otherwise = w
|
||||
|
||||
@@ -225,7 +225,7 @@ useEquipment cr i = useE (_eeUse (_equipEffect $ _itUse itm)) itm cr
|
||||
|
||||
-- a map updating all inventory items
|
||||
upInv :: Creature -> World -> World
|
||||
upInv cr = cWorld . creatures . ix (_crID cr) . crInv %~ IM.mapWithKey (itemUpdate cr)
|
||||
upInv cr = cWorld . lWorld . creatures . ix (_crID cr) . crInv %~ IM.mapWithKey (itemUpdate cr)
|
||||
|
||||
-- a loop going over equipped items
|
||||
equipmentEffects :: Creature -> World -> World
|
||||
@@ -275,7 +275,7 @@ doItemTargeting invid cr w = case cr ^? crInv . ix invid . itTargeting of
|
||||
Just NoTargeting -> w
|
||||
Just t ->
|
||||
let (w', t') = updateTargeting (_tgUpdate t) (_crInv cr IM.! invid) cr w t
|
||||
in w' & cWorld . creatures . ix (_crID cr) . crInv . ix invid . itTargeting .~ t'
|
||||
in w' & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itTargeting .~ t'
|
||||
|
||||
weaponReloadSounds :: Creature -> World -> World
|
||||
weaponReloadSounds cr w = case cr ^? crInvSel . iselAction of
|
||||
|
||||
@@ -21,12 +21,12 @@ yourControl cr w
|
||||
| inTermFocus w = dimCreatureLight cr w & updateUsingInput
|
||||
| otherwise =
|
||||
dimCreatureLight cr w
|
||||
& cWorld . creatures . ix (_crID cr)
|
||||
& cWorld . lWorld . creatures . ix (_crID cr)
|
||||
%~ (wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons w))
|
||||
& updateUsingInput
|
||||
|
||||
dimCreatureLight :: Creature -> World -> World
|
||||
dimCreatureLight cr = cWorld . tempLightSources .:~ tlsTimeRadColPos 1 300 0.1 (addZ 100 $ _crPos cr)
|
||||
dimCreatureLight cr = cWorld . lWorld . tempLightSources .:~ tlsTimeRadColPos 1 300 0.1 (addZ 100 $ _crPos cr)
|
||||
|
||||
-- note the order of operation, setting the posture first--this prevents the twist fire bug
|
||||
|
||||
@@ -57,12 +57,12 @@ wasdWithAiming w speed cr
|
||||
| otherwise = crMvAbsolute (speed *.* movAbs) . set crMvDir dir
|
||||
theTurn cr' = creatureTurnTowardDir (_crMvDir cr') 0.2 cr'
|
||||
movDir = wasdDir w
|
||||
dir = (w ^. cWorld . cwCam . cwcRot) + argV movDir
|
||||
movAbs = rotateV (w ^. cWorld . cwCam . cwcRot) $ normalizeV movDir
|
||||
dir = (w ^. cWorld . lWorld . cwCam . cwcRot) + argV movDir
|
||||
movAbs = rotateV (w ^. cWorld . lWorld . cwCam . cwcRot) $ normalizeV movDir
|
||||
isAiming = _posture (_crStance cr) == Aiming
|
||||
mouseDir = case cr ^? crInv . ix (crSel cr) . itScope . scopePos of
|
||||
Just _ -> argV $ mouseWorldPos w -.- _crPos cr
|
||||
_ -> argV (_mousePos w) + (w ^. cWorld . cwCam . cwcRot)
|
||||
_ -> argV (_mousePos w) + (w ^. cWorld . lWorld . cwCam . cwcRot)
|
||||
|
||||
wasdM :: SDL.Scancode -> Point2
|
||||
wasdM scancode = case scancode of
|
||||
|
||||
Reference in New Issue
Block a user