Reloading slows movement

This commit is contained in:
2021-12-05 00:36:31 +00:00
parent cbf344e73e
commit 1bb1a06101
9 changed files with 155 additions and 24 deletions
+9
View File
@@ -0,0 +1,9 @@
module Dodge.ChainEffect where
import Dodge.Data
type ChainEffect =
(Item -> Creature -> World -> World)
-> Item
-> Creature
-> World
-> World
+16 -5
View File
@@ -5,6 +5,7 @@ import Dodge.Data
--import Dodge.Combine.Data --import Dodge.Combine.Data
import Multiset import Multiset
import Dodge.Item.Weapon.BulletGuns import Dodge.Item.Weapon.BulletGuns
import Dodge.Item.Weapon.Launcher
--import Dodge.Item.Craftable --import Dodge.Item.Craftable
import Control.Lens import Control.Lens
@@ -18,22 +19,32 @@ import Data.List (scanl')
itemCombinations :: [ (M.Map CombineType Int, Item) ] itemCombinations :: [ (M.Map CombineType Int, Item) ]
itemCombinations = map (first toMultiset) $ itemCombinations = map (first toMultiset) $
[ p [PIPE,HARDWARE] (bangStick 1) [ p [PIPE,HARDWARE] (bangStick 1)
, p [PIPE,PIPE,HARDWARE] bangCane
, p [PIPE,PIPE,PIPE,HARDWARE] bangRod
, p [BANGSTICK 1,CAN] revolver
, p [BANGSTICK 1,TIN] pistol , p [BANGSTICK 1,TIN] pistol
, p [PISTOL, SPRING, HARDWARE] autoPistol , p [PISTOL, SPRING, HARDWARE] autoPistol
, p [AUTOPISTOL, PLANK, HARDWARE] smg , p [AUTOPISTOL, PLANK, HARDWARE] smg
, p [AUTOPISTOL, HARDWARE] machinePistol , p [AUTOPISTOL, HARDWARE] machinePistol
, p [BANGSTICK 1,CAN] revolver
, p [REVOLVER, SPRING, HARDWARE] $ revolverX 1 , p [REVOLVER, SPRING, HARDWARE] $ revolverX 1
, p [PIPE,TUBE,HARDWARE] bangCone , p [PIPE,TUBE,HARDWARE] bangCone
, p [BANGCONE,PLANK] blunderbuss , p [BANGCONE,PLANK] blunderbuss
, p [BLUNDERBUSS,TUBE] grapeShotCannon
, p [BANGCONE,PUMP,HARDWARE] $ grenadeLauncher 1 , p [BANGCONE,PUMP,HARDWARE] $ grenadeLauncher 1
, p [GRENADELAUNCHER 1,MOTOR,DRUM] $ grenadeLauncher 2 , p [GRENADELAUNCHER 1,MOTOR,DRUM] $ grenadeLauncher 2
, p [BLUNDERBUSS,TUBE] grapeShotCannon
, p [PIPE,PIPE,HARDWARE] bangCane
, p [BANGCANE,PIPE,PIPE] (bangCaneX 2)
, p [BANGCANE,TIN] rifle
, p [RIFLE,SPRING,HARDWARE] autoRifle
, p [RIFLE,SPRING,CAN] assaultRifle
, p [PIPE,PIPE,PIPE,HARDWARE] bangRod
, p [TUBE,TUBE,TUBE,HARDWARE] launcher
] ]
++ map (\i -> ([PIPE,BANGSTICK i],bangStick (i+1))) [1..8] ++ map (\i -> ([PIPE,BANGSTICK i],bangStick (i+1))) [1..8]
++ map (\i -> ([REVOLVERX i,CAN] ,revolverX (i+1))) [1..6] ++ map (\i -> ([REVOLVERX i,CAN] ,revolverX (i+1))) [1..5]
++ map (\i -> ([BANGCANEX i,PIPE,PIPE] ,bangCaneX (i+1))) [1..5]
where where
p = (,) p = (,)
+4 -1
View File
@@ -19,11 +19,13 @@ data CombineType
| BLUNDERBUSS | BLUNDERBUSS
| GRAPESHOTCANNON | GRAPESHOTCANNON
| GRENADELAUNCHER Int -- number of chambers that can be reloaded | GRENADELAUNCHER Int -- number of chambers that can be reloaded
| MORTAR -- | MORTARCONE / HANDMORTAR
| MINIGUN | MINIGUN
| BANGCANE | BANGCANE
| BANGCANEX Int | BANGCANEX Int
| RIFLE | RIFLE
| AUTORIFLE
| ASSAULTRIFLE
| AUTOGUN | AUTOGUN
| SPREADGUN | SPREADGUN
| MULTGUN | MULTGUN
@@ -63,6 +65,7 @@ data CombineType
| PUMP | PUMP
| MOTOR | MOTOR
| PRISM | PRISM
| LIGHTER
| MAGNET | MAGNET
| TPipe | TPipe
| NoCombineType | NoCombineType
+4 -1
View File
@@ -38,9 +38,12 @@ crMvAbsolute p' cr = advanceStepCounter (magV p) cr
equipFactor equipFactor
| _posture (_crStance cr) == Aiming | _posture (_crStance cr) == Aiming
= product $ map equipAimSpeed $ IM.elems $ _crInv cr = product $ map equipAimSpeed $ IM.elems $ _crInv cr
| _posture (_crStance cr) == Reloading
= product $ map equipAimSpeed $ IM.elems $ _crInv cr
| otherwise = product $ map equipSpeed $ IM.elems $ _crInv cr | otherwise = product $ map equipSpeed $ IM.elems $ _crInv cr
aimingFactor aimingFactor
| _posture (_crStance cr) == Aiming = fromMaybe 1 $ it ^? itUse . useAim . aimSpeed | _posture (_crStance cr) == Aiming || _posture (_crStance cr) == Reloading
= fromMaybe 1 $ it ^? itUse . useAim . aimSpeed
| otherwise = 1 | otherwise = 1
it = _crInv cr IM.! _crInvSel cr it = _crInv cr IM.! _crInvSel cr
+1 -1
View File
@@ -28,7 +28,7 @@ data FootForward
| WasRightForward | WasRightForward
deriving deriving
(Eq,Ord,Show) (Eq,Ord,Show)
data Posture = Aiming | AtEase data Posture = Aiming | Reloading | AtEase
deriving deriving
(Eq,Ord,Show) (Eq,Ord,Show)
+6 -3
View File
@@ -12,6 +12,7 @@ import qualified SDL
import qualified Data.Set as S import qualified Data.Set as S
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
import Data.Monoid import Data.Monoid
import Data.Maybe
{- | The AI equivalent for your control. -} {- | The AI equivalent for your control. -}
yourControl yourControl
:: Creature :: Creature
@@ -62,8 +63,10 @@ wasdDir w = foldr ((+.+) . wasdM) (V2 0 0) $ _keys w
{- | Set posture according to mouse presses. -} {- | Set posture according to mouse presses. -}
mouseActionsCr :: S.Set SDL.MouseButton -> Creature -> Creature mouseActionsCr :: S.Set SDL.MouseButton -> Creature -> Creature
mouseActionsCr pkeys mouseActionsCr pkeys cr
| rbPressed = crStance . posture .~ Aiming | reloading = cr & crStance . posture .~ Reloading
| otherwise = crStance . posture .~ AtEase | rbPressed = cr & crStance . posture .~ Aiming
| otherwise = cr & crStance . posture .~ AtEase
where where
reloading = isJust $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . reloadState . _Just'
rbPressed = SDL.ButtonRight `S.member` pkeys rbPressed = SDL.ButtonRight `S.member` pkeys
+3 -2
View File
@@ -548,8 +548,9 @@ data TweakParam = TweakParam
} }
data GunBarrels data GunBarrels
= MultiBarrel = MultiBarrel
{ _brlSpread :: BarrelSpread { _brlSpread :: BarrelSpread
, _brlNum :: Int , _brlNum :: Int
, _brlInaccuracy :: Float
} }
| RotBarrel | RotBarrel
{ _brlNum :: Int { _brlNum :: Int
+107 -11
View File
@@ -8,6 +8,10 @@ module Dodge.Item.Weapon.BulletGuns
, bangStick , bangStick
, bangRod , bangRod
, bangCane , bangCane
, bangCaneX
, rifle
, autoRifle
, assaultRifle
, autoGun , autoGun
, multGun , multGun
, miniGun , miniGun
@@ -42,10 +46,11 @@ import Geometry
import ShapePicture import ShapePicture
import Shape import Shape
import Sound.Data import Sound.Data
import LensHelp
import Data.Maybe import Data.Maybe
import qualified Data.Sequence as Seq import qualified Data.Sequence as Seq
import Control.Lens --import Control.Lens
import Control.Monad.State import Control.Monad.State
import System.Random import System.Random
@@ -143,26 +148,109 @@ bangStick i = defaultGun
, _gunBarrels = MultiBarrel , _gunBarrels = MultiBarrel
{_brlNum = i {_brlNum = i
,_brlSpread = SpreadBarrels 0.2 ,_brlSpread = SpreadBarrels 0.2
,_brlInaccuracy = 0
} }
} }
, _itTweaks = defaultBulletSelTweak , _itTweaks = defaultBulletSelTweak
, _itInvSize = fromIntegral i / 3 , _itInvSize = fromIntegral i / 3
} }
bangCane,bangRod :: Item bangCane :: Item
bangCane = defaultGun bangCane = defaultGun
{ _itParams = BulletShooter { _itName = "BANGCANE"
, _itCombineType = BANGCANE
,_itParams = BulletShooter
{ _muzVel = 0.8 { _muzVel = 0.8
, _rifling = 0.9 , _rifling = 0.9
, _bore = 2 , _bore = 2
, _gunBarrels = SingleBarrel 0.05 , _gunBarrels = SingleBarrel 0.1
} }
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 1
, _reloadTime = 20
, _reloadType = ActivePartial 1
}
, _itUse = useAmmoParamsRate 6 upHammer
[ ammoHammerCheck
, useTimeCheck
, withSoundStart tap3S
, useAmmoAmount 1
, torqueAfterI 0.1
, applyInaccuracy
, withMuzFlareI
, withRecoilI 50
]
, _itFloorPict = autoGunPic , _itFloorPict = autoGunPic
, _itTweaks = defaultBulletSelTweak
} & itUse . useAim . aimSpeed .~ 0.4 } & itUse . useAim . aimSpeed .~ 0.4
& itUse . useAim . aimRange .~ 1 & itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandTwist & itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5} & itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
bangCaneX :: Int -> Item
bangCaneX i = bangCane
{ _itName = "BANGCANEx"++show i
, _itCombineType = BANGCANEX i
, _itUse = useAmmoParamsRate 6 upHammer
[ ammoHammerCheck
, useTimeCheck
, withSoundItemChoiceStart bangStickSoundChoice
, useAmmoAmount 1
, torqueAfterI 0.2
, duplicateLoadedBarrels
, applyInaccuracy
, withMuzFlareI
, withRecoilI 50
]
} & itUse . useAim . aimSpeed .~ 0.4
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itConsumption . ammoMax .~ i
& itParams . gunBarrels .~ MultiBarrel
{_brlSpread = AlignedBarrels
,_brlNum = i
,_brlInaccuracy = 0.1
}
rifle :: Item
rifle = bangCane
& itName .~ "RIFLE"
& itCombineType .~ RIFLE
& itConsumption . ammoMax .~ 15
& itConsumption . reloadType .~ ActiveClear
& itConsumption . reloadTime .~ 80
autoRifle :: Item
autoRifle = rifle
& itName .~ "AUTORIFLE"
& itCombineType .~ AUTORIFLE
& itUse . useMods %~ ((ammoCheckI :) . tail)
-- & itUse . useDelay . rateMax .~ 6
assaultRifle :: Item
assaultRifle = rifle
& itName .~ "ASSAULTRIFLE"
& itCombineType .~ ASSAULTRIFLE
& itUse . useDelay . rateMax .~ 18
& itUse . useMods .~
[ ammoHammerCheck
, useTimeCheck
, torqueAfterI 0.2
, lockInvFor 10
, \f it -> repeatOnFrames (take (_ammoLoaded (_itConsumption it) - 1) [3,6]) f it
, withSoundStart tap3S
, useAmmoAmount 1
, applyInaccuracy
, withMuzFlareI
, withRecoilI 50
]
bangRod :: Item
bangRod = bangCane bangRod = bangCane
{ _itParams = BulletShooter { _itName = "BANGROD"
, _itCombineType = BANGROD
, _itParams = BulletShooter
{ _muzVel = 0.8 { _muzVel = 0.8
, _rifling = 1 , _rifling = 1
, _bore = 2 , _bore = 2
@@ -187,10 +275,11 @@ revolverX i = revolver
, \f it -> repeatOnFrames (take (_ammoLoaded (_itConsumption it) - 1) [2,4,6,8,10]) f it , \f it -> repeatOnFrames (take (_ammoLoaded (_itConsumption it) - 1) [2,4,6,8,10]) f it
, withSoundStart tap3S , withSoundStart tap3S
, useAmmoUpTo 1 , useAmmoUpTo 1
-- , applyInaccuracy , applyInaccuracy
, withMuzFlareI , withMuzFlareI
-- , spreadLoaded -- , spreadLoaded
, withRecoilI 25 , torqueAfterI 0.2
, withRecoilI 10
] ]
} & itConsumption . ammoMax .~ i * 6 } & itConsumption . ammoMax .~ i * 6
bangCone :: Item bangCone :: Item
@@ -257,6 +346,7 @@ blunderbuss = bangCone
, withRandomItemParams coneRandItemParams , withRandomItemParams coneRandItemParams
] ]
& useAim . aimStance .~ TwoHandTwist & useAim . aimStance .~ TwoHandTwist
& useAim . aimSpeed .~ 0.4
} }
grapeShotCannon :: Item grapeShotCannon :: Item
@@ -282,7 +372,6 @@ grapeShotCannon = blunderbuss
& itConsumption . ammoMax .~ 15 & itConsumption . ammoMax .~ 15
& itConsumption . reloadTime .~ 30 & itConsumption . reloadTime .~ 30
grenadeLauncher :: Int -> Item grenadeLauncher :: Int -> Item
grenadeLauncher _ = bangCone grenadeLauncher _ = bangCone
@@ -415,11 +504,13 @@ hvAutoGunPic it =
where where
am = _ammoLoaded $ _itConsumption it am = _ammoLoaded $ _itConsumption it
autoPistol :: Item autoPistol :: Item
autoPistol = pistol & itUse . useMods .~ (ammoCheckI : pistolAfterHamMods) autoPistol = pistol
& itUse . useMods .~ (ammoCheckI : pistolAfterHamMods)
& itName .~ "AUTOPISTOL" & itName .~ "AUTOPISTOL"
& itCombineType .~ AUTOPISTOL & itCombineType .~ AUTOPISTOL
machinePistol :: Item machinePistol :: Item
machinePistol = autoPistol & itUse . useDelay . rateMax .~ 2 machinePistol = autoPistol
& itUse . useDelay . rateMax .~ 2
& itUse . useMods .~ (ammoCheckI : machinePistolAfterHamMods) & itUse . useMods .~ (ammoCheckI : machinePistolAfterHamMods)
& itName .~ "MACHINEPISTOL" & itName .~ "MACHINEPISTOL"
& itCombineType .~ MACHINEPISTOL & itCombineType .~ MACHINEPISTOL
@@ -428,6 +519,7 @@ smg = autoPistol -- & some parameter affecting stability
& itUse . useMods .~ (ammoCheckI : smgAfterHamMods) & itUse . useMods .~ (ammoCheckI : smgAfterHamMods)
& itName .~ "SMG" & itName .~ "SMG"
& itCombineType .~ SMG & itCombineType .~ SMG
& itUse . useAim . aimStance .~ TwoHandTwist
ltAutoGun :: Item ltAutoGun :: Item
ltAutoGun = defaultAutoGun ltAutoGun = defaultAutoGun
{ _itName = "AUTO-LT" { _itName = "AUTO-LT"
@@ -522,7 +614,9 @@ miniGun = defaultAutoGun
, _bore = 2 , _bore = 2
, _gunBarrels = MultiBarrel , _gunBarrels = MultiBarrel
{_brlSpread = RotatingBarrels 0.01 {_brlSpread = RotatingBarrels 0.01
,_brlNum = 4} ,_brlNum = 4
,_brlInaccuracy = 0
}
} }
, _itEquipPict = pictureWeaponAim miniGunPictItem , _itEquipPict = pictureWeaponAim miniGunPictItem
, _itTweaks = defaultBulletSelTweak , _itTweaks = defaultBulletSelTweak
@@ -602,6 +696,7 @@ spreadGun = defaultGun
, _gunBarrels = MultiBarrel , _gunBarrels = MultiBarrel
{_brlNum = 5 {_brlNum = 5
,_brlSpread = SpreadBarrels 0.5 ,_brlSpread = SpreadBarrels 0.5
,_brlInaccuracy = 0
} }
} }
, _itFloorPict = spreadGunPic , _itFloorPict = spreadGunPic
@@ -648,6 +743,7 @@ multGun = defaultGun
, _gunBarrels = MultiBarrel , _gunBarrels = MultiBarrel
{_brlNum = 5 {_brlNum = 5
,_brlSpread = AlignedBarrels ,_brlSpread = AlignedBarrels
,_brlInaccuracy = 0
} }
} }
, _itTweaks = defaultBulletSelTweak , _itTweaks = defaultBulletSelTweak
+5
View File
@@ -2,6 +2,7 @@ module LensHelp
( module Control.Lens ( module Control.Lens
, (.:~) , (.:~)
, (.++~) , (.++~)
, (++.~)
) where ) where
import Control.Lens import Control.Lens
@@ -12,3 +13,7 @@ infixr 4 .:~
infixr 4 .++~ infixr 4 .++~
(.++~) :: ASetter s t [a] [a] -> [a] -> s -> t (.++~) :: ASetter s t [a] [a] -> [a] -> s -> t
(.++~) m x = m %~ (x ++) (.++~) m x = m %~ (x ++)
infixr 4 ++.~
(++.~) :: ASetter s t [a] [a] -> [a] -> s -> t
(++.~) m x = m %~ (++ x)