455 lines
13 KiB
Haskell
455 lines
13 KiB
Haskell
module Dodge.Item.Weapon.BulletGuns
|
|
( pistol
|
|
, autoGun
|
|
, multGun
|
|
, miniGun
|
|
, spreadGun
|
|
, ltAutoGun
|
|
, hvAutoGun
|
|
, autogunSpread
|
|
, autoGunPic
|
|
, longGun
|
|
)
|
|
where
|
|
import Dodge.Data
|
|
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 Data.Maybe
|
|
import qualified Data.Sequence as Seq
|
|
import Control.Lens
|
|
|
|
autoGun :: Item
|
|
autoGun = defaultAutoGun
|
|
{ _itName = "AUTOGUN"
|
|
, _itIdentity = AutoGun
|
|
, _itConsumption = defaultAmmo
|
|
{ _aoType = basicBullet
|
|
, _ammoMax = 30
|
|
, _ammoLoaded = 30
|
|
, _reloadTime = 80
|
|
}
|
|
, _itUse = useAmmoParamsRate 4 NoHammer
|
|
[ ammoCheckI
|
|
, charFiringStratI
|
|
[('S', hammerCheckI)
|
|
]
|
|
, useTimeCheck
|
|
, charFiringStratI
|
|
[('M', torqueBefore 0.08)
|
|
,('S', torqueBefore 0.05)
|
|
]
|
|
, withSoundForI autoBS 5
|
|
--, withSoundForI seagullChatterS 5
|
|
, useAmmo 1
|
|
, applyInaccuracy
|
|
, withMuzFlareI
|
|
, withSmoke 1 black 20 200 5
|
|
]
|
|
& useAim . aimSpeed .~ 0.4
|
|
& useAim . aimRange .~ 1
|
|
& useAim . aimStance .~ TwoHandTwist
|
|
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
|
|
, _itFloorPict = autoGunPic
|
|
-- , _itZoom = defaultItZoom
|
|
, _itEquipPict = pictureWeaponOnAim
|
|
, _itAttachment = ItCharMode $ Seq.fromList "MS"
|
|
, _itScroll = scrollCharMode
|
|
, _itInvDisplay = basicWeaponDisplay
|
|
, _itParams = BulletShooter
|
|
{ _muzVel = 1
|
|
, _bore = 2
|
|
, _gunBarrels = SingleBarrel 0.1
|
|
}
|
|
, _itTweaks = defaultBulletSelTweak
|
|
}
|
|
autoGunPic :: Item -> SPic
|
|
autoGunPic it = noPic $
|
|
colorSH red (prismPoly
|
|
(map (addZ 5) $ rectNESW 2 12 (-2) (-8))
|
|
(map (addZ 0) $ rectNESW 4 12 (-4) (-12))
|
|
)
|
|
<> translateSHf 0 (-1) (rotateSHx (negate $ pi/4) . upperPrismPoly 2 $ rectNESW (negate $ 3 + 0.25 * x) 0 3 (-5))
|
|
where
|
|
x = fromIntegral $ _ammoLoaded $ _itConsumption it
|
|
|
|
pistol :: Item
|
|
pistol = defaultGun
|
|
{ _itName = "PISTOL"
|
|
, _itIdentity = Pistol
|
|
, _itConsumption = defaultAmmo
|
|
{ _aoType = basicBullet
|
|
, _ammoMax = 15
|
|
, _ammoLoaded = 15
|
|
, _reloadTime = 10
|
|
, _reloadType = PartialActive 1
|
|
}
|
|
, _itUse = useAmmoParamsRate 8 upHammer
|
|
[ ammoCheckI
|
|
, hammerCheckI
|
|
, useTimeCheck
|
|
, withSoundStart tap3S
|
|
, useAmmo 1
|
|
, applyInaccuracy
|
|
, withMuzFlareI
|
|
]
|
|
, _itFloorPict = pistolPic
|
|
-- , _itZoom = defaultItZoom
|
|
, _itEquipPict = pictureWeaponAim pistolPic
|
|
, _itID = Nothing
|
|
, _itInvDisplay = basicWeaponDisplay
|
|
, _itInvColor = white
|
|
, _itTargeting = Nothing
|
|
, _itParams = BulletShooter
|
|
{ _muzVel = 0.8
|
|
, _bore = 2
|
|
, _gunBarrels = SingleBarrel 0.05
|
|
}
|
|
, _itTweaks = defaultBulletSelTweak
|
|
}
|
|
pistolPic :: Item -> SPic
|
|
pistolPic it = noPic $ colorSH green (prismPoly
|
|
(map (addZ 3) $ rectNESW 3 3 (-3) (-3))
|
|
(map (addZ 0) $ rectNESW 5 3 (-5) (-7))
|
|
)
|
|
<> translateSH (V3 (-4) 5.5 4) (rotateSH pi $ bulletClip am)
|
|
where
|
|
am = _ammoLoaded $ _itConsumption it
|
|
|
|
bulletClip :: Int -> Shape
|
|
bulletClip x = rotateSHx (negate $ pi/4) . upperPrismPoly 2 $ rectNESW 3 0 (3 - 0.25 * am) (-5)
|
|
where
|
|
am = fromIntegral x
|
|
|
|
hvAutoGun :: Item
|
|
hvAutoGun = defaultAutoGun
|
|
{ _itName = "AUTO-HV"
|
|
, _itIdentity = HvAutoGun
|
|
, _itConsumption = defaultAmmo
|
|
{ _aoType = hvBullet
|
|
, _ammoMax = 100
|
|
, _ammoLoaded = 100
|
|
, _reloadTime = 200
|
|
}
|
|
, _itUse = useAmmoParamsRate 25 NoHammer
|
|
[ ammoCheckI
|
|
, rateIncAB (torqueBeforeAtLeast 0.1 0.1) (torqueAfterI 0.2)
|
|
, withSoundStart bangEchoS
|
|
, withThinSmokeI
|
|
, withMuzFlareI
|
|
]
|
|
& useAim . aimSpeed .~ 0.2
|
|
& useAim . aimRange .~ 1
|
|
& useAim . aimStance .~ TwoHandTwist
|
|
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
|
|
& useDelay .~ VariableRate {_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0}
|
|
, _itFloorPict = hvAutoGunPic
|
|
, _itInvSize = 3
|
|
, _itInvDisplay = \it -> basicWeaponDisplay it ++
|
|
["* FRATE: *"
|
|
,"* " ++ fromMaybe " " (maybeRateStatus it) ++ " *"
|
|
]
|
|
}
|
|
hvAutoGunPic :: Item -> SPic
|
|
hvAutoGunPic it =
|
|
( colorSH orange (prismPoly
|
|
(map (addZ 5) $ rectNESW 3 12 (-3) (-8))
|
|
(map (addZ 0) $ rectNESW 5 12 (-5) (-12))
|
|
)
|
|
<> bulletClip am
|
|
, mempty
|
|
)
|
|
where
|
|
am = _ammoLoaded $ _itConsumption it
|
|
ltAutoGun :: Item
|
|
ltAutoGun = defaultAutoGun
|
|
{ _itName = "AUTO-LT"
|
|
, _itIdentity = LtAutoGun
|
|
, _itConsumption = defaultAmmo
|
|
{ _aoType = ltBullet
|
|
, _ammoMax = 25
|
|
, _ammoLoaded = 25
|
|
, _reloadTime = 80
|
|
}
|
|
, _itUse = useAmmoParamsRate 2 NoHammer
|
|
[ ammoCheckI
|
|
, useTimeCheck
|
|
, withSoundStart tap1S
|
|
, useAmmo 1
|
|
, applyInaccuracy
|
|
, torqueAfterI 0.2
|
|
, withSidePushI 50
|
|
, modClock 2 withMuzFlareI
|
|
]
|
|
, _itFloorPict = ltAutoGunPic
|
|
, _itParams = BulletShooter
|
|
{ _muzVel = 1
|
|
, _bore = 2
|
|
, _gunBarrels = SingleBarrel autogunSpread
|
|
}
|
|
, _itTweaks = defaultBulletSelTweak
|
|
}
|
|
& itDimension . muzzleLength .~ 10
|
|
ltAutoGunPic :: Item -> SPic
|
|
ltAutoGunPic it =
|
|
( colorSH green $ prismPoly
|
|
(map (addZ 5) $ mirrorXAxis [V2 (-2) 3, V2 5 3, V2 10 0])
|
|
(map (addZ 0) $ mirrorXAxis [V2 (-5) 5, V2 5 5, V2 10 0])
|
|
<> bulletClip am
|
|
, mempty
|
|
)
|
|
where
|
|
am = _ammoLoaded $ _itConsumption it
|
|
miniGun :: Item
|
|
miniGun = defaultAutoGun
|
|
{ _itName = "MINI-G"
|
|
, _itIdentity = 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
|
|
, useAmmo 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
|
|
, _itEquipPict = pictureWeaponAim miniGunPictItem
|
|
, _itTweaks = defaultBulletSelTweak
|
|
, _itInvSize = 4
|
|
, _itInvDisplay = \it -> basicWeaponDisplay it ++
|
|
["*" ++ replicate 8 ' ' ++ "*"
|
|
,"* " ++ fromMaybe " " (maybeWarmupStatus it) ++ " *"
|
|
,"*" ++ replicate 8 ' ' ++ "*" ]
|
|
-- [" " ++ replicate 8 ch
|
|
-- ," " ++ replicate 2 ch ++ fromMaybe " " (maybeWarmupStatus it) ++ replicate 2 ch
|
|
-- ," " ++ replicate 8 ch]
|
|
} & itDimension . muzzleLength .~ 15
|
|
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"
|
|
, _itIdentity = SpreadGun
|
|
, _itConsumption = defaultAmmo
|
|
{ _aoType = basicBullet
|
|
, _ammoMax = 5
|
|
, _ammoLoaded = 5
|
|
, _reloadTime = 80
|
|
}
|
|
, _itUse = useAmmoParamsRate 20 upHammer
|
|
[ ammoCheckI
|
|
, hammerCheckI
|
|
, useTimeCheck
|
|
, withSoundStart shotgunS
|
|
, useAmmo 1
|
|
, withRecoilI 100
|
|
, withMuzFlareI
|
|
, spreadNumI
|
|
]
|
|
, _itParams = BulletShooter
|
|
{ _muzVel = 0.7
|
|
, _bore = 2
|
|
, _gunBarrels = MultiBarrel
|
|
{_brlNum = 5
|
|
,_brlSpread = SpreadBarrels 0.5
|
|
}
|
|
}
|
|
, _itFloorPict = spreadGunPic
|
|
, _itTweaks = defaultBulletSelTweak
|
|
}
|
|
spreadGunPic :: Item -> SPic
|
|
spreadGunPic it =
|
|
( colorSH green (upperPrismPoly 5 $ map toV2[(-3,0),(3,6),(3,-6)])
|
|
<> bulletClip am
|
|
, mempty
|
|
)
|
|
where
|
|
am = _ammoLoaded $ _itConsumption it
|
|
multGun :: Item
|
|
multGun = defaultGun
|
|
{ _itName = "MULTGUN"
|
|
, _itIdentity = MultGun
|
|
, _itConsumption = defaultAmmo
|
|
{ _aoType = basicBullet
|
|
, _ammoMax = 2
|
|
, _ammoLoaded = 2
|
|
, _reloadTime = 40
|
|
}
|
|
, _itUse = useAmmoParamsRate 20 upHammer
|
|
[ ammoCheckI
|
|
, hammerCheckI
|
|
, useTimeCheck
|
|
, withSoundStart shotgunS
|
|
, useAmmo 1
|
|
, withRecoilI 200
|
|
, withMuzFlareI
|
|
, numI
|
|
]
|
|
& useAim . aimSpeed .~ 0.4
|
|
& useAim . aimRange .~ 1
|
|
& useAim . aimStance .~ TwoHandTwist
|
|
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
|
|
, _itFloorPict = multGunSPic
|
|
, _itParams = BulletShooter
|
|
{ _muzVel = 1
|
|
, _bore = 3
|
|
, _gunBarrels = MultiBarrel
|
|
{_brlNum = 5
|
|
,_brlSpread = AlignedBarrels
|
|
}
|
|
}
|
|
, _itTweaks = defaultBulletSelTweak
|
|
}
|
|
multGunSPic :: Item -> SPic
|
|
multGunSPic it =
|
|
( colorSH red (
|
|
upperPrismPoly 2 (rectNESW 4 8 (-4) (-12)) <>
|
|
translateSHf 8 0 (concatMap barrel [12,7,2,-3,-8] <>
|
|
upperPrismPoly 2 (map toV2 [(-1.5,12),(-2,12),(-2,-12),(-1.5,-12)])
|
|
)
|
|
) <> bulletClip am
|
|
, mempty
|
|
)
|
|
where
|
|
barrel y = prismPoly
|
|
(map (addZ 5) $ rectNSEW y (y-4) 2 0 )
|
|
(map (addZ 0) $ rectNSEW y (y-4) 2 (-2))
|
|
am = _ammoLoaded $ _itConsumption it
|
|
longGun :: Item
|
|
longGun = defaultGun
|
|
{ _itName = "LONGGUN"
|
|
, _itIdentity = LongGun
|
|
, _itConsumption = defaultAmmo
|
|
{ _aoType = hvBullet
|
|
, _ammoMax = 1
|
|
, _ammoLoaded = 1
|
|
, _reloadTime = 100
|
|
, _reloadType = PassiveReload skwareFadeTwoSecS
|
|
}
|
|
, _itUse = useAmmoParamsRate 100 upHammer
|
|
[ ammoCheckI
|
|
, hammerCheckI
|
|
, useTimeCheck
|
|
, withSoundStart bangEchoS
|
|
, useAmmo 1
|
|
, withThickSmokeI
|
|
, torqueAfterI 0.05
|
|
, withMuzFlareI
|
|
]
|
|
& useAim . aimSpeed .~ 0.2
|
|
& useAim . aimRange .~ 1
|
|
& useAim . aimStance .~ TwoHandTwist
|
|
& useAim . aimZoom .~ defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5}
|
|
, _itFloorPict = longGunSPic
|
|
-- , _itZoom = defaultItZoom
|
|
, _itScroll = zoomLongGun
|
|
, _itAttachment = ItScope (V2 0 0) 0 1 False
|
|
, _itEffect = itemLaserScopeEffect
|
|
}
|
|
longGunSPic :: Item -> SPic
|
|
longGunSPic _ =
|
|
( colorSH orange $ upperPrismPoly 5 $ rectWH 12 2
|
|
, mempty
|
|
)
|
|
|
|
zoomLongGun :: Float -> Creature -> Item -> Item
|
|
zoomLongGun x _
|
|
| x > 0 = startZoomInLongGun
|
|
| x < 0 = startZoomOutLongGun
|
|
| otherwise = id
|
|
|
|
startZoomInLongGun :: Item -> Item
|
|
startZoomInLongGun = itAttachment . scopeZoomChange %~ \x -> max 5 (x + 5)
|
|
startZoomOutLongGun :: Item -> Item
|
|
startZoomOutLongGun = itAttachment . scopeZoomChange %~ \x -> min (-5) (x-5)
|
|
|
|
autogunSpread :: Float
|
|
autogunSpread = 0.07
|