Refactor weapon usages

This commit is contained in:
2021-08-27 16:31:43 +01:00
parent cb8613036f
commit dd44a93476
11 changed files with 308 additions and 60 deletions
+89 -49
View File
@@ -14,7 +14,7 @@ import Dodge.WorldEvent
import Dodge.Default
--import Dodge.Default.Shell
import Dodge.Item.Draw
import Dodge.Particle.Bullet.HitEffect
--import Dodge.Particle.Bullet.HitEffect
import Dodge.Item.Data
import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Item.Weapon.TriggerType
@@ -23,6 +23,7 @@ import Dodge.Item.Weapon.UseEffect
import Dodge.Item.Weapon.Laser
import Dodge.Item.Weapon.Shell
import Dodge.Item.Weapon.Bullet
import Dodge.Item.Weapon.AmmoParams
import Dodge.Default.Weapon
import Dodge.Item.Weapon.Booster
import Dodge.Item.Weapon.Grenade
@@ -87,10 +88,6 @@ pistol = defaultGun
pistolPic :: Picture
pistolPic = color green $ polygon $ rectNESW 5 5 (-5) (-5)
useAmmoParams :: Item -> Creature -> World -> World
useAmmoParams it = withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b)
where
b = _wpAmmo it
effectGun :: String -> (Creature -> World -> World) -> Item
effectGun name eff = defaultGun
@@ -111,7 +108,9 @@ rezGun = defaultGun
, _wpReloadState = 0
, _itUseRate = 0
, _itUseTime = 0
, _itUse = \_ -> shoot aTeslaArc
, _itUse = \_ -> aTeslaArc
, _itUseModifiers =
[]
, _wpSpread = 0.001
, _wpRange = 20
, _itFloorPict = onLayer FlItLayer $ color chartreuse $ pictures
@@ -228,7 +227,10 @@ tractorGun = defaultAutoGun
, _wpReloadState = 0
, _itUseRate = 0
, _itUseTime = 0
, _itUse = \_ -> shoot $ aTractorBeam 0
, _itUse = \_ -> aTractorBeam 0
, _itUseModifiers =
[ ammoUseCheckI
]
, _wpSpread = 0.00001
, _wpRange = 20
, _itFloorPict = onLayer FlItLayer $ color blue $ pictures [polygon $ rectNESW 1.5 6 (-1.5) 0 ]
@@ -275,9 +277,12 @@ hvAutoGun = defaultAutoGun
, _wpReloadState = 0
, _itUseRate = 25
, _itUseTime = 0
, _itUse = \it -> mkHvBul it
, _itUse = useAmmoParams
, _itUseModifiers =
[ rateIncABI 24 10 (torqueBeforeForcedI 0.1) (torqueAfterI 0.2)
, withSoundI longGunSound
, withThinSmokeI
, withMuzFlareI
]
, _wpRange = 20
, _itFloorPict = onLayer FlItLayer hvAutoGunPic
@@ -286,11 +291,6 @@ hvAutoGun = defaultAutoGun
, _itEquipPict = pictureWeaponOnAim hvAutoGunPic
, _wpAmmo = hvBullet
}
where
mkHvBul it = withSound longGunSound
. withThinSmoke
. withMuzFlare
$ useAmmoParams it
hvAutoGunPic :: Picture
hvAutoGunPic = color orange $ polygon $ rectNESW 5 12 (-5) (-12)
ltAutoGun :: Item
@@ -336,16 +336,15 @@ miniGun = defaultAutoGun
, _wpMaxWarmUp = 100
, _itUseRate = 1
, _itUseTime = 0
, _itUse = \it -> withWarmUp 26
. shootWithSoundFor 28 2
. torqueBefore 0.1
-- . torqueBefore 0.03
. withSidePush 50
. withRecoil 15
-- . withRandomDir 0.1
. withRandomOffset 9
. withMuzFlare
$ useAmmoParams it
, _itUse = useAmmoParams
, _itUseModifiers =
[ withWarmUpI 26
, shootWithSoundForI 28 2
, torqueBeforeForcedI 0.1
, withSidePushI 50
, withRandomOffsetI 9
, withMuzFlareI
]
, _wpRange = 20
, _itFloorPict = onLayer FlItLayer miniGunPict
, _itAimingSpeed = 0.4
@@ -358,7 +357,6 @@ miniGunPict = pictures
[ translate 5 0 . color red $ polygon $ rectNESW 9 7 (-9) (-5)
, color red . polygon $ rectNESW 4 12 (-4) (-12)
]
spreadGun :: Item
spreadGun = defaultGun
{ _itName = "SPREAD"
@@ -369,17 +367,25 @@ spreadGun = defaultGun
, _wpReloadState = 0
, _itUseRate = 20
, _itUseTime = 0
, _itUse = \_ -> shootWithSound shotgunSound
. withRecoil 100
. withMuzFlare
$ spreadNumVelWthHiteff spreadGunSpread 9 (V2 30 0) 2 basicBulletEffect
--, _itUse = \_ -> spreadNumVelWthHiteff spreadGunSpread 9 (V2 30 0) 2 basicBulletEffect
, _itUse = useAmmoParams
, _itUseModifiers =
[ shootWithSoundI shotgunSound
, withRecoilI 100
, withMuzFlareI
, spreadNumI
]
, _wpSpread = spreadGunSpread
, _wpRange = 20
, _itFloorPict = onLayer FlItLayer $ color green $ pictures [ polygon $ map toV2[(-3,0),(3,6),(3,-6)] ]
, _itFloorPict = onLayer FlItLayer $ spreadGunPic
, _itAimingSpeed = 1
, _itAimingRange = 0
, _itEquipPict = pictureWeaponOnAim $ color green $ pictures [ polygon $ map toV2[(-3,0),(3,6),(3,-6)] ]
, _itEquipPict = pictureWeaponOnAim $ spreadGunPic
, _wpAmmo = basicBullet
, _wpNumBarrels = 50
}
spreadGunPic :: Picture
spreadGunPic = color green $ pictures [ polygon $ map toV2[(-3,0),(3,6),(3,-6)] ]
multGun :: Item
multGun = defaultGun
{ _itName = "MULTGUN"
@@ -390,10 +396,13 @@ multGun = defaultGun
, _wpReloadState = 0
, _itUseRate = 20
, _itUseTime = 0
, _itUse = \_ -> shootWithSound shotgunSound
. withRecoil 200
. withMuzFlare
$ numVelWthHitEff 5 (V2 50 0) 5 basicBulletEffect
, _itUse = useAmmoParams
, _itUseModifiers =
[ shootWithSoundI shotgunSound
, withRecoilI 200
, withMuzFlareI
, numI
]
, _wpSpread = spreadGunSpread
, _wpRange = 20
, _itFloorPict = onLayer FlItLayer multGunPic
@@ -402,6 +411,8 @@ multGun = defaultGun
, _itZoom = defaultItZoom {_itAimZoomFac = 1.5}
, _itEquipPict = pictureWeaponOnAim multGunPic
, _itAimStance = TwoHandTwist
, _wpAmmo = basicBullet
, _wpNumBarrels = 5
}
multGunPic :: Picture
multGunPic = color red $ pictures
@@ -426,11 +437,13 @@ longGun = defaultGun
, _wpReloadType = PassiveReload skwareFadeTwoSecSound
, _itUseRate = 100
, _itUseTime = 0
, _itUse = shootWithSound longGunSound
. withThickSmoke
. torqueAfter 0.05
. withMuzFlare
. useAmmoParams
, _itUse = useAmmoParams
, _itUseModifiers =
[ shootWithSoundI longGunSound
, withThickSmokeI
, torqueAfterI 0.05
, withMuzFlareI
]
, _wpRange = 200
, _itFloorPict = onLayer FlItLayer longGunPic
, _itAimingSpeed = 0.2
@@ -468,7 +481,10 @@ poisonSprayer = defaultAutoGun
, _wpReloadState = 0
, _itUseRate = 0
, _itUseTime = 0
, _itUse = \_ -> shoot aGasCloud
, _itUse = \_ -> aGasCloud
, _itUseModifiers =
[shootWithSoundI buzzSound
]
, _wpSpread = 0.3
, _wpRange = 8
, _itFloorPict = onLayer FlItLayer $ color yellow $ polygon $ rectNESW 4 4 (-4) (-4)
@@ -487,7 +503,12 @@ flamer = defaultAutoGun
, _wpReloadState = 0
, _itUseRate = 0
, _itUseTime = 0
, _itUse = \_ -> shoot $ withSidePush 5 $ withSidePushAfter 10 $ randWalkAngle 0.2 0.01 aFlame
, _itUse = \_ -> randWalkAngle 0.2 0.01 aFlame
, _itUseModifiers =
[ ammoUseCheckI
, withSidePushI 5
, withSidePushAfterI 10
]
, _wpSpread = 0
, _wpRange = 8
, _itFloorPict = onLayer FlItLayer flamerPic
@@ -512,7 +533,11 @@ blinkGun = defaultGun
, _wpReloadState = 0
, _itUseRate = 0
, _itUseTime = 0
, _itUse = \_ -> hammerCheck $ shoot aSelf
, _itUse = \_ -> aSelf
, _itUseModifiers =
[ hammerCheckI
, ammoUseCheckI
]
, _itLeftClickUse = Just $ hammerCheckL $ shootL aSelfL
, _wpSpread = 0.05
, _wpRange = 20
@@ -630,7 +655,7 @@ retireRemoteBomb itid 0 pjid w = w
& pointToItem (_itemPositions w IM.! itid) %~
( (itAttachment . _Just . scopePos .~ V2 0 0)
. (itZoom .~ defaultItZoom)
. (itUse .~ (\_ -> hammerCheck throwRemoteBomb))
. (itUse .~ (\_ -> throwRemoteBomb))
)
& projectiles %~ IM.delete pjid
retireRemoteBomb itid t pjid w = setScope w
@@ -707,7 +732,10 @@ grenade = Throwable
, _itFloorPict = onLayer FlItLayer $ polygon $ map toV2 [(-3,-3),(-3,3),(3,3),(3,-3)]
, _twMaxRange = 150
, _twAccuracy = 30
, _itUse = \_ -> useTimeCheck $ throwGrenade makeExplosionAt
, _itUse = \_ -> throwGrenade makeExplosionAt
, _itUseModifiers =
[ useTimeCheckI
]
, _itAimingSpeed = 1
, _itAimingRange = 0
, _itZoom = defaultItZoom {_itAimZoomMax = f fuseTime, _itAimZoomMin = f fuseTime}
@@ -757,7 +785,10 @@ remoteBomb = defaultThrowable
, _itFloorPict = onLayer FlItLayer $ polygon $ map toV2 [(-3,-3),(-3,3),(3,3),(3,-3)]
, _twMaxRange = 150
, _twAccuracy = 30
, _itUse = \_ -> hammerCheck throwRemoteBomb
, _itUse = \_ -> throwRemoteBomb
, _itUseModifiers =
[ hammerCheckI
]
, _itAttachment = Just $ ItScope (V2 0 0) 0 1 True
, _itEquipPict = pictureWeaponOnAim remoteBombUnarmedPic
}
@@ -881,7 +912,7 @@ throwRemoteBomb cr w = setLocation
resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTE"
removePict = set (creatures . ix cid . crInv . ix j . itEquipPict) $ \ _ _ -> blank
resetFire = set (creatures . ix cid . crInv . ix j . itUse)
$ \_ -> hammerCheck $ explodeRemoteBomb itid i
$ \_ -> explodeRemoteBomb itid i
p' = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr) 0)
p | circOnSomeWall p' 4 w = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr-4) 0)
| otherwise = p'
@@ -949,7 +980,10 @@ radar = defaultGun
, _wpReloadState = 0
, _itUseRate = 120
, _itUseTime = 0
, _itUse = \_ -> shoot aRadarPulse
, _itUse = \_ -> aRadarPulse
, _itUseModifiers =
[ ammoUseCheckI
]
, _wpSpread = autogunSpread
, _wpRange = 20
, _itHammer = HammerUp
@@ -972,7 +1006,10 @@ sonar = defaultGun
, _wpReloadState = 0
, _itUseRate = 120
, _itUseTime = 0
, _itUse = \_ -> shoot aSonarPulse
, _itUse = \_ -> aSonarPulse
, _itUseModifiers =
[ ammoUseCheckI
]
, _wpRange = 20
, _itHammer = HammerUp
, _itFloorPict = onLayer FlItLayer $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
@@ -1024,7 +1061,10 @@ spawnGun cr = defaultGun
, _wpReloadTime = 80
, _wpReloadState = 0
, _itUseRate = 100
, _itUse = \_ -> hammerCheck $ spawnCrNextTo cr
, _itUse = \_ -> spawnCrNextTo cr
, _itUseModifiers =
[ hammerCheckI
]
}
spawnCrNextTo
:: Creature -- ^ Creature to spawn