Move launcher homing to module, add double launcher

This commit is contained in:
2022-03-02 18:05:42 +00:00
parent ae387e85e3
commit 163d0c584a
4 changed files with 52 additions and 20 deletions
+34 -17
View File
@@ -1,7 +1,8 @@
module Dodge.Item.Weapon.Launcher
( launcher
, trackingLauncher
, doubleLauncher
, remoteLauncher
, fireTrackingShell
) where
import Dodge.Data
import Dodge.Default
@@ -43,12 +44,13 @@ launcher = defaultGun
{ _amPayload = makeExplosionAt
, _amString = "EXPLOSIVE SHELL"
, _amPjDraw = drawShell
, _amPjCreation = fireShell
}
, _ammoBaseMax = 1
, _ammoLoaded = 1
, _reloadTime = 80
}
, _itUse = ruseRate 20 fireLauncher upHammer
, _itUse = ruseRate 20 usePjCreation upHammer
[ hammerCheckI
, ammoCheckI
, useTimeCheck
@@ -58,7 +60,6 @@ launcher = defaultGun
& useAim . aimSpeed .~ 0.2
& useAim . aimRange .~ 0.5
& useAim . aimStance .~ TwoHandTwist
, _itEffect = NoItEffect
, _itParams = ShellLauncher
{ _shellSpinDrag = 1
, _shellSpinAmount = 2
@@ -80,6 +81,28 @@ launcher = defaultGun
, _dimSPic = launcherPic
}
}
& itModules . at ModLauncherHoming ?~ DefaultModule
doubleLauncher :: Item
doubleLauncher = launcher
& itName .~ "DOUBLEROCKO"
& itType .~ DOUBLELAUNCHER
& itUse . rUse .~ usePjCreationDouble
& itUse . useMods .~
[ hammerCheckI
, ammoCheckI
, useTimeCheck
, withSoundStart tap4S
, useAmmoAmount 1
]
usePjCreation :: Item -> Creature -> World -> World
usePjCreation it = _amPjCreation (_aoType (_itConsumption it)) it
usePjCreationDouble :: Item -> Creature -> World -> World
usePjCreationDouble it cr = _amPjCreation (_aoType (_itConsumption it)) it cr
. _amPjCreation (_aoType (_itConsumption it)) it (cr & crDir +~ pi)
launcherPic :: Item -> SPic
launcherPic _ =
( colorSH cyan $ prismPoly
@@ -155,8 +178,8 @@ doThrust pj w = w
(sparkD,_) = randomR (-0.2,0.2) $ _randGen w
r1 = randInCirc 10 & evalState $ _randGen w
fireLauncher :: Item -> Creature -> World -> World
fireLauncher it cr = makeShell it cr $ \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj
fireShell :: Item -> Creature -> World -> World
fireShell it cr = makeShell it cr $ \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj
. pjThrust thrustdelay pj
. reduceSpinBy (1-fromIntegral spindrag*2 / 200) pj
. decTimMvVel pj
@@ -253,12 +276,6 @@ trySpinByCID cid i pj w = w & props . ix pjid . pjSpin .~ newSpin
_ -> 0
spinFactor = 5 * (6 - fromIntegral i)
trackingLauncher :: Item
trackingLauncher = launcher
& itName .~ "ROCKO-TRACK"
& itType .~ TRACKINGLAUNCHER
& itUse . rUse .~ fireTrackingLauncher
remoteLauncherName :: String
remoteLauncherName = "ROCKO-REMOTE"
@@ -266,13 +283,13 @@ remoteLauncher :: Item
remoteLauncher = launcher
& itName .~ remoteLauncherName
& itType .~ REMOTELAUNCHER
& itUse . rUse .~ fireRemoteLauncher
& itUse . rUse .~ fireRemoteShell
& itScope .~ RemoteScope (V2 0 0) 1 True
& itConsumption . aoType . amPjDraw .~ drawRemoteShell
-- TODO consider allowing tweaking rocket speed
fireRemoteLauncher :: Item -> Creature -> World -> World
fireRemoteLauncher it cr w = setLocation
fireRemoteShell :: Item -> Creature -> World -> World
fireRemoteShell it cr w = setLocation
$ set (creatures . ix cid . crInv . ix j . itUse . rUse)
(\_ _ -> explodeRemoteRocket itid i)
$ set (creatures . ix cid . crInv . ix j . itName) remoteLauncherName
@@ -340,7 +357,7 @@ explodeRemoteRocket
-> World
-> World
explodeRemoteRocket itid pjid w = w
& props . ix pjid . pjUpdate .~ (\_ -> retireRemoteProj fireRemoteLauncher itid 30 pjid)
& props . ix pjid . pjUpdate .~ (\_ -> retireRemoteProj fireRemoteShell itid 30 pjid)
& props . ix pjid . prDraw .~ const mempty
& itPoint . itUse . rUse .~ (\_ _ -> id)
& itPoint . itName .~ "REMOTELAUNCHER"
@@ -349,8 +366,8 @@ explodeRemoteRocket itid pjid w = w
itPoint = pointToItem $ _itemPositions w IM.! itid
thepj = _props w IM.! pjid
fireTrackingLauncher :: Item -> Creature -> World -> World
fireTrackingLauncher it cr w = setLocation
fireTrackingShell :: Item -> Creature -> World -> World
fireTrackingShell it cr w = setLocation
$ addTrackRocket w
where
cid = _crID cr