Mid refactor of item ruse--broken

This commit is contained in:
2022-07-20 16:30:30 +01:00
parent eeb98eb151
commit 795c4c1987
18 changed files with 238 additions and 185 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ moduleModification imt = case imt of
where
makeDirectedTele it = it
& itTargeting .~ targetRBPress
& itUse . useMods .:~ withPosDirWallCheck directedTelPos
& itUse . useMods %~ ModWithDirectedTeleport -- .:~ withPosDirWallCheck directedTelPos
-- for the camera: the simplest option is to remove all zoom/offset
& itUse . useAim . aimZoom . itZoomFac .~ 1
& itUse . useAim . aimRange .~ 0
+1 -1
View File
@@ -404,7 +404,7 @@ data ItemUse
= RightUse
{ _rUse :: HeldUse -- Item -> Creature -> World -> World
, _useDelay :: UseDelay
, _useMods :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
, _useMods :: HeldMod --[(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
, _useHammer :: HammerPosition
, _useAim :: AimParams
, _heldScroll :: HeldScroll --Float -> Creature -> Item -> Item
+24 -1
View File
@@ -18,4 +18,27 @@ data HeldUse = HeldDoNothing
| HeldForceField
| HeldShatter
data HeldUseMods = HeldModsDoNothing
data HeldMod = HeldModNothing
| PoisonSprayerMod
| FlameSpitterMod
| FlameThrowerMod
| LauncherMod
| TeslaMod
| CircleLaserMod
| LasWideMod
| DualBeamMod
| LasMod
| LauncherXMod
| ShatterMod
| AmmoCheckMod
| AmmoUseCheckMod
| AmmoHammerTimeUseOneMod
| BangCaneMod
| VolleyGunMod
| AutoRifleMod
| BangRodMod
| ElephantGunMod
| AutoAmrMod
| MachineGunMod
| ModWithDirectedTeleport HeldMod
| BangStickMod
+1 -1
View File
@@ -61,7 +61,7 @@ defaultrUse :: ItemUse
defaultrUse = RightUse
{ _rUse = HeldDoNothing
, _useDelay = FixedRate {_rateMax = 8, _rateTime = 0}
, _useMods = []
, _useMods = HeldModNothing
, _useHammer = HammerUp
, _useAim = defaultAimParams
, _heldScroll = HeldScrollDoNothing
+183
View File
@@ -17,6 +17,189 @@ import RandomHelp
import Data.Traversable
useMod :: HeldMod -> [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
useMod hm = case hm of
HeldModNothing -> []
PoisonSprayerMod ->
[ ammoCheckI
, withSoundForI foamSprayLoopS 5
, useAmmoAmount 1
]
FlameSpitterMod ->
[ ammoCheckI
, useTimeCheck
, lockInvFor 10
, repeatOnFrames [1..9]
, withRandomItemParams f
, useAmmoAmount 1
, withSidePushI 5
, withSidePushAfterI 20
]
FlameThrowerMod ->
[ ammoCheckI
, useAmmoAmount 1
, withSidePushI 5
--, withTempLight 1 100 (V3 1 0 0)
, withSidePushAfterI 20
]
LauncherMod ->
[ hammerCheckI
, ammoCheckI
, useTimeCheck
, withSoundStart tap4S
, useAmmoAmount 1
]
TeslaMod ->
[ ammoCheckI
, withTempLight 1 100 (V3 0 0 1)
, withSoundForI elecCrackleS 1
, useAmmoAmount 1
]
CircleLaserMod ->
[ ammoCheckI
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withSoundForI tone440sawtoothquietS 2
, useAmmoAmount 1
, withItemUpdate' increasecycle
, duplicateItem f
]
LasWideMod ->
[ ammoCheckI
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withSoundForI tone440sawtoothquietS 2
, useAmmoAmount 1
, crAtMuzPos
, withItemUpdate' increasecycle
, withItem $ \it -> duplicateOffsetsV2 (xs it)
]
DualBeamMod ->
[ ammoCheckI
, withItem $ \it -> withMuzPosShift (V2 0 (thegap it)) $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withItem $ \it -> withMuzPosShift (V2 0 (-thegap it)) $ flareCircleAt (_lasColor2 $ _itParams it) 0.8
, withSoundForI tone440sawtoothquietS 2
, useAmmoAmount 1
]
LasMod ->
[ ammoCheckI
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, withSoundForI tone440sawtoothquietS 2
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, useAmmoAmount 1
, crAtMuzPos
]
LauncherXMod ->
[ hammerCheckI
, ammoCheckI
, useTimeCheck
, withSoundStart tap4S
, useAmmoAmount i
]
ShatterMod ->
[ ammoHammerCheck
, useTimeCheck
-- , withSoundStart tap3S
, useAmmoAmount 1
]
AmmoCheckMod -> [ ammoCheckI ]
AmmoUseCheckMod -> [ ammoUseCheck ]
AmmoHammerTimeUseOneMod ->
[ ammoHammerCheck
, useTimeCheck
, useAmmoAmount 1
]
BangCaneMod ->
[ ammoHammerCheck
, useTimeCheck
, withSoundStart tap3S
, useAmmoAmount 1
, withTorqueAfter
, applyInaccuracy
, withRecoil
, withSmoke 1 black 20 200 5
, withMuzFlareI
]
VolleyGunMod ->
[ ammoHammerCheck
, useTimeCheck
, withSoundItemChoiceStart caneStickSoundChoice
, useAllAmmo
, withTorqueAfter
, duplicateLoadedBarrels
, applyInaccuracy
, withMuzFlareI
, withRecoil
]
AutoRifleMod -> -- note this is the same as BangCanemMod with the first changed
[ ammoCheckI
, useTimeCheck
, withSoundStart tap3S
, useAmmoAmount 1
, withTorqueAfter
, applyInaccuracy
, withRecoil
, withSmoke 1 black 20 200 5
, withMuzFlareI
]
BangRodMod ->
[ ammoHammerCheck
, useTimeCheck
, withSoundStart bangEchoS
, useAmmoAmount 1
, withTorqueAfter
, applyInaccuracy
, withThickSmokeI
, withMuzFlareI
, withRecoil
]
ElephantGunMod ->
[ ammoHammerCheck
, useTimeCheck
, withSoundStart bangEchoS
, useAmmoAmount 1
, withTorqueAfter
, applyInaccuracy
, withThickSmokeI
, withMuzFlareI
, withRecoil
]
AutoAmrMod ->
[ ammoCheckI -- cf ElephantGun
, useTimeCheck
, withSoundStart bangEchoS
, useAmmoAmount 1
, withTorqueAfter
, applyInaccuracy
, withThickSmokeI
, withMuzFlareI
, withRecoil
]
MachineGunMod ->
[ ammoCheckI
, rateIncAB (torqueBeforeAtLeast 0.1 0.1) withTorqueAfter
, withSoundStart bangEchoS
, withThinSmokeI
, withMuzFlareI
]
ModWithDirectedTeleport hm' ->
withPosDirWallCheck directedTelPos : useMod hm'
BangStickMod ->
[ ammoHammerCheck
, useTimeCheck
, withSoundItemChoiceStart bangStickSoundChoice
, useAllAmmo
, withMuzFlareI
, withTorqueAfter
, spreadLoaded
-- , applyInaccuracy
, withRecoil
]
where
f = do
nzpres <- state $ randomR (3,4)
return $ sprayNozzles . ix 0 . nzPressure .~ nzpres
useHeld :: HeldUse -> Item -> Creature -> World -> World
useHeld hu = case hu of
HeldDoNothing -> const $ const id
+1 -1
View File
@@ -130,7 +130,7 @@ flatShield = defaultWeapon
& itUse .~ defaultrUse
{ _rUse = HeldDoNothing
, _useDelay = NoDelay
, _useMods = []
, _useMods = HeldModNothing
, _useHammer = HammerUp
, _useAim = AimParams
{ _aimWeight = 5
+6 -43
View File
@@ -77,12 +77,7 @@ teslaGun = defaultBatteryGun
& itParams .~ teslaParams
& itUse . rUse .~ HeldTeslaArc --shootTeslaArc
& itUse . useDelay .~ NoDelay
& itUse . useMods .~
[ ammoCheckI
, withTempLight 1 100 (V3 0 0 1)
, withSoundForI elecCrackleS 1
, useAmmoAmount 1
]
& itUse . useMods .~ TeslaMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimStance .~ TwoHandFlat
& itUse . useAim . aimHandlePos .~ 4
@@ -115,15 +110,7 @@ lasCircle = lasGun
& itUse . rUse .~ HeldLaser --shootLaser
& itUse . useDelay .~ NoDelay
& itUse . rUse .~ HeldCircleLaser --circleLaser
& itUse . useMods .~
[ ammoCheckI
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withSoundForI tone440sawtoothquietS 2
, useAmmoAmount 1
, withItemUpdate' increasecycle
, duplicateItem f
]
& itUse . useMods .~ CircleLaserMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandTwist
@@ -137,16 +124,7 @@ lasWide n = lasGun
& itType . iyBase .~ HELD (LASWIDE n)
& itParams . lasColor .~ yellow
& itParams . lasDamage .~ 2
& itUse . useMods .~
[ ammoCheckI
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withSoundForI tone440sawtoothquietS 2
, useAmmoAmount 1
, crAtMuzPos
, withItemUpdate' increasecycle
, withItem $ \it -> duplicateOffsetsV2 (xs it)
]
& itUse . useMods .~ LasWideMod
where
increasecycle it = case _useHammer (_itUse it) of
HammerUp -> it & itParams . lasCycle .~ 1
@@ -236,13 +214,7 @@ dualBeam = lasGun
}
& itUse . rUse .~ HeldDualLaser --shootDualLaser
& itUse . useDelay .~ NoDelay
& itUse . useMods .~
[ ammoCheckI
, withItem $ \it -> withMuzPosShift (V2 0 (thegap it)) $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withItem $ \it -> withMuzPosShift (V2 0 (-thegap it)) $ flareCircleAt (_lasColor2 $ _itParams it) 0.8
, withSoundForI tone440sawtoothquietS 2
, useAmmoAmount 1
]
& itUse . useMods .~ DualBeamMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandFlat
@@ -288,14 +260,7 @@ lasGun = defaultAutoBatteryGun
& itDimension . dimCenter .~ V3 15 0 0
& itUse . rUse .~ HeldLaser --shootLaser
& itUse . useDelay .~ NoDelay
& itUse . useMods .~
[ ammoCheckI
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, withSoundForI tone440sawtoothquietS 2
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, useAmmoAmount 1
, crAtMuzPos
]
& itUse . useMods .~ LasMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandTwist
@@ -334,9 +299,7 @@ tractorGun = lasGun
}
& itUse . rUse .~ HeldTractor --aTractorBeam
& itUse . useDelay .~ NoDelay
& itUse . useMods .~
[ ammoCheckI
]
& itUse . useMods .~ AmmoCheckMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandTwist
+3 -23
View File
@@ -37,17 +37,7 @@ defaultBangCane = defaultBulletWeapon
& itDimension . dimRad .~ 8
& itDimension . dimCenter .~ V3 5 0 0
& itUse . useDelay . rateMax .~ 6
& itUse . useMods .~
[ ammoHammerCheck
, useTimeCheck
, withSoundStart tap3S
, useAmmoAmount 1
, withTorqueAfter
, applyInaccuracy
, withRecoil
, withSmoke 1 black 20 200 5
, withMuzFlareI
]
& itUse . useMods .~ BangCaneMod
& itUse . useAim . aimStance .~ OneHand
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 15
@@ -57,17 +47,7 @@ defaultBangCane = defaultBulletWeapon
volleyGun :: Int -> Item
volleyGun i = defaultBangCane
& itUse . useDelay . rateMax .~ 6
& itUse . useMods .~
[ ammoHammerCheck
, useTimeCheck
, withSoundItemChoiceStart caneStickSoundChoice
, useAllAmmo
, withTorqueAfter
, duplicateLoadedBarrels
, applyInaccuracy
, withMuzFlareI
, withRecoil
]
& itUse . useMods .~ VolleyGunMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandFlat
@@ -119,7 +99,7 @@ repeater = rifle
autoRifle :: Item
autoRifle = repeater
& itType . iyBase .~ HELD AUTORIFLE
& itUse . useMods %~ ((ammoCheckI :) . tail)
& itUse . useMods .~ AutoRifleMod
& itType . iyModules . at ModAutoMag ?~ EMPTYMODULE
-- & itUse . useDelay . rateMax .~ 6
burstRifle :: Item
+4 -30
View File
@@ -35,17 +35,7 @@ bangRod = defaultBulletWeapon
, _randomOffset = 0
}
& itUse . useDelay . rateMax .~ 12
& itUse . useMods .~
[ ammoHammerCheck
, useTimeCheck
, withSoundStart bangEchoS
, useAmmoAmount 1
, withTorqueAfter
, applyInaccuracy
, withThickSmokeI
, withMuzFlareI
, withRecoil
]
& itUse . useMods .~ BangRodMod
& itDimension . dimRad .~ 12
& itDimension . dimCenter .~ V3 5 0 0
& itConsumption . laMax .~ 1
@@ -63,17 +53,7 @@ elephantGun = bangRod
& itType . iyBase .~ HELD ELEPHANTGUN
& itUse . useAim . aimStance .~ TwoHandTwist
& itParams . gunBarrels .~ SingleBarrel 0.05
& itUse . useMods .~
[ ammoHammerCheck
, useTimeCheck
, withSoundStart bangEchoS
, useAmmoAmount 1
, withTorqueAfter
, applyInaccuracy
, withThickSmokeI
, withMuzFlareI
, withRecoil
]
& itUse . useMods .~ ElephantGunMod
& itParams . recoil .~ 50
& itParams . torqueAfter .~ 0.1
amr :: Item
@@ -84,7 +64,7 @@ amr = elephantGun
autoAmr :: Item
autoAmr = amr
& itType . iyBase .~ HELD AUTOAMR
& itUse . useMods %~ ((ammoCheckI :) . tail)
& itUse . useMods .~ AutoAmrMod
sniperRifle :: Item
sniperRifle = elephantGun
@@ -99,13 +79,7 @@ machineGun :: Item
machineGun = bangRod
& itType . iyBase .~ HELD MACHINEGUN
& itUse . useDelay . rateMax .~ 25
& itUse . useMods .~
[ ammoCheckI
, rateIncAB (torqueBeforeAtLeast 0.1 0.1) withTorqueAfter
, withSoundStart bangEchoS
, withThinSmokeI
, withMuzFlareI
]
& itUse . useMods .~ MachineGunMod
& itUse . useAim . aimWeight .~ 8
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandTwist
+1 -11
View File
@@ -47,17 +47,7 @@ bangStick i = defaultBulletWeapon
& itDimension . dimRad .~ 5
& itDimension . dimCenter .~ V3 5 0 0
& itUse . useDelay . rateMax .~ 8
& itUse . useMods .~
[ ammoHammerCheck
, useTimeCheck
, withSoundItemChoiceStart bangStickSoundChoice
, useAllAmmo
, withMuzFlareI
, withTorqueAfter
, spreadLoaded
-- , applyInaccuracy
, withRecoil
]
& itUse . useMods .~ BangStickMod
& itType . iyBase .~ HELD (BANGSTICK i)
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 10
+1 -6
View File
@@ -16,12 +16,7 @@ droneLauncher :: Item
droneLauncher = defaultWeapon
& itUse . useDelay . rateMax .~ 20
-- & itUse . rUse .~ aDroneWithItemParams
& itUse . useMods .~
[ ammoCheckI
, useTimeCheck
, withSoundStart tap4S
, useAmmoAmount 1
]
& itUse . useMods .~ AmmoUseCheckMod
& itUse . useAim . aimWeight .~ 8
& itUse . useAim . aimRange .~ 0.5
& itUse . useAim . aimStance .~ TwoHandTwist
+2 -14
View File
@@ -45,13 +45,7 @@ launcher = defaultWeapon
& itDimension . dimCenter .~ V3 10 0 0
& itUse . useDelay . rateMax .~ 20
& itUse . rUse .~ HeldPJCreation --usePjCreation
& itUse . useMods .~
[ hammerCheckI
, ammoCheckI
, useTimeCheck
, withSoundStart tap4S
, useAmmoAmount 1
]
& itUse . useMods .~ LauncherMod
& itUse . useAim . aimWeight .~ 8
& itUse . useAim . aimRange .~ 0.5
& itUse . useAim . aimStance .~ TwoHandTwist
@@ -66,13 +60,7 @@ launcherX i = launcher
& itConsumption . laMax .~ i
& itConsumption . laLoaded .~ i
& itUse . rUse .~ HeldPJCreationX i
& itUse . useMods .~
[ hammerCheckI
, ammoCheckI
, useTimeCheck
, withSoundStart tap4S
, useAmmoAmount i
]
& itUse . useMods .~ LauncherXMod
basicAmPjMoves :: IM.IntMap TweakParam
basicAmPjMoves = IM.fromList . zip [0..] $
+1 -3
View File
@@ -14,9 +14,7 @@ clickDetector :: Detector -> Item
clickDetector dt = defaultWeapon
& itUse . useDelay . rateMax .~ 20
& itUse . rUse .~ HeldDetectorEffect dt --detectorEffect dt
& itUse . useMods .~
[ ammoUseCheck
]
& itUse . useMods .~ AmmoUseCheckMod
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1}
& itType . iyBase .~ HELD (HELDDETECTOR dt)
+1 -6
View File
@@ -27,12 +27,7 @@ shatterGun = defaultWeapon
& itType . iyBase .~ HELD SHATTERGUN
& itUse . useDelay . rateMax .~ 10
& itUse . rUse .~ HeldShatter --shootShatter
& itUse . useMods .~
[ ammoHammerCheck
, useTimeCheck
-- , withSoundStart tap3S
, useAmmoAmount 1
]
& itUse . useMods .~ ShatterMod
& itUse . useAim . aimStance .~ TwoHandFlat
shootShatter :: Item -> Creature -> World -> World
+1 -5
View File
@@ -38,11 +38,7 @@ sonicGun = defaultAutoGun
& itDimension . dimCenter .~ V3 15 0 0
& itUse . useDelay . rateMax .~ 8
& itUse . rUse .~ HeldSonicWave --aSonicWave
& itUse . useMods .~
[ ammoHammerCheck
, useTimeCheck
, useAmmoAmount 1
]
& itUse . useMods .~ AmmoHammerTimeUseOneMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandTwist
+4 -4
View File
@@ -18,10 +18,10 @@ spawnGun :: Creature -> Item
spawnGun _ = defaultWeapon
& itUse . useDelay . rateMax .~ 100
& itUse . rUse .~ HeldDoNothing --(\_ -> spawnCrNextTo cr)
& itUse . useMods .~
[ ammoCheckI
, hammerCheckI
]
& itUse . useMods .~ HeldModNothing
-- [ ammoCheckI
-- , hammerCheckI
-- ]
& itType . iyBase .~ LEFT SPAWNER
spawnCrNextTo
:: Creature -- ^ Creature to spawn
+3 -27
View File
@@ -23,12 +23,7 @@ poisonSprayer = flameThrower
{ _amString = "POISONGAS"
, _amCreateGas = CreatePoisonGas --aGasCloud
}
& itUse . useMods .~
[ ammoCheckI
, withSoundForI foamSprayLoopS 5
, useAmmoAmount 1
-- , spreadNumI
]
& itUse . useMods .~ PoisonSprayerMod
flameSpitter :: Item
flameSpitter = flameThrower
@@ -38,20 +33,7 @@ flameSpitter = flameThrower
& itParams . sprayNozzles . ix 0 . nzPressure .~ 4
& itUse . useAim . aimStance .~ OneHand
& itUse . useDelay .~ FixedRate {_rateMax =12,_rateTime = 0}
& itUse . useMods .~
[ ammoCheckI
, useTimeCheck
, lockInvFor 10
, repeatOnFrames [1..9]
, withRandomItemParams f
, useAmmoAmount 1
, withSidePushI 5
, withSidePushAfterI 20
]
where
f = do
nzpres <- state $ randomR (3,4)
return $ sprayNozzles . ix 0 . nzPressure .~ nzpres
& itUse . useMods .~ FlameSpitterMod
flameTorrent :: Item
flameTorrent = flameThrower
@@ -106,13 +88,7 @@ flameThrower = defaultAutoGun
& itDimension . dimCenter .~ V3 9 0 0
& itUse . rUse .~ HeldOverNozzlesUseGasParams -- overNozzles useGasParams
& itUse . useDelay .~ NoDelay
& itUse . useMods .~
[ ammoCheckI
, useAmmoAmount 1
, withSidePushI 5
--, withTempLight 1 100 (V3 1 0 0)
, withSidePushAfterI 20
]
& itUse . useMods .~ FlameThrowerMod
& itUse . useAim . aimWeight .~ 5
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomMax = 5, _itZoomMin = 1.5}
& itUse . useAim . aimStance .~ TwoHandTwist
-8
View File
@@ -1,17 +1,9 @@
module Dodge.Projectile.Create where
import Dodge.Data
--import Dodge.Payload
--import Dodge.SoundLogic
--import Dodge.Movement.Turn
import Dodge.Item.Location
--import Dodge.EnergyBall
--import Dodge.WorldEvent.Cloud
import LensHelp
import qualified IntMapHelp as IM
import Geometry
--import RandomHelp
--import Data.Maybe
createProjectile :: ProjectileCreate -> Item -> Creature -> World -> World
createProjectile pt = case pt of