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
t = _buTimer bt
-- should be made safe?
-- should be renamed to shootBullet or something
useAmmoParams :: Item -> Creature -> World -> World
useAmmoParams it cr w =
w & cWorld . lWorld . instantBullets
@@ -63,13 +65,13 @@ useAmmoParams it cr w =
& buPos .~ _crPos cr
& buTrajectory %~ settrajectory
& buVel %~ (rotateV dir . (muzvel *.*))
& buDrag *~ _rifling (_itParams it)
& buDrag *~ _rifling (_heldParams $ _itUse it)
)
where
sp = _crPos cr +.+ (muzlength ^?! _head . _x) *.* unitVectorAtAngle dir
dir = _crDir cr
bultype = _laAmmoType $ _heldConsumption $ _itUse it
muzvel = _muzVel $ _itParams it
muzvel = _muzVel $ _heldParams $ _itUse it
muzlength = aimingMuzzlePos cr it
settrajectory traj = case traj of
BasicBulletTrajectory -> BasicBulletTrajectory
-6
View File
@@ -18,7 +18,6 @@ data Bullet = Bullet
{ _buDelayFraction :: Float
, _buEffect :: BulletEffect
, _buSpawn :: BulletSpawn
, _buUpdateMod :: BulletUpdateMod
, _buTrajectory :: BulletTrajectory
, _buVel :: Point2
, _buDrag :: Float
@@ -34,10 +33,6 @@ data EnergyBallType = IncBall | TeslaBall | ConcBall
| FlashBall
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
= DestroyBullet
| BounceBullet
@@ -69,7 +64,6 @@ data BulletTrajectoryType
makeLenses ''Bullet
makeLenses ''BulletSpawn
deriveJSON defaultOptions ''EnergyBallType
deriveJSON defaultOptions ''BulletUpdateMod
deriveJSON defaultOptions ''BulletEffect
deriveJSON defaultOptions ''BulletSpawn
deriveJSON defaultOptions ''BulletTrajectory
-7
View File
@@ -45,13 +45,6 @@ data ItemParams
}
| Attracting {_attractionPower :: Point2}
| BulletShooter
{ _muzVel :: Float
, _rifling :: Float
, _bore :: Float
, _recoil :: Float
, _torqueAfter :: Float
, _randomOffset :: Float
}
| Sprayer {_sprayNozzles :: [Nozzle]}
| AngleWalk
{ _maxWalkAngle :: Float
+21
View File
@@ -33,6 +33,7 @@ data ItemUse
, _heldHammer :: HammerPosition
, _heldAim :: AimParams
, _heldConsumption :: HeldConsumption
, _heldParams :: HeldParams
-- , _useTargeting :: Maybe TargetType
}
| LeftUse
@@ -56,6 +57,16 @@ data ItemUse
{_attachParams :: AttachParams}
--deriving (Eq, Show, Read) --Generic, Flat)
data HeldParams
= DefaultHeldParams
| BulletShooterParams
{ _muzVel :: Float
, _rifling :: Float
, _recoil :: Float
, _torqueAfter :: Float
, _randomOffset :: Float
}
data AttachParams
= ScrollAttachParams {_scrollAttachParams :: ScrollAttachParams}
| AmmoAttachParams
@@ -65,6 +76,14 @@ data AttachParams
| TargetAttachParams
data AmmoParams = DefaultAmmoParams
| BulletParams
{ _bupEffect :: BulletEffect
, _bupSpawn :: BulletSpawn
, _bupDrag :: Float
, _bupWidth :: Float
, _bupTimer :: Int
, _bupDamages :: [Damage]
}
data ScrollAttachParams
= ZoomScrollParams
@@ -126,10 +145,12 @@ makeLenses ''ItemUse
makeLenses ''AimParams
makeLenses ''ItZoom
makeLenses ''Muzzle
makeLenses ''HeldParams
makeLenses ''AttachParams
makeLenses ''ScrollAttachParams
makeLenses ''AmmoParams
deriveJSON defaultOptions ''AmmoParams
deriveJSON defaultOptions ''HeldParams
deriveJSON defaultOptions ''Muzzle
deriveJSON defaultOptions ''AimStance
deriveJSON defaultOptions ''ScrollAttachParams
+7
View File
@@ -35,4 +35,11 @@ defaultHeldUse =
, _heldHammer = HammerUp
, _heldAim = defaultAimParams
, _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
]
BangConeMod ->
[ withRandomItemParams coneRandItemParams
[ withRandomItem coneRandItemParams
, withRandomItemUpdate coneRandItemUpdate
, withRandomOffset
, duplicateLoadedBarrels
@@ -497,15 +497,13 @@ coneRandItemUpdate = do
wth <- state $ randomR (1, 5)
return (itUse . heldConsumption . laAmmoType . amBullet . buWidth .~ wth)
coneRandItemParams :: State StdGen (ItemParams -> ItemParams)
coneRandItemParams :: State StdGen (Item -> Item)
coneRandItemParams = do
muzv <- state $ randomR (0.5, 1)
rifl <- state $ randomR (0.3, 0.9)
return $ \itparams ->
itparams
{ _muzVel = muzv
, _rifling = rifl
}
return $ \it ->
it & itUse . heldParams . muzVel .~ muzv
& itUse . heldParams . rifling .~ rifl
mcShootLaser :: Item -> Machine -> World -> World
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 =
defaultBulletWeapon
& itParams
.~ BulletShooter
& itUse . heldParams
.~ BulletShooterParams
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
@@ -44,7 +43,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]
& itParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i
& itUse . heldParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i
& itType . iyBase .~ HELD (VOLLEYGUN i)
multiGun :: Int -> Item
@@ -56,7 +55,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]
& itParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i
& itUse . heldParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i
& itType . iyBase .~ HELD (MULTIGUN i)
rifle :: Item
@@ -109,9 +108,9 @@ miniGunX i =
& itUse .~ miniGunUse i
& itUse . heldAim . aimTurnSpeed .~ 0.5
& itUse . heldAim . aimMuzzles .~ replicate i (Muzzle (V2 30 0) 0 0.05)
& itParams . recoil .~ 10
& itParams . torqueAfter .~ 0.01
& itParams . randomOffset .~ 10
& itUse . heldParams . recoil .~ 10
& itUse . heldParams . torqueAfter .~ 0.01
& itUse . heldParams . randomOffset .~ 10
& itInvSize .~ fromIntegral i + 1
& itDimension . dimRad .~ 20
& itDimension . dimCenter .~ V3 5 0 0
+10 -10
View File
@@ -12,13 +12,6 @@ bangCone =
defaultBulletWeapon
{ _itParams =
BulletShooter
{ _muzVel = 0.7
, _rifling = 0.8
, _bore = 5
, _recoil = 150
, _torqueAfter = 0.1
, _randomOffset = 12
}
}
& itDimension . dimRad .~ 8
& itDimension . dimCenter .~ V3 5 0 0
@@ -26,6 +19,13 @@ bangCone =
& itUse . heldMods .~ BangConeMod
-- & itUse . heldAim . aimHandlePos .~ 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
blunderbuss :: Item
@@ -41,6 +41,6 @@ grapeCannon :: Int -> Item
grapeCannon i =
blunderbuss
& itType . iyBase .~ HELD (GRAPECANNON i)
& itParams . recoil .~ (150 + fromIntegral i * 50)
& itParams . torqueAfter .~ (0.1 + 0.2 * fromIntegral i)
& itParams . randomOffset .~ (12 + 4 * fromIntegral i)
& itUse . heldParams . recoil .~ (150 + fromIntegral i * 50)
& itUse . heldParams . torqueAfter .~ (0.1 + 0.2 * fromIntegral i)
& itUse . heldParams . randomOffset .~ (12 + 4 * fromIntegral i)
+4 -5
View File
@@ -17,11 +17,10 @@ import LensHelp
bangRod :: Item
bangRod =
defaultBulletWeapon
& itParams
.~ BulletShooter
& itUse . heldParams
.~ BulletShooterParams
{ _muzVel = 0.8
, _rifling = 1
, _bore = 2
, _recoil = 50
, _torqueAfter = 0.3
, _randomOffset = 0
@@ -46,7 +45,7 @@ elephantGun =
& itUse . heldAim . aimStance .~ TwoHandUnder
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0.05
& itUse . heldMods .~ ElephantGunMod
& itParams . recoil .~ 50
& itUse . heldParams . recoil .~ 50
amr :: Item
amr =
@@ -78,4 +77,4 @@ machineGun =
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldDelay .~ VariableRate{_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0}
& 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 i =
defaultBulletWeapon
& itParams
.~ BulletShooter
& itUse . heldParams
.~ BulletShooterParams
{ _muzVel = 0.8
, _rifling = 0.8
, _bore = 2
, _recoil = 25
, _torqueAfter = 0.18 + 0.02 * fromIntegral i
, _randomOffset = 0
@@ -45,10 +44,9 @@ pistol =
& itUse . heldDelay . rateMax .~ 6
& itUse . heldMods .~ PistolMod
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 10 0) 0 0.05]
& itParams
& itUse . heldParams
%~ ( (muzVel .~ 0.8)
. (rifling .~ 0.8)
. (bore .~ 2)
. (recoil .~ 10)
. (torqueAfter .~ 0.2)
)
@@ -68,7 +66,7 @@ machinePistol =
& itUse . heldMods .~ MachinePistolMod -- (ammoCheckI : machinePistolAfterHamMods)
& itType . iyBase .~ HELD MACHINEPISTOL
& itType . iyModules . at ModAutoMag .~ Nothing
& itParams . recoil .~ 20
& itUse . heldParams . recoil .~ 20
smg :: Item
smg =
@@ -78,4 +76,4 @@ smg =
& itUse . heldAim . aimStance .~ TwoHandUnder
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 20 0) 0 0]
-- & itUse . heldAim . aimHandlePos .~ 2
& itParams . torqueAfter .~ 0.05
& itUse . heldParams . torqueAfter .~ 0.05
-1
View File
@@ -21,7 +21,6 @@ defaultBullet =
{ _buDelayFraction = 1
, _buEffect = DestroyBullet
, _buSpawn = BulSpark
, _buUpdateMod = NoBulletUpdateMod
, _buTrajectory = BasicBulletTrajectory
, _buVel = V2 50 0
, _buDrag = 1
+9 -3
View File
@@ -24,6 +24,7 @@ module Dodge.Item.Weapon.TriggerType (
withTorqueAfter,
torqueSideEffect,
withRandomItemParams,
withRandomItem,
withRandomItemUpdate,
withSoundStart,
withSoundItemChoiceStart,
@@ -297,7 +298,7 @@ withRecoil :: ChainEffect
withRecoil eff it cr = eff it cr . over (cWorld . lWorld . creatures . ix cid) pushback
where
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))
{- | 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
(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 ::
(Item -> Creature -> World -> (Point2, Float)) ->
ChainEffect
@@ -548,7 +554,7 @@ withRandomOffset f item cr w = f item (cr & crPos %~ (+.+ offV)) $ set randGen g
where
(offsetVal, g) = randomR (- offsetAmount, offsetAmount) $ _randGen w
offV = rotateV (_crDir cr) (V2 0 offsetVal)
offsetAmount = fromMaybe 0 $ item ^? itParams . randomOffset
offsetAmount = fromMaybe 0 $ item ^? itUse . heldParams . randomOffset
-- | Rotates a creature
torqueBefore ::
@@ -615,7 +621,7 @@ withTorqueAfter feff item cr w
where
cid = _crID cr
(rot, g) = randomR (- torque, torque) $ _randGen w
torque = fromMaybe 0 $ item ^? itParams . torqueAfter
torque = fromMaybe 0 $ item ^? itUse . heldParams . torqueAfter
rotateScope = fromMaybe id $ do
i <- yourScopeInvID w
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