Unify launcher projectiles
This commit is contained in:
@@ -15,7 +15,7 @@ import Control.Lens
|
||||
data Huse
|
||||
= HeldDoNothing
|
||||
-- | HeldFireRemoteShell
|
||||
| HeldExplodeRemoteShell Int Int
|
||||
-- | HeldExplodeRemoteShell Int Int
|
||||
| HeldDetectorEffect Detector
|
||||
| HeldForceField
|
||||
-- | HeldShatter
|
||||
|
||||
@@ -25,14 +25,14 @@ data ProjectileUpdate
|
||||
= PJThrust {_pjuStart :: Int, _pjuEnd :: Int}
|
||||
| PJSpin {_pjuTime :: Int, _pjuCID :: Int, _pjuSpinAmound :: Int}
|
||||
-- | PJTrack {_pjuStart :: Int, _pjuEnd :: Int, _pjuScreenID :: Int}
|
||||
| PJRemoteSetDirection {_pjuStart :: Int, _pjuEnd :: Int, _pjuScreenID :: Int}
|
||||
| PJRemoteSetDirection {_pjuStart :: Int, _pjuEnd :: Int, _pjuControllerID :: Maybe Int}
|
||||
| PJReduceSpin {_pjuReduceSpin :: Float}
|
||||
-- | PJRemoteDirection {_pjuStart :: Int, _pjuEnd :: Int, _pjuCID :: Int, _pjuITID :: Int}
|
||||
-- | PJSetScope {_pjuITID :: Int}
|
||||
| PJRetireRemote {_pjuItID :: Int, _pjuTimer :: Int, _pjuPJID :: Int}
|
||||
| PJRetireRemote {_pjuScreenID :: Maybe Int, _pjuTimer :: Int, _pjuPJID :: Int}
|
||||
| PJDecTimMvVel
|
||||
| PJShellCollisionCheck
|
||||
| PJRemoteShellCollisionCheck {_pjuScreenID :: Int}
|
||||
-- | PJShellCollisionCheck
|
||||
| PJRemoteShellCollisionCheck {_pjuScreenID :: Maybe Int}
|
||||
-- | PJRemoteShellExplosion
|
||||
deriving (Show, Eq, Ord, Read) --Generic, Flat)
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import Dodge.Creature.HandPos
|
||||
import Dodge.Data.World
|
||||
import Dodge.Gas
|
||||
import Dodge.Item.Weapon.BatteryGuns
|
||||
import Dodge.Item.Weapon.Launcher
|
||||
--import Dodge.Item.Weapon.Launcher
|
||||
import Dodge.Item.Weapon.Radar
|
||||
import Dodge.Item.Weapon.Shatter
|
||||
import Dodge.Item.Weapon.TriggerType
|
||||
@@ -323,7 +323,7 @@ useHeld hu = case hu of
|
||||
-- HeldSonicWave -> aSonicWave
|
||||
HeldForceField -> useForceFieldGun . _ldtValue
|
||||
-- HeldShatter -> shootShatter . _ldtValue
|
||||
HeldExplodeRemoteShell itid pjid -> const $ const $ explodeRemoteRocket itid pjid
|
||||
-- HeldExplodeRemoteShell itid pjid -> const $ const $ explodeRemoteRocket itid pjid
|
||||
|
||||
--usePjCreation :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
--usePjCreation itm cr = fromMaybe id $ do
|
||||
@@ -507,13 +507,13 @@ createProjectile magtree muz itm cr = fromMaybe failsound $ do
|
||||
-- matype <- ammoitem ^? itUse . amagType
|
||||
-- guard $ matype == ProjectileAmmo
|
||||
j <- ammoitem ^? itLocation . ilInvID
|
||||
return $ fireTrackingShell (mscreen ^? _Just . ldtValue) ammoitem muz itm cr . extrafuncs j
|
||||
-- pt <- ammoitem ^? itUse . amagParams . ampPjCreation
|
||||
return $ case mscreen of
|
||||
Nothing -> fireShell ammoitem muz itm cr . extrafuncs j
|
||||
Just stree -> fireTrackingShell
|
||||
(stree ^. ldtValue . itID)
|
||||
(stree ^?! ldtValue . itLocation . ilInvID) ammoitem muz itm cr
|
||||
. extrafuncs j
|
||||
-- return $ case mscreen of
|
||||
-- Nothing -> fireShell ammoitem muz itm cr . extrafuncs j
|
||||
-- Just stree -> fireTrackingShell
|
||||
-- (stree ^? ldtValue) ammoitem muz itm cr
|
||||
-- . extrafuncs j
|
||||
where
|
||||
--extrafuncs j = cancelanyreloading . startthesound . useammo j
|
||||
extrafuncs j = startthesound . useammo j
|
||||
|
||||
@@ -2,6 +2,7 @@ module Dodge.Item.Weapon.Launcher (
|
||||
explodeRemoteRocket,
|
||||
) where
|
||||
|
||||
import Dodge.SoundLogic
|
||||
import Control.Lens
|
||||
import Dodge.Data.World
|
||||
--import Dodge.Item.Location
|
||||
@@ -9,18 +10,19 @@ import Dodge.Payload
|
||||
|
||||
explodeRemoteRocket ::
|
||||
-- | Item id
|
||||
Int ->
|
||||
Maybe Int ->
|
||||
-- | Projectile id
|
||||
Int ->
|
||||
World ->
|
||||
World
|
||||
explodeRemoteRocket itid pjid w =
|
||||
explodeRemoteRocket mitid pjid w =
|
||||
w
|
||||
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid]
|
||||
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [PJRetireRemote mitid 30 pjid]
|
||||
& cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
||||
-- & itPoint . itUse . heldUse .~ HeldDoNothing
|
||||
-- & itPoint . itUse . heldMods .~ DoNothingMod
|
||||
& usePayload (_prjPayload thepj) (_prjPos thepj)
|
||||
& stopSoundFrom (ShellSound pjid)
|
||||
where
|
||||
-- itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid-- _itemLocations (_cWorld w) IM.! itid
|
||||
thepj = w ^?! cWorld . lWorld . projectiles . ix pjid
|
||||
|
||||
@@ -20,9 +20,10 @@ fireShell ammoitem muz it cr =
|
||||
ammoitem
|
||||
muz
|
||||
cr
|
||||
[ PJShellCollisionCheck
|
||||
[ PJRemoteShellCollisionCheck Nothing
|
||||
, PJDecTimMvVel
|
||||
, PJSpin 335 (_crID cr) spinamount
|
||||
, PJRemoteSetDirection (350 - thrustdelay) 0 Nothing
|
||||
, PJThrust (350 - thrustdelay) 0
|
||||
, PJReduceSpin (1 - fromIntegral spindrag * 2 / 200)
|
||||
]
|
||||
@@ -32,6 +33,7 @@ fireShell ammoitem muz it cr =
|
||||
spinamount = _shellSpinAmount params
|
||||
thrustdelay = _shellThrustDelay params
|
||||
|
||||
-- rather than screen invid why not use an item location?
|
||||
makeShell :: Maybe Int -> Item -> Muzzle -> Creature -> [ProjectileUpdate] -> World -> World
|
||||
makeShell mscreeninvid ammoitem muz cr theupdate w = fromMaybe w $ do
|
||||
aparams <- ammoitem ^? itUse . amagParams
|
||||
@@ -64,16 +66,17 @@ makeShell mscreeninvid ammoitem muz cr theupdate w = fromMaybe w $ do
|
||||
|
||||
--am = _heldConsumption $ _itUse it
|
||||
|
||||
fireTrackingShell :: Int -> Int -> Item -> Muzzle -> Item -> Creature -> World -> World
|
||||
fireTrackingShell screenid screeninvid ammoitem muz it cr = makeShell
|
||||
(Just screeninvid)
|
||||
-- assumes the mscreen is in your inventory
|
||||
fireTrackingShell :: Maybe Item -> Item -> Muzzle -> Item -> Creature -> World -> World
|
||||
fireTrackingShell mscreen ammoitem muz it cr = makeShell
|
||||
(mscreen ^? _Just . itLocation . ilInvID) -- Just screeninvid)
|
||||
ammoitem
|
||||
muz
|
||||
cr
|
||||
[ PJRemoteShellCollisionCheck screenid
|
||||
[ PJRemoteShellCollisionCheck (mscreen ^? _Just . itID) --Just screenid)
|
||||
, PJDecTimMvVel
|
||||
, PJSpin 335 (_crID cr) spinamount
|
||||
, PJRemoteSetDirection (350 - thrustdelay) 0 screenid
|
||||
, PJRemoteSetDirection (350 - thrustdelay) 0 (mscreen ^? _Just . itID)
|
||||
, PJThrust (350 - thrustdelay) 0
|
||||
, PJReduceSpin (1 - fromIntegral spindrag * 2 / 200)
|
||||
]
|
||||
|
||||
@@ -39,22 +39,23 @@ shellCollisionCheck doExplode pj w
|
||||
vel = _prjVel pj
|
||||
newPos = oldPos +.+ vel
|
||||
|
||||
remoteShellCollisionCheck :: Int -> Proj -> World -> World
|
||||
remoteShellCollisionCheck screenid = shellCollisionCheck $ \pj -> explodeRemoteRocket screenid (_prjID pj)
|
||||
remoteShellCollisionCheck :: Maybe Int -> Proj -> World -> World
|
||||
remoteShellCollisionCheck mscreenid = shellCollisionCheck
|
||||
$ \pj -> explodeRemoteRocket mscreenid (_prjID pj)
|
||||
|
||||
plainShellCollisionCheck :: Proj -> World -> World
|
||||
plainShellCollisionCheck = shellCollisionCheck $ \pj ->
|
||||
usePayload (_prjPayload pj) (_prjPos pj)
|
||||
. stopSoundFrom (ShellSound (_prjID pj))
|
||||
. (cWorld . lWorld . projectiles %~ IM.delete (_prjID pj))
|
||||
--plainShellCollisionCheck :: Proj -> World -> World
|
||||
--plainShellCollisionCheck = shellCollisionCheck $ \pj ->
|
||||
-- usePayload (_prjPayload pj) (_prjPos pj)
|
||||
-- . stopSoundFrom (ShellSound (_prjID pj))
|
||||
-- . (cWorld . lWorld . projectiles %~ IM.delete (_prjID pj))
|
||||
|
||||
upsProjectile :: Proj -> World -> World
|
||||
upsProjectile pj w' = foldr (`upProjectile` pj) w' (_prjUpdates pj)
|
||||
|
||||
upProjectile :: ProjectileUpdate -> Proj -> World -> World
|
||||
upProjectile pu pj = case pu of
|
||||
PJRemoteShellCollisionCheck screenid -> remoteShellCollisionCheck screenid pj
|
||||
PJShellCollisionCheck -> plainShellCollisionCheck pj
|
||||
PJRemoteShellCollisionCheck mscreenid -> remoteShellCollisionCheck mscreenid pj
|
||||
-- PJShellCollisionCheck -> plainShellCollisionCheck pj
|
||||
PJDecTimMvVel -> decTimMvVel pj
|
||||
PJThrust st et
|
||||
| act st et -> doThrust pj
|
||||
@@ -62,15 +63,15 @@ upProjectile pu pj = case pu of
|
||||
PJSpin t cid spinamount
|
||||
| ain t -> trySpinByCID cid spinamount pj
|
||||
| otherwise -> id
|
||||
PJRemoteSetDirection st et screenid
|
||||
| act st et -> pjRemoteSetDirection screenid pj
|
||||
PJRemoteSetDirection st et mscreenid
|
||||
| act st et -> pjRemoteSetDirection mscreenid pj
|
||||
| otherwise -> id
|
||||
PJReduceSpin x -> reduceSpinBy x pj
|
||||
-- PJRemoteDirection st et cid itid
|
||||
-- | act st et -> setRemoteDir cid itid pj
|
||||
-- | otherwise -> id
|
||||
-- PJSetScope itid -> setRemoteScope itid (_prjPos pj)
|
||||
PJRetireRemote itid 0 pjid -> retireRemoteProj itid pjid
|
||||
PJRetireRemote mitid 0 pjid -> retireRemoteProj mitid pjid
|
||||
-- the following requires that this is at the top of the update list, which is
|
||||
-- not ideal
|
||||
PJRetireRemote _ _ pjid -> cWorld . lWorld . projectiles . ix pjid . prjUpdates . ix 0 . pjuTimer -~ 1
|
||||
@@ -79,40 +80,17 @@ upProjectile pu pj = case pu of
|
||||
act st et = time <= st && time >= et
|
||||
ain t = time == t
|
||||
|
||||
retireRemoteProj :: Int -> Int -> World -> World
|
||||
retireRemoteProj itid pjid w = w & cWorld . lWorld . projectiles %~ IM.delete pjid
|
||||
retireRemoteProj :: Maybe Int -> Int -> World -> World
|
||||
retireRemoteProj mitid pjid w = w & cWorld . lWorld . projectiles %~ IM.delete pjid
|
||||
& removelink
|
||||
where
|
||||
removelink = fromMaybe id $ do
|
||||
itid <- mitid
|
||||
loc <- w ^? cWorld . lWorld . itemLocations . ix itid
|
||||
itm <- w ^? pointerToItemLocation loc . itUse . atLinkedProjectile . _Just
|
||||
guard $ itm == pjid
|
||||
--return $ pointerToItemLocation . itUse . atLinkedProjectile .~ Nothing
|
||||
return $ pointerToItemLocation loc . itUse . atLinkedProjectile .~ Nothing
|
||||
|
||||
|
||||
--retireRemoteProj :: Int -> Int -> World -> World
|
||||
--retireRemoteProj itid pjid w =
|
||||
-- w
|
||||
-- & pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix itid)
|
||||
-- %~ ( (itScope . remotePos .~ V2 0 0)
|
||||
-- . (itUse . heldUse .~ HeldFireRemoteShell)
|
||||
-- . (itUse . heldMods .~ FireRemoteShellMod)
|
||||
-- )
|
||||
-- & cWorld . lWorld . props %~ IM.delete pjid
|
||||
|
||||
--setRemoteDir :: Int -> Int -> Proj -> World -> World
|
||||
--setRemoteDir cid itid pj w = w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc .~ turntonewdir
|
||||
-- where
|
||||
-- turntonewdir = magV (_prjAcc pj) *.* unitVectorAtAngle newdir
|
||||
-- --i = _prjID pj
|
||||
-- newdir
|
||||
-- | SDL.ButtonRight `M.member` _mouseButtons (_input w)
|
||||
-- && w ^? cWorld . lWorld . creatures . ix cid . crManipulation . manObject . imSelectedItem
|
||||
-- == w ^? cWorld . lWorld . itemLocations . ix itid . ilInvID
|
||||
-- = (w ^. wCam . camRot) + argV (_mousePos (_input w))
|
||||
-- | otherwise = _prjDir pj
|
||||
|
||||
doThrust :: Proj -> World -> World
|
||||
doThrust pj w =
|
||||
w
|
||||
@@ -166,17 +144,16 @@ trySpinByCID cid i pj w = w & cWorld . lWorld . projectiles . ix pjid . prjSpin
|
||||
-- --itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid
|
||||
|
||||
-- note this only allows YOU to remotely track projectiles
|
||||
pjRemoteSetDirection :: Int -> Proj -> World -> World
|
||||
pjRemoteSetDirection screenid pj w = w
|
||||
& cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc .~ turntonewdir
|
||||
where
|
||||
turntonewdir = magV (_prjAcc pj) *.* unitVectorAtAngle newdir
|
||||
--i = _prjID pj
|
||||
newdir
|
||||
| w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imSelectedItem
|
||||
== w ^? cWorld . lWorld . itemLocations . ix screenid . ilInvID
|
||||
= (w ^. wCam . camRot) + argV (_mousePos (_input w))
|
||||
| otherwise = _prjDir pj
|
||||
pjRemoteSetDirection :: Maybe Int -> Proj -> World -> World
|
||||
pjRemoteSetDirection mscreenid pj w = fromMaybe w $ do
|
||||
screenid <- mscreenid
|
||||
let newdir
|
||||
| w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imSelectedItem
|
||||
== w ^? cWorld . lWorld . itemLocations . ix screenid . ilInvID
|
||||
= (w ^. wCam . camRot) + argV (_mousePos (_input w))
|
||||
| otherwise = _prjDir pj
|
||||
turntonewdir = magV (_prjAcc pj) *.* unitVectorAtAngle newdir
|
||||
return $ w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc .~ turntonewdir
|
||||
|
||||
--pjTrack :: Int -> Proj -> World -> World
|
||||
--pjTrack screenid pj w = w-- rotateToTarget pj w
|
||||
|
||||
@@ -14,7 +14,7 @@ selectUse ittree _ w = fromMaybe w $ do
|
||||
pjid <- ittree ^? ldtValue . itUse . atLinkedProjectile . _Just
|
||||
thepj <- w ^? cWorld . lWorld . projectiles . ix pjid
|
||||
return $ w
|
||||
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid] -- 69 is placeholder, should be removed
|
||||
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [PJRetireRemote (Just itid) 30 pjid] -- 69 is placeholder, should be removed
|
||||
& cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
||||
-- & itPoint . itUse . heldUse .~ HeldDoNothing
|
||||
-- & itPoint . itUse . heldMods .~ DoNothingMod
|
||||
|
||||
Reference in New Issue
Block a user