Cleanup launchers
This commit is contained in:
@@ -154,9 +154,10 @@ targetRBPressUpdate _ _ w t
|
||||
|
||||
targetRBCreatureUpdate :: Item -> Creature -> World -> Targeting -> Targeting
|
||||
targetRBCreatureUpdate _ _ w t
|
||||
| SDL.ButtonRight `S.member` _mouseButtons w = t & updatePos
|
||||
| SDL.ButtonRight `S.member` _mouseButtons w && isJust (t ^? tgID . _Just)
|
||||
= t & updatePos
|
||||
& tgActive .~ True
|
||||
| otherwise = t & tgID .~ fmap _crID (creatureNearPoint mwp w)
|
||||
| otherwise = t & tgID .~ fmap _crID (creatureNearPointI 3 mwp w)
|
||||
& updatePos
|
||||
& tgActive .~ False
|
||||
where
|
||||
|
||||
@@ -44,12 +44,13 @@ launcher = defaultGun
|
||||
, _amString = "EXPLOSIVE SHELL"
|
||||
, _amPjDraw = drawShell
|
||||
}
|
||||
, _ammoBaseMax = 30
|
||||
, _ammoLoaded = 30
|
||||
, _ammoBaseMax = 1
|
||||
, _ammoLoaded = 1
|
||||
, _reloadTime = 80
|
||||
}
|
||||
, _itUse = ruseRate 20 aRocketWithItemParams upHammer
|
||||
[ ammoCheckI
|
||||
, _itUse = ruseRate 20 fireLauncher upHammer
|
||||
[ hammerCheckI
|
||||
, ammoCheckI
|
||||
, useTimeCheck
|
||||
, withSoundStart tap4S
|
||||
, useAmmoAmount 1
|
||||
@@ -154,19 +155,18 @@ doThrust pj w = w
|
||||
(sparkD,_) = randomR (-0.2,0.2) $ _randGen w
|
||||
r1 = randInCirc 10 & evalState $ _randGen w
|
||||
|
||||
aRocketWithItemParams :: Item -> Creature -> World -> World
|
||||
aRocketWithItemParams it cr w = over props addShell w
|
||||
fireLauncher :: Item -> Creature -> World -> World
|
||||
fireLauncher it cr w = addShell w
|
||||
where
|
||||
i = IM.newKey $ _props w
|
||||
params = _itParams it
|
||||
spindrag = _shellSpinDrag params
|
||||
spinamount = _shellSpinAmount params
|
||||
thrustdelay = _shellThrustDelay params
|
||||
addShell = makeShell i it cr $ \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj
|
||||
. pjThrust thrustdelay pj
|
||||
. reduceSpinBy (1-fromIntegral spindrag*2 / 200) pj
|
||||
. decTimMvVel pj
|
||||
. moveShell pj
|
||||
addShell = makeShell it cr $ \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj
|
||||
. pjThrust thrustdelay pj
|
||||
. reduceSpinBy (1-fromIntegral spindrag*2 / 200) pj
|
||||
. decTimMvVel pj
|
||||
. moveShell pj
|
||||
|
||||
moveShell :: Prop -- ^ Projectile id
|
||||
-> World
|
||||
@@ -181,13 +181,12 @@ moveShell pj w
|
||||
where
|
||||
time = _pjTimer pj
|
||||
doExplode = w
|
||||
& projectileExplosion oldPos
|
||||
& _pjPayload pj oldPos
|
||||
& stopSoundFrom (ShellSound i)
|
||||
& props %~ IM.delete i
|
||||
i = _pjID pj
|
||||
oldPos = _pjPos pj
|
||||
vel = _pjVel pj
|
||||
projectileExplosion = _pjPayload pj
|
||||
newPos = oldPos +.+ vel
|
||||
|
||||
reduceSpinBy :: Float -> Prop -> World -> World
|
||||
@@ -257,35 +256,16 @@ trySpinByCID cid i pj w = w & props . ix pjid . pjSpin .~ newSpin
|
||||
|
||||
trackingLauncher :: Item
|
||||
trackingLauncher = launcher
|
||||
{ _itName = "ROCKO-TRACK"
|
||||
, _itType = TRACKINGLAUNCHER
|
||||
, _itUse = ruseRate 10 fireTrackingLauncher upHammer
|
||||
[ ammoCheckI
|
||||
, hammerCheckI
|
||||
, useTimeCheck
|
||||
, withSoundStart tap4S
|
||||
, useAmmoAmount 1
|
||||
]
|
||||
& useAim . aimSpeed .~ 0.2
|
||||
& useAim . aimRange .~ 0.5
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
}
|
||||
& itName .~ "ROCKO-TRACK"
|
||||
& itType .~ TRACKINGLAUNCHER
|
||||
& itUse . rUse .~ fireTrackingLauncher
|
||||
|
||||
remoteLauncher :: Item
|
||||
remoteLauncher = launcher
|
||||
{ _itName = "ROCKO-REMOTE"
|
||||
, _itType = REMOTELAUNCHER
|
||||
, _itUse = ruseRate 10 fireRemoteLauncher upHammer
|
||||
[ ammoCheckI
|
||||
, hammerCheckI
|
||||
, useTimeCheck
|
||||
, withSoundStart tap4S
|
||||
, useAmmoAmount 1
|
||||
]
|
||||
& useAim . aimSpeed .~ 0.2
|
||||
& useAim . aimRange .~ 0.5
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
, _itScope = RemoteScope (V2 0 0) 1 True
|
||||
}
|
||||
& itName .~ "ROCKO-REMOTE"
|
||||
& itType .~ REMOTELAUNCHER
|
||||
& itUse . rUse .~ fireRemoteLauncher
|
||||
& itScope .~ RemoteScope (V2 0 0) 1 True
|
||||
& itConsumption . aoType . amPjDraw .~ drawRemoteShell
|
||||
-- TODO consider allowing tweaking rocket speed
|
||||
|
||||
@@ -294,11 +274,11 @@ fireRemoteLauncher it cr w = setLocation
|
||||
$ set (creatures . ix cid . crInv . ix j . itUse . rUse)
|
||||
(\_ _ -> explodeRemoteRocket itid i)
|
||||
$ set (creatures . ix cid . crInv . ix j . itName) "REMOTEROCKET"
|
||||
$ over props addRemRocket w
|
||||
$ addRemRocket w
|
||||
where
|
||||
i = IM.newKey $ _props w
|
||||
cid = _crID cr
|
||||
addRemRocket = makeShell i it cr $ \pj ->
|
||||
addRemRocket = makeShell it cr $ \pj ->
|
||||
decTimMvVel pj . setRemoteScope itid pj . moveRemoteShell cid itid pj
|
||||
j = _crInvSel cr
|
||||
newitid = IM.newKey $ _itemPositions w
|
||||
@@ -368,11 +348,10 @@ explodeRemoteRocket itid pjid w
|
||||
|
||||
fireTrackingLauncher :: Item -> Creature -> World -> World
|
||||
fireTrackingLauncher it cr w = setLocation
|
||||
$ over props addTrackRocket w
|
||||
$ addTrackRocket w
|
||||
where
|
||||
i = IM.newKey $ _props w
|
||||
cid = _crID cr
|
||||
addTrackRocket = makeShell i it cr $ \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj
|
||||
addTrackRocket = makeShell it cr $ \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj
|
||||
. pjThrust thrustdelay pj
|
||||
. reduceSpinBy (1-fromIntegral spindrag*2 / 200) pj
|
||||
. decTimMvVel pj
|
||||
@@ -392,8 +371,8 @@ fireTrackingLauncher it cr w = setLocation
|
||||
spindrag = _shellSpinDrag params
|
||||
params = _itParams it
|
||||
|
||||
makeShell :: Int -> Item -> Creature -> (Prop -> World -> World) -> IM.IntMap Prop -> IM.IntMap Prop
|
||||
makeShell i it cr theupdate = IM.insert i Shell
|
||||
makeShell :: Item -> Creature -> (Prop -> World -> World) -> World -> World
|
||||
makeShell it cr theupdate w = w & props %~ IM.insert i Shell
|
||||
{ _pjPos = pos
|
||||
, _pjZ = 20
|
||||
, _pjStartPos = pos
|
||||
@@ -408,6 +387,7 @@ makeShell i it cr theupdate = IM.insert i Shell
|
||||
, _pjTimer = 50
|
||||
}
|
||||
where
|
||||
i = IM.newKey $ _props w
|
||||
dir = _crDir cr
|
||||
pos = _crPos cr +.+ rotateV dir (V2 (_crRad cr + 1) 0)
|
||||
am = _itConsumption it
|
||||
|
||||
Reference in New Issue
Block a user