Improve click detectors

Introduce "gadgets" as a structural function, for items that can be used
when held and when not held. Click detectors are such an item. Make
click detectors correctly attach and use up batteries when used.
This commit is contained in:
2024-12-18 13:34:05 +00:00
parent 4d6d255893
commit c4e8046332
17 changed files with 119 additions and 79 deletions
+3 -1
View File
@@ -40,6 +40,7 @@ volleyGun i =
<*> ZipList [0..i-1]
<*> pure PistolFlare
<*> pure MuzzleShootBullet
<*> pure (UseExactly 1)
)
& itUse . heldParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i
& itUse . heldParams . recoil .~ 20 + 10 * fromIntegral i
@@ -88,7 +89,8 @@ miniGunX i =
& itUse . heldParams . bulGunSound ?~ (mini1S,2)
& itUse . heldAim . aimTurnSpeed .~ 0.5
& itUse . heldAim . aimMuzzles
.~ replicate i (Muzzle (V2 30 0) 0 0.05 0 MiniGunFlare MuzzleShootBullet)
.~ replicate i
(Muzzle (V2 30 0) 0 0.05 0 MiniGunFlare MuzzleShootBullet (UseExactly 1))
& itUse . heldParams . recoil .~ 10 * fromIntegral i
& itUse . heldParams . torqueAfter .~ 0.04 + 0.02 * fromIntegral i
& itUse . heldParams . sidePush .~ 10 * fromIntegral i
+2 -1
View File
@@ -13,7 +13,8 @@ bangCone =
defaultBulletWeapon
& itUse . heldDelay . rateMax .~ 20
& itUse . heldAim . aimMuzzles
.~ replicate 15 (Muzzle (V2 15 0) 0 0.5 0 DefaultFlareType MuzzleShootBullet)
.~ replicate 15
(Muzzle (V2 15 0) 0 0.5 0 DefaultFlareType MuzzleShootBullet (UseExactly 1))
& itUse . heldParams . muzVel .~ UniRandFloat 0.5 0.8
& itUse . heldParams . rifling .~ UniRandFloat 0.3 0.8
& itUse . heldParams . recoil .~ 150
+1
View File
@@ -35,6 +35,7 @@ launcherX i =
<*> ZipList [0..]
<*> pure DefaultFlareType
<*> pure MuzzleLauncher
<*> pure (UseExactly 1)
)
& itAmmoSlots .~ IM.fromList [(j,LauncherAmmo) | j <- [0..i-1]]
where
+1
View File
@@ -84,6 +84,7 @@ flameThrower =
, _nzWalkSpeed = 0.01
, _nzCurrentWalkAngle = 0
}
(UseExactly 1)
]
& itAmmoSlots .~ singleAmmo GasAmmo
& itType .~ HELD FLAMETHROWER
+2 -1
View File
@@ -22,7 +22,8 @@ bangStick i =
& itType .~ HELD (BANGSTICK i)
& itUse . heldDelay . rateMax .~ 8
& itUse . heldAim . aimMuzzles
.~ [Muzzle (V2 10 0) a 0.01 0 DefaultFlareType MuzzleShootBullet | a <- spreadAroundCenter i baseStickSpread]
.~ [Muzzle (V2 10 0) a 0.01 0 DefaultFlareType MuzzleShootBullet (UseExactly 1)
| a <- spreadAroundCenter i baseStickSpread]
baseStickSpread :: Float
baseStickSpread = 0.2
+3
View File
@@ -38,5 +38,8 @@ clickDetector dt =
& itUse . heldDelay . rateMax .~ 20
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}
& itAmmoSlots .~ singleAmmo ElectricalAmmo
& itUse . heldParams .~ DefaultHeldParams
& itType .~ HELD (DETECTOR dt)
& itUse . heldAim . aimMuzzles . ix 0 . mzEffect .~ MuzzleDetector
& itUse . heldAim . aimMuzzles . ix 0 . mzAmmoPerShot .~ UseExactly 100