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