Tweak parameters on bezier gun, abstract out random accuracy direction

This commit is contained in:
2021-03-16 13:56:19 +01:00
parent ca5ff88522
commit 875679d25f
6 changed files with 69 additions and 87 deletions
+36 -47
View File
@@ -19,6 +19,7 @@ import Dodge.Item.Draw
import Dodge.Item.Weapon.Bullet
import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Item.Weapon.TriggerType
import Dodge.Item.Weapon.Recock
import Geometry
import Picture
@@ -329,12 +330,46 @@ launcher = defaultGun
}
bezierGun = defaultAutoGun
{ _itName = "B-GUN"
, _wpFire = bezierShoot
, _wpFire = maybeSetTarget shootBezier
, _itAttachment = Nothing
, _itScrollUp = removeItAttachment 0
, _itScrollDown = removeItAttachment 0
, _itHammer = HammerUp
, _itEffect = bezierRecock
, _itZoom = basicItZoom
, _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 .~ Just (ItTargetPos mp)
where
mp = mouseWorldPos w
cr = _creatures w IM.! cid
itRef = _crInvSel cr
shootBezier :: Point2 -> Int -> World -> World
shootBezier targetp cid w = (shootWithSound 0 . withMuzFlare . withRecoil 40 . torqueBefore 0.05
. withRandomDir 0.5)
bezBul cid w
where
bezBul = mkBezierBul startp controlp targetp
controlp = mouseWorldPos w
cr = _creatures w IM.! cid
dir = _crDir cr
startp = _crPos cr +.+ rotateV dir (_crRad cr + 1,0)
mkBezierBul :: Point2 -> Point2 -> Point2 -> Int -> World -> World
mkBezierBul startp controlp targetp cid w = over particles' (bbul :) w
where
bbul = aCurveBulAt (Just cid) white startp (controlp +.+ randPos) (targetp +.+ randPos')
(threeEff' bulHitCr' bulHitWall' bulHitFF') 5
(randPos,randPos') = flip evalState (_randGen w)
$ do a <- randInCirc 10
b <- randInCirc 10
return (a,b)
removeItAttachment :: Int -> Int -> World -> World
removeItAttachment i _ w = w & creatures . ix i . crInv . ix itRef . itAttachment .~ Nothing
where cr = _creatures w IM.! i
@@ -1338,7 +1373,6 @@ remoteBomb = defaultThrowable
throwGrenade :: Int -> Int -> World -> World
--throwGrenade n w = rmInvItem n $ over particles addG $ set randGen g w
throwGrenade fuseTime n w = setWp $ removePict $ over particles addG $ set randGen g w
where addG = IM.insert i
$ Particle { _ptPos = p
@@ -1364,14 +1398,6 @@ throwGrenade fuseTime n w = setWp $ removePict $ over particles addG $ set randG
dir = argV v
setWp :: World -> World
setWp w' = w' & creatures . ix n . crInv . ix j . itEffect .~ throwArmReset 20
--maybewpid = w ^? creatures . ix n . crInv . ix j . itID . _Just
--setWpLocation :: World -> World
--setWpLocation w' = case maybewpid of
-- Nothing -> w' & creatures . ix n . crInv . ix j . itID .~ Just newitid
-- & itemPositions %~ IM.insert newitid (InInv n j)
-- _ -> w'
--newitid = newKey $ _itemPositions w
--wpid = fromMaybe newitid maybewpid
throwArmReset :: Int -> ItEffect
throwArmReset x =
@@ -1396,43 +1422,6 @@ grenadePic x = pictures [ color (dark $ dark green) $ circleSolid 5
$ scale 0.05 0.05 $ color green $ text $ show $ 1 + quot x 20
]
bezTest cid w = mkBezierBul (0,11) (0,20) (0,20) cid w
bezierTarget :: Int -> World -> World
bezierTarget cid w = setTarget w
where
j = _crInvSel $ _creatures w IM.! cid
setTarget = set (creatures . ix cid . crInv . ix j . wpFire) $ bezierControl p
p = mouseWorldPos w
bezierControl :: Point2 -> Int -> World -> World
bezierControl targetp cid w = resetGun $ shootWithSound 0 (mkBezierBul startp controlp targetp) cid w
where
j = _crInvSel $ _creatures w IM.! cid
controlp = mouseWorldPos w
cr = _creatures w IM.! cid
dir = _crDir cr
startp = _crPos cr +.+ rotateV dir (_crRad cr + 1,0)
resetGun = set (creatures . ix cid . crInv . ix j . wpFire) $ bezierTarget
bezierShoot :: Int -> World -> World
bezierShoot cid w = case w ^? creatures . ix cid . crInv . ix itRef . itAttachment of
Just (Just (ItTargetPos targetp)) -> shootWithSound 0 (mkBezierBul startp controlp targetp) cid w
_ -> w & creatures . ix cid . crInv . ix itRef . itAttachment .~ Just (ItTargetPos controlp)
where
j = _crInvSel $ _creatures w IM.! cid
controlp = mouseWorldPos w
cr = _creatures w IM.! cid
dir = _crDir cr
startp = _crPos cr +.+ rotateV dir (_crRad cr + 1,0)
itRef = _crInvSel cr
mkBezierBul :: Point2 -> Point2 -> Point2 -> Int -> World -> World
mkBezierBul startp controlp targetp cid w = over particles' (bbul :) w
where
bbul = aCurveBulAt (Just cid) white startp controlp targetp
(threeEff' bulHitCr' bulHitWall' bulHitFF') 5
fireRemoteLauncher :: Int -> World -> World
fireRemoteLauncher cid w = setLocation $ resetFire $ resetName
$ soundOnce (fromIntegral launcherSound)