Remove external duplicated ItemLinks
This commit is contained in:
@@ -13,24 +13,24 @@ import qualified Linear.Quaternion as Q
|
||||
|
||||
data ItemLink
|
||||
= TriggerLink
|
||||
| AmmoInLink Int AmmoType
|
||||
| AmmoModLink
|
||||
| AmmoTargetingLink
|
||||
| AmmoPayloadLink
|
||||
| AmmoEffectLink
|
||||
| WeaponScopeLink
|
||||
| WeaponTargetingLink
|
||||
| JoystickLink
|
||||
| RemoteScreenLink
|
||||
| RemoteDetonatorLink
|
||||
| SmokeReducerLink
|
||||
-- | AugmentedHUDLink
|
||||
| FunctionChangeLink
|
||||
| MakeAutoLink
|
||||
| ProjectileStabiliserLink
|
||||
| UnderBarrelSlotLink
|
||||
| UnderBarrelPlatformLink
|
||||
| GrenadeHitEffectLink
|
||||
-- | AmmoInLink Int AmmoType
|
||||
-- | AmmoModLink
|
||||
-- | AmmoTargetingLink
|
||||
-- | AmmoPayloadLink
|
||||
-- | AmmoEffectLink
|
||||
-- | WeaponScopeLink
|
||||
-- | WeaponTargetingLink
|
||||
-- | JoystickLink
|
||||
-- | RemoteScreenLink
|
||||
-- | RemoteDetonatorLink
|
||||
-- | SmokeReducerLink
|
||||
---- | AugmentedHUDLink
|
||||
-- | FunctionChangeLink
|
||||
-- | MakeAutoLink
|
||||
-- | ProjectileStabiliserLink
|
||||
-- | UnderBarrelSlotLink
|
||||
-- | UnderBarrelPlatformLink
|
||||
-- | GrenadeHitEffectLink
|
||||
| SFLink {_sfLink :: ItemStructuralFunction}
|
||||
deriving (Eq, Ord, Show, Read)
|
||||
|
||||
|
||||
+83
-30
@@ -775,9 +775,9 @@ useLoadedAmmo loc cr (_, w) (Just (mz, x, magtree)) = (,) True $
|
||||
MuzzleGLauncher ->
|
||||
createProjectile
|
||||
(itmtree ^. ldtValue . _3)
|
||||
(Grenade (getGrenadeHitEffect $ fmap (^. _1) itmtree))
|
||||
(Grenade (getGrenadeHitEffect $ itmtree))
|
||||
magtree
|
||||
(getPJStabiliser $ fmap (^. _1) itmtree)
|
||||
(getPJStabiliser $ itmtree)
|
||||
mz
|
||||
cr
|
||||
w
|
||||
@@ -925,10 +925,11 @@ removeAmmoFromMag x mid cr = fromMaybe id $ do
|
||||
. _Just
|
||||
-~ x
|
||||
|
||||
getBulletType :: LDTree ItemLink Item -> Maybe Bullet
|
||||
getBulletType :: LDTree ItemLink OItem -> Maybe Bullet
|
||||
getBulletType magtree =
|
||||
--magtree ^? ldtValue . itConsumables . magParams . ampBullet
|
||||
(magtree ^? ldtValue >>= magAmmoParams >>= (^? ampBullet))
|
||||
-- (magAmmoParams (magtree ^. ldtValue . _1) ^? _Just . ampBullet)
|
||||
(magtree ^? ldtValue . _1 . to magAmmoParams . _Just . ampBullet)
|
||||
-- <&> buTrajectory .~ btraj
|
||||
<&> buPayload .~ bpayload
|
||||
<&> buEffect .~ beffect
|
||||
@@ -940,11 +941,19 @@ getBulletType magtree =
|
||||
-- bt <- attree ^? ldtValue . itUse . ubMod . bmTrajectory
|
||||
-- return $ getBulletTrajectory mz (itmtree ^. ldtValue) bt tp cr w
|
||||
bpayload = fromMaybe (BulPlain 100) $ do
|
||||
attree <- lookup AmmoPayloadLink (magtree ^. ldtLeft)
|
||||
attree ^? ldtValue . itUse . ubMod . bmPayload
|
||||
attree <- find ispayload (magtree ^. ldtLeft)
|
||||
attree ^? _2 . ldtValue . _1 . itUse . ubMod . bmPayload
|
||||
ispayload :: (ItemLink,LDTree ItemLink OItem) -> Bool
|
||||
ispayload y = case y ^. _2 . ldtValue . _2 of
|
||||
AmmoPayloadSF {} -> True
|
||||
_ -> False
|
||||
beffect = fromMaybe DestroyBullet $ do
|
||||
attree <- lookup AmmoEffectLink (magtree ^. ldtLeft)
|
||||
attree ^? ldtValue . itUse . ubMod . bmEffect
|
||||
attree <- find isammoeffect (magtree ^. ldtLeft)
|
||||
attree ^? _2 . ldtValue . _1 . itUse . ubMod . bmEffect
|
||||
isammoeffect :: (ItemLink,LDTree ItemLink OItem) -> Bool
|
||||
isammoeffect y = case y ^. _2 . ldtValue . _2 of
|
||||
AmmoEffectSF {} -> True
|
||||
_ -> False
|
||||
|
||||
magAmmoParams :: Item -> Maybe AmmoParams
|
||||
magAmmoParams itm = case itm ^. itType of
|
||||
@@ -985,7 +994,7 @@ shootBullets ::
|
||||
World ->
|
||||
World
|
||||
shootBullets loc cr (mz, x, magtree) w = fromMaybe w $ do
|
||||
thebullet <- getBulletType $ fmap (^. _1) magtree
|
||||
thebullet <- getBulletType $ magtree
|
||||
return $ foldl' (&) w (replicate x (shootBullet thebullet loc cr mz))
|
||||
|
||||
shootBullet :: Bullet -> LocationLDT ItemLink OItem -> Creature -> Muzzle -> World -> World
|
||||
@@ -1240,19 +1249,36 @@ shootTeslaArc loc cr mz w =
|
||||
0 -> 0
|
||||
i -> fst . randomR (- i, i) $ _randGen w
|
||||
|
||||
determineProjectileTracking :: LDTree ItemLink Item -> LDTree ItemLink Item -> RocketHoming
|
||||
determineProjectileTracking :: LDTree ItemLink OItem
|
||||
-> LDTree ItemLink OItem -> RocketHoming
|
||||
determineProjectileTracking magtree itmtree =
|
||||
fromMaybe NoHoming $
|
||||
finddronecontrols <|> findexternaltracking
|
||||
where
|
||||
finddronecontrols = do
|
||||
screen <- lookup RemoteScreenLink (magtree ^. ldtLeft)
|
||||
_ <- lookup JoystickLink (screen ^. ldtLeft)
|
||||
return $ HomeUsingRemoteScreen (screen ^. ldtValue . itID)
|
||||
screen <- find isremscreen (magtree ^. ldtLeft)
|
||||
_ <- find isjoystick (screen ^. _2 . ldtLeft)
|
||||
return $ HomeUsingRemoteScreen (screen ^. _2 . ldtValue . _1 . itID)
|
||||
findexternaltracking = do
|
||||
_ <- lookup AmmoTargetingLink (magtree ^. ldtLeft)
|
||||
targetingtree <- lookup WeaponTargetingLink (itmtree ^. ldtRight)
|
||||
return $ HomeUsingTargeting (targetingtree ^. ldtValue . itID)
|
||||
_ <- find isammotargeting (magtree ^. ldtLeft)
|
||||
targetingtree <- find isweapontargeting (itmtree ^. ldtRight)
|
||||
return $ HomeUsingTargeting (targetingtree ^. _2 . ldtValue . _1 . itID)
|
||||
isremscreen :: (ItemLink,LDTree ItemLink OItem) -> Bool
|
||||
isremscreen x = case x ^. _2 . ldtValue . _2 of
|
||||
RemoteScreenSF {} -> True
|
||||
_ -> False
|
||||
isjoystick :: (ItemLink,LDTree ItemLink OItem) -> Bool
|
||||
isjoystick x = case x ^. _2 . ldtValue . _2 of
|
||||
JoystickSF {} -> True
|
||||
_ -> False
|
||||
isammotargeting :: (ItemLink,LDTree ItemLink OItem) -> Bool
|
||||
isammotargeting x = case x ^. _2 . ldtValue . _2 of
|
||||
AmmoTargetingSF {} -> True
|
||||
_ -> False
|
||||
isweapontargeting :: (ItemLink,LDTree ItemLink OItem) -> Bool
|
||||
isweapontargeting x = case x ^. _2 . ldtValue . _2 of
|
||||
WeaponTargetingSF {} -> True
|
||||
_ -> False
|
||||
|
||||
createProjectileR ::
|
||||
LocationLDT ItemLink OItem ->
|
||||
@@ -1265,31 +1291,45 @@ createProjectileR loc magtree =
|
||||
createProjectile
|
||||
(loc ^. locLDT . ldtValue . _3)
|
||||
( Rocket
|
||||
(determineProjectileTracking (fmap (^. _1) magtree) $ fmap (^. _1) itmtree)
|
||||
(determineProjectileTracking ( magtree) $ itmtree)
|
||||
smoke
|
||||
)
|
||||
magtree
|
||||
(getPJStabiliser $ fmap (^. _1) itmtree)
|
||||
(getPJStabiliser itmtree)
|
||||
where
|
||||
itmtree = loc ^. locLDT
|
||||
smoke
|
||||
| isJust $ lookup SmokeReducerLink (magtree ^. ldtLeft) = Just ReducedRocketSmoke
|
||||
| isJust $ find issmokereducer (magtree ^. ldtLeft) = Just ReducedRocketSmoke
|
||||
| otherwise = Nothing
|
||||
issmokereducer :: (ItemLink,LDTree ItemLink OItem) -> Bool
|
||||
issmokereducer y = case y ^. _2 . ldtValue . _2 of
|
||||
SmokeReducerSF {} -> True
|
||||
_ -> False
|
||||
|
||||
getPJStabiliser :: LDTree ItemLink Item -> Maybe PJStabiliser
|
||||
getPJStabiliser ldt = case lookup ProjectileStabiliserLink (ldt ^. ldtRight) of
|
||||
Just ldt' -> case ldt' ^? ldtValue . itType . ibtAttach of
|
||||
getPJStabiliser :: LDTree ItemLink OItem -> Maybe PJStabiliser
|
||||
getPJStabiliser ldt = case find isprojstab (ldt ^. ldtRight) of
|
||||
Just ldt' -> case ldt' ^? _2 . ldtValue . _1 . itType . ibtAttach of
|
||||
Just GIMBAL -> Just StabOrthReduce
|
||||
Just GYROSCOPE -> Just StabSpinIncrease
|
||||
_ -> Nothing
|
||||
_ -> Nothing
|
||||
where
|
||||
isprojstab :: (ItemLink,LDTree ItemLink OItem) -> Bool
|
||||
isprojstab y = case y ^. _2 . ldtValue . _2 of
|
||||
ProjectileStabiliserSF {} -> True
|
||||
_ -> False
|
||||
|
||||
getGrenadeHitEffect :: LDTree ItemLink Item -> GrenadeHitEffect
|
||||
getGrenadeHitEffect t = case lookup GrenadeHitEffectLink (t ^. ldtRight) of
|
||||
Just ldt' -> case ldt' ^? ldtValue . itType of
|
||||
getGrenadeHitEffect :: LDTree ItemLink OItem -> GrenadeHitEffect
|
||||
getGrenadeHitEffect t = case find isghiteff (t ^. ldtRight) of
|
||||
Just ldt' -> case ldt' ^? _2 . ldtValue . _1 . itType of
|
||||
Just STICKYMOD -> GStick
|
||||
_ -> GBounce 2
|
||||
_ -> GBounce 2
|
||||
where
|
||||
isghiteff :: (ItemLink,LDTree ItemLink OItem) -> Bool
|
||||
isghiteff y = case y ^. _2 . ldtValue . _2 of
|
||||
GrenadeHitEffectSF {} -> True
|
||||
_ -> False
|
||||
|
||||
createProjectile ::
|
||||
(Point3, Q.Quaternion Float) ->
|
||||
@@ -1304,19 +1344,32 @@ createProjectile x pjtype magtree stab muz cr = fromMaybe failsound $ do
|
||||
magid <- magtree ^? ldtValue . _1 . itLocation . ilInvID
|
||||
ammoitem <- cr ^? crInv . ix magid
|
||||
let rdetonate =
|
||||
(^. ldtValue . _1 . itID)
|
||||
<$> lookup RemoteDetonatorLink (magtree ^. ldtLeft)
|
||||
(^. _2 . ldtValue . _1 . itID)
|
||||
<$> find isrdet (magtree ^. ldtLeft)
|
||||
rscreen =
|
||||
(^. ldtValue . _1 . itID)
|
||||
<$> lookup RemoteScreenLink (magtree ^. ldtLeft)
|
||||
(^. _2 . ldtValue . _1 . itID)
|
||||
<$> find isrscreen (magtree ^. ldtLeft)
|
||||
aparams <-
|
||||
((magtree ^? ldtLeft) >>= lookup AmmoPayloadLink >>= (^? ldtValue . _1 . itType . ibtAttach . shellPayload))
|
||||
((magtree ^? ldtLeft) >>= find isampay >>= (^? _2 . ldtValue . _1 . itType . ibtAttach . shellPayload))
|
||||
-- <|> ammoitem ^? itConsumables . magParams . ampPayload
|
||||
<|> magAmmoParams ammoitem ^? _Just . ampPayload
|
||||
return $
|
||||
createShell x rdetonate rscreen stab pjtype aparams muz cr
|
||||
. startthesound
|
||||
where
|
||||
isrdet :: (ItemLink,LDTree ItemLink OItem) -> Bool
|
||||
isrdet y = case y ^. _2 . ldtValue . _2 of
|
||||
RemoteDetonatorSF {} -> True
|
||||
_ -> False
|
||||
isrscreen :: (ItemLink,LDTree ItemLink OItem) -> Bool
|
||||
isrscreen y = case y ^. _2 . ldtValue . _2 of
|
||||
RemoteScreenSF {} -> True
|
||||
_ -> False
|
||||
isampay :: (ItemLink,LDTree ItemLink OItem) -> Bool
|
||||
isampay y = case y ^. _2 . ldtValue . _2 of
|
||||
AmmoPayloadSF {} -> True
|
||||
_ -> False
|
||||
|
||||
-- the sound should be moved to the projectile firing
|
||||
startthesound =
|
||||
soundMultiFrom
|
||||
|
||||
Reference in New Issue
Block a user