Refactor crPos to be a V3
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
3392801227273840162
|
||||
7114951007332849727
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
module Dodge.Barreloid (updateBarreloid) where
|
||||
|
||||
import Linear
|
||||
import Data.List
|
||||
import Data.Maybe
|
||||
import Dodge.Creature.State
|
||||
@@ -29,16 +30,16 @@ updateExpBarrel ps cr w = case cr ^. crHP of
|
||||
& flip (foldl' f) ps
|
||||
HP _ ->
|
||||
w
|
||||
& makeExplosionAt ((cr ^. crPos) `v2z` 20) 0
|
||||
& makeExplosionAt ((cr ^. crPos) & _z +~ 20) 0
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ CrIsGibs
|
||||
_ -> w
|
||||
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
|
||||
hiss
|
||||
| null ps = id
|
||||
| otherwise = soundContinue
|
||||
(BarrelHiss (_crID cr)) (_crPos cr) foamSprayLoopS (Just 1)
|
||||
(BarrelHiss (_crID cr)) (cr ^. crPos . _xy) foamSprayLoopS (Just 1)
|
||||
|
||||
updateBarrel :: Creature -> World -> World
|
||||
updateBarrel cr = case cr ^. crHP of
|
||||
@@ -53,7 +54,7 @@ damToExpBarrel :: Creature -> Damage -> Creature
|
||||
damToExpBarrel cr dm = case dm of
|
||||
Piercing x p _ ->
|
||||
cr & crHP . _HP -~ div x 200
|
||||
& crType . barrelType . piercedPoints .:~ (p - _crPos cr)
|
||||
& crType . barrelType . piercedPoints .:~ (p - cr ^. crPos . _xy)
|
||||
Poison{} -> cr
|
||||
Sparking{} -> cr
|
||||
_ -> cr & crHP . _HP -~ fromMaybe 0 (dm ^? dmAmount)
|
||||
|
||||
+10
-11
@@ -37,6 +37,7 @@ module Dodge.Base.Collide (
|
||||
collide3,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import qualified Data.IntSet as IS
|
||||
@@ -60,7 +61,7 @@ overlapSegCrs :: Point2 -> Point2 -> [Creature] -> [(Point2, Creature)]
|
||||
{-# INLINE overlapSegCrs #-}
|
||||
overlapSegCrs sp ep =
|
||||
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)
|
||||
{-# INLINE doBounce #-}
|
||||
@@ -125,7 +126,7 @@ collide3 sp ep w =
|
||||
|
||||
-- Just (hitpoint,normaltosurface)
|
||||
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
|
||||
f x wl = collide3Wall sp wl x
|
||||
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
|
||||
h <- crHeight cr
|
||||
(p,n) <- fst $ intersectCylSeg
|
||||
(addZ (cr ^. crZ) cpos)
|
||||
(cr ^. crPos)
|
||||
(crRad $ cr ^. crType)
|
||||
h
|
||||
sp
|
||||
ep
|
||||
return (p, Just (n,OCreature cr))
|
||||
where
|
||||
cpos = cr ^. crPos
|
||||
|
||||
crHeight :: Creature -> Maybe Float
|
||||
crHeight cr = case cr ^. crHP of
|
||||
@@ -288,7 +287,7 @@ circOnAnyCr :: Point2 -> Float -> World -> Bool
|
||||
{-# INLINE circOnAnyCr #-}
|
||||
circOnAnyCr p r w = IS.foldr f False $ crIXsNearPoint p w
|
||||
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
|
||||
hasLOS :: Point2 -> Point2 -> World -> Bool
|
||||
@@ -325,15 +324,15 @@ canSee :: Int -> Int -> World -> Bool
|
||||
{-# INLINE canSee #-}
|
||||
canSee i j w = hasLOS p1 p2 w
|
||||
where
|
||||
p1 = w ^?! cWorld . lWorld . creatures . ix i . crPos -- _crPos (_creatures (_cWorld w) IM.! i)
|
||||
p2 = w ^?! cWorld . lWorld . creatures . ix j . crPos -- _crPos (_creatures (_cWorld w) IM.! j) -- unsafe
|
||||
p1 = w ^?! cWorld . lWorld . creatures . ix i . crPos . _xy -- _crPos (_creatures (_cWorld w) IM.! i)
|
||||
p2 = w ^?! cWorld . lWorld . creatures . ix j . crPos . _xy -- _crPos (_creatures (_cWorld w) IM.! j) -- unsafe
|
||||
|
||||
canSeeIndirect :: Int -> Int -> World -> Bool
|
||||
{-# INLINE canSeeIndirect #-}
|
||||
canSeeIndirect i j w = hasLOSIndirect ipos jpos w
|
||||
where
|
||||
ipos = w ^?! cWorld . lWorld . creatures . ix i . crPos
|
||||
jpos = w ^?! cWorld . lWorld . creatures . ix j . crPos
|
||||
ipos = w ^?! cWorld . lWorld . creatures . ix i . crPos . _xy
|
||||
jpos = w ^?! cWorld . lWorld . creatures . ix j . crPos . _xy
|
||||
|
||||
anythingHitCirc :: Float -> Point2 -> Point2 -> World -> Bool
|
||||
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 =
|
||||
maybe
|
||||
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)
|
||||
|| bl
|
||||
|
||||
|
||||
+3
-1
@@ -17,6 +17,7 @@ import Geometry
|
||||
import LensHelp
|
||||
import qualified ListHelp as List
|
||||
import System.Random
|
||||
import Linear
|
||||
|
||||
updateBullet :: World -> Bullet -> (World, Maybe Bullet)
|
||||
updateBullet w bu
|
||||
@@ -108,7 +109,8 @@ updateBulVel bt = bt & buVel .*.*~ _buDrag bt
|
||||
|
||||
bounceDir :: IM.IntMap Item -> (Point2, Either Creature Wall) -> Maybe Point2
|
||||
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
|
||||
|
||||
useBulletPayload :: Bullet -> Point2 -> World -> World
|
||||
|
||||
@@ -92,8 +92,8 @@ ID 0.
|
||||
startCr :: Creature
|
||||
startCr =
|
||||
defaultCreature
|
||||
& crPos .~ V2 20 0
|
||||
& crOldPos .~ V2 20 0
|
||||
& crPos .~ V3 20 0 0
|
||||
& crOldPos .~ V3 20 0 0
|
||||
& crDir .~ pi / 2
|
||||
& crMvDir .~ pi / 2
|
||||
& crID .~ 0
|
||||
|
||||
@@ -13,6 +13,7 @@ module Dodge.Creature.Action (
|
||||
youDropItem,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import NewInt
|
||||
import Dodge.Creature.MoveType
|
||||
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)
|
||||
where
|
||||
cdir = _crDir cr
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
canSee' = canSee (_crID cr) tcid w
|
||||
aimSp = case crMvType cr ^? mvAimSpeed of
|
||||
Just f -> doFloatFloat f $ safeAngleVV (unitVectorAtAngle cdir) (tpos - cpos)
|
||||
Nothing -> error "creature without aiming type"
|
||||
tpos
|
||||
| canSee' = w ^?! cWorld . lWorld . creatures . ix tcid . crPos
|
||||
| canSee' = w ^?! cWorld . lWorld . creatures . ix tcid . crPos . _xy
|
||||
| otherwise = p
|
||||
|
||||
performPathTo :: Creature -> World -> Point2 -> OutAction
|
||||
@@ -73,7 +74,7 @@ performPathTo cr w p
|
||||
)
|
||||
_ -> ([], Nothing)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
jit = _mvTurnJit $ crMvType cr
|
||||
|
||||
performTurnToA :: Creature -> Point2 -> OutAction
|
||||
@@ -81,7 +82,7 @@ performTurnToA cr p
|
||||
| angleVV cdirv dirv < 0.1 = ([], Nothing)
|
||||
| otherwise = ([MvTurnToward p, RandomTurn jit], Just (TurnToPoint p))
|
||||
where
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
cdirv = unitVectorAtAngle (_crDir cr)
|
||||
dirv = p -.- cpos
|
||||
jit = _mvTurnJit $ crMvType cr
|
||||
@@ -121,15 +122,15 @@ performAction cr w ac = case ac of
|
||||
DoActions acs ->
|
||||
let (imps, newAcs) = unzip $ map (performAction cr w) acs
|
||||
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
|
||||
TurnToPoint p -> performTurnToA cr p
|
||||
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)
|
||||
UseTarget f -> performAction cr w $ doMCrAc f $ cr ^? crIntention . targetCr . _Just
|
||||
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
|
||||
ArbitraryAction f -> performAction cr w (doCrWdAc f cr w)
|
||||
DoImpulsesAlongside sideImp mainAc -> case performAction cr w mainAc of
|
||||
@@ -175,10 +176,10 @@ dropItem :: Creature -> Int -> World -> World
|
||||
dropItem cr invid w' =
|
||||
doanyitemdropeffect
|
||||
. maybeshiftseldown
|
||||
. copyItemToFloor (_crPos cr) itm -- . mayberemoveequip
|
||||
. copyItemToFloor (cr ^. crPos . _xy) itm -- . mayberemoveequip
|
||||
. rmInvItem (_crID cr) (NInt invid) -- it is important
|
||||
-- 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'
|
||||
where
|
||||
--doanyitemdropeffect = fromMaybe id $ do
|
||||
|
||||
@@ -5,6 +5,7 @@ module Dodge.Creature.Action.Blink (
|
||||
unsafeBlinkAction,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import Dodge.Creature.Radius
|
||||
import Dodge.Zoning.Wall
|
||||
import Data.Maybe
|
||||
@@ -25,13 +26,13 @@ blinkActionMousePos cr w =
|
||||
w
|
||||
& soundMultiFrom [TeleSound 0, TeleSound 1] p3 teleS Nothing
|
||||
& blinkDistortions cpos p3
|
||||
& cWorld . lWorld . creatures . ix cid . crPos .~ p3
|
||||
& cWorld . lWorld . creatures . ix cid . crPos . _xy .~ p3
|
||||
& blinkShockwave cid p3
|
||||
& inverseShockwaveAt (cpos `v2z` 20) 40 2 2
|
||||
where
|
||||
cid = _crID cr
|
||||
p1 = w ^. cWorld . lWorld . lAimPos
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
--p2 = bouncePoint (const True) 1 cpos p1 w
|
||||
p2 = pushIntoMaybe $ collideCircWalls cpos p1 r (wlsNearSeg cpos p1 w)
|
||||
r = crRad $ cr ^. crType
|
||||
@@ -61,7 +62,7 @@ unsafeBlinkAction cr w
|
||||
| success =
|
||||
soundMultiFrom [TeleSound 0, TeleSound 1] mwp teleS Nothing
|
||||
. blinkDistortions cpos mwp
|
||||
. set (cWorld . lWorld . creatures . ix cid . crPos) mwp
|
||||
. set (cWorld . lWorld . creatures . ix cid . crPos . _xy) mwp
|
||||
. blinkShockwave cid mwp
|
||||
$ inverseShockwaveAt (cpos `v2z` 20) 40 2 2 w
|
||||
| otherwise =
|
||||
@@ -74,7 +75,7 @@ unsafeBlinkAction cr w
|
||||
return (isLHS mwp `uncurry` _wlLine wl)
|
||||
cid = _crID cr
|
||||
mwp = w ^. cWorld . lWorld . lAimPos
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
|
||||
blinkShockwave ::
|
||||
-- | Blinking creature ID.
|
||||
@@ -93,14 +94,14 @@ blinkActionFail cr w =
|
||||
w
|
||||
& soundMultiFrom [TeleSound 0, TeleSound 1] p3 teleS Nothing
|
||||
& 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
|
||||
where
|
||||
distR = 120
|
||||
distortionBulge = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9
|
||||
cid = _crID cr
|
||||
p1 = w ^. cWorld . lWorld . lAimPos
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
p2 = bouncePoint (const True) 1 cpos p1 w
|
||||
r = 1.5 * crRad (cr ^. crType)
|
||||
p3 = maybe p1 (mvPointTowardAtSpeed r cpos . fst) p2
|
||||
|
||||
+44
-40
@@ -1,5 +1,6 @@
|
||||
module Dodge.Creature.Boid where
|
||||
|
||||
import Linear
|
||||
import Dodge.Creature.Radius
|
||||
import Control.Lens
|
||||
import Control.Monad.Reader
|
||||
@@ -16,28 +17,28 @@ invertEncircleDistP d tcr cenp cr =
|
||||
ypos
|
||||
+.+ d *.* reflectIn (cenp -.- ypos) (squashNormalizeV (cpos -.- cenp))
|
||||
where
|
||||
cpos = _crPos cr
|
||||
ypos = _crPos tcr
|
||||
cpos = cr ^. crPos . _xy
|
||||
ypos = tcr ^. crPos . _xy
|
||||
|
||||
encircleDistP :: Float -> Creature -> Point2 -> Creature -> Point2
|
||||
encircleDistP d tcr cenp cr = ypos +.+ d *.* squashNormalizeV (cpos -.- cenp)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
ypos = _crPos tcr
|
||||
cpos = cr ^. crPos . _xy
|
||||
ypos = tcr ^. crPos . _xy
|
||||
|
||||
encircleP :: Creature -> Point2 -> Creature -> Point2
|
||||
encircleP tcr cenp cr = ypos +.+ 50 *.* squashNormalizeV (cpos -.- cenp)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
ypos = _crPos tcr
|
||||
cpos = cr ^. crPos . _xy
|
||||
ypos = tcr ^. crPos . _xy
|
||||
|
||||
--f x = 150 * sigmoid (x-10)
|
||||
|
||||
encircleCloseP :: Creature -> Point2 -> Creature -> Point2
|
||||
encircleCloseP tcr cenp cr = ypos +.+ f (max 0 (magV (ypos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
ypos = _crPos tcr
|
||||
cpos = cr ^. crPos . _xy
|
||||
ypos = tcr ^. crPos . _xy
|
||||
f x = 150 * sigmoid (x -10)
|
||||
|
||||
forbidFlee ::
|
||||
@@ -50,8 +51,8 @@ forbidFlee f tcr cenp cr
|
||||
| ptargTest = tpos
|
||||
| otherwise = ptarg
|
||||
where
|
||||
cpos = _crPos cr
|
||||
tpos = _crPos tcr
|
||||
cpos = cr ^. crPos . _xy
|
||||
tpos = tcr ^. crPos . _xy
|
||||
ptarg = f tcr cenp cr
|
||||
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 tcr cenp cr = tpos +.+ splitp -- +.+ 25 *.* (normalizeV $ tpos -.- cenp)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
tpos = _crPos tcr
|
||||
cpos = cr ^. crPos . _xy
|
||||
tpos = tcr ^. crPos . _xy
|
||||
splitp
|
||||
| isLHS cenp cpos tpos =
|
||||
150 *.* orthCenpTpos
|
||||
@@ -75,8 +76,8 @@ pincerP tcr cenp cr = tpos +.+ splitp -- +.+ 25 *.* (normalizeV $ tpos -.- cenp)
|
||||
pincerP''' :: Creature -> Point2 -> Creature -> Point2
|
||||
pincerP''' tcr cenp cr = interpWith (sigmoid $ 0.05 * dtcen) cenawayp cenclosep
|
||||
where
|
||||
cpos = _crPos cr
|
||||
tpos = _crPos tcr
|
||||
cpos = cr ^. crPos . _xy
|
||||
tpos = tcr ^. crPos . _xy
|
||||
dtcen = dist tpos cenp
|
||||
f x = 150 * sigmoid (x -10)
|
||||
cenawayp
|
||||
@@ -97,8 +98,8 @@ pincerP' tcr cenp cr
|
||||
cenp +.+ f (max 0 (magV (tpos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp)
|
||||
| otherwise = tpos +.+ f (max 0 (magV (tpos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
tpos = _crPos tcr
|
||||
cpos = cr ^. crPos . _xy
|
||||
tpos = tcr ^. crPos . _xy
|
||||
f x = 150 * sigmoid (x -10)
|
||||
|
||||
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)
|
||||
| otherwise = tpos +.+ f (max 0 (magV (tpos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
tpos = _crPos tcr
|
||||
cpos = cr ^. crPos . _xy
|
||||
tpos = tcr ^. crPos . _xy
|
||||
f x = 150 * sigmoid (x -10)
|
||||
|
||||
encircle :: Creature -> IM.IntMap Creature -> Creature -> Point2
|
||||
@@ -118,17 +119,17 @@ encircle tcr crs cr
|
||||
| length crs <= 1 = ypos
|
||||
| otherwise = ypos +.+ f (max 0 (magV (ypos -.- cenp) - 80)) *.* squashNormalizeV (cpos -.- cenp)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
ypos = _crPos tcr
|
||||
cpos = cr ^. crPos . _xy
|
||||
ypos = tcr ^. crPos . _xy
|
||||
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 tcr crs cr = p
|
||||
where
|
||||
ypos = _crPos tcr
|
||||
cpos = _crPos cr
|
||||
ps = map _crPos $ IM.elems crs
|
||||
ypos = tcr ^. crPos . _xy
|
||||
cpos = cr ^. crPos . _xy
|
||||
ps = map (^. crPos . _xy) $ IM.elems crs
|
||||
cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps
|
||||
p
|
||||
| dist cen ypos < 20 = ypos
|
||||
@@ -137,10 +138,11 @@ lineOrth tcr crs cr = p
|
||||
holdForm :: Creature -> IM.IntMap Creature -> Creature -> Point2
|
||||
holdForm ycr crs cr = p
|
||||
where
|
||||
ypos = _crPos ycr
|
||||
cpos = _crPos cr
|
||||
ps = map _crPos $ IM.elems crs
|
||||
cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps
|
||||
ypos = ycr ^. crPos . _xy
|
||||
cpos = cr ^. crPos . _xy
|
||||
ps = map (^. crPos . _xy) $ IM.elems crs
|
||||
cen = centroid ps
|
||||
--cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps
|
||||
p
|
||||
| dist cen ypos < 20 = ypos
|
||||
| otherwise = ypos +.+ cpos -.- cen
|
||||
@@ -148,20 +150,22 @@ holdForm ycr crs cr = p
|
||||
lineUp :: Creature -> IM.IntMap Creature -> Creature -> Point2
|
||||
lineUp ycr crs cr = p
|
||||
where
|
||||
ypos = _crPos ycr
|
||||
cpos = _crPos cr
|
||||
ps = map _crPos $ IM.elems crs
|
||||
cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps
|
||||
ypos = ycr ^. crPos . _xy
|
||||
cpos = cr ^. crPos . _xy
|
||||
ps = map (^. crPos . _xy) $ IM.elems crs
|
||||
--cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps
|
||||
cen = centroid ps
|
||||
p = (0.05 *.* ypos) +.+ (0.95 *.* errorClosestPointOnLine 500 cen ypos cpos)
|
||||
|
||||
-- not nice, a kind of encircle
|
||||
spreadOut :: Creature -> IM.IntMap Creature -> Creature -> Point2
|
||||
spreadOut ycr crs cr = p
|
||||
where
|
||||
ypos = _crPos ycr
|
||||
cpos = _crPos cr
|
||||
ps = map _crPos $ IM.elems crs
|
||||
cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps
|
||||
ypos = ycr ^. crPos . _xy
|
||||
cpos = cr ^. crPos . _xy
|
||||
ps = map (^. crPos . _xy) $ IM.elems crs
|
||||
cen = centroid ps
|
||||
-- cen = (1 / fromIntegral (length ps)) *.* foldr1 (+.+) ps
|
||||
p
|
||||
| dist cen ypos < 30 = ypos
|
||||
| otherwise = ypos +.+ (spreadFactor *.* cpos -.- cen)
|
||||
@@ -307,8 +311,8 @@ meleeHeadingMove maxta minta tacutoff speed tp cr tcr
|
||||
[MoveForward speed, TurnToward tp maxta, RandomTurn maxta]
|
||||
| otherwise = [MoveForward speed, TurnToward tp minta, RandomTurn maxta]
|
||||
where
|
||||
cpos = _crPos cr
|
||||
tpos = _crPos tcr
|
||||
cpos = cr ^. crPos . _xy
|
||||
tpos = tcr ^. crPos . _xy
|
||||
combinedRad = crRad (cr ^. crType) + crRad (tcr ^. crType)
|
||||
|
||||
mvPointMeleeTarg :: Point2 -> Creature -> Creature -> [Impulse]
|
||||
@@ -324,6 +328,6 @@ mvPointMeleeTarg p cr crT
|
||||
[MoveForward 3, TurnToward p 0.2, RandomTurn 0.2]
|
||||
| otherwise = [MoveForward 3, TurnToward p 0.05, RandomTurn 0.2]
|
||||
where
|
||||
cpos = _crPos cr
|
||||
tpos = _crPos crT
|
||||
cpos = cr ^. crPos . _xy
|
||||
tpos = crT ^. crPos . _xy
|
||||
combinedRad = crRad (cr ^. crType) + crRad (crT ^. crType)
|
||||
|
||||
@@ -3,16 +3,17 @@ module Dodge.Creature.ChooseTarget where
|
||||
import Control.Lens
|
||||
import Dodge.Base
|
||||
import Dodge.Data.World
|
||||
import Linear
|
||||
|
||||
targetYouLOS :: Creature -> World -> Maybe Creature
|
||||
{-# INLINE targetYouLOS #-}
|
||||
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
|
||||
|
||||
targetYouCognizant :: Creature -> World -> Maybe Creature
|
||||
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) =
|
||||
Just $ you w
|
||||
| otherwise = Nothing
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.Creature.Damage (applyCreatureDamage) where
|
||||
|
||||
import Linear
|
||||
import Dodge.Material.Damage
|
||||
import Data.List
|
||||
import Dodge.Creature.Mass
|
||||
@@ -25,11 +26,11 @@ applyPiercingDamage cr dm w
|
||||
= f . makeSpark NormalSpark p1 (argV (p1 - p)) $ w
|
||||
| otherwise = f . damageHP cr (_dmAmount dm) $ w
|
||||
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
|
||||
x = crMass (_crType cr)
|
||||
p = _dmPos dm
|
||||
p1 = p + 2 *.* squashNormalizeV (p - _crPos cr)
|
||||
p1 = p + 2 *.* squashNormalizeV (p - cr ^. crPos . _xy)
|
||||
|
||||
damageHP :: Creature -> Int -> World -> World
|
||||
damageHP cr x =
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
|
||||
module Dodge.Creature.Impulse (
|
||||
impulsiveAIBefore,
|
||||
) where
|
||||
module Dodge.Creature.Impulse (impulsiveAIBefore) where
|
||||
|
||||
import Linear
|
||||
import NewInt
|
||||
import Dodge.Creature.MoveType
|
||||
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
|
||||
)
|
||||
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
|
||||
ChangeStrategy strat -> crup $ cr & crActionPlan . apStrategy .~ strat
|
||||
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
|
||||
Just tcr -> followImpulse cr w (doCrImp f tcr)
|
||||
_ -> 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
|
||||
MvTurnToward p ->
|
||||
crup $
|
||||
@@ -81,10 +80,10 @@ followImpulse cr w imp = case imp of
|
||||
mvType = crMvType cr
|
||||
speed = _mvSpeed mvType
|
||||
turnRad = doFloatFloat $ _mvTurnRad mvType
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
cdir = _crDir 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
|
||||
hitCr i =
|
||||
cWorld . lWorld . creatures . ix i . crDamage
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
module Dodge.Creature.Impulse.Flee where
|
||||
|
||||
import Control.Lens
|
||||
import Linear
|
||||
import Dodge.Data.World
|
||||
import FoldableHelp
|
||||
import Geometry
|
||||
|
||||
retreatPointForFrom ::
|
||||
Float -> World -> Creature -> Point2 -> Maybe Point2
|
||||
retreatPointForFrom :: Float -> World -> Creature -> Point2 -> Maybe Point2
|
||||
retreatPointForFrom d _ cr p =
|
||||
safeMinimumOn (dist cpos) $
|
||||
divideCircle 10 p d
|
||||
where
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
|
||||
-- = head $ sortBy (compare `on` (\p -> dist p ypos < 300)) $ retreatP'' : retreatPs
|
||||
-- where
|
||||
|
||||
@@ -7,6 +7,7 @@ module Dodge.Creature.Impulse.Movement (
|
||||
creatureTurnTo,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import Control.Lens
|
||||
import Dodge.Base
|
||||
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 lw p' cr =
|
||||
advanceStepCounter (magV p) cr
|
||||
& crPos +~ p
|
||||
& crPos . _xy +~ p
|
||||
& crMvDir .~ argV p
|
||||
where
|
||||
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
|
||||
| otherwise = cr & crDir .~ dirToTarget
|
||||
where
|
||||
vToTarg = p -.- _crPos cr
|
||||
vToTarg = p -.- cr ^. crPos . _xy
|
||||
dirToTarget = argV vToTarg
|
||||
|
||||
-- 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
|
||||
| otherwise = cr & crDir -~ turnSpeed
|
||||
where
|
||||
vToTarg = p -.- _crPos cr
|
||||
vToTarg = p -.- cr ^. crPos . _xy
|
||||
dirToTarget = argV vToTarg
|
||||
|
||||
@@ -95,7 +95,7 @@ chaseCritAwarenessUpdate w cr = case _cpAttention $ _crPerception cr of
|
||||
replicate numjits [RandomImpulse thejitter]
|
||||
++ [[ChangeStrategy $ CloseToMelee 0]]
|
||||
)
|
||||
, AimAt 0 (w ^?! cWorld . lWorld . creatures . ix 0 . crPos)
|
||||
, AimAt 0 (w ^?! cWorld . lWorld . creatures . ix 0 . crPos . _xy)
|
||||
]
|
||||
| otherwise = id
|
||||
|
||||
@@ -147,14 +147,14 @@ newExtraAwareness cr w cid
|
||||
| not $ canSeeIndirect (_crID cr) cid w = Nothing
|
||||
| otherwise = Just . Suspicious $ visionCheck cr tpos * awakeLevelPerception cr
|
||||
where
|
||||
tpos = w ^?! cWorld . lWorld . creatures . ix cid . crPos -- _crPos $ _creatures (_cWorld w) IM.! cid
|
||||
cpos = _crPos cr
|
||||
tpos = w ^?! cWorld . lWorld . creatures . ix cid . crPos . _xy -- _crPos $ _creatures (_cWorld w) IM.! cid
|
||||
cpos = cr ^. crPos . _xy
|
||||
|
||||
visionCheck :: Creature -> Point2 -> Float
|
||||
visionCheck cr tpos = doFloatFloat (_viFOV vi) ang * doFloatFloat (_viDist vi) d
|
||||
where
|
||||
vi = _cpVision $ _crPerception cr
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
dirvec = unitVectorAtAngle (_crDir cr)
|
||||
ang = angleVV dirvec (tpos - (cpos - crRad (cr ^. crType) *^ dirvec))
|
||||
d = dist tpos cpos
|
||||
@@ -187,4 +187,4 @@ soundIsClose w cr (pos, vol) =
|
||||
&& vol > doFloatFloat (_auDist . _cpAudition $ _crPerception cr) (dist pos cpos)
|
||||
&& hasLOS cpos pos w
|
||||
where
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.Creature.Picture.Awareness where
|
||||
|
||||
import Linear (_xy)
|
||||
import Dodge.Creature.Radius
|
||||
import qualified Data.Vector as V
|
||||
import Dodge.Clock
|
||||
@@ -31,7 +32,7 @@ creatureDisplayText w cr =
|
||||
lw = w ^. cWorld . lWorld
|
||||
campos = w ^. wCam . camViewFrom
|
||||
theScale = 0.15 / (w ^. wCam . camZoom)
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
v = cpos -.- campos
|
||||
(V2 x y) = campos +.+ v +.+ crRad (cr ^. crType) *.* normalizeV v
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ module Dodge.Creature.ReaderUpdate (
|
||||
setViewPos,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import Dodge.Creature.Vocalization
|
||||
import Dodge.Creature.Radius
|
||||
import RandomHelp
|
||||
@@ -47,16 +48,16 @@ tryMeleeAttack cr tcr
|
||||
& crActionPlan . apStrategy .~ MeleeStrike
|
||||
| otherwise = cr
|
||||
where
|
||||
cpos = _crPos cr
|
||||
tpos = _crPos tcr
|
||||
cpos = cr ^. crPos . _xy
|
||||
tpos = tcr ^. crPos . _xy
|
||||
|
||||
setMvPos :: World -> Creature -> Creature
|
||||
setMvPos w cr = cr & crIntention . mvToPoint .~ mpos
|
||||
where
|
||||
int = _crIntention cr
|
||||
mtpos = do
|
||||
tpos <- _crPos <$> _targetCr int
|
||||
guard $ hasLOSIndirect (_crPos cr) tpos w
|
||||
tpos <- (^. crPos . _xy) <$> _targetCr int
|
||||
guard $ hasLOSIndirect (cr ^. crPos . _xy) tpos w
|
||||
return tpos
|
||||
mpos = mtpos <|> _mvToPoint int
|
||||
|
||||
@@ -70,8 +71,8 @@ attentionViewPoint w cr = do
|
||||
attention <- cr ^? crPerception . cpAttention . getAttentiveTo
|
||||
cid <- sortOn snd (IM.toList attention) ^? ix 0 . _1
|
||||
tcr <- w ^? cWorld . lWorld . creatures . ix cid
|
||||
guard $ visionCheck cr (_crPos tcr) > 0
|
||||
return (_crPos tcr)
|
||||
guard $ visionCheck cr (tcr ^. crPos . _xy) > 0
|
||||
tcr ^? crPos . _xy
|
||||
|
||||
setTargetMv ::
|
||||
-- | Function for determining target
|
||||
@@ -82,7 +83,7 @@ setTargetMv ::
|
||||
setTargetMv targFunc w cr =
|
||||
maybe
|
||||
cr
|
||||
(\ctarg -> cr & crIntention . mvToPoint ?~ _crPos ctarg)
|
||||
(\ctarg -> cr & crIntention . mvToPoint ?~ (ctarg ^. crPos . _xy))
|
||||
(targFunc w cr)
|
||||
|
||||
-- ugly
|
||||
@@ -90,14 +91,14 @@ flockACC :: World -> Creature -> Creature
|
||||
flockACC w cr = case cr ^? crIntention . targetCr . _Just of
|
||||
Nothing -> cr
|
||||
Just tcr ->
|
||||
let tpos = _crPos tcr
|
||||
cpos = _crPos cr
|
||||
let tpos = tcr ^. crPos . _xy
|
||||
cpos = cr ^. crPos . _xy
|
||||
isFarACC cr' =
|
||||
_crGroup cr' == _crGroup cr
|
||||
&& _crID cr' /= _crID cr
|
||||
&& dist (_crPos cr') tpos > dist cpos tpos
|
||||
&& dist (cr' ^. crPos . _xy) tpos > dist cpos tpos
|
||||
macr =
|
||||
safeMinimumOn (dist cpos . _crPos)
|
||||
safeMinimumOn (dist cpos . (^. crPos . _xy))
|
||||
. filter isFarACC
|
||||
$ crsNearCirc cpos 50 w
|
||||
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
|
||||
horDir = normalizeV (vNormal (cpos -.- tpos))
|
||||
horShift =
|
||||
if isLHS tpos cpos (_crPos acr)
|
||||
if isLHS tpos cpos (acr ^. crPos . _xy)
|
||||
then r *.* horDir
|
||||
else negate r *.* horDir
|
||||
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)
|
||||
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
||||
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 ->
|
||||
cr & crActionPlan . apAction .~ [bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]]
|
||||
& crActionPlan . apStrategy .~ WatchAndWait
|
||||
@@ -146,7 +147,7 @@ goToTarget w cr = case cr ^? crIntention . mvToPoint . _Just of
|
||||
viewTarget :: World -> Creature -> Creature
|
||||
viewTarget w cr = case cr ^? crIntention . viewPoint . _Just of
|
||||
Just p
|
||||
| hasLOSIndirect p (_crPos cr) w ->
|
||||
| hasLOSIndirect p (cr ^. crPos . _xy) w ->
|
||||
cr
|
||||
& crActionPlan . apAction
|
||||
.~ [TurnToPoint p]
|
||||
@@ -210,7 +211,7 @@ searchIfDamaged cr
|
||||
& crActionPlan . apStrategy
|
||||
.~ StrategyActions
|
||||
LookAround
|
||||
[ TurnToPoint (_crPos cr -.- unitVectorAtAngle (_crDir cr))
|
||||
[ TurnToPoint (cr ^. crPos . _xy -.- unitVectorAtAngle (_crDir cr))
|
||||
`DoActionThen` 40 `WaitThen` bfsThenReturn 500
|
||||
]
|
||||
| otherwise = cr
|
||||
|
||||
+11
-10
@@ -4,6 +4,7 @@ module Dodge.Creature.State (
|
||||
invItemEffs,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import NewInt
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
@@ -121,7 +122,7 @@ coolMachinePistol cr itm w
|
||||
dosound s =
|
||||
soundContinue
|
||||
(CrWeaponSound (_crID cr) (fromIntegral $ _itID itm))
|
||||
(_crPos cr)
|
||||
(cr ^. crPos . _xy)
|
||||
s
|
||||
(Just 1)
|
||||
d = pointerToItem itm . itParams
|
||||
@@ -227,7 +228,7 @@ shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ d
|
||||
x = 1
|
||||
isammolink AmmoMagSF{} = True
|
||||
isammolink _ = False
|
||||
pos = _crPos cr + xyV3 (rotate3 cdir p)
|
||||
pos = cr ^. crPos . _xy + xyV3 (rotate3 cdir p)
|
||||
cdir = _crDir cr
|
||||
itm = itmtree ^. dtValue . _1
|
||||
pointittarg = cWorld . lWorld . items . ix itid . itTargeting
|
||||
@@ -251,7 +252,7 @@ shineTorch cr loc = fromMaybe id $ do
|
||||
x = 10
|
||||
isammolink AmmoMagSF{} = True
|
||||
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
|
||||
|
||||
-- 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
|
||||
where
|
||||
newtarg =
|
||||
safeMinimumOn (dist mwp . _crPos)
|
||||
. filter (canseepos . _crPos)
|
||||
safeMinimumOn (dist mwp . (^. crPos . _xy))
|
||||
. filter (canseepos . (^. crPos . _xy))
|
||||
$ crsNearCirc mwp 40 w
|
||||
canseepos p = hasLOS (_crPos cr) p w
|
||||
canseepos p = hasLOS ((^. crPos . _xy) cr) p w
|
||||
mwp = w ^. cWorld . lWorld . lAimPos
|
||||
updatePos t' = t' & itTgPos .~ posFromMaybeID (_itTgID t')
|
||||
posFromMaybeID Nothing = Nothing
|
||||
posFromMaybeID (Just i) = w ^? cWorld . lWorld . creatures . ix i . crPos
|
||||
posFromMaybeID Nothing = Nothing
|
||||
posFromMaybeID (Just i) = w ^? cWorld . lWorld . creatures . ix i . crPos . _xy
|
||||
canSeeTarget = fromMaybe False $ do
|
||||
cid <- ituse ^? itTgID . _Just
|
||||
cpos <- w ^? cWorld . lWorld . creatures . ix cid . crPos
|
||||
Just $ hasLOS cpos (_crPos cr) w
|
||||
cpos <- w ^? cWorld . lWorld . creatures . ix cid . crPos . _xy
|
||||
Just $ hasLOS cpos ( cr ^. crPos . _xy) w
|
||||
|
||||
--isFrictionless :: Creature -> Bool
|
||||
--isFrictionless cr = case cr ^? crStance . carriage of
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
module Dodge.Creature.State.WalkCycle (updateWalkCycle) where
|
||||
|
||||
import Linear
|
||||
import Control.Lens
|
||||
import Dodge.Data.World
|
||||
import Dodge.SoundLogic
|
||||
@@ -15,7 +16,7 @@ updateWalkCycle cid w
|
||||
w
|
||||
& soundMultiFrom
|
||||
[FootstepSound i | i <- [0 .. 10]]
|
||||
(cr ^. crPos)
|
||||
(cr ^. crPos . _xy)
|
||||
(chooseFootSound ff)
|
||||
Nothing
|
||||
& over (cWorld . lWorld . creatures . ix cid . crStance . carriage) resetStride
|
||||
|
||||
@@ -24,6 +24,7 @@ module Dodge.Creature.Test (
|
||||
crSafeDistFromTarg,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import NewInt
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Dodge.Creature.Radius
|
||||
@@ -49,7 +50,7 @@ import Geometry
|
||||
-- return (x > 0)
|
||||
|
||||
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 tcid (w, cr) = fromMaybe False $ do
|
||||
@@ -71,7 +72,7 @@ crHasTargetLOS w cr = case cr ^? crIntention . targetCr . _Just of
|
||||
|
||||
crSafeDistFromTarg :: Float -> Creature -> Bool
|
||||
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
|
||||
|
||||
crStratConMatches :: Strategy -> Creature -> Bool
|
||||
@@ -81,7 +82,7 @@ crStratConMatches strat cr = strat == _apStrategy (_crActionPlan cr)
|
||||
|
||||
crAwayFromPost :: Creature -> Bool
|
||||
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
|
||||
where
|
||||
sentinelGoal (SentinelAt _ _) = True
|
||||
@@ -108,8 +109,9 @@ crIsArmouredFrom m p cr = fromMaybe False $ do
|
||||
ittype <- m ^? ix itid . itType
|
||||
return $
|
||||
EQUIP FRONTARMOUR == ittype
|
||||
&& p /= _crOldPos cr
|
||||
&& angleVV (unitVectorAtAngle (_crDir cr + frontarmdirection)) (p -.- _crOldPos cr) < pi / 2
|
||||
&& p /= ( cr ^. crOldPos . _xy)
|
||||
&& angleVV (unitVectorAtAngle (_crDir cr + frontarmdirection))
|
||||
(p -.- (cr ^. crOldPos . _xy)) < pi / 2
|
||||
where
|
||||
-- even though angleVV can generate NaN, the comparison seems to deal with it
|
||||
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)
|
||||
|
||||
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
|
||||
{-# INLINE isAnimate #-}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.Creature.Update (updateCreature) where
|
||||
|
||||
import Linear
|
||||
import NewInt
|
||||
import Color
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
@@ -31,8 +32,8 @@ import ShapePicture.Data
|
||||
updateCreature :: Creature -> World -> World
|
||||
updateCreature cr
|
||||
| null (cr ^? crHP . _HP) = id
|
||||
| _crZ cr < negate 100 = (tocr . crHP .~ CrIsPitted) . destroyAllInvItems cr
|
||||
| _crZ cr < 0 = (tocr . crZVel -~ 0.5) . (tocr . crZ +~ _crZVel cr)
|
||||
| cr ^. crPos . _z < negate 100 = (tocr . crHP .~ CrIsPitted) . destroyAllInvItems cr
|
||||
| cr ^. crPos . _z < 0 = (tocr . crZVel -~ 0.5) . (tocr . crPos . _z +~ _crZVel cr)
|
||||
| otherwise = updateCreature' cr
|
||||
where
|
||||
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 cr w
|
||||
| _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
|
||||
& soundContinue (CrChasm (_crID cr)) (_crPos cr) debrisS (Just 100)
|
||||
& tocr . crPos -~ normalizeV (vNormal (x - y))
|
||||
& soundContinue (CrChasm (_crID cr)) (cr ^. crPos . _xy) debrisS (Just 100)
|
||||
& tocr . crPos . _xy -~ normalizeV (vNormal (x - y))
|
||||
| any f (w ^. cWorld . chasms) = w & tocr . crZVel -~ 0.5
|
||||
| otherwise = w
|
||||
where
|
||||
tocr = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
g = uncurry $ circOnSeg (_crPos cr) (crRad $ cr ^. crType)
|
||||
f = circInPolygon (_crPos cr) (crRad $ cr ^. crType)
|
||||
g = uncurry $ circOnSeg (cr ^. crPos . _xy) (crRad $ cr ^. crType)
|
||||
f = circInPolygon (cr ^. crPos . _xy) (crRad $ cr ^. crType)
|
||||
|
||||
updatePulse :: Pulse -> Pulse
|
||||
updatePulse PulseStatus{_pulseRate = pr, _pulseProgress = pp}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
module Dodge.Creature.YourControl (yourControl) where
|
||||
|
||||
import Linear
|
||||
import Control.Monad
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.Map.Strict as M
|
||||
@@ -139,7 +140,7 @@ wasdAim inp w cr
|
||||
| Aiming {} <- cr ^. crStance . posture = removeAimPosture cr
|
||||
| otherwise = creatureTurnTowardDir (_crMvAim cr) 0.2 cr
|
||||
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 m cr = fromMaybe cr $ do
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.CreatureEffect where
|
||||
|
||||
import Linear
|
||||
import Data.Maybe
|
||||
import Dodge.Base.Collide
|
||||
import Dodge.Creature.Test
|
||||
@@ -28,7 +29,7 @@ doIntImp ii = case ii of
|
||||
doCrImp :: CrImp -> Creature -> Impulse
|
||||
doCrImp ci = case ci of
|
||||
NoCrImp -> const ImpulseNothing
|
||||
TurnTowardCr x -> \cr -> TurnToward (_crPos cr) x
|
||||
TurnTowardCr x -> \cr -> TurnToward (cr ^. crPos . _xy) x
|
||||
|
||||
doP2Imp :: P2Imp -> Point2 -> Impulse
|
||||
doP2Imp p2i = case p2i of
|
||||
@@ -60,7 +61,8 @@ doMCrAc mca = case mca of
|
||||
|
||||
doCrAc :: CrAc -> Creature -> Action
|
||||
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
|
||||
|
||||
fleeFromTarget :: Creature -> Action
|
||||
@@ -77,7 +79,7 @@ doMP2Ac mp2a = case mp2a of
|
||||
doCrWdAc :: CrWdAc -> Creature -> World -> Action
|
||||
doCrWdAc cw = case cw of
|
||||
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
|
||||
return $
|
||||
DoReplicate t $
|
||||
@@ -97,10 +99,10 @@ chooseMovementSpreadGun cr w
|
||||
DoImpulses [TurnToward p 0.26, MoveForward 3]
|
||||
where
|
||||
d = dist cpos p
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
--tcr = _creatures (_cWorld w) IM.! 0
|
||||
tcr = w ^?! cWorld . lWorld . creatures . ix 0
|
||||
p = _crPos tcr
|
||||
p = tcr ^. crPos . _xy
|
||||
|
||||
chooseMovementLtAuto :: Creature -> World -> Action
|
||||
chooseMovementLtAuto cr w
|
||||
@@ -111,13 +113,15 @@ chooseMovementLtAuto cr w
|
||||
| otherwise =
|
||||
DoImpulses [UseItem, TurnToward p' 0.05, Move (V2 0 3)]
|
||||
where
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
tcr = w ^?! cWorld . lWorld . creatures . ix 0
|
||||
p = _crPos tcr
|
||||
p = tcr ^. crPos . _xy
|
||||
v = vNormal $ p -.- cpos
|
||||
p' = p +.+ 0.5 *.* (v -.- 20 *.* normalizeV v)
|
||||
|
||||
fleeFrom :: Creature -> Maybe Creature -> Action
|
||||
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
|
||||
|
||||
@@ -37,9 +37,9 @@ import Geometry.Data
|
||||
--import qualified IntMapHelp as IM
|
||||
|
||||
data Creature = Creature
|
||||
{ _crPos :: Point2
|
||||
, _crOldPos :: Point2
|
||||
, _crZ :: Float
|
||||
{ _crPos :: Point3
|
||||
, _crOldPos :: Point3
|
||||
-- , _crZ :: Float
|
||||
, _crZVel :: Float
|
||||
, _crDir :: Float
|
||||
, _crMvDir :: Float
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{-# OPTIONS -Wno-incomplete-uni-patterns #-}
|
||||
module Dodge.Debug.Picture where
|
||||
|
||||
import Linear (_xy)
|
||||
import Control.Lens
|
||||
import Data.Foldable
|
||||
import qualified Data.Graph.Inductive as FGL
|
||||
@@ -211,7 +212,7 @@ drawPathBetween w = concat $ do
|
||||
|
||||
drawWallsNearYou :: World -> Picture
|
||||
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
|
||||
where
|
||||
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)
|
||||
where
|
||||
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 =
|
||||
uncurryV translate p
|
||||
. scale 0.1 0.1
|
||||
@@ -414,12 +415,12 @@ drawCrInfo cfig w =
|
||||
| _crID cr == 0 = Nothing
|
||||
| crOnScreen =
|
||||
Just
|
||||
( _crPos cr
|
||||
( cr ^. crPos . _xy
|
||||
, catMaybes
|
||||
-- [fmap show $ ap ^? crGoal
|
||||
[ fpreShow "crHP" $ cr ^? crHP . _HP
|
||||
, fpreShow "crStrategy" $ ap ^? apStrategy
|
||||
, fmap (("crPos....." ++) . shortShow) $ cr ^? crPos
|
||||
, fmap (("crPos....." ++) . shortShow) $ cr ^? crPos . _xy
|
||||
, fpreShow "cpVigilance" $ cr ^? crPerception . cpVigilance
|
||||
, -- , fmap show $ cr ^? crOldPos
|
||||
fpreShow "crAction" $ ap ^? apAction
|
||||
@@ -429,7 +430,7 @@ drawCrInfo cfig w =
|
||||
| otherwise = Nothing
|
||||
where
|
||||
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 str = fmap (((rightPad 7 '.' str ++ "...") ++) . show)
|
||||
|
||||
@@ -12,9 +12,9 @@ import Geometry.Data
|
||||
defaultCreature :: Creature
|
||||
defaultCreature =
|
||||
Creature
|
||||
{ _crPos = V2 0 0
|
||||
, _crOldPos = V2 0 0
|
||||
, _crZ = 0
|
||||
{ _crPos = V3 0 0 0
|
||||
, _crOldPos = V3 0 0 0
|
||||
-- , _crZ = 0
|
||||
, _crZVel = 0
|
||||
, _crDir = 0
|
||||
, _crMvDir = 0
|
||||
|
||||
@@ -3,6 +3,7 @@ module Dodge.Equipment (
|
||||
effectOnEquip,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import Control.Lens
|
||||
import Data.Maybe
|
||||
import Dodge.Creature.HandPos
|
||||
@@ -60,4 +61,4 @@ setWristShieldPos itm cr w = w & moveWallIDUnsafe i wlline
|
||||
-- g
|
||||
-- | twists cr = (+.+.+ V3 (-5) 10 0)
|
||||
-- | otherwise = id
|
||||
f = (+.+ _crPos cr) . stripZ . rotate3 (_crDir cr) . handtrans
|
||||
f = (+.+ cr ^. crPos . _xy) . stripZ . rotate3 (_crDir cr) . handtrans
|
||||
|
||||
+19
-12
@@ -1,6 +1,4 @@
|
||||
module Dodge.Euse (
|
||||
equipBackgroundEffect,
|
||||
) where
|
||||
module Dodge.Euse (equipBackgroundEffect) where
|
||||
|
||||
import Dodge.Creature.HandPos
|
||||
import Dodge.Creature.Test
|
||||
@@ -11,14 +9,19 @@ import Dodge.Data.World
|
||||
import Dodge.Wall.Move
|
||||
import Geometry
|
||||
import LensHelp
|
||||
import Linear
|
||||
|
||||
equipBackgroundEffect :: LocationDT OItem -> Creature -> EquipSite
|
||||
-> World -> World
|
||||
equipBackgroundEffect ::
|
||||
LocationDT OItem ->
|
||||
Creature ->
|
||||
EquipSite ->
|
||||
World ->
|
||||
World
|
||||
equipBackgroundEffect loc cr = case eo of
|
||||
EQUIP (MAGSHIELD mt) -> const $ useMagShield mt itm cr
|
||||
EQUIP WRISTARMOUR -> setWristShieldPos itm cr
|
||||
EQUIP HEADLAMP -> const $ createHeadLamp itm cr
|
||||
_ -> const id
|
||||
_ -> const id
|
||||
where
|
||||
itm = loc ^. locDT . dtValue . _1
|
||||
eo = itm ^. itType
|
||||
@@ -28,7 +31,7 @@ useMagShield :: MagnetBuBu -> Item -> Creature -> World -> World
|
||||
useMagShield mt _ cr w =
|
||||
w & cWorld . lWorld . magnets
|
||||
.:~ Magnet
|
||||
{ _mgPos = _crPos cr
|
||||
{ _mgPos = cr ^. crPos . _xy
|
||||
, _mgField = mt
|
||||
}
|
||||
|
||||
@@ -43,7 +46,7 @@ setWristShieldPos itm cr x = moveWallIDUnsafe i wlline
|
||||
g
|
||||
| twists cr = (+.+.+ V3 (-5) 10 0)
|
||||
| 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
|
||||
--shieldWallDamage :: Damage -> Wall -> Int -> World -> World
|
||||
@@ -53,10 +56,14 @@ setWristShieldPos itm cr x = moveWallIDUnsafe i wlline
|
||||
-- _ -> w
|
||||
|
||||
createHeadLamp :: Item -> Creature -> World -> World
|
||||
createHeadLamp _ cr w = w &
|
||||
cWorld . lWorld . lights
|
||||
createHeadLamp _ cr w =
|
||||
w
|
||||
& cWorld . lWorld . lights
|
||||
.:~ LSParam
|
||||
((_crPos cr `v2z` 0) +.+.+ rotate3 (_crDir cr)
|
||||
(translateToES cr OnHead (V3 5 0 3)))
|
||||
( _crPos cr
|
||||
+.+.+ rotate3
|
||||
(_crDir cr)
|
||||
(translateToES cr OnHead (V3 5 0 3))
|
||||
)
|
||||
200
|
||||
0.7
|
||||
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
module Dodge.Gas where
|
||||
|
||||
import Linear
|
||||
import Control.Lens
|
||||
import Dodge.Data.World
|
||||
import Dodge.Flame
|
||||
import Dodge.WorldEvent
|
||||
@@ -13,7 +15,7 @@ createGas gc = case gc of
|
||||
aGasCloud :: Float -> Point2 -> Float -> Creature -> World -> World
|
||||
aGasCloud pressure pos dir cr =
|
||||
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 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)
|
||||
|
||||
-- (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
@@ -8,6 +8,7 @@ module Dodge.HeldUse (
|
||||
heldEffectMuzzles,
|
||||
) where
|
||||
|
||||
import Linear (_xy)
|
||||
import Color
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
@@ -72,7 +73,7 @@ hammerCheck f pt loc cr w = case itemTriggerType loc of
|
||||
w & setwarming
|
||||
& soundContinue
|
||||
(CrWeaponSound cid 0)
|
||||
(_crPos cr)
|
||||
(cr ^. crPos . _xy)
|
||||
(warmupSound $ it ^. itType)
|
||||
(Just 2)
|
||||
& itmset . itParams . wTime +~ 1
|
||||
@@ -82,7 +83,7 @@ hammerCheck f pt loc cr w = case itemTriggerType loc of
|
||||
w & setwarming
|
||||
& soundContinue
|
||||
(CrWeaponSound cid 0)
|
||||
(_crPos cr)
|
||||
(cr ^. crPos . _xy)
|
||||
(warmupSound $ it ^. itType)
|
||||
(Just 2)
|
||||
& itmset . itParams . wTime +~ 1
|
||||
@@ -371,8 +372,8 @@ applyCME loc cr cme
|
||||
itm = loc ^. locDT . dtValue . _1
|
||||
spush = maybe 0 itemSidePush $ itm ^? itType . ibtHeld
|
||||
failsound w = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
|
||||
Just 0 -> soundStart (CrWeaponFailSound (_crID cr)) (_crPos cr) click1S Nothing w
|
||||
_ -> soundContinue (CrWeaponFailSound (_crID cr)) (_crPos cr) click1S Nothing w
|
||||
Just 0 -> soundStart (CrWeaponFailSound (_crID cr)) (cr ^. crPos . _xy) click1S Nothing w
|
||||
_ -> soundContinue (CrWeaponFailSound (_crID cr)) (cr ^. crPos . _xy) click1S Nothing w
|
||||
|
||||
itemSidePush :: HeldItemType -> Float
|
||||
itemSidePush = \case
|
||||
@@ -443,14 +444,14 @@ applySoundCME itm cr = fromMaybe id $ do
|
||||
(soundid, x) <- bgunSound itm
|
||||
return $
|
||||
if x > 0
|
||||
then soundContinue (CrWeaponSound cid 0) (_crPos cr) soundid (Just x)
|
||||
else soundMultiFrom [CrWeaponSound cid j | j <- [0 .. 16]] (_crPos cr) soundid Nothing
|
||||
then soundContinue (CrWeaponSound cid 0) (cr ^. crPos . _xy) soundid (Just x)
|
||||
else soundMultiFrom [CrWeaponSound cid j | j <- [0 .. 16]] (cr ^. crPos . _xy) soundid Nothing
|
||||
where
|
||||
cid = _crID cr
|
||||
|
||||
applyRecoil :: LocationDT OItem -> Creature -> World -> World
|
||||
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)
|
||||
where
|
||||
itm = loc ^. locDT . dtValue . _1
|
||||
@@ -552,7 +553,7 @@ applySidePush :: Float -> Creature -> World -> World
|
||||
applySidePush 0 _ w = w
|
||||
applySidePush maxSide cr w =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix cid . crPos +~ push
|
||||
& cWorld . lWorld . creatures . ix cid . crPos . _xy +~ push
|
||||
& randGen .~ g
|
||||
where
|
||||
cid = _crID cr
|
||||
@@ -664,7 +665,7 @@ makeMuzzleFlare mz loc cr = case mz ^. mzFlareType of
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`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
|
||||
oddcheck 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
|
||||
& soundContinue (CrWeaponSound (_crID cr) 0) cpos tone440sawtoothquietS (Just 2)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
spos = cpos +.+ (crRad (cr ^. crType) + 10) *.* unitVectorAtAngle dir
|
||||
xpos = cpos +.+ 400 *.* unitVectorAtAngle dir
|
||||
dir = _crDir cr
|
||||
@@ -827,7 +828,7 @@ creatureShootLaser loc cr mz w =
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`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
|
||||
(a, g) = randomR (- inacc, inacc) $ _randGen w
|
||||
inacc = _mzInaccuracy mz
|
||||
@@ -868,7 +869,7 @@ creatureShootPulseLaser loc cr mz w =
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`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
|
||||
(a, g) = randomR (- inacc, inacc) $ _randGen w
|
||||
inacc = _mzInaccuracy mz
|
||||
@@ -895,7 +896,7 @@ creatureShootPulseBall loc cr mz w = w & randGen .~ g & shootPulseBall pos dir
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`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
|
||||
(a, g) = randomR (- inacc, inacc) $ _randGen w
|
||||
inacc = _mzInaccuracy mz
|
||||
@@ -991,7 +992,7 @@ shootBullet bu loc cr mz w = makeBullet bu itm bulpos dir . (randGen .~ g) $ w
|
||||
locOrient loc cr
|
||||
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
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
|
||||
dir = _crDir cr + Q.qToAng q + a
|
||||
inacc = _mzInaccuracy mz
|
||||
@@ -1130,7 +1131,7 @@ useGasParams (NInt magitid) mz loc cr w =
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`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
|
||||
inacc = _mzInaccuracy mz
|
||||
offset = case mz ^. mzRandomOffset of
|
||||
@@ -1219,7 +1220,7 @@ shootTeslaArc loc cr mz w =
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`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
|
||||
offset = case mz ^. mzRandomOffset of
|
||||
0 -> 0
|
||||
@@ -1343,12 +1344,12 @@ createProjectile x pjtype mtree stab muz cr w = fromMaybe (failsound w) $ do
|
||||
makesound =
|
||||
soundMultiFrom
|
||||
[CrWeaponSound (_crID cr) j | j <- [0 .. 3]]
|
||||
(_crPos cr)
|
||||
(cr ^. crPos . _xy)
|
||||
tap4S
|
||||
Nothing
|
||||
failsound w' = case w' ^? input . mouseButtons . ix SDL.ButtonLeft of
|
||||
Just 0 -> soundStart (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w'
|
||||
_ -> soundContinue (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) (cr ^. crPos . _xy) click1S Nothing w'
|
||||
|
||||
---- need to add these to muzzle flare?
|
||||
--makeMuzzleSmoke :: Muzzle -> Item -> Creature -> World -> World
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.Humanoid where
|
||||
|
||||
import Linear
|
||||
import Data.Maybe
|
||||
import Dodge.Creature.Action
|
||||
import Dodge.Creature
|
||||
@@ -218,9 +219,9 @@ chooseMovementPistol' cr w =
|
||||
$ g
|
||||
where
|
||||
g = _randGen w
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
ycr = w ^?! cWorld . lWorld . creatures . ix 0
|
||||
ypos = _crPos ycr
|
||||
ypos = ycr ^. crPos . _xy
|
||||
chargeProb
|
||||
| dist cpos ypos > 300 = 5
|
||||
| dist cpos ypos > 150 = 1
|
||||
@@ -252,8 +253,8 @@ retreatActionsPistol tcr cr =
|
||||
`DoImpulsesAlongside` 3
|
||||
`DoReplicate` ImpulsesList (replicate 9 [Move (V2 (-3) 0)] ++ [[UseItem]])
|
||||
where
|
||||
cpos = _crPos cr
|
||||
tpos = _crPos tcr
|
||||
cpos = cr ^. crPos . _xy
|
||||
tpos = tcr ^. crPos . _xy
|
||||
retreatOffset =
|
||||
let a
|
||||
| dist cpos tpos < 50 = 0
|
||||
|
||||
@@ -16,6 +16,7 @@ module Dodge.Inventory (
|
||||
destroyAllInvItems,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import Data.Function
|
||||
import Data.Maybe
|
||||
import Dodge.Base
|
||||
@@ -128,7 +129,7 @@ updateCloseObjects w =
|
||||
return (x /= TerminalDeactivated)
|
||||
_ -> True
|
||||
isclose x = dist y x < 40 && hasButtonLOS y x w
|
||||
y = _crPos $ you w
|
||||
y = you w ^. crPos . _xy
|
||||
|
||||
changeSwapSel :: Int -> World -> World
|
||||
changeSwapSel yi w
|
||||
|
||||
@@ -6,6 +6,7 @@ module Dodge.Inventory.Add (
|
||||
pickUpItemAt,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import qualified Data.IntSet as IS
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
@@ -61,7 +62,7 @@ createItemYou :: Item -> World -> World
|
||||
createItemYou itm w = maybe w' snd $ tryPutItemInInv 0 itid w'
|
||||
where
|
||||
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
|
||||
|
||||
-- the duplication is annoying...
|
||||
|
||||
@@ -3,6 +3,7 @@ module Dodge.Inventory.Swap (
|
||||
swapAnyExtraSelection
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import NewInt
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.Item.Grammar
|
||||
@@ -71,7 +72,7 @@ checkConnection so s i j w = fromMaybe w $ do
|
||||
iit <- locs ^? ix i . _2
|
||||
jit <- locs ^? ix j . _2
|
||||
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 x = case x ^. locDtContext of
|
||||
|
||||
@@ -6,6 +6,7 @@ module Dodge.Item.BackgroundEffect (
|
||||
removeShieldWall,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import Color
|
||||
import Control.Lens
|
||||
import Dodge.Creature.Radius
|
||||
@@ -46,7 +47,7 @@ createShieldWall it cr w = case it ^? itParams . flatShieldWlMIX . _Just of
|
||||
crid = _crID cr
|
||||
wlline = (a, b)
|
||||
crdirv = unitVectorAtAngle $ _crDir cr
|
||||
crpos = _crPos cr
|
||||
crpos =cr ^. crPos . _xy
|
||||
rad = crRad (cr ^. crType) + 2
|
||||
a = crpos +.+ rad *.* crdirv -.- 10 *.* therot crdirv
|
||||
b = crpos +.+ rad *.* crdirv +.+ 10 *.* therot crdirv
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.Item.Weapon.Shatter (shootShatter) where
|
||||
|
||||
import Linear
|
||||
import Dodge.Base.Collide
|
||||
import Dodge.Block.Debris
|
||||
import Dodge.Data.World
|
||||
@@ -18,7 +19,7 @@ shootShatter _ cr w =
|
||||
Opaque {} -> True
|
||||
SeeThrough -> True
|
||||
_ -> 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
|
||||
dir = _crDir cr
|
||||
ep = sp +.+ 200 *.* unitVectorAtAngle dir
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.Lampoid (updateLampoid) where
|
||||
|
||||
import Linear
|
||||
import Dodge.Creature.State
|
||||
import Dodge.Data.World
|
||||
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
|
||||
& doDamage (cr ^. crID)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
cid = _crID cr
|
||||
crtype = _crType cr
|
||||
h = _lampHeight crtype
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.Machine where
|
||||
|
||||
import Linear
|
||||
import Dodge.Base
|
||||
import Dodge.Data.World
|
||||
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
|
||||
| otherwise = f mc w
|
||||
where
|
||||
d = dist (_crPos $ you w) (_mcPos mc)
|
||||
d = dist (you w ^. crPos . _xy) (_mcPos mc)
|
||||
mid = _mcID mc
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
module Dodge.Machine.Update (updateMachine) where
|
||||
|
||||
import Linear
|
||||
import Control.Monad
|
||||
import Data.List (partition)
|
||||
import Data.Maybe
|
||||
@@ -61,7 +62,7 @@ updateTurret rotSpeed mc w =
|
||||
| elecDam < 10 = updateFiringStatus . doTurn
|
||||
| otherwise = id
|
||||
mcid = _mcID mc
|
||||
ypos = _crPos $ you w
|
||||
ypos = you w ^. crPos . _xy
|
||||
mcpos = _mcPos mc
|
||||
seesYou = hasLOSIndirect mcpos ypos w
|
||||
(elecDams, dams) = partition isElectrical $ _mcDamage mc
|
||||
@@ -122,7 +123,7 @@ mcPlaySound mc w = case _mcType mc of
|
||||
w
|
||||
_ -> w
|
||||
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
|
||||
|
||||
mcApplyDamage :: [Damage] -> Machine -> World -> World
|
||||
@@ -156,9 +157,9 @@ mcNoItemsTest mc ps w
|
||||
falsetog = mc ^? mcType . _McProxSensor . proxToggle . _Just == Just False
|
||||
notog =
|
||||
null (mc ^? mcType . _McProxSensor . proxToggle . _Just)
|
||||
&& pointInPoly (cr ^. crPos) qs
|
||||
&& pointInPoly (cr ^. crPos . _xy) qs
|
||||
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))
|
||||
cr = w ^?! cWorld . lWorld . creatures . ix 0
|
||||
mcsenslens = cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McProxSensor
|
||||
@@ -170,7 +171,7 @@ mcNoItemsTest mc ps w
|
||||
mcProximitySensorUpdate ::
|
||||
Machine -> ProximitySensor -> ProximityRequirement -> World -> World
|
||||
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 =
|
||||
w
|
||||
& mcsenslens . proxToggle ?~ True
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.Material.Damage (damMatSideEffect) where
|
||||
|
||||
import Linear
|
||||
import Control.Lens
|
||||
import Dodge.Data.World
|
||||
import Dodge.SoundLogic
|
||||
@@ -45,7 +46,7 @@ damageStone dm ecw w =
|
||||
where
|
||||
v = case ecw of
|
||||
Right wl -> uncurry (-) $ _wlLine wl
|
||||
Left cr -> vNormal (p - _crPos cr)
|
||||
Left cr -> vNormal (p - cr ^. crPos . _xy)
|
||||
randsound p xs =
|
||||
let (x, g) = runState (takeOne xs) $ _randGen w
|
||||
in soundStart so p x Nothing . set randGen g
|
||||
@@ -76,7 +77,7 @@ damageMetal dm ecw w =
|
||||
where
|
||||
v = case ecw of
|
||||
Right wl -> uncurry (-) $ _wlLine wl
|
||||
Left cr -> vNormal (p - _crPos cr)
|
||||
Left cr -> vNormal (p - cr ^. crPos . _xy)
|
||||
outTo x t = x -.- squashNormalizeV t
|
||||
randsound p xs =
|
||||
let (x, g) = runState (takeOne xs) $ _randGen w
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
-}
|
||||
module Dodge.Placement.PlaceSpot (placeSpot) where
|
||||
|
||||
import Linear
|
||||
import Color
|
||||
import Control.Monad.State
|
||||
import Data.Bifunctor
|
||||
@@ -184,7 +185,10 @@ mvPP :: Point2 -> Float -> PressPlate -> PressPlate
|
||||
mvPP p rot pp = pp{_ppPos = p, _ppRot = rot}
|
||||
|
||||
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 p a = (fsDir +~ a) . (fsPos %~ ((p +.+) . rotateV a))
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
module Dodge.PressPlate where
|
||||
|
||||
import Control.Lens
|
||||
import Linear
|
||||
import Dodge.Base.You
|
||||
import Dodge.Data.World
|
||||
import Dodge.WorldEvent.Explosion
|
||||
@@ -12,5 +14,6 @@ doPressPlateEvent ppe = case ppe of
|
||||
|
||||
ppLevelReset :: PressPlate -> World -> World
|
||||
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
|
||||
|
||||
@@ -12,6 +12,7 @@ import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import NewInt
|
||||
import Linear
|
||||
|
||||
data PJStabiliser
|
||||
= StabOrthReduce
|
||||
@@ -35,7 +36,7 @@ createShell (p,q) mdetonator mscreen stab pjtype payload muz cr w =
|
||||
& updatedetonator
|
||||
& cWorld . lWorld . projectiles . at i
|
||||
?~ Shell
|
||||
{ _pjPos = pos `v2z` 20
|
||||
{ _pjPos = pos
|
||||
, _pjVel = (rotateV dir' (V2 speed 0) + crvelcomponent) `v2z` 0
|
||||
, _pjID = i
|
||||
, _pjDir = dir'
|
||||
@@ -49,8 +50,8 @@ createShell (p,q) mdetonator mscreen stab pjtype payload muz cr w =
|
||||
}
|
||||
where
|
||||
crvelcomponent = case stab of
|
||||
Just StabOrthReduce -> projV (cr ^. crPos - cr ^. crOldPos) (unitVectorAtAngle dir)
|
||||
_ -> cr ^. crPos - cr ^. crOldPos
|
||||
Just StabOrthReduce -> projV (cr ^. crPos . _xy - cr ^. crOldPos . _xy) (unitVectorAtAngle dir)
|
||||
_ -> (cr ^. crPos - cr ^. crOldPos) ^. _xy
|
||||
bs = case stab of
|
||||
Just StabOrthReduce -> Nothing
|
||||
Just StabSpinIncrease -> Just (_crID cr, 5)
|
||||
@@ -74,5 +75,6 @@ createShell (p,q) mdetonator mscreen stab pjtype payload muz cr w =
|
||||
.:~ i
|
||||
i = IM.newKey $ w ^. cWorld . lWorld . projectiles
|
||||
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)
|
||||
|
||||
@@ -88,7 +88,7 @@ shellHitCreature p cr pj w
|
||||
.~ Grenade
|
||||
( GStuckCreature
|
||||
(cr ^. crID)
|
||||
(rotate3z (- cr ^. crDir) (p - ((cr ^. crPos) `v2z` 0)))
|
||||
(rotate3z (- cr ^. crDir) (p - ((cr ^. crPos . _xy) `v2z` 0)))
|
||||
(pj ^. pjDir - cr ^. crDir)
|
||||
)
|
||||
& soundOriginIDsAt (ShellSound (pj ^. pjID)) [slapS, slap1S] (pj ^. pjPos . _xy)
|
||||
@@ -250,9 +250,9 @@ moveStuckGrenade cid poff d pj w
|
||||
vel = cpos - cr ^. crOldPos
|
||||
in w
|
||||
& 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) . pjVel . _xy .~ vel
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjVel .~ vel
|
||||
| otherwise =
|
||||
w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjType .~ Grenade GStick
|
||||
|
||||
|
||||
+21
-18
@@ -1,5 +1,6 @@
|
||||
module Dodge.Prop.Gib (addCrGibs) where
|
||||
|
||||
import Linear
|
||||
import Color
|
||||
import Control.Monad
|
||||
import Data.Foldable
|
||||
@@ -16,27 +17,27 @@ import RandomHelp
|
||||
addCrGibs :: Creature -> World -> World
|
||||
addCrGibs cr = case damageDirection $ _crDamage cr of
|
||||
Nothing ->
|
||||
addGibAt 25 (_skinHead skin) cpos
|
||||
addGibAt (_skinHead skin) (cpos & _z +~ 25)
|
||||
. addGibsAtDir pi 0 3 7 (_skinLower skin) cpos
|
||||
. addGibsAtDir pi 0 13 20 (_skinUpper skin) cpos
|
||||
. makeDustAt Flesh 50 (addZ 20 cpos)
|
||||
. makeDustAt Flesh 50 (addZ 20 cpos)
|
||||
. makeDustAt Flesh 50 (addZ 20 cpos)
|
||||
. makeDustAt Flesh 50 (addZ 20 cpos)
|
||||
. makeDustAt Flesh 50 (cpos)
|
||||
. makeDustAt Flesh 50 (cpos)
|
||||
. makeDustAt Flesh 50 (cpos)
|
||||
. makeDustAt Flesh 50 (cpos)
|
||||
Just d ->
|
||||
addGibsAtDir (pi / 4) d 3 7 (_skinLower skin) cpos
|
||||
. addGibsAtDir (pi / 4) d 13 20 (_skinUpper skin) cpos
|
||||
. addGibAtDir d 25 (_skinHead skin) cpos
|
||||
. makeDustAt Flesh 50 (addZ 20 cpos)
|
||||
. makeDustAt Flesh 50 (addZ 20 cpos)
|
||||
. makeDustAt Flesh 50 (addZ 20 cpos)
|
||||
. makeDustAt Flesh 50 (addZ 20 cpos)
|
||||
. addGibAtDir d (_skinHead skin) (cpos & _z +~ 25)
|
||||
. makeDustAt Flesh 50 cpos
|
||||
. makeDustAt Flesh 50 cpos
|
||||
. makeDustAt Flesh 50 cpos
|
||||
. makeDustAt Flesh 50 cpos
|
||||
where
|
||||
skin = crShape $ _crType cr -- this should be cleaned up
|
||||
cpos = _crPos cr
|
||||
|
||||
-- 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 =
|
||||
foldl' (flip $ addGib4 p col) w (zip4 vels zspeeds quats hs)
|
||||
& randGen .~ newg
|
||||
@@ -48,24 +49,26 @@ addGibsAtDir spread dir minh maxh col p w =
|
||||
zspeeds = replicateM 4 (state (randomR (-8, 8))) & 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) =
|
||||
cWorld . lWorld . debris
|
||||
.:~ DebrisChunk
|
||||
{ _dbPos = p `v2z` h
|
||||
{ _dbPos = p & _z +~ h
|
||||
, _dbType = Gib 3 col
|
||||
, _dbVel = v `v2z` zs
|
||||
, _dbRot = q
|
||||
, _dbSpin = Q.axisAngle (vNormal v `v2z` 0) (-0.1)
|
||||
}
|
||||
|
||||
addGibAt :: Float -> Color -> Point2 -> World -> World
|
||||
addGibAt h col p w = addGibAtDir d h col p (w & randGen .~ newg)
|
||||
addGibAt :: Color -> Point3 -> World -> World
|
||||
--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
|
||||
(d, newg) = randomR (0, 2 * pi) $ _randGen w
|
||||
|
||||
addGibAtDir :: Float -> Float -> Color -> Point2 -> World -> World
|
||||
addGibAtDir dir h col p w =
|
||||
addGibAtDir :: Float -> Color -> Point3 -> World -> World
|
||||
--addGibAtDir dir h col p w =
|
||||
addGibAtDir dir col p w =
|
||||
w
|
||||
& cWorld . lWorld . debris .:~ gib
|
||||
& randGen .~ newg
|
||||
@@ -78,7 +81,7 @@ addGibAtDir dir h col p w =
|
||||
let v = s *.* unitVectorAtAngle dir
|
||||
return $
|
||||
DebrisChunk
|
||||
{ _dbPos = p `v2z` h
|
||||
{ _dbPos = p
|
||||
, _dbType = Gib 3 col
|
||||
, _dbVel = v `v2z` zs
|
||||
, _dbRot = q
|
||||
|
||||
@@ -5,6 +5,7 @@ module Dodge.RadarSweep (
|
||||
updateRadarSweep,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import Color
|
||||
import Data.Maybe
|
||||
import qualified Data.Set as S
|
||||
@@ -29,7 +30,7 @@ aRadarPulse itid mitid armitid ob cr =
|
||||
.:~ RadarSweep
|
||||
{ _rsTimer = 50
|
||||
, _rsRad = 0
|
||||
, _rsPos = _crPos cr
|
||||
, _rsPos = cr ^. crPos . _xy
|
||||
, _rsObject = ob
|
||||
, _rsMapper = mitid
|
||||
, _rsAR = armitid
|
||||
@@ -85,7 +86,7 @@ blipAt r col i p =
|
||||
}
|
||||
|
||||
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
|
||||
f q = dist p q <= r && dist p q > r - 100
|
||||
g cr = _crID cr /= 0
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
module Dodge.Render.Picture (fixedCoordPictures) where
|
||||
|
||||
import Linear (_xy)
|
||||
import Control.Lens
|
||||
import Data.Maybe
|
||||
import Dodge.Base.Coordinate
|
||||
@@ -116,7 +117,7 @@ mouseCursorType u = case u ^. uvWorld . input . mouseContext of
|
||||
w = u ^. uvWorld
|
||||
selsec = u ^? uvWorld . hud . diSelection . _Just . slSec
|
||||
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) $
|
||||
argV (w ^. cWorld . lWorld . lAimPos -.- cpos)
|
||||
- w ^. wCam . camRot
|
||||
@@ -293,6 +294,6 @@ drawAimSweep cr w = fold $ do
|
||||
where
|
||||
cdir = _crDir cr
|
||||
rot = campos ^. camRot
|
||||
p = _crPos cr
|
||||
p = cr ^. crPos . _xy
|
||||
campos = w ^. wCam
|
||||
mwp = w ^. cWorld . lWorld . lAimPos
|
||||
|
||||
@@ -26,7 +26,7 @@ worldSPic cfig u =
|
||||
<> foldup drawPulseBall (filtOn _pbPos _pulseBalls)
|
||||
<> foldup (shiftDraw _blPos _blDir (drawBlock . _blDraw)) (filtOn _blPos _blocks)
|
||||
<> 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
|
||||
(Prelude.uncurry floorItemSPic)
|
||||
( IM.intersectionWith
|
||||
@@ -65,7 +65,7 @@ drawPulseBall pb =
|
||||
$ circleSolidCol green white 10
|
||||
|
||||
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
|
||||
_ | CrIsCorpse sp <- cr ^. crHP -> sp
|
||||
_ | null (cr ^? crHP . _HP) -> mempty
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.SpawnAt (respawn) where
|
||||
|
||||
import Linear
|
||||
--import Dodge.SoundLogic.ExternallyGeneratedSounds
|
||||
import Dodge.Creature
|
||||
import Geometry.Data
|
||||
@@ -20,4 +21,4 @@ spawnAt p d w = w
|
||||
---- SoundStart BackgroundSound p foamSprayFadeOutS Nothing :
|
||||
-- [MakeStartCloudAt (V3 x y 20 & _xy +~ p) | x <- [-5, -4 .. 5], y <- [-5, -4 .. 5]]
|
||||
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
|
||||
|
||||
@@ -4,6 +4,7 @@ import Control.Lens
|
||||
import Dodge.Data.World
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import Linear
|
||||
|
||||
updateTractorBeam :: World -> TractorBeam -> (World, Maybe TractorBeam)
|
||||
updateTractorBeam w pj
|
||||
@@ -26,7 +27,7 @@ tractFlIt q p1 outpos it
|
||||
|
||||
tractCr :: Point2 -> Point2 -> Point2 -> Creature -> Creature
|
||||
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
|
||||
|
||||
tractorPullPos :: Point2 -> Point2 -> Point2 -> Point2
|
||||
|
||||
+7
-7
@@ -317,7 +317,7 @@ checkTermDist w = fromMaybe w $ do
|
||||
tmid <- w ^? hud . subInventory . termID
|
||||
btid <- w ^? cWorld . lWorld . terminals . ix tmid . tmButtonID
|
||||
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
|
||||
|
||||
updateMouseContext :: Config -> Universe -> Universe
|
||||
@@ -505,7 +505,7 @@ updateCreatureSoundPositions w =
|
||||
$ _playingSounds w
|
||||
where
|
||||
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)}
|
||||
Nothing -> Just s{_soundTime = Just 0}
|
||||
updateSound _ _ = Nothing
|
||||
@@ -846,11 +846,11 @@ dustSpringVel a v b
|
||||
|
||||
simpleCrSprings :: World -> World
|
||||
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
|
||||
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 c1 c2
|
||||
@@ -859,13 +859,13 @@ crCrSpring c1 c2
|
||||
| diff >= comRad = id
|
||||
| otherwise =
|
||||
cWorld . lWorld . creatures
|
||||
%~ ( over (ix id1 . crPos) (+.+ overlap1)
|
||||
. over (ix id2 . crPos) (-.- overlap2)
|
||||
%~ ( over (ix id1 . crPos . _xy) (+.+ overlap1)
|
||||
. over (ix id2 . crPos . _xy) (-.- overlap2)
|
||||
)
|
||||
where
|
||||
id1 = _crID c1
|
||||
id2 = _crID c2
|
||||
vec = _crPos c1 -.- _crPos c2
|
||||
vec = c1 ^. crPos . _xy -.- c2 ^. crPos . _xy
|
||||
diff = magV vec
|
||||
comRad = crRad (c1 ^. crType) + crRad (c2 ^. crType)
|
||||
overlap1 = ((comRad - diff) * crMass (_crType c2) * 0.5 / massT) *.* errorNormalizeV 55 vec
|
||||
|
||||
@@ -87,8 +87,8 @@ updateInGameCamera cfig w =
|
||||
moveZoomCamera :: Config -> Input -> Creature -> World -> Camera -> Camera
|
||||
moveZoomCamera cfig theinput cr w campos =
|
||||
campos
|
||||
& camCenter .~ fromMaybe (_crPos cr +.+ offset) mremotepos
|
||||
& camViewFrom .~ fromMaybe (_crPos cr) mremotepos
|
||||
& camCenter .~ fromMaybe (cr ^. crPos . _xy +.+ offset) mremotepos
|
||||
& camViewFrom .~ fromMaybe (cr ^. crPos . _xy) mremotepos
|
||||
& camZoom .~ newzoom
|
||||
& camDefaultZoom .~ newDefaultZoom
|
||||
& camItemZoom .~ newItemZoom
|
||||
@@ -215,7 +215,7 @@ rotateToOverlappingWall w =
|
||||
w
|
||||
where
|
||||
cr = you w
|
||||
p = _crPos (you w)
|
||||
p = (you w) ^. crPos . _xy
|
||||
|
||||
doWallRotate :: Wall -> World -> World
|
||||
doWallRotate wl w
|
||||
|
||||
@@ -6,11 +6,12 @@ import Dodge.Data.World
|
||||
import Dodge.Zoning.Creature
|
||||
import Geometry.Vector3D
|
||||
import LensHelp
|
||||
import Linear
|
||||
|
||||
cloudPoisonDamage :: Cloud -> World -> World
|
||||
cloudPoisonDamage c w = foldl' (flip doDam) w (filter f $ crsNearPoint clpos w)
|
||||
where
|
||||
doDam cr =
|
||||
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
|
||||
|
||||
@@ -383,7 +383,7 @@ updateKeysInTerminal :: Int -> Universe -> Universe
|
||||
updateKeysInTerminal tmid u = fromMaybe deactivate $ do
|
||||
tm <- u ^? uvWorld . cWorld . lWorld . terminals . ix tmid
|
||||
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
|
||||
_ | dist x y > 40 || not (hasButtonLOS x y (u ^. uvWorld)) -> Nothing
|
||||
TerminalDeactivated -> Nothing
|
||||
@@ -553,7 +553,7 @@ tryCombine (i, j) w = fromMaybe w $ do
|
||||
. ix j
|
||||
. siPayload
|
||||
. _Just
|
||||
p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
|
||||
p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos . _xy
|
||||
return $
|
||||
createItemYou it (foldr (destroyInvItem 0 . NInt) w (sort is))
|
||||
& soundStart InventorySound p wrench1S Nothing
|
||||
|
||||
@@ -6,6 +6,7 @@ module Dodge.WallCreatureCollisions (
|
||||
crOnWall,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import Dodge.Creature.Radius
|
||||
import Control.Lens
|
||||
import Data.Maybe
|
||||
@@ -35,15 +36,15 @@ colCrWall w c
|
||||
-- c'' = c' & crPos %~ pushOutFromWalls rad ls
|
||||
--c' = c & crPos %~ pushOutFromWalls' rad (reverse ls)
|
||||
c' =
|
||||
c & crPos
|
||||
c & crPos . _xy
|
||||
%~ pushOutFromCorners r ls'
|
||||
. pushOutFromWalls r ls'
|
||||
. fst
|
||||
. flip (collidePoint p1) wls -- check push throughs
|
||||
-- . flip (collidePointWalls' p1) wls -- check push throughs
|
||||
r = crRad (c ^. crType) + wallBuffer
|
||||
p1 = _crOldPos c
|
||||
p2 = _crPos c
|
||||
p1 = c ^. crOldPos . _xy
|
||||
p2 = c ^. crPos . _xy
|
||||
ls = _wlLine <$> wls
|
||||
ls' = filter (uncurry $ isLHS p1) ls
|
||||
wls = filter (not . _wlWalkable) $ wlsNearRect (p2 +.+ V2 r r) (p2 -.- V2 r r) w
|
||||
@@ -53,7 +54,8 @@ wallBuffer :: Float
|
||||
wallBuffer = 0
|
||||
|
||||
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
|
||||
-- out from the wall
|
||||
@@ -74,13 +76,13 @@ pushOutFromWalls rad wls p1 = case (getFirst . foldMap (First . pushOutFromWall
|
||||
pushOrCrush :: [(Point2, Point2)] -> Creature -> Creature
|
||||
pushOrCrush wls cr = case mapMaybe (pushOutFromWall (crRad (cr ^. crType)) cpos) wls of
|
||||
[] -> cr
|
||||
(p : _) -> cr & crPos .~ p
|
||||
(p : _) -> cr & crPos . _xy .~ p
|
||||
where
|
||||
-- (_:p:_) -> cr
|
||||
-- & crPos .~ p
|
||||
-- & crState . crDamage %~ ( Blunt 50 cpos cpos cpos : )
|
||||
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
|
||||
-- note the inclusion of endpoints in circOnSeg
|
||||
crOnWall :: Creature -> World -> Bool
|
||||
@@ -89,7 +91,7 @@ crOnWall cr =
|
||||
. filter (not . _wlWalkable)
|
||||
. wlsNearPoint p
|
||||
where
|
||||
p = _crPos cr
|
||||
p = cr ^. crPos . _xy
|
||||
r = crRad (cr ^. crType)
|
||||
|
||||
-- assumes that the wall is orientated
|
||||
@@ -99,9 +101,9 @@ pushOutFromWall rad cp2 (wp1, wp2)
|
||||
| isOnWall = Just newP
|
||||
| otherwise = Nothing
|
||||
where
|
||||
norm = errorNormalizeV 61 $ vNormal (wp1 -.- wp2)
|
||||
wp1' = wp1 +.+ rad *.* norm
|
||||
wp2' = wp2 +.+ rad *.* norm
|
||||
n = errorNormalizeV 61 $ vNormal (wp1 -.- wp2)
|
||||
wp1' = wp1 +.+ rad *.* n
|
||||
wp2' = wp2 +.+ rad *.* n
|
||||
newP = errorClosestPointOnLine 5 wp1' wp2' cp2
|
||||
isOnWall = circOnSegNoEndpoints wp1 wp2 cp2 rad
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ module Dodge.WorldEvent.ThingsHit (
|
||||
crWlPbHit,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import Dodge.Data.Object
|
||||
import Dodge.Creature.Radius
|
||||
import Control.Monad
|
||||
@@ -148,6 +149,6 @@ crsHitRadial :: Point2 -> Float -> World -> [(Point2, Creature)]
|
||||
crsHitRadial p r = mapMaybe f . crsNearCirc p r
|
||||
where
|
||||
f cr = do
|
||||
let cp = _crPos cr
|
||||
let cp = cr ^. crPos . _xy
|
||||
guard $ dist p cp < r + crRad (_crType cr)
|
||||
return (cp + (1 + crRad (_crType cr)) *.* (cp - p), cr)
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
module Dodge.WorldPos where
|
||||
|
||||
import Dodge.Base.You
|
||||
import Dodge.Data.World
|
||||
import Geometry
|
||||
import Control.Lens
|
||||
import Linear
|
||||
|
||||
doWorldPos :: WdP2 -> World -> Point2
|
||||
doWorldPos wp2 = case wp2 of
|
||||
doWorldPos = \case
|
||||
WdP2Const p -> const p
|
||||
WdYouPos -> _crPos . you
|
||||
WdYouPos -> (^. crPos . _xy) . you
|
||||
|
||||
@@ -10,6 +10,7 @@ import Dodge.Zoning.Common
|
||||
import FoldableHelp
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import Linear
|
||||
|
||||
crIXsNearPoint :: Point2 -> World -> IS.IntSet
|
||||
crIXsNearPoint = nearPoint crZoneSize _crZoning
|
||||
@@ -42,7 +43,7 @@ crZoneSize :: Float
|
||||
crZoneSize = 15
|
||||
|
||||
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 f is w = fst <$> IS.foldl' g Nothing is
|
||||
|
||||
@@ -727,7 +727,7 @@ MODStringOption src/Dodge/Data/Universe.hs 97;" C
|
||||
MOTOR src/Dodge/Data/Item/Combine.hs 64;" C
|
||||
MP2Ac src/Dodge/Data/CreatureEffect.hs 56;" t
|
||||
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
|
||||
MTree src/Dodge/Data/MetaTree.hs 11;" C
|
||||
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
|
||||
airlockSimple src/Dodge/Room/Airlock.hs 108;" 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
|
||||
alteRifle src/Dodge/Item/Held/Cane.hs 22;" 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
|
||||
angleVV3 src/Geometry/Vector3D.hs 122;" 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
|
||||
applyCreatureDamage src/Dodge/Creature/Damage.hs 13;" 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
|
||||
bossRoom src/Dodge/Room/Boss.hs 61;" 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
|
||||
boundedGrid src/Grid.hs 19;" 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
|
||||
calcSmoothScroll src/Dodge/SmoothScroll.hs 11;" f
|
||||
calcTexCoord src/Tile.hs 19;" f
|
||||
canSee src/Dodge/Base/Collide.hs 335;" f
|
||||
canSeeIndirect src/Dodge/Base/Collide.hs 342;" f
|
||||
canSee src/Dodge/Base/Collide.hs 324;" f
|
||||
canSeeIndirect src/Dodge/Base/Collide.hs 331;" f
|
||||
cancelExamineInventory src/Dodge/Item/BackgroundEffect.hs 22;" f
|
||||
capacitor src/Dodge/Item/Ammo.hs 69;" 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
|
||||
chasmSimpleMaze src/Dodge/Room/Tutorial.hs 175;" 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
|
||||
checkConnection src/Dodge/Inventory/Swap.hs 65;" 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 208;" 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
|
||||
circOnAnyCr src/Dodge/Base/Collide.hs 298;" f
|
||||
circOnAnyCr src/Dodge/Base/Collide.hs 287;" f
|
||||
circOnSeg src/Geometry.hs 101;" 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
|
||||
circleDecoration src/Dodge/Placement/TopDecoration.hs 56;" 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
|
||||
collectDamageTypes src/Dodge/Damage.hs 53;" f
|
||||
collectInvItems src/Dodge/Update/Input/InGame.hs 295;" f
|
||||
collide3 src/Dodge/Base/Collide.hs 119;" f
|
||||
collide3Chasm src/Dodge/Base/Collide.hs 103;" f
|
||||
collide3Chasms src/Dodge/Base/Collide.hs 96;" f
|
||||
collide3Creature src/Dodge/Base/Collide.hs 153;" f
|
||||
collide3Floors src/Dodge/Base/Collide.hs 134;" f
|
||||
collide3Wall src/Dodge/Base/Collide.hs 148;" f
|
||||
collide3Walls src/Dodge/Base/Collide.hs 128;" f
|
||||
collide3WallsFloor src/Dodge/Base/Collide.hs 90;" f
|
||||
collideCircWalls src/Dodge/Base/Collide.hs 255;" f
|
||||
collidePoint src/Dodge/Base/Collide.hs 54;" f
|
||||
collidePointTestFilter src/Dodge/Base/Collide.hs 191;" f
|
||||
collidePointWallsFilter src/Dodge/Base/Collide.hs 205;" f
|
||||
collide3 src/Dodge/Base/Collide.hs 118;" f
|
||||
collide3Chasm src/Dodge/Base/Collide.hs 102;" f
|
||||
collide3Chasms src/Dodge/Base/Collide.hs 95;" f
|
||||
collide3Creature src/Dodge/Base/Collide.hs 152;" f
|
||||
collide3Floors src/Dodge/Base/Collide.hs 133;" f
|
||||
collide3Wall src/Dodge/Base/Collide.hs 147;" f
|
||||
collide3Walls src/Dodge/Base/Collide.hs 127;" f
|
||||
collide3WallsFloor src/Dodge/Base/Collide.hs 89;" f
|
||||
collideCircWalls src/Dodge/Base/Collide.hs 244;" f
|
||||
collidePoint src/Dodge/Base/Collide.hs 53;" f
|
||||
collidePointTestFilter src/Dodge/Base/Collide.hs 180;" f
|
||||
collidePointWallsFilter src/Dodge/Base/Collide.hs 194;" f
|
||||
color src/Picture/Base.hs 108;" f
|
||||
colorLamp src/Dodge/Creature/Lamp.hs 10;" 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
|
||||
crHasTarget src/Dodge/Creature/Test.hs 64;" 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
|
||||
crIXsNearCirc src/Dodge/Zoning/Creature.hs 32;" 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
|
||||
doBlBl src/Dodge/BlBl.hs 5;" 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
|
||||
doConLoop src/Loop.hs 137;" 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
|
||||
handleWindowMoveEvent src/Dodge/Event.hs 44;" 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
|
||||
hasLOS src/Dodge/Base/Collide.hs 305;" f
|
||||
hasLOSIndirect src/Dodge/Base/Collide.hs 321;" f
|
||||
hasLOS src/Dodge/Base/Collide.hs 294;" f
|
||||
hasLOSIndirect src/Dodge/Base/Collide.hs 310;" f
|
||||
hat src/Dodge/Item/Equipment.hs 76;" f
|
||||
head src/DoubleStack.hs 14;" 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
|
||||
intersectCircLineAlong src/Geometry/Intersect.hs 364;" f
|
||||
intersectCircSeg src/Geometry/Intersect.hs 353;" f
|
||||
intersectCircSegFirst src/Geometry/Intersect.hs 415;" f
|
||||
intersectCircSegTest src/Geometry/Intersect.hs 407;" f
|
||||
intersectCircSegFirst src/Geometry/Intersect.hs 417;" f
|
||||
intersectCircSegTest src/Geometry/Intersect.hs 409;" f
|
||||
intersectCylSeg src/Geometry/Intersect.hs 382;" f
|
||||
intersectLineLine src/Geometry/Intersect.hs 19;" 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
|
||||
isValidCommand src/Dodge/Debug/Terminal.hs 134;" 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
|
||||
isotriBWH src/Geometry/Polygon.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
|
||||
overPosSH src/Shape.hs 261;" f
|
||||
overPosSP src/ShapePicture.hs 41;" f
|
||||
overlapCircWalls src/Dodge/Base/Collide.hs 232;" f
|
||||
overlapCircWallsClosest src/Dodge/Base/Collide.hs 278;" f
|
||||
overlapSegCrs src/Dodge/Base/Collide.hs 60;" f
|
||||
overlapSegWalls src/Dodge/Base/Collide.hs 214;" f
|
||||
overlapCircWalls src/Dodge/Base/Collide.hs 221;" f
|
||||
overlapCircWallsClosest src/Dodge/Base/Collide.hs 267;" f
|
||||
overlapSegCrs src/Dodge/Base/Collide.hs 59;" f
|
||||
overlapSegWalls src/Dodge/Base/Collide.hs 203;" f
|
||||
overrideInternal src/Dodge/Creature/ReaderUpdate.hs 174;" f
|
||||
overrideMeleeCloseTarget src/Dodge/Creature/ReaderUpdate.hs 35;" 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
|
||||
restrictOutLinks src/Dodge/RoomLink.hs 47;" f
|
||||
restrictRMInLinksPD src/Dodge/Room/Link.hs 25;" f
|
||||
restrictSeg src/Dodge/Base/Collide.hs 173;" f
|
||||
resumeSound src/Dodge/SoundLogic.hs 48;" f
|
||||
retreatActionsPistol src/Dodge/Humanoid.hs 249;" 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
|
||||
viewTarget src/Dodge/Creature/ReaderUpdate.hs 146;" 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
|
||||
vocalizationTest src/Dodge/Creature/Vocalization.hs 42;" 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
|
||||
wallIsZeroLength src/Dodge/LevelGen/StaticWalls.hs 179;" 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
|
||||
wallsToDraw src/Dodge/Render/Walls.hs 17;" f
|
||||
warmupSound src/Dodge/HeldUse.hs 1421;" f
|
||||
|
||||
Reference in New Issue
Block a user