Fix remote camera bug

This commit is contained in:
2021-08-27 12:45:52 +01:00
parent 3ff04576ab
commit 832232fef6
7 changed files with 70 additions and 21 deletions
+18 -14
View File
@@ -86,6 +86,7 @@ pistol = defaultGun
}
pistolPic :: Picture
pistolPic = color green $ polygon $ rectNESW 5 5 (-5) (-5)
useAmmoParams :: Item -> Creature -> World -> World
useAmmoParams it = withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b)
where
@@ -134,7 +135,10 @@ teslaGun = defaultGun
, _wpReloadState = 0
, _itUseRate = 0
, _itUseTime = 0
, _itUse = \_ -> shoot aTeslaArc
, _itUse = \_ -> aTeslaArc
, _itUseModifiers =
[ shootWithSoundForI 25 1
]
, _wpSpread = 0.001
, _wpRange = 20
, _itFloorPict = onLayer FlItLayer teslaGunPic
@@ -162,7 +166,10 @@ lasGun = defaultAutoGun
, _wpReloadState = 0
, _itUseRate = 0
, _itUseTime = 0
, _itUse = \_ -> shoot aLaser
, _itUse = \_ -> aLaser
, _itUseModifiers =
[ shootWithSoundForI 24 1
]
, _wpSpread = 0.001
, _wpRange = 20
, _itFloorPict = onLayer FlItLayer lasGunPic
@@ -246,7 +253,10 @@ remoteLauncher = defaultGun
, _wpReloadState = 0
, _itUseRate = 10
, _itUseTime = 0
, _itUse = \_ -> hammerCheck fireRemoteLauncher
, _itUse = \_ -> fireRemoteLauncher
, _itUseModifiers =
[ hammerCheckI
]
, _wpSpread = 0.02
, _wpRange = 20
, _itFloorPict = onLayer FlItLayer $ color cyan $ polygon $ rectNESW 5 5 (-5) (-5)
@@ -529,14 +539,8 @@ boosterGun = defaultGun
}
aTeslaArc :: Creature -> World -> World
aTeslaArc cr w = aTeslaArc' cr $ soundFrom (CrWeaponSound cid) 25 1 0 w
where
cid = _crID cr
aTeslaArc' :: Creature -> World -> World
aTeslaArc' cr w
aTeslaArc cr w
= teslaGunFlashAt (pos +.+ 5 *.* unitVectorAtAngle dir)
-- $ over projectiles (IM.insert i (makeTeslaArcAt i pos dir))
$ set randGen g w
& particles %~ (makeTeslaArcAt pos dir :)
where
@@ -607,7 +611,7 @@ pointToItem (OnFloor flid) = floorItems . ix flid . flIt
retireRemoteRocket :: Int -> Int -> Int -> World -> World
retireRemoteRocket itid 0 pjid w =
set (pointToItem (_itemPositions w IM.! itid) . itAttachment . _Just . scopePos) (V2 0 0)
$ set (pointToItem (_itemPositions w IM.! itid) . itUse) (\_ -> hammerCheck fireRemoteLauncher)
$ set (pointToItem (_itemPositions w IM.! itid) . itUse) (\_ -> fireRemoteLauncher)
(w & projectiles %~ IM.delete pjid)
retireRemoteRocket itid t pjid w = setScope w
& projectiles . ix pjid . pjUpdate .~ (\_ -> retireRemoteRocket itid (t-1) pjid)
@@ -761,13 +765,13 @@ fireRemoteLauncher cr w = setLocation
$ resetFire
$ resetName
$ soundOnce launcherSound
$ over projectiles remRocket w
$ over projectiles addRemRocket w
where
i = IM.newKey $ _projectiles w
cid = _crID cr
dir = _crDir cr
pos = _crPos cr +.+ rotateV dir (V2 (_crRad cr + 1) 0)
remRocket = IM.insert i $ Shell
addRemRocket = IM.insert i $ Shell
{ _pjPos = pos
, _pjStartPos = pos
, _pjVel = rotateV dir (V2 1 0)
@@ -784,7 +788,7 @@ fireRemoteLauncher cr w = setLocation
newitid = IM.newKey $ _itemPositions w
maybeitid = cr ^? crInv . ix j . itID . _Just
resetFire = set (creatures . ix cid . crInv . ix j . itUse)
$ \_ -> hammerCheck $ \_ -> explodeRemoteRocket itid i
$ \_ _ -> explodeRemoteRocket itid i
resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTEROCKET"
setLocation :: World -> World
setLocation w' = case maybeitid of