Cleanup
This commit is contained in:
+54
-30
@@ -75,7 +75,7 @@ hammerCheck f pt loc cr w = case itemTriggerType loc of
|
||||
& cWorld . lWorld . creatures . ix cid . crInv . ix invid . itParams . wTime +~ 1
|
||||
WarmUpNoDelay{} -> f loc cr w & setwarming
|
||||
WarmUpCoolDown ws _ _
|
||||
-- UNSAFE:
|
||||
-- UNSAFE:
|
||||
| _wTime (_itParams $ it) < ws ->
|
||||
w & setwarming
|
||||
& soundContinue (CrWeaponSound cid 0) (_crPos cr) (warmupSound $ it ^. itType) (Just 2)
|
||||
@@ -208,7 +208,7 @@ heldItemMuzzles = \case
|
||||
& ix 0 . mzInaccuracy .~ 0
|
||||
BANGCONE -> [Muzzle (V2 15 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15) 12]
|
||||
BLUNDERBUSS -> [Muzzle (V2 30 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15) 12]
|
||||
GRAPECANNON i -> [Muzzle (V2 30 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15) (12 + 4*fromIntegral i)]
|
||||
GRAPECANNON i -> [Muzzle (V2 30 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15) (12 + 4 * fromIntegral i)]
|
||||
TORCH -> dbwMuzzles & ix 0 . mzPos .~ V2 10 0
|
||||
VOLLEYGUN{} -> error "should get volleygun muzzles earlier"
|
||||
FLAMETHROWER -> flameMuzzles
|
||||
@@ -498,7 +498,7 @@ applyRecoil loc cr =
|
||||
+~ rotateV (_crDir cr + Q.qToAng q) (V2 ((- recoilAmount itm) / crMass (_crType cr)) 0)
|
||||
where
|
||||
itm = loc ^. locLDT . ldtValue . _1
|
||||
(_,q) = locOrient loc cr
|
||||
(_, q) = locOrient loc cr
|
||||
|
||||
recoilAmount :: Item -> Float
|
||||
recoilAmount itm
|
||||
@@ -703,8 +703,9 @@ makeMuzzleFlare mz loc cr = case mz ^. mzFlareType of
|
||||
)
|
||||
TeslaGunFlare -> cWorld . lWorld . lights .:~ LSParam (pos `v2z` 10) 100 (V3 0 0 1)
|
||||
where
|
||||
(V3 x y _,q) = locOrient loc cr
|
||||
`Q.comp` (_mzPos mz `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`Q.comp` (_mzPos mz `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
pos = _crPos cr + rotateV (_crDir cr) (V2 x y)
|
||||
dir = _crDir cr + Q.qToAng q
|
||||
oddcheck f w
|
||||
@@ -767,7 +768,7 @@ useLoadedAmmo loc cr (_, w) (Just (mz, x, magtree)) = (,) True $
|
||||
removeAmmoFromMag x mid cr . makeMuzzleFlare mz loc cr $ case _mzEffect mz of
|
||||
MuzzleShootBullet -> shootBullets loc cr (mz, x, magtree) w
|
||||
MuzzleLaser -> creatureShootLaser loc cr mz w
|
||||
MuzzleTesla -> shootTeslaArc itm cr mz w
|
||||
MuzzleTesla -> shootTeslaArc loc cr mz w
|
||||
MuzzleTractor -> shootTractorBeam cr w
|
||||
MuzzleRLauncher -> createProjectileR loc magtree mz cr w
|
||||
MuzzleGLauncher ->
|
||||
@@ -779,7 +780,7 @@ useLoadedAmmo loc cr (_, w) (Just (mz, x, magtree)) = (,) True $
|
||||
mz
|
||||
cr
|
||||
w
|
||||
MuzzleNozzle{} -> useGasParams mid mz (itm ^. _1) cr $ walkNozzle mz (itm ^. _1) cr w
|
||||
MuzzleNozzle{} -> useGasParams mid mz loc cr $ walkNozzle mz (itm ^. _1) cr w
|
||||
MuzzleShatter -> shootShatter (itm ^. _1) cr w
|
||||
MuzzleDetector ->
|
||||
itemDetectorEffect
|
||||
@@ -878,13 +879,17 @@ creatureShootLaser loc cr mz w =
|
||||
(getLaserColor loc)
|
||||
where
|
||||
itmtree = loc ^. locLDT
|
||||
istree = fmap (\(x, _, _) -> x) itmtree
|
||||
itm = itmtree ^. ldtValue
|
||||
(moff, mrot) = heldItemOrient2D' itm cr (_mzPos mz) (_mzRot mz)
|
||||
pos = _crPos cr + rotateV (_crDir cr) moff
|
||||
dir = _crDir cr + mrot + a
|
||||
istree = fmap (\(i, _, _) -> i) itmtree
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
pos = _crPos cr + rotateV (_crDir cr) (V2 x y)
|
||||
dir = _crDir cr + Q.qToAng q + a
|
||||
(a, g) = randomR (- inacc, inacc) $ _randGen w
|
||||
inacc = _mzInaccuracy mz
|
||||
offset = case mz ^. mzRandomOffset of
|
||||
0 -> 0
|
||||
i -> fst . randomR (- i, i) $ _randGen w
|
||||
|
||||
shootLaser ::
|
||||
SoundOrigin ->
|
||||
@@ -985,8 +990,9 @@ shootBullets loc cr (mz, x, magtree) w = fromMaybe w $ do
|
||||
shootBullet :: Bullet -> LocationLDT ItemLink OItem -> Creature -> Muzzle -> World -> World
|
||||
shootBullet bu loc cr mz w = makeBullet bu itm bulpos dir . (randGen .~ g) $ w
|
||||
where
|
||||
(V3 x y _,q) = locOrient loc cr
|
||||
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
itm = loc ^. locLDT . ldtValue . _1
|
||||
bulpos = _crPos cr + rotateV (_crDir cr) (V2 x y)
|
||||
(a, g) = randomR (- inacc, inacc) $ _randGen w
|
||||
@@ -1108,26 +1114,37 @@ mcUseHeld hit = case hit of
|
||||
LASER -> mcShootLaser
|
||||
_ -> mcShootAuto
|
||||
|
||||
useGasParams :: Maybe Int -> Muzzle -> Item -> Creature -> World -> World
|
||||
useGasParams mmagid mz itm cr w =
|
||||
useGasParams ::
|
||||
Maybe Int ->
|
||||
Muzzle ->
|
||||
LocationLDT ItemLink OItem ->
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
useGasParams mmagid mz loc cr w =
|
||||
w
|
||||
& createGas gastype pressure pos dir cr
|
||||
& randGen .~ g'
|
||||
where
|
||||
itm = loc ^. locLDT . ldtValue . _1
|
||||
(pressure, g) = doGenFloat (_nzPressure $ _mzEffect mz) (_randGen w)
|
||||
gastype = fromMaybe (error "cannot find gas ammo") $ do
|
||||
magid <- mmagid
|
||||
hit <- itm ^? itType . ibtHeld
|
||||
--fueltype <- cr ^? crInv . ix magid . itConsumables . magParams . ampCreateGas
|
||||
fueltype <- cr ^? crInv . ix magid >>= magAmmoParams >>= (^? ampCreateGas)
|
||||
gasType hit fueltype
|
||||
--pos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm)
|
||||
(moff, mrot) = heldItemOrient2D itm cr (_mzPos mz) (_mzRot mz)
|
||||
pos = _crPos cr + rotateV (_crDir cr) moff
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
-- (moff, mrot) = heldItemOrient2D itm cr (_mzPos mz) (_mzRot mz)
|
||||
pos = _crPos cr + rotateV (_crDir cr) (V2 x y)
|
||||
(a, g') = randomR (- inacc, inacc) g
|
||||
inacc = _mzInaccuracy mz
|
||||
--dir = _crDir cr + mrot + a + _nzCurrentWalkAngle (_mzEffect mz)
|
||||
dir = _crDir cr + mrot + a + _nzAngle (_itParams itm)
|
||||
offset = case mz ^. mzRandomOffset of
|
||||
0 -> 0
|
||||
i -> fst . randomR (- i, i) $ _randGen w
|
||||
-- dir = _crDir cr + mrot + a + _nzAngle (_itParams itm)
|
||||
dir = _crDir cr + Q.qToAng q + a + _nzAngle (_itParams itm)
|
||||
|
||||
gasType :: HeldItemType -> GasFuel -> Maybe GasCreate
|
||||
gasType hit _ = case hit of
|
||||
@@ -1203,17 +1220,24 @@ mcShootAuto itm mc w
|
||||
dir = mc ^?! mcType . _McTurret . tuDir
|
||||
|
||||
-- | assumes that the item is held
|
||||
shootTeslaArc :: OItem -> Creature -> Muzzle -> World -> World
|
||||
shootTeslaArc itm cr mz w =
|
||||
w' & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itParams .~ ip
|
||||
shootTeslaArc :: LocationLDT ItemLink OItem -> Creature -> Muzzle -> World -> World
|
||||
shootTeslaArc loc cr mz w =
|
||||
w' & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itParams .~ ip
|
||||
& soundContinue (CrWeaponSound (_crID cr) 0) pos elecCrackleS (Just 2)
|
||||
where
|
||||
-- use items item location instead
|
||||
itRef = cr ^?! crManipulation . manObject . imRootSelectedItem -- unsafe!! TODO change
|
||||
(w', ip) = makeTeslaArc (_itParams (itm ^. _1)) pos dir w
|
||||
(moff, mrot) = heldItemOrient2D' itm cr (_mzPos mz) (_mzRot mz)
|
||||
pos = _crPos cr + rotateV (_crDir cr) moff
|
||||
dir = _crDir cr + mrot
|
||||
-- itRef = cr ^?! crManipulation . manObject . imRootSelectedItem -- unsafe!! TODO change
|
||||
itm = loc ^. locLDT . ldtValue . _1
|
||||
invid = itm ^?! itLocation . ilInvID
|
||||
(w', ip) = makeTeslaArc (itm ^. itParams) pos dir w
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
pos = _crPos cr + rotateV (_crDir cr) (V2 x y)
|
||||
dir = _crDir cr + Q.qToAng q
|
||||
offset = case mz ^. mzRandomOffset of
|
||||
0 -> 0
|
||||
i -> fst . randomR (- i, i) $ _randGen w
|
||||
|
||||
determineProjectileTracking :: LDTree ItemLink Item -> LDTree ItemLink Item -> RocketHoming
|
||||
determineProjectileTracking magtree itmtree =
|
||||
|
||||
Reference in New Issue
Block a user