Make bezierGun set target on right click
This commit is contained in:
@@ -106,6 +106,14 @@ creaturesNearPoint p w = IM.unions [f b $ f a $ _creaturesZone w | a<-[x-1,x,x+
|
|||||||
Just val -> val
|
Just val -> val
|
||||||
_ -> IM.empty
|
_ -> IM.empty
|
||||||
|
|
||||||
|
creaturesNearPointI :: Int -> Point2 -> World -> IM.IntMap Creature
|
||||||
|
creaturesNearPointI n p w = IM.unions [f b $ f a $ _creaturesZone w | a<-[x-n..x+n] , b<-[y-n..y+n]]
|
||||||
|
where
|
||||||
|
(x,y) = crZoneOfPoint p
|
||||||
|
f i m = case IM.lookup i m of
|
||||||
|
Just val -> val
|
||||||
|
_ -> IM.empty
|
||||||
|
|
||||||
cloudsNearPoint :: Point2 -> World -> IM.IntMap Cloud
|
cloudsNearPoint :: Point2 -> World -> IM.IntMap Cloud
|
||||||
cloudsNearPoint p w = IM.unions [f b $ f a $ _cloudsZone w | a<-[x-1,x,x+1] , b<-[y-1,y,y+1]]
|
cloudsNearPoint p w = IM.unions [f b $ f a $ _cloudsZone w | a<-[x-1,x,x+1] , b<-[y-1,y,y+1]]
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
module Dodge.Creature.ArmourChase
|
module Dodge.Creature.ArmourChase
|
||||||
|
( armourChaseCrit
|
||||||
|
)
|
||||||
where
|
where
|
||||||
|
import Dodge.Base
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Default
|
import Dodge.Default
|
||||||
import Dodge.Creature.State
|
import Dodge.Creature.State
|
||||||
@@ -7,12 +10,14 @@ import Dodge.Creature.State.Data
|
|||||||
import Dodge.Creature.Rationality
|
import Dodge.Creature.Rationality
|
||||||
import Dodge.Creature.ReaderUpdate
|
import Dodge.Creature.ReaderUpdate
|
||||||
import Dodge.Creature.AlertLevel
|
import Dodge.Creature.AlertLevel
|
||||||
import Dodge.Creature.ChooseTarget
|
|
||||||
import Dodge.Creature.Picture
|
import Dodge.Creature.Picture
|
||||||
import Dodge.Item.Equipment
|
import Dodge.Item.Equipment
|
||||||
import Dodge.Item.Consumable
|
import Dodge.Item.Consumable
|
||||||
import Picture
|
import Picture
|
||||||
|
import Geometry
|
||||||
|
|
||||||
|
import Data.Maybe
|
||||||
|
import Data.List
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Control.Monad.Reader
|
import Control.Monad.Reader
|
||||||
@@ -23,9 +28,10 @@ armourChaseCrit = defaultCreature
|
|||||||
watchUpdateStratR [] >=>
|
watchUpdateStratR [] >=>
|
||||||
doStrategyActionsR >=>
|
doStrategyActionsR >=>
|
||||||
performActionsR >=>
|
performActionsR >=>
|
||||||
chaseTargetR targetYouLOS >=>
|
chaseTargetR (const . _crTarget) >=>
|
||||||
basicPerceptionUpdateR [0] >=>
|
basicPerceptionUpdateR [0] >=>
|
||||||
targetYouWhenCognizantR >=>
|
targetYouWhenCognizantR >=>
|
||||||
|
flockACCR >=>
|
||||||
overrideMeleeCloseTargetR >=>
|
overrideMeleeCloseTargetR >=>
|
||||||
return . (crMeleeCooldown . _Just %~ max 0 . subtract 1)
|
return . (crMeleeCooldown . _Just %~ max 0 . subtract 1)
|
||||||
, _crHP = 300
|
, _crHP = 300
|
||||||
@@ -37,3 +43,26 @@ armourChaseCrit = defaultCreature
|
|||||||
, _crMeleeCooldown = Just 0
|
, _crMeleeCooldown = Just 0
|
||||||
, _crGroup = ShieldGroup
|
, _crGroup = ShieldGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flockACCR :: Creature -> Reader World Creature
|
||||||
|
flockACCR = reader . flockACC
|
||||||
|
|
||||||
|
flockACC :: Creature -> World -> Creature
|
||||||
|
flockACC cr w = fromMaybe cr $ mFlockACC cr w
|
||||||
|
|
||||||
|
mFlockACC :: Creature -> World -> Maybe Creature
|
||||||
|
mFlockACC cr w = do
|
||||||
|
tcr <- _crTarget cr
|
||||||
|
let tpos = _crPos tcr
|
||||||
|
cpos = _crPos cr
|
||||||
|
isFarACC cr' = _crGroup cr' == ShieldGroup && _crID cr' /= _crID cr
|
||||||
|
&& dist (_crPos cr') tpos > dist cpos tpos
|
||||||
|
-- && circOnSeg (_crPos cr') tpos cpos (_crRad cr + _crRad cr')
|
||||||
|
nearACCs = IM.filter isFarACC $ creaturesNearPointI 3 cpos w
|
||||||
|
acr <- listToMaybe $ sortOn (dist cpos . _crPos) $ IM.elems nearACCs
|
||||||
|
let r = _crRad acr + _crRad cr + 10
|
||||||
|
horDir = normalizeV (vNormal (cpos -.- tpos))
|
||||||
|
horShift = if isLHS tpos cpos (_crPos acr)
|
||||||
|
then r *.* horDir
|
||||||
|
else negate r *.* horDir
|
||||||
|
return $ cr & crActionPlan . crImpulse .~ [MoveForward 2.5,TurnToward (tpos +.+ horShift) 0.05 ]
|
||||||
|
|||||||
@@ -41,5 +41,6 @@ data CrGroup
|
|||||||
}
|
}
|
||||||
| CrGroupID { _crGroupID :: Int }
|
| CrGroupID { _crGroupID :: Int }
|
||||||
| ShieldGroup
|
| ShieldGroup
|
||||||
|
deriving (Eq, Show)
|
||||||
makeLenses ''CreatureState
|
makeLenses ''CreatureState
|
||||||
makeLenses ''CrSpState
|
makeLenses ''CrSpState
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ roomTreex = do
|
|||||||
,[SpecificRoom . pure . pure . Right $ roomGlassOctogon 400
|
,[SpecificRoom . pure . pure . Right $ roomGlassOctogon 400
|
||||||
& rmPS %~ ([sPS (0,50) 0 $ PutCrit armourChaseCrit
|
& rmPS %~ ([sPS (0,50) 0 $ PutCrit armourChaseCrit
|
||||||
,sPS (50,25) 0 $ PutCrit armourChaseCrit
|
,sPS (50,25) 0 $ PutCrit armourChaseCrit
|
||||||
|
,sPS (50,0) 0 $ PutCrit armourChaseCrit
|
||||||
]++)
|
]++)
|
||||||
]
|
]
|
||||||
--,[Corridor]
|
--,[Corridor]
|
||||||
|
|||||||
+15
-14
@@ -58,7 +58,6 @@ pistol
|
|||||||
,poisonLauncher
|
,poisonLauncher
|
||||||
,teslaLauncher
|
,teslaLauncher
|
||||||
,remoteLauncher
|
,remoteLauncher
|
||||||
,bezierGun
|
|
||||||
,defaultThrowable
|
,defaultThrowable
|
||||||
-- ,shatterGun
|
-- ,shatterGun
|
||||||
,longGun,flamer,blinkGun,forceFieldGun :: Item
|
,longGun,flamer,blinkGun,forceFieldGun :: Item
|
||||||
@@ -319,9 +318,21 @@ teslaLauncher = launcher
|
|||||||
, _wpFire = shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makeTeslaExplosionAt
|
, _wpFire = shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makeTeslaExplosionAt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useTargetPos
|
||||||
|
:: (Point2 -> Int -> World -> World)
|
||||||
|
-> Int
|
||||||
|
-> World
|
||||||
|
-> World
|
||||||
|
useTargetPos f cid w = case cr ^? crInv . ix (_crInvSel cr) . itAttachment . _Just . itTargetPos of
|
||||||
|
Nothing -> w
|
||||||
|
Just p -> f p cid w
|
||||||
|
where
|
||||||
|
cr = _creatures w IM.! cid
|
||||||
|
|
||||||
|
bezierGun :: Item
|
||||||
bezierGun = defaultAutoGun
|
bezierGun = defaultAutoGun
|
||||||
{ _itName = "B-GUN"
|
{ _itName = "B-GUN"
|
||||||
, _wpFire = hammerCheck $ maybeSetTarget $ \p ->
|
, _wpFire = useTargetPos $ \p ->
|
||||||
shootWithSound 0
|
shootWithSound 0
|
||||||
. withMuzFlare
|
. withMuzFlare
|
||||||
. withRecoil 40
|
. withRecoil 40
|
||||||
@@ -331,23 +342,13 @@ bezierGun = defaultAutoGun
|
|||||||
, _itScrollUp = removeItAttachment 0
|
, _itScrollUp = removeItAttachment 0
|
||||||
, _itScrollDown = removeItAttachment 0
|
, _itScrollDown = removeItAttachment 0
|
||||||
, _itHammer = HammerUp
|
, _itHammer = HammerUp
|
||||||
, _itEffect = bezierRecock
|
, _itEffect = bezierTargetEffect
|
||||||
, _itZoom = defaultItZoom
|
, _itZoom = defaultItZoom
|
||||||
, _itAimingRange = 0
|
, _itAimingRange = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
maybeSetTarget :: (Point2 -> Int -> World -> World) -> Int -> World -> World
|
|
||||||
maybeSetTarget f cid w = case join $ w ^? creatures . ix cid . crInv . ix itRef . itAttachment of
|
|
||||||
Just (ItTargetPos targetp)
|
|
||||||
-> f targetp cid w
|
|
||||||
_ -> w & creatures . ix cid . crInv . ix itRef . itAttachment ?~ ItTargetPos mp
|
|
||||||
where
|
|
||||||
mp = mouseWorldPos w
|
|
||||||
cr = _creatures w IM.! cid
|
|
||||||
itRef = _crInvSel cr
|
|
||||||
|
|
||||||
shootBezier :: Point2 -> Int -> World -> World
|
shootBezier :: Point2 -> Int -> World -> World
|
||||||
shootBezier targetp cid w = over particles (theBullet :) w
|
shootBezier targetp cid w = w & particles %~ (theBullet :)
|
||||||
where
|
where
|
||||||
theBullet = aCurveBulAt
|
theBullet = aCurveBulAt
|
||||||
(Just cid)
|
(Just cid)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import Dodge.Data
|
|||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
import Dodge.Item.Weapon.Decoration
|
import Dodge.Item.Weapon.Decoration
|
||||||
import Dodge.Item.Weapon.UseEffect
|
import Dodge.Item.Weapon.UseEffect
|
||||||
|
import Dodge.Item.Attachment.Data
|
||||||
import Dodge.WorldEvent.Flash
|
import Dodge.WorldEvent.Flash
|
||||||
import Dodge.WorldEvent.ThingsHit
|
import Dodge.WorldEvent.ThingsHit
|
||||||
import Picture
|
import Picture
|
||||||
@@ -16,6 +17,8 @@ import Geometry.Vector
|
|||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
|
import qualified Data.Set as S
|
||||||
|
import qualified SDL
|
||||||
{- |
|
{- |
|
||||||
Controls resetting a weapon, allows for non-continuous fire needing a button release. -}
|
Controls resetting a weapon, allows for non-continuous fire needing a button release. -}
|
||||||
wpRecock :: ItEffect
|
wpRecock :: ItEffect
|
||||||
@@ -98,3 +101,17 @@ autoSonarEffect = ItInvEffect {_itInvEffect = f 50 ,_itEffectCounter = 0 }
|
|||||||
. itEffect . itInvEffect .~ f 140
|
. itEffect . itInvEffect .~ f 140
|
||||||
f t cr i w = w & creatures . ix (_crID cr) . crInv . ix i
|
f t cr i w = w & creatures . ix (_crID cr) . crInv . ix i
|
||||||
. itEffect . itInvEffect .~ f (t-1)
|
. itEffect . itInvEffect .~ f (t-1)
|
||||||
|
|
||||||
|
bezierTargetEffect :: ItEffect
|
||||||
|
bezierTargetEffect = ItInvEffect
|
||||||
|
{_itInvEffect = setBezierTarget
|
||||||
|
,_itEffectCounter = 0
|
||||||
|
}
|
||||||
|
setBezierTarget :: Creature -> Int -> World -> World
|
||||||
|
setBezierTarget cr invid w
|
||||||
|
| _crInvSel cr /= invid = w
|
||||||
|
| SDL.ButtonRight `S.member` _mouseButtons w = w
|
||||||
|
& creatures . ix (_crID cr) . crInv . ix invid . itAttachment
|
||||||
|
%~ maybe (Just $ ItTargetPos $ mouseWorldPos w) Just
|
||||||
|
| otherwise = w & creatures . ix (_crID cr) . crInv . ix invid . itAttachment .~ Nothing
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user