Refactor crPos to be a V3

This commit is contained in:
2025-10-10 13:47:31 +01:00
parent 98ece551c7
commit 49fb982877
58 changed files with 375 additions and 307 deletions
+1 -1
View File
@@ -1 +1 @@
3392801227273840162 7114951007332849727
+5 -4
View File
@@ -2,6 +2,7 @@
module Dodge.Barreloid (updateBarreloid) where module Dodge.Barreloid (updateBarreloid) where
import Linear
import Data.List import Data.List
import Data.Maybe import Data.Maybe
import Dodge.Creature.State import Dodge.Creature.State
@@ -29,16 +30,16 @@ updateExpBarrel ps cr w = case cr ^. crHP of
& flip (foldl' f) ps & flip (foldl' f) ps
HP _ -> HP _ ->
w w
& makeExplosionAt ((cr ^. crPos) `v2z` 20) 0 & makeExplosionAt ((cr ^. crPos) & _z +~ 20) 0
& cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ CrIsGibs & cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ CrIsGibs
_ -> w _ -> w
where where
f w' p = makeSpark NormalSpark (p + normalizeV p + cr ^. crPos) (argV p) w' f w' p = makeSpark NormalSpark (p + normalizeV p + cr ^. crPos . _xy) (argV p) w'
damages = cr ^. crDamage damages = cr ^. crDamage
hiss hiss
| null ps = id | null ps = id
| otherwise = soundContinue | otherwise = soundContinue
(BarrelHiss (_crID cr)) (_crPos cr) foamSprayLoopS (Just 1) (BarrelHiss (_crID cr)) (cr ^. crPos . _xy) foamSprayLoopS (Just 1)
updateBarrel :: Creature -> World -> World updateBarrel :: Creature -> World -> World
updateBarrel cr = case cr ^. crHP of updateBarrel cr = case cr ^. crHP of
@@ -53,7 +54,7 @@ damToExpBarrel :: Creature -> Damage -> Creature
damToExpBarrel cr dm = case dm of damToExpBarrel cr dm = case dm of
Piercing x p _ -> Piercing x p _ ->
cr & crHP . _HP -~ div x 200 cr & crHP . _HP -~ div x 200
& crType . barrelType . piercedPoints .:~ (p - _crPos cr) & crType . barrelType . piercedPoints .:~ (p - cr ^. crPos . _xy)
Poison{} -> cr Poison{} -> cr
Sparking{} -> cr Sparking{} -> cr
_ -> cr & crHP . _HP -~ fromMaybe 0 (dm ^? dmAmount) _ -> cr & crHP . _HP -~ fromMaybe 0 (dm ^? dmAmount)
+10 -11
View File
@@ -37,6 +37,7 @@ module Dodge.Base.Collide (
collide3, collide3,
) where ) where
import Linear
import Control.Lens import Control.Lens
import Control.Monad import Control.Monad
import qualified Data.IntSet as IS import qualified Data.IntSet as IS
@@ -60,7 +61,7 @@ overlapSegCrs :: Point2 -> Point2 -> [Creature] -> [(Point2, Creature)]
{-# INLINE overlapSegCrs #-} {-# INLINE overlapSegCrs #-}
overlapSegCrs sp ep = overlapSegCrs sp ep =
mapMaybe mapMaybe
(\cr -> (,cr) <$> listToMaybe (intersectCircSeg (_crPos cr) (crRad $ cr ^. crType) sp ep)) (\cr -> (,cr) <$> listToMaybe (intersectCircSeg (cr ^. crPos . _xy) (crRad $ cr ^. crType) sp ep))
doBounce :: Float -> Point2 -> Point2 -> (Point2, Maybe Wall) -> Maybe (Point2, Point2) doBounce :: Float -> Point2 -> Point2 -> (Point2, Maybe Wall) -> Maybe (Point2, Point2)
{-# INLINE doBounce #-} {-# INLINE doBounce #-}
@@ -125,7 +126,7 @@ collide3 sp ep w =
-- Just (hitpoint,normaltosurface) -- Just (hitpoint,normaltosurface)
collide3Walls :: Point3 -> World -> (Point3, MPO) -> (Point3, MPO) collide3Walls :: Point3 -> World -> (Point3, MPO) -> (Point3, MPO)
collide3Walls sp w ex@(ep, _) = foldl' f ex wls collide3Walls sp w e@(ep, _) = foldl' f e wls
where where
f x wl = collide3Wall sp wl x f x wl = collide3Wall sp wl x
wls = wlsNearSeg (xyV3 sp) (xyV3 ep) w wls = wlsNearSeg (xyV3 sp) (xyV3 ep) w
@@ -153,14 +154,12 @@ collide3Creature :: Point3 -> Creature -> (Point3, MPO) -> (Point3, MPO)
collide3Creature sp cr (ep, m) = fromMaybe (ep, m) $ do collide3Creature sp cr (ep, m) = fromMaybe (ep, m) $ do
h <- crHeight cr h <- crHeight cr
(p,n) <- fst $ intersectCylSeg (p,n) <- fst $ intersectCylSeg
(addZ (cr ^. crZ) cpos) (cr ^. crPos)
(crRad $ cr ^. crType) (crRad $ cr ^. crType)
h h
sp sp
ep ep
return (p, Just (n,OCreature cr)) return (p, Just (n,OCreature cr))
where
cpos = cr ^. crPos
crHeight :: Creature -> Maybe Float crHeight :: Creature -> Maybe Float
crHeight cr = case cr ^. crHP of crHeight cr = case cr ^. crHP of
@@ -288,7 +287,7 @@ circOnAnyCr :: Point2 -> Float -> World -> Bool
{-# INLINE circOnAnyCr #-} {-# INLINE circOnAnyCr #-}
circOnAnyCr p r w = IS.foldr f False $ crIXsNearPoint p w circOnAnyCr p r w = IS.foldr f False $ crIXsNearPoint p w
where where
f cid bl = maybe False (\cr -> dist p (_crPos cr) < r + crRad (cr ^. crType)) (w ^? cWorld . lWorld . creatures . ix cid) || bl f cid bl = maybe False (\cr -> dist p (cr ^. crPos . _xy) < r + crRad (cr ^. crType)) (w ^? cWorld . lWorld . creatures . ix cid) || bl
-- | More general collision tests follow -- | More general collision tests follow
hasLOS :: Point2 -> Point2 -> World -> Bool hasLOS :: Point2 -> Point2 -> World -> Bool
@@ -325,15 +324,15 @@ canSee :: Int -> Int -> World -> Bool
{-# INLINE canSee #-} {-# INLINE canSee #-}
canSee i j w = hasLOS p1 p2 w canSee i j w = hasLOS p1 p2 w
where where
p1 = w ^?! cWorld . lWorld . creatures . ix i . crPos -- _crPos (_creatures (_cWorld w) IM.! i) p1 = w ^?! cWorld . lWorld . creatures . ix i . crPos . _xy -- _crPos (_creatures (_cWorld w) IM.! i)
p2 = w ^?! cWorld . lWorld . creatures . ix j . crPos -- _crPos (_creatures (_cWorld w) IM.! j) -- unsafe p2 = w ^?! cWorld . lWorld . creatures . ix j . crPos . _xy -- _crPos (_creatures (_cWorld w) IM.! j) -- unsafe
canSeeIndirect :: Int -> Int -> World -> Bool canSeeIndirect :: Int -> Int -> World -> Bool
{-# INLINE canSeeIndirect #-} {-# INLINE canSeeIndirect #-}
canSeeIndirect i j w = hasLOSIndirect ipos jpos w canSeeIndirect i j w = hasLOSIndirect ipos jpos w
where where
ipos = w ^?! cWorld . lWorld . creatures . ix i . crPos ipos = w ^?! cWorld . lWorld . creatures . ix i . crPos . _xy
jpos = w ^?! cWorld . lWorld . creatures . ix j . crPos jpos = w ^?! cWorld . lWorld . creatures . ix j . crPos . _xy
anythingHitCirc :: Float -> Point2 -> Point2 -> World -> Bool anythingHitCirc :: Float -> Point2 -> Point2 -> World -> Bool
anythingHitCirc rad sp ep w = hitCr || circHitWall sp ep rad w anythingHitCirc rad sp ep w = hitCr || circHitWall sp ep rad w
@@ -345,7 +344,7 @@ anythingHitCirc rad sp ep w = hitCr || circHitWall sp ep rad w
f cid bl = f cid bl =
maybe maybe
False False
(\cr -> intersectCircSegTest (_crPos cr) (rad + crRad (cr ^. crType)) sp ep) (\cr -> intersectCircSegTest (cr ^. crPos . _xy) (rad + crRad (cr ^. crType)) sp ep)
(w ^? cWorld . lWorld . creatures . ix cid) (w ^? cWorld . lWorld . creatures . ix cid)
|| bl || bl
+3 -1
View File
@@ -17,6 +17,7 @@ import Geometry
import LensHelp import LensHelp
import qualified ListHelp as List import qualified ListHelp as List
import System.Random import System.Random
import Linear
updateBullet :: World -> Bullet -> (World, Maybe Bullet) updateBullet :: World -> Bullet -> (World, Maybe Bullet)
updateBullet w bu updateBullet w bu
@@ -108,7 +109,8 @@ updateBulVel bt = bt & buVel .*.*~ _buDrag bt
bounceDir :: IM.IntMap Item -> (Point2, Either Creature Wall) -> Maybe Point2 bounceDir :: IM.IntMap Item -> (Point2, Either Creature Wall) -> Maybe Point2
bounceDir _ (_, Right wl) | _wlBouncy wl = Just $ uncurry (-) (_wlLine wl) bounceDir _ (_, Right wl) | _wlBouncy wl = Just $ uncurry (-) (_wlLine wl)
bounceDir m (p, Left cr) | crIsArmouredFrom m p cr = Just $ vNormal $ p - _crPos cr bounceDir m (p, Left cr) | crIsArmouredFrom m p cr
= Just $ vNormal $ p - (cr ^. crPos . _xy)
bounceDir _ _ = Nothing bounceDir _ _ = Nothing
useBulletPayload :: Bullet -> Point2 -> World -> World useBulletPayload :: Bullet -> Point2 -> World -> World
+2 -2
View File
@@ -92,8 +92,8 @@ ID 0.
startCr :: Creature startCr :: Creature
startCr = startCr =
defaultCreature defaultCreature
& crPos .~ V2 20 0 & crPos .~ V3 20 0 0
& crOldPos .~ V2 20 0 & crOldPos .~ V3 20 0 0
& crDir .~ pi / 2 & crDir .~ pi / 2
& crMvDir .~ pi / 2 & crMvDir .~ pi / 2
& crID .~ 0 & crID .~ 0
+10 -9
View File
@@ -13,6 +13,7 @@ module Dodge.Creature.Action (
youDropItem, youDropItem,
) where ) where
import Linear
import NewInt import NewInt
import Dodge.Creature.MoveType import Dodge.Creature.MoveType
import Dodge.Creature.Radius import Dodge.Creature.Radius
@@ -49,13 +50,13 @@ performAimAt :: Creature -> World -> Int -> Point2 -> OutAction
performAimAt cr w tcid p = ([TurnToward tpos aimSp], Just $ AimAt tcid tpos) performAimAt cr w tcid p = ([TurnToward tpos aimSp], Just $ AimAt tcid tpos)
where where
cdir = _crDir cr cdir = _crDir cr
cpos = _crPos cr cpos = cr ^. crPos . _xy
canSee' = canSee (_crID cr) tcid w canSee' = canSee (_crID cr) tcid w
aimSp = case crMvType cr ^? mvAimSpeed of aimSp = case crMvType cr ^? mvAimSpeed of
Just f -> doFloatFloat f $ safeAngleVV (unitVectorAtAngle cdir) (tpos - cpos) Just f -> doFloatFloat f $ safeAngleVV (unitVectorAtAngle cdir) (tpos - cpos)
Nothing -> error "creature without aiming type" Nothing -> error "creature without aiming type"
tpos tpos
| canSee' = w ^?! cWorld . lWorld . creatures . ix tcid . crPos | canSee' = w ^?! cWorld . lWorld . creatures . ix tcid . crPos . _xy
| otherwise = p | otherwise = p
performPathTo :: Creature -> World -> Point2 -> OutAction performPathTo :: Creature -> World -> Point2 -> OutAction
@@ -73,7 +74,7 @@ performPathTo cr w p
) )
_ -> ([], Nothing) _ -> ([], Nothing)
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
jit = _mvTurnJit $ crMvType cr jit = _mvTurnJit $ crMvType cr
performTurnToA :: Creature -> Point2 -> OutAction performTurnToA :: Creature -> Point2 -> OutAction
@@ -81,7 +82,7 @@ performTurnToA cr p
| angleVV cdirv dirv < 0.1 = ([], Nothing) | angleVV cdirv dirv < 0.1 = ([], Nothing)
| otherwise = ([MvTurnToward p, RandomTurn jit], Just (TurnToPoint p)) | otherwise = ([MvTurnToward p, RandomTurn jit], Just (TurnToPoint p))
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
cdirv = unitVectorAtAngle (_crDir cr) cdirv = unitVectorAtAngle (_crDir cr)
dirv = p -.- cpos dirv = p -.- cpos
jit = _mvTurnJit $ crMvType cr jit = _mvTurnJit $ crMvType cr
@@ -121,15 +122,15 @@ performAction cr w ac = case ac of
DoActions acs -> DoActions acs ->
let (imps, newAcs) = unzip $ map (performAction cr w) acs let (imps, newAcs) = unzip $ map (performAction cr w) acs
in (concat imps, Just . DoActions $ catMaybes newAcs) in (concat imps, Just . DoActions $ catMaybes newAcs)
StartSentinelPost -> ([AddGoal $ SentinelAt (_crPos cr) (_crDir cr)], Nothing) StartSentinelPost -> ([AddGoal $ SentinelAt (cr ^. crPos . _xy) (_crDir cr)], Nothing)
PathTo p -> performPathTo cr w p PathTo p -> performPathTo cr w p
TurnToPoint p -> performTurnToA cr p TurnToPoint p -> performTurnToA cr p
LeadTarget p -> case cr ^? crIntention . targetCr . _Just of LeadTarget p -> case cr ^? crIntention . targetCr . _Just of
Just tcr -> ([TurnTo (_crPos tcr +.+ rotateV (_crDir tcr) p)], Nothing) Just tcr -> ([TurnTo (tcr ^. crPos . _xy +.+ rotateV (_crDir tcr) p)], Nothing)
_ -> ([], Nothing) _ -> ([], Nothing)
UseTarget f -> performAction cr w $ doMCrAc f $ cr ^? crIntention . targetCr . _Just UseTarget f -> performAction cr w $ doMCrAc f $ cr ^? crIntention . targetCr . _Just
UseSelf f -> performAction cr w $ doCrAc f cr UseSelf f -> performAction cr w $ doCrAc f cr
UseAheadPos f -> performAction cr w (doP2Ac f (_crPos cr +.+ 20 *.* unitVectorAtAngle (_crDir cr))) UseAheadPos f -> performAction cr w (doP2Ac f (cr ^. crPos . _xy +.+ 20 *.* unitVectorAtAngle (_crDir cr)))
UseMvTargetPos f -> performAction cr w $ doMP2Ac f $ _mvToPoint $ _crIntention cr UseMvTargetPos f -> performAction cr w $ doMP2Ac f $ _mvToPoint $ _crIntention cr
ArbitraryAction f -> performAction cr w (doCrWdAc f cr w) ArbitraryAction f -> performAction cr w (doCrWdAc f cr w)
DoImpulsesAlongside sideImp mainAc -> case performAction cr w mainAc of DoImpulsesAlongside sideImp mainAc -> case performAction cr w mainAc of
@@ -175,10 +176,10 @@ dropItem :: Creature -> Int -> World -> World
dropItem cr invid w' = dropItem cr invid w' =
doanyitemdropeffect doanyitemdropeffect
. maybeshiftseldown . maybeshiftseldown
. copyItemToFloor (_crPos cr) itm -- . mayberemoveequip . copyItemToFloor (cr ^. crPos . _xy) itm -- . mayberemoveequip
. rmInvItem (_crID cr) (NInt invid) -- it is important . rmInvItem (_crID cr) (NInt invid) -- it is important
-- to do this before copying the item to the floor! -- to do this before copying the item to the floor!
. soundStart (CrSound (_crID cr)) (_crPos cr) whiteNoiseFadeOutS Nothing . soundStart (CrSound (_crID cr)) (cr ^. crPos . _xy) whiteNoiseFadeOutS Nothing
$ w' $ w'
where where
--doanyitemdropeffect = fromMaybe id $ do --doanyitemdropeffect = fromMaybe id $ do
+7 -6
View File
@@ -5,6 +5,7 @@ module Dodge.Creature.Action.Blink (
unsafeBlinkAction, unsafeBlinkAction,
) where ) where
import Linear
import Dodge.Creature.Radius import Dodge.Creature.Radius
import Dodge.Zoning.Wall import Dodge.Zoning.Wall
import Data.Maybe import Data.Maybe
@@ -25,13 +26,13 @@ blinkActionMousePos cr w =
w w
& soundMultiFrom [TeleSound 0, TeleSound 1] p3 teleS Nothing & soundMultiFrom [TeleSound 0, TeleSound 1] p3 teleS Nothing
& blinkDistortions cpos p3 & blinkDistortions cpos p3
& cWorld . lWorld . creatures . ix cid . crPos .~ p3 & cWorld . lWorld . creatures . ix cid . crPos . _xy .~ p3
& blinkShockwave cid p3 & blinkShockwave cid p3
& inverseShockwaveAt (cpos `v2z` 20) 40 2 2 & inverseShockwaveAt (cpos `v2z` 20) 40 2 2
where where
cid = _crID cr cid = _crID cr
p1 = w ^. cWorld . lWorld . lAimPos p1 = w ^. cWorld . lWorld . lAimPos
cpos = _crPos cr cpos = cr ^. crPos . _xy
--p2 = bouncePoint (const True) 1 cpos p1 w --p2 = bouncePoint (const True) 1 cpos p1 w
p2 = pushIntoMaybe $ collideCircWalls cpos p1 r (wlsNearSeg cpos p1 w) p2 = pushIntoMaybe $ collideCircWalls cpos p1 r (wlsNearSeg cpos p1 w)
r = crRad $ cr ^. crType r = crRad $ cr ^. crType
@@ -61,7 +62,7 @@ unsafeBlinkAction cr w
| success = | success =
soundMultiFrom [TeleSound 0, TeleSound 1] mwp teleS Nothing soundMultiFrom [TeleSound 0, TeleSound 1] mwp teleS Nothing
. blinkDistortions cpos mwp . blinkDistortions cpos mwp
. set (cWorld . lWorld . creatures . ix cid . crPos) mwp . set (cWorld . lWorld . creatures . ix cid . crPos . _xy) mwp
. blinkShockwave cid mwp . blinkShockwave cid mwp
$ inverseShockwaveAt (cpos `v2z` 20) 40 2 2 w $ inverseShockwaveAt (cpos `v2z` 20) 40 2 2 w
| otherwise = | otherwise =
@@ -74,7 +75,7 @@ unsafeBlinkAction cr w
return (isLHS mwp `uncurry` _wlLine wl) return (isLHS mwp `uncurry` _wlLine wl)
cid = _crID cr cid = _crID cr
mwp = w ^. cWorld . lWorld . lAimPos mwp = w ^. cWorld . lWorld . lAimPos
cpos = _crPos cr cpos = cr ^. crPos . _xy
blinkShockwave :: blinkShockwave ::
-- | Blinking creature ID. -- | Blinking creature ID.
@@ -93,14 +94,14 @@ blinkActionFail cr w =
w w
& soundMultiFrom [TeleSound 0, TeleSound 1] p3 teleS Nothing & soundMultiFrom [TeleSound 0, TeleSound 1] p3 teleS Nothing
& cWorld . lWorld . distortions .:~ distortionBulge & cWorld . lWorld . distortions .:~ distortionBulge
& cWorld . lWorld . creatures . ix cid . crPos .~ p3 & cWorld . lWorld . creatures . ix cid . crPos . _xy .~ p3
& inverseShockwaveAt (cpos `v2z` 20) 40 2 2 & inverseShockwaveAt (cpos `v2z` 20) 40 2 2
where where
distR = 120 distR = 120
distortionBulge = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9 distortionBulge = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9
cid = _crID cr cid = _crID cr
p1 = w ^. cWorld . lWorld . lAimPos p1 = w ^. cWorld . lWorld . lAimPos
cpos = _crPos cr cpos = cr ^. crPos . _xy
p2 = bouncePoint (const True) 1 cpos p1 w p2 = bouncePoint (const True) 1 cpos p1 w
r = 1.5 * crRad (cr ^. crType) r = 1.5 * crRad (cr ^. crType)
p3 = maybe p1 (mvPointTowardAtSpeed r cpos . fst) p2 p3 = maybe p1 (mvPointTowardAtSpeed r cpos . fst) p2
+44 -40
View File
@@ -1,5 +1,6 @@
module Dodge.Creature.Boid where module Dodge.Creature.Boid where
import Linear
import Dodge.Creature.Radius import Dodge.Creature.Radius
import Control.Lens import Control.Lens
import Control.Monad.Reader import Control.Monad.Reader
@@ -16,28 +17,28 @@ invertEncircleDistP d tcr cenp cr =
ypos ypos
+.+ d *.* reflectIn (cenp -.- ypos) (squashNormalizeV (cpos -.- cenp)) +.+ d *.* reflectIn (cenp -.- ypos) (squashNormalizeV (cpos -.- cenp))
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
ypos = _crPos tcr ypos = tcr ^. crPos . _xy
encircleDistP :: Float -> Creature -> Point2 -> Creature -> Point2 encircleDistP :: Float -> Creature -> Point2 -> Creature -> Point2
encircleDistP d tcr cenp cr = ypos +.+ d *.* squashNormalizeV (cpos -.- cenp) encircleDistP d tcr cenp cr = ypos +.+ d *.* squashNormalizeV (cpos -.- cenp)
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
ypos = _crPos tcr ypos = tcr ^. crPos . _xy
encircleP :: Creature -> Point2 -> Creature -> Point2 encircleP :: Creature -> Point2 -> Creature -> Point2
encircleP tcr cenp cr = ypos +.+ 50 *.* squashNormalizeV (cpos -.- cenp) encircleP tcr cenp cr = ypos +.+ 50 *.* squashNormalizeV (cpos -.- cenp)
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
ypos = _crPos tcr ypos = tcr ^. crPos . _xy
--f x = 150 * sigmoid (x-10) --f x = 150 * sigmoid (x-10)
encircleCloseP :: Creature -> Point2 -> Creature -> Point2 encircleCloseP :: Creature -> Point2 -> Creature -> Point2
encircleCloseP tcr cenp cr = ypos +.+ f (max 0 (magV (ypos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp) encircleCloseP tcr cenp cr = ypos +.+ f (max 0 (magV (ypos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp)
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
ypos = _crPos tcr ypos = tcr ^. crPos . _xy
f x = 150 * sigmoid (x -10) f x = 150 * sigmoid (x -10)
forbidFlee :: forbidFlee ::
@@ -50,8 +51,8 @@ forbidFlee f tcr cenp cr
| ptargTest = tpos | ptargTest = tpos
| otherwise = ptarg | otherwise = ptarg
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
tpos = _crPos tcr tpos = tcr ^. crPos . _xy
ptarg = f tcr cenp cr ptarg = f tcr cenp cr
ptargTest = isLHS cpos (cpos +.+ rotateV (negate (pi / 2)) (cpos -.- tpos)) ptarg ptargTest = isLHS cpos (cpos +.+ rotateV (negate (pi / 2)) (cpos -.- tpos)) ptarg
@@ -61,8 +62,8 @@ forbidFlee f tcr cenp cr
pincerP :: Creature -> Point2 -> Creature -> Point2 pincerP :: Creature -> Point2 -> Creature -> Point2
pincerP tcr cenp cr = tpos +.+ splitp -- +.+ 25 *.* (normalizeV $ tpos -.- cenp) pincerP tcr cenp cr = tpos +.+ splitp -- +.+ 25 *.* (normalizeV $ tpos -.- cenp)
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
tpos = _crPos tcr tpos = tcr ^. crPos . _xy
splitp splitp
| isLHS cenp cpos tpos = | isLHS cenp cpos tpos =
150 *.* orthCenpTpos 150 *.* orthCenpTpos
@@ -75,8 +76,8 @@ pincerP tcr cenp cr = tpos +.+ splitp -- +.+ 25 *.* (normalizeV $ tpos -.- cenp)
pincerP''' :: Creature -> Point2 -> Creature -> Point2 pincerP''' :: Creature -> Point2 -> Creature -> Point2
pincerP''' tcr cenp cr = interpWith (sigmoid $ 0.05 * dtcen) cenawayp cenclosep pincerP''' tcr cenp cr = interpWith (sigmoid $ 0.05 * dtcen) cenawayp cenclosep
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
tpos = _crPos tcr tpos = tcr ^. crPos . _xy
dtcen = dist tpos cenp dtcen = dist tpos cenp
f x = 150 * sigmoid (x -10) f x = 150 * sigmoid (x -10)
cenawayp cenawayp
@@ -97,8 +98,8 @@ pincerP' tcr cenp cr
cenp +.+ f (max 0 (magV (tpos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp) cenp +.+ f (max 0 (magV (tpos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp)
| otherwise = tpos +.+ f (max 0 (magV (tpos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp) | otherwise = tpos +.+ f (max 0 (magV (tpos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp)
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
tpos = _crPos tcr tpos = tcr ^. crPos . _xy
f x = 150 * sigmoid (x -10) f x = 150 * sigmoid (x -10)
pincerP'' :: Creature -> Point2 -> Creature -> Point2 pincerP'' :: Creature -> Point2 -> Creature -> Point2
@@ -109,8 +110,8 @@ pincerP'' tcr cenp cr
cenp +.+ f (max 0 (magV (tpos -.- cenp) - 80)) *.* squashNormalizeV (vNormal $ cenp -.- tpos) cenp +.+ f (max 0 (magV (tpos -.- cenp) - 80)) *.* squashNormalizeV (vNormal $ cenp -.- tpos)
| otherwise = tpos +.+ f (max 0 (magV (tpos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp) | otherwise = tpos +.+ f (max 0 (magV (tpos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp)
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
tpos = _crPos tcr tpos = tcr ^. crPos . _xy
f x = 150 * sigmoid (x -10) f x = 150 * sigmoid (x -10)
encircle :: Creature -> IM.IntMap Creature -> Creature -> Point2 encircle :: Creature -> IM.IntMap Creature -> Creature -> Point2
@@ -118,17 +119,17 @@ encircle tcr crs cr
| length crs <= 1 = ypos | length crs <= 1 = ypos
| otherwise = ypos +.+ f (max 0 (magV (ypos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp) | otherwise = ypos +.+ f (max 0 (magV (ypos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp)
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
ypos = _crPos tcr ypos = tcr ^. crPos . _xy
f x = 150 * sigmoid (x -10) f x = 150 * sigmoid (x -10)
cenp = centroid (map _crPos $ IM.elems crs) cenp = centroid (map (^. crPos . _xy) $ IM.elems crs)
lineOrth :: Creature -> IM.IntMap Creature -> Creature -> Point2 lineOrth :: Creature -> IM.IntMap Creature -> Creature -> Point2
lineOrth tcr crs cr = p lineOrth tcr crs cr = p
where where
ypos = _crPos tcr ypos = tcr ^. crPos . _xy
cpos = _crPos cr cpos = cr ^. crPos . _xy
ps = map _crPos $ IM.elems crs ps = map (^. crPos . _xy) $ IM.elems crs
cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps
p p
| dist cen ypos < 20 = ypos | dist cen ypos < 20 = ypos
@@ -137,10 +138,11 @@ lineOrth tcr crs cr = p
holdForm :: Creature -> IM.IntMap Creature -> Creature -> Point2 holdForm :: Creature -> IM.IntMap Creature -> Creature -> Point2
holdForm ycr crs cr = p holdForm ycr crs cr = p
where where
ypos = _crPos ycr ypos = ycr ^. crPos . _xy
cpos = _crPos cr cpos = cr ^. crPos . _xy
ps = map _crPos $ IM.elems crs ps = map (^. crPos . _xy) $ IM.elems crs
cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps cen = centroid ps
--cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps
p p
| dist cen ypos < 20 = ypos | dist cen ypos < 20 = ypos
| otherwise = ypos +.+ cpos -.- cen | otherwise = ypos +.+ cpos -.- cen
@@ -148,20 +150,22 @@ holdForm ycr crs cr = p
lineUp :: Creature -> IM.IntMap Creature -> Creature -> Point2 lineUp :: Creature -> IM.IntMap Creature -> Creature -> Point2
lineUp ycr crs cr = p lineUp ycr crs cr = p
where where
ypos = _crPos ycr ypos = ycr ^. crPos . _xy
cpos = _crPos cr cpos = cr ^. crPos . _xy
ps = map _crPos $ IM.elems crs ps = map (^. crPos . _xy) $ IM.elems crs
cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps --cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps
cen = centroid ps
p = (0.05 *.* ypos) +.+ (0.95 *.* errorClosestPointOnLine 500 cen ypos cpos) p = (0.05 *.* ypos) +.+ (0.95 *.* errorClosestPointOnLine 500 cen ypos cpos)
-- not nice, a kind of encircle -- not nice, a kind of encircle
spreadOut :: Creature -> IM.IntMap Creature -> Creature -> Point2 spreadOut :: Creature -> IM.IntMap Creature -> Creature -> Point2
spreadOut ycr crs cr = p spreadOut ycr crs cr = p
where where
ypos = _crPos ycr ypos = ycr ^. crPos . _xy
cpos = _crPos cr cpos = cr ^. crPos . _xy
ps = map _crPos $ IM.elems crs ps = map (^. crPos . _xy) $ IM.elems crs
cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps cen = centroid ps
-- cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps
p p
| dist cen ypos < 30 = ypos | dist cen ypos < 30 = ypos
| otherwise = ypos +.+ (spreadFactor *.* cpos -.- cen) | otherwise = ypos +.+ (spreadFactor *.* cpos -.- cen)
@@ -307,8 +311,8 @@ meleeHeadingMove maxta minta tacutoff speed tp cr tcr
[MoveForward speed, TurnToward tp maxta, RandomTurn maxta] [MoveForward speed, TurnToward tp maxta, RandomTurn maxta]
| otherwise = [MoveForward speed, TurnToward tp minta, RandomTurn maxta] | otherwise = [MoveForward speed, TurnToward tp minta, RandomTurn maxta]
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
tpos = _crPos tcr tpos = tcr ^. crPos . _xy
combinedRad = crRad (cr ^. crType) + crRad (tcr ^. crType) combinedRad = crRad (cr ^. crType) + crRad (tcr ^. crType)
mvPointMeleeTarg :: Point2 -> Creature -> Creature -> [Impulse] mvPointMeleeTarg :: Point2 -> Creature -> Creature -> [Impulse]
@@ -324,6 +328,6 @@ mvPointMeleeTarg p cr crT
[MoveForward 3, TurnToward p 0.2, RandomTurn 0.2] [MoveForward 3, TurnToward p 0.2, RandomTurn 0.2]
| otherwise = [MoveForward 3, TurnToward p 0.05, RandomTurn 0.2] | otherwise = [MoveForward 3, TurnToward p 0.05, RandomTurn 0.2]
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
tpos = _crPos crT tpos = crT ^. crPos . _xy
combinedRad = crRad (cr ^. crType) + crRad (crT ^. crType) combinedRad = crRad (cr ^. crType) + crRad (crT ^. crType)
+3 -2
View File
@@ -3,16 +3,17 @@ module Dodge.Creature.ChooseTarget where
import Control.Lens import Control.Lens
import Dodge.Base import Dodge.Base
import Dodge.Data.World import Dodge.Data.World
import Linear
targetYouLOS :: Creature -> World -> Maybe Creature targetYouLOS :: Creature -> World -> Maybe Creature
{-# INLINE targetYouLOS #-} {-# INLINE targetYouLOS #-}
targetYouLOS cr w targetYouLOS cr w
| hasLOS (_crPos cr) (_crPos $ you w) w = Just $ you w | hasLOS (cr ^. crPos . _xy) ( you w ^. crPos . _xy) w = Just $ you w
| otherwise = Nothing | otherwise = Nothing
targetYouCognizant :: Creature -> World -> Maybe Creature targetYouCognizant :: Creature -> World -> Maybe Creature
targetYouCognizant cr w targetYouCognizant cr w
| hasLOS (_crPos cr) (_crPos $ you w) w | hasLOS (cr ^. crPos . _xy) (you w ^. crPos . _xy) w
&& isCog (cr ^? crPerception . cpAwareness . ix 0) = && isCog (cr ^? crPerception . cpAwareness . ix 0) =
Just $ you w Just $ you w
| otherwise = Nothing | otherwise = Nothing
+3 -2
View File
@@ -1,5 +1,6 @@
module Dodge.Creature.Damage (applyCreatureDamage) where module Dodge.Creature.Damage (applyCreatureDamage) where
import Linear
import Dodge.Material.Damage import Dodge.Material.Damage
import Data.List import Data.List
import Dodge.Creature.Mass import Dodge.Creature.Mass
@@ -25,11 +26,11 @@ applyPiercingDamage cr dm w
= f . makeSpark NormalSpark p1 (argV (p1 - p)) $ w = f . makeSpark NormalSpark p1 (argV (p1 - p)) $ w
| otherwise = f . damageHP cr (_dmAmount dm) $ w | otherwise = f . damageHP cr (_dmAmount dm) $ w
where where
f = cWorld . lWorld . creatures . ix (_crID cr) . crPos +~ _dmVector dm f = cWorld . lWorld . creatures . ix (_crID cr) . crPos . _xy +~ _dmVector dm
/ V2 x x / V2 x x
x = crMass (_crType cr) x = crMass (_crType cr)
p = _dmPos dm p = _dmPos dm
p1 = p + 2 *.* squashNormalizeV (p - _crPos cr) p1 = p + 2 *.* squashNormalizeV (p - cr ^. crPos . _xy)
damageHP :: Creature -> Int -> World -> World damageHP :: Creature -> Int -> World -> World
damageHP cr x = damageHP cr x =
+6 -7
View File
@@ -1,9 +1,8 @@
{-# LANGUAGE TupleSections #-} {-# LANGUAGE TupleSections #-}
module Dodge.Creature.Impulse ( module Dodge.Creature.Impulse (impulsiveAIBefore) where
impulsiveAIBefore,
) where
import Linear
import NewInt import NewInt
import Dodge.Creature.MoveType import Dodge.Creature.MoveType
import Data.Foldable import Data.Foldable
@@ -58,7 +57,7 @@ followImpulse cr w imp = case imp of
, crMvAbsolute (w ^. cWorld . lWorld) (10 *.* normalizeV (posFromID cid' -.- cpos)) $ cr & crType . meleeCooldown .~ 20 , crMvAbsolute (w ^. cWorld . lWorld) (10 *.* normalizeV (posFromID cid' -.- cpos)) $ cr & crType . meleeCooldown .~ 20
) )
RandomTurn a -> (randGen .~ snd (rr a), cr & crDir +~ fst (rr a)) RandomTurn a -> (randGen .~ snd (rr a), cr & crDir +~ fst (rr a))
MakeSound sid -> (soundStart (CrSound (_crID cr)) (_crPos cr) sid Nothing, cr) MakeSound sid -> (soundStart (CrSound (_crID cr)) (cr ^. crPos . _xy) sid Nothing, cr)
DropItem -> undefined DropItem -> undefined
ChangeStrategy strat -> crup $ cr & crActionPlan . apStrategy .~ strat ChangeStrategy strat -> crup $ cr & crActionPlan . apStrategy .~ strat
AddGoal gl -> crup $ cr & crActionPlan . apGoal .:~ gl AddGoal gl -> crup $ cr & crActionPlan . apGoal .:~ gl
@@ -71,7 +70,7 @@ followImpulse cr w imp = case imp of
ImpulseUseTarget f -> case cr ^? crIntention . targetCr . _Just of ImpulseUseTarget f -> case cr ^? crIntention . targetCr . _Just of
Just tcr -> followImpulse cr w (doCrImp f tcr) Just tcr -> followImpulse cr w (doCrImp f tcr)
_ -> crup cr _ -> crup cr
ImpulseUseAheadPos f -> followImpulse cr w (doP2Imp f (_crPos cr +.+ 20 *.* unitVectorAtAngle (_crDir cr))) ImpulseUseAheadPos f -> followImpulse cr w (doP2Imp f (cr ^. crPos . _xy +.+ 20 *.* unitVectorAtAngle (_crDir cr)))
MvForward -> crup $ crMvForward speed (w ^. cWorld . lWorld) cr MvForward -> crup $ crMvForward speed (w ^. cWorld . lWorld) cr
MvTurnToward p -> MvTurnToward p ->
crup $ crup $
@@ -81,10 +80,10 @@ followImpulse cr w imp = case imp of
mvType = crMvType cr mvType = crMvType cr
speed = _mvSpeed mvType speed = _mvSpeed mvType
turnRad = doFloatFloat $ _mvTurnRad mvType turnRad = doFloatFloat $ _mvTurnRad mvType
cpos = _crPos cr cpos = cr ^. crPos . _xy
cdir = _crDir cr cdir = _crDir cr
cid = _crID cr cid = _crID cr
posFromID cid' = w ^?! cWorld . lWorld . creatures . ix cid' . crPos posFromID cid' = w ^?! cWorld . lWorld . creatures . ix cid' . crPos . _xy
rr a = randomR (- a, a) $ _randGen w rr a = randomR (- a, a) $ _randGen w
hitCr i = hitCr i =
cWorld . lWorld . creatures . ix i . crDamage cWorld . lWorld . creatures . ix i . crDamage
+4 -3
View File
@@ -1,16 +1,17 @@
module Dodge.Creature.Impulse.Flee where module Dodge.Creature.Impulse.Flee where
import Control.Lens
import Linear
import Dodge.Data.World import Dodge.Data.World
import FoldableHelp import FoldableHelp
import Geometry import Geometry
retreatPointForFrom :: retreatPointForFrom :: Float -> World -> Creature -> Point2 -> Maybe Point2
Float -> World -> Creature -> Point2 -> Maybe Point2
retreatPointForFrom d _ cr p = retreatPointForFrom d _ cr p =
safeMinimumOn (dist cpos) $ safeMinimumOn (dist cpos) $
divideCircle 10 p d divideCircle 10 p d
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
-- = head $ sortBy (compare `on` (\p -> dist p ypos < 300)) $ retreatP'' : retreatPs -- = head $ sortBy (compare `on` (\p -> dist p ypos < 300)) $ retreatP'' : retreatPs
-- where -- where
+4 -3
View File
@@ -7,6 +7,7 @@ module Dodge.Creature.Impulse.Movement (
creatureTurnTo, creatureTurnTo,
) where ) where
import Linear
import Control.Lens import Control.Lens
import Dodge.Base import Dodge.Base
import Dodge.Creature.Statistics import Dodge.Creature.Statistics
@@ -28,7 +29,7 @@ crMvBy p lw cr = crMvAbsolute lw (rotateV (_crDir cr) p) cr
crMvAbsolute :: LWorld -> Point2 -> Creature -> Creature crMvAbsolute :: LWorld -> Point2 -> Creature -> Creature
crMvAbsolute lw p' cr = crMvAbsolute lw p' cr =
advanceStepCounter (magV p) cr advanceStepCounter (magV p) cr
& crPos +~ p & crPos . _xy +~ p
& crMvDir .~ argV p & crMvDir .~ argV p
where where
p = strengthFactor (getCrMoveSpeed lw cr) *.* p' p = strengthFactor (getCrMoveSpeed lw cr) *.* p'
@@ -55,7 +56,7 @@ creatureTurnTo p cr
| vToTarg == V2 0 0 = cr -- this should deal with the angleVV error | vToTarg == V2 0 0 = cr -- this should deal with the angleVV error
| otherwise = cr & crDir .~ dirToTarget | otherwise = cr & crDir .~ dirToTarget
where where
vToTarg = p -.- _crPos cr vToTarg = p -.- cr ^. crPos . _xy
dirToTarget = argV vToTarg dirToTarget = argV vToTarg
-- the following is perhaps not ideal because it mixes normalizeAngle with -- the following is perhaps not ideal because it mixes normalizeAngle with
@@ -80,5 +81,5 @@ creatureTurnToward p turnSpeed cr
| isLeftOfA (normalizeAngle dirToTarget) (normalizeAngle $ _crDir cr) = cr & crDir +~ turnSpeed | isLeftOfA (normalizeAngle dirToTarget) (normalizeAngle $ _crDir cr) = cr & crDir +~ turnSpeed
| otherwise = cr & crDir -~ turnSpeed | otherwise = cr & crDir -~ turnSpeed
where where
vToTarg = p -.- _crPos cr vToTarg = p -.- cr ^. crPos . _xy
dirToTarget = argV vToTarg dirToTarget = argV vToTarg
+5 -5
View File
@@ -95,7 +95,7 @@ chaseCritAwarenessUpdate w cr = case _cpAttention $ _crPerception cr of
replicate numjits [RandomImpulse thejitter] replicate numjits [RandomImpulse thejitter]
++ [[ChangeStrategy $ CloseToMelee 0]] ++ [[ChangeStrategy $ CloseToMelee 0]]
) )
, AimAt 0 (w ^?! cWorld . lWorld . creatures . ix 0 . crPos) , AimAt 0 (w ^?! cWorld . lWorld . creatures . ix 0 . crPos . _xy)
] ]
| otherwise = id | otherwise = id
@@ -147,14 +147,14 @@ newExtraAwareness cr w cid
| not $ canSeeIndirect (_crID cr) cid w = Nothing | not $ canSeeIndirect (_crID cr) cid w = Nothing
| otherwise = Just . Suspicious $ visionCheck cr tpos * awakeLevelPerception cr | otherwise = Just . Suspicious $ visionCheck cr tpos * awakeLevelPerception cr
where where
tpos = w ^?! cWorld . lWorld . creatures . ix cid . crPos -- _crPos $ _creatures (_cWorld w) IM.! cid tpos = w ^?! cWorld . lWorld . creatures . ix cid . crPos . _xy -- _crPos $ _creatures (_cWorld w) IM.! cid
cpos = _crPos cr cpos = cr ^. crPos . _xy
visionCheck :: Creature -> Point2 -> Float visionCheck :: Creature -> Point2 -> Float
visionCheck cr tpos = doFloatFloat (_viFOV vi) ang * doFloatFloat (_viDist vi) d visionCheck cr tpos = doFloatFloat (_viFOV vi) ang * doFloatFloat (_viDist vi) d
where where
vi = _cpVision $ _crPerception cr vi = _cpVision $ _crPerception cr
cpos = _crPos cr cpos = cr ^. crPos . _xy
dirvec = unitVectorAtAngle (_crDir cr) dirvec = unitVectorAtAngle (_crDir cr)
ang = angleVV dirvec (tpos - (cpos - crRad (cr ^. crType) *^ dirvec)) ang = angleVV dirvec (tpos - (cpos - crRad (cr ^. crType) *^ dirvec))
d = dist tpos cpos d = dist tpos cpos
@@ -187,4 +187,4 @@ soundIsClose w cr (pos, vol) =
&& vol > doFloatFloat (_auDist . _cpAudition $ _crPerception cr) (dist pos cpos) && vol > doFloatFloat (_auDist . _cpAudition $ _crPerception cr) (dist pos cpos)
&& hasLOS cpos pos w && hasLOS cpos pos w
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
+2 -1
View File
@@ -1,5 +1,6 @@
module Dodge.Creature.Picture.Awareness where module Dodge.Creature.Picture.Awareness where
import Linear (_xy)
import Dodge.Creature.Radius import Dodge.Creature.Radius
import qualified Data.Vector as V import qualified Data.Vector as V
import Dodge.Clock import Dodge.Clock
@@ -31,7 +32,7 @@ creatureDisplayText w cr =
lw = w ^. cWorld . lWorld lw = w ^. cWorld . lWorld
campos = w ^. wCam . camViewFrom campos = w ^. wCam . camViewFrom
theScale = 0.15 / (w ^. wCam . camZoom) theScale = 0.15 / (w ^. wCam . camZoom)
cpos = _crPos cr cpos = cr ^. crPos . _xy
v = cpos -.- campos v = cpos -.- campos
(V2 x y) = campos +.+ v +.+ crRad (cr ^. crType) *.* normalizeV v (V2 x y) = campos +.+ v +.+ crRad (cr ^. crType) *.* normalizeV v
+16 -15
View File
@@ -13,6 +13,7 @@ module Dodge.Creature.ReaderUpdate (
setViewPos, setViewPos,
) where ) where
import Linear
import Dodge.Creature.Vocalization import Dodge.Creature.Vocalization
import Dodge.Creature.Radius import Dodge.Creature.Radius
import RandomHelp import RandomHelp
@@ -47,16 +48,16 @@ tryMeleeAttack cr tcr
& crActionPlan . apStrategy .~ MeleeStrike & crActionPlan . apStrategy .~ MeleeStrike
| otherwise = cr | otherwise = cr
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
tpos = _crPos tcr tpos = tcr ^. crPos . _xy
setMvPos :: World -> Creature -> Creature setMvPos :: World -> Creature -> Creature
setMvPos w cr = cr & crIntention . mvToPoint .~ mpos setMvPos w cr = cr & crIntention . mvToPoint .~ mpos
where where
int = _crIntention cr int = _crIntention cr
mtpos = do mtpos = do
tpos <- _crPos <$> _targetCr int tpos <- (^. crPos . _xy) <$> _targetCr int
guard $ hasLOSIndirect (_crPos cr) tpos w guard $ hasLOSIndirect (cr ^. crPos . _xy) tpos w
return tpos return tpos
mpos = mtpos <|> _mvToPoint int mpos = mtpos <|> _mvToPoint int
@@ -70,8 +71,8 @@ attentionViewPoint w cr = do
attention <- cr ^? crPerception . cpAttention . getAttentiveTo attention <- cr ^? crPerception . cpAttention . getAttentiveTo
cid <- sortOn snd (IM.toList attention) ^? ix 0 . _1 cid <- sortOn snd (IM.toList attention) ^? ix 0 . _1
tcr <- w ^? cWorld . lWorld . creatures . ix cid tcr <- w ^? cWorld . lWorld . creatures . ix cid
guard $ visionCheck cr (_crPos tcr) > 0 guard $ visionCheck cr (tcr ^. crPos . _xy) > 0
return (_crPos tcr) tcr ^? crPos . _xy
setTargetMv :: setTargetMv ::
-- | Function for determining target -- | Function for determining target
@@ -82,7 +83,7 @@ setTargetMv ::
setTargetMv targFunc w cr = setTargetMv targFunc w cr =
maybe maybe
cr cr
(\ctarg -> cr & crIntention . mvToPoint ?~ _crPos ctarg) (\ctarg -> cr & crIntention . mvToPoint ?~ (ctarg ^. crPos . _xy))
(targFunc w cr) (targFunc w cr)
-- ugly -- ugly
@@ -90,14 +91,14 @@ flockACC :: World -> Creature -> Creature
flockACC w cr = case cr ^? crIntention . targetCr . _Just of flockACC w cr = case cr ^? crIntention . targetCr . _Just of
Nothing -> cr Nothing -> cr
Just tcr -> Just tcr ->
let tpos = _crPos tcr let tpos = tcr ^. crPos . _xy
cpos = _crPos cr cpos = cr ^. crPos . _xy
isFarACC cr' = isFarACC cr' =
_crGroup cr' == _crGroup cr _crGroup cr' == _crGroup cr
&& _crID cr' /= _crID cr && _crID cr' /= _crID cr
&& dist (_crPos cr') tpos > dist cpos tpos && dist (cr' ^. crPos . _xy) tpos > dist cpos tpos
macr = macr =
safeMinimumOn (dist cpos . _crPos) safeMinimumOn (dist cpos . (^. crPos . _xy))
. filter isFarACC . filter isFarACC
$ crsNearCirc cpos 50 w $ crsNearCirc cpos 50 w
in case macr of in case macr of
@@ -106,7 +107,7 @@ flockACC w cr = case cr ^? crIntention . targetCr . _Just of
let r = crRad (acr ^. crType) + crRad (cr ^. crType) + 10 let r = crRad (acr ^. crType) + crRad (cr ^. crType) + 10
horDir = normalizeV (vNormal (cpos -.- tpos)) horDir = normalizeV (vNormal (cpos -.- tpos))
horShift = horShift =
if isLHS tpos cpos (_crPos acr) if isLHS tpos cpos (acr ^. crPos . _xy)
then r *.* horDir then r *.* horDir
else negate r *.* horDir else negate r *.* horDir
in cr & crIntention . mvToPoint ?~ tpos +.+ horShift in cr & crIntention . mvToPoint ?~ tpos +.+ horShift
@@ -128,7 +129,7 @@ chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
numjits = fst $ randomR (15, 25) (_randGen w) numjits = fst $ randomR (15, 25) (_randGen w)
_ -> case cr ^? crIntention . mvToPoint . _Just of _ -> case cr ^? crIntention . mvToPoint . _Just of
Just p Just p
| dist (_crPos cr) p > crRad (cr ^. crType) -> cr & crActionPlan . apAction .~ [PathTo p] | dist (cr ^. crPos . _xy) p > crRad (cr ^. crType) -> cr & crActionPlan . apAction .~ [PathTo p]
| otherwise -> | otherwise ->
cr & crActionPlan . apAction .~ [bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]] cr & crActionPlan . apAction .~ [bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]]
& crActionPlan . apStrategy .~ WatchAndWait & crActionPlan . apStrategy .~ WatchAndWait
@@ -146,7 +147,7 @@ goToTarget w cr = case cr ^? crIntention . mvToPoint . _Just of
viewTarget :: World -> Creature -> Creature viewTarget :: World -> Creature -> Creature
viewTarget w cr = case cr ^? crIntention . viewPoint . _Just of viewTarget w cr = case cr ^? crIntention . viewPoint . _Just of
Just p Just p
| hasLOSIndirect p (_crPos cr) w -> | hasLOSIndirect p (cr ^. crPos . _xy) w ->
cr cr
& crActionPlan . apAction & crActionPlan . apAction
.~ [TurnToPoint p] .~ [TurnToPoint p]
@@ -210,7 +211,7 @@ searchIfDamaged cr
& crActionPlan . apStrategy & crActionPlan . apStrategy
.~ StrategyActions .~ StrategyActions
LookAround LookAround
[ TurnToPoint (_crPos cr -.- unitVectorAtAngle (_crDir cr)) [ TurnToPoint (cr ^. crPos . _xy -.- unitVectorAtAngle (_crDir cr))
`DoActionThen` 40 `WaitThen` bfsThenReturn 500 `DoActionThen` 40 `WaitThen` bfsThenReturn 500
] ]
| otherwise = cr | otherwise = cr
+10 -9
View File
@@ -4,6 +4,7 @@ module Dodge.Creature.State (
invItemEffs, invItemEffs,
) where ) where
import Linear
import NewInt import NewInt
import Control.Applicative import Control.Applicative
import Control.Monad import Control.Monad
@@ -121,7 +122,7 @@ coolMachinePistol cr itm w
dosound s = dosound s =
soundContinue soundContinue
(CrWeaponSound (_crID cr) (fromIntegral $ _itID itm)) (CrWeaponSound (_crID cr) (fromIntegral $ _itID itm))
(_crPos cr) (cr ^. crPos . _xy)
s s
(Just 1) (Just 1)
d = pointerToItem itm . itParams d = pointerToItem itm . itParams
@@ -227,7 +228,7 @@ shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ d
x = 1 x = 1
isammolink AmmoMagSF{} = True isammolink AmmoMagSF{} = True
isammolink _ = False isammolink _ = False
pos = _crPos cr + xyV3 (rotate3 cdir p) pos = cr ^. crPos . _xy + xyV3 (rotate3 cdir p)
cdir = _crDir cr cdir = _crDir cr
itm = itmtree ^. dtValue . _1 itm = itmtree ^. dtValue . _1
pointittarg = cWorld . lWorld . items . ix itid . itTargeting pointittarg = cWorld . lWorld . items . ix itid . itTargeting
@@ -251,7 +252,7 @@ shineTorch cr loc = fromMaybe id $ do
x = 10 x = 10
isammolink AmmoMagSF{} = True isammolink AmmoMagSF{} = True
isammolink _ = False isammolink _ = False
pos = _crPos cr `v2z` 0 + rotate3 cdir (p + Q.rotate q (V3 5 0 1.5)) pos = _crPos cr + rotate3 cdir (p + Q.rotate q (V3 5 0 1.5))
cdir = _crDir cr cdir = _crDir cr
-- this probably needs to be set to null when dropped as well? -- this probably needs to be set to null when dropped as well?
@@ -295,18 +296,18 @@ setRBCreatureTargeting cr w ituse
| otherwise = ituse & itTgID .~ fmap _crID newtarg & updatePos & itTgActive .~ False | otherwise = ituse & itTgID .~ fmap _crID newtarg & updatePos & itTgActive .~ False
where where
newtarg = newtarg =
safeMinimumOn (dist mwp . _crPos) safeMinimumOn (dist mwp . (^. crPos . _xy))
. filter (canseepos . _crPos) . filter (canseepos . (^. crPos . _xy))
$ crsNearCirc mwp 40 w $ crsNearCirc mwp 40 w
canseepos p = hasLOS (_crPos cr) p w canseepos p = hasLOS ((^. crPos . _xy) cr) p w
mwp = w ^. cWorld . lWorld . lAimPos mwp = w ^. cWorld . lWorld . lAimPos
updatePos t' = t' & itTgPos .~ posFromMaybeID (_itTgID t') updatePos t' = t' & itTgPos .~ posFromMaybeID (_itTgID t')
posFromMaybeID Nothing = Nothing posFromMaybeID Nothing = Nothing
posFromMaybeID (Just i) = w ^? cWorld . lWorld . creatures . ix i . crPos posFromMaybeID (Just i) = w ^? cWorld . lWorld . creatures . ix i . crPos . _xy
canSeeTarget = fromMaybe False $ do canSeeTarget = fromMaybe False $ do
cid <- ituse ^? itTgID . _Just cid <- ituse ^? itTgID . _Just
cpos <- w ^? cWorld . lWorld . creatures . ix cid . crPos cpos <- w ^? cWorld . lWorld . creatures . ix cid . crPos . _xy
Just $ hasLOS cpos (_crPos cr) w Just $ hasLOS cpos ( cr ^. crPos . _xy) w
--isFrictionless :: Creature -> Bool --isFrictionless :: Creature -> Bool
--isFrictionless cr = case cr ^? crStance . carriage of --isFrictionless cr = case cr ^? crStance . carriage of
+2 -1
View File
@@ -2,6 +2,7 @@
module Dodge.Creature.State.WalkCycle (updateWalkCycle) where module Dodge.Creature.State.WalkCycle (updateWalkCycle) where
import Linear
import Control.Lens import Control.Lens
import Dodge.Data.World import Dodge.Data.World
import Dodge.SoundLogic import Dodge.SoundLogic
@@ -15,7 +16,7 @@ updateWalkCycle cid w
w w
& soundMultiFrom & soundMultiFrom
[FootstepSound i | i <- [0 .. 10]] [FootstepSound i | i <- [0 .. 10]]
(cr ^. crPos) (cr ^. crPos . _xy)
(chooseFootSound ff) (chooseFootSound ff)
Nothing Nothing
& over (cWorld . lWorld . creatures . ix cid . crStance . carriage) resetStride & over (cWorld . lWorld . creatures . ix cid . crStance . carriage) resetStride
+8 -6
View File
@@ -24,6 +24,7 @@ module Dodge.Creature.Test (
crSafeDistFromTarg, crSafeDistFromTarg,
) where ) where
import Linear
import NewInt import NewInt
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
import Dodge.Creature.Radius import Dodge.Creature.Radius
@@ -49,7 +50,7 @@ import Geometry
-- return (x > 0) -- return (x > 0)
crCanSeeCr :: Creature -> (World, Creature) -> Bool crCanSeeCr :: Creature -> (World, Creature) -> Bool
crCanSeeCr tcr (w, cr) = hasLOS (_crPos cr) (_crPos tcr) w crCanSeeCr tcr (w, cr) = hasLOS (cr ^. crPos . _xy) (tcr ^. crPos . _xy) w
--crCanSeeCrid :: Int -> (World, Creature) -> Bool --crCanSeeCrid :: Int -> (World, Creature) -> Bool
--crCanSeeCrid tcid (w, cr) = fromMaybe False $ do --crCanSeeCrid tcid (w, cr) = fromMaybe False $ do
@@ -71,7 +72,7 @@ crHasTargetLOS w cr = case cr ^? crIntention . targetCr . _Just of
crSafeDistFromTarg :: Float -> Creature -> Bool crSafeDistFromTarg :: Float -> Creature -> Bool
crSafeDistFromTarg d cr = case cr ^? crIntention . targetCr . _Just of crSafeDistFromTarg d cr = case cr ^? crIntention . targetCr . _Just of
Just tcr -> dist (_crPos cr) (_crPos tcr) > d Just tcr -> dist (cr ^. crPos . _xy) (tcr ^. crPos . _xy) > d
Nothing -> True Nothing -> True
crStratConMatches :: Strategy -> Creature -> Bool crStratConMatches :: Strategy -> Creature -> Bool
@@ -81,7 +82,7 @@ crStratConMatches strat cr = strat == _apStrategy (_crActionPlan cr)
crAwayFromPost :: Creature -> Bool crAwayFromPost :: Creature -> Bool
crAwayFromPost cr = case find sentinelGoal . _apGoal $ _crActionPlan cr of crAwayFromPost cr = case find sentinelGoal . _apGoal $ _crActionPlan cr of
Just (SentinelAt p _) -> dist p (_crPos cr) > 15 Just (SentinelAt p _) -> dist p (cr ^. crPos . _xy) > 15
_ -> False _ -> False
where where
sentinelGoal (SentinelAt _ _) = True sentinelGoal (SentinelAt _ _) = True
@@ -108,8 +109,9 @@ crIsArmouredFrom m p cr = fromMaybe False $ do
ittype <- m ^? ix itid . itType ittype <- m ^? ix itid . itType
return $ return $
EQUIP FRONTARMOUR == ittype EQUIP FRONTARMOUR == ittype
&& p /= _crOldPos cr && p /= ( cr ^. crOldPos . _xy)
&& angleVV (unitVectorAtAngle (_crDir cr + frontarmdirection)) (p -.- _crOldPos cr) < pi / 2 && angleVV (unitVectorAtAngle (_crDir cr + frontarmdirection))
(p -.- (cr ^. crOldPos . _xy)) < pi / 2
where where
-- even though angleVV can generate NaN, the comparison seems to deal with it -- even though angleVV can generate NaN, the comparison seems to deal with it
frontarmdirection frontarmdirection
@@ -125,7 +127,7 @@ crIsArmouredFrom m p cr = fromMaybe False $ do
--crNearSeg d p1 p2 cr = circOnSeg p1 p2 (_crPos cr) (_crRad cr + d) --crNearSeg d p1 p2 cr = circOnSeg p1 p2 (_crPos cr) (_crRad cr + d)
crNearPoint :: Float -> Point2 -> Creature -> Bool crNearPoint :: Float -> Point2 -> Creature -> Bool
crNearPoint d p cr = dist (_crPos cr) p < d + crRad (cr ^. crType) crNearPoint d p cr = dist (cr ^. crPos . _xy) p < d + crRad (cr ^. crType)
isAnimate :: Creature -> Bool isAnimate :: Creature -> Bool
{-# INLINE isAnimate #-} {-# INLINE isAnimate #-}
+8 -7
View File
@@ -1,5 +1,6 @@
module Dodge.Creature.Update (updateCreature) where module Dodge.Creature.Update (updateCreature) where
import Linear
import NewInt import NewInt
import Color import Color
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
@@ -31,8 +32,8 @@ import ShapePicture.Data
updateCreature :: Creature -> World -> World updateCreature :: Creature -> World -> World
updateCreature cr updateCreature cr
| null (cr ^? crHP . _HP) = id | null (cr ^? crHP . _HP) = id
| _crZ cr < negate 100 = (tocr . crHP .~ CrIsPitted) . destroyAllInvItems cr | cr ^. crPos . _z < negate 100 = (tocr . crHP .~ CrIsPitted) . destroyAllInvItems cr
| _crZ cr < 0 = (tocr . crZVel -~ 0.5) . (tocr . crZ +~ _crZVel cr) | cr ^. crPos . _z < 0 = (tocr . crZVel -~ 0.5) . (tocr . crPos . _z +~ _crZVel cr)
| otherwise = updateCreature' cr | otherwise = updateCreature' cr
where where
tocr = cWorld . lWorld . creatures . ix (_crID cr) tocr = cWorld . lWorld . creatures . ix (_crID cr)
@@ -131,16 +132,16 @@ dropAll cr w = foldl' (flip (dropItem cr)) w . reverse . IM.keys . _unNIntMap $
chasmTest :: Creature -> World -> World chasmTest :: Creature -> World -> World
chasmTest cr w chasmTest cr w
| _crZVel cr < 0 = w & tocr . crZVel -~ 0.5 | _crZVel cr < 0 = w & tocr . crZVel -~ 0.5
& tocr . crZ +~ _crZVel cr & tocr . crPos . _z +~ _crZVel cr
| Just (x, y) <- List.find g (foldMap loopPairs $ w ^. cWorld . chasms) = w | Just (x, y) <- List.find g (foldMap loopPairs $ w ^. cWorld . chasms) = w
& soundContinue (CrChasm (_crID cr)) (_crPos cr) debrisS (Just 100) & soundContinue (CrChasm (_crID cr)) (cr ^. crPos . _xy) debrisS (Just 100)
& tocr . crPos -~ normalizeV (vNormal (x - y)) & tocr . crPos . _xy -~ normalizeV (vNormal (x - y))
| any f (w ^. cWorld . chasms) = w & tocr . crZVel -~ 0.5 | any f (w ^. cWorld . chasms) = w & tocr . crZVel -~ 0.5
| otherwise = w | otherwise = w
where where
tocr = cWorld . lWorld . creatures . ix (_crID cr) tocr = cWorld . lWorld . creatures . ix (_crID cr)
g = uncurry $ circOnSeg (_crPos cr) (crRad $ cr ^. crType) g = uncurry $ circOnSeg (cr ^. crPos . _xy) (crRad $ cr ^. crType)
f = circInPolygon (_crPos cr) (crRad $ cr ^. crType) f = circInPolygon (cr ^. crPos . _xy) (crRad $ cr ^. crType)
updatePulse :: Pulse -> Pulse updatePulse :: Pulse -> Pulse
updatePulse PulseStatus{_pulseRate = pr, _pulseProgress = pp} updatePulse PulseStatus{_pulseRate = pr, _pulseProgress = pp}
+2 -1
View File
@@ -2,6 +2,7 @@
module Dodge.Creature.YourControl (yourControl) where module Dodge.Creature.YourControl (yourControl) where
import Linear
import Control.Monad import Control.Monad
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
@@ -139,7 +140,7 @@ wasdAim inp w cr
| Aiming {} <- cr ^. crStance . posture = removeAimPosture cr | Aiming {} <- cr ^. crStance . posture = removeAimPosture cr
| otherwise = creatureTurnTowardDir (_crMvAim cr) 0.2 cr | otherwise = creatureTurnTowardDir (_crMvAim cr) 0.2 cr
where where
mousedir = argV $ w ^. cWorld . lWorld . lAimPos - (cr ^. crPos) mousedir = argV $ w ^. cWorld . lWorld . lAimPos - (cr ^. crPos . _xy)
setAimPosture :: IM.IntMap Item -> Creature -> Creature setAimPosture :: IM.IntMap Item -> Creature -> Creature
setAimPosture m cr = fromMaybe cr $ do setAimPosture m cr = fromMaybe cr $ do
+12 -8
View File
@@ -1,5 +1,6 @@
module Dodge.CreatureEffect where module Dodge.CreatureEffect where
import Linear
import Data.Maybe import Data.Maybe
import Dodge.Base.Collide import Dodge.Base.Collide
import Dodge.Creature.Test import Dodge.Creature.Test
@@ -28,7 +29,7 @@ doIntImp ii = case ii of
doCrImp :: CrImp -> Creature -> Impulse doCrImp :: CrImp -> Creature -> Impulse
doCrImp ci = case ci of doCrImp ci = case ci of
NoCrImp -> const ImpulseNothing NoCrImp -> const ImpulseNothing
TurnTowardCr x -> \cr -> TurnToward (_crPos cr) x TurnTowardCr x -> \cr -> TurnToward (cr ^. crPos . _xy) x
doP2Imp :: P2Imp -> Point2 -> Impulse doP2Imp :: P2Imp -> Point2 -> Impulse
doP2Imp p2i = case p2i of doP2Imp p2i = case p2i of
@@ -60,7 +61,8 @@ doMCrAc mca = case mca of
doCrAc :: CrAc -> Creature -> Action doCrAc :: CrAc -> Creature -> Action
doCrAc ca = case ca of doCrAc ca = case ca of
CrTurnAround -> \cr -> TurnToPoint (_crPos cr -.- 10 *.* unitVectorAtAngle (_crDir cr)) CrTurnAround -> \cr -> TurnToPoint
(cr ^. crPos . _xy -.- 10 *.* unitVectorAtAngle (_crDir cr))
CrFleeFromTarget -> fleeFromTarget CrFleeFromTarget -> fleeFromTarget
fleeFromTarget :: Creature -> Action fleeFromTarget :: Creature -> Action
@@ -77,7 +79,7 @@ doMP2Ac mp2a = case mp2a of
doCrWdAc :: CrWdAc -> Creature -> World -> Action doCrWdAc :: CrWdAc -> Creature -> World -> Action
doCrWdAc cw = case cw of doCrWdAc cw = case cw of
CrWdBFSThenReturn t -> \cr w -> fromMaybe NoAction $ do CrWdBFSThenReturn t -> \cr w -> fromMaybe NoAction $ do
n <- walkableNodeNear w (_crPos cr) n <- walkableNodeNear w (cr ^. crPos . _xy)
let as = take 20 $ map PathTo $ bfsNodePoints n w let as = take 20 $ map PathTo $ bfsNodePoints n w
return $ return $
DoReplicate t $ DoReplicate t $
@@ -97,10 +99,10 @@ chooseMovementSpreadGun cr w
DoImpulses [TurnToward p 0.26, MoveForward 3] DoImpulses [TurnToward p 0.26, MoveForward 3]
where where
d = dist cpos p d = dist cpos p
cpos = _crPos cr cpos = cr ^. crPos . _xy
--tcr = _creatures (_cWorld w) IM.! 0 --tcr = _creatures (_cWorld w) IM.! 0
tcr = w ^?! cWorld . lWorld . creatures . ix 0 tcr = w ^?! cWorld . lWorld . creatures . ix 0
p = _crPos tcr p = tcr ^. crPos . _xy
chooseMovementLtAuto :: Creature -> World -> Action chooseMovementLtAuto :: Creature -> World -> Action
chooseMovementLtAuto cr w chooseMovementLtAuto cr w
@@ -111,13 +113,15 @@ chooseMovementLtAuto cr w
| otherwise = | otherwise =
DoImpulses [UseItem, TurnToward p' 0.05, Move (V2 0 3)] DoImpulses [UseItem, TurnToward p' 0.05, Move (V2 0 3)]
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
tcr = w ^?! cWorld . lWorld . creatures . ix 0 tcr = w ^?! cWorld . lWorld . creatures . ix 0
p = _crPos tcr p = tcr ^. crPos . _xy
v = vNormal $ p -.- cpos v = vNormal $ p -.- cpos
p' = p +.+ 0.5 *.* (v -.- 20 *.* normalizeV v) p' = p +.+ 0.5 *.* (v -.- 20 *.* normalizeV v)
fleeFrom :: Creature -> Maybe Creature -> Action fleeFrom :: Creature -> Maybe Creature -> Action
fleeFrom cr mtcr = case mtcr of fleeFrom cr mtcr = case mtcr of
Just tcr -> DoImpulses [MoveForward 3, TurnToward ((2 *.* _crPos cr) -.- _crPos tcr) (pi / 4)] Just tcr -> DoImpulses
[MoveForward 3
, TurnToward ((2 *.* (cr ^. crPos ._xy)) -.- (tcr ^. crPos . _xy)) (pi / 4)]
Nothing -> NoAction Nothing -> NoAction
+3 -3
View File
@@ -37,9 +37,9 @@ import Geometry.Data
--import qualified IntMapHelp as IM --import qualified IntMapHelp as IM
data Creature = Creature data Creature = Creature
{ _crPos :: Point2 { _crPos :: Point3
, _crOldPos :: Point2 , _crOldPos :: Point3
, _crZ :: Float -- , _crZ :: Float
, _crZVel :: Float , _crZVel :: Float
, _crDir :: Float , _crDir :: Float
, _crMvDir :: Float , _crMvDir :: Float
+6 -5
View File
@@ -1,6 +1,7 @@
{-# OPTIONS -Wno-incomplete-uni-patterns #-} {-# OPTIONS -Wno-incomplete-uni-patterns #-}
module Dodge.Debug.Picture where module Dodge.Debug.Picture where
import Linear (_xy)
import Control.Lens import Control.Lens
import Data.Foldable import Data.Foldable
import qualified Data.Graph.Inductive as FGL import qualified Data.Graph.Inductive as FGL
@@ -211,7 +212,7 @@ drawPathBetween w = concat $ do
drawWallsNearYou :: World -> Picture drawWallsNearYou :: World -> Picture
drawWallsNearYou w = concat $ do drawWallsNearYou w = concat $ do
p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos . _xy
return $ setLayer DebugLayer $ foldMap f $ wlsNearPoint p w return $ setLayer DebugLayer $ foldMap f $ wlsNearPoint p w
where where
f wl = color violet $ thickLine 3 [a, b] f wl = color violet $ thickLine 3 [a, b]
@@ -384,7 +385,7 @@ drawWlIDs :: World -> Picture
drawWlIDs w = setLayer FixedCoordLayer $ foldMap f (w ^. cWorld . lWorld . walls) drawWlIDs w = setLayer FixedCoordLayer $ foldMap f (w ^. cWorld . lWorld . walls)
where where
f wl f wl
| dist (_crPos $ you w) (fst (_wlLine wl)) > 200 = mempty -- this should be improved with a better "on screen test" | dist (you w ^. crPos . _xy) (fst (_wlLine wl)) > 200 = mempty -- this should be improved with a better "on screen test"
| otherwise = | otherwise =
uncurryV translate p uncurryV translate p
. scale 0.1 0.1 . scale 0.1 0.1
@@ -414,12 +415,12 @@ drawCrInfo cfig w =
| _crID cr == 0 = Nothing | _crID cr == 0 = Nothing
| crOnScreen = | crOnScreen =
Just Just
( _crPos cr ( cr ^. crPos . _xy
, catMaybes , catMaybes
-- [fmap show $ ap ^? crGoal -- [fmap show $ ap ^? crGoal
[ fpreShow "crHP" $ cr ^? crHP . _HP [ fpreShow "crHP" $ cr ^? crHP . _HP
, fpreShow "crStrategy" $ ap ^? apStrategy , fpreShow "crStrategy" $ ap ^? apStrategy
, fmap (("crPos....." ++) . shortShow) $ cr ^? crPos , fmap (("crPos....." ++) . shortShow) $ cr ^? crPos . _xy
, fpreShow "cpVigilance" $ cr ^? crPerception . cpVigilance , fpreShow "cpVigilance" $ cr ^? crPerception . cpVigilance
, -- , fmap show $ cr ^? crOldPos , -- , fmap show $ cr ^? crOldPos
fpreShow "crAction" $ ap ^? apAction fpreShow "crAction" $ ap ^? apAction
@@ -429,7 +430,7 @@ drawCrInfo cfig w =
| otherwise = Nothing | otherwise = Nothing
where where
ap = _crActionPlan cr ap = _crActionPlan cr
crOnScreen = pointIsOnScreen cfig cam $ _crPos cr crOnScreen = pointIsOnScreen cfig cam $ cr ^. crPos . _xy
fpreShow :: (Show a, Functor f) => String -> f a -> f String fpreShow :: (Show a, Functor f) => String -> f a -> f String
fpreShow str = fmap (((rightPad 7 '.' str ++ "...") ++) . show) fpreShow str = fmap (((rightPad 7 '.' str ++ "...") ++) . show)
+3 -3
View File
@@ -12,9 +12,9 @@ import Geometry.Data
defaultCreature :: Creature defaultCreature :: Creature
defaultCreature = defaultCreature =
Creature Creature
{ _crPos = V2 0 0 { _crPos = V3 0 0 0
, _crOldPos = V2 0 0 , _crOldPos = V3 0 0 0
, _crZ = 0 -- , _crZ = 0
, _crZVel = 0 , _crZVel = 0
, _crDir = 0 , _crDir = 0
, _crMvDir = 0 , _crMvDir = 0
+2 -1
View File
@@ -3,6 +3,7 @@ module Dodge.Equipment (
effectOnEquip, effectOnEquip,
) where ) where
import Linear
import Control.Lens import Control.Lens
import Data.Maybe import Data.Maybe
import Dodge.Creature.HandPos import Dodge.Creature.HandPos
@@ -60,4 +61,4 @@ setWristShieldPos itm cr w = w & moveWallIDUnsafe i wlline
-- g -- g
-- | twists cr = (+.+.+ V3 (-5) 10 0) -- | twists cr = (+.+.+ V3 (-5) 10 0)
-- | otherwise = id -- | otherwise = id
f = (+.+ _crPos cr) . stripZ . rotate3 (_crDir cr) . handtrans f = (+.+ cr ^. crPos . _xy) . stripZ . rotate3 (_crDir cr) . handtrans
+18 -11
View File
@@ -1,6 +1,4 @@
module Dodge.Euse ( module Dodge.Euse (equipBackgroundEffect) where
equipBackgroundEffect,
) where
import Dodge.Creature.HandPos import Dodge.Creature.HandPos
import Dodge.Creature.Test import Dodge.Creature.Test
@@ -11,9 +9,14 @@ import Dodge.Data.World
import Dodge.Wall.Move import Dodge.Wall.Move
import Geometry import Geometry
import LensHelp import LensHelp
import Linear
equipBackgroundEffect :: LocationDT OItem -> Creature -> EquipSite equipBackgroundEffect ::
-> World -> World LocationDT OItem ->
Creature ->
EquipSite ->
World ->
World
equipBackgroundEffect loc cr = case eo of equipBackgroundEffect loc cr = case eo of
EQUIP (MAGSHIELD mt) -> const $ useMagShield mt itm cr EQUIP (MAGSHIELD mt) -> const $ useMagShield mt itm cr
EQUIP WRISTARMOUR -> setWristShieldPos itm cr EQUIP WRISTARMOUR -> setWristShieldPos itm cr
@@ -28,7 +31,7 @@ useMagShield :: MagnetBuBu -> Item -> Creature -> World -> World
useMagShield mt _ cr w = useMagShield mt _ cr w =
w & cWorld . lWorld . magnets w & cWorld . lWorld . magnets
.:~ Magnet .:~ Magnet
{ _mgPos = _crPos cr { _mgPos = cr ^. crPos . _xy
, _mgField = mt , _mgField = mt
} }
@@ -43,7 +46,7 @@ setWristShieldPos itm cr x = moveWallIDUnsafe i wlline
g g
| twists cr = (+.+.+ V3 (-5) 10 0) | twists cr = (+.+.+ V3 (-5) 10 0)
| otherwise = id | otherwise = id
f = (+.+ _crPos cr) . stripZ . rotate3 (_crDir cr) . handtrans cr f = (+.+ cr ^. crPos . _xy) . stripZ . rotate3 (_crDir cr) . handtrans cr
-- TODO the reflection should be controled by the particle -- TODO the reflection should be controled by the particle
--shieldWallDamage :: Damage -> Wall -> Int -> World -> World --shieldWallDamage :: Damage -> Wall -> Int -> World -> World
@@ -53,10 +56,14 @@ setWristShieldPos itm cr x = moveWallIDUnsafe i wlline
-- _ -> w -- _ -> w
createHeadLamp :: Item -> Creature -> World -> World createHeadLamp :: Item -> Creature -> World -> World
createHeadLamp _ cr w = w & createHeadLamp _ cr w =
cWorld . lWorld . lights w
& cWorld . lWorld . lights
.:~ LSParam .:~ LSParam
((_crPos cr `v2z` 0) +.+.+ rotate3 (_crDir cr) ( _crPos cr
(translateToES cr OnHead (V3 5 0 3))) +.+.+ rotate3
(_crDir cr)
(translateToES cr OnHead (V3 5 0 3))
)
200 200
0.7 0.7
+4 -2
View File
@@ -1,5 +1,7 @@
module Dodge.Gas where module Dodge.Gas where
import Linear
import Control.Lens
import Dodge.Data.World import Dodge.Data.World
import Dodge.Flame import Dodge.Flame
import Dodge.WorldEvent import Dodge.WorldEvent
@@ -13,7 +15,7 @@ createGas gc = case gc of
aGasCloud :: Float -> Point2 -> Float -> Creature -> World -> World aGasCloud :: Float -> Point2 -> Float -> Creature -> World -> World
aGasCloud pressure pos dir cr = aGasCloud pressure pos dir cr =
makeGasCloud pos $ makeGasCloud pos $
(_crPos cr -.- _crOldPos cr) +.+ pressure *.* unitVectorAtAngle dir (cr ^. crPos . _xy -.- cr ^. crOldPos . _xy) +.+ pressure *.* unitVectorAtAngle dir
aFlame :: Float -> Point2 -> Float -> Creature -> World -> World aFlame :: Float -> Point2 -> Float -> Creature -> World -> World
aFlame pressure pos dir cr = makeFlame pos vel aFlame pressure pos dir cr = makeFlame pos vel
@@ -21,4 +23,4 @@ aFlame pressure pos dir cr = makeFlame pos vel
--w & instantParticles .:~ aFlameParticle t pos vel Nothing -- (Just $ _crID cr) --w & instantParticles .:~ aFlameParticle t pos vel Nothing -- (Just $ _crID cr)
-- (t,_) = randomR (99,101) (_randGen w) -- (t,_) = randomR (99,101) (_randGen w)
vel = (_crPos cr -.- _crOldPos cr) +.+ pressure *.* unitVectorAtAngle dir vel = (cr ^. crPos . _xy -.- cr ^. crOldPos . _xy) +.+ pressure *.* unitVectorAtAngle dir
+20 -19
View File
@@ -8,6 +8,7 @@ module Dodge.HeldUse (
heldEffectMuzzles, heldEffectMuzzles,
) where ) where
import Linear (_xy)
import Color import Color
import Control.Applicative import Control.Applicative
import Control.Monad import Control.Monad
@@ -72,7 +73,7 @@ hammerCheck f pt loc cr w = case itemTriggerType loc of
w & setwarming w & setwarming
& soundContinue & soundContinue
(CrWeaponSound cid 0) (CrWeaponSound cid 0)
(_crPos cr) (cr ^. crPos . _xy)
(warmupSound $ it ^. itType) (warmupSound $ it ^. itType)
(Just 2) (Just 2)
& itmset . itParams . wTime +~ 1 & itmset . itParams . wTime +~ 1
@@ -82,7 +83,7 @@ hammerCheck f pt loc cr w = case itemTriggerType loc of
w & setwarming w & setwarming
& soundContinue & soundContinue
(CrWeaponSound cid 0) (CrWeaponSound cid 0)
(_crPos cr) (cr ^. crPos . _xy)
(warmupSound $ it ^. itType) (warmupSound $ it ^. itType)
(Just 2) (Just 2)
& itmset . itParams . wTime +~ 1 & itmset . itParams . wTime +~ 1
@@ -371,8 +372,8 @@ applyCME loc cr cme
itm = loc ^. locDT . dtValue . _1 itm = loc ^. locDT . dtValue . _1
spush = maybe 0 itemSidePush $ itm ^? itType . ibtHeld spush = maybe 0 itemSidePush $ itm ^? itType . ibtHeld
failsound w = case w ^? input . mouseButtons . ix SDL.ButtonLeft of failsound w = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> soundStart (CrWeaponFailSound (_crID cr)) (_crPos cr) click1S Nothing w Just 0 -> soundStart (CrWeaponFailSound (_crID cr)) (cr ^. crPos . _xy) click1S Nothing w
_ -> soundContinue (CrWeaponFailSound (_crID cr)) (_crPos cr) click1S Nothing w _ -> soundContinue (CrWeaponFailSound (_crID cr)) (cr ^. crPos . _xy) click1S Nothing w
itemSidePush :: HeldItemType -> Float itemSidePush :: HeldItemType -> Float
itemSidePush = \case itemSidePush = \case
@@ -443,14 +444,14 @@ applySoundCME itm cr = fromMaybe id $ do
(soundid, x) <- bgunSound itm (soundid, x) <- bgunSound itm
return $ return $
if x > 0 if x > 0
then soundContinue (CrWeaponSound cid 0) (_crPos cr) soundid (Just x) then soundContinue (CrWeaponSound cid 0) (cr ^. crPos . _xy) soundid (Just x)
else soundMultiFrom [CrWeaponSound cid j | j <- [0 .. 16]] (_crPos cr) soundid Nothing else soundMultiFrom [CrWeaponSound cid j | j <- [0 .. 16]] (cr ^. crPos . _xy) soundid Nothing
where where
cid = _crID cr cid = _crID cr
applyRecoil :: LocationDT OItem -> Creature -> World -> World applyRecoil :: LocationDT OItem -> Creature -> World -> World
applyRecoil loc cr = applyRecoil loc cr =
cWorld . lWorld . creatures . ix (_crID cr) . crPos cWorld . lWorld . creatures . ix (_crID cr) . crPos . _xy
+~ rotateV (_crDir cr + Q.qToAng q) (V2 ((- recoilAmount itm) / crMass (_crType cr)) 0) +~ rotateV (_crDir cr + Q.qToAng q) (V2 ((- recoilAmount itm) / crMass (_crType cr)) 0)
where where
itm = loc ^. locDT . dtValue . _1 itm = loc ^. locDT . dtValue . _1
@@ -552,7 +553,7 @@ applySidePush :: Float -> Creature -> World -> World
applySidePush 0 _ w = w applySidePush 0 _ w = w
applySidePush maxSide cr w = applySidePush maxSide cr w =
w w
& cWorld . lWorld . creatures . ix cid . crPos +~ push & cWorld . lWorld . creatures . ix cid . crPos . _xy +~ push
& randGen .~ g & randGen .~ g
where where
cid = _crID cr cid = _crID cr
@@ -664,7 +665,7 @@ makeMuzzleFlare mz loc cr = case mz ^. mzFlareType of
(V3 x y _, q) = (V3 x y _, q) =
locOrient loc cr locOrient loc cr
`Q.comp` (_mzPos mz `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz)) `Q.comp` (_mzPos mz `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
pos = _crPos cr + rotateV (_crDir cr) (V2 x y) pos = (cr ^. crPos . _xy) + rotateV (_crDir cr) (V2 x y)
dir = _crDir cr + Q.qToAng q dir = _crDir cr + Q.qToAng q
oddcheck f w oddcheck f w
| odd (w ^. cWorld . lWorld . lClock) = f w | odd (w ^. cWorld . lWorld . lClock) = f w
@@ -796,7 +797,7 @@ shootTractorBeam cr w =
w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt spos outpos dir power w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt spos outpos dir power
& soundContinue (CrWeaponSound (_crID cr) 0) cpos tone440sawtoothquietS (Just 2) & soundContinue (CrWeaponSound (_crID cr) 0) cpos tone440sawtoothquietS (Just 2)
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
spos = cpos +.+ (crRad (cr ^. crType) + 10) *.* unitVectorAtAngle dir spos = cpos +.+ (crRad (cr ^. crType) + 10) *.* unitVectorAtAngle dir
xpos = cpos +.+ 400 *.* unitVectorAtAngle dir xpos = cpos +.+ 400 *.* unitVectorAtAngle dir
dir = _crDir cr dir = _crDir cr
@@ -827,7 +828,7 @@ creatureShootLaser loc cr mz w =
(V3 x y _, q) = (V3 x y _, q) =
locOrient loc cr locOrient loc cr
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz)) `Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
pos = _crPos cr + rotateV (_crDir cr) (V2 x y) pos = cr ^. crPos . _xy + rotateV (_crDir cr) (V2 x y)
dir = _crDir cr + Q.qToAng q + a dir = _crDir cr + Q.qToAng q + a
(a, g) = randomR (- inacc, inacc) $ _randGen w (a, g) = randomR (- inacc, inacc) $ _randGen w
inacc = _mzInaccuracy mz inacc = _mzInaccuracy mz
@@ -868,7 +869,7 @@ creatureShootPulseLaser loc cr mz w =
(V3 x y _, q) = (V3 x y _, q) =
locOrient loc cr locOrient loc cr
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz)) `Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
pos = _crPos cr + rotateV (_crDir cr) (V2 x y) pos = cr ^. crPos . _xy + rotateV (_crDir cr) (V2 x y)
dir = _crDir cr + Q.qToAng q + a dir = _crDir cr + Q.qToAng q + a
(a, g) = randomR (- inacc, inacc) $ _randGen w (a, g) = randomR (- inacc, inacc) $ _randGen w
inacc = _mzInaccuracy mz inacc = _mzInaccuracy mz
@@ -895,7 +896,7 @@ creatureShootPulseBall loc cr mz w = w & randGen .~ g & shootPulseBall pos dir
(V3 x y _, q) = (V3 x y _, q) =
locOrient loc cr locOrient loc cr
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz)) `Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
pos = _crPos cr + rotateV (_crDir cr) (V2 x y) pos = cr ^. crPos . _xy + rotateV (_crDir cr) (V2 x y)
dir = _crDir cr + Q.qToAng q + a dir = _crDir cr + Q.qToAng q + a
(a, g) = randomR (- inacc, inacc) $ _randGen w (a, g) = randomR (- inacc, inacc) $ _randGen w
inacc = _mzInaccuracy mz inacc = _mzInaccuracy mz
@@ -991,7 +992,7 @@ shootBullet bu loc cr mz w = makeBullet bu itm bulpos dir . (randGen .~ g) $ w
locOrient loc cr locOrient loc cr
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz)) `Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
itm = loc ^. locDT . dtValue . _1 itm = loc ^. locDT . dtValue . _1
bulpos = _crPos cr + rotateV (_crDir cr) (V2 x y) bulpos = cr ^. crPos . _xy + rotateV (_crDir cr) (V2 x y)
(a, g) = randomR (- inacc, inacc) $ _randGen w (a, g) = randomR (- inacc, inacc) $ _randGen w
dir = _crDir cr + Q.qToAng q + a dir = _crDir cr + Q.qToAng q + a
inacc = _mzInaccuracy mz inacc = _mzInaccuracy mz
@@ -1130,7 +1131,7 @@ useGasParams (NInt magitid) mz loc cr w =
(V3 x y _, q) = (V3 x y _, q) =
locOrient loc cr locOrient loc cr
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz)) `Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
pos = _crPos cr + rotateV (_crDir cr) (V2 x y) pos = cr ^. crPos . _xy + rotateV (_crDir cr) (V2 x y)
(a, g') = randomR (- inacc, inacc) g (a, g') = randomR (- inacc, inacc) g
inacc = _mzInaccuracy mz inacc = _mzInaccuracy mz
offset = case mz ^. mzRandomOffset of offset = case mz ^. mzRandomOffset of
@@ -1219,7 +1220,7 @@ shootTeslaArc loc cr mz w =
(V3 x y _, q) = (V3 x y _, q) =
locOrient loc cr locOrient loc cr
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz)) `Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
pos = _crPos cr + rotateV (_crDir cr) (V2 x y) pos = cr ^. crPos . _xy + rotateV (_crDir cr) (V2 x y)
dir = _crDir cr + Q.qToAng q dir = _crDir cr + Q.qToAng q
offset = case mz ^. mzRandomOffset of offset = case mz ^. mzRandomOffset of
0 -> 0 0 -> 0
@@ -1343,12 +1344,12 @@ createProjectile x pjtype mtree stab muz cr w = fromMaybe (failsound w) $ do
makesound = makesound =
soundMultiFrom soundMultiFrom
[CrWeaponSound (_crID cr) j | j <- [0 .. 3]] [CrWeaponSound (_crID cr) j | j <- [0 .. 3]]
(_crPos cr) (cr ^. crPos . _xy)
tap4S tap4S
Nothing Nothing
failsound w' = case w' ^? input . mouseButtons . ix SDL.ButtonLeft of failsound w' = case w' ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> soundStart (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w' Just 0 -> soundStart (CrWeaponSound (_crID cr) 0) (cr ^. crPos . _xy) click1S Nothing w'
_ -> soundContinue (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w' _ -> soundContinue (CrWeaponSound (_crID cr) 0) (cr ^. crPos . _xy) click1S Nothing w'
---- need to add these to muzzle flare? ---- need to add these to muzzle flare?
--makeMuzzleSmoke :: Muzzle -> Item -> Creature -> World -> World --makeMuzzleSmoke :: Muzzle -> Item -> Creature -> World -> World
+5 -4
View File
@@ -1,5 +1,6 @@
module Dodge.Humanoid where module Dodge.Humanoid where
import Linear
import Data.Maybe import Data.Maybe
import Dodge.Creature.Action import Dodge.Creature.Action
import Dodge.Creature import Dodge.Creature
@@ -218,9 +219,9 @@ chooseMovementPistol' cr w =
$ g $ g
where where
g = _randGen w g = _randGen w
cpos = _crPos cr cpos = cr ^. crPos . _xy
ycr = w ^?! cWorld . lWorld . creatures . ix 0 ycr = w ^?! cWorld . lWorld . creatures . ix 0
ypos = _crPos ycr ypos = ycr ^. crPos . _xy
chargeProb chargeProb
| dist cpos ypos > 300 = 5 | dist cpos ypos > 300 = 5
| dist cpos ypos > 150 = 1 | dist cpos ypos > 150 = 1
@@ -252,8 +253,8 @@ retreatActionsPistol tcr cr =
`DoImpulsesAlongside` 3 `DoImpulsesAlongside` 3
`DoReplicate` ImpulsesList (replicate 9 [Move (V2 (-3) 0)] ++ [[UseItem]]) `DoReplicate` ImpulsesList (replicate 9 [Move (V2 (-3) 0)] ++ [[UseItem]])
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
tpos = _crPos tcr tpos = tcr ^. crPos . _xy
retreatOffset = retreatOffset =
let a let a
| dist cpos tpos < 50 = 0 | dist cpos tpos < 50 = 0
+2 -1
View File
@@ -16,6 +16,7 @@ module Dodge.Inventory (
destroyAllInvItems, destroyAllInvItems,
) where ) where
import Linear
import Data.Function import Data.Function
import Data.Maybe import Data.Maybe
import Dodge.Base import Dodge.Base
@@ -128,7 +129,7 @@ updateCloseObjects w =
return (x /= TerminalDeactivated) return (x /= TerminalDeactivated)
_ -> True _ -> True
isclose x = dist y x < 40 && hasButtonLOS y x w isclose x = dist y x < 40 && hasButtonLOS y x w
y = _crPos $ you w y = you w ^. crPos . _xy
changeSwapSel :: Int -> World -> World changeSwapSel :: Int -> World -> World
changeSwapSel yi w changeSwapSel yi w
+2 -1
View File
@@ -6,6 +6,7 @@ module Dodge.Inventory.Add (
pickUpItemAt, pickUpItemAt,
) where ) where
import Linear
import qualified Data.IntSet as IS import qualified Data.IntSet as IS
import Control.Lens import Control.Lens
import Control.Monad import Control.Monad
@@ -61,7 +62,7 @@ createItemYou :: Item -> World -> World
createItemYou itm w = maybe w' snd $ tryPutItemInInv 0 itid w' createItemYou itm w = maybe w' snd $ tryPutItemInInv 0 itid w'
where where
itid = IM.newKey $ w ^. cWorld . lWorld . items itid = IM.newKey $ w ^. cWorld . lWorld . items
pos = w ^?! cWorld . lWorld . creatures . ix 0 . crPos pos = w ^?! cWorld . lWorld . creatures . ix 0 . crPos . _xy
w' = copyItemToFloor pos (itm & itID .~ NInt itid) w w' = copyItemToFloor pos (itm & itID .~ NInt itid) w
-- the duplication is annoying... -- the duplication is annoying...
+2 -1
View File
@@ -3,6 +3,7 @@ module Dodge.Inventory.Swap (
swapAnyExtraSelection swapAnyExtraSelection
) where ) where
import Linear
import NewInt import NewInt
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.Item.Grammar import Dodge.Item.Grammar
@@ -71,7 +72,7 @@ checkConnection so s i j w = fromMaybe w $ do
iit <- locs ^? ix i . _2 iit <- locs ^? ix i . _2
jit <- locs ^? ix j . _2 jit <- locs ^? ix j . _2
guard $ isConnected iit || isConnected jit guard $ isConnected iit || isConnected jit
return $ soundStart so cpos s Nothing w return $ soundStart so (cpos ^. _xy) s Nothing w
isConnected :: LocationDT a -> Bool isConnected :: LocationDT a -> Bool
isConnected x = case x ^. locDtContext of isConnected x = case x ^. locDtContext of
+2 -1
View File
@@ -6,6 +6,7 @@ module Dodge.Item.BackgroundEffect (
removeShieldWall, removeShieldWall,
) where ) where
import Linear
import Color import Color
import Control.Lens import Control.Lens
import Dodge.Creature.Radius import Dodge.Creature.Radius
@@ -46,7 +47,7 @@ createShieldWall it cr w = case it ^? itParams . flatShieldWlMIX . _Just of
crid = _crID cr crid = _crID cr
wlline = (a, b) wlline = (a, b)
crdirv = unitVectorAtAngle $ _crDir cr crdirv = unitVectorAtAngle $ _crDir cr
crpos = _crPos cr crpos =cr ^. crPos . _xy
rad = crRad (cr ^. crType) + 2 rad = crRad (cr ^. crType) + 2
a = crpos +.+ rad *.* crdirv -.- 10 *.* therot crdirv a = crpos +.+ rad *.* crdirv -.- 10 *.* therot crdirv
b = crpos +.+ rad *.* crdirv +.+ 10 *.* therot crdirv b = crpos +.+ rad *.* crdirv +.+ 10 *.* therot crdirv
+2 -1
View File
@@ -1,5 +1,6 @@
module Dodge.Item.Weapon.Shatter (shootShatter) where module Dodge.Item.Weapon.Shatter (shootShatter) where
import Linear
import Dodge.Base.Collide import Dodge.Base.Collide
import Dodge.Block.Debris import Dodge.Block.Debris
import Dodge.Data.World import Dodge.Data.World
@@ -18,7 +19,7 @@ shootShatter _ cr w =
Opaque {} -> True Opaque {} -> True
SeeThrough -> True SeeThrough -> True
_ -> False _ -> False
sp = _crPos cr +.+ 10 *.* unitVectorAtAngle dir sp = cr ^. crPos ._xy +.+ 10 *.* unitVectorAtAngle dir
-- the 10 is arbtrary and should be changed to a muzzle position -- the 10 is arbtrary and should be changed to a muzzle position
dir = _crDir cr dir = _crDir cr
ep = sp +.+ 200 *.* unitVectorAtAngle dir ep = sp +.+ 200 *.* unitVectorAtAngle dir
+2 -1
View File
@@ -1,5 +1,6 @@
module Dodge.Lampoid (updateLampoid) where module Dodge.Lampoid (updateLampoid) where
import Linear
import Dodge.Creature.State import Dodge.Creature.State
import Dodge.Data.World import Dodge.Data.World
import Dodge.LightSource import Dodge.LightSource
@@ -31,7 +32,7 @@ updateLampoid cr w = case cr ^?! crType . lampLSID of
& cWorld . lWorld . lightSources . ix i . lsParam . lsPos .~ addZ h cpos & cWorld . lWorld . lightSources . ix i . lsParam . lsPos .~ addZ h cpos
& doDamage (cr ^. crID) & doDamage (cr ^. crID)
where where
cpos = _crPos cr cpos = cr ^. crPos . _xy
cid = _crID cr cid = _crID cr
crtype = _crType cr crtype = _crType cr
h = _lampHeight crtype h = _lampHeight crtype
+2 -1
View File
@@ -1,5 +1,6 @@
module Dodge.Machine where module Dodge.Machine where
import Linear
import Dodge.Base import Dodge.Base
import Dodge.Data.World import Dodge.Data.World
import Dodge.Machine.Damage import Dodge.Machine.Damage
@@ -51,5 +52,5 @@ machineAddSound sid f mc w
| d < 200 = soundContinueVol (1 -0.005 * d) (MachineSound mid) (_mcPos mc) sid (Just 2) $ f mc w | d < 200 = soundContinueVol (1 -0.005 * d) (MachineSound mid) (_mcPos mc) sid (Just 2) $ f mc w
| otherwise = f mc w | otherwise = f mc w
where where
d = dist (_crPos $ you w) (_mcPos mc) d = dist (you w ^. crPos . _xy) (_mcPos mc)
mid = _mcID mc mid = _mcID mc
+6 -5
View File
@@ -2,6 +2,7 @@
module Dodge.Machine.Update (updateMachine) where module Dodge.Machine.Update (updateMachine) where
import Linear
import Control.Monad import Control.Monad
import Data.List (partition) import Data.List (partition)
import Data.Maybe import Data.Maybe
@@ -61,7 +62,7 @@ updateTurret rotSpeed mc w =
| elecDam < 10 = updateFiringStatus . doTurn | elecDam < 10 = updateFiringStatus . doTurn
| otherwise = id | otherwise = id
mcid = _mcID mc mcid = _mcID mc
ypos = _crPos $ you w ypos = you w ^. crPos . _xy
mcpos = _mcPos mc mcpos = _mcPos mc
seesYou = hasLOSIndirect mcpos ypos w seesYou = hasLOSIndirect mcpos ypos w
(elecDams, dams) = partition isElectrical $ _mcDamage mc (elecDams, dams) = partition isElectrical $ _mcDamage mc
@@ -122,7 +123,7 @@ mcPlaySound mc w = case _mcType mc of
w w
_ -> w _ -> w
where where
d = max 0 (dist (_crPos $ you w) (_mcPos mc) - 100) d = max 0 (dist ( you w ^. crPos . _xy) (_mcPos mc) - 100)
mid = _mcID mc mid = _mcID mc
mcApplyDamage :: [Damage] -> Machine -> World -> World mcApplyDamage :: [Damage] -> Machine -> World -> World
@@ -156,9 +157,9 @@ mcNoItemsTest mc ps w
falsetog = mc ^? mcType . _McProxSensor . proxToggle . _Just == Just False falsetog = mc ^? mcType . _McProxSensor . proxToggle . _Just == Just False
notog = notog =
null (mc ^? mcType . _McProxSensor . proxToggle . _Just) null (mc ^? mcType . _McProxSensor . proxToggle . _Just)
&& pointInPoly (cr ^. crPos) qs && pointInPoly (cr ^. crPos . _xy) qs
t = t =
((cr ^. crInv == mempty) || not (pointInPoly (cr ^. crPos) qs)) ((cr ^. crInv == mempty) || not (pointInPoly (cr ^. crPos . _xy) qs))
&& not (any ((`pointInPoly` qs) . _flItPos) (w ^. cWorld . lWorld . floorItems)) && not (any ((`pointInPoly` qs) . _flItPos) (w ^. cWorld . lWorld . floorItems))
cr = w ^?! cWorld . lWorld . creatures . ix 0 cr = w ^?! cWorld . lWorld . creatures . ix 0
mcsenslens = cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McProxSensor mcsenslens = cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McProxSensor
@@ -170,7 +171,7 @@ mcNoItemsTest mc ps w
mcProximitySensorUpdate :: mcProximitySensorUpdate ::
Machine -> ProximitySensor -> ProximityRequirement -> World -> World Machine -> ProximitySensor -> ProximityRequirement -> World -> World
mcProximitySensorUpdate mc sens pr w mcProximitySensorUpdate mc sens pr w
| truetog || dist (_crPos ycr) (_mcPos mc) > 40 = w | truetog || dist (ycr ^. crPos . _xy) (_mcPos mc) > 40 = w
| mcProxTest w pr = | mcProxTest w pr =
w w
& mcsenslens . proxToggle ?~ True & mcsenslens . proxToggle ?~ True
+3 -2
View File
@@ -1,5 +1,6 @@
module Dodge.Material.Damage (damMatSideEffect) where module Dodge.Material.Damage (damMatSideEffect) where
import Linear
import Control.Lens import Control.Lens
import Dodge.Data.World import Dodge.Data.World
import Dodge.SoundLogic import Dodge.SoundLogic
@@ -45,7 +46,7 @@ damageStone dm ecw w =
where where
v = case ecw of v = case ecw of
Right wl -> uncurry (-) $ _wlLine wl Right wl -> uncurry (-) $ _wlLine wl
Left cr -> vNormal (p - _crPos cr) Left cr -> vNormal (p - cr ^. crPos . _xy)
randsound p xs = randsound p xs =
let (x, g) = runState (takeOne xs) $ _randGen w let (x, g) = runState (takeOne xs) $ _randGen w
in soundStart so p x Nothing . set randGen g in soundStart so p x Nothing . set randGen g
@@ -76,7 +77,7 @@ damageMetal dm ecw w =
where where
v = case ecw of v = case ecw of
Right wl -> uncurry (-) $ _wlLine wl Right wl -> uncurry (-) $ _wlLine wl
Left cr -> vNormal (p - _crPos cr) Left cr -> vNormal (p - cr ^. crPos . _xy)
outTo x t = x -.- squashNormalizeV t outTo x t = x -.- squashNormalizeV t
randsound p xs = randsound p xs =
let (x, g) = runState (takeOne xs) $ _randGen w let (x, g) = runState (takeOne xs) $ _randGen w
+5 -1
View File
@@ -6,6 +6,7 @@
-} -}
module Dodge.Placement.PlaceSpot (placeSpot) where module Dodge.Placement.PlaceSpot (placeSpot) where
import Linear
import Color import Color
import Control.Monad.State import Control.Monad.State
import Data.Bifunctor import Data.Bifunctor
@@ -184,7 +185,10 @@ mvPP :: Point2 -> Float -> PressPlate -> PressPlate
mvPP p rot pp = pp{_ppPos = p, _ppRot = rot} mvPP p rot pp = pp{_ppPos = p, _ppRot = rot}
mvCr :: Point2 -> Float -> Creature -> Creature mvCr :: Point2 -> Float -> Creature -> Creature
mvCr p rot cr = cr{_crPos = p, _crOldPos = p, _crDir = rot} mvCr p rot cr = cr
& crPos . _xy .~ p
& crOldPos . _xy .~ p
& crDir .~ rot
mvFS :: Point2 -> Float -> ForegroundShape -> ForegroundShape mvFS :: Point2 -> Float -> ForegroundShape -> ForegroundShape
mvFS p a = (fsDir +~ a) . (fsPos %~ ((p +.+) . rotateV a)) mvFS p a = (fsDir +~ a) . (fsPos %~ ((p +.+) . rotateV a))
+4 -1
View File
@@ -1,5 +1,7 @@
module Dodge.PressPlate where module Dodge.PressPlate where
import Control.Lens
import Linear
import Dodge.Base.You import Dodge.Base.You
import Dodge.Data.World import Dodge.Data.World
import Dodge.WorldEvent.Explosion import Dodge.WorldEvent.Explosion
@@ -12,5 +14,6 @@ doPressPlateEvent ppe = case ppe of
ppLevelReset :: PressPlate -> World -> World ppLevelReset :: PressPlate -> World -> World
ppLevelReset pp w ppLevelReset pp w
| dist (_crPos $ you w) (_ppPos pp) < 20 = makeExplosionAt (_ppPos pp `v2z` 20) 0 w | dist (you w ^. crPos . _xy) (_ppPos pp) < 20
= makeExplosionAt (_ppPos pp `v2z` 20) 0 w
| otherwise = w | otherwise = w
+6 -4
View File
@@ -12,6 +12,7 @@ import Geometry
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import LensHelp import LensHelp
import NewInt import NewInt
import Linear
data PJStabiliser data PJStabiliser
= StabOrthReduce = StabOrthReduce
@@ -35,7 +36,7 @@ createShell (p,q) mdetonator mscreen stab pjtype payload muz cr w =
& updatedetonator & updatedetonator
& cWorld . lWorld . projectiles . at i & cWorld . lWorld . projectiles . at i
?~ Shell ?~ Shell
{ _pjPos = pos `v2z` 20 { _pjPos = pos
, _pjVel = (rotateV dir' (V2 speed 0) + crvelcomponent) `v2z` 0 , _pjVel = (rotateV dir' (V2 speed 0) + crvelcomponent) `v2z` 0
, _pjID = i , _pjID = i
, _pjDir = dir' , _pjDir = dir'
@@ -49,8 +50,8 @@ createShell (p,q) mdetonator mscreen stab pjtype payload muz cr w =
} }
where where
crvelcomponent = case stab of crvelcomponent = case stab of
Just StabOrthReduce -> projV (cr ^. crPos - cr ^. crOldPos) (unitVectorAtAngle dir) Just StabOrthReduce -> projV (cr ^. crPos . _xy - cr ^. crOldPos . _xy) (unitVectorAtAngle dir)
_ -> cr ^. crPos - cr ^. crOldPos _ -> (cr ^. crPos - cr ^. crOldPos) ^. _xy
bs = case stab of bs = case stab of
Just StabOrthReduce -> Nothing Just StabOrthReduce -> Nothing
Just StabSpinIncrease -> Just (_crID cr, 5) Just StabSpinIncrease -> Just (_crID cr, 5)
@@ -74,5 +75,6 @@ createShell (p,q) mdetonator mscreen stab pjtype payload muz cr w =
.:~ i .:~ i
i = IM.newKey $ w ^. cWorld . lWorld . projectiles i = IM.newKey $ w ^. cWorld . lWorld . projectiles
dir = _crDir cr + _mzRot muz dir = _crDir cr + _mzRot muz
pos = _crPos cr + rotateV dir (xyV3 p + rotateV (argV (Q.qToV2 q)) (_mzPos muz)) --pos = _crPos cr + rotateV dir (xyV3 p + rotateV (argV (Q.qToV2 q)) (_mzPos muz))
pos = _crPos cr + over _xy (rotateV dir) (p + addZ 0 (rotateV (argV (Q.qToV2 q)) (_mzPos muz)))
dir' = dir + argV (Q.qToV2 q) dir' = dir + argV (Q.qToV2 q)
+3 -3
View File
@@ -88,7 +88,7 @@ shellHitCreature p cr pj w
.~ Grenade .~ Grenade
( GStuckCreature ( GStuckCreature
(cr ^. crID) (cr ^. crID)
(rotate3z (- cr ^. crDir) (p - ((cr ^. crPos) `v2z` 0))) (rotate3z (- cr ^. crDir) (p - ((cr ^. crPos . _xy) `v2z` 0)))
(pj ^. pjDir - cr ^. crDir) (pj ^. pjDir - cr ^. crDir)
) )
& soundOriginIDsAt (ShellSound (pj ^. pjID)) [slapS, slap1S] (pj ^. pjPos . _xy) & soundOriginIDsAt (ShellSound (pj ^. pjID)) [slapS, slap1S] (pj ^. pjPos . _xy)
@@ -250,9 +250,9 @@ moveStuckGrenade cid poff d pj w
vel = cpos - cr ^. crOldPos vel = cpos - cr ^. crOldPos
in w in w
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjPos . _xy & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjPos . _xy
.~ xyV3 ((cpos `v2z` 0) + rotate3z cdir poff) .~ xyV3 (cpos + rotate3z cdir poff)
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjDir .~ d + cdir & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjDir .~ d + cdir
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjVel . _xy .~ vel & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjVel .~ vel
| otherwise = | otherwise =
w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjType .~ Grenade GStick w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjType .~ Grenade GStick
+21 -18
View File
@@ -1,5 +1,6 @@
module Dodge.Prop.Gib (addCrGibs) where module Dodge.Prop.Gib (addCrGibs) where
import Linear
import Color import Color
import Control.Monad import Control.Monad
import Data.Foldable import Data.Foldable
@@ -16,27 +17,27 @@ import RandomHelp
addCrGibs :: Creature -> World -> World addCrGibs :: Creature -> World -> World
addCrGibs cr = case damageDirection $ _crDamage cr of addCrGibs cr = case damageDirection $ _crDamage cr of
Nothing -> Nothing ->
addGibAt 25 (_skinHead skin) cpos addGibAt (_skinHead skin) (cpos & _z +~ 25)
. addGibsAtDir pi 0 3 7 (_skinLower skin) cpos . addGibsAtDir pi 0 3 7 (_skinLower skin) cpos
. addGibsAtDir pi 0 13 20 (_skinUpper skin) cpos . addGibsAtDir pi 0 13 20 (_skinUpper skin) cpos
. makeDustAt Flesh 50 (addZ 20 cpos) . makeDustAt Flesh 50 (cpos)
. makeDustAt Flesh 50 (addZ 20 cpos) . makeDustAt Flesh 50 (cpos)
. makeDustAt Flesh 50 (addZ 20 cpos) . makeDustAt Flesh 50 (cpos)
. makeDustAt Flesh 50 (addZ 20 cpos) . makeDustAt Flesh 50 (cpos)
Just d -> Just d ->
addGibsAtDir (pi / 4) d 3 7 (_skinLower skin) cpos addGibsAtDir (pi / 4) d 3 7 (_skinLower skin) cpos
. addGibsAtDir (pi / 4) d 13 20 (_skinUpper skin) cpos . addGibsAtDir (pi / 4) d 13 20 (_skinUpper skin) cpos
. addGibAtDir d 25 (_skinHead skin) cpos . addGibAtDir d (_skinHead skin) (cpos & _z +~ 25)
. makeDustAt Flesh 50 (addZ 20 cpos) . makeDustAt Flesh 50 cpos
. makeDustAt Flesh 50 (addZ 20 cpos) . makeDustAt Flesh 50 cpos
. makeDustAt Flesh 50 (addZ 20 cpos) . makeDustAt Flesh 50 cpos
. makeDustAt Flesh 50 (addZ 20 cpos) . makeDustAt Flesh 50 cpos
where where
skin = crShape $ _crType cr -- this should be cleaned up skin = crShape $ _crType cr -- this should be cleaned up
cpos = _crPos cr cpos = _crPos cr
-- this is ugly because it is mostly copy-paste from addGibsAt -- this is ugly because it is mostly copy-paste from addGibsAt
addGibsAtDir :: Float -> Float -> Float -> Float -> Color -> Point2 -> World -> World addGibsAtDir :: Float -> Float -> Float -> Float -> Color -> Point3 -> World -> World
addGibsAtDir spread dir minh maxh col p w = addGibsAtDir spread dir minh maxh col p w =
foldl' (flip $ addGib4 p col) w (zip4 vels zspeeds quats hs) foldl' (flip $ addGib4 p col) w (zip4 vels zspeeds quats hs)
& randGen .~ newg & randGen .~ newg
@@ -48,24 +49,26 @@ addGibsAtDir spread dir minh maxh col p w =
zspeeds = replicateM 4 (state (randomR (-8, 8))) & evalState $ _randGen w zspeeds = replicateM 4 (state (randomR (-8, 8))) & evalState $ _randGen w
quats = replicateM 4 (Q.vToQuat (V3 0 0 1) <$> randOnUnitSphere) & evalState $ _randGen w quats = replicateM 4 (Q.vToQuat (V3 0 0 1) <$> randOnUnitSphere) & evalState $ _randGen w
addGib4 :: Point2 -> Color -> (Point2, Float, QFloat, Float) -> World -> World addGib4 :: Point3 -> Color -> (Point2, Float, QFloat, Float) -> World -> World
addGib4 p col (v, zs, q, h) = addGib4 p col (v, zs, q, h) =
cWorld . lWorld . debris cWorld . lWorld . debris
.:~ DebrisChunk .:~ DebrisChunk
{ _dbPos = p `v2z` h { _dbPos = p & _z +~ h
, _dbType = Gib 3 col , _dbType = Gib 3 col
, _dbVel = v `v2z` zs , _dbVel = v `v2z` zs
, _dbRot = q , _dbRot = q
, _dbSpin = Q.axisAngle (vNormal v `v2z` 0) (-0.1) , _dbSpin = Q.axisAngle (vNormal v `v2z` 0) (-0.1)
} }
addGibAt :: Float -> Color -> Point2 -> World -> World addGibAt :: Color -> Point3 -> World -> World
addGibAt h col p w = addGibAtDir d h col p (w & randGen .~ newg) --addGibAt h col p w = addGibAtDir d h col p (w & randGen .~ newg)
addGibAt col p w = addGibAtDir d col p (w & randGen .~ newg)
where where
(d, newg) = randomR (0, 2 * pi) $ _randGen w (d, newg) = randomR (0, 2 * pi) $ _randGen w
addGibAtDir :: Float -> Float -> Color -> Point2 -> World -> World addGibAtDir :: Float -> Color -> Point3 -> World -> World
addGibAtDir dir h col p w = --addGibAtDir dir h col p w =
addGibAtDir dir col p w =
w w
& cWorld . lWorld . debris .:~ gib & cWorld . lWorld . debris .:~ gib
& randGen .~ newg & randGen .~ newg
@@ -78,7 +81,7 @@ addGibAtDir dir h col p w =
let v = s *.* unitVectorAtAngle dir let v = s *.* unitVectorAtAngle dir
return $ return $
DebrisChunk DebrisChunk
{ _dbPos = p `v2z` h { _dbPos = p
, _dbType = Gib 3 col , _dbType = Gib 3 col
, _dbVel = v `v2z` zs , _dbVel = v `v2z` zs
, _dbRot = q , _dbRot = q
+3 -2
View File
@@ -5,6 +5,7 @@ module Dodge.RadarSweep (
updateRadarSweep, updateRadarSweep,
) where ) where
import Linear
import Color import Color
import Data.Maybe import Data.Maybe
import qualified Data.Set as S import qualified Data.Set as S
@@ -29,7 +30,7 @@ aRadarPulse itid mitid armitid ob cr =
.:~ RadarSweep .:~ RadarSweep
{ _rsTimer = 50 { _rsTimer = 50
, _rsRad = 0 , _rsRad = 0
, _rsPos = _crPos cr , _rsPos = cr ^. crPos . _xy
, _rsObject = ob , _rsObject = ob
, _rsMapper = mitid , _rsMapper = mitid
, _rsAR = armitid , _rsAR = armitid
@@ -85,7 +86,7 @@ blipAt r col i p =
} }
crBlips :: Point2 -> Float -> World -> ([Point2], S.Set (Point2, Point2)) crBlips :: Point2 -> Float -> World -> ([Point2], S.Set (Point2, Point2))
crBlips p r = (,mempty) . IM.elems . IM.filter f . fmap _crPos . IM.filter g . _creatures . _lWorld . _cWorld crBlips p r = (,mempty) . IM.elems . IM.filter f . fmap (^. crPos . _xy) . IM.filter g . _creatures . _lWorld . _cWorld
where where
f q = dist p q <= r && dist p q > r - 100 f q = dist p q <= r && dist p q > r - 100
g cr = _crID cr /= 0 g cr = _crID cr /= 0
+3 -2
View File
@@ -2,6 +2,7 @@
module Dodge.Render.Picture (fixedCoordPictures) where module Dodge.Render.Picture (fixedCoordPictures) where
import Linear (_xy)
import Control.Lens import Control.Lens
import Data.Maybe import Data.Maybe
import Dodge.Base.Coordinate import Dodge.Base.Coordinate
@@ -116,7 +117,7 @@ mouseCursorType u = case u ^. uvWorld . input . mouseContext of
w = u ^. uvWorld w = u ^. uvWorld
selsec = u ^? uvWorld . hud . diSelection . _Just . slSec selsec = u ^? uvWorld . hud . diSelection . _Just . slSec
a = fromMaybe 0 $ do a = fromMaybe 0 $ do
cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos . _xy
return . toClosestMultiple (pi / 32) $ return . toClosestMultiple (pi / 32) $
argV (w ^. cWorld . lWorld . lAimPos -.- cpos) argV (w ^. cWorld . lWorld . lAimPos -.- cpos)
- w ^. wCam . camRot - w ^. wCam . camRot
@@ -293,6 +294,6 @@ drawAimSweep cr w = fold $ do
where where
cdir = _crDir cr cdir = _crDir cr
rot = campos ^. camRot rot = campos ^. camRot
p = _crPos cr p = cr ^. crPos . _xy
campos = w ^. wCam campos = w ^. wCam
mwp = w ^. cWorld . lWorld . lAimPos mwp = w ^. cWorld . lWorld . lAimPos
+2 -2
View File
@@ -26,7 +26,7 @@ worldSPic cfig u =
<> foldup drawPulseBall (filtOn _pbPos _pulseBalls) <> foldup drawPulseBall (filtOn _pbPos _pulseBalls)
<> foldup (shiftDraw _blPos _blDir (drawBlock . _blDraw)) (filtOn _blPos _blocks) <> foldup (shiftDraw _blPos _blDir (drawBlock . _blDraw)) (filtOn _blPos _blocks)
<> foldup (shiftDraw _fsPos _fsDir (const _fsSPic)) (filtOn _fsPos _foreShapes) <> foldup (shiftDraw _fsPos _fsDir (const _fsSPic)) (filtOn _fsPos _foreShapes)
<> foldup (drawCreature (lw ^. items)) (filtOn _crPos _creatures) <> foldup (drawCreature (lw ^. items)) (filtOn (^. crPos . _xy) _creatures)
<> foldup <> foldup
(Prelude.uncurry floorItemSPic) (Prelude.uncurry floorItemSPic)
( IM.intersectionWith ( IM.intersectionWith
@@ -65,7 +65,7 @@ drawPulseBall pb =
$ circleSolidCol green white 10 $ circleSolidCol green white 10
drawCreature :: IM.IntMap Item -> Creature -> SPic drawCreature :: IM.IntMap Item -> Creature -> SPic
drawCreature m cr = translateSPz (_crZ cr) . uncurryV translateSPxy (_crPos cr) . rotateSP (_crDir cr) $ drawCreature m cr = translateSP (_crPos cr) . rotateSP (_crDir cr) $
case cr ^. crType of case cr ^. crType of
_ | CrIsCorpse sp <- cr ^. crHP -> sp _ | CrIsCorpse sp <- cr ^. crHP -> sp
_ | null (cr ^? crHP . _HP) -> mempty _ | null (cr ^? crHP . _HP) -> mempty
+2 -1
View File
@@ -1,5 +1,6 @@
module Dodge.SpawnAt (respawn) where module Dodge.SpawnAt (respawn) where
import Linear
--import Dodge.SoundLogic.ExternallyGeneratedSounds --import Dodge.SoundLogic.ExternallyGeneratedSounds
import Dodge.Creature import Dodge.Creature
import Geometry.Data import Geometry.Data
@@ -20,4 +21,4 @@ spawnAt p d w = w
---- SoundStart BackgroundSound p foamSprayFadeOutS Nothing : ---- SoundStart BackgroundSound p foamSprayFadeOutS Nothing :
-- [MakeStartCloudAt (V3 x y 20 & _xy +~ p) | x <- [-5, -4 .. 5], y <- [-5, -4 .. 5]] -- [MakeStartCloudAt (V3 x y 20 & _xy +~ p) | x <- [-5, -4 .. 5], y <- [-5, -4 .. 5]]
where where
f = set crPos p . set crDir d . set crMvDir d . set crMvAim d . set crZ 0 . set crZVel 0 f = set (crPos . _xy) p . set crDir d . set crMvDir d . set crMvAim d . set (crPos . _z) 0 . set crZVel 0
+2 -1
View File
@@ -4,6 +4,7 @@ import Control.Lens
import Dodge.Data.World import Dodge.Data.World
import Geometry import Geometry
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import Linear
updateTractorBeam :: World -> TractorBeam -> (World, Maybe TractorBeam) updateTractorBeam :: World -> TractorBeam -> (World, Maybe TractorBeam)
updateTractorBeam w pj updateTractorBeam w pj
@@ -26,7 +27,7 @@ tractFlIt q p1 outpos it
tractCr :: Point2 -> Point2 -> Point2 -> Creature -> Creature tractCr :: Point2 -> Point2 -> Point2 -> Creature -> Creature
tractCr q p1 outpos cr tractCr q p1 outpos cr
| segOnCirc p1 outpos (_crPos cr) 10 = cr & crPos %~ tractorPullPos q p1 | segOnCirc p1 outpos (cr ^. crPos . _xy) 10 = cr & crPos . _xy %~ tractorPullPos q p1
| otherwise = cr | otherwise = cr
tractorPullPos :: Point2 -> Point2 -> Point2 -> Point2 tractorPullPos :: Point2 -> Point2 -> Point2 -> Point2
+7 -7
View File
@@ -317,7 +317,7 @@ checkTermDist w = fromMaybe w $ do
tmid <- w ^? hud . subInventory . termID tmid <- w ^? hud . subInventory . termID
btid <- w ^? cWorld . lWorld . terminals . ix tmid . tmButtonID btid <- w ^? cWorld . lWorld . terminals . ix tmid . tmButtonID
btpos <- w ^? cWorld . lWorld . buttons . ix btid . btPos btpos <- w ^? cWorld . lWorld . buttons . ix btid . btPos
guard $ dist btpos (_crPos $ you w) > 40 guard $ dist btpos ( you w ^. crPos . _xy) > 40
return $ w & hud . subInventory .~ NoSubInventory return $ w & hud . subInventory .~ NoSubInventory
updateMouseContext :: Config -> Universe -> Universe updateMouseContext :: Config -> Universe -> Universe
@@ -505,7 +505,7 @@ updateCreatureSoundPositions w =
$ _playingSounds w $ _playingSounds w
where where
insertSound w' k s = w' & toPlaySounds %~ M.insertWith (const id) k s insertSound w' k s = w' & toPlaySounds %~ M.insertWith (const id) k s
updateSound (CrMouth cid) s = case w ^? cWorld . lWorld . creatures . ix cid . crPos of updateSound (CrMouth cid) s = case w ^? cWorld . lWorld . creatures . ix cid . crPos . _xy of
Just p -> Just s{_soundPos = p, _soundAngDist = Just (soundAngle p w, 0)} Just p -> Just s{_soundPos = p, _soundAngDist = Just (soundAngle p w, 0)}
Nothing -> Just s{_soundTime = Just 0} Nothing -> Just s{_soundTime = Just 0}
updateSound _ _ = Nothing updateSound _ _ = Nothing
@@ -846,11 +846,11 @@ dustSpringVel a v b
simpleCrSprings :: World -> World simpleCrSprings :: World -> World
simpleCrSprings w = IM.foldl' (flip crSpring) w simpleCrSprings w = IM.foldl' (flip crSpring) w
$ IM.filter (\cr -> _crZ cr >= 0) $ w ^. cWorld . lWorld . creatures $ IM.filter (\cr -> cr ^. crPos . _z >= 0) $ w ^. cWorld . lWorld . creatures
-- note that this may in rare cases not push creatures away from each other -- note that this may in rare cases not push creatures away from each other
crSpring :: Creature -> World -> World crSpring :: Creature -> World -> World
crSpring c w = foldl' (flip $ crCrSpring c) w $ crsNearPoint (_crPos c) w crSpring c w = foldl' (flip $ crCrSpring c) w $ crsNearPoint (c ^. crPos . _xy) w
crCrSpring :: Creature -> Creature -> World -> World crCrSpring :: Creature -> Creature -> World -> World
crCrSpring c1 c2 crCrSpring c1 c2
@@ -859,13 +859,13 @@ crCrSpring c1 c2
| diff >= comRad = id | diff >= comRad = id
| otherwise = | otherwise =
cWorld . lWorld . creatures cWorld . lWorld . creatures
%~ ( over (ix id1 . crPos) (+.+ overlap1) %~ ( over (ix id1 . crPos . _xy) (+.+ overlap1)
. over (ix id2 . crPos) (-.- overlap2) . over (ix id2 . crPos . _xy) (-.- overlap2)
) )
where where
id1 = _crID c1 id1 = _crID c1
id2 = _crID c2 id2 = _crID c2
vec = _crPos c1 -.- _crPos c2 vec = c1 ^. crPos . _xy -.- c2 ^. crPos . _xy
diff = magV vec diff = magV vec
comRad = crRad (c1 ^. crType) + crRad (c2 ^. crType) comRad = crRad (c1 ^. crType) + crRad (c2 ^. crType)
overlap1 = ((comRad - diff) * crMass (_crType c2) * 0.5 / massT) *.* errorNormalizeV 55 vec overlap1 = ((comRad - diff) * crMass (_crType c2) * 0.5 / massT) *.* errorNormalizeV 55 vec
+3 -3
View File
@@ -87,8 +87,8 @@ updateInGameCamera cfig w =
moveZoomCamera :: Config -> Input -> Creature -> World -> Camera -> Camera moveZoomCamera :: Config -> Input -> Creature -> World -> Camera -> Camera
moveZoomCamera cfig theinput cr w campos = moveZoomCamera cfig theinput cr w campos =
campos campos
& camCenter .~ fromMaybe (_crPos cr +.+ offset) mremotepos & camCenter .~ fromMaybe (cr ^. crPos . _xy +.+ offset) mremotepos
& camViewFrom .~ fromMaybe (_crPos cr) mremotepos & camViewFrom .~ fromMaybe (cr ^. crPos . _xy) mremotepos
& camZoom .~ newzoom & camZoom .~ newzoom
& camDefaultZoom .~ newDefaultZoom & camDefaultZoom .~ newDefaultZoom
& camItemZoom .~ newItemZoom & camItemZoom .~ newItemZoom
@@ -215,7 +215,7 @@ rotateToOverlappingWall w =
w w
where where
cr = you w cr = you w
p = _crPos (you w) p = (you w) ^. crPos . _xy
doWallRotate :: Wall -> World -> World doWallRotate :: Wall -> World -> World
doWallRotate wl w doWallRotate wl w
+2 -1
View File
@@ -6,11 +6,12 @@ import Dodge.Data.World
import Dodge.Zoning.Creature import Dodge.Zoning.Creature
import Geometry.Vector3D import Geometry.Vector3D
import LensHelp import LensHelp
import Linear
cloudPoisonDamage :: Cloud -> World -> World cloudPoisonDamage :: Cloud -> World -> World
cloudPoisonDamage c w = foldl' (flip doDam) w (filter f $ crsNearPoint clpos w) cloudPoisonDamage c w = foldl' (flip doDam) w (filter f $ crsNearPoint clpos w)
where where
doDam cr = doDam cr =
cWorld . lWorld . creatures . ix (_crID cr) . crDamage .:~ Poison 1 cWorld . lWorld . creatures . ix (_crID cr) . crDamage .:~ Poison 1
f cr = dist3 (addZ 20 $ _crPos cr) (_clPos c) < crRad (cr ^. crType) + 20 f cr = dist3 (_crPos cr & _z +~ 20) (_clPos c) < crRad (cr ^. crType) + 20
clpos = stripZ $ _clPos c clpos = stripZ $ _clPos c
+2 -2
View File
@@ -383,7 +383,7 @@ updateKeysInTerminal :: Int -> Universe -> Universe
updateKeysInTerminal tmid u = fromMaybe deactivate $ do updateKeysInTerminal tmid u = fromMaybe deactivate $ do
tm <- u ^? uvWorld . cWorld . lWorld . terminals . ix tmid tm <- u ^? uvWorld . cWorld . lWorld . terminals . ix tmid
x <- u ^? uvWorld . cWorld . lWorld . buttons . ix (tm ^. tmButtonID) . btPos x <- u ^? uvWorld . cWorld . lWorld . buttons . ix (tm ^. tmButtonID) . btPos
y <- u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crPos y <- u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crPos . _xy
case tm ^. tmStatus of case tm ^. tmStatus of
_ | dist x y > 40 || not (hasButtonLOS x y (u ^. uvWorld)) -> Nothing _ | dist x y > 40 || not (hasButtonLOS x y (u ^. uvWorld)) -> Nothing
TerminalDeactivated -> Nothing TerminalDeactivated -> Nothing
@@ -553,7 +553,7 @@ tryCombine (i, j) w = fromMaybe w $ do
. ix j . ix j
. siPayload . siPayload
. _Just . _Just
p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos . _xy
return $ return $
createItemYou it (foldr (destroyInvItem 0 . NInt) w (sort is)) createItemYou it (foldr (destroyInvItem 0 . NInt) w (sort is))
& soundStart InventorySound p wrench1S Nothing & soundStart InventorySound p wrench1S Nothing
+12 -10
View File
@@ -6,6 +6,7 @@ module Dodge.WallCreatureCollisions (
crOnWall, crOnWall,
) where ) where
import Linear
import Dodge.Creature.Radius import Dodge.Creature.Radius
import Control.Lens import Control.Lens
import Data.Maybe import Data.Maybe
@@ -35,15 +36,15 @@ colCrWall w c
-- c'' = c' & crPos %~ pushOutFromWalls rad ls -- c'' = c' & crPos %~ pushOutFromWalls rad ls
--c' = c & crPos %~ pushOutFromWalls' rad (reverse ls) --c' = c & crPos %~ pushOutFromWalls' rad (reverse ls)
c' = c' =
c & crPos c & crPos . _xy
%~ pushOutFromCorners r ls' %~ pushOutFromCorners r ls'
. pushOutFromWalls r ls' . pushOutFromWalls r ls'
. fst . fst
. flip (collidePoint p1) wls -- check push throughs . flip (collidePoint p1) wls -- check push throughs
-- . flip (collidePointWalls' p1) wls -- check push throughs -- . flip (collidePointWalls' p1) wls -- check push throughs
r = crRad (c ^. crType) + wallBuffer r = crRad (c ^. crType) + wallBuffer
p1 = _crOldPos c p1 = c ^. crOldPos . _xy
p2 = _crPos c p2 = c ^. crPos . _xy
ls = _wlLine <$> wls ls = _wlLine <$> wls
ls' = filter (uncurry $ isLHS p1) ls ls' = filter (uncurry $ isLHS p1) ls
wls = filter (not . _wlWalkable) $ wlsNearRect (p2 +.+ V2 r r) (p2 -.- V2 r r) w wls = filter (not . _wlWalkable) $ wlsNearRect (p2 +.+ V2 r r) (p2 -.- V2 r r) w
@@ -53,7 +54,8 @@ wallBuffer :: Float
wallBuffer = 0 wallBuffer = 0
pushCreatureOutFromWalls :: [(Point2, Point2)] -> Creature -> Creature pushCreatureOutFromWalls :: [(Point2, Point2)] -> Creature -> Creature
pushCreatureOutFromWalls ls cr = cr & crPos %~ pushOutFromWalls (crRad (cr ^. crType)) ls pushCreatureOutFromWalls ls cr = cr & crPos . _xy
%~ pushOutFromWalls (crRad (cr ^. crType)) ls
-- the following tests whether or not a point is on a wall, and if so pushes it -- the following tests whether or not a point is on a wall, and if so pushes it
-- out from the wall -- out from the wall
@@ -74,13 +76,13 @@ pushOutFromWalls rad wls p1 = case (getFirst . foldMap (First . pushOutFromWall
pushOrCrush :: [(Point2, Point2)] -> Creature -> Creature pushOrCrush :: [(Point2, Point2)] -> Creature -> Creature
pushOrCrush wls cr = case mapMaybe (pushOutFromWall (crRad (cr ^. crType)) cpos) wls of pushOrCrush wls cr = case mapMaybe (pushOutFromWall (crRad (cr ^. crType)) cpos) wls of
[] -> cr [] -> cr
(p : _) -> cr & crPos .~ p (p : _) -> cr & crPos . _xy .~ p
where where
-- (_:p:_) -> cr -- (_:p:_) -> cr
-- & crPos .~ p -- & crPos .~ p
-- & crState . crDamage %~ ( Blunt 50 cpos cpos cpos : ) -- & crState . crDamage %~ ( Blunt 50 cpos cpos cpos : )
cpos = _crPos cr cpos = cr ^. crPos . _xy
-- note the inclusion of endpoints in circOnSeg -- note the inclusion of endpoints in circOnSeg
crOnWall :: Creature -> World -> Bool crOnWall :: Creature -> World -> Bool
@@ -89,7 +91,7 @@ crOnWall cr =
. filter (not . _wlWalkable) . filter (not . _wlWalkable)
. wlsNearPoint p . wlsNearPoint p
where where
p = _crPos cr p = cr ^. crPos . _xy
r = crRad (cr ^. crType) r = crRad (cr ^. crType)
-- assumes that the wall is orientated -- assumes that the wall is orientated
@@ -99,9 +101,9 @@ pushOutFromWall rad cp2 (wp1, wp2)
| isOnWall = Just newP | isOnWall = Just newP
| otherwise = Nothing | otherwise = Nothing
where where
norm = errorNormalizeV 61 $ vNormal (wp1 -.- wp2) n = errorNormalizeV 61 $ vNormal (wp1 -.- wp2)
wp1' = wp1 +.+ rad *.* norm wp1' = wp1 +.+ rad *.* n
wp2' = wp2 +.+ rad *.* norm wp2' = wp2 +.+ rad *.* n
newP = errorClosestPointOnLine 5 wp1' wp2' cp2 newP = errorClosestPointOnLine 5 wp1' wp2' cp2
isOnWall = circOnSegNoEndpoints wp1 wp2 cp2 rad isOnWall = circOnSegNoEndpoints wp1 wp2 cp2 rad
+2 -1
View File
@@ -15,6 +15,7 @@ module Dodge.WorldEvent.ThingsHit (
crWlPbHit, crWlPbHit,
) where ) where
import Linear
import Dodge.Data.Object import Dodge.Data.Object
import Dodge.Creature.Radius import Dodge.Creature.Radius
import Control.Monad import Control.Monad
@@ -148,6 +149,6 @@ crsHitRadial :: Point2 -> Float -> World -> [(Point2, Creature)]
crsHitRadial p r = mapMaybe f . crsNearCirc p r crsHitRadial p r = mapMaybe f . crsNearCirc p r
where where
f cr = do f cr = do
let cp = _crPos cr let cp = cr ^. crPos . _xy
guard $ dist p cp < r + crRad (_crType cr) guard $ dist p cp < r + crRad (_crType cr)
return (cp + (1 + crRad (_crType cr)) *.* (cp - p), cr) return (cp + (1 + crRad (_crType cr)) *.* (cp - p), cr)
+5 -2
View File
@@ -1,10 +1,13 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.WorldPos where module Dodge.WorldPos where
import Dodge.Base.You import Dodge.Base.You
import Dodge.Data.World import Dodge.Data.World
import Geometry import Geometry
import Control.Lens
import Linear
doWorldPos :: WdP2 -> World -> Point2 doWorldPos :: WdP2 -> World -> Point2
doWorldPos wp2 = case wp2 of doWorldPos = \case
WdP2Const p -> const p WdP2Const p -> const p
WdYouPos -> _crPos . you WdYouPos -> (^. crPos . _xy) . you
+2 -1
View File
@@ -10,6 +10,7 @@ import Dodge.Zoning.Common
import FoldableHelp import FoldableHelp
import Geometry import Geometry
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import Linear
crIXsNearPoint :: Point2 -> World -> IS.IntSet crIXsNearPoint :: Point2 -> World -> IS.IntSet
crIXsNearPoint = nearPoint crZoneSize _crZoning crIXsNearPoint = nearPoint crZoneSize _crZoning
@@ -42,7 +43,7 @@ crZoneSize :: Float
crZoneSize = 15 crZoneSize = 15
zoneOfCr :: Creature -> [Int2] zoneOfCr :: Creature -> [Int2]
zoneOfCr cr = zoneOfCirc crZoneSize (_crPos cr) (crRad $ cr ^. crType) zoneOfCr cr = zoneOfCirc crZoneSize (cr ^. crPos . _xy) (crRad $ cr ^. crType)
minCrIXOn :: Ord a => (Creature -> a) -> IS.IntSet -> World -> Maybe Creature minCrIXOn :: Ord a => (Creature -> a) -> IS.IntSet -> World -> Maybe Creature
minCrIXOn f is w = fst <$> IS.foldl' g Nothing is minCrIXOn f is w = fst <$> IS.foldl' g Nothing is
+36 -37
View File
@@ -727,7 +727,7 @@ MODStringOption src/Dodge/Data/Universe.hs 97;" C
MOTOR src/Dodge/Data/Item/Combine.hs 64;" C MOTOR src/Dodge/Data/Item/Combine.hs 64;" C
MP2Ac src/Dodge/Data/CreatureEffect.hs 56;" t MP2Ac src/Dodge/Data/CreatureEffect.hs 56;" t
MP2NoAction src/Dodge/Data/CreatureEffect.hs 56;" C MP2NoAction src/Dodge/Data/CreatureEffect.hs 56;" C
MPO src/Dodge/Base/Collide.hs 88;" t MPO src/Dodge/Base/Collide.hs 87;" t
MTRS src/Dodge/Data/MTRS.hs 6;" t MTRS src/Dodge/Data/MTRS.hs 6;" t
MTree src/Dodge/Data/MetaTree.hs 11;" C MTree src/Dodge/Data/MetaTree.hs 11;" C
Machine src/Dodge/Data/Machine.hs 30;" t Machine src/Dodge/Data/Machine.hs 30;" t
@@ -2613,7 +2613,7 @@ airlockDoor src/Dodge/Room/Airlock.hs 93;" f
airlockDoubleDoor src/Dodge/Room/Airlock.hs 96;" f airlockDoubleDoor src/Dodge/Room/Airlock.hs 96;" f
airlockSimple src/Dodge/Room/Airlock.hs 108;" f airlockSimple src/Dodge/Room/Airlock.hs 108;" f
airlockZ src/Dodge/Room/Airlock.hs 133;" f airlockZ src/Dodge/Room/Airlock.hs 133;" f
allVisibleWalls src/Dodge/Base/Collide.hs 226;" f allVisibleWalls src/Dodge/Base/Collide.hs 215;" f
alongSegBy src/Geometry.hs 40;" f alongSegBy src/Geometry.hs 40;" f
alteRifle src/Dodge/Item/Held/Cane.hs 22;" f alteRifle src/Dodge/Item/Held/Cane.hs 22;" f
ammoMagInfo src/Dodge/Item/Info.hs 49;" f ammoMagInfo src/Dodge/Item/Info.hs 49;" f
@@ -2631,7 +2631,7 @@ angleBetween src/Geometry.hs 158;" f
angleVV src/Geometry/Vector.hs 58;" f angleVV src/Geometry/Vector.hs 58;" f
angleVV3 src/Geometry/Vector3D.hs 122;" f angleVV3 src/Geometry/Vector3D.hs 122;" f
anyUnusedSpot src/Dodge/PlacementSpot.hs 66;" f anyUnusedSpot src/Dodge/PlacementSpot.hs 66;" f
anythingHitCirc src/Dodge/Base/Collide.hs 349;" f anythingHitCirc src/Dodge/Base/Collide.hs 338;" f
applyCME src/Dodge/HeldUse.hs 361;" f applyCME src/Dodge/HeldUse.hs 361;" f
applyCreatureDamage src/Dodge/Creature/Damage.hs 13;" f applyCreatureDamage src/Dodge/Creature/Damage.hs 13;" f
applyEventIO src/Loop.hs 89;" f applyEventIO src/Loop.hs 89;" f
@@ -2781,7 +2781,7 @@ blunderbuss src/Dodge/Item/Held/Cone.hs 14;" f
bossKeyItems src/Dodge/LockAndKey.hs 12;" f bossKeyItems src/Dodge/LockAndKey.hs 12;" f
bossRoom src/Dodge/Room/Boss.hs 61;" f bossRoom src/Dodge/Room/Boss.hs 61;" f
bounceDir src/Dodge/Bullet.hs 109;" f bounceDir src/Dodge/Bullet.hs 109;" f
bouncePoint src/Dodge/Base/Collide.hs 84;" f bouncePoint src/Dodge/Base/Collide.hs 83;" f
boundPoints src/Bound.hs 10;" f boundPoints src/Bound.hs 10;" f
boundedGrid src/Grid.hs 19;" f boundedGrid src/Grid.hs 19;" f
boxABC src/Polyhedra.hs 108;" f boxABC src/Polyhedra.hs 108;" f
@@ -2814,8 +2814,8 @@ cFilledRect src/Dodge/CharacterEnums.hs 6;" f
cWireRect src/Dodge/CharacterEnums.hs 10;" f cWireRect src/Dodge/CharacterEnums.hs 10;" f
calcSmoothScroll src/Dodge/SmoothScroll.hs 11;" f calcSmoothScroll src/Dodge/SmoothScroll.hs 11;" f
calcTexCoord src/Tile.hs 19;" f calcTexCoord src/Tile.hs 19;" f
canSee src/Dodge/Base/Collide.hs 335;" f canSee src/Dodge/Base/Collide.hs 324;" f
canSeeIndirect src/Dodge/Base/Collide.hs 342;" f canSeeIndirect src/Dodge/Base/Collide.hs 331;" f
cancelExamineInventory src/Dodge/Item/BackgroundEffect.hs 22;" f cancelExamineInventory src/Dodge/Item/BackgroundEffect.hs 22;" f
capacitor src/Dodge/Item/Ammo.hs 69;" f capacitor src/Dodge/Item/Ammo.hs 69;" f
cardEightVec src/Dodge/Base/CardinalPoint.hs 17;" f cardEightVec src/Dodge/Base/CardinalPoint.hs 17;" f
@@ -2845,7 +2845,7 @@ chaseCritPerceptionUpdate src/Dodge/Creature/Perception.hs 31;" f
chaseCritVocalization src/Dodge/Creature/ChaseCrit.hs 37;" f chaseCritVocalization src/Dodge/Creature/ChaseCrit.hs 37;" f
chasmSimpleMaze src/Dodge/Room/Tutorial.hs 175;" f chasmSimpleMaze src/Dodge/Room/Tutorial.hs 175;" f
chasmTest src/Dodge/Creature/Update.hs 131;" f chasmTest src/Dodge/Creature/Update.hs 131;" f
chasmWallToSurface src/Dodge/Base/Collide.hs 110;" f chasmWallToSurface src/Dodge/Base/Collide.hs 109;" f
checkCombineSelectionExists src/Dodge/DisplayInventory.hs 100;" f checkCombineSelectionExists src/Dodge/DisplayInventory.hs 100;" f
checkConnection src/Dodge/Inventory/Swap.hs 65;" f checkConnection src/Dodge/Inventory/Swap.hs 65;" f
checkDeath src/Dodge/Creature/Update.hs 69;" f checkDeath src/Dodge/Creature/Update.hs 69;" f
@@ -2870,12 +2870,12 @@ chooseMovementLtAuto src/Dodge/CreatureEffect.hs 105;" f
chooseMovementPistol src/Dodge/Humanoid.hs 203;" f chooseMovementPistol src/Dodge/Humanoid.hs 203;" f
chooseMovementPistol' src/Dodge/Humanoid.hs 208;" f chooseMovementPistol' src/Dodge/Humanoid.hs 208;" f
chooseMovementSpreadGun src/Dodge/CreatureEffect.hs 88;" f chooseMovementSpreadGun src/Dodge/CreatureEffect.hs 88;" f
circHitWall src/Dodge/Base/Collide.hs 243;" f circHitWall src/Dodge/Base/Collide.hs 232;" f
circInPolygon src/Geometry/Polygon.hs 101;" f circInPolygon src/Geometry/Polygon.hs 101;" f
circOnAnyCr src/Dodge/Base/Collide.hs 298;" f circOnAnyCr src/Dodge/Base/Collide.hs 287;" f
circOnSeg src/Geometry.hs 101;" f circOnSeg src/Geometry.hs 101;" f
circOnSegNoEndpoints src/Geometry.hs 91;" f circOnSegNoEndpoints src/Geometry.hs 91;" f
circOnSomeWall src/Dodge/Base/Collide.hs 292;" f circOnSomeWall src/Dodge/Base/Collide.hs 281;" f
circle src/Picture/Base.hs 180;" f circle src/Picture/Base.hs 180;" f
circleDecoration src/Dodge/Placement/TopDecoration.hs 56;" f circleDecoration src/Dodge/Placement/TopDecoration.hs 56;" f
circleSolid src/Picture/Base.hs 164;" f circleSolid src/Picture/Base.hs 164;" f
@@ -2923,18 +2923,18 @@ colCrWall src/Dodge/WallCreatureCollisions.hs 28;" f
colCrsWalls src/Dodge/WallCreatureCollisions.hs 18;" f colCrsWalls src/Dodge/WallCreatureCollisions.hs 18;" f
collectDamageTypes src/Dodge/Damage.hs 53;" f collectDamageTypes src/Dodge/Damage.hs 53;" f
collectInvItems src/Dodge/Update/Input/InGame.hs 295;" f collectInvItems src/Dodge/Update/Input/InGame.hs 295;" f
collide3 src/Dodge/Base/Collide.hs 119;" f collide3 src/Dodge/Base/Collide.hs 118;" f
collide3Chasm src/Dodge/Base/Collide.hs 103;" f collide3Chasm src/Dodge/Base/Collide.hs 102;" f
collide3Chasms src/Dodge/Base/Collide.hs 96;" f collide3Chasms src/Dodge/Base/Collide.hs 95;" f
collide3Creature src/Dodge/Base/Collide.hs 153;" f collide3Creature src/Dodge/Base/Collide.hs 152;" f
collide3Floors src/Dodge/Base/Collide.hs 134;" f collide3Floors src/Dodge/Base/Collide.hs 133;" f
collide3Wall src/Dodge/Base/Collide.hs 148;" f collide3Wall src/Dodge/Base/Collide.hs 147;" f
collide3Walls src/Dodge/Base/Collide.hs 128;" f collide3Walls src/Dodge/Base/Collide.hs 127;" f
collide3WallsFloor src/Dodge/Base/Collide.hs 90;" f collide3WallsFloor src/Dodge/Base/Collide.hs 89;" f
collideCircWalls src/Dodge/Base/Collide.hs 255;" f collideCircWalls src/Dodge/Base/Collide.hs 244;" f
collidePoint src/Dodge/Base/Collide.hs 54;" f collidePoint src/Dodge/Base/Collide.hs 53;" f
collidePointTestFilter src/Dodge/Base/Collide.hs 191;" f collidePointTestFilter src/Dodge/Base/Collide.hs 180;" f
collidePointWallsFilter src/Dodge/Base/Collide.hs 205;" f collidePointWallsFilter src/Dodge/Base/Collide.hs 194;" f
color src/Picture/Base.hs 108;" f color src/Picture/Base.hs 108;" f
colorLamp src/Dodge/Creature/Lamp.hs 10;" f colorLamp src/Dodge/Creature/Lamp.hs 10;" f
colorSH src/Shape.hs 237;" f colorSH src/Shape.hs 237;" f
@@ -2996,7 +2996,7 @@ crDisplayAwareness src/Dodge/Creature/Picture/Awareness.hs 38;" f
crDisplayVigilance src/Dodge/Creature/Picture/Awareness.hs 52;" f crDisplayVigilance src/Dodge/Creature/Picture/Awareness.hs 52;" f
crHasTarget src/Dodge/Creature/Test.hs 64;" f crHasTarget src/Dodge/Creature/Test.hs 64;" f
crHasTargetLOS src/Dodge/Creature/Test.hs 67;" f crHasTargetLOS src/Dodge/Creature/Test.hs 67;" f
crHeight src/Dodge/Base/Collide.hs 164;" f crHeight src/Dodge/Base/Collide.hs 165;" f
crHit src/Dodge/WorldEvent/ThingsHit.hs 112;" f crHit src/Dodge/WorldEvent/ThingsHit.hs 112;" f
crIXsNearCirc src/Dodge/Zoning/Creature.hs 32;" f crIXsNearCirc src/Dodge/Zoning/Creature.hs 32;" f
crIXsNearPoint src/Dodge/Zoning/Creature.hs 14;" f crIXsNearPoint src/Dodge/Zoning/Creature.hs 14;" f
@@ -3251,7 +3251,7 @@ doBackspace src/Dodge/Update/Input/Text.hs 31;" f
doBarrelSpin src/Dodge/Projectile/Update.hs 211;" f doBarrelSpin src/Dodge/Projectile/Update.hs 211;" f
doBlBl src/Dodge/BlBl.hs 5;" f doBlBl src/Dodge/BlBl.hs 5;" f
doBlSh src/Dodge/Block/Draw.hs 14;" f doBlSh src/Dodge/Block/Draw.hs 14;" f
doBounce src/Dodge/Base/Collide.hs 66;" f doBounce src/Dodge/Base/Collide.hs 65;" f
doButtonEvent src/Dodge/Button/Event.hs 9;" f doButtonEvent src/Dodge/Button/Event.hs 9;" f
doConLoop src/Loop.hs 137;" f doConLoop src/Loop.hs 137;" f
doConLoop' src/Loop.hs 226;" f doConLoop' src/Loop.hs 226;" f
@@ -3766,10 +3766,10 @@ handleResizeEvent src/Dodge/Event.hs 53;" f
handleTextInput src/Dodge/Event/Input.hs 19;" f handleTextInput src/Dodge/Event/Input.hs 19;" f
handleWindowMoveEvent src/Dodge/Event.hs 44;" f handleWindowMoveEvent src/Dodge/Event.hs 44;" f
hardQuit src/Dodge/Concurrent.hs 32;" f hardQuit src/Dodge/Concurrent.hs 32;" f
hasButtonLOS src/Dodge/Base/Collide.hs 312;" f hasButtonLOS src/Dodge/Base/Collide.hs 301;" f
hasCaneGunDim src/Dodge/Item/InvSize.hs 48;" f hasCaneGunDim src/Dodge/Item/InvSize.hs 48;" f
hasLOS src/Dodge/Base/Collide.hs 305;" f hasLOS src/Dodge/Base/Collide.hs 294;" f
hasLOSIndirect src/Dodge/Base/Collide.hs 321;" f hasLOSIndirect src/Dodge/Base/Collide.hs 310;" f
hat src/Dodge/Item/Equipment.hs 76;" f hat src/Dodge/Item/Equipment.hs 76;" f
head src/DoubleStack.hs 14;" f head src/DoubleStack.hs 14;" f
headLamp src/Dodge/Item/Equipment.hs 79;" f headLamp src/Dodge/Item/Equipment.hs 79;" f
@@ -3856,8 +3856,8 @@ interpWith src/Dodge/Creature/Boid.hs 11;" f
intersectCircLine src/Geometry/Intersect.hs 373;" f intersectCircLine src/Geometry/Intersect.hs 373;" f
intersectCircLineAlong src/Geometry/Intersect.hs 364;" f intersectCircLineAlong src/Geometry/Intersect.hs 364;" f
intersectCircSeg src/Geometry/Intersect.hs 353;" f intersectCircSeg src/Geometry/Intersect.hs 353;" f
intersectCircSegFirst src/Geometry/Intersect.hs 415;" f intersectCircSegFirst src/Geometry/Intersect.hs 417;" f
intersectCircSegTest src/Geometry/Intersect.hs 407;" f intersectCircSegTest src/Geometry/Intersect.hs 409;" f
intersectCylSeg src/Geometry/Intersect.hs 382;" f intersectCylSeg src/Geometry/Intersect.hs 382;" f
intersectLineLine src/Geometry/Intersect.hs 19;" f intersectLineLine src/Geometry/Intersect.hs 19;" f
intersectLinePlaneAlong src/Geometry/Intersect.hs 34;" f intersectLinePlaneAlong src/Geometry/Intersect.hs 34;" f
@@ -3934,7 +3934,7 @@ isUnusedLnkType src/Dodge/PlacementSpot.hs 190;" f
isUsedLnkUnplaced src/Dodge/PlacementSpot.hs 174;" f isUsedLnkUnplaced src/Dodge/PlacementSpot.hs 174;" f
isValidCommand src/Dodge/Debug/Terminal.hs 134;" f isValidCommand src/Dodge/Debug/Terminal.hs 134;" f
isVowel src/StringHelp.hs 8;" f isVowel src/StringHelp.hs 8;" f
isWalkable src/Dodge/Base/Collide.hs 328;" f isWalkable src/Dodge/Base/Collide.hs 317;" f
isoMatrix src/MatrixHelper.hs 30;" f isoMatrix src/MatrixHelper.hs 30;" f
isotriBWH src/Geometry/Polygon.hs 21;" f isotriBWH src/Geometry/Polygon.hs 21;" f
itDim src/Dodge/Item/InvSize.hs 21;" f itDim src/Dodge/Item/InvSize.hs 21;" f
@@ -4413,10 +4413,10 @@ overPos src/Picture/Base.hs 303;" f
overPosObj src/Shape.hs 277;" f overPosObj src/Shape.hs 277;" f
overPosSH src/Shape.hs 261;" f overPosSH src/Shape.hs 261;" f
overPosSP src/ShapePicture.hs 41;" f overPosSP src/ShapePicture.hs 41;" f
overlapCircWalls src/Dodge/Base/Collide.hs 232;" f overlapCircWalls src/Dodge/Base/Collide.hs 221;" f
overlapCircWallsClosest src/Dodge/Base/Collide.hs 278;" f overlapCircWallsClosest src/Dodge/Base/Collide.hs 267;" f
overlapSegCrs src/Dodge/Base/Collide.hs 60;" f overlapSegCrs src/Dodge/Base/Collide.hs 59;" f
overlapSegWalls src/Dodge/Base/Collide.hs 214;" f overlapSegWalls src/Dodge/Base/Collide.hs 203;" f
overrideInternal src/Dodge/Creature/ReaderUpdate.hs 174;" f overrideInternal src/Dodge/Creature/ReaderUpdate.hs 174;" f
overrideMeleeCloseTarget src/Dodge/Creature/ReaderUpdate.hs 35;" f overrideMeleeCloseTarget src/Dodge/Creature/ReaderUpdate.hs 35;" f
overwriteLabel src/Dodge/Tree/Compose.hs 31;" f overwriteLabel src/Dodge/Tree/Compose.hs 31;" f
@@ -4779,7 +4779,6 @@ restrictInLinks src/Dodge/RoomLink.hs 44;" f
restrictLinkType src/Dodge/RoomLink.hs 34;" f restrictLinkType src/Dodge/RoomLink.hs 34;" f
restrictOutLinks src/Dodge/RoomLink.hs 47;" f restrictOutLinks src/Dodge/RoomLink.hs 47;" f
restrictRMInLinksPD src/Dodge/Room/Link.hs 25;" f restrictRMInLinksPD src/Dodge/Room/Link.hs 25;" f
restrictSeg src/Dodge/Base/Collide.hs 173;" f
resumeSound src/Dodge/SoundLogic.hs 48;" f resumeSound src/Dodge/SoundLogic.hs 48;" f
retreatActionsPistol src/Dodge/Humanoid.hs 249;" f retreatActionsPistol src/Dodge/Humanoid.hs 249;" f
retreatFireLauncher src/Dodge/Humanoid.hs 270;" f retreatFireLauncher src/Dodge/Humanoid.hs 270;" f
@@ -5625,7 +5624,7 @@ viewClipBounds src/Dodge/Debug/Picture.hs 329;" f
viewDistanceFromItems src/Dodge/Update/Camera.hs 194;" f viewDistanceFromItems src/Dodge/Update/Camera.hs 194;" f
viewTarget src/Dodge/Creature/ReaderUpdate.hs 146;" f viewTarget src/Dodge/Creature/ReaderUpdate.hs 146;" f
violet src/Color.hs 21;" f violet src/Color.hs 21;" f
visibleWalls src/Dodge/Base/Collide.hs 218;" f visibleWalls src/Dodge/Base/Collide.hs 207;" f
visionCheck src/Dodge/Creature/Perception.hs 153;" f visionCheck src/Dodge/Creature/Perception.hs 153;" f
vocalizationTest src/Dodge/Creature/Vocalization.hs 42;" f vocalizationTest src/Dodge/Creature/Vocalization.hs 42;" f
volleyGun src/Dodge/Item/Held/Cane.hs 15;" f volleyGun src/Dodge/Item/Held/Cane.hs 15;" f
@@ -5636,7 +5635,7 @@ wallBlips src/Dodge/RadarSweep.hs 98;" f
wallBuffer src/Dodge/WallCreatureCollisions.hs 52;" f wallBuffer src/Dodge/WallCreatureCollisions.hs 52;" f
wallIsZeroLength src/Dodge/LevelGen/StaticWalls.hs 179;" f wallIsZeroLength src/Dodge/LevelGen/StaticWalls.hs 179;" f
wallLine src/Dodge/Placement/Instance/Wall.hs 71;" f wallLine src/Dodge/Placement/Instance/Wall.hs 71;" f
wallToSurface src/Dodge/Base/Collide.hs 183;" f wallToSurface src/Dodge/Base/Collide.hs 172;" f
wallsFromRooms src/Dodge/Layout.hs 132;" f wallsFromRooms src/Dodge/Layout.hs 132;" f
wallsToDraw src/Dodge/Render/Walls.hs 17;" f wallsToDraw src/Dodge/Render/Walls.hs 17;" f
warmupSound src/Dodge/HeldUse.hs 1421;" f warmupSound src/Dodge/HeldUse.hs 1421;" f