Partial refactor of bullet weapon effect chain
This commit is contained in:
@@ -38,8 +38,8 @@ baseComposedItem ibt itm = case ibt of
|
||||
heldComposedItem :: Item -> CIL
|
||||
heldComposedItem itm = (WeaponCI, map f ats, [])
|
||||
where
|
||||
ats = itm ^.. itUse . heldAmmoTypes . traverse
|
||||
f atype = (AmmoInLink atype,AmmoCI atype)
|
||||
ats = maybe [] IM.toList $ itm ^? itUse . heldAmmoTypes
|
||||
f (i,atype) = (AmmoInLink i atype,AmmoCI atype)
|
||||
|
||||
ammoComposedItem :: Item -> CIL
|
||||
ammoComposedItem itm = fromMaybe (error "in ammoComposedItem, wrong item") $ do
|
||||
|
||||
@@ -30,13 +30,13 @@ teslaGun =
|
||||
& itUse . heldAim . aimWeight .~ 6
|
||||
& itUse . heldAim . aimStance .~ TwoHandFlat
|
||||
-- & itUse . heldAim . aimMuzPos .~ 4
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 4 0) 0 0 0]
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 4 0) 0 0 0 DefaultFlareType]
|
||||
& itType . iyBase .~ HELD TESLAGUN
|
||||
|
||||
lasGun :: Item
|
||||
lasGun =
|
||||
defaultAutoBatteryGun
|
||||
& itUse . heldAmmoTypes .~ [ElectricalAmmo]
|
||||
& itUse . heldAmmoTypes .~ singleAmmo ElectricalAmmo
|
||||
& itParams
|
||||
.~ Refracting
|
||||
{ _phaseV = 1
|
||||
@@ -59,7 +59,7 @@ lasGun =
|
||||
& itUse . heldAim . aimStance .~ TwoHandUnder
|
||||
-- & itUse . heldAim . aimHandlePos .~ 5
|
||||
-- & itUse . heldAim . aimMuzPos .~ 30
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0 0]
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0 0 DefaultFlareType]
|
||||
& itType . iyBase .~ HELD LASGUN
|
||||
|
||||
lasGunTweak :: TweakParam
|
||||
@@ -84,7 +84,7 @@ tractorGun =
|
||||
& itUse . heldMods .~ TractorMod
|
||||
& itUse . heldAim . aimWeight .~ 6
|
||||
& itUse . heldAim . aimRange .~ 1
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0 0]
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0 0 DefaultFlareType]
|
||||
& itType . iyBase .~ HELD TRACTORGUN
|
||||
|
||||
tractorGunTweak :: TweakParam
|
||||
@@ -102,7 +102,7 @@ lasWide n =
|
||||
& itParams . lasColor .~ yellow
|
||||
& itParams . lasDamage .~ 2
|
||||
& itUse . heldMods .~ LasWideMod n
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 y) 0 0 0 | y <- spreadFromCenter n 1]
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 y) 0 0 0 DefaultFlareType | y <- spreadFromCenter n 1]
|
||||
|
||||
defaultBatteryGun :: Item
|
||||
defaultBatteryGun =
|
||||
@@ -137,7 +137,7 @@ dualBeam :: Item
|
||||
dualBeam =
|
||||
lasGun
|
||||
& itType . iyBase .~ HELD DUALBEAM
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0 0]
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0 0 DefaultFlareType]
|
||||
& itParams
|
||||
.~ DualBeam
|
||||
{ _phaseV = 1
|
||||
|
||||
@@ -8,6 +8,7 @@ module Dodge.Item.Held.Cane (
|
||||
miniGunX,
|
||||
) where
|
||||
|
||||
import Dodge.SoundLogic.ExternallyGeneratedSounds
|
||||
import Dodge.Base
|
||||
import Dodge.Data.Item
|
||||
import Dodge.Default
|
||||
@@ -25,6 +26,8 @@ defaultBangCane =
|
||||
, _recoil = 50
|
||||
, _torqueAfter = 0.1
|
||||
, _randomOffset = 0
|
||||
, _sidePush = 0
|
||||
, _bulGunSound = tap3S
|
||||
}
|
||||
& itDimension . dimRad .~ 8
|
||||
& itDimension . dimCenter .~ V3 5 0 0
|
||||
@@ -32,7 +35,7 @@ defaultBangCane =
|
||||
& itUse . heldMods .~ BangCaneMod
|
||||
& itUse . heldAim . aimStance .~ OneHand
|
||||
-- & itUse . heldAim . aimHandlePos .~ 5
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 0) 0 0.01 0]
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 0) 0 0.01 0 DefaultFlareType]
|
||||
|
||||
volleyGun :: Int -> Item
|
||||
volleyGun i =
|
||||
@@ -43,7 +46,7 @@ volleyGun i =
|
||||
& itUse . heldAim . aimStance .~ TwoHandFlat
|
||||
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
|
||||
& itUse . heldAim . aimMuzzles .~
|
||||
([Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 3] <*> [0..])
|
||||
([Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 3] <*> [0..] <*> repeat DefaultFlareType)
|
||||
& itUse . heldParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i
|
||||
& itType . iyBase .~ HELD (VOLLEYGUN i)
|
||||
|
||||
@@ -56,7 +59,7 @@ multiGun i =
|
||||
& itUse . heldAim . aimStance .~ TwoHandFlat
|
||||
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
|
||||
& itUse . heldAim . aimMuzzles .~
|
||||
([Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 3] <*> [0..])
|
||||
([Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 3] <*> [0..] <*> repeat DefaultFlareType)
|
||||
& itUse . heldParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i
|
||||
& itType . iyBase .~ HELD (MULTIGUN i)
|
||||
|
||||
@@ -68,7 +71,7 @@ rifle =
|
||||
& itUse . heldAim . aimWeight .~ 6
|
||||
& itUse . heldAim . aimRange .~ 1
|
||||
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 25 0) 0 0.01 0]
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 25 0) 0 0.01 0 DefaultFlareType]
|
||||
& itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE
|
||||
|
||||
repeater :: Item
|
||||
@@ -103,14 +106,14 @@ miniGunUse i =
|
||||
& heldAim . aimRange .~ 1
|
||||
& heldAim . aimStance .~ TwoHandUnder
|
||||
& heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
|
||||
& heldAmmoTypes .~ [BeltBulletAmmo]
|
||||
& heldAmmoTypes .~ singleAmmo BeltBulletAmmo
|
||||
|
||||
miniGunX :: Int -> Item
|
||||
miniGunX i =
|
||||
autoRifle
|
||||
& itUse .~ miniGunUse i
|
||||
& itUse . heldAim . aimTurnSpeed .~ 0.5
|
||||
& itUse . heldAim . aimMuzzles .~ replicate i (Muzzle (V2 30 0) 0 0.05 0)
|
||||
& itUse . heldAim . aimMuzzles .~ replicate i (Muzzle (V2 30 0) 0 0.05 0 DefaultFlareType)
|
||||
& itUse . heldParams . recoil .~ 10
|
||||
& itUse . heldParams . torqueAfter .~ 0.01
|
||||
& itUse . heldParams . randomOffset .~ 10
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.Item.Held.Cone where
|
||||
|
||||
import Dodge.SoundLogic.ExternallyGeneratedSounds
|
||||
import Control.Lens
|
||||
import Dodge.Data.Item
|
||||
import Dodge.Default.Item
|
||||
@@ -15,13 +16,15 @@ bangCone =
|
||||
& itUse . heldDelay . rateMax .~ 20
|
||||
& itUse . heldMods .~ BangConeMod
|
||||
-- & itUse . heldAim . aimHandlePos .~ 5
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 0) 0 0.5 0]
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 0) 0 0.5 0 DefaultFlareType]
|
||||
& itUse . heldParams .~ BulletShooterParams
|
||||
{ _muzVel = 0.7
|
||||
, _rifling = 0.8
|
||||
, _recoil = 150
|
||||
, _torqueAfter = 0.1
|
||||
, _randomOffset = 12
|
||||
, _sidePush = 0
|
||||
, _bulGunSound = bangEchoS
|
||||
}
|
||||
& itType . iyBase .~ HELD BANGCONE
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ launcher =
|
||||
& itUse . heldAim . aimStance .~ TwoHandOver
|
||||
-- & itUse . heldAim . aimHandlePos .~ V2 3 0
|
||||
-- & itUse . heldAim . aimMuzPos .~ 20
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 20 0) 0 0 0]
|
||||
& itUse . heldAmmoTypes .~ [ProjectileAmmo]
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 20 0) 0 0 0 DefaultFlareType]
|
||||
& itUse . heldAmmoTypes .~ singleAmmo ProjectileAmmo
|
||||
& itType . iyBase .~ HELD LAUNCHER
|
||||
& itType . iyModules . at ModLauncherHoming ?~ EMPTYMODULE
|
||||
|
||||
@@ -42,7 +42,7 @@ launcherX i =
|
||||
& itType . iyBase .~ HELD (LAUNCHERX i)
|
||||
-- & itUse . heldUse .~ HeldPJCreationX i
|
||||
& itUse . heldMods .~ LauncherXMod i
|
||||
& itUse . heldAim . aimMuzzles .~ ([Muzzle (V2 20 0) a 0 | a <- angles] <*> [0..])
|
||||
& itUse . heldAim . aimMuzzles .~ ([Muzzle (V2 20 0) a 0 | a <- angles] <*> [0..] <*> [DefaultFlareType])
|
||||
where
|
||||
angles = take i [0,2*pi/ fromIntegral i ..]
|
||||
--angles = take i [1,2 ..]
|
||||
|
||||
@@ -7,6 +7,7 @@ module Dodge.Item.Held.Rod (
|
||||
machineGun,
|
||||
) where
|
||||
|
||||
import Dodge.SoundLogic.ExternallyGeneratedSounds
|
||||
import Dodge.Data.Item
|
||||
import Dodge.Default
|
||||
--import Dodge.Item.Weapon.Bullet
|
||||
@@ -24,6 +25,8 @@ bangRod =
|
||||
, _recoil = 50
|
||||
, _torqueAfter = 0.3
|
||||
, _randomOffset = 0
|
||||
, _sidePush = 0
|
||||
, _bulGunSound = bangEchoS
|
||||
}
|
||||
& itUse . heldDelay . rateMax .~ 12
|
||||
& itUse . heldMods .~ BangRodMod
|
||||
@@ -35,7 +38,7 @@ bangRod =
|
||||
& itUse . heldAim . aimStance .~ OneHand
|
||||
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
|
||||
-- & itUse . heldAim . aimHandlePos .~ 5
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0.1 0]
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0.1 0 DefaultFlareType]
|
||||
-- & itUse . heldConsumption . laAmmoType .~ hvBulletAmmo
|
||||
|
||||
elephantGun :: Item
|
||||
|
||||
@@ -17,7 +17,7 @@ poisonSprayer :: Item
|
||||
poisonSprayer =
|
||||
flameThrower
|
||||
& itType . iyBase .~ HELD POISONSPRAYER
|
||||
& itUse . heldAmmoTypes .~ [GasAmmo]
|
||||
& itUse . heldAmmoTypes .~ singleAmmo GasAmmo
|
||||
& itUse . heldParams .~ GasSprayParams CreatePoisonGas --aGasCloud
|
||||
& itUse . heldMods .~ PoisonSprayerMod
|
||||
|
||||
@@ -88,7 +88,7 @@ flameThrower =
|
||||
& itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 5, _izMin = 1.5}
|
||||
& itUse . heldAim . aimStance .~ TwoHandUnder
|
||||
-- & itUse . heldAim . aimHandlePos .~ 0
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 18 0) 0 0 0]
|
||||
& itUse . heldAmmoTypes .~ [GasAmmo]
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 18 0) 0 0 0 DefaultFlareType]
|
||||
& itUse . heldAmmoTypes .~ singleAmmo GasAmmo
|
||||
& itType . iyBase .~ HELD FLAMETHROWER
|
||||
& itUse . heldParams .~ GasSprayParams CreateFlame --aGasCloud
|
||||
|
||||
@@ -6,6 +6,7 @@ module Dodge.Item.Held.Stick (
|
||||
smg,
|
||||
) where
|
||||
|
||||
import Dodge.SoundLogic.ExternallyGeneratedSounds
|
||||
import Dodge.Base
|
||||
import Dodge.Data.Item
|
||||
import Dodge.Default.Item
|
||||
@@ -23,6 +24,8 @@ bangStick i =
|
||||
, _recoil = 25
|
||||
, _torqueAfter = 0.18 + 0.02 * fromIntegral i
|
||||
, _randomOffset = 0
|
||||
, _sidePush = 0
|
||||
, _bulGunSound = tap3S
|
||||
}
|
||||
& itType . iyBase .~ HELD (BANGSTICK i)
|
||||
& itInvSize .~ fromIntegral i / 3
|
||||
@@ -30,7 +33,8 @@ bangStick i =
|
||||
& itDimension . dimCenter .~ V3 5 0 0
|
||||
& itUse . heldDelay . rateMax .~ 8
|
||||
& itUse . heldMods .~ BangStickMod
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 10 0) a 0.01 0 | a <- spreadAroundCenter i baseStickSpread]
|
||||
& itUse . heldAim . aimMuzzles
|
||||
.~ [Muzzle (V2 10 0) a 0.01 0 DefaultFlareType | a <- spreadAroundCenter i baseStickSpread]
|
||||
|
||||
baseStickSpread :: Float
|
||||
baseStickSpread = 0.2
|
||||
@@ -38,15 +42,16 @@ baseStickSpread = 0.2
|
||||
pistol :: Item
|
||||
pistol =
|
||||
bangStick 1
|
||||
& itUse . heldAmmoTypes .~ [BulletAmmo]
|
||||
-- & itUse . heldAmmoTypes .~ [BulletAmmo]
|
||||
& itUse . heldDelay . rateMax .~ 6
|
||||
& itUse . heldMods .~ PistolMod
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 10 0) 0 0.05 0]
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 10 0) 0 0.05 0 DefaultFlareType]
|
||||
& itUse . heldParams
|
||||
%~ ( (muzVel .~ 0.8)
|
||||
. (rifling .~ 0.8)
|
||||
. (recoil .~ 10)
|
||||
. (torqueAfter .~ 0.2)
|
||||
. (sidePush .~ 50)
|
||||
)
|
||||
& itType . iyBase .~ HELD PISTOL
|
||||
|
||||
@@ -72,6 +77,6 @@ smg =
|
||||
& itUse . heldMods .~ SmgMod --(ammoCheckI : smgAfterHamMods)
|
||||
& itType . iyBase .~ HELD SMG
|
||||
& itUse . heldAim . aimStance .~ TwoHandUnder
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 20 0) 0 0 0]
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 20 0) 0 0 0 DefaultFlareType]
|
||||
-- & itUse . heldAim . aimHandlePos .~ 2
|
||||
& itUse . heldParams . torqueAfter .~ 0.05
|
||||
|
||||
@@ -44,7 +44,7 @@ forceFieldGun =
|
||||
-- than the list below
|
||||
--[ hammerCheckI , ammoCheckI , useAmmoAmount 1]
|
||||
& itType . iyBase .~ HELD FORCEFIELDGUN
|
||||
& itUse . heldAmmoTypes .~ [ElectricalAmmo]
|
||||
& itUse . heldAmmoTypes .~ singleAmmo ElectricalAmmo
|
||||
|
||||
{- |
|
||||
Sends out pulses that display walls.
|
||||
|
||||
@@ -16,7 +16,7 @@ droneLauncher =
|
||||
& itUse . heldAim . aimWeight .~ 8
|
||||
& itUse . heldAim . aimRange .~ 0.5
|
||||
& itUse . heldAim . aimStance .~ TwoHandOver
|
||||
& itUse . heldAmmoTypes .~ [DroneAmmo]
|
||||
& itUse . heldAmmoTypes .~ singleAmmo DroneAmmo
|
||||
& itType . iyBase .~ HELD DRONELAUNCHER
|
||||
|
||||
lasDronesPic :: Item -> SPic
|
||||
|
||||
@@ -53,6 +53,7 @@ module Dodge.Item.Weapon.TriggerType (
|
||||
duplicateOffsetsV2,
|
||||
duplicateOffsetsFocus,
|
||||
hammerCheckL,
|
||||
hammerCheck,
|
||||
shootL,
|
||||
useTimeCheck,
|
||||
ammoCheckI,
|
||||
@@ -145,7 +146,7 @@ ammoCheckI :: ChainEffect
|
||||
ammoCheckI eff itm cr w = fromMaybe (failsound w) $ do
|
||||
atype <- itm ^? ldtValue . itUse . heldAmmoTypes . ix 0
|
||||
leftitms <- itm ^? ldtLeft
|
||||
mag <- lookup (AmmoInLink atype) leftitms
|
||||
mag <- lookup (AmmoInLink 0 atype) leftitms
|
||||
x <- mag ^? ldtValue . itUse . amagLoadStatus . iaLoaded
|
||||
guard $ x > 0
|
||||
return $ eff itm cr $ w -- & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
|
||||
@@ -363,7 +364,7 @@ useAmmoAmount :: Int -> ChainEffect
|
||||
useAmmoAmount amAmount eff item cr = fromMaybe id $ do
|
||||
atype <- item ^? ldtValue . itUse . heldAmmoTypes . ix 0
|
||||
leftitms <- item ^? ldtLeft
|
||||
mag <- lookup (AmmoInLink atype) leftitms
|
||||
mag <- lookup (AmmoInLink 0 atype) leftitms
|
||||
magid <- mag ^? ldtValue . itLocation . ipInvID
|
||||
-- invid <- ams ^? ix 0 . itLocation . ipInvID
|
||||
return $ eff item cr
|
||||
@@ -380,7 +381,8 @@ useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay . rateTime
|
||||
_ -> w
|
||||
where
|
||||
cid = _crID cr
|
||||
setUseTime = cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTime +~ userate
|
||||
setUseTime = cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTime
|
||||
+~ userate
|
||||
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||
userate = fromMaybe 0 $ item ^? ldtValue . itUse . heldDelay . rateMax
|
||||
|
||||
@@ -390,6 +392,14 @@ blCheck f it cr w = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
|
||||
Just 0 -> f it cr w
|
||||
_ -> w
|
||||
|
||||
hammerCheck :: ChainEffect
|
||||
hammerCheck f it cr w = case it ^? ldtValue . itUse . heldTriggerType of
|
||||
Just HammerTrigger -> case w ^? input . mouseButtons . ix SDL.ButtonLeft of
|
||||
Just 0 -> f it cr w
|
||||
_ -> w
|
||||
_ -> f it cr w
|
||||
|
||||
|
||||
{- | Applies a world effect after a hammer position check.
|
||||
Arbitrary inventory position.
|
||||
-}
|
||||
|
||||
Reference in New Issue
Block a user