Files
loop/src/Dodge/Combine/Module.hs
T

58 lines
2.4 KiB
Haskell

module Dodge.Combine.Module where
import Dodge.Data
import Dodge.Tesla
import Dodge.WorldEvent.SpawnParticle
import Dodge.Particle.Damage
import Dodge.Item.Weapon.ExtraEffect
import Dodge.Item.Weapon.Launcher
import Dodge.Item.Weapon.TriggerType
import LensHelp
import Geometry
import Dodge.Beam
import Dodge.Base.Coordinate
import Data.Maybe
moduleModification :: ItemModuleType -> Item -> Item
moduleModification imt = case imt of
EMPTYMODULE -> id
DRUMMAG -> itConsumption . laMax .~ 45
BELTMAG -> itConsumption . laMax .~ 150
MAGNETMAG -> itUse . useDelay . rateMax .~ 4
INCENDBUL -> f $ spawnAtBulDams incBall
BOUNCEBUL -> itConsumption . laAmmoType . amBulEffect .~ BounceBullet
STATICBUL -> f $ spawnAtBulDams aStaticBall
CONCUSBUL -> f $ spawnAtBulDams concBall
TARGCR -> itTargeting .~ targetRBCreature
TARGLAS -> itTargeting .~ targetLaser
TARGPOS -> itTargeting .~ targetRBPress
MAGNETTRAJ -> (itConsumption . laAmmoType . amBulTraj .~ MagnetTrajectory 0)
. (itConsumption . laAmmoType . amBulVel .~ V2 10 0)
FLECHETRAJ -> itConsumption . laAmmoType . amBulTraj .~ FlechetteTrajectory 0
BEZIERTRAJ -> itConsumption . laAmmoType . amBulTraj .~ BezierTrajectory 0 0 0
INCENDLAS -> itParams . lasBeam .~ BeamCombine flameBeamCombine
SPLITLAS -> itParams . lasBeam .~ BeamCombine splitBeamCombine
STATICLAS -> (itParams . lasBeam .~ BeamCombine teslaBeamCombine)
. (itParams . subParams ?~ teslaParams)
WEPTELE -> makeDirectedTele
LAUNCHHOME -> itConsumption . laAmmoType . amPjCreation .~ fireTrackingShell
EXTRABATTERY -> itConsumption . laMax +~ 1000
ATTACHTORCH -> id
where
f ameff = itConsumption . laAmmoType . amBulDams .~ 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)
applyModules :: Item -> Item
applyModules it = foldr moduleModification it (_iyModules (_itType it))