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