Expose recoil, torque etc as item parameters
This commit is contained in:
@@ -586,6 +586,9 @@ data ItemParams
|
||||
, _rifling :: Float
|
||||
, _bore :: Float
|
||||
, _gunBarrels :: GunBarrels
|
||||
, _recoil :: Float
|
||||
, _torqueAfter :: Float
|
||||
, _randomOffset :: Float
|
||||
}
|
||||
| Sprayer
|
||||
{ _nozzleSpread :: Float
|
||||
|
||||
@@ -149,7 +149,17 @@ defItDimCol col = ItemDimension
|
||||
}
|
||||
, _dimSPic = const $ noPic $ colorSH col $ upperPrismPoly 3 $ square 4
|
||||
}
|
||||
|
||||
defBulletShooter :: ItemParams
|
||||
defBulletShooter = BulletShooter
|
||||
{ _muzVel = 1
|
||||
, _rifling = 0.8
|
||||
, _bore = 2
|
||||
, _gunBarrels = SingleBarrel 0
|
||||
, _recoil = 0
|
||||
, _torqueAfter = 0
|
||||
, _randomOffset = 0
|
||||
}
|
||||
|
||||
defaultAutoGun :: Item
|
||||
defaultAutoGun = defaultGun
|
||||
& itUse . useAim . aimStance .~ TwoHandTwist
|
||||
|
||||
@@ -51,6 +51,9 @@ bangCane = defaultGun
|
||||
, _gunBarrels = SingleBarrel
|
||||
{ _brlInaccuracy = 0.01
|
||||
}
|
||||
, _recoil = 50
|
||||
, _torqueAfter = 0.1
|
||||
, _randomOffset = 0
|
||||
}
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _aoType = basicBullet
|
||||
@@ -63,9 +66,9 @@ bangCane = defaultGun
|
||||
, useTimeCheck
|
||||
, withSoundStart tap3S
|
||||
, useAmmoAmount 1
|
||||
, torqueAfterI 0.1
|
||||
, withTorqueAfter
|
||||
, applyInaccuracy
|
||||
, withRecoilI 50
|
||||
, withRecoil
|
||||
, withSmoke 1 black 20 200 5
|
||||
, withMuzFlareI
|
||||
]
|
||||
@@ -244,7 +247,7 @@ miniGunUse i = ruseInstant (useAmmoParams $ Just 1) NoHammer $
|
||||
[ withSidePushI 50
|
||||
, torqueBefore 0.05
|
||||
, afterRecoil recoilAmount
|
||||
, withRandomOffsetI 10
|
||||
, withRandomOffset
|
||||
, withOldDir x
|
||||
, trigDoAlso (useAmmoParams $ Just x)
|
||||
] | x <- map ((/fromIntegral i) . fromIntegral) [1..i-1]
|
||||
@@ -252,7 +255,7 @@ miniGunUse i = ruseInstant (useAmmoParams $ Just 1) NoHammer $
|
||||
<>
|
||||
[ withSidePushI 50
|
||||
, afterRecoil recoilAmount
|
||||
, withRandomOffsetI 10
|
||||
, withRandomOffset
|
||||
]
|
||||
where
|
||||
recoilAmount = 5
|
||||
@@ -283,6 +286,9 @@ miniGunX i = defaultAutoGun
|
||||
,_brlNum = i
|
||||
,_brlInaccuracy = 0
|
||||
}
|
||||
, _recoil = 10
|
||||
, _torqueAfter = 0
|
||||
, _randomOffset = 10
|
||||
}
|
||||
, _itEquipPict = pictureWeaponAim (miniGunXPictItem i)
|
||||
, _itTweaks = defaultBulletSelTweak
|
||||
|
||||
@@ -44,17 +44,20 @@ bangRod = defaultGun
|
||||
, _rifling = 1
|
||||
, _bore = 2
|
||||
, _gunBarrels = SingleBarrel 0.1
|
||||
, _recoil = 50
|
||||
, _torqueAfter = 0.3
|
||||
, _randomOffset = 0
|
||||
}
|
||||
, _itUse = ruseAmmoParamsRate 12 upHammer
|
||||
[ ammoHammerCheck
|
||||
, useTimeCheck
|
||||
, withSoundStart bangEchoS
|
||||
, useAmmoAmount 1
|
||||
, torqueAfterI 0.3
|
||||
, withTorqueAfter
|
||||
, applyInaccuracy
|
||||
, withThickSmokeI
|
||||
, withMuzFlareI
|
||||
, withRecoilI 50
|
||||
, withRecoil
|
||||
]
|
||||
, _itDimension = ItemDimension
|
||||
{ _dimRad = 12
|
||||
|
||||
@@ -58,10 +58,10 @@ bangStick i = defaultGun
|
||||
, withSoundItemChoiceStart bangStickSoundChoice
|
||||
, useAllAmmo
|
||||
, withMuzFlareI
|
||||
, torqueAfterI (0.18 + 0.02 * fromIntegral i)
|
||||
, withTorqueAfter
|
||||
, spreadLoaded
|
||||
-- , applyInaccuracy
|
||||
, withRecoilI 25
|
||||
, withRecoil
|
||||
]
|
||||
, _itID = Nothing
|
||||
, _itInvColor = white
|
||||
@@ -74,6 +74,9 @@ bangStick i = defaultGun
|
||||
,_brlSpread = SpreadBarrels baseStickSpread
|
||||
,_brlInaccuracy = 0.01
|
||||
}
|
||||
, _recoil = 25
|
||||
, _torqueAfter = 0.18 + 0.02 * fromIntegral i
|
||||
, _randomOffset = 0
|
||||
}
|
||||
, _itTweaks = defaultBulletSelTweak
|
||||
, _itInvSize = fromIntegral i / 3
|
||||
@@ -184,14 +187,14 @@ pistol = (bangStick 1)
|
||||
-- , _itEquipPict = pictureWeaponAim pistolPic
|
||||
, _itID = Nothing
|
||||
, _itInvColor = white
|
||||
, _itParams = BulletShooter
|
||||
{ _muzVel = 0.8
|
||||
, _rifling = 0.8
|
||||
, _bore = 2
|
||||
, _gunBarrels = SingleBarrel 0.05
|
||||
}
|
||||
, _itTweaks = defaultBulletSelTweak
|
||||
} & itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> makeTinClipAt pi (V3 5 2 0) it)
|
||||
& itParams %~
|
||||
( ( muzVel .~ 0.8 )
|
||||
. ( rifling .~ 0.8 )
|
||||
. ( bore .~ 2 )
|
||||
. ( gunBarrels .~ SingleBarrel 0.05 )
|
||||
)
|
||||
autoPistol :: Item
|
||||
autoPistol = pistol
|
||||
& itUse . useMods .~ (ammoCheckI : pistolAfterHamMods)
|
||||
|
||||
@@ -90,6 +90,9 @@ autoGun = defaultAutoGun
|
||||
, _rifling = 0.9
|
||||
, _bore = 2
|
||||
, _gunBarrels = SingleBarrel 0.1
|
||||
, _recoil = 0
|
||||
, _torqueAfter = 0
|
||||
, _randomOffset = 0
|
||||
}
|
||||
, _itTweaks = defaultBulletSelTweak
|
||||
}
|
||||
@@ -119,21 +122,23 @@ bangCone = defaultGun
|
||||
, useTimeCheck
|
||||
, withSoundStart bangEchoS
|
||||
, useAllAmmo
|
||||
, torqueAfterI 0.1
|
||||
, withRecoilI 150
|
||||
, withTorqueAfter
|
||||
, withRecoil
|
||||
, duplicateLoaded
|
||||
, withMuzFlareI
|
||||
, applyInaccuracy
|
||||
, withRandomOffsetI 12
|
||||
, withRandomOffset
|
||||
, withRandomItemUpdate coneRandItemUpdate
|
||||
, withRandomItemParams coneRandItemParams
|
||||
]
|
||||
& useAim . aimSpeed .~ 0.4
|
||||
, _itParams = BulletShooter
|
||||
{ _muzVel = 0.7
|
||||
, _rifling = 0.8
|
||||
, _bore = 5
|
||||
, _gunBarrels = SingleBarrel 0.5
|
||||
, _recoil = 150
|
||||
, _torqueAfter = 0.1
|
||||
, _randomOffset = 12
|
||||
}
|
||||
, _itDimension = ItemDimension
|
||||
{ _dimRad = 8
|
||||
@@ -151,22 +156,33 @@ coneRandItemUpdate :: State StdGen (Item -> Item)
|
||||
coneRandItemUpdate = do
|
||||
wth <- state $ randomR (1,5)
|
||||
return (\it -> it & itConsumption . aoType . amBulWth .~ wth)
|
||||
coneRandItemParams :: State StdGen ItemParams
|
||||
coneRandItemParams :: State StdGen (ItemParams -> ItemParams)
|
||||
coneRandItemParams = do
|
||||
muzv <- state $ randomR (0.5,1)
|
||||
rifl <- state $ randomR (0.3,0.9)
|
||||
return $ BulletShooter
|
||||
return $ \itparams -> itparams
|
||||
{ _muzVel = muzv
|
||||
, _rifling = rifl
|
||||
, _bore = 5
|
||||
, _gunBarrels = SingleBarrel 0.5
|
||||
}
|
||||
|
||||
blunderbuss :: Item
|
||||
blunderbuss = bangCone
|
||||
{_itName = "BLUNDERBUSS"
|
||||
,_itType = BLUNDERBUSS
|
||||
,_itUse = ruseAmmoParamsRate 20 upHammer
|
||||
, _itDimension = ItemDimension
|
||||
{ _dimRad = 8
|
||||
, _dimCenter = V3 5 0 0
|
||||
, _dimPortage = HeldItem
|
||||
{_handlePos = 5
|
||||
,_muzPos = 30
|
||||
}
|
||||
, _dimSPic = const $ noPic $ colorSH cyan $ upperPrismPoly 3 (rectXH 20 2)
|
||||
<> upperPrismPoly 6 (rectNSEW 4 (-4) 30 20)
|
||||
}
|
||||
}
|
||||
& itConsumption . ammoBaseMax .~ 25
|
||||
& itConsumption . reloadTime .~ 30
|
||||
& itUse . useMods .~
|
||||
[ ammoCheckI
|
||||
, hammerCheckI
|
||||
, useTimeCheck
|
||||
@@ -181,21 +197,8 @@ blunderbuss = bangCone
|
||||
, withRandomItemUpdate coneRandItemUpdate
|
||||
, withRandomItemParams coneRandItemParams
|
||||
]
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
& useAim . aimSpeed .~ 0.4
|
||||
, _itDimension = ItemDimension
|
||||
{ _dimRad = 8
|
||||
, _dimCenter = V3 5 0 0
|
||||
, _dimPortage = HeldItem
|
||||
{_handlePos = 5
|
||||
,_muzPos = 30
|
||||
}
|
||||
, _dimSPic = const $ noPic $ colorSH cyan $ upperPrismPoly 3 (rectXH 20 2)
|
||||
<> upperPrismPoly 6 (rectNSEW 4 (-4) 30 20)
|
||||
}
|
||||
}
|
||||
& itConsumption . ammoBaseMax .~ 25
|
||||
& itConsumption . reloadTime .~ 30
|
||||
& itUse . useAim . aimStance .~ TwoHandTwist
|
||||
& itUse . useAim . aimSpeed .~ 0.4
|
||||
bigBlunderbuss :: Item
|
||||
bigBlunderbuss = blunderbuss
|
||||
{_itName = "BIGBLUNDERBUSS"
|
||||
@@ -349,7 +352,7 @@ ltAutoGun = defaultAutoGun
|
||||
, modClock 2 withMuzFlareI
|
||||
]
|
||||
-- , _itFloorPict = ltAutoGunPic
|
||||
, _itParams = BulletShooter
|
||||
, _itParams = defBulletShooter
|
||||
{ _muzVel = 1
|
||||
, _rifling = 0.8
|
||||
, _bore = 2
|
||||
@@ -377,7 +380,7 @@ spreadGun = defaultGun
|
||||
, withMuzFlareI
|
||||
, spreadNumI
|
||||
]
|
||||
, _itParams = BulletShooter
|
||||
, _itParams = defBulletShooter
|
||||
{ _muzVel = 0.7
|
||||
, _rifling = 0.8
|
||||
, _bore = 2
|
||||
@@ -416,7 +419,7 @@ multGun = defaultGun
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
|
||||
-- , _itFloorPict = multGunSPic
|
||||
, _itParams = BulletShooter
|
||||
, _itParams = defBulletShooter
|
||||
{ _muzVel = 1
|
||||
, _rifling = 0.9
|
||||
, _bore = 3
|
||||
|
||||
@@ -15,6 +15,7 @@ module Dodge.Item.Weapon.TriggerType
|
||||
, torqueBefore
|
||||
, torqueBeforeAtLeast
|
||||
, torqueAfterI
|
||||
, withTorqueAfter
|
||||
, torqueSideEffect
|
||||
, withRandomItemParams
|
||||
, withRandomItemUpdate
|
||||
@@ -29,8 +30,10 @@ module Dodge.Item.Weapon.TriggerType
|
||||
, withPositionWallCheck
|
||||
, withPosDirWallCheck
|
||||
, withRandomOffsetI
|
||||
, withRandomOffset
|
||||
, withRandomDirI
|
||||
, withRecoilI
|
||||
, withRecoil
|
||||
, afterRecoil
|
||||
, withSidePushAfterI
|
||||
, withSidePushI
|
||||
@@ -242,6 +245,12 @@ withRecoilI recoilAmount eff item cr = eff item cr . over (creatures . ix cid) p
|
||||
where
|
||||
cid = _crID cr
|
||||
pushback = over crPos (+.+ rotateV (_crDir cr) (V2 ((-recoilAmount) / _crMass cr ) 0))
|
||||
withRecoil :: ChainEffect
|
||||
withRecoil eff it cr = eff it cr . over (creatures . ix cid) pushback
|
||||
where
|
||||
cid = _crID cr
|
||||
recoilAmount = fromMaybe 0 $ it ^? itParams . recoil
|
||||
pushback = over crPos (+.+ rotateV (_crDir cr) (V2 ((-recoilAmount) / _crMass cr ) 0))
|
||||
{- | Pushes a creature sideways by a random amount.
|
||||
Applied before the underlying effect. -}
|
||||
withSidePushI
|
||||
@@ -395,12 +404,10 @@ withRandomItemUpdate randItUp eff it cr w = eff (f it) cr $ w & randGen .~ g
|
||||
where
|
||||
(f,g) = runState randItUp (_randGen w)
|
||||
|
||||
withRandomItemParams
|
||||
:: State StdGen ItemParams
|
||||
-> ChainEffect
|
||||
withRandomItemParams rip eff it cr w = eff (it & itParams .~ it') cr $ w & randGen .~ g
|
||||
withRandomItemParams :: State StdGen (ItemParams -> ItemParams) -> ChainEffect
|
||||
withRandomItemParams rip eff it cr w = eff (it & itParams %~ f) cr $ w & randGen .~ g
|
||||
where
|
||||
(it',g) = runState rip (_randGen w)
|
||||
(f,g) = runState rip (_randGen w)
|
||||
|
||||
withPositionOffset
|
||||
:: (Item -> Creature -> World -> (Point2,Float))
|
||||
@@ -434,6 +441,13 @@ withRandomOffsetI offsetAmount f item cr w = f item (cr & crPos %~ (+.+ offV)) $
|
||||
where
|
||||
(offsetVal , g) = randomR (-offsetAmount,offsetAmount) $ _randGen w
|
||||
offV = rotateV (_crDir cr) (V2 0 offsetVal)
|
||||
{- | Apply the effect to a translated creature. -}
|
||||
withRandomOffset :: ChainEffect
|
||||
withRandomOffset f item cr w = f item (cr & crPos %~ (+.+ offV)) $ set randGen g w
|
||||
where
|
||||
(offsetVal , g) = randomR (-offsetAmount,offsetAmount) $ _randGen w
|
||||
offV = rotateV (_crDir cr) (V2 0 offsetVal)
|
||||
offsetAmount = fromMaybe 0 $ item ^? itParams . randomOffset
|
||||
-- | Rotates a creature
|
||||
torqueBefore
|
||||
:: Float -- ^ Max possible rotation
|
||||
@@ -465,8 +479,7 @@ torqueBeforeAtLeast minTorque exTorque feff item cr w
|
||||
rot' | rot < 0 = rot - minTorque
|
||||
| otherwise = rot + minTorque
|
||||
-- | Rotate a randomly creature after applying an effect.
|
||||
torqueAfterI
|
||||
:: Float -- ^ Max possible rotation
|
||||
torqueAfterI :: Float -- ^ Max possible rotation
|
||||
-> ChainEffect
|
||||
torqueAfterI torque feff item cr w
|
||||
-- | cid == 0 = rotateScope $ set randGen g $ over cameraRot (+rot) $ feff item cr w
|
||||
@@ -477,6 +490,17 @@ torqueAfterI torque feff item cr w
|
||||
(rot, g) = randomR (-torque,torque) $ _randGen w
|
||||
-- rotateScope = creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
||||
-- . itAttachment . scopePos %~ rotateV rot
|
||||
--
|
||||
-- | Rotate a randomly creature after applying an effect.
|
||||
withTorqueAfter :: ChainEffect
|
||||
withTorqueAfter feff item cr w
|
||||
-- | cid == 0 = rotateScope $ set randGen g $ over cameraRot (+rot) $ feff item cr w
|
||||
| cid == 0 = set randGen g $ over cameraRot (+rot) $ feff item cr w
|
||||
| otherwise = set randGen g $ over (creatures . ix cid . crDir) (+rot) $ feff item cr w
|
||||
where
|
||||
cid = _crID cr
|
||||
(rot, g) = randomR (-torque,torque) $ _randGen w
|
||||
torque = fromMaybe 0 $ item ^? itParams. torqueAfter
|
||||
|
||||
spreadNumI :: ChainEffect
|
||||
spreadNumI eff item cr w = foldr f w dirs
|
||||
|
||||
Reference in New Issue
Block a user