Implement remote screen for launcher projectiles

This commit is contained in:
2024-09-27 10:39:21 +01:00
parent fb6fcff61c
commit 5f9fb183a9
35 changed files with 238 additions and 170 deletions
+1 -1
View File
@@ -1 +1 @@
All good (620 modules, at 16:31:55)
All good (620 modules, at 10:38:24)
+1 -1
View File
@@ -4,7 +4,7 @@ import Dodge.Data.Universe
import Control.Lens
useNormalCamera :: Universe -> Universe
useNormalCamera = (uvWorld . wCam . camControl .~ CamInGame)
useNormalCamera = (uvWorld . wCam . camControl .~ CamInGame{_cigType = CamOnPlayer})
. (uvWorld . timeFlow .~ NormalTimeFlow)
pauseAndFloatCam :: Universe -> Universe
+2 -2
View File
@@ -25,7 +25,7 @@ import SimpleTrie
invertInventoryToMap :: IM.IntMap Item -> M.Map ItemBaseType [Int]
invertInventoryToMap =
IM.foldrWithKey
(\k it -> (M.insertWith (++) (_iyBase $ _itType it) [k]))
(\k it -> M.insertWith (++) (_iyBase $ _itType it) [k])
mempty
groupSplitItemAmounts :: M.Map ItemBaseType [Int] -> [((ItAmount, ItemBaseType), [Int])]
@@ -39,7 +39,7 @@ flatLookupItems =
. invertInventoryToMap
combineItemListYouX :: World -> [([Int], Item)]
combineItemListYouX = map (first $ concat) . flatLookupItems . yourInv
combineItemListYouX = map (first concat) . flatLookupItems . yourInv
combineList :: World -> [SelectionItem CombinableItem]
combineList = map f . combineListInfo
+1 -1
View File
@@ -34,7 +34,7 @@ moduleModification imt = case imt of
--LAUNCHHOME -> itUse . heldConsumption . laAmmoType . amPjCreation .~ CreateTrackingShell
LAUNCHHOME -> id
ATTACHTORCH -> id
where
-- where
-- makeDirectedTele it =
-- it
-- & itUse . heldMods %~ ModWithDirectedTeleport -- .:~ withPosDirWallCheck directedTelPos
-1
View File
@@ -299,7 +299,6 @@ stackedInventory =
, miniGunX 3
, beltMag
, boosterGun
, remoteLauncher
, flatShield
, spawnGun (lamp 5)
, lasGun
+3 -2
View File
@@ -18,7 +18,8 @@ import Dodge.Data.World
import Geometry.Data
sentinelAI :: World -> Creature -> Creature
sentinelAI w =
--sentinelAI w =
sentinelAI =
sentinelExtraWatchUpdate
[
( crHasTargetLOS
@@ -37,7 +38,7 @@ sentinelAI w =
]
)
]
w
-- w
where
advanceShoot = DoImpulses [UseItem, MoveForward 3]
tcid cr = _crID <$> _targetCr (_crIntention cr)
+3 -3
View File
@@ -247,11 +247,11 @@ invSideEff cr w =
w' & maybe id (\g -> doInvEffect g it cr) (it ^? itEffect . ieInv)
itemInvSideEffect :: Creature -> Item -> World -> World
itemInvSideEffect _ _
itemInvSideEffect _ _ = id
--itemInvSideEffect cr it
-- | hastorchattach = createAttachLight cr it
| otherwise = id
where
-- | otherwise = id
-- where
-- hastorchattach = it ^? itType . iyModules . ix ModHeldAttach == Just ATTACHTORCH && _itIsRoot it
--createAttachLight :: Creature -> Item -> World -> World
+12 -4
View File
@@ -9,11 +9,17 @@ import Data.Aeson
import Data.Aeson.TH
import Geometry.Data
data CamControl
= CamInGame
| CamFloat
data CamInGameType
= CamOnPlayer
| CamOpticScope
| CamRemoteScope
deriving (Eq,Show,Read,Enum,Bounded)
data CamControl
= CamInGame { _cigType :: CamInGameType}
| CamFloat
deriving (Eq,Show,Read)
data Camera = Camera
{ _camCenter :: Point2
, _camRot :: Float
@@ -28,8 +34,10 @@ data Camera = Camera
}
makeLenses ''Camera
makeLenses ''CamInGameType
concat
<$> mapM
(deriveJSON defaultOptions)
[''CamControl
[''CamInGameType
,''CamControl
,''Camera ]
+1 -1
View File
@@ -191,7 +191,7 @@ data HeldItemType
| TRACTORGUN
| LAUNCHER
| LAUNCHERX {_xNum :: Int}
| REMOTELAUNCHER
-- | REMOTELAUNCHER
| POISONSPRAYER
| DRONELAUNCHER
| SHATTERGUN
+3 -3
View File
@@ -14,11 +14,11 @@ import Control.Lens
data Huse
= HeldDoNothing
| HeldFireRemoteShell
-- | HeldFireRemoteShell
| HeldExplodeRemoteShell Int Int
| HeldDetectorEffect Detector
| HeldForceField
| HeldShatter
-- | HeldShatter
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data Cuse
@@ -58,7 +58,7 @@ data Luse
data HeldMod
= PistolMod
| FireRemoteShellMod
-- | FireRemoteShellMod
| ExplodeRemoteShellMod
| DoNothingMod
deriving (Eq, Ord, Show, Read) --Generic, Flat)
+1 -1
View File
@@ -112,7 +112,7 @@ data AmmoParams
| ProjectileParams
{ _ampPayload :: Payload
, _ampPjDraw :: ProjectileDraw
, _ampPjCreation :: ProjectileCreate
-- , _ampPjCreation :: ProjectileCreate
}
| GasParams {_ampCreateGas :: GasFuel}
deriving (Eq, Show, Read) --Generic, Flat)
+7 -5
View File
@@ -24,14 +24,16 @@ data ProjectileCreate = CreateShell | CreateTrackingShell
data ProjectileUpdate
= PJThrust {_pjuStart :: Int, _pjuEnd :: Int}
| PJSpin {_pjuTime :: Int, _pjuCID :: Int, _pjuSpinAmound :: Int}
| PJTrack {_pjuStart :: Int, _pjuEnd :: Int, _pjuCRID :: Int}
-- | PJTrack {_pjuStart :: Int, _pjuEnd :: Int, _pjuScreenID :: Int}
| PJRemoteSetDirection {_pjuStart :: Int, _pjuEnd :: Int, _pjuScreenID :: Int}
| PJReduceSpin {_pjuReduceSpin :: Float}
| PJRemoteDirection {_pjuStart :: Int, _pjuEnd :: Int, _pjuCID :: Int, _pjuITID :: Int}
| PJSetScope {_pjuITID :: Int}
| PJRetireRemote {_pjuITID :: Int, _pjuTimer :: Int, _pjuPJID :: Int}
-- | PJRemoteDirection {_pjuStart :: Int, _pjuEnd :: Int, _pjuCID :: Int, _pjuITID :: Int}
-- | PJSetScope {_pjuITID :: Int}
| PJRetireRemote {_pjuItID :: Int, _pjuTimer :: Int, _pjuPJID :: Int}
| PJDecTimMvVel
| PJShellCollisionCheck
| PJRemoteShellCollisionCheck
| PJRemoteShellCollisionCheck {_pjuScreenID :: Int}
-- | PJRemoteShellExplosion
deriving (Show, Eq, Ord, Read) --Generic, Flat)
data AmmoType
+1 -1
View File
@@ -25,7 +25,7 @@ data Proj
, _prjTimer :: Int
, _prjZ :: Float
, _prjUpdates :: [ProjectileUpdate]
, _prjMITID :: Maybe Int
-- , _prjMITID :: Maybe Int
}
deriving (Eq, Ord, Show, Read) --Generic, Flat)
+1 -1
View File
@@ -19,5 +19,5 @@ defaultShell =
, _prjTimer = 0
, _prjPayload = ExplosionPayload
, _prjUpdates = []
, _prjMITID = Nothing
-- , _prjMITID = Nothing
}
+1 -1
View File
@@ -74,7 +74,7 @@ defaultCWCam =
, _camItemZoom = 1
, _camBoundBox = square 100
, _camBoundDist = (100, -100, 100, -100)
, _camControl = CamInGame
, _camControl = CamInGame {_cigType = CamOnPlayer}
}
defaultCWorld :: CWorld
+1 -1
View File
@@ -120,7 +120,7 @@ headMap _ _ [] = []
lastMap :: (a -> b) -> (a -> b) -> [a] -> [b]
lastMap _ _ [] = []
lastMap f _ (x:[]) = [f x]
lastMap f _ [x] = [f x]
lastMap f g (x:xs) = g x : lastMap f g xs
prettyDT :: (a -> String) -> DoubleTree a -> [String]
+22 -18
View File
@@ -44,10 +44,9 @@ import Sound.Data
heldEffect :: HeldMod -> LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
heldEffect effecttype = case effecttype of
PistolMod -> bulGunEffect
FireRemoteShellMod -> undefined
-- FireRemoteShellMod -> undefined
ExplodeRemoteShellMod -> undefined
DoNothingMod -> const $ const id
where
bulGunEffect :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
bulGunEffect = hammerCheck $ useTimeCheck bulGunEffect'
@@ -131,7 +130,8 @@ applyTorqueCME itm cr w
-- (Muzzle,Int,Int) = (muzzle, amountloaded, id of mag taken from)
loadMuzzle :: LabelDoubleTree ComposeLinkType Item
-> Muzzle -> (LabelDoubleTree ComposeLinkType Item,Maybe (Muzzle, Int,LabelDoubleTree ComposeLinkType Item))
-> Muzzle
-> (LabelDoubleTree ComposeLinkType Item,Maybe (Muzzle, Int,LabelDoubleTree ComposeLinkType Item))
loadMuzzle t@(LDT _ l _) mz = fromMaybe (t,Nothing) $ do
let as = _mzAmmoSlot mz
amamount = 1
@@ -313,7 +313,7 @@ useHeld hu = case hu of
-- HeldOverNozzlesUseGasParams -> overNozzles useGasParams
-- HeldPJCreation -> usePjCreation
-- HeldPJCreationX _ -> usePjCreationX
HeldFireRemoteShell -> fireRemoteShell
-- HeldFireRemoteShell -> fireRemoteShell
HeldDetectorEffect dt -> detectorEffect dt . _ldtValue
-- HeldTeslaArc -> shootTeslaArc . _ldtValue
-- HeldLaser -> shootLaser . _ldtValue
@@ -322,7 +322,7 @@ useHeld hu = case hu of
-- HeldTractor -> aTractorBeam . _ldtValue
-- HeldSonicWave -> aSonicWave
HeldForceField -> useForceFieldGun . _ldtValue
HeldShatter -> shootShatter . _ldtValue
-- HeldShatter -> shootShatter . _ldtValue
HeldExplodeRemoteShell itid pjid -> const $ const $ explodeRemoteRocket itid pjid
--usePjCreation :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
@@ -402,18 +402,18 @@ useGasParams mmagid mz itm cr w =
pos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm)
(a,g') = randomR (-inacc,inacc) g
inacc = _mzInaccuracy mz
dir = _crDir cr + _mzRot mz + a + (_nzCurrentWalkAngle $ _mzEffect mz)
dir = _crDir cr + _mzRot mz + a + _nzCurrentWalkAngle (_mzEffect mz)
gasCreate :: GasFuel -> GasCreate -> GasCreate
gasCreate = flip const
gasCreate = const id
doGenFloat :: RandomGen g => GenFloat -> g -> (Float, g)
doGenFloat (ConstFloat x) g = (x,g)
doGenFloat (UniRandFloat x y) g = randomR (x,y) g
fireRemoteShell :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
fireRemoteShell = undefined
--fireRemoteShell :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
--fireRemoteShell = undefined
--fireRemoteShell :: [Item] -> Item -> Creature -> World -> World
--fireRemoteShell ams it cr w =
-- set
@@ -497,24 +497,28 @@ useForceFieldGun itm cr w = fromMaybe w $ do
where
i = fromMaybe (IM.newKey (_walls (_lWorld (_cWorld w)))) $ itm ^? itParams . paramMID . _Just
createProjectile :: LabelDoubleTree ComposeLinkType Item -> Muzzle -> Item -> Creature -> World -> World
createProjectile mmagtree muz itm cr = fromMaybe failsound $ do
magid <- mmagtree ^? ldtValue . itLocation . ilInvID
createProjectile
:: LabelDoubleTree ComposeLinkType Item
-> Muzzle -> Item -> Creature -> World -> World
createProjectile magtree muz itm cr = fromMaybe failsound $ do
magid <- magtree ^? ldtValue . itLocation . ilInvID
ammoitem <- cr ^? crInv . ix magid
-- let mremotescreen = magtree ^.
let mscreen = lookup RemoteScreenLink (magtree ^. ldtLeft)
-- matype <- ammoitem ^? itUse . amagType
-- guard $ matype == ProjectileAmmo
j <- ammoitem ^? itLocation . ilInvID
pt <- ammoitem ^? itUse . amagParams . ampPjCreation
return $ case pt of
CreateShell -> fireShell ammoitem muz itm cr . extrafuncs j
CreateTrackingShell -> fireTrackingShell 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
where
--extrafuncs j = cancelanyreloading . startthesound . useammo j
extrafuncs j = startthesound . useammo j
useammo j = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix j . itUse . amagLoadStatus . iaLoaded -~ 1
--cancelanyreloading = cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
-- the sound should be moved to the projectile firing
startthesound = soundMultiFrom [CrWeaponSound (_crID cr) j | j <- [0..3]] (_crPos cr) tap4S Nothing
failsound w' = case w' ^? input . mouseButtons . ix SDL.ButtonLeft of
+2 -2
View File
@@ -222,8 +222,8 @@ updateCloseObjects w =
changeSwapSel :: Int -> World -> World
changeSwapSel yi w
| yi == 0 = w
| yi > 0 = (foldr ($) w $ replicate yi (changeSwapWith $ f IM.cycleLT))
| otherwise = (foldr ($) w $ replicate (negate yi) (changeSwapWith $ f IM.cycleGT))
| yi > 0 = foldr ($) w $ replicate yi (changeSwapWith $ f IM.cycleLT)
| otherwise = foldr ($) w $ replicate (negate yi) (changeSwapWith $ f IM.cycleGT)
where
f g i m = fst <$> g i m
-1
View File
@@ -59,7 +59,6 @@ shellMag =
{ _amagParams = ProjectileParams
{ _ampPayload = ExplosionPayload
, _ampPjDraw = DrawShell
, _ampPjCreation = CreateShell
}
, _amagLoadStatus =
ReloadStatus
+1 -1
View File
@@ -145,7 +145,7 @@ showEquipmentNumber _ itm = case _eeUse ee of
-- <|> Just [x]
showLoadedAmount :: Item -> String
showLoadedAmount itm = fromMaybe [] $ fmap show $ itm ^? itUse . amagLoadStatus . iaLoaded
showLoadedAmount itm = maybe [] show $ itm ^? itUse . amagLoadStatus . iaLoaded
--showReloadProgress :: Creature -> Item -> String
--showReloadProgress _ itm = fromMaybe [] $ do
+5 -5
View File
@@ -168,15 +168,15 @@ heldItemSPic ht it = case ht of
GRAPECANNON _ -> noPic $ bangConeShape 20
MINIGUNX i -> miniGunXPictItem i it
VOLLEYGUN i -> noPic $ volleyGunShape i -- <> addBullets it
RIFLE -> noPic $ baseRifleShape -- <> addBullets it
RIFLE -> noPic baseRifleShape -- <> addBullets it
-- REPEATER -> noPic $ baseRifleShape <> addTinClip it
AUTORIFLE -> noPic $ baseRifleShape <> addTinClip it
BURSTRIFLE -> noPic $ baseRifleShape <> addTinClip it
BANGROD -> noPic $ baseRodShape -- <> addBullets it
ELEPHANTGUN -> noPic $ baseAMRShape -- <> addBullets it
BANGROD -> noPic baseRodShape -- <> addBullets it
ELEPHANTGUN -> noPic baseAMRShape -- <> addBullets it
AMR -> noPic $ baseAMRShape <> addTinClip it
AUTOAMR -> noPic $ baseAMRShape <> addTinClip it
SNIPERRIFLE -> noPic $ baseAMRShape -- <> addBullets it
SNIPERRIFLE -> noPic baseAMRShape -- <> addBullets it
-- MACHINEGUN -> noPic $ baseAMRShape <> addTinClip it
FLAMESPITTER -> flamerPic it
FLAMETHROWER -> flamerPic it
@@ -193,7 +193,7 @@ heldItemSPic ht it = case ht of
TRACTORGUN -> tractorGunPic it
LAUNCHER -> launcherPic it
LAUNCHERX _ -> launcherPic it
REMOTELAUNCHER -> launcherPic it
-- REMOTELAUNCHER -> launcherPic it
POISONSPRAYER -> flamerPic it
DRONELAUNCHER -> defSPic
SHATTERGUN -> shatterGunSPic
+14 -8
View File
@@ -41,14 +41,20 @@ basePartiallyComposedItem itm = case itm ^. itType . iyBase of
ATTACH TARGETATTACH{} -> (itm,WeaponTargetingSF, LinkTest (const Nothing) (const Nothing))
ATTACH ZOOMSCOPE -> (itm,WeaponScopeSF, LinkTest (const Nothing) (const Nothing))
ATTACH ROCKETHOMER -> (itm,AmmoModifierSF ProjectileAmmo, LinkTest (const Nothing) (const Nothing))
ATTACH REMOTESCREEN -> (itm,AmmoModifierSF ProjectileAmmo, LinkTest (const Nothing) (const Nothing))
ATTACH REMOTESCREEN -> (itm,RemoteScreenSF, LinkTest (const Nothing) (const Nothing))
_ -> (itm,UncomposableIsolateSF, LinkTest (const Nothing) (const Nothing))
--AMMOMAG _ -> ammoComposedItem' itm
ammoComposedItem :: Item -> PartiallyComposedItem
ammoComposedItem itm = fromMaybe (error "in ammoComposedItem, wrong item") $ do
atype <- itm ^? itUse . amagType
return (itm, AmmoMagSF atype, useBreakListsLinkTest [(AmmoModifierSF atype, AmmoModLink)] [])
return (itm
, AmmoMagSF atype
, useBreakListsLinkTest
[(AmmoModifierSF atype, AmmoModLink)
,(RemoteScreenSF, RemoteScreenLink)
]
[]
)
type LDTComb a b = LabelDoubleTree b a -> LabelDoubleTree b a -> Maybe (LabelDoubleTree b a)
@@ -84,10 +90,10 @@ joinItemsInList :: (a -> a -> Maybe a) -> [a] -> [a]
joinItemsInList f xs = snd $ h (xs, [])
where
h ([], zs) = ([], zs)
h ((y : ys), []) = h (ys, [y])
h ((y : ys), (z : zs)) = case f y z of
Nothing -> h (ys, (y : z : zs))
Just w -> h ((w : ys), zs)
h (y : ys, []) = h (ys, [y])
h (y : ys, z : zs) = case f y z of
Nothing -> h (ys, y : z : zs)
Just w -> h (w : ys, zs)
invLDT :: IM.IntMap Item -> [LabelDoubleTree ComposeLinkType PartiallyComposedItem]
invLDT =
@@ -135,7 +141,7 @@ invIndentIM = IM.fromAscList . zip [0 ..] . reverse . map (over _1 (^. _1))
. concatMap ldtToIndentList . invLDT
invTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ComposeLinkType Item)
invTrees = IM.unions . map (ldtToIM getindex) . map (fmap (^. _1)) . invLDT
invTrees = IM.unions . map (ldtToIM getindex . fmap (^. _1)) . invLDT
where
getindex :: Item -> Int
getindex i =
+1 -1
View File
@@ -61,7 +61,7 @@ itemFromHeldType ht = case ht of
TRACTORGUN -> tractorGun
LAUNCHER -> launcher
LAUNCHERX i -> launcherX i
REMOTELAUNCHER -> remoteLauncher
-- REMOTELAUNCHER -> remoteLauncher
POISONSPRAYER -> poisonSprayer
DRONELAUNCHER -> undefined
FORCEFIELDGUN -> forceFieldGun
+8 -8
View File
@@ -62,14 +62,14 @@ launcherX i =
angles = take i [0,2*pi/ fromIntegral i ..]
--angles = take i [1,2 ..]
remoteLauncher :: Item
remoteLauncher =
launcher
& itType . iyBase .~ HELD REMOTELAUNCHER
-- & itUse . heldUse .~ HeldFireRemoteShell --fireRemoteShell
& itUse . heldMods .~ FireRemoteShellMod
& itScope .~ RemoteScope (V2 0 0) 1
-- & itUse . heldConsumption . laAmmoType . amPjDraw .~ DrawRemoteShell
--remoteLauncher :: Item
--remoteLauncher =
-- launcher
-- & itType . iyBase .~ HELD REMOTELAUNCHER
---- & itUse . heldUse .~ HeldFireRemoteShell --fireRemoteShell
---- & itUse . heldMods .~ FireRemoteShellMod
-- & itScope .~ RemoteScope (V2 0 0) 1
---- & itUse . heldConsumption . laAmmoType . amPjDraw .~ DrawRemoteShell
basicAmPjMoves :: IM.IntMap TweakParam
basicAmPjMoves =
+1 -1
View File
@@ -96,7 +96,7 @@ heldInfo hit = case hit of
TRACTORGUN -> "An item that produces a beam of gravitons."
LAUNCHER -> "A large tube that can launch self propelled projectiles. Moving the tube after launch will cause the projectile to spin."
LAUNCHERX i -> over _head toUpper (showInt i) ++ " tubes that can launch self propelled projectiles. Tubes that do not face forward launch their projecitles at an angle."
REMOTELAUNCHER -> "A large tube that can launch self propelled projectiles. Contains a transmitter allowing for remote control of launched projectiles."
-- REMOTELAUNCHER -> "A large tube that can launch self propelled projectiles. Contains a transmitter allowing for remote control of launched projectiles."
POISONSPRAYER -> "A weapon that releases noxious gases."
DRONELAUNCHER -> "A device for launching drones."
SHATTERGUN -> "A seismic device that shatters hard items in its line of fire."
+1 -1
View File
@@ -60,7 +60,7 @@ heldBounds hit = case hit of
TRACTORGUN -> ls
LAUNCHER -> launchs
LAUNCHERX _ -> launchs
REMOTELAUNCHER -> launchs
-- REMOTELAUNCHER -> launchs
POISONSPRAYER -> fs
DRONELAUNCHER -> fs
SHATTERGUN -> launchs
+2 -2
View File
@@ -2,7 +2,7 @@
module Dodge.Item.Weapon (
module Dodge.Item.Weapon.TriggerType,
module Dodge.Item.Weapon.ExtraEffect,
module Dodge.Item.Weapon.Remote,
-- module Dodge.Item.Weapon.Remote,
module Dodge.Item.Weapon.Grenade,
module Dodge.Item.Weapon.Spawn,
module Dodge.Item.Weapon.Radar,
@@ -18,7 +18,7 @@ import Dodge.Item.Weapon.ExtraEffect
import Dodge.Item.Weapon.Grenade
import Dodge.Item.Weapon.Launcher
import Dodge.Item.Weapon.Radar
import Dodge.Item.Weapon.Remote
--import Dodge.Item.Weapon.Remote
import Dodge.Item.Weapon.Spawn
import Dodge.Item.Weapon.TriggerType
import Dodge.Item.Weapon.Utility
+3 -3
View File
@@ -4,7 +4,7 @@ module Dodge.Item.Weapon.Launcher (
import Control.Lens
import Dodge.Data.World
import Dodge.Item.Location
--import Dodge.Item.Location
import Dodge.Payload
explodeRemoteRocket ::
@@ -19,8 +19,8 @@ explodeRemoteRocket itid pjid w =
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid]
& cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
-- & itPoint . itUse . heldUse .~ HeldDoNothing
& itPoint . itUse . heldMods .~ DoNothingMod
-- & itPoint . itUse . heldMods .~ DoNothingMod
& usePayload (_prjPayload thepj) (_prjPos thepj)
where
itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid-- _itemLocations (_cWorld w) IM.! itid
-- itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid-- _itemLocations (_cWorld w) IM.! itid
thepj = w ^?! cWorld . lWorld . projectiles . ix pjid
+12 -12
View File
@@ -1,16 +1,16 @@
module Dodge.Item.Weapon.Remote (
setRemoteScope,
-- setRemoteScope,
) where
import Control.Lens
import Dodge.Data.World
import Geometry
--import Control.Lens
--import Dodge.Data.World
--import Geometry
setRemoteScope :: Int -> Point2 -> World -> World
setRemoteScope itid pos w = case w ^? cWorld . lWorld . itemLocations . ix itid of
Just (InInv cid' invid _ _ _) ->
w
& cWorld . lWorld . creatures . ix cid' . crInv . ix invid . itScope
. remotePos
.~ (pos -.- (w ^?! cWorld . lWorld . creatures . ix cid' . crPos))
_ -> w
--setRemoteScope :: Int -> Point2 -> World -> World
--setRemoteScope itid pos w = case w ^? cWorld . lWorld . itemLocations . ix itid of
-- Just (InInv cid' invid _ _ _) ->
-- w
-- & cWorld . lWorld . creatures . ix cid' . crInv . ix invid . itScope
-- . remotePos
-- .~ (pos -.- (w ^?! cWorld . lWorld . creatures . ix cid' . crPos))
-- _ -> w
+14 -14
View File
@@ -1,4 +1,4 @@
{-# LANGUAGE TupleSections #-}
--{-# LANGUAGE TupleSections #-}
{- |
Weapon effects when pulling the trigger.
@@ -29,7 +29,7 @@ module Dodge.Item.Weapon.TriggerType (
hammerCheck,
shootL,
useTimeCheck,
ammoCheckI,
-- ammoCheckI,
modClock,
blCheck,
repeatTransformed,
@@ -115,18 +115,18 @@ withThickSmokeI eff item cr w =
-- TODO create a trigger that does different things on first and continued
-- fire.
ammoCheckI :: ChainEffect
ammoCheckI eff itm cr w = fromMaybe (failsound w) $ do
atype <- itm ^? ldtValue . itUse . heldAmmoTypes . ix 0
leftitms <- itm ^? ldtLeft
mag <- lookup (AmmoInLink 0 atype) leftitms
x <- mag ^? ldtValue . itUse . amagLoadStatus . iaLoaded
guard $ x > 0
return $ eff itm cr $ w -- & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
where
failsound = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> soundStart (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing
_ -> soundContinue (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing
--ammoCheckI :: ChainEffect
--ammoCheckI eff itm cr w = fromMaybe (failsound w) $ do
-- atype <- itm ^? ldtValue . itUse . heldAmmoTypes . ix 0
-- leftitms <- itm ^? ldtLeft
-- mag <- lookup (AmmoInLink 0 atype) leftitms
-- x <- mag ^? ldtValue . itUse . amagLoadStatus . iaLoaded
-- guard $ x > 0
-- return $ eff itm cr w -- & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
-- where
-- failsound = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
-- Just 0 -> soundStart (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing
-- _ -> soundContinue (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing
itUseCharge :: Int -> Item -> Item
itUseCharge x = itUse . leftConsumption . arLoaded %~ (max 0 . subtract x)
+14 -11
View File
@@ -16,9 +16,9 @@ import LensHelp
fireShell :: Item -> Muzzle -> Item -> Creature -> World -> World
fireShell ammoitem muz it cr =
makeShell
Nothing
ammoitem
muz
it
cr
[ PJShellCollisionCheck
, PJDecTimMvVel
@@ -32,8 +32,8 @@ fireShell ammoitem muz it cr =
spinamount = _shellSpinAmount params
thrustdelay = _shellThrustDelay params
makeShell :: Item -> Muzzle -> Item -> Creature -> [ProjectileUpdate] -> World -> World
makeShell ammoitem muz it cr theupdate w = fromMaybe w $ do
makeShell :: Maybe Int -> Item -> Muzzle -> Creature -> [ProjectileUpdate] -> World -> World
makeShell mscreeninvid ammoitem muz cr theupdate w = fromMaybe w $ do
aparams <- ammoitem ^? itUse . amagParams
return $
w & cWorld . lWorld . projectiles . at i
@@ -50,27 +50,30 @@ makeShell ammoitem muz it cr theupdate w = fromMaybe w $ do
, _prjPayload = _ampPayload aparams
, _prjTimer = 350
, _prjUpdates = theupdate
, _prjMITID = Just $ _itID it
-- , _prjMITID = Just $ _itID it
}
& updatescreen
where
updatescreen = fromMaybe id $ do
screeninvid <- mscreeninvid
return $ cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix screeninvid
. itUse . atLinkedProjectile ?~ i
i = IM.newKey $ w ^. cWorld . lWorld . projectiles -- _props (_cWorld w)
dir = _crDir cr + _mzRot muz
pos = _crPos cr +.+ rotateV dir (_mzPos muz)
--am = _heldConsumption $ _itUse it
fireTrackingShell :: Item -> Muzzle -> Item -> Creature -> World -> World
fireTrackingShell ammoitem muz it cr = fromMaybe id $ do
return $
makeShell
fireTrackingShell :: Int -> Int -> Item -> Muzzle -> Item -> Creature -> World -> World
fireTrackingShell screenid screeninvid ammoitem muz it cr = makeShell
(Just screeninvid)
ammoitem
muz
it
cr
[ PJRemoteShellCollisionCheck
[ PJRemoteShellCollisionCheck screenid
, PJDecTimMvVel
, PJSpin 335 (_crID cr) spinamount
, PJTrack (350 - thrustdelay) 0 (_itID it)
, PJRemoteSetDirection (350 - thrustdelay) 0 screenid
, PJThrust (350 - thrustdelay) 0
, PJReduceSpin (1 - fromIntegral spindrag * 2 / 200)
]
+81 -40
View File
@@ -39,8 +39,8 @@ shellCollisionCheck doExplode pj w
vel = _prjVel pj
newPos = oldPos +.+ vel
remoteShellCollisionCheck :: Proj -> World -> World
remoteShellCollisionCheck = shellCollisionCheck $ \pj -> explodeRemoteRocket (fromJust (_prjMITID pj)) (_prjID pj)
remoteShellCollisionCheck :: Int -> Proj -> World -> World
remoteShellCollisionCheck screenid = shellCollisionCheck $ \pj -> explodeRemoteRocket screenid (_prjID pj)
plainShellCollisionCheck :: Proj -> World -> World
plainShellCollisionCheck = shellCollisionCheck $ \pj ->
@@ -53,7 +53,7 @@ upsProjectile pj w' = foldr (`upProjectile` pj) w' (_prjUpdates pj)
upProjectile :: ProjectileUpdate -> Proj -> World -> World
upProjectile pu pj = case pu of
PJRemoteShellCollisionCheck -> remoteShellCollisionCheck pj
PJRemoteShellCollisionCheck screenid -> remoteShellCollisionCheck screenid pj
PJShellCollisionCheck -> plainShellCollisionCheck pj
PJDecTimMvVel -> decTimMvVel pj
PJThrust st et
@@ -62,15 +62,17 @@ upProjectile pu pj = case pu of
PJSpin t cid spinamount
| ain t -> trySpinByCID cid spinamount pj
| otherwise -> id
PJTrack st et crid
| act st et -> pjTrack crid pj
PJRemoteSetDirection st et screenid
| act st et -> pjRemoteSetDirection screenid 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)
-- 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
-- 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
where
time = _prjTimer pj
@@ -78,26 +80,38 @@ upProjectile pu pj = case pu of
ain t = time == t
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
retireRemoteProj itid pjid w = w & cWorld . lWorld . projectiles %~ IM.delete pjid
& removelink
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
removelink = fromMaybe id $ do
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 =
@@ -137,19 +151,46 @@ trySpinByCID cid i pj w = w & cWorld . lWorld . projectiles . ix pjid . prjSpin
_ -> 0
spinFactor = 5 * (6 - fromIntegral i)
pjTrack :: Int -> Proj -> World -> World
pjTrack crid pj w = rotateToTarget pj w
--pjTrack :: Int -> Proj -> World -> World
--pjTrack crid pj w = rotateToTarget pj w
-- where
-- rotateToTarget _ = fromMaybe id $ do
-- tpos <- w ^? cWorld . lWorld . creatures . ix crid . crTargeting . ctPos . _Just
-- return $
-- cWorld . lWorld . projectiles . ix (_prjID pj) . prjSpin
-- .~ turnToAmount
-- 0.15
-- (_prjPos pj)
-- tpos
-- (argV $ _prjAcc pj)
-- --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
rotateToTarget _ = fromMaybe id $ do
tpos <- w ^? cWorld . lWorld . creatures . ix crid . crTargeting . ctPos . _Just
return $
cWorld . lWorld . projectiles . ix (_prjID pj) . prjSpin
.~ turnToAmount
0.15
(_prjPos pj)
tpos
(argV $ _prjAcc pj)
--itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid
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
--pjTrack :: Int -> Proj -> World -> World
--pjTrack screenid pj w = w-- rotateToTarget pj w
-- where
-- rotateToTarget _ = fromMaybe id $ do
-- tpos <- w ^? cWorld . lWorld . creatures . ix crid . crTargeting . ctPos . _Just
-- return $
-- cWorld . lWorld . projectiles . ix (_prjID pj) . prjSpin
-- .~ turnToAmount
-- 0.15
-- (_prjPos pj)
-- tpos
-- (argV $ _prjAcc pj)
-- --itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid
reduceSpinBy :: Float -> Proj -> World -> World
reduceSpinBy x pj = cWorld . lWorld . projectiles . ix (_prjID pj) . prjSpin *~ x
+3 -2
View File
@@ -10,14 +10,15 @@ import Control.Lens
selectUse :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
selectUse ittree _ w = fromMaybe w $ do
itid <- ittree ^? ldtValue . itID
pjid <- ittree ^? ldtValue . itUse . atLinkedProjectile . _Just
thepj <- w ^? cWorld . lWorld . projectiles . ix pjid
return $ w
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [PJRetireRemote 69 30 pjid] -- 69 is placeholder, should be removed
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid] -- 69 is placeholder, should be removed
& cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
-- & itPoint . itUse . heldUse .~ HeldDoNothing
-- & itPoint . itUse . heldMods .~ DoNothingMod
& usePayload (_prjPayload thepj) (_prjPos thepj)
where
-- where
-- itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid-- _itemLocations (_cWorld w) IM.! itid
+14 -10
View File
@@ -31,7 +31,7 @@ import qualified SDL
update where your avatar's view is from. -}
updateCamera :: Configuration -> World -> World
updateCamera cfig w = case w ^. wCam . camControl of
CamInGame -> updateInGameCamera cfig w
CamInGame {} -> updateInGameCamera cfig w
CamFloat -> updateFloatingCamera cfig w
updateFloatingCamera :: Configuration -> World -> World
@@ -72,16 +72,16 @@ updateInGameCamera :: Configuration -> World -> World
updateInGameCamera cfig w =
w
& updateBounds cfig
& wCam %~ moveZoomCamera cfig (w ^. input) (you w)
& wCam %~ moveZoomCamera cfig (w ^. input) (you w) w
& updateScopeZoom
& rotateCamera cfig
& over wCam (setViewDistance cfig) -- I think this should be updated after the zoom?
moveZoomCamera :: Configuration -> Input -> Creature -> Camera -> Camera
moveZoomCamera cfig theinput cr campos =
moveZoomCamera :: Configuration -> Input -> Creature -> World -> Camera -> Camera
moveZoomCamera cfig theinput cr w campos =
campos
& camCenter .~ _crPos cr +.+ offset
& camViewFrom .~ _crPos cr +.+ vfoffset
& camCenter .~ fromMaybe (_crPos cr +.+ offset ) mremotepos
& camViewFrom .~ fromMaybe (_crPos cr +.+ vfoffset) mremotepos
& camZoom .~ newzoom
& camDefaultZoom .~ newDefaultZoom
& camItemZoom .~ newItemZoom
@@ -89,22 +89,26 @@ moveZoomCamera cfig theinput cr campos =
vfoffset = fromMaybe 0 $ do
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
i <- cr ^? crManipulation . manObject . imSelectedItem
(cr ^? crInv . ix i . itScope . remotePos)
cr ^? crInv . ix i . itScope . remotePos
mremotepos = do
i <- cr ^? crManipulation . manObject . imSelectedItem
j <- cr ^? crInv . ix i . itUse . atLinkedProjectile . _Just
w ^? cWorld . lWorld . projectiles . ix j . prjPos
docamrot = rotateV (campos ^. camRot)
offset = fromMaybe noscopeoffset $ do
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
i <- cr ^? crManipulation . manObject . imSelectedItem
(fmap docamrot (cr ^? crInv . ix i . itScope . opticPos))
fmap docamrot (cr ^? crInv . ix i . itScope . opticPos)
<|> (cr ^? crInv . ix i . itScope . remotePos)
noscopeoffset = docamrot $
((newzoom - newDefaultZoom) / (newDefaultZoom * newzoom)) *.* _mousePos theinput
newzoom = fromMaybe (newDefaultZoom * newItemZoom) $ do
i <- cr ^? crManipulation . manObject . imSelectedItem
(cr ^? crInv . ix i . itScope . opticZoom)
cr ^? crInv . ix i . itScope . opticZoom
idealDefaultZoom = clipZoom wallZoom
newDefaultZoom = fromMaybe (changeZoom (campos ^. camDefaultZoom) idealDefaultZoom) $ do
i <- cr ^? crManipulation . manObject . imSelectedItem
(cr ^? crInv . ix i . itScope . opticZoom)
cr ^? crInv . ix i . itScope . opticZoom
idealItemZoom = fromMaybe 1 $ do
guard $ crIsAiming cr
i <- cr ^? crManipulation . manObject . imSelectedItem
+1 -1
View File
@@ -41,7 +41,7 @@ muzFlareAt col tranv dir w =
}
where
thestate = replicateM 4 $ state $ randomR (2,20)
((a : b : c : d : _), g) = runState thestate $ _randGen w -- randomRs (2, 20) (_randGen w)
(a : b : c : d : _, g) = runState thestate $ _randGen w -- randomRs (2, 20) (_randGen w)
flareCircleAt :: Color -> Float -> Point3 -> World -> World
flareCircleAt col alphax tranv =