Files
loop/src/Dodge/Item/Weapon/BulletGun/Cane.hs
T
2022-02-28 21:36:42 +00:00

330 lines
9.9 KiB
Haskell

module Dodge.Item.Weapon.BulletGun.Cane
( bangCane
, bangCaneX
, repeater
, rifle
, autoRifle
, burstRifle
, completeBurstRifle
, fastBurstRifle
, miniGunX
) where
--import Dodge.Particle.Bullet.HitEffect
--import Dodge.WorldEvent.HitEffect
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.Map.Strict as M
--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
{ _brlInaccuracy = 0.01
}
}
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoBaseMax = 1
, _reloadTime = 20
, _reloadType = ActivePartial 1
}
, _itUse = ruseAmmoParamsRate 6 upHammer
[ ammoHammerCheck
, useTimeCheck
, withSoundStart tap3S
, useAmmoAmount 1
, torqueAfterI 0.1
, applyInaccuracy
, withRecoilI 50
, withSmoke 1 black 20 200 5
, withMuzFlareI
]
, _itTweaks = defaultBulletSelTweak
, _itDimension = ItemDimension
{ _dimRad = 8
, _dimCenter = V3 5 0 0
, _dimPortage = HeldItem
{_handlePos = 5
,_muzPos = 15
}
, _dimSPic = \it -> noPic $ baseCaneShape
<> makeSingleClipAt (V3 5 0 3) it
}
} & 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 = ruseAmmoParamsRate 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)
. (\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 . ammoBaseMax .~ 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)
. (\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 = 15
}
, _dimSPic = \it -> noPic $ baseRifleShape
<> makeSingleClipAt (V3 5 0 3) it
}
}
& itUse . useAim . aimStance .~ TwoHandTwist
& itName .~ "RIFLE"
& itType .~ RIFLE
& itConsumption . ammoBaseMax .~ 1
repeater :: Item
repeater = rifle
& itModules . at ModRifleMag ?~ DefaultModule
& itName .~ "REPEATER"
& itType .~ REPEATER
& itConsumption . reloadType .~ ActiveClear
& itConsumption . reloadTime .~ 80
& itConsumption . ammoBaseMax .~ 15
& itDimension . dimSPic .~ (\it -> noPic $ baseRifleShape
<> makeTinClipAt 0 (V3 10 (-2) 0) it
)
baseCaneShape :: Shape
baseCaneShape = colorSH red $ upperPrismPoly 3 $ rectXH 15 1.5
baseRifleShape :: Shape
baseRifleShape = colorSH red $ upperPrismPoly 3 $ rectXH 25 2
autoRifle :: Item
autoRifle = repeater
& itName .~ "AUTORIFLE"
& itType .~ AUTORIFLE
& itUse . useMods %~ ((ammoCheckI :) . tail)
& itModules . at ModAutoMag ?~ DefaultModule
-- & itUse . useDelay . rateMax .~ 6
burstRifle :: Item
burstRifle = repeater
& itName .~ "BURSTRIFLE"
& itType .~ BURSTRIFLE
& itParams . gunBarrels . brlInaccuracy .~ 0.05
& itUse . useDelay . rateMax .~ 18
& itUse . useMods .~
[ ammoHammerCheck
, useTimeCheck
, sideEffectOnFrame 7 (torqueSideEffect 0.2)
, lockInvFor 7
, \f it -> repeatOnFrames (take (_ammoLoaded (_itConsumption it) - 1) [3,6]) f it
, withSoundStart tap3S
, useAmmoAmount 1
, applyInaccuracy
, withMuzFlareI
, withRecoilI 50
]
fastBurstRifle :: Item
fastBurstRifle = repeater
& itName .~ "FASTBURSTRIFLE"
& itType .~ FASTBURSTRIFLE
& itParams . gunBarrels . brlInaccuracy .~ 0.06
& itUse . useDelay . rateMax .~ 18
& itUse . useMods .~
[ ammoHammerCheck
, useTimeCheck
, sideEffectOnFrame 9 (torqueSideEffect 0.4)
, lockInvFor 9
, \f it -> repeatOnFrames (take (_ammoLoaded (_itConsumption it) - 1) [2,4,6,8]) f it
, withSoundStart tap3S
, useAmmoAmount 1
, applyInaccuracy
, withMuzFlareI
, withRecoilI 50
]
completeBurstRifle :: Item
completeBurstRifle = repeater
& itName .~ "COMPLETEBURSTRIFLE"
& itType .~ COMPLETEBURSTRIFLE
& itModules . at ModRifleMag .~ Nothing
& itParams . gunBarrels . brlInaccuracy .~ 0.1
& itUse . useDelay . rateMax .~ 28
& itUse . useMods .~
[ ammoHammerCheck
, useTimeCheck
, sideEffectOnFrame 15 (torqueSideEffect 0.8)
, lockInvFor 15
, \f it -> repeatOnFrames (take (_ammoLoaded (_itConsumption it) - 1) [1..14]) f it
, withSoundStart tap3S
, useAmmoAmount 1
, applyInaccuracy
, withMuzFlareI
, withRecoilI 50
]
miniGunUse :: Int -> ItemUse
miniGunUse i = ruseInstant (useAmmoParams $ Just 1) NoHammer $
[ ammoCheckI
, withWarmUp crankSlowS
, withSoundForI mini1S 2
--, withThinSmokeI
, withSmoke 1 black 20 200 5
, withMuzFlareI
, useAmmoAmount i
] <>
concat [
[ withSidePushI 50
, torqueBefore 0.05
, afterRecoil recoilAmount
, withRandomOffsetI 10
, withOldDir x
, trigDoAlso (useAmmoParams $ Just x)
] | x <- map ((/fromIntegral i) . fromIntegral) [1..i-1]
]
<>
[ withSidePushI 50
, afterRecoil recoilAmount
, withRandomOffsetI 10
]
where
recoilAmount = 5
miniGunX :: Int -> Item
miniGunX i = defaultAutoGun
{ _itName = "MINIGUN-" ++ show i
, _itType = MINIGUNX i
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoBaseMax = 1500
, _ammoLoaded = 1500
, _reloadTime = 200
}
, _itUse = miniGunUse i
& 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 = i
,_brlInaccuracy = 0
}
}
, _itEquipPict = pictureWeaponAim (miniGunXPictItem i)
, _itTweaks = defaultBulletSelTweak
, _itInvSize = 4
, _itInvDisplay = \it -> head (basicItemDisplay it) :
["*" ++ replicate 13 ' ' ++ "*"
,"* " ++ fromMaybe " " (maybeWarmupStatus it) ++ " *"
,"*" ++ replicate 13 ' ' ++ "*" ]
++ moduleStrings it
, _itDimension = ItemDimension
{ _dimRad = 20
, _dimCenter = V3 5 0 0
, _dimPortage = HeldItem
{_handlePos = 5
,_muzPos = 20
}
, _dimSPic = miniGunXPictItem i
}
}
& itDimension . dimPortage . muzPos .~ 40
miniGunXPictItem :: Int -> Item -> SPic
miniGunXPictItem i it = miniGunXPict i spin (_ammoLoaded $ _itConsumption it)
where
spin = (-10) * _ammoLoaded (_itConsumption it) + _warmTime (_useDelay $ _itUse it)
miniGunXPict :: Int -> Int -> Int -> SPic
miniGunXPict i spin _ =
( colorSH red (rotateSHx a barrels)
<> baseRifleShape
-- <> clip (-1) 0
-- <> clip (-7) 0
, mempty
)
where
aBarrel = translateSH (V3 15 2 2) baseCaneShape
barrels = concatMap (\an -> aBarrel & rotateSHx (2*pi * fromIntegral an / fromIntegral i)) [1..i]
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))