Commit before changing module system to Map

This commit is contained in:
2022-02-21 07:50:15 +00:00
parent 779e076c93
commit 724ee21afc
25 changed files with 171 additions and 86 deletions
+12
View File
@@ -0,0 +1,12 @@
module Dodge.Item.MaxAmmo where
import Dodge.Data
import Control.Lens
itMaxAmmo :: Item -> Int
itMaxAmmo it = _ammoBaseMax (_itConsumption it)
+ maybe 0 f (it ^? itModules . modRifleMag . theModule)
where
f DrumMag = 45
f BeltMag = 135
f MagnetMag = 0
+9 -3
View File
@@ -7,6 +7,7 @@ module Dodge.Item.Weapon.AmmoParams
, fractionLoadedAmmo2
) where
import Dodge.Data
import Dodge.Item.MaxAmmo
import Dodge.Particle.Bullet.Spawn
import Dodge.Creature.HandPos
import Dodge.WorldEvent.HitEffect
@@ -54,9 +55,13 @@ useAmmoParams it cr = withVelWthHiteff
useAmmoParamsVelMod :: Float -> Item -> Creature -> World -> World
useAmmoParamsVelMod vfact it = withDelayedVelWthHiteff vfact (_amBulVel b) (_rifling $ _itParams it)
(_amBulWth b) (_amBulEff b)
(_amBulWth b)
-- (_amBulEff b)
bulHitEff
where
b = _aoType $ _itConsumption it
bulHitEff = fromMaybe (destroyOnImpact bulHitCr bulHitWall)
$ it ^? itModules . modHitEffect . theModule
{- | Creates a bullet with a given velocity, width, and 'HitEffect' -}
withVelWthHiteff
@@ -98,7 +103,8 @@ loadedAmmo it
| otherwise = 0
fractionLoadedAmmo :: Item -> Float
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (_ammoMax (_itConsumption it))
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (itMaxAmmo it)
fractionLoadedAmmo2 :: Item -> Float
fractionLoadedAmmo2 it = 1 - (1 - fromIntegral (loadedAmmo it) / fromIntegral (_ammoMax (_itConsumption it)))**2
fractionLoadedAmmo2 it = 1 -
(1 - fromIntegral (loadedAmmo it) / fromIntegral (itMaxAmmo it))**2
+3 -3
View File
@@ -35,7 +35,7 @@ teslaGun = defaultGun
{ _itName = "TESLA"
, _itType = TESLAGUN
, _itConsumption = defaultAmmo
{ _ammoMax = 200
{ _ammoBaseMax = 200
, _ammoLoaded = 200
, _reloadTime = 80
}
@@ -69,7 +69,7 @@ lasGun = defaultAutoGun
{ _itName = "LASGUN"
, _itType = LASGUN
, _itConsumption = defaultAmmo
{ _ammoMax = 200
{ _ammoBaseMax = 200
, _ammoLoaded = 200
, _reloadTime = 80
}
@@ -129,7 +129,7 @@ tractorGun = lasGun
{ _itName = "TRACTORGUN"
, _itType = TRACTORGUN
, _itConsumption = defaultAmmo
{ _ammoMax = 10000
{ _ammoBaseMax = 10000
, _ammoLoaded = 10000
, _reloadTime = 40
}
+1 -1
View File
@@ -43,7 +43,7 @@ bezierGun = defaultGun
, _itEffect = rbSetTarget
-- , _itZoom = defaultItZoom
, _itConsumption = defaultAmmo
{ _ammoMax = 50
{ _ammoBaseMax = 50
}
}
+1 -1
View File
@@ -115,7 +115,7 @@ boosterGun = defaultGun
, _itType = BOOSTER
, _itInvColor = cyan
, _itConsumption = defaultAmmo
{ _ammoMax = 100
{ _ammoBaseMax = 100
, _ammoLoaded = 100
, _reloadTime = 20
}
+11 -7
View File
@@ -53,7 +53,7 @@ bangCane = defaultGun
}
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 1
, _ammoBaseMax = 1
, _reloadTime = 20
, _reloadType = ActivePartial 1
}
@@ -115,7 +115,7 @@ bangCaneX i = bangCane
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandFlat
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itConsumption . ammoMax .~ i
& itConsumption . ammoBaseMax .~ i
& itParams . gunBarrels .~ MultiBarrel
{_brlSpread = AlignedBarrels
,_brlNum = i
@@ -145,21 +145,23 @@ rifle = bangCane
, _dimSPic = \it -> noPic $ baseRifleShape
<> makeSingleClipAt (V3 5 0 3) it
}
, _itModules = ItemModules
{ _modHitEffect = DefaultModule }
}
& itUse . useAim . aimStance .~ TwoHandTwist
& itName .~ "RIFLE"
& itType .~ RIFLE
& itConsumption . ammoMax .~ 1
& itConsumption . ammoBaseMax .~ 1
repeater :: Item
repeater = rifle
& itModules .~ ItemModules
{ _modHitEffect = DefaultModule
, _modRifleMag = DefaultModule
}
& itName .~ "REPEATER"
& itType .~ REPEATER
& itConsumption . reloadType .~ ActiveClear
& itConsumption . reloadTime .~ 80
& itConsumption . ammoMax .~ 15
& itConsumption . ammoBaseMax .~ 15
& itDimension . dimSPic .~ (\it -> noPic $ baseRifleShape
<> makeTinClipAt 0 (V3 10 (-2) 0) it
)
@@ -216,6 +218,7 @@ completeBurstRifle :: Item
completeBurstRifle = repeater
& itName .~ "COMPLETEBURSTRIFLE"
& itType .~ COMPLETEBURSTRIFLE
& itModules . modRifleMag .~ BlockedModule
& itParams . gunBarrels . brlInaccuracy .~ 0.1
& itUse . useDelay . rateMax .~ 28
& itUse . useMods .~
@@ -263,7 +266,7 @@ miniGunX i = defaultAutoGun
, _itType = MINIGUNX i
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 1500
, _ammoBaseMax = 1500
, _ammoLoaded = 1500
, _reloadTime = 200
}
@@ -291,6 +294,7 @@ miniGunX i = defaultAutoGun
["*" ++ replicate 13 ' ' ++ "*"
,"* " ++ fromMaybe " " (maybeWarmupStatus it) ++ " *"
,"*" ++ replicate 13 ' ' ++ "*" ]
++ moduleStrings it
, _itDimension = ItemDimension
{ _dimRad = 20
, _dimCenter = V3 5 0 0
+2 -2
View File
@@ -65,7 +65,7 @@ bangRod = defaultGun
}
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 1
, _ammoBaseMax = 1
, _reloadTime = 20
, _reloadType = ActiveClear
}
@@ -101,7 +101,7 @@ amr :: Item
amr = elephantGun
& itName .~ "AMR"
& itType .~ AMR
& itConsumption . ammoMax .~ 15
& itConsumption . ammoBaseMax .~ 15
& itDimension . dimSPic .~ (\it -> noPic $ baseAMRShape
<> makeTinClipAt 0 (V3 10 (-2) 0) it
)
+4 -4
View File
@@ -48,7 +48,7 @@ bangStick i = defaultGun
, _itType = BANGSTICK i
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = i
, _ammoBaseMax = i
, _reloadTime = 15
, _reloadType = ActivePartial 1
}
@@ -119,7 +119,7 @@ revolver = pistol
, _itType = REVOLVER
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 6
, _ammoBaseMax = 6
, _ammoLoaded = 0
, _reloadTime = 15
, _reloadType = ActivePartial 1
@@ -174,7 +174,7 @@ pistol = (bangStick 1)
, _itType = PISTOL
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 15
, _ammoBaseMax = 15
, _ammoLoaded = 0
, _reloadTime = 70
, _reloadType = ActiveClear
@@ -233,4 +233,4 @@ revolverX i = revolver
, torqueAfterI 0.2
, withRecoilI 10
]
} & itConsumption . ammoMax .~ i * 6
} & itConsumption . ammoBaseMax .~ i * 6
+12 -12
View File
@@ -55,7 +55,7 @@ autoGun = defaultAutoGun
, _itType = AUTOGUN
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 30
, _ammoBaseMax = 30
, _ammoLoaded = 30
, _reloadTime = 80
}
@@ -109,7 +109,7 @@ bangCone = defaultGun
, _itType = BANGCONE
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 5
, _ammoBaseMax = 5
, _reloadTime = 25
, _reloadType = ActiveClear
}
@@ -194,7 +194,7 @@ blunderbuss = bangCone
<> upperPrismPoly 6 (rectNSEW 4 (-4) 30 20)
}
}
& itConsumption . ammoMax .~ 25
& itConsumption . ammoBaseMax .~ 25
& itConsumption . reloadTime .~ 30
bigBlunderbuss :: Item
bigBlunderbuss = blunderbuss
@@ -218,7 +218,7 @@ bigBlunderbuss = blunderbuss
& useAim . aimStance .~ TwoHandTwist
& useAim . aimSpeed .~ 0.4
}
& itConsumption . ammoMax .~ 50
& itConsumption . ammoBaseMax .~ 50
& itConsumption . reloadTime .~ 36
biggerBlunderbuss :: Item
biggerBlunderbuss = bigBlunderbuss
@@ -242,7 +242,7 @@ biggerBlunderbuss = bigBlunderbuss
& useAim . aimStance .~ TwoHandTwist
& useAim . aimSpeed .~ 0.4
}
& itConsumption . ammoMax .~ 75
& itConsumption . ammoBaseMax .~ 75
& itConsumption . reloadTime .~ 43
biggestBlunderbuss :: Item
biggestBlunderbuss = biggerBlunderbuss
@@ -266,7 +266,7 @@ biggestBlunderbuss = biggerBlunderbuss
& useAim . aimStance .~ TwoHandTwist
& useAim . aimSpeed .~ 0.4
}
& itConsumption . ammoMax .~ 100
& itConsumption . ammoBaseMax .~ 100
& itConsumption . reloadTime .~ 50
grapeShotCannon :: Item
@@ -291,7 +291,7 @@ grapeShotCannon = blunderbuss
& useAim . aimStance .~ TwoHandTwist
& useAim . aimSpeed .~ 0.4
}
& itConsumption . ammoMax .~ 15
& itConsumption . ammoBaseMax .~ 15
& itConsumption . reloadTime .~ 30
grenadeLauncher :: Int -> Item
@@ -305,7 +305,7 @@ hvAutoGun = defaultAutoGun
, _itType = HVAUTOGUN
, _itConsumption = defaultAmmo
{ _aoType = hvBullet
, _ammoMax = 100
, _ammoBaseMax = 100
, _ammoLoaded = 100
, _reloadTime = 200
}
@@ -334,7 +334,7 @@ ltAutoGun = defaultAutoGun
, _itType = LTAUTOGUN
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 15
, _ammoBaseMax = 15
, _ammoLoaded = 0
, _reloadTime = 90
}
@@ -363,7 +363,7 @@ spreadGun = defaultGun
, _itType = SPREADGUN
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 5
, _ammoBaseMax = 5
, _ammoLoaded = 5
, _reloadTime = 80
}
@@ -396,7 +396,7 @@ multGun = defaultGun
, _itType = MULTGUN
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 5
, _ammoBaseMax = 5
, _ammoLoaded = 2
, _reloadTime = 10
, _reloadType = ActivePartial 1
@@ -434,7 +434,7 @@ longGun = defaultGun
, _itType = LONGGUN
, _itConsumption = defaultAmmo
{ _aoType = hvBullet
, _ammoMax = 1
, _ammoBaseMax = 1
, _ammoLoaded = 1
, _reloadTime = 100
, _reloadType = PassiveReload skwareFadeTwoSecS
+1 -1
View File
@@ -24,7 +24,7 @@ lasDrones = defaultGun
, _itType = DRONELAUNCHER
, _itConsumption = defaultAmmo
{ _aoType = DroneAmmo { _amString = "LASDRONE" }
, _ammoMax = 2
, _ammoBaseMax = 2
, _ammoLoaded = 2
, _reloadTime = 80
}
+7 -2
View File
@@ -5,6 +5,7 @@ module Dodge.Item.Weapon.InventoryDisplay
( basicItemDisplay
, maybeWarmupStatus
, maybeRateStatus
, moduleStrings
) where
import Dodge.Data
import Padding
@@ -17,9 +18,8 @@ import Control.Lens
basicItemDisplay :: Item -> [String]
basicItemDisplay it = Prelude.take (itSlotsTaken it) $
(midPadL 15 ' ' thename (' ' : thenumber) ++ theparam)
: moduleStrings ++ repeat "*"
: moduleStrings it ++ repeat "*"
where
moduleStrings = fromMaybe [] $ it ^? itModules . modHitEffect . modName
thename = _itName it
thenumber = case it ^? itConsumption of
Just am@LoadableAmmo{} -> case _reloadState am of
@@ -37,6 +37,11 @@ basicItemDisplay it = Prelude.take (itSlotsTaken it) $
-- , maybeRateStatus
]
moduleStrings :: Item -> [String]
moduleStrings it = map (" " ++)
$ (fromMaybe [] $ it ^? itModules . modHitEffect . modName)
++ (fromMaybe [] $ it ^? itModules . modRifleMag . modName)
maybeModeStatus :: Item -> Maybe String
maybeModeStatus it = case it ^? itAttachment of
Just ItCharMode {_itCharMode = (c :<| _)} -> Just [' ',c]
+2 -2
View File
@@ -44,7 +44,7 @@ launcher = defaultGun
, _amString = "EXPLOSIVE SHELL"
, _amPjDraw = shellPic
}
, _ammoMax = 30
, _ammoBaseMax = 30
, _ammoLoaded = 30
, _reloadTime = 80
}
@@ -271,7 +271,7 @@ remoteLauncher = launcher
, _amString = ""
, _amPjDraw = shellPic
}
, _ammoMax = 30
, _ammoBaseMax = 30
, _ammoLoaded = 30
, _reloadTime = 80
}
+2 -2
View File
@@ -22,7 +22,7 @@ radar = defaultGun
{ _itName = "RADAR"
, _itType = RADAR
, _itConsumption = defaultAmmo
{ _ammoMax = 100
{ _ammoBaseMax = 100
, _ammoLoaded = 100
, _reloadTime = 200
}
@@ -41,7 +41,7 @@ sonar = defaultGun
{ _itName = "SONAR"
, _itType = RADAR
, _itConsumption = defaultAmmo
{ _ammoMax = 100
{ _ammoBaseMax = 100
, _ammoLoaded = 100
, _reloadTime = 200
}
+1 -1
View File
@@ -33,7 +33,7 @@ sonicGun = defaultAutoGun
{ _itName = "SONICGUN"
, _itType = SONICGUN
, _itConsumption = defaultAmmo
{ _ammoMax = 10
{ _ammoBaseMax = 10
, _ammoLoaded = 10
, _reloadTime = 80
}
+1 -1
View File
@@ -18,7 +18,7 @@ spawnGun :: Creature -> Item
spawnGun cr = defaultGun
{ _itName = "SPAWNER"
, _itConsumption = defaultAmmo
{ _ammoMax = 1
{ _ammoBaseMax = 1
, _ammoLoaded = 1
, _reloadTime = 80
}
+2 -2
View File
@@ -38,7 +38,7 @@ poisonSprayer = defaultAutoGun
{ _itName = "POISON"
, _itType = SPRAYER
, _itConsumption = defaultAmmo
{ _ammoMax = 500
{ _ammoBaseMax = 500
, _ammoLoaded = 500
, _reloadTime = 100
}
@@ -92,7 +92,7 @@ flamer = defaultAutoGun
{ _itName = "FLAMER"
, _itType = SQUIRTER
, _itConsumption = defaultAmmo
{ _ammoMax = 250
{ _ammoBaseMax = 250
, _ammoLoaded = 250
, _reloadTime = 100
}
+3 -3
View File
@@ -60,7 +60,7 @@ shrinkGun = defaultGun
{ _itName = "SHRINKER"
, _itType = SHRINKER
, _itConsumption = defaultAmmo
{ _ammoMax = 100
{ _ammoBaseMax = 100
, _ammoLoaded = 100
, _reloadTime = 20
}
@@ -91,7 +91,7 @@ blinkGun = defaultGun
, _itType = BLINKER
, _itInvColor = cyan
, _itConsumption = defaultAmmo
{ _ammoMax = 100
{ _ammoBaseMax = 100
, _ammoLoaded = 100
, _reloadTime = 20
}
@@ -123,7 +123,7 @@ forceFieldGun = defaultGun
{ _itName = "FORCEFIELD"
, _itType = FORCEFIELD
, _itConsumption = defaultAmmo
{ _ammoMax = 100
{ _ammoBaseMax = 100
, _ammoLoaded = 100
, _reloadTime = 40
, _reloadState = Nothing'