Defunction-ify item modules, requires more cleanup

This commit is contained in:
2022-06-08 12:28:11 +01:00
parent d91a53f76c
commit bcbfd7d2fa
48 changed files with 762 additions and 740 deletions
+25 -45
View File
@@ -8,12 +8,13 @@ import Dodge.Particle.Damage
import Dodge.Item.Equipment
import Dodge.Item.Craftable
import Dodge.Item.Weapon
import Dodge.Combine.Module
import Dodge.Base
import LensHelp
import Data.Maybe
itemCombinations :: [([(Int,CombineType)],Item)]
itemCombinations :: [([(Int,ItemBaseType)],Item)]
itemCombinations =
[ po [PIPE, HARDWARE] (bangStick 1)
, po [BANGSTICK 1, TIN] pistol
@@ -90,7 +91,8 @@ itemCombinations =
++ map (\i -> po [REVOLVERX i,CAN] $ revolverX (i+1)) [1..5]
++ map (\i -> p [o (BANGCANEX i),p 2 PIPE] $ bangCaneX (i+1)) [1..5]
++ map (\i -> po [MINIGUNX i,BANGCANE] $ miniGunX (i+1)) [3..15]
++ [ po (_itType it:mtype) $ it & itModules . ix modtype .~ m
++ [ po (_iyBase (_itType it):mtype) $ it & itType . iyModules . ix modtype .~ m
| (modtype,is,ms) <- moduleCombinations
, it <- is
, (mtype,m) <- ms
@@ -100,7 +102,7 @@ itemCombinations =
po xs it = (map o xs,it)
o = (1,)
moduleCombinations :: [( ModuleSlot, [Item], [([CombineType],ItemModule)] )]
moduleCombinations :: [( ModuleSlot, [Item], [([ItemBaseType],ItemModuleType)] )]
moduleCombinations =
[ ( ModRifleMag
, [repeater
@@ -108,8 +110,8 @@ moduleCombinations =
,burstRifle
,fastBurstRifle
]
, [amod [DRUM,HARDWARE] "+DRUM MAG" (itConsumption . laMax .~ 45)
,amod [MOTOR,HARDWARE] "+BELT FEED" (itConsumption . laMax .~ 150)
, [amod [DRUM,HARDWARE] DRUMMAG
,amod [MOTOR,HARDWARE] BELTMAG
]
)
, ( ModAutoMag
@@ -117,78 +119,56 @@ moduleCombinations =
,autoPistol
,smg
]
, [amod [MAGNET,HARDWARE] "+MAGNET FEED" (itUse . useDelay . rateMax .~ 4)
, [amod [MAGNET,HARDWARE] MAGNETMAG
]
)
, ( ModBullet
, bulletWeapons
, [amod [INCENDIARYMODULE] "+INCENDIARY" (f $ expireAndDamage $ spawnAtBulDams incBall)
,amod [BOUNCEMODULE] "+BOUNCE" (f $ expireAndDamage bounceBulDams)
,amod [STATICMODULE] "+STATIC" (f $ expireAndDamage $ spawnAtBulDams aStaticBall)
,amod [CONCUSSMODULE] "+CONCUSS" (f $ expireAndDamage $ spawnAtBulDams concBall)
, [amod [INCENDIARYMODULE] INCENDBUL
,amod [BOUNCEMODULE] BOUNCEBUL
,amod [STATICMODULE] STATICBUL
,amod [CONCUSSMODULE] CONCUSBUL
]
)
, ( ModTarget
, homingLaunchers ++ bulletWeapons
, [amod [MICROCHIP,CREATURESENSOR] "+CREATURETARGETING" (itTargeting .~ targetRBCreature)
,amod [MICROCHIP,PRISM] "+LASERTARGETING" (itTargeting .~ targetLaser)
,amod [MICROCHIP,TIN] "+POSTIONALTARGETING" (itTargeting .~ targetRBPress)
, [amod [MICROCHIP,CREATURESENSOR] TARGCR
,amod [MICROCHIP,PRISM] TARGLAS
,amod [MICROCHIP,TIN] TARGPOS
]
)
, ( ModBulletTrajectory
, bulletWeapons
, [amod [MAGNET,MICROCHIP,HARDWARE] "+MAGNETTRAJECTORY"
( (itConsumption . laType . amBulTraj .~ MagnetTrajectory)
. (itConsumption . laType . amBulVel .~ V2 10 0)
)
,amod [MICROCHIP,HARDWARE] "+FLECHETTETRAJECTORY"
(itConsumption . laType . amBulTraj .~ FlechetteTrajectory)
,amod [ANTIMATTER,HARDWARE] "+BEZIERTRAJECTORY"
(itConsumption . laType . amBulTraj .~ BezierTrajectory)
, [amod [MAGNET,MICROCHIP,HARDWARE] MAGNETTRAJ
,amod [MICROCHIP,HARDWARE] FLECHETRAJ
,amod [ANTIMATTER,HARDWARE] BEZIERTRAJ
]
)
, ( ModDualBeam
, [lasGunDual]
, [amod [INCENDIARYMODULE] "+INCENDIARY" (itParams . lasBeam .~ BeamCombine flameBeamCombine)
,amod [STATICMODULE] "+STATIC"
( (itParams . lasBeam .~ BeamCombine teslaBeamCombine)
. (itParams . subParams ?~ teslaParams)
)
,amod [TRANSFORMER] "+SPLIT" (itParams . lasBeam .~ BeamCombine splitBeamCombine)
, [amod [INCENDIARYMODULE] INCENDLAS
,amod [TRANSFORMER] SPLITLAS
,amod [STATICMODULE] STATICLAS
]
)
, ( ModTeleport
, teleportableWeapons
, [amod [TELEPORTMODULE,MICROCHIP] "+DIRECTEDTELE" makeDirectedTele
, [amod [TELEPORTMODULE,MICROCHIP] WEPTELE
]
)
, ( ModLauncherHoming
, homingLaunchers
, [ amod [MICROCHIP,TRANSMITTER] "+TARGET HOMING"
(itConsumption . laType . amPjCreation .~ fireTrackingShell)
, [ amod [MICROCHIP,TRANSMITTER] LAUNCHHOME
]
)
, ( ModBattery
, batteryGuns
, [amod [BATTERY] "+BATTERY" (itConsumption . laMax +~ 1000)
, [amod [BATTERY] EXTRABATTERY
]
)
]
where
makeDirectedTele it = it
& itTargeting .~ targetRBPress
& itUse . useMods .:~ withPosDirWallCheck directedTelPos
-- for the camera: the simplest option is to remove all zoom/offset
& itUse . useAim . aimZoom . itZoomFac .~ 1
& itUse . useAim . aimRange .~ 0
-- a better option would be to involve a "scope" centered on the firing
-- position
directedTelPos it cr w = (p,a)
where
p = fromMaybe (_crPos cr) $ it ^? itTargeting . tgPos . _Just
a = argV (mouseWorldPos w -.- p)
f ameff = itConsumption . laType . amBulEff .~ ameff
amod cts str func = (cts,ItemModule [str] 1 func)
amod = (,)
homingLaunchers :: [Item]
homingLaunchers = launcher : [launcherX i | i <- [2..10]]
+56 -4
View File
@@ -1,11 +1,22 @@
{-# LANGUAGE TemplateHaskell #-}
module Dodge.Combine.Data
(CombineType (..)
,Detector (..)
) where
where
import Dodge.Equipment.Data
import Control.Lens
import qualified Data.Map.Strict as M
-- this should probably store loaded ammo
data ItemType = ItemType
{_iyBase :: ItemBaseType
,_iyModules :: M.Map ModuleSlot ItemModuleType
}
deriving (Eq,Ord,Show)
-- TODO make this an enum somehow...?
data CombineType
data ItemBaseType
= NOTDEFINED
| EFFGUN String
| AUTOEFFGUN String
-- Weapons
| BANGSTICK Int
| PISTOL
@@ -76,6 +87,7 @@ data CombineType
| BLINKERUNSAFE
| FORCEFIELDGUN
| SHRINKER
| SPAWNER
-- Equipment
| CLICKDETECTOR Detector
| AUTODETECTOR Detector
@@ -86,6 +98,7 @@ data CombineType
| INVISIBILITYEQUIPMENT EquipSite
| BRAINHAT
| HEADLAMP
| HEADLAMP1
| POWERLEGS
| SPEEDLEGS
| JUMPLEGS
@@ -141,11 +154,50 @@ data CombineType
--
| KEYCARD Int
--
| MEDKIT Int
--
| NoCombineType
deriving (Eq,Ord,Show)
data ItemModuleType
= EMPTYMODULE
| DRUMMAG
| BELTMAG
| MAGNETMAG
| INCENDBUL
| BOUNCEBUL
| STATICBUL
| CONCUSBUL
| TARGCR
| TARGLAS
| TARGPOS
| MAGNETTRAJ
| FLECHETRAJ
| BEZIERTRAJ
| INCENDLAS
| SPLITLAS
| STATICLAS
| WEPTELE
| LAUNCHHOME
| EXTRABATTERY
deriving (Eq,Ord,Show)
data Detector
= ITEMDETECTOR
| CREATUREDETECTOR
| WALLDETECTOR
deriving (Eq,Ord,Show)
data ModuleSlot
= ModBullet
| ModRifleMag
| ModAutoMag
| ModTarget
| ModBulletTrajectory
| ModLauncherHoming
| ModBattery
| ModTeleport
| ModDualBeam
deriving (Eq,Ord,Show)
makeLenses ''ItemType
+64
View File
@@ -0,0 +1,64 @@
module Dodge.Combine.Module where
import Dodge.Data
import Dodge.Tesla
import Dodge.Particle.HitEffect.ExpireAndDamage
import Dodge.WorldEvent.SpawnParticle
import Dodge.Particle.Damage
import Dodge.IncBall
import Dodge.Item.Weapon.ExtraEffect
import Dodge.Item.Weapon.Launcher
import Dodge.Item.Weapon.TriggerType
import LensHelp
import Geometry
--import Dodge.Item.Weapon.BatteryGuns
import Dodge.Beam
import Dodge.Base.Coordinate
import Data.Maybe
fromModuleType :: ItemModuleType -> ItemModule
fromModuleType imt = case imt of
EMPTYMODULE -> ItemModule ["EMPTYMODULE"] 1 id
DRUMMAG -> mod "+DRUM MAG" (itConsumption . laMax .~ 45)
BELTMAG -> mod "+BELT FEED" (itConsumption . laMax .~ 150)
MAGNETMAG -> mod "+MAGNET FEED" (itUse . useDelay . rateMax .~ 4)
INCENDBUL -> mod "+INCENDIARY" (f $ expireAndDamage $ spawnAtBulDams incBall)
BOUNCEBUL -> mod "+BOUNCE" (f $ expireAndDamage bounceBulDams)
STATICBUL -> mod "+STATIC" (f $ expireAndDamage $ spawnAtBulDams aStaticBall)
CONCUSBUL -> mod "+CONCUSS" (f $ expireAndDamage $ spawnAtBulDams concBall)
TARGCR -> mod "+CREATURETARGETING" (itTargeting .~ targetRBCreature)
TARGLAS -> mod "+LASERTARGETING" (itTargeting .~ targetLaser)
TARGPOS -> mod "+POSTIONALTARGETING" (itTargeting .~ targetRBPress)
MAGNETTRAJ -> mod "+MAGNETTRAJECTORY"
( (itConsumption . laType . amBulTraj .~ MagnetTrajectory)
. (itConsumption . laType . amBulVel .~ V2 10 0)
)
FLECHETRAJ -> mod "+FLECHETTETRAJECTORY"
(itConsumption . laType . amBulTraj .~ FlechetteTrajectory)
BEZIERTRAJ -> mod "+BEZIERTRAJECTORY"
(itConsumption . laType . amBulTraj .~ BezierTrajectory)
INCENDLAS -> mod "+INCENDIARY" (itParams . lasBeam .~ BeamCombine flameBeamCombine)
SPLITLAS -> mod "+SPLIT" (itParams . lasBeam .~ BeamCombine splitBeamCombine)
STATICLAS -> mod "+STATIC"
( (itParams . lasBeam .~ BeamCombine teslaBeamCombine)
. (itParams . subParams ?~ teslaParams)
)
WEPTELE -> mod "+DIRECTEDTELE" makeDirectedTele
LAUNCHHOME -> mod "+TARGET HOMING" (itConsumption . laType . amPjCreation .~ fireTrackingShell)
EXTRABATTERY -> mod "+BATTERY" (itConsumption . laMax +~ 1000)
where
mod str func = ItemModule [str] 1 func
f ameff = itConsumption . laType . amBulEff .~ ameff
makeDirectedTele it = it
& itTargeting .~ targetRBPress
& itUse . useMods .:~ withPosDirWallCheck directedTelPos
-- for the camera: the simplest option is to remove all zoom/offset
& itUse . useAim . aimZoom . itZoomFac .~ 1
& itUse . useAim . aimRange .~ 0
-- a better option would be to involve a "scope" centered on the firing
-- position
directedTelPos it cr w = (p,a)
where
p = fromMaybe (_crPos cr) $ it ^? itTargeting . tgPos . _Just
a = argV (mouseWorldPos w -.- p)
--amod cts str func = (cts,ItemModule [str] 1 func)