Reorganise weapons

This commit is contained in:
2021-12-06 17:41:53 +00:00
parent b058fba814
commit 19540bd19e
12 changed files with 570 additions and 458 deletions
+4 -28
View File
@@ -20,14 +20,15 @@ import qualified Data.IntMap.Strict as IM
--import qualified Data.IntSet as IS
import qualified Data.Map.Strict as M
import Data.Maybe
import Data.List (sort,scanl',sortOn)
import Data.List (scanl',sortOn)
combinationsTrie :: Trie (Int,CombineType) Item
combinationsTrie = foldr (uncurry insertInTrie) emptyTrie
$ map (first (sortOn snd)) itemCombinations
lookupTypeTrie :: [(CombineType,Int,Int)] -> Maybe ([Int],Item)
lookupTypeTrie = undefined
-- this can probably be improved by going through accessing the combinations
-- trie going through each combine type in your inventory in order, rather than
-- creating all multisets of combine types.
lookupItems' :: [(CombineType,Int,Int)] -> [ ([Int],Item) ]
lookupItems' xs = lookupItems (sortOn (\(ct,_,_) -> ct) xs) combinationsTrie
@@ -39,29 +40,6 @@ lookupItems ((ct,i,n):xs) t = do
let is = replicate n' i
concatMap (map (first (is ++)) . lookupItems xs) $ maybeToList (_trieChildren t M.!? (n',ct))
--lookupTypeTrie' :: [CombineType] -> Maybe Item
--lookupTypeTrie' = flip lookupTrie combinationsTrie . sort
combineItemList :: IM.IntMap Item -> [([Int],Item)]
combineItemList = undefined
--combineItemList :: IM.IntMap Item -> [([Int],Item)]
--combineItemList = mapMaybe (pushOutMaybe . second lookupTypeTrie)
-- . listCombos
pushOutMaybe :: (a,Maybe b) -> Maybe (a,b)
pushOutMaybe (_,Nothing) = Nothing
pushOutMaybe (x,Just y) = Just (x,y)
listCombos :: IM.IntMap Item -> [([Int], [CombineType])]
listCombos = concatMap expandOut . invertListInvMult
expandOut :: [(CombineType,Int,Int)] -> [([Int],[CombineType])]
expandOut [] = [([],[])]
expandOut (x:xs) = (<>) <$> f x <*> expandOut xs
where
f (ct,i,n) = map (\j -> (replicate j i,replicate j ct)) [1..min 4 n]
invertListInvMult :: IM.IntMap Item -> [[(CombineType,Int,Int)]]
invertListInvMult = powlistUpToN 4 . invertListInv
@@ -70,8 +48,6 @@ invertListInv = IM.foldrWithKey
(\k it -> ((_itType it, k, itStackAmount it) :) )
[]
combineItemListYou' :: World -> [([Int],Item)]
combineItemListYou' = combineItemList . yourInv
combineItemListYou :: World -> [([Int],Item)]
combineItemListYou = concatMap lookupItems' . invertListInvMult . yourInv
+8 -1
View File
@@ -3,6 +3,8 @@ module Dodge.Combine.Combinations where
import Dodge.Data
import Dodge.Item.Weapon.BulletGuns
import Dodge.Item.Weapon.Launcher
import Dodge.Item.Weapon.SprayGuns
itemCombinations :: [([(Int,CombineType)],Item)]
itemCombinations =
[ po [PIPE, HARDWARE] (bangStick 1)
@@ -24,7 +26,7 @@ itemCombinations =
, po [BANGCANE,TIN] rifle
, po [RIFLE,SPRING,HARDWARE] autoRifle
, po [RIFLE,SPRING,CAN] assaultRifle
, po [BANGCANE,BANGCANE] miniGun
, po [MOTOR,BANGCANE,BANGCANE,BANGCANE] miniGun
, p [p 3 PIPE,o HARDWARE] bangRod
, po [BANGROD,PLANK,HARDWARE] elephantGun
@@ -33,6 +35,11 @@ itemCombinations =
, po [BANGROD,PLATE,DRUM,MOTOR] machineGun
, p [p 3 TUBE,o HARDWARE] launcher
, po [LIGHTER,PIPE,CAN] flameStick
, po [FLAMESTICK,CAN,PUMP] blowTorch
, po [FLAMESTICK,IRONBAR,DRUM] flameThrower
, po [FLAMESTICK,DRUM,DRUM] flameWall
]
++ map (\i -> po [PIPE,BANGSTICK i] $ bangStick (i+1)) [1..8]
++ map (\i -> po [REVOLVERX i,CAN] $ revolverX (i+1)) [1..5]
+3
View File
@@ -30,6 +30,9 @@ data CombineType
| AMR
| SNIPERRIFLE
| MACHINEGUN
| FLAMESTICK
| BLOWTORCH
| FLAMETHROWER
| AUTOGUN
| SPREADGUN
| MULTGUN
+1 -1
View File
@@ -1,6 +1,6 @@
module Dodge.Item.Consumable where
import Dodge.Data
import Dodge.Picture.Layer
--import Dodge.Picture.Layer
import Dodge.Default
import Dodge.SoundLogic
import Dodge.Inventory
+1 -1
View File
@@ -11,7 +11,7 @@ import qualified IntMapHelp as IM
import Dodge.Picture.Layer
import Picture
import ShapePicture
import Shape
--import Shape
import Data.Maybe
import Control.Lens
+287
View File
@@ -0,0 +1,287 @@
module Dodge.Item.Weapon.BulletGun.Cane
( bangCane
, bangCaneX
, rifle
, autoRifle
, assaultRifle
, miniGun
) where
import Dodge.Item.Weapon.BulletGun.Clip
import Dodge.Data
--import Dodge.ChainEffect
import Dodge.TweakBullet
import Dodge.Default.Weapon
import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Default
--import Dodge.Item.Attachment
--import Dodge.Item.Weapon.ExtraEffect
--import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Item.Weapon.AmmoParams
import Dodge.Item.Draw
import Dodge.Item.Weapon.Bullet
import Dodge.Item.Weapon.TriggerType
import Dodge.SoundLogic.LoadSound
import Picture
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.Monad.State
--import System.Random
bangCane :: Item
bangCane = defaultGun
{ _itName = "BANGCANE"
, _itType = BANGCANE
,_itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _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
]
, _itTweaks = defaultBulletSelTweak
, _itDimension = ItemDimension
{ _dimRad = 8
, _dimCenter = V3 5 0 0
, _dimPortage = HeldItem
{_handlePos = 5
,_muzPos = 20
}
, _dimSPic = \it -> noPic $ baseCaneShape
<> caneClip it
}
} & itUse . useAim . aimSpeed .~ 0.4
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ OneHand
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
caneClip :: Item -> Shape
caneClip it = case it ^? itConsumption . ammoLoaded of
Just 0 -> mempty
_ -> translateSH (V3 5 0 3) $ upperPrismPoly 1 $ square 1.5
bangCaneX :: Int -> Item
bangCaneX i = bangCane
{ _itName = "BANGCANEx"++show i
, _itType = BANGCANEX i
, _itUse = useAmmoParamsRate 6 upHammer
[ ammoHammerCheck
, useTimeCheck
, withSoundItemChoiceStart caneStickSoundChoice
, useAllAmmo
, torqueAfterI 0.5
, duplicateLoadedBarrels
, applyInaccuracy
, withMuzFlareI
, withRecoilI 50
]
, _itDimension = ItemDimension
{ _dimRad = 8
, _dimCenter = V3 5 0 0
, _dimPortage = HeldItem
{_handlePos = 5
,_muzPos = 15
}
, _dimSPic = \it -> noPic $
(colorSH red $ foldMap
(\y -> upperPrismPoly 3 $ map (+.+ V2 0 y) $ rectXH 15 2)
$ map (\k -> fromIntegral k * 5 - ((fromIntegral i - 1) * 2.5)) [0..i-1]
) <> caneClipX i it
}
} & itUse . useAim . aimSpeed .~ 0.4
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandFlat
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itConsumption . ammoMax .~ i
& itParams . gunBarrels .~ MultiBarrel
{_brlSpread = AlignedBarrels
,_brlNum = i
,_brlInaccuracy = 0.1
}
caneStickSoundChoice :: Item -> SoundID
caneStickSoundChoice it
| _ammoLoaded (_itConsumption it) < 2 = tap3S
| otherwise = shotgunS
caneClipX :: Int -> Item -> Shape
caneClipX i it = case it ^? itConsumption . ammoLoaded of
Just la | la > 0 -> foldMap
(\y -> translateSH (V3 5 0 3) . upperPrismPoly 1 $ map (+.+ V2 0 y) $ square 1.5)
$ map (\k -> fromIntegral k * 5 - ((fromIntegral i - 1) * 2.5)) [0..la-1]
_ -> mempty
rifle :: Item
rifle = bangCane
{ _itDimension = ItemDimension
{ _dimRad = 8
, _dimCenter = V3 5 0 0
, _dimPortage = HeldItem
{_handlePos = 5
,_muzPos = 25
}
, _dimSPic = \it -> noPic $ baseCaneShape
<> makeClipAt 0 (V3 10 (-2) 0) it
}
}
& itUse . useAim . aimStance .~ TwoHandTwist
& itName .~ "RIFLE"
& itType .~ RIFLE
& itConsumption . ammoMax .~ 15
& itConsumption . reloadType .~ ActiveClear
& itConsumption . reloadTime .~ 80
baseCaneShape :: Shape
baseCaneShape = colorSH red $ upperPrismPoly 3 $ rectXH 15 2
autoRifle :: Item
autoRifle = rifle
& itName .~ "AUTORIFLE"
& itType .~ AUTORIFLE
& itUse . useMods %~ ((ammoCheckI :) . tail)
-- & itUse . useDelay . rateMax .~ 6
assaultRifle :: Item
assaultRifle = rifle
& itName .~ "ASSAULTRIFLE"
& itType .~ 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
]
miniGun :: Item
miniGun = defaultAutoGun
{ _itName = "MINIGUN"
, _itType = MINIGUN
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 1500
, _ammoLoaded = 1500
, _reloadTime = 200
}
, _itUse = ruseInstant (useAmmoParamsVelMod vm4) NoHammer
[ ammoCheckI
, withWarmUp crankSlowS
--, afterRecoil recoilAmount
, withSoundForI mini1S 2
--, withThinSmokeI
, torqueAfterI 0.05
, withSidePushI 53
, afterRecoil recoilAmount
, withRandomOffsetI 12
, trigDoAlso (useAmmoParamsVelMod vm1)
--, torqueBeforeForcedI 0.001
, withSidePushI 52
, afterRecoil recoilAmount
, withRandomOffsetI 11
, withOldDir od1
, trigDoAlso (useAmmoParamsVelMod vm2)
--, torqueBeforeForcedI 0.001
, withSidePushI 51
, afterRecoil recoilAmount
, withRandomOffsetI 10
, withOldDir od2
, trigDoAlso (useAmmoParamsVelMod vm3)
--, torqueBeforeForcedI 0.001
, withSidePushI 50
, afterRecoil recoilAmount
, withRandomOffsetI 9
, withOldDir od3
, useAmmoAmount 4
, withMuzFlareI
, withSmoke 1 black 20 200 5
]
& useDelay .~ WarmUpNoDelay {_warmTime = 0,_warmMax = 200}
& useAim . aimSpeed .~ 0.4
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
-- , _itFloorPict = miniGunPictItem
, _itParams = BulletShooter
{ _muzVel = 1
, _rifling = 0.9
, _bore = 2
, _gunBarrels = MultiBarrel
{_brlSpread = RotatingBarrels 0.01
,_brlNum = 4
,_brlInaccuracy = 0
}
}
, _itEquipPict = pictureWeaponAim miniGunPictItem
, _itTweaks = defaultBulletSelTweak
, _itInvSize = 4
, _itInvDisplay = \it -> head (basicItemDisplay it) :
["*" ++ replicate 13 ' ' ++ "*"
,"* " ++ fromMaybe " " (maybeWarmupStatus it) ++ " *"
,"*" ++ replicate 13 ' ' ++ "*" ]
-- [" " ++ replicate 8 ch
-- ," " ++ replicate 2 ch ++ fromMaybe " " (maybeWarmupStatus it) ++ replicate 2 ch
-- ," " ++ replicate 8 ch]
}
where
--ch = '*'
recoilAmount = 5
[vm1,vm2,vm3,vm4] =
[ 0.25
, 0.5
, 0.75
, 1
]
[od1,od2,od3] =
[ 0.25, 0.5, 0.9]
--[ 0.75, 0.5, 0.25]
--[ 0, 0, 0]
miniGunPictItem :: Item -> SPic
miniGunPictItem it = miniGunPict spin (_ammoLoaded $ _itConsumption it)
where
spin = (-10) * _ammoLoaded (_itConsumption it) + _warmTime (_useDelay $ _itUse it)
miniGunPict :: Int -> Int -> SPic
miniGunPict spin am =
( colorSH red (rotateSHx a barrels)
<> colorSH red (upperPrismPoly 5 $ rectNESW 8 8 (-8) 4)
<> colorSH red (prismPoly
(map (addZ 5) $ rectNESW 2 12 (-2) (-12))
(map (addZ 0) $ rectNESW 4 12 (-4) (-16))
)
<> clip (-1) 0
<> clip (-7) 0
, mempty
)
where
aBarrel = translateSH (V3 7 0 9) $ prismPoly
(map (addZ 5) $ rectNESW 2 12 (-2) (-1))
(map (addZ 0) $ rectNESW 4 12 (-4) (-5))
barrels = concatMap (\an -> aBarrel & rotateSHx an) [0,0.5* pi, pi, 1.5*pi]
a = fromIntegral spin / 100
x = fromIntegral am / 10
clip y z = translateSH (V3 0 (-1) z) (rotateSHx (negate $ pi/4)
. upperPrismPoly 2
$ rectNESW (negate $ 3 + 0.25 * x) y 3 (y-5))
+12
View File
@@ -0,0 +1,12 @@
module Dodge.Item.Weapon.BulletGun.Clip where
import Dodge.Data
import Shape
import Geometry
import Data.Maybe
import Control.Lens
makeClipAt :: Float -> Point3 -> Item -> Shape
makeClipAt r p it = translateSH p . overPosSH (rotate3z r) $ upperPrismPoly 1 $ rectNSEW 0 (-y) (-2) 2
where
y = fromIntegral y' * 0.3
y' = fromMaybe 0 $ it ^? itConsumption . ammoLoaded
+215
View File
@@ -0,0 +1,215 @@
module Dodge.Item.Weapon.BulletGun.Stick
( bangStick
, pistol
, autoPistol
, machinePistol
, smg
, revolver
, revolverX
) where
import Dodge.Item.Weapon.BulletGun.Clip
import Dodge.Data
import Dodge.ChainEffect
import Dodge.TweakBullet
import Dodge.Default.Weapon
--import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Default
--import Dodge.Item.Attachment
--import Dodge.Item.Weapon.ExtraEffect
--import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Item.Weapon.AmmoParams
--import Dodge.Item.Draw
import Dodge.Item.Weapon.Bullet
import Dodge.Item.Weapon.TriggerType
import Dodge.SoundLogic.LoadSound
import Picture
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.Monad.State
--import System.Random
bangStickSoundChoice :: Item -> SoundID
bangStickSoundChoice it
| _ammoLoaded (_itConsumption it) < 2 = tap3S
| otherwise = shotgunS
bangStick :: Int -> Item
bangStick i = defaultGun
{ _itName = case i of
1 -> "BANGSTICK"
_ -> "BANGSTICKx"++ show i
, _itType = BANGSTICK i
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = i
, _reloadTime = 15
, _reloadType = ActivePartial 1
}
, _itUse = useAmmoParamsRate 8 upHammer
[ ammoHammerCheck
, useTimeCheck
, withSoundItemChoiceStart bangStickSoundChoice
, useAllAmmo
-- , applyInaccuracy
, withMuzFlareI
, spreadLoaded
, withRecoilI 25
]
, _itID = Nothing
, _itInvColor = white
, _itTargeting = Nothing
, _itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 0.8
, _bore = 2
, _gunBarrels = MultiBarrel
{_brlNum = i
,_brlSpread = SpreadBarrels 0.2
,_brlInaccuracy = 0
}
}
, _itTweaks = defaultBulletSelTweak
, _itInvSize = fromIntegral i / 3
, _itDimension = ItemDimension
{ _dimRad = 5
, _dimCenter = V3 5 0 0
, _dimPortage = HeldItem
{_handlePos = 5
,_muzPos = 10
}
, _dimSPic = \it -> noPic $ baseStickShape
<> stickClip it
}
}
baseStickShape :: Shape
baseStickShape = colorSH green $ upperPrismPoly 3 $ rectXH 10 2
stickClip :: Item -> Shape
stickClip it = case it ^? itConsumption . ammoLoaded of
Just 0 -> mempty
_ -> translateSH (V3 5 0 3) $ upperPrismPoly 1 $ square 1.5
revolver :: Item
revolver = pistol
{ _itName = "REVOLVER"
, _itType = REVOLVER
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 6
, _ammoLoaded = 0
, _reloadTime = 15
, _reloadType = ActivePartial 1
}
}
& itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> revolverClip it)
revolverClip :: Item -> Shape
revolverClip it = case it ^? itConsumption . ammoLoaded of
Just al | al > 0 -> translateSH (V3 5 0 1) $ foldMap f [1..al]
_ -> mempty
where
f i = rotateSHx (fromIntegral i * pi / 3 + pi/6) . translateSH (V3 0 0 2) $ upperPrismPoly 1 $ square 1
pistolAfterHamMods :: [ChainEffect]
pistolAfterHamMods =
[ useTimeCheck
, useAmmoAmount 1
, withSoundStart tap3S
, applyInaccuracy
, torqueAfterI 0.2
, withRecoilI 10
, withSidePushI 50
, withMuzFlareI
]
machinePistolAfterHamMods :: [ChainEffect]
machinePistolAfterHamMods =
[ useTimeCheck
, useAmmoAmount 1
, withSoundStart tap1S
, applyInaccuracy
, torqueAfterI 0.3
, withSidePushI 50
, withRecoilI 20
, withMuzFlareI
]
smgAfterHamMods :: [ChainEffect]
smgAfterHamMods =
[ useTimeCheck
, useAmmoAmount 1
, withSoundStart tap3S
, applyInaccuracy
, torqueAfterI 0.05
, withRecoilI 10
, withSidePushI 30
, withMuzFlareI
]
pistol :: Item
pistol = (bangStick 1)
{ _itName = "PISTOL"
, _itType = PISTOL
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 15
, _ammoLoaded = 0
, _reloadTime = 70
, _reloadType = ActiveClear
}
, _itUse = useAmmoParamsRate 6 upHammer
(ammoHammerCheck : pistolAfterHamMods)
-- , _itZoom = defaultItZoom
-- , _itEquipPict = pictureWeaponAim pistolPic
, _itID = Nothing
, _itInvColor = white
, _itTargeting = Nothing
, _itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 0.8
, _bore = 2
, _gunBarrels = SingleBarrel 0.05
}
, _itTweaks = defaultBulletSelTweak
} & itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> makeClipAt pi (V3 5 2 0) it)
autoPistol :: Item
autoPistol = pistol
& itUse . useMods .~ (ammoCheckI : pistolAfterHamMods)
& itName .~ "AUTOPISTOL"
& itType .~ AUTOPISTOL
machinePistol :: Item
machinePistol = autoPistol
& itUse . useDelay . rateMax .~ 2
& itUse . useMods .~ (ammoCheckI : machinePistolAfterHamMods)
& itName .~ "MACHINEPISTOL"
& itType .~ MACHINEPISTOL
smg :: Item
smg = autoPistol -- & some parameter affecting stability
& itUse . useMods .~ (ammoCheckI : smgAfterHamMods)
& itName .~ "SMG"
& itType .~ SMG
& itUse . useAim . aimStance .~ TwoHandTwist
revolverX :: Int -> Item
revolverX i = revolver
{ _itName = "REVx"++show i
, _itType = REVOLVERX i
, _itUse = useAmmoParamsRate 8 upHammer
[ ammoHammerCheck
, useTimeCheck
-- rather than locking the inventory, a better solution may be to check
-- that the weapon is still in your hands in the repeated frames
, lockInvFor 10
, \f it -> repeatOnFrames (take (_ammoLoaded (_itConsumption it) - 1) [2,4,6,8,10]) f it
, withSoundStart tap3S
, useAmmoUpTo 1
, applyInaccuracy
, withMuzFlareI
-- , spreadLoaded
, torqueAfterI 0.2
, withRecoilI 10
]
} & itConsumption . ammoMax .~ i * 6
+13 -421
View File
@@ -1,24 +1,9 @@
module Dodge.Item.Weapon.BulletGuns
( pistol
, autoPistol
, machinePistol
, smg
, revolver
, revolverX
, bangStick
, bangRod
( bangRod
, elephantGun
, amr
, sniperRifle
, machineGun
, bangCane
, bangCaneX
, rifle
, autoRifle
, assaultRifle
, autoGun
, multGun
, miniGun
, bangCone
, blunderbuss
, grapeShotCannon
@@ -27,12 +12,18 @@ module Dodge.Item.Weapon.BulletGuns
, ltAutoGun
, hvAutoGun
, autogunSpread
, autoGun
, multGun
, autoGunPic
, longGun
)
where
, module Dodge.Item.Weapon.BulletGun.Stick
, module Dodge.Item.Weapon.BulletGun.Cane
) where
import Dodge.Item.Weapon.BulletGun.Stick
import Dodge.Item.Weapon.BulletGun.Cane
--import Dodge.Item.Weapon.BulletGun.Clip
import Dodge.Data
import Dodge.ChainEffect
--import Dodge.ChainEffect
import Dodge.TweakBullet
import Dodge.Default.Weapon
import Dodge.Item.Weapon.InventoryDisplay
@@ -49,7 +40,7 @@ import Picture
import Geometry
import ShapePicture
import Shape
import Sound.Data
--import Sound.Data
import LensHelp
import Data.Maybe
@@ -112,189 +103,8 @@ autoGunPic it = noPic $
where
x = fromIntegral $ _ammoLoaded $ _itConsumption it
bangStickSoundChoice :: Item -> SoundID
bangStickSoundChoice it
| _ammoLoaded (_itConsumption it) < 2 = tap3S
| otherwise = shotgunS
bangStick :: Int -> Item
bangStick i = defaultGun
{ _itName = case i of
1 -> "BANGSTICK"
_ -> "BANGSTICKx"++ show i
, _itType = BANGSTICK i
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = i
, _reloadTime = 15
, _reloadType = ActivePartial 1
}
, _itUse = useAmmoParamsRate 8 upHammer
[ ammoHammerCheck
, useTimeCheck
, withSoundItemChoiceStart bangStickSoundChoice
, useAllAmmo
-- , applyInaccuracy
, withMuzFlareI
, spreadLoaded
, withRecoilI 25
]
-- , _itZoom = defaultItZoom
-- , _itEquipPict = pictureWeaponAim pistolPic
, _itID = Nothing
, _itInvColor = white
, _itTargeting = Nothing
, _itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 0.8
, _bore = 2
, _gunBarrels = MultiBarrel
{_brlNum = i
,_brlSpread = SpreadBarrels 0.2
,_brlInaccuracy = 0
}
}
, _itTweaks = defaultBulletSelTweak
, _itInvSize = fromIntegral i / 3
, _itDimension = ItemDimension
{ _dimRad = 5
, _dimCenter = V3 5 0 0
, _dimPortage = HeldItem
{_handlePos = 5
,_muzPos = 10
}
, _dimSPic = const $ noPic $ colorSH green $ upperPrismPoly 3 $ rectXH 10 2
}
}
bangCane :: Item
bangCane = defaultGun
{ _itName = "BANGCANE"
, _itType = BANGCANE
,_itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _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
]
, _itTweaks = defaultBulletSelTweak
, _itDimension = ItemDimension
{ _dimRad = 8
, _dimCenter = V3 5 0 0
, _dimPortage = HeldItem
{_handlePos = 5
,_muzPos = 20
}
, _dimSPic = const $ noPic $ colorSH red $ upperPrismPoly 3 $ rectXH 15 2
}
} & itUse . useAim . aimSpeed .~ 0.4
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ OneHand
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
bangCaneX :: Int -> Item
bangCaneX i = bangCane
{ _itName = "BANGCANEx"++show i
, _itType = BANGCANEX i
, _itUse = useAmmoParamsRate 6 upHammer
[ ammoHammerCheck
, useTimeCheck
, withSoundItemChoiceStart bangStickSoundChoice
, useAllAmmo
, torqueAfterI 0.5
, duplicateLoadedBarrels
, applyInaccuracy
, withMuzFlareI
, withRecoilI 50
]
, _itDimension = ItemDimension
{ _dimRad = 8
, _dimCenter = V3 5 0 0
, _dimPortage = HeldItem
{_handlePos = 5
,_muzPos = 15
}
, _dimSPic = const $ noPic $ colorSH red $ foldMap
(\y -> upperPrismPoly 3 $ map (+.+ V2 0 y) $ rectXH 15 2)
$ map (\k -> fromIntegral k * 5 - ((fromIntegral i - 1) * 2.5)) [0..i-1]
}
} & itUse . useAim . aimSpeed .~ 0.4
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandFlat
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itConsumption . ammoMax .~ i
& itParams . gunBarrels .~ MultiBarrel
{_brlSpread = AlignedBarrels
,_brlNum = i
,_brlInaccuracy = 0.1
}
rifle :: Item
rifle = bangCane
{ _itDimension = ItemDimension
{ _dimRad = 8
, _dimCenter = V3 5 0 0
, _dimPortage = HeldItem
{_handlePos = 5
,_muzPos = 25
}
, _dimSPic = \it -> noPic $ (colorSH red $ upperPrismPoly 3 $ rectXH 25 2)
<> makeClipAt (V3 10 (-2) 0) it
}
}
& itUse . useAim . aimStance .~ TwoHandTwist
& itName .~ "RIFLE"
& itType .~ RIFLE
& itConsumption . ammoMax .~ 15
& itConsumption . reloadType .~ ActiveClear
& itConsumption . reloadTime .~ 80
makeClipAt :: Point3 -> Item -> Shape
makeClipAt p it = translateSH p $ upperPrismPoly 1 $ rectNSEW 0 (-y) (-2) 2
where
y = fromIntegral y' * 0.3
y' = fromMaybe 0 $ it ^? itConsumption . ammoLoaded
autoRifle :: Item
autoRifle = rifle
& itName .~ "AUTORIFLE"
& itType .~ AUTORIFLE
& itUse . useMods %~ ((ammoCheckI :) . tail)
-- & itUse . useDelay . rateMax .~ 6
assaultRifle :: Item
assaultRifle = rifle
& itName .~ "ASSAULTRIFLE"
& itType .~ 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 = defaultGun
{ _itName = "BANGROD"
, _itType = BANGROD
, _itParams = BulletShooter
@@ -359,26 +169,6 @@ machineGun = bangRod
& itName .~ "MACHINEGUN"
& itType .~ MACHINEGUN
revolverX :: Int -> Item
revolverX i = revolver
{ _itName = "REVx"++show i
, _itType = REVOLVERX i
, _itUse = useAmmoParamsRate 8 upHammer
[ ammoHammerCheck
, useTimeCheck
-- rather than locking the inventory, a better solution may be to check
-- that the weapon is still in your hands in the repeated frames
, lockInvFor 10
, \f it -> repeatOnFrames (take (_ammoLoaded (_itConsumption it) - 1) [2,4,6,8,10]) f it
, withSoundStart tap3S
, useAmmoUpTo 1
, applyInaccuracy
, withMuzFlareI
-- , spreadLoaded
, torqueAfterI 0.2
, withRecoilI 10
]
} & itConsumption . ammoMax .~ i * 6
bangCone :: Item
bangCone = defaultGun
{ _itName = "BANGCONE"
@@ -484,6 +274,7 @@ grapeShotCannon = blunderbuss
, withRandomItemParams coneRandItemParams
]
& useAim . aimStance .~ TwoHandTwist
& useAim . aimSpeed .~ 0.4
}
& itConsumption . ammoMax .~ 15
& itConsumption . reloadTime .~ 30
@@ -491,79 +282,6 @@ grapeShotCannon = blunderbuss
grenadeLauncher :: Int -> Item
grenadeLauncher _ = bangCone
revolver :: Item
revolver = pistol
{ _itName = "REVOLVER"
, _itType = REVOLVER
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 6
, _ammoLoaded = 0
, _reloadTime = 15
, _reloadType = ActivePartial 1
}
}
pistolAfterHamMods :: [ChainEffect]
pistolAfterHamMods =
[ useTimeCheck
, useAmmoAmount 1
, withSoundStart tap3S
, applyInaccuracy
, torqueAfterI 0.2
, withRecoilI 10
, withSidePushI 50
, withMuzFlareI
]
machinePistolAfterHamMods :: [ChainEffect]
machinePistolAfterHamMods =
[ useTimeCheck
, useAmmoAmount 1
, withSoundStart tap1S
, applyInaccuracy
, torqueAfterI 0.3
, withSidePushI 50
, withRecoilI 20
, withMuzFlareI
]
smgAfterHamMods :: [ChainEffect]
smgAfterHamMods =
[ useTimeCheck
, useAmmoAmount 1
, withSoundStart tap3S
, applyInaccuracy
, torqueAfterI 0.05
, withRecoilI 10
, withSidePushI 30
, withMuzFlareI
]
pistol :: Item
pistol = defaultGun
{ _itName = "PISTOL"
, _itType = PISTOL
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 15
, _ammoLoaded = 0
, _reloadTime = 70
, _reloadType = ActiveClear
}
, _itUse = useAmmoParamsRate 6 upHammer
(ammoHammerCheck : pistolAfterHamMods)
-- , _itZoom = defaultItZoom
-- , _itEquipPict = pictureWeaponAim pistolPic
, _itID = Nothing
, _itInvColor = white
, _itTargeting = Nothing
, _itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 0.8
, _bore = 2
, _gunBarrels = SingleBarrel 0.05
}
, _itTweaks = defaultBulletSelTweak
}
hvAutoGun :: Item
@@ -595,23 +313,6 @@ hvAutoGun = defaultAutoGun
,"* " ++ fromMaybe " " (maybeRateStatus it) ++ " *"
]
}
autoPistol :: Item
autoPistol = pistol
& itUse . useMods .~ (ammoCheckI : pistolAfterHamMods)
& itName .~ "AUTOPISTOL"
& itType .~ AUTOPISTOL
machinePistol :: Item
machinePistol = autoPistol
& itUse . useDelay . rateMax .~ 2
& itUse . useMods .~ (ammoCheckI : machinePistolAfterHamMods)
& itName .~ "MACHINEPISTOL"
& itType .~ MACHINEPISTOL
smg :: Item
smg = autoPistol -- & some parameter affecting stability
& itUse . useMods .~ (ammoCheckI : smgAfterHamMods)
& itName .~ "SMG"
& itType .~ SMG
& itUse . useAim . aimStance .~ TwoHandTwist
ltAutoGun :: Item
ltAutoGun = defaultAutoGun
{ _itName = "AUTO-LT"
@@ -641,115 +342,6 @@ ltAutoGun = defaultAutoGun
}
, _itTweaks = defaultBulletSelTweak
}
miniGun :: Item
miniGun = defaultAutoGun
{ _itName = "MINIGUN"
, _itType = MINIGUN
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 1500
, _ammoLoaded = 1500
, _reloadTime = 200
}
, _itUse = ruseInstant (useAmmoParamsVelMod vm4) NoHammer
[ ammoCheckI
, withWarmUp crankSlowS
--, afterRecoil recoilAmount
, withSoundForI mini1S 2
--, withThinSmokeI
, torqueAfterI 0.05
, withSidePushI 53
, afterRecoil recoilAmount
, withRandomOffsetI 12
, trigDoAlso (useAmmoParamsVelMod vm1)
--, torqueBeforeForcedI 0.001
, withSidePushI 52
, afterRecoil recoilAmount
, withRandomOffsetI 11
, withOldDir od1
, trigDoAlso (useAmmoParamsVelMod vm2)
--, torqueBeforeForcedI 0.001
, withSidePushI 51
, afterRecoil recoilAmount
, withRandomOffsetI 10
, withOldDir od2
, trigDoAlso (useAmmoParamsVelMod vm3)
--, torqueBeforeForcedI 0.001
, withSidePushI 50
, afterRecoil recoilAmount
, withRandomOffsetI 9
, withOldDir od3
, useAmmoAmount 4
, withMuzFlareI
, withSmoke 1 black 20 200 5
]
& useDelay .~ WarmUpNoDelay {_warmTime = 0,_warmMax = 200}
& useAim . aimSpeed .~ 0.4
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
-- , _itFloorPict = miniGunPictItem
, _itParams = BulletShooter
{ _muzVel = 1
, _rifling = 0.9
, _bore = 2
, _gunBarrels = MultiBarrel
{_brlSpread = RotatingBarrels 0.01
,_brlNum = 4
,_brlInaccuracy = 0
}
}
, _itEquipPict = pictureWeaponAim miniGunPictItem
, _itTweaks = defaultBulletSelTweak
, _itInvSize = 4
, _itInvDisplay = \it -> head (basicItemDisplay it) :
["*" ++ replicate 13 ' ' ++ "*"
,"* " ++ fromMaybe " " (maybeWarmupStatus it) ++ " *"
,"*" ++ replicate 13 ' ' ++ "*" ]
-- [" " ++ replicate 8 ch
-- ," " ++ replicate 2 ch ++ fromMaybe " " (maybeWarmupStatus it) ++ replicate 2 ch
-- ," " ++ replicate 8 ch]
}
where
--ch = '*'
recoilAmount = 5
[vm1,vm2,vm3,vm4] =
[ 0.25
, 0.5
, 0.75
, 1
]
[od1,od2,od3] =
[ 0.25, 0.5, 0.9]
--[ 0.75, 0.5, 0.25]
--[ 0, 0, 0]
miniGunPictItem :: Item -> SPic
miniGunPictItem it = miniGunPict spin (_ammoLoaded $ _itConsumption it)
where
spin = (-10) * _ammoLoaded (_itConsumption it) + _warmTime (_useDelay $ _itUse it)
miniGunPict :: Int -> Int -> SPic
miniGunPict spin am =
( colorSH red (rotateSHx a barrels)
<> colorSH red (upperPrismPoly 5 $ rectNESW 8 8 (-8) 4)
<> colorSH red (prismPoly
(map (addZ 5) $ rectNESW 2 12 (-2) (-12))
(map (addZ 0) $ rectNESW 4 12 (-4) (-16))
)
<> clip (-1) 0
<> clip (-7) 0
, mempty
)
where
aBarrel = translateSH (V3 7 0 9) $ prismPoly
(map (addZ 5) $ rectNESW 2 12 (-2) (-1))
(map (addZ 0) $ rectNESW 4 12 (-4) (-5))
barrels = concatMap (\an -> aBarrel & rotateSHx an) [0,0.5* pi, pi, 1.5*pi]
a = fromIntegral spin / 100
x = fromIntegral am / 10
clip y z = translateSH (V3 0 (-1) z) (rotateSHx (negate $ pi/4)
. upperPrismPoly 2
$ rectNESW (negate $ 3 + 0.25 * x) y 3 (y-5))
spreadGun :: Item
spreadGun = defaultGun
{ _itName = "SPREAD"
+1 -1
View File
@@ -1,6 +1,6 @@
module Dodge.Item.Weapon.Radar where
import Dodge.Data
import Dodge.Picture.Layer
--import Dodge.Picture.Layer
import Dodge.Default
import Dodge.Item.Draw
import Dodge.Item.Weapon.TriggerType
+24 -4
View File
@@ -1,8 +1,11 @@
module Dodge.Item.Weapon.SprayGuns
( poisonSprayer
, flamer
)
where
, flameStick
, blowTorch
, flameThrower
, flameWall
) where
import Dodge.Data
--import Dodge.Data.SoundOrigin
--import Dodge.Base
@@ -52,21 +55,38 @@ poisonSprayer = defaultAutoGun
{ _nozzleSpread = 0.2
, _nozzleNum = 3
}
, _itDimension = ItemDimension
{ _dimRad = 7
, _dimCenter = V3 9 0 0
, _dimPortage = HeldItem
{ _handlePos = 5
, _muzPos = 18
}
, _dimSPic = flamerPic
}
-- , _itFloorPict = flamerPic
}
flamerPic :: Item -> SPic
flamerPic it =
( colorSH yellow $
translateSHf tx ty (upperPrismPoly tz $ polyCirc 3 r)
++ upperPrismPoly 5 (rectNESW 2 9 (-2) (-9))
++ upperPrismPoly 5 (rectNESW 2 18 (-2) 0)
, color black $ translate3 (V3 tx ty (tz+0.01)) $ circleSolid (r * am)
)
where
tx = - 5
tx = 4
ty = - 6
tz = 3
r = 5
am = fractionLoadedAmmo2 it
flameStick :: Item
flameStick = undefined
blowTorch :: Item
blowTorch = undefined
flameThrower :: Item
flameThrower = undefined
flameWall :: Item
flameWall = undefined
flamer :: Item
flamer = defaultAutoGun
{ _itName = "FLAMER"
+1 -1
View File
@@ -2,7 +2,7 @@ module Dodge.Item.Weapon.Utility where
import Dodge.Data
--import Dodge.Base
import Dodge.Default
import Dodge.Picture.Layer
--import Dodge.Picture.Layer
import Dodge.Creature.Action
import Dodge.Item.Weapon.TriggerType
import Dodge.Default.Weapon