Continue refactor of reloading

This commit is contained in:
2022-06-20 11:12:24 +01:00
parent 2f4b381484
commit a85cf4d1fb
27 changed files with 243 additions and 299 deletions
+14 -8
View File
@@ -20,14 +20,7 @@ itemDisplay it = Prelude.take (itSlotsTaken it) $
++ moduleStrings it ++ repeat "*"
where
thename = show . _iyBase $ _itType it
thenumber = case it ^? itConsumption of
Just am@LoadableAmmo{} -> case _laTransfer am of
NoTransfer -> show (_laLoaded am)
Transfer _ time -> show time ++ "R" ++ show (_laLoaded am)
Just am@ChargeableAmmo{} -> show $ _wpCharge am
Just x@ItemItselfConsumable{} -> show (_icAmount x)
Just NoConsumption -> ""
Nothing -> ""
thenumber = showConsumption (_itConsumption it)
theparam = fromMaybe []
. listToMaybe
$ mapMaybe ($ it)
@@ -36,6 +29,19 @@ itemDisplay it = Prelude.take (itSlotsTaken it) $
-- , maybeRateStatus
]
showConsumption :: ItemConsumption -> String
showConsumption ic = case ic of
am@LoadableAmmo{} -> showLoading (_laLoadType ic) ++ show (_laLoaded am)
am@ChargeableAmmo{} -> show $ _wpCharge am
x@ItemItselfConsumable{} -> show (_icAmount x)
NoConsumption -> ""
showLoading :: LoadType -> String
showLoading lt = case lt ^? loadProgress of
Just (Eject t) -> show t ++ "E"
Just (Insert t _) -> show t ++ "R"
Just NoTransfer -> ""
Nothing -> ""
-- & itInvDisplay .~ \it -> head (basicItemDisplay it) :
-- ["*FIRERATE:" ++ fromMaybe "" (maybeRateStatus it)
-- ]
+2 -6
View File
@@ -110,13 +110,9 @@ maxT :: Int
maxT = 20
boosterGun :: Item
boosterGun = defaultGun
boosterGun = defaultLeftItem
{ _itInvColor = cyan
, _itConsumption = defaultAmmo
{ _laMax = 100
, _laLoaded = 100
, _laReloadTime = 20
}
, _itConsumption = defaultChargeable
, _itUse = luseInstantNoH $ boostSelfL 10
, _itEffect = resetAttachmentID
}
+1 -1
View File
@@ -49,7 +49,7 @@ useAmmoParams vfact it cr w = w & instantParticles .:~ aBulAt
sp = _crPos cr +.+ muzlength *.* unitVectorAtAngle dir
cid = _crID cr
dir = _crDir cr
bultype = _laType $ _itConsumption it
bultype = _laAmmoType $ _itConsumption it
muzvel = _muzVel $ _itParams it
muzlength = aimingMuzzlePos cr it
thetraj = case _amBulTraj bultype of
+13 -16
View File
@@ -53,7 +53,7 @@ import qualified Data.Map.Strict as M
--import Control.Monad.State
defaultBatteryGun :: Item
defaultBatteryGun = defaultGun
defaultBatteryGun = defaultWeapon
& itType . iyModules .~ batteryModules
batteryModules :: M.Map ModuleSlot ItemModuleType
@@ -72,11 +72,10 @@ sparkGun = teslaGun
& itParams . arcSize .~ 10
teslaGun :: Item
teslaGun = defaultBatteryGun
{ _itConsumption = defaultAmmo
{ _laMax = 200
, _laLoaded = 200
, _laReloadTime = 80
}
{ _itConsumption = defaultLoadable
& laMax .~ 200
& laLoadType . ejectTime .~ 40
& laLoadType . insertTime .~ 40
, _itUse = ruseInstant shootTeslaArc NoHammer
[ ammoCheckI
, withTempLight 1 100 (V3 0 0 1)
@@ -253,11 +252,10 @@ lasSwing = lasGun
x' = _lasCycle $ _itParams it
lasGun :: Item
lasGun = defaultAutoBatteryGun
{ _itConsumption = defaultAmmo
{ _laMax = 200
, _laLoaded = 200
, _laReloadTime = 80
}
{ _itConsumption = defaultLoadable
& laMax .~ 200
& laLoadType . ejectTime .~ 40
& laLoadType . insertTime .~ 40
, _itUse = ruseInstant shootLaser NoHammer
[ ammoCheckI
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
@@ -320,11 +318,10 @@ lasGunTweak = TweakParam
tractorGun :: Item
tractorGun = lasGun
{ _itConsumption = defaultAmmo
{ _laMax = 10000
, _laLoaded = 10000
, _laReloadTime = 40
}
{ _itConsumption = defaultLoadable
& laMax .~ 10000
& laLoadType . ejectTime .~ 20
& laLoadType . insertTime .~ 20
, _itUse = ruseInstant aTractorBeam NoHammer
[ ammoCheckI
]
+11 -15
View File
@@ -21,7 +21,6 @@ import Dodge.Default
--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
@@ -38,7 +37,7 @@ import LensHelp
--import System.Random
bangCane :: Item
bangCane = defaultGun
bangCane = defaultBulletWeapon
{ _itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
@@ -50,12 +49,6 @@ bangCane = defaultGun
, _torqueAfter = 0.1
, _randomOffset = 0
}
, _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 1
, _laReloadTime = 15
, _laReloadType = ActivePartial 1
}
, _itUse = ruseAmmoParamsRate 6 upHammer
[ ammoHammerCheck
, useTimeCheck
@@ -79,6 +72,8 @@ bangCane = defaultGun
}
} & itUse . useAim . aimStance .~ OneHand
& itType . iyBase .~ BANGCANE
& itConsumption . laMax .~ 1
& itConsumption . laLoadType .~ ActivePartial 10 1 NoTransfer
bangCaneX :: Int -> Item
bangCaneX i = bangCane
{ _itUse = ruseAmmoParamsRate 6 upHammer
@@ -144,6 +139,7 @@ rifle = bangCane
& itUse . useAim . aimStance .~ TwoHandTwist
& itType . iyBase .~ RIFLE
& itConsumption . laMax .~ 1
& itConsumption . laLoadType .~ ActiveEject 5 5 NoTransfer
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
-- & itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
@@ -152,8 +148,8 @@ repeater :: Item
repeater = rifle
& itType . iyModules . at ModRifleMag ?~ EMPTYMODULE
& itType . iyBase .~ REPEATER
& itConsumption . laReloadType .~ ActiveClear
& itConsumption . laReloadTime .~ 80
& itConsumption . laLoadType . ejectTime .~ 40
& itConsumption . laLoadType . insertTime .~ 40
& itConsumption . laMax .~ 15
& itDimension . dimSPic .~ (\it -> noPic $ baseRifleShape
<> makeTinClipAt 0 (V3 10 (-2) 0) it
@@ -252,14 +248,14 @@ miniGunUse i = ruseInstant (useAmmoParams $ Just 1) NoHammer $
miniGunX :: Int -> Item
miniGunX i = defaultAutoGun
{ _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 1500
{ _itConsumption = defaultBulletLoadable
{ _laMax = 1500
, _laLoaded = 1500
, _laReloadTime = 200
}
& laLoadType . ejectTime .~ 60
& laLoadType . insertTime .~ 60
, _itUse = miniGunUse i
& useDelay .~ WarmUpNoDelay {_warmTime = 0,_warmMax = 200}
& useDelay .~ WarmUpNoDelay {_warmTime = 0,_warmMax = 100}
& useAim . aimWeight .~ 6
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
+7 -9
View File
@@ -22,7 +22,6 @@ 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
@@ -38,7 +37,7 @@ import LensHelp
--import System.Random
bangRod :: Item
bangRod = defaultGun
bangRod = defaultBulletWeapon
{ _itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 1
@@ -69,18 +68,16 @@ bangRod = defaultGun
, _dimSPic = \it -> noPic $ baseRodShape
<> makeSingleClipAt (V3 5 0 3) it
}
, _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 1
, _laReloadTime = 20
}
}
& itConsumption . laMax .~ 1
& itConsumption . laLoadType . ejectTime .~ 10
& itConsumption . laLoadType . insertTime .~ 10
& itType . iyBase .~ BANGROD
& itUse . useAim . aimWeight .~ 8
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ OneHand
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itConsumption . laType . amBulEff .~ expireAndDamage heavyBulDams
& itConsumption . laAmmoType . amBulEff .~ expireAndDamage heavyBulDams
baseRodShape :: Shape
baseRodShape = colorSH orange $ upperPrismPoly 3 $ rectXH 20 2
baseAMRShape :: Shape
@@ -145,6 +142,7 @@ machineGun = bangRod
& useDelay .~ VariableRate {_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0}
)
& itConsumption . laMax .~ 100
& itConsumption . laReloadTime .~ 75
& itConsumption . laLoadType . ejectTime .~ 25
& itConsumption . laLoadType . insertTime .~ 25
& itInvSize .~ 3
& itParams. torqueAfter .~ 0.2 -- not sure if this is necessary?
+14 -29
View File
@@ -18,7 +18,6 @@ import Dodge.Default
--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
@@ -40,14 +39,8 @@ bangStickSoundChoice it
| otherwise = shotgunS
bangStick :: Int -> Item
bangStick i = defaultGun
{ _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = i
, _laReloadTime = 10
, _laReloadType = ActivePartial 1
}
, _itUse = ruseAmmoParamsRate 8 upHammer
bangStick i = defaultBulletWeapon
{ _itUse = ruseAmmoParamsRate 8 upHammer
[ ammoHammerCheck
, useTimeCheck
, withSoundItemChoiceStart bangStickSoundChoice
@@ -84,6 +77,8 @@ bangStick i = defaultGun
}
}
& itType . iyBase .~ BANGSTICK i
& itConsumption . laMax .~ i
& itConsumption . laLoadType .~ ActivePartial 10 1 NoTransfer
baseStickShapeX :: Int -> Shape
baseStickShapeX i = foldMap f [0..i-1]
where
@@ -110,14 +105,10 @@ stickClip it = case it ^? itConsumption . laLoaded of
revolver :: Item
revolver = pistol
{ _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 6
, _laLoaded = 0
, _laReloadTime = 10
, _laReloadType = ActivePartial 1
}
}
& itConsumption .~
(defaultBulletLoadable
& laMax .~ 6
& laLoadType .~ ActivePartial 10 1 NoTransfer )
& itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> revolverClip it)
& itType . iyBase .~ REVOLVER
@@ -164,18 +155,12 @@ smgAfterHamMods =
pistol :: Item
pistol = (bangStick 1)
{ _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 15
, _laLoaded = 0
, _laReloadTime = 70
, _laReloadType = ActiveClear
}
, _itUse = ruseAmmoParamsRate 6 upHammer
(ammoHammerCheck : pistolAfterHamMods)
-- , _itZoom = defaultItZoom
-- , _itEquipPict = pictureWeaponAim pistolPic
} & itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> makeTinClipAt pi (V3 5 2 0) it)
& itConsumption .~ ( defaultBulletLoadable
& laMax .~ 15
& laLoadType . ejectTime .~ 20
& laLoadType . insertTime .~ 20 )
& itUse .~ ruseAmmoParamsRate 6 upHammer (ammoHammerCheck : pistolAfterHamMods)
& itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> makeTinClipAt pi (V3 5 2 0) it)
& itParams %~
( ( muzVel .~ 0.8 )
. ( rifling .~ 0.8 )
+18 -50
View File
@@ -8,7 +8,6 @@ module Dodge.Item.Weapon.BulletGuns
, autogunSpread
, autoGun
, autoGunPic
, longGun
, module Dodge.Item.Weapon.BulletGun.Stick
, module Dodge.Item.Weapon.BulletGun.Cane
, module Dodge.Item.Weapon.BulletGun.Rod
@@ -16,7 +15,6 @@ module Dodge.Item.Weapon.BulletGuns
import Dodge.Item.Weapon.BulletGun.Stick
import Dodge.Item.Weapon.BulletGun.Cane
import Dodge.Item.Weapon.BulletGun.Rod
import Dodge.Item.Weapon.ZoomScope
--import Dodge.Item.Weapon.BulletGun.Clip
import Dodge.Data
--import Dodge.ChainEffect
@@ -26,7 +24,6 @@ import Dodge.Item.Attachment
--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
@@ -43,12 +40,12 @@ import System.Random
autoGun :: Item
autoGun = defaultAutoGun
{ _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 30
{ _itConsumption = defaultBulletLoadable
{ _laMax = 30
, _laLoaded = 30
, _laReloadTime = 80
}
& laLoadType . ejectTime .~ 40
& laLoadType . insertTime .~ 40
, _itUse = ruseAmmoParamsRate 4 NoHammer
[ ammoCheckI
, charFiringStratI
@@ -97,14 +94,8 @@ autoGunPic it = noPic $
x = fromIntegral $ _laLoaded $ _itConsumption it
bangCone :: Item
bangCone = defaultGun
{ _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 5
, _laReloadTime = 25
, _laReloadType = ActiveClear
}
, _itUse = ruseAmmoParamsRate 20 upHammer
bangCone = defaultBulletWeapon
{ _itUse = ruseAmmoParamsRate 20 upHammer
[ ammoCheckI
, hammerCheckI
, useTimeCheck
@@ -140,10 +131,13 @@ bangCone = defaultGun
}
}
& itType . iyBase .~ BANGCONE
& itConsumption . laMax .~ 5
& itConsumption . laLoadType . ejectTime .~ 10
& itConsumption . laLoadType . insertTime .~ 10
coneRandItemUpdate :: State StdGen (Item -> Item)
coneRandItemUpdate = do
wth <- state $ randomR (1,5)
return (\it -> it & itConsumption . laType . amBulWth .~ wth)
return (\it -> it & itConsumption . laAmmoType . amBulWth .~ wth)
coneRandItemParams :: State StdGen (ItemParams -> ItemParams)
coneRandItemParams = do
muzv <- state $ randomR (0.5,1)
@@ -167,7 +161,8 @@ blunderbuss = bangCone
}
}
& itConsumption . laMax .~ 25
& itConsumption . laReloadTime .~ 30
& itConsumption . laLoadType . ejectTime .~ 15
& itConsumption . laLoadType . insertTime .~ 15
& itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimWeight .~ 6
& itType . iyBase .~ BLUNDERBUSS
@@ -175,7 +170,8 @@ bigBlunderbuss :: Item
bigBlunderbuss = blunderbuss
& itType . iyBase .~ BIGBLUNDERBUSS
& itConsumption . laMax .~ 50
& itConsumption . laReloadTime .~ 36
& itConsumption . laLoadType . ejectTime .~ 18
& itConsumption . laLoadType . insertTime .~ 18
& itParams . recoil .~ 200
& itParams . torqueAfter .~ 0.3
& itParams . randomOffset .~ 16
@@ -183,7 +179,8 @@ biggerBlunderbuss :: Item
biggerBlunderbuss = bigBlunderbuss
& itType . iyBase .~ BIGGERBLUNDERBUSS
& itConsumption . laMax .~ 75
& itConsumption . laReloadTime .~ 43
& itConsumption . laLoadType . ejectTime .~ 20
& itConsumption . laLoadType . insertTime .~ 20
& itParams . recoil .~ 250
& itParams . torqueAfter .~ 0.5
& itParams . randomOffset .~ 20
@@ -191,7 +188,8 @@ biggestBlunderbuss :: Item
biggestBlunderbuss = biggerBlunderbuss
& itType . iyBase .~ BIGGESTBLUNDERBUSS
& itConsumption . laMax .~ 100
& itConsumption . laReloadTime .~ 50
& itConsumption . laLoadType . ejectTime .~ 25
& itConsumption . laLoadType . insertTime .~ 25
& itParams . recoil .~ 300
& itParams . torqueAfter .~ 0.7
& itParams . randomOffset .~ 24
@@ -199,35 +197,5 @@ biggestBlunderbuss = biggerBlunderbuss
grenadeLauncher :: Int -> Item
grenadeLauncher _ = bangCone
longGun :: Item
longGun = defaultGun
{ _itConsumption = defaultAmmo
{ _laType = hvBullet
, _laMax = 1
, _laLoaded = 1
, _laReloadTime = 100
, _laReloadType = PassiveReload skwareFadeTwoSecS
}
, _itUse = ruseAmmoParamsRate 100 upHammer
[ ammoCheckI
, hammerCheckI
, useTimeCheck
, withSoundStart bangEchoS
, useAmmoAmount 1
, withThickSmokeI
, withTorqueAfter
, withMuzFlareI
]
& useAim . aimWeight .~ 8
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5}
& heldScroll .~ zoomLongGun
, _itAttachment = NoItAttachment
, _itScope = ZoomScope (V2 0 0) 0 1 0.1 False
-- , _itEffect = itemLaserScopeEffect
}
& itType . iyBase .~ LONGGUN
autogunSpread :: Float
autogunSpread = 0.07
+7 -9
View File
@@ -19,14 +19,8 @@ import Control.Lens
--import System.Random
droneLauncher :: Item
droneLauncher = defaultGun
{ _itConsumption = defaultAmmo
{ _laType = DroneAmmo { _amString = "LASDRONE" }
, _laMax = 2
, _laLoaded = 2
, _laReloadTime = 80
}
, _itUse = ruseRate 20 aDroneWithItemParams upHammer
droneLauncher = defaultWeapon
{ _itUse = ruseRate 20 aDroneWithItemParams upHammer
[ ammoCheckI
, useTimeCheck
, withSoundStart tap4S
@@ -37,6 +31,10 @@ droneLauncher = defaultGun
& useAim . aimStance .~ TwoHandTwist
, _itEffect = NoItEffect
}
& itConsumption . laAmmoType .~ DroneAmmo { _amString = "LASDRONE" }
& itConsumption . laMax .~ 2
& itConsumption . laLoadType . ejectTime .~ 40
& itConsumption . laLoadType . insertTime .~ 40
& itType . iyBase .~ DRONELAUNCHER
lasDronesPic :: Item -> SPic
@@ -63,7 +61,7 @@ aDroneWithItemParams it cr w = over props (IM.insert i theShell) w
{ _prPos = pos
, _pjStartPos = pos
, _pjVel = rotateV dir (V2 1 0)
, _prDraw = _amPjDraw $ _laType am
, _prDraw = _amPjDraw $ _laAmmoType am
, _pjID = i
, _pjUpdate = const id
}
+8 -8
View File
@@ -186,7 +186,7 @@ targetRBPressUpdate w t
& tgActive .~ False
targetLaserUpdate :: Item -> Creature -> World -> Targeting -> (World,Targeting)
targetLaserUpdate it cr w t
targetLaserUpdate _ cr w t
| crIsAiming cr = (addLaserPic w,t
& tgPos .~ fmap fst mp
& tgActive .~ True
@@ -205,10 +205,10 @@ targetLaserUpdate it cr w t
]
, _ptUpdate = ptSimpleTime 1
}
wpammo = _itConsumption it
reloadFrac
| _laLoaded wpammo == 0 = 1
| otherwise = case _laTransfer wpammo of
Transfer _ rs -> fromIntegral rs / fromIntegral (_laReloadTime wpammo)
NoTransfer -> 1
col = mixColors reloadFrac (1-reloadFrac) blue red
--wpammo = _itConsumption it
-- reloadFrac
-- | _laLoaded wpammo == 0 = 1
-- | otherwise = case _laTransfer wpammo of
-- Transfer _ rs -> fromIntegral rs / fromIntegral (_laReloadTime wpammo)
-- NoTransfer -> 1
col = blue -- mixColors reloadFrac (1-reloadFrac) blue red
+13 -13
View File
@@ -34,18 +34,18 @@ import Control.Lens
import Control.Applicative
launcher :: Item
launcher = defaultGun
{ _itConsumption = defaultAmmo
{ _laType = ProjectileAmmo
launcher = defaultWeapon
{ _itConsumption = defaultLoadable
& laAmmoType .~ ProjectileAmmo
{ _amPayload = makeExplosionAt
, _amString = "EXPLOSIVE SHELL"
, _amPjDraw = drawShell
, _amPjCreation = fireShell
}
, _laMax = 1
, _laLoaded = 1
, _laReloadTime = 80
}
& laMax .~ 1
& laLoaded .~ 1
& laLoadType . ejectTime .~ 40
& laLoadType . insertTime .~ 40
, _itUse = ruseRate 20 usePjCreation upHammer
[ hammerCheckI
, ammoCheckI
@@ -94,14 +94,14 @@ launcherX i = launcher
]
usePjCreation :: Item -> Creature -> World -> World
usePjCreation it = _amPjCreation (_laType (_itConsumption it)) it
usePjCreation it = _amPjCreation (_laAmmoType (_itConsumption it)) it
usePjCreationX :: Int -> Item -> Creature -> World -> World
usePjCreationX i it cr = foldr f
(_amPjCreation (_laType (_itConsumption it)) it cr)
(_amPjCreation (_laAmmoType (_itConsumption it)) it cr)
[1..i-1]
where
f n = (. _amPjCreation (_laType (_itConsumption it)) it (cr & crDir +~ (2*pi*fromIntegral n / fromIntegral i)))
f n = (. _amPjCreation (_laAmmoType (_itConsumption it)) it (cr & crDir +~ (2*pi*fromIntegral n / fromIntegral i)))
launcherPic :: Item -> SPic
launcherPic _ =
@@ -280,7 +280,7 @@ remoteLauncher = launcher
& itType . iyBase .~ REMOTELAUNCHER
& itUse . rUse .~ fireRemoteShell
& itScope .~ RemoteScope (V2 0 0) 1 True
& itConsumption . laType . amPjDraw .~ drawRemoteShell
& itConsumption . laAmmoType . amPjDraw .~ drawRemoteShell
-- TODO consider allowing tweaking rocket speed
fireRemoteShell :: Item -> Creature -> World -> World
@@ -374,13 +374,13 @@ makeShell it cr theupdate w = w & props %~ IM.insert i Shell
, _pjZ = 20
, _pjStartPos = pos
, _pjVel = rotateV dir (V2 1 0)
, _prDraw = _amPjDraw $ _laType am
, _prDraw = _amPjDraw $ _laAmmoType am
, _pjID = i
, _pjUpdate = theupdate
, _pjAcc = rotateV dir (V2 3 0)
, _pjDir = dir
, _pjSpin = 0
, _pjPayload = _amPayload $ _laType am
, _pjPayload = _amPayload $ _laAmmoType am
, _pjTimer = 50
}
where
+2 -3
View File
@@ -22,9 +22,8 @@ import Control.Lens
{- |
Sends out pulses that display walls. -}
clickDetector :: Detector -> Item
clickDetector dt = defaultGun
{ _itConsumption = defaultAmmo
, _itUse = ruseRate 20 (detectorEffect dt) upHammer
clickDetector dt = defaultWeapon
{ _itUse = ruseRate 20 (detectorEffect dt) upHammer
[ ammoUseCheck
]
& useAim . aimRange .~ 1
+1 -2
View File
@@ -27,9 +27,8 @@ import LensHelp
import qualified Data.IntMap.Strict as IM
shatterGun :: Item
shatterGun = defaultGun
shatterGun = defaultWeapon
& itType . iyBase .~ SHATTERGUN
& itConsumption .~ defaultAmmo
& itUse .~ ruseRate 10 shootShatter upHammer
[ ammoHammerCheck
, useTimeCheck
+4 -5
View File
@@ -30,11 +30,10 @@ import LensHelp
sonicGun :: Item
sonicGun = defaultAutoGun
{ _itConsumption = defaultAmmo
{ _laMax = 10
, _laLoaded = 10
, _laReloadTime = 80
}
{ _itConsumption = defaultLoadable
& laMax .~ 10
& laLoadType . ejectTime .~ 40
& laLoadType . insertTime .~ 40
, _itUse = ruseRate 8 aSonicWave (HasHammer HammerUp)
[ ammoHammerCheck
, useTimeCheck
+5 -6
View File
@@ -15,12 +15,11 @@ import Control.Lens
{- |
Creates a creature next to the creature using the item. -}
spawnGun :: Creature -> Item
spawnGun cr = defaultGun
{ _itConsumption = defaultAmmo
{ _laMax = 1
, _laLoaded = 1
, _laReloadTime = 80
}
spawnGun cr = defaultWeapon
{ _itConsumption = defaultLoadable
& laMax .~ 1
& laLoadType . ejectTime .~ 40
& laLoadType . insertTime .~ 40
, _itUse = ruseRate 100
(\_ -> spawnCrNextTo cr)
upHammer
+9 -9
View File
@@ -40,7 +40,7 @@ import System.Random
poisonSprayer :: Item
poisonSprayer = flameThrower
& itType . iyBase .~ POISONSPRAYER
& itConsumption . laType .~ GasAmmo
& itConsumption . laAmmoType .~ GasAmmo
{ _amString = "POISONGAS"
, _amCreateGas = aGasCloud
}
@@ -68,7 +68,8 @@ flameSpitter :: Item
flameSpitter = flameThrower
& itType . iyBase .~ FLAMESPITTER
& itConsumption . laMax .~ 10
& itConsumption . laReloadTime .~ 20
& itConsumption . laLoadType . ejectTime .~ 10
& itConsumption . laLoadType . insertTime .~ 10
& itParams . sprayNozzles . ix 0 . nzPressure .~ 4
& itUse . useAim . aimStance .~ OneHand
& itUse . useDelay .~ FixedRate {_rateMax =12,_rateTime = 0}
@@ -116,15 +117,14 @@ flameWall = flameThrower
flameThrower :: Item
flameThrower = defaultAutoGun
{ _itConsumption = defaultAmmo
{ _laMax = 250
, _laLoaded = 0
, _laReloadTime = 100
, _laType = GasAmmo
{ _itConsumption = defaultLoadable
& laMax .~ 250
& laAmmoType .~ GasAmmo
{_amString = "FLAME"
,_amCreateGas = aFlame
}
}
& laLoadType . ejectTime .~ 40
& laLoadType . insertTime .~ 40
, _itUse = ruseInstant (overNozzles useGasParams) NoHammer
[ ammoCheckI
, useAmmoAmount 1
@@ -191,7 +191,7 @@ overNozzle eff it cr w nz =
wa = min maxa $ max (negate maxa) (_nzCurrentWalkAngle nz + walkamount)
useGasParams :: Nozzle -> Item -> Creature -> World -> World
useGasParams nz it cr = _amCreateGas (_laType (_itConsumption it)) (_nzPressure nz) pos dir cr
useGasParams nz it cr = _amCreateGas (_laAmmoType (_itConsumption it)) (_nzPressure nz) pos dir cr
where
dir = _crDir cr
pos = _crPos cr +.+ (_nzLength nz *.* unitVectorAtAngle (_crDir cr))
+5 -5
View File
@@ -173,15 +173,15 @@ rateIncAB exeffFirst exeffCont eff item cr w
itRef = _crInvSel cr
pointItem = creatures . ix cid . crInv . ix itRef
currentRate = _rateMax (_useDelay (_itUse item))
repeatFire = _laTransfer (_itConsumption item) == NoTransfer && _rateTime (_useDelay (_itUse item)) == 1
firstFire = _laTransfer (_itConsumption item) == NoTransfer && _rateTime (_useDelay (_itUse item)) == 0
repeatFire = _loadProgress (_laLoadType $ _itConsumption item) == NoTransfer && _rateTime (_useDelay (_itUse item)) == 1
firstFire = _loadProgress (_laLoadType $ _itConsumption item) == NoTransfer && _rateTime (_useDelay (_itUse item)) == 0
{- | Apply effect after a warm up. -}
-- note this is quite unsafe, requires the item to have the correct delay type
withWarmUp
:: SoundID -- ^ warm up sound id
-> ChainEffect
withWarmUp soundID f item cr w
| _laTransfer (_itConsumption item) /= NoTransfer = w
| _loadProgress (_laLoadType $ _itConsumption item) /= NoTransfer = w
| curWarmUp < maxWarmUp = w
& pointerToItem . itUse . useDelay . warmTime +~ 2
& soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2)
@@ -323,7 +323,7 @@ ammoUseCheck f item cr w
cid = _crID cr
itRef = _crInvSel cr
pointerToItem = creatures . ix cid . crInv . ix itRef
fireCondition = _laTransfer (_itConsumption item) == NoTransfer
fireCondition = _loadProgress (_laLoadType $ _itConsumption item) == NoTransfer
&& _rateTime (_useDelay (_itUse item)) == 0
&& _laLoaded (_itConsumption item) > 0
-- reloadCondition = _laLoaded (_itConsumption item) == 0
@@ -359,7 +359,7 @@ shootL f item cr w
cid = _crID cr
invid = fromJust $ _itInvPos item
pointerToItem = creatures . ix cid . crInv . ix invid
fireCondition = _laTransfer (_itConsumption item) == NoTransfer
fireCondition = _loadProgress (_laLoadType $ _itConsumption item) == NoTransfer
&& _rateTime (_useDelay (_itUse item)) == 0
&& _laLoaded (_itConsumption item) > 0
-- reloadCondition = _laLoaded (_itConsumption item) == 0
+8 -10
View File
@@ -22,7 +22,7 @@ import Control.Lens
--import Control.Monad
rewindGun :: Item
rewindGun = defaultGun
rewindGun = defaultLeftItem
{ _itInvColor = cyan
, _itConsumption = ChargeableAmmo
{ _wpMaxCharge = 250
@@ -63,9 +63,8 @@ useRewindGun _ _ w = case _rewindWorlds w of
-- needs to shift this item to the current inventory slot
shrinkGun :: Item
shrinkGun = defaultGun
{ _itConsumption = defaultAmmo
, _itUse = defaultlUse {_lUse = hammerCheckL useShrinkGun}
shrinkGun = defaultLeftItem
{_itUse = defaultlUse {_lUse = hammerCheckL useShrinkGun}
& useHammer .~ upHammer
-- , _itFloorPict = shrinkGunPic
, _itAttachment = AttachBool True
@@ -89,9 +88,8 @@ useShrinkGun it cr w = if _atBool $ _itAttachment it
( (itAttachment . atBool .~ isInUse) . (itCurseStatus .~ cstatus) )
blinkGun :: Item
blinkGun = defaultGun
blinkGun = defaultLeftItem
{ _itInvColor = cyan
, _itConsumption = defaultAmmo
, _itUse = defaultlUse
& lUse .~ hammerCheckL (shootL $ const blinkAction)
& useHammer .~ upHammer
@@ -107,20 +105,20 @@ unsafeBlinkGun = blinkGun
& itUse . eqEq . eqViewDist ?~ 400
effectGun :: String -> (Creature -> World -> World) -> Item
effectGun name eff = defaultGun
effectGun name eff = defaultWeapon
{ _itUse = defaultrUse
& rUse .~ const eff
& useMods .~ [hammerCheckI]
}
& itType . iyBase .~ EFFGUN name
autoEffectGun :: String -> (Creature -> World -> World) -> Item
autoEffectGun name eff = defaultGun
autoEffectGun name eff = defaultWeapon
{ _itUse = defaultrUse {_rUse = const eff}
}
& itType . iyBase .~ AUTOEFFGUN name
forceFieldGun :: Item
forceFieldGun = defaultGun
{ _itConsumption = defaultAmmo & laType .~ ForceFieldAmmo forceField
forceFieldGun = defaultWeapon
{ _itConsumption = defaultLoadable & laAmmoType .~ ForceFieldAmmo forceField
, _itUse = ruseInstant useForceFieldGun (HasHammer HammerUp)
[ hammerCheckI , ammoCheckI , useAmmoAmount 1]
-- , _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-4,-4),(-4,4),(4,4),(4,0),(0,0),(0,-4)]