Start moving bullet ammo parameters to more sensible places

This commit is contained in:
2024-06-22 00:08:42 +01:00
parent 944b40cb56
commit a3eca3a674
15 changed files with 271 additions and 248 deletions
+1 -1
View File
@@ -1 +1 @@
All good (615 modules, at 23:19:36) All good (615 modules, at 00:01:24)
+1 -1
View File
File diff suppressed because one or more lines are too long
+4 -2
View File
@@ -56,6 +56,8 @@ updateBulVel bt = case _buTrajectory bt of
where where
t = _buTimer bt t = _buTimer bt
-- should be made safe?
-- should be renamed to shootBullet or something
useAmmoParams :: Item -> Creature -> World -> World useAmmoParams :: Item -> Creature -> World -> World
useAmmoParams it cr w = useAmmoParams it cr w =
w & cWorld . lWorld . instantBullets w & cWorld . lWorld . instantBullets
@@ -63,13 +65,13 @@ useAmmoParams it cr w =
& buPos .~ _crPos cr & buPos .~ _crPos cr
& buTrajectory %~ settrajectory & buTrajectory %~ settrajectory
& buVel %~ (rotateV dir . (muzvel *.*)) & buVel %~ (rotateV dir . (muzvel *.*))
& buDrag *~ _rifling (_itParams it) & buDrag *~ _rifling (_heldParams $ _itUse it)
) )
where where
sp = _crPos cr +.+ (muzlength ^?! _head . _x) *.* unitVectorAtAngle dir sp = _crPos cr +.+ (muzlength ^?! _head . _x) *.* unitVectorAtAngle dir
dir = _crDir cr dir = _crDir cr
bultype = _laAmmoType $ _heldConsumption $ _itUse it bultype = _laAmmoType $ _heldConsumption $ _itUse it
muzvel = _muzVel $ _itParams it muzvel = _muzVel $ _heldParams $ _itUse it
muzlength = aimingMuzzlePos cr it muzlength = aimingMuzzlePos cr it
settrajectory traj = case traj of settrajectory traj = case traj of
BasicBulletTrajectory -> BasicBulletTrajectory BasicBulletTrajectory -> BasicBulletTrajectory
-6
View File
@@ -18,7 +18,6 @@ data Bullet = Bullet
{ _buDelayFraction :: Float { _buDelayFraction :: Float
, _buEffect :: BulletEffect , _buEffect :: BulletEffect
, _buSpawn :: BulletSpawn , _buSpawn :: BulletSpawn
, _buUpdateMod :: BulletUpdateMod
, _buTrajectory :: BulletTrajectory , _buTrajectory :: BulletTrajectory
, _buVel :: Point2 , _buVel :: Point2
, _buDrag :: Float , _buDrag :: Float
@@ -34,10 +33,6 @@ data EnergyBallType = IncBall | TeslaBall | ConcBall
| FlashBall | FlashBall
deriving (Show, Eq, Ord, Enum, Bounded, Read) --Generic, Flat) deriving (Show, Eq, Ord, Enum, Bounded, Read) --Generic, Flat)
data BulletUpdateMod = NoBulletUpdateMod
| ABulletUpdateMod -- hack for template splicing
deriving (Show, Eq, Ord, Enum, Bounded, Read) --Generic, Flat)
data BulletEffect data BulletEffect
= DestroyBullet = DestroyBullet
| BounceBullet | BounceBullet
@@ -69,7 +64,6 @@ data BulletTrajectoryType
makeLenses ''Bullet makeLenses ''Bullet
makeLenses ''BulletSpawn makeLenses ''BulletSpawn
deriveJSON defaultOptions ''EnergyBallType deriveJSON defaultOptions ''EnergyBallType
deriveJSON defaultOptions ''BulletUpdateMod
deriveJSON defaultOptions ''BulletEffect deriveJSON defaultOptions ''BulletEffect
deriveJSON defaultOptions ''BulletSpawn deriveJSON defaultOptions ''BulletSpawn
deriveJSON defaultOptions ''BulletTrajectory deriveJSON defaultOptions ''BulletTrajectory
-7
View File
@@ -45,13 +45,6 @@ data ItemParams
} }
| Attracting {_attractionPower :: Point2} | Attracting {_attractionPower :: Point2}
| BulletShooter | BulletShooter
{ _muzVel :: Float
, _rifling :: Float
, _bore :: Float
, _recoil :: Float
, _torqueAfter :: Float
, _randomOffset :: Float
}
| Sprayer {_sprayNozzles :: [Nozzle]} | Sprayer {_sprayNozzles :: [Nozzle]}
| AngleWalk | AngleWalk
{ _maxWalkAngle :: Float { _maxWalkAngle :: Float
+21
View File
@@ -33,6 +33,7 @@ data ItemUse
, _heldHammer :: HammerPosition , _heldHammer :: HammerPosition
, _heldAim :: AimParams , _heldAim :: AimParams
, _heldConsumption :: HeldConsumption , _heldConsumption :: HeldConsumption
, _heldParams :: HeldParams
-- , _useTargeting :: Maybe TargetType -- , _useTargeting :: Maybe TargetType
} }
| LeftUse | LeftUse
@@ -56,6 +57,16 @@ data ItemUse
{_attachParams :: AttachParams} {_attachParams :: AttachParams}
--deriving (Eq, Show, Read) --Generic, Flat) --deriving (Eq, Show, Read) --Generic, Flat)
data HeldParams
= DefaultHeldParams
| BulletShooterParams
{ _muzVel :: Float
, _rifling :: Float
, _recoil :: Float
, _torqueAfter :: Float
, _randomOffset :: Float
}
data AttachParams data AttachParams
= ScrollAttachParams {_scrollAttachParams :: ScrollAttachParams} = ScrollAttachParams {_scrollAttachParams :: ScrollAttachParams}
| AmmoAttachParams | AmmoAttachParams
@@ -65,6 +76,14 @@ data AttachParams
| TargetAttachParams | TargetAttachParams
data AmmoParams = DefaultAmmoParams data AmmoParams = DefaultAmmoParams
| BulletParams
{ _bupEffect :: BulletEffect
, _bupSpawn :: BulletSpawn
, _bupDrag :: Float
, _bupWidth :: Float
, _bupTimer :: Int
, _bupDamages :: [Damage]
}
data ScrollAttachParams data ScrollAttachParams
= ZoomScrollParams = ZoomScrollParams
@@ -126,10 +145,12 @@ makeLenses ''ItemUse
makeLenses ''AimParams makeLenses ''AimParams
makeLenses ''ItZoom makeLenses ''ItZoom
makeLenses ''Muzzle makeLenses ''Muzzle
makeLenses ''HeldParams
makeLenses ''AttachParams makeLenses ''AttachParams
makeLenses ''ScrollAttachParams makeLenses ''ScrollAttachParams
makeLenses ''AmmoParams makeLenses ''AmmoParams
deriveJSON defaultOptions ''AmmoParams deriveJSON defaultOptions ''AmmoParams
deriveJSON defaultOptions ''HeldParams
deriveJSON defaultOptions ''Muzzle deriveJSON defaultOptions ''Muzzle
deriveJSON defaultOptions ''AimStance deriveJSON defaultOptions ''AimStance
deriveJSON defaultOptions ''ScrollAttachParams deriveJSON defaultOptions ''ScrollAttachParams
+7
View File
@@ -35,4 +35,11 @@ defaultHeldUse =
, _heldHammer = HammerUp , _heldHammer = HammerUp
, _heldAim = defaultAimParams , _heldAim = defaultAimParams
, _heldConsumption = defaultLoadable , _heldConsumption = defaultLoadable
, _heldParams = BulletShooterParams
{ _muzVel = 0.8
, _rifling = 0.8
, _recoil = 10
, _torqueAfter = 0.2
, _randomOffset = 0
}
} }
+5 -7
View File
@@ -339,7 +339,7 @@ useMod hm = case hm of
, ammoCheckI , ammoCheckI
] ]
BangConeMod -> BangConeMod ->
[ withRandomItemParams coneRandItemParams [ withRandomItem coneRandItemParams
, withRandomItemUpdate coneRandItemUpdate , withRandomItemUpdate coneRandItemUpdate
, withRandomOffset , withRandomOffset
, duplicateLoadedBarrels , duplicateLoadedBarrels
@@ -497,15 +497,13 @@ coneRandItemUpdate = do
wth <- state $ randomR (1, 5) wth <- state $ randomR (1, 5)
return (itUse . heldConsumption . laAmmoType . amBullet . buWidth .~ wth) return (itUse . heldConsumption . laAmmoType . amBullet . buWidth .~ wth)
coneRandItemParams :: State StdGen (ItemParams -> ItemParams) coneRandItemParams :: State StdGen (Item -> Item)
coneRandItemParams = do coneRandItemParams = do
muzv <- state $ randomR (0.5, 1) muzv <- state $ randomR (0.5, 1)
rifl <- state $ randomR (0.3, 0.9) rifl <- state $ randomR (0.3, 0.9)
return $ \itparams -> return $ \it ->
itparams it & itUse . heldParams . muzVel .~ muzv
{ _muzVel = muzv & itUse . heldParams . rifling .~ rifl
, _rifling = rifl
}
mcShootLaser :: Item -> Machine -> World -> World mcShootLaser :: Item -> Machine -> World -> World
mcShootLaser it mc = cWorld . lWorld . lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir mcShootLaser it mc = cWorld . lWorld . lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
+7 -8
View File
@@ -18,11 +18,10 @@ import LensHelp
defaultBangCane :: Item defaultBangCane :: Item
defaultBangCane = defaultBangCane =
defaultBulletWeapon defaultBulletWeapon
& itParams & itUse . heldParams
.~ BulletShooter .~ BulletShooterParams
{ _muzVel = 0.8 { _muzVel = 0.8
, _rifling = 0.9 , _rifling = 0.9
, _bore = 2
, _recoil = 50 , _recoil = 50
, _torqueAfter = 0.1 , _torqueAfter = 0.1
, _randomOffset = 0 , _randomOffset = 0
@@ -44,7 +43,7 @@ volleyGun i =
& itUse . heldAim . aimStance .~ TwoHandFlat & itUse . heldAim . aimStance .~ TwoHandFlat
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5} & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 3] & itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 3]
& itParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i & itUse . heldParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i
& itType . iyBase .~ HELD (VOLLEYGUN i) & itType . iyBase .~ HELD (VOLLEYGUN i)
multiGun :: Int -> Item multiGun :: Int -> Item
@@ -56,7 +55,7 @@ multiGun i =
& itUse . heldAim . aimStance .~ TwoHandFlat & itUse . heldAim . aimStance .~ TwoHandFlat
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5} & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 3] & itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 3]
& itParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i & itUse . heldParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i
& itType . iyBase .~ HELD (MULTIGUN i) & itType . iyBase .~ HELD (MULTIGUN i)
rifle :: Item rifle :: Item
@@ -109,9 +108,9 @@ miniGunX i =
& itUse .~ miniGunUse i & itUse .~ miniGunUse i
& itUse . heldAim . aimTurnSpeed .~ 0.5 & itUse . heldAim . aimTurnSpeed .~ 0.5
& itUse . heldAim . aimMuzzles .~ replicate i (Muzzle (V2 30 0) 0 0.05) & itUse . heldAim . aimMuzzles .~ replicate i (Muzzle (V2 30 0) 0 0.05)
& itParams . recoil .~ 10 & itUse . heldParams . recoil .~ 10
& itParams . torqueAfter .~ 0.01 & itUse . heldParams . torqueAfter .~ 0.01
& itParams . randomOffset .~ 10 & itUse . heldParams . randomOffset .~ 10
& itInvSize .~ fromIntegral i + 1 & itInvSize .~ fromIntegral i + 1
& itDimension . dimRad .~ 20 & itDimension . dimRad .~ 20
& itDimension . dimCenter .~ V3 5 0 0 & itDimension . dimCenter .~ V3 5 0 0
+10 -10
View File
@@ -12,13 +12,6 @@ bangCone =
defaultBulletWeapon defaultBulletWeapon
{ _itParams = { _itParams =
BulletShooter BulletShooter
{ _muzVel = 0.7
, _rifling = 0.8
, _bore = 5
, _recoil = 150
, _torqueAfter = 0.1
, _randomOffset = 12
}
} }
& itDimension . dimRad .~ 8 & itDimension . dimRad .~ 8
& itDimension . dimCenter .~ V3 5 0 0 & itDimension . dimCenter .~ V3 5 0 0
@@ -26,6 +19,13 @@ bangCone =
& itUse . heldMods .~ BangConeMod & itUse . heldMods .~ BangConeMod
-- & itUse . heldAim . aimHandlePos .~ 5 -- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 0) 0 0.5] & itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 0) 0 0.5]
& itUse . heldParams .~ BulletShooterParams
{ _muzVel = 0.7
, _rifling = 0.8
, _recoil = 150
, _torqueAfter = 0.1
, _randomOffset = 12
}
& itType . iyBase .~ HELD BANGCONE & itType . iyBase .~ HELD BANGCONE
blunderbuss :: Item blunderbuss :: Item
@@ -41,6 +41,6 @@ grapeCannon :: Int -> Item
grapeCannon i = grapeCannon i =
blunderbuss blunderbuss
& itType . iyBase .~ HELD (GRAPECANNON i) & itType . iyBase .~ HELD (GRAPECANNON i)
& itParams . recoil .~ (150 + fromIntegral i * 50) & itUse . heldParams . recoil .~ (150 + fromIntegral i * 50)
& itParams . torqueAfter .~ (0.1 + 0.2 * fromIntegral i) & itUse . heldParams . torqueAfter .~ (0.1 + 0.2 * fromIntegral i)
& itParams . randomOffset .~ (12 + 4 * fromIntegral i) & itUse . heldParams . randomOffset .~ (12 + 4 * fromIntegral i)
+4 -5
View File
@@ -17,11 +17,10 @@ import LensHelp
bangRod :: Item bangRod :: Item
bangRod = bangRod =
defaultBulletWeapon defaultBulletWeapon
& itParams & itUse . heldParams
.~ BulletShooter .~ BulletShooterParams
{ _muzVel = 0.8 { _muzVel = 0.8
, _rifling = 1 , _rifling = 1
, _bore = 2
, _recoil = 50 , _recoil = 50
, _torqueAfter = 0.3 , _torqueAfter = 0.3
, _randomOffset = 0 , _randomOffset = 0
@@ -46,7 +45,7 @@ elephantGun =
& itUse . heldAim . aimStance .~ TwoHandUnder & itUse . heldAim . aimStance .~ TwoHandUnder
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0.05 & itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0.05
& itUse . heldMods .~ ElephantGunMod & itUse . heldMods .~ ElephantGunMod
& itParams . recoil .~ 50 & itUse . heldParams . recoil .~ 50
amr :: Item amr :: Item
amr = amr =
@@ -78,4 +77,4 @@ machineGun =
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5} & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldDelay .~ VariableRate{_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0} & itUse . heldDelay .~ VariableRate{_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0}
& itInvSize .~ 3 & itInvSize .~ 3
& itParams . torqueAfter .~ 0.2 -- not sure if this is necessary? & itUse . heldParams . torqueAfter .~ 0.2 -- not sure if this is necessary?
+5 -7
View File
@@ -16,11 +16,10 @@ import LensHelp
bangStick :: Int -> Item bangStick :: Int -> Item
bangStick i = bangStick i =
defaultBulletWeapon defaultBulletWeapon
& itParams & itUse . heldParams
.~ BulletShooter .~ BulletShooterParams
{ _muzVel = 0.8 { _muzVel = 0.8
, _rifling = 0.8 , _rifling = 0.8
, _bore = 2
, _recoil = 25 , _recoil = 25
, _torqueAfter = 0.18 + 0.02 * fromIntegral i , _torqueAfter = 0.18 + 0.02 * fromIntegral i
, _randomOffset = 0 , _randomOffset = 0
@@ -45,10 +44,9 @@ pistol =
& itUse . heldDelay . rateMax .~ 6 & itUse . heldDelay . rateMax .~ 6
& itUse . heldMods .~ PistolMod & itUse . heldMods .~ PistolMod
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 10 0) 0 0.05] & itUse . heldAim . aimMuzzles .~ [Muzzle (V2 10 0) 0 0.05]
& itParams & itUse . heldParams
%~ ( (muzVel .~ 0.8) %~ ( (muzVel .~ 0.8)
. (rifling .~ 0.8) . (rifling .~ 0.8)
. (bore .~ 2)
. (recoil .~ 10) . (recoil .~ 10)
. (torqueAfter .~ 0.2) . (torqueAfter .~ 0.2)
) )
@@ -68,7 +66,7 @@ machinePistol =
& itUse . heldMods .~ MachinePistolMod -- (ammoCheckI : machinePistolAfterHamMods) & itUse . heldMods .~ MachinePistolMod -- (ammoCheckI : machinePistolAfterHamMods)
& itType . iyBase .~ HELD MACHINEPISTOL & itType . iyBase .~ HELD MACHINEPISTOL
& itType . iyModules . at ModAutoMag .~ Nothing & itType . iyModules . at ModAutoMag .~ Nothing
& itParams . recoil .~ 20 & itUse . heldParams . recoil .~ 20
smg :: Item smg :: Item
smg = smg =
@@ -78,4 +76,4 @@ smg =
& itUse . heldAim . aimStance .~ TwoHandUnder & itUse . heldAim . aimStance .~ TwoHandUnder
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 20 0) 0 0] & itUse . heldAim . aimMuzzles .~ [Muzzle (V2 20 0) 0 0]
-- & itUse . heldAim . aimHandlePos .~ 2 -- & itUse . heldAim . aimHandlePos .~ 2
& itParams . torqueAfter .~ 0.05 & itUse . heldParams . torqueAfter .~ 0.05
-1
View File
@@ -21,7 +21,6 @@ defaultBullet =
{ _buDelayFraction = 1 { _buDelayFraction = 1
, _buEffect = DestroyBullet , _buEffect = DestroyBullet
, _buSpawn = BulSpark , _buSpawn = BulSpark
, _buUpdateMod = NoBulletUpdateMod
, _buTrajectory = BasicBulletTrajectory , _buTrajectory = BasicBulletTrajectory
, _buVel = V2 50 0 , _buVel = V2 50 0
, _buDrag = 1 , _buDrag = 1
+9 -3
View File
@@ -24,6 +24,7 @@ module Dodge.Item.Weapon.TriggerType (
withTorqueAfter, withTorqueAfter,
torqueSideEffect, torqueSideEffect,
withRandomItemParams, withRandomItemParams,
withRandomItem,
withRandomItemUpdate, withRandomItemUpdate,
withSoundStart, withSoundStart,
withSoundItemChoiceStart, withSoundItemChoiceStart,
@@ -297,7 +298,7 @@ withRecoil :: ChainEffect
withRecoil eff it cr = eff it cr . over (cWorld . lWorld . creatures . ix cid) pushback withRecoil eff it cr = eff it cr . over (cWorld . lWorld . creatures . ix cid) pushback
where where
cid = _crID cr cid = _crID cr
recoilAmount = fromMaybe 0 $ it ^? itParams . recoil recoilAmount = fromMaybe 0 $ it ^? itUse . heldParams . recoil
pushback = over crPos (+.+ rotateV (_crDir cr) (V2 ((- recoilAmount) / _crMass cr) 0)) pushback = over crPos (+.+ rotateV (_crDir cr) (V2 ((- recoilAmount) / _crMass cr) 0))
{- | Pushes a creature sideways by a random amount. {- | Pushes a creature sideways by a random amount.
@@ -517,6 +518,11 @@ withRandomItemParams rip eff it cr w = eff (it & itParams %~ f) cr $ w & randGen
where where
(f, g) = runState rip (_randGen w) (f, g) = runState rip (_randGen w)
withRandomItem :: State StdGen (Item -> Item) -> ChainEffect
withRandomItem rip eff it cr w = eff (f it) cr $ w & randGen .~ g
where
(f, g) = runState rip (_randGen w)
withPositionOffset :: withPositionOffset ::
(Item -> Creature -> World -> (Point2, Float)) -> (Item -> Creature -> World -> (Point2, Float)) ->
ChainEffect ChainEffect
@@ -548,7 +554,7 @@ withRandomOffset f item cr w = f item (cr & crPos %~ (+.+ offV)) $ set randGen g
where where
(offsetVal, g) = randomR (- offsetAmount, offsetAmount) $ _randGen w (offsetVal, g) = randomR (- offsetAmount, offsetAmount) $ _randGen w
offV = rotateV (_crDir cr) (V2 0 offsetVal) offV = rotateV (_crDir cr) (V2 0 offsetVal)
offsetAmount = fromMaybe 0 $ item ^? itParams . randomOffset offsetAmount = fromMaybe 0 $ item ^? itUse . heldParams . randomOffset
-- | Rotates a creature -- | Rotates a creature
torqueBefore :: torqueBefore ::
@@ -615,7 +621,7 @@ withTorqueAfter feff item cr w
where where
cid = _crID cr cid = _crID cr
(rot, g) = randomR (- torque, torque) $ _randGen w (rot, g) = randomR (- torque, torque) $ _randGen w
torque = fromMaybe 0 $ item ^? itParams . torqueAfter torque = fromMaybe 0 $ item ^? itUse . heldParams . torqueAfter
rotateScope = fromMaybe id $ do rotateScope = fromMaybe id $ do
i <- yourScopeInvID w i <- yourScopeInvID w
return $ cWorld . lWorld . creatures . ix cid . crInv . ix i . itUse . attachParams . scrollAttachParams . opticPos %~ rotateV rot return $ cWorld . lWorld . creatures . ix cid . crInv . ix i . itUse . attachParams . scrollAttachParams . opticPos %~ rotateV rot
+197 -190
View File
File diff suppressed because it is too large Load Diff