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 =
|
||||
|
||||
@@ -5,8 +5,6 @@ module Dodge.Item.HeldOffset (
|
||||
twoFlatHRot,
|
||||
heldItemOffset,
|
||||
heldItemRelativeOrient,
|
||||
heldItemOrient2D,
|
||||
heldItemOrient2D',
|
||||
locOrient,
|
||||
handHandleOrient,
|
||||
) where
|
||||
@@ -32,18 +30,7 @@ transToHandle itm = (-.-.- V3 x y 0)
|
||||
where
|
||||
V2 x y = handlePos itm
|
||||
|
||||
heldItemOrient2D :: Item -> Creature -> Point2 -> Float -> (Point2, Float)
|
||||
heldItemOrient2D itm cr p a = (V2 x y, argV . Q.qToV2 $ q)
|
||||
where
|
||||
(V3 x y _, q) = heldItemRelativeOrient itm cr (p `v2z` 0, Q.axisAngle (V3 0 0 1) a)
|
||||
|
||||
heldItemOrient2D' :: OItem -> Creature -> Point2 -> Float -> (Point2, Float)
|
||||
heldItemOrient2D' (itm, _, (p1, q1)) cr p a = (V2 x y, argV . Q.qToV2 $ q)
|
||||
where
|
||||
(V3 x y _, q) = heldItemRelativeOrient itm cr (p1 + Q.rotate q1 (p `v2z` 0), q1 * Q.axisAngle (V3 0 0 1) a)
|
||||
|
||||
heldItemRelativeOrient ::
|
||||
Item -> Creature -> (Point3, Q.Quaternion Float) -> (Point3, Q.Quaternion Float)
|
||||
heldItemRelativeOrient :: Item -> Creature -> Point3Q -> Point3Q
|
||||
heldItemRelativeOrient itm cr (p, q)
|
||||
| Aiming{} <- _posture (_crStance cr) =
|
||||
(p + aimingWeaponZeroPos cr itm `v2z` shoulderHeight, Q.qID * q)
|
||||
@@ -70,7 +57,9 @@ heldItemRelativeOrient itm cr (p, q)
|
||||
sLen = _strideLength $ _crStance cr
|
||||
|
||||
handleOrient :: LocationLDT ItemLink CItem -> Point3Q
|
||||
handleOrient _ = (V3 (-3) 0 0, Q.qID)
|
||||
handleOrient loc = case loc ^. locLDT . ldtValue . _1 . itType of
|
||||
HELD FLAMETHROWER -> (V3 (-1) 0 0, Q.qID)
|
||||
_ -> (V3 (-3) 0 0, Q.qID)
|
||||
|
||||
-- note this is relative to the creature
|
||||
handOrient :: Creature -> AimStance -> Point3Q
|
||||
@@ -93,8 +82,10 @@ handOrient cr = case cr ^. crStance . posture of
|
||||
sLen = _strideLength $ _crStance cr
|
||||
|
||||
locOrient :: LocationLDT ItemLink OItem -> Creature -> Point3Q
|
||||
locOrient loc cr = handHandleOrient (fmap (\(x,y,_) -> (x,y)) loc) cr `Q.comp`
|
||||
(loc ^. locLDT . ldtValue . _3)
|
||||
locOrient loc cr =
|
||||
handHandleOrient (fmap (\(x, y, _) -> (x, y)) loc) cr
|
||||
`Q.comp` (loc ^. locLDT . ldtValue . _3)
|
||||
|
||||
-- heldItemRelativeOrient
|
||||
-- (locToTop loc ^. locLDT . ldtValue . _1)
|
||||
-- cr
|
||||
|
||||
Reference in New Issue
Block a user