Refactor, try to limit dependencies

This commit is contained in:
2022-07-28 00:59:56 +01:00
parent 8aa5c17ab9
commit 160560af5f
418 changed files with 15104 additions and 13342 deletions
+74 -207
View File
@@ -1,73 +1,32 @@
module Dodge.Item.Weapon.BatteryGuns
( lasGun
, lasCircle
, dualBeam
, lasWide
, sparkGun
, teslaGun
, teslaParams
, tractorGun
, lasRayAt
, flameBeamCombine
, teslaBeamCombine
, splitBeamCombine
, shootTeslaArc
, shootLaser
, circleLaser
, shootDualLaser
, aTractorBeam
) where
import Dodge.Data
import Dodge.Reloading.Action
import Dodge.Tesla
import Dodge.Beam
import Dodge.Item.Weapon.LaserPath
import Dodge.Item.Location
import Dodge.Creature.HandPos
import Dodge.Default.Weapon
import Dodge.Base
--import Dodge.Zone
import Geometry
import Picture
import LensHelp
module Dodge.Item.Weapon.BatteryGuns (
teslaParams,
lasRayAt,
flameBeamCombine,
teslaBeamCombine,
splitBeamCombine,
shootTeslaArc,
shootLaser,
circleLaser,
shootDualLaser,
aTractorBeam,
) where
import Dodge.Base
import Dodge.Beam
import Dodge.Creature.HandPos
import Dodge.Data.World
import Dodge.Item.Location
import Dodge.Item.Weapon.LaserPath
import Dodge.Tesla
import Geometry
import qualified IntMapHelp as IM
import qualified Data.Map.Strict as M
import LensHelp
import Picture
--import Control.Monad.State
defaultBatteryGun :: Item
defaultBatteryGun = defaultWeapon
& itType . iyModules .~ batteryModules
batteryModules :: M.Map ModuleSlot ItemModuleType
batteryModules = M.fromList
[(ModBattery, EMPTYMODULE)
,(ModTeleport, EMPTYMODULE)
]
defaultAutoBatteryGun :: Item
defaultAutoBatteryGun = defaultAutoGun
& itType . iyModules .~ batteryModules
sparkGun :: Item
sparkGun = teslaGun
& itType . iyBase .~ HELD SPARKGUN
& itParams . arcSize .~ 10
teslaGun :: Item
teslaGun = defaultBatteryGun
& itUse . heldConsumption . laMax .~ 200
& itUse . heldConsumption . laCycle .~ [loadEject 10, loadInsert 10 , loadPrime 60]
& itDimension . dimRad .~ 9
& itDimension . dimCenter .~ V3 4 0 0
& itParams .~ teslaParams
& itUse . rUse .~ HeldTeslaArc --shootTeslaArc
& itUse . useDelay .~ NoDelay
& itUse . useMods .~ TeslaMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimStance .~ TwoHandFlat
& itUse . useAim . aimHandlePos .~ 4
& itUse . useAim . aimMuzPos .~ 4
& itType . iyBase .~ HELD TESLAGUN
--lasPulse :: Item
--lasPulse = lasGun
-- & itType . iyBase .~ LASPULSE
@@ -75,7 +34,7 @@ teslaGun = defaultBatteryGun
-- [ ammoCheckI
-- , withItem $ \it -> withTempLight 1 (100 * frac it) (xyzV4 (_lasColor $ _itParams it))
-- , withItem $ \it -> withSoundForVol (frac it) tone440sawtoothquietS 2
-- , withItemUpdate itup
-- , withItemUpdate itup
-- $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) (frac it * 0.8)
-- , useAmmoAmount 1
-- ]
@@ -86,26 +45,8 @@ teslaGun = defaultBatteryGun
-- & itParams . lasColor .~ frac it * orange
-- frac it = 0.5 * (1 + sin (pi * fromIntegral (_lasCycle $ _itParams it) * 0.1))
lasCircle :: Item
lasCircle = lasGun
& itType . iyBase .~ HELD LASCIRCLE
& itParams . lasColor .~ orange
& itParams . lasDamage .~ 2
& itUse . heldConsumption . laMax .~ 10000
& itUse . rUse .~ HeldLaser --shootLaser
& itUse . useDelay .~ NoDelay
& itUse . rUse .~ HeldCircleLaser --circleLaser
& itUse . useMods .~ CircleLaserMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandTwist
lasWide :: Int -> Item
lasWide n = lasGun
& itType . iyBase .~ HELD (LASWIDE n)
& itParams . lasColor .~ yellow
& itParams . lasDamage .~ 2
& itUse . useMods .~ LasWideMod n
--lasWidePulse :: Item
--lasWidePulse = lasGun
-- & itType . iyBase .~ LASGUNWIDEPULSE
@@ -115,7 +56,7 @@ lasWide n = lasGun
-- [ ammoCheckI
-- , withItem $ \it -> withTempLight 1 (100 * frac it) (xyzV4 (_lasColor $ _itParams it))
-- , withItem $ \it -> withSoundForVol (frac it) tone440sawtoothquietS 2
-- , withItemUpdate itup
-- , withItemUpdate itup
-- $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) (frac it * 0.8)
-- , useAmmoAmount 1
-- , withItemUpdate itup $ \it -> duplicateOffsets (xs it)
@@ -171,27 +112,7 @@ lasWide n = lasGun
-- n' = 9 * n
-- xs = [ 0.25 * (fromIntegral x - fromIntegral (n'-1) /2) | x <- [0..n'-1] ]
dualBeam :: Item
dualBeam = lasGun
& itType . iyBase .~ HELD DUALBEAM
& itUse . useAim . aimMuzPos .~ 0
& itParams .~ DualBeam
{ _phaseV = 1
, _lasColor = red
, _lasColor2 = green
, _lasCycle = 0
, _lasDamage = 11
, _lasBeam = BeamCombine LasBeamCombine
, _subParams = Nothing
, _dbGap = 20
}
& itUse . rUse .~ HeldDualLaser --shootDualLaser
& itUse . useDelay .~ NoDelay
& itUse . useMods .~ DualBeamMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandFlat
& itType . iyModules . at ModDualBeam ?~ EMPTYMODULE
--lasSwing :: Item
--lasSwing = lasGun
-- & itType . iyBase .~ LASGUNSWING
@@ -210,79 +131,20 @@ dualBeam = lasGun
-- where
-- y = 15 * sin (pi * fromIntegral x' * 0.01)
-- x' = _lasCycle $ _itParams it
lasGun :: Item
lasGun = defaultAutoBatteryGun
& itUse . heldConsumption .~ ( defaultLoadable
& laMax .~ 200
& laCycle .~ [loadEject 10, loadInsert 10 , loadPrime 60]
)
& itParams .~ Refracting
{ _phaseV = 1
, _lasColor = yellow
, _lasColor2 = yellow
, _lasCycle = 0
, _lasDamage = 11
}
& itTweaks .~ Tweakable
{ _tweakParams = IM.fromList [(0,lasGunTweak)]
}
& itDimension . dimRad .~ 10
& itDimension . dimCenter .~ V3 15 0 0
& itUse . rUse .~ HeldLaser --shootLaser
& itUse . useDelay .~ NoDelay
& itUse . useMods .~ LasMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 30
& itType . iyBase .~ HELD LASGUN
lasGunTweak :: TweakParam
lasGunTweak = TweakParam
{ _tweakType = TweakPhaseV
, _tweakVal = 1
, _tweakMax = 3
}
tractorGun :: Item
tractorGun = lasGun
& itUse . heldConsumption .~
( defaultLoadable
& laMax .~ 10000
& laCycle .~ [loadEject 10, loadInsert 10 , loadPrime 60] )
& itParams .~ Attracting {_attractionPower = 1}
& itTweaks .~ Tweakable
{ _tweakParams = IM.fromList [(0,tractorGunTweak)]
}
& itUse . rUse .~ HeldTractor --aTractorBeam
& itUse . useDelay .~ NoDelay
& itUse . useMods .~ AmmoCheckMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 30
& itType . iyBase .~ HELD TRACTORGUN
tractorGunTweak :: TweakParam
tractorGunTweak = TweakParam
{ _tweakType = TweakTractionPower
, _tweakVal = 1
, _tweakMax = 4
}
-- | assumes that the item is held
shootTeslaArc :: Item -> Creature -> World -> World
shootTeslaArc it cr w = w'
& cWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itParams .~ ip
where
(w',ip) = shootTeslaArc' (_itParams it) pos dir w
shootTeslaArc it cr w =
w'
& cWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itParams .~ ip
where
(w', ip) = shootTeslaArc' (_itParams it) pos dir w
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
dir = _crDir cr
shootLaser :: Item -> Creature -> World -> World
shootLaser it cr = cWorld . lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
where
where
pos = _crPos cr
dir = _crDir cr
phasev = _phaseV . _itParams $ _crInv cr IM.! crSel cr
@@ -291,10 +153,11 @@ shootLaser it cr = cWorld . lasers .:~ lasRayAt (_lasColor $ _itParams it) dam p
-- this has the feel of a left click item
circleLaser :: Item -> Creature -> World -> World
circleLaser it cr w
| hasLOSIndirect cpos pos w = w
& cWorld . lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
| hasLOSIndirect cpos pos w =
w
& cWorld . lasers .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
| otherwise = w
where
where
cpos = _crPos cr
mwp = mouseWorldPos w
pos = _crPos cr +.+ rotateV dir (V2 0 (max 70 $ dist cpos mwp))
@@ -303,19 +166,21 @@ circleLaser it cr w
dam = _lasDamage $ _itParams it
shootDualLaser :: Item -> Creature -> World -> World
shootDualLaser it cr w = w'
& cWorld . newBeams . positronBeams .:~ dualRayAt (_lasBeam $ _itParams it) itid w (_lasColor $ _itParams it) dam phasev posl dirl
& cWorld . newBeams . electronBeams .:~ basicBeamAt itid w (_lasColor2 $ _itParams it) dam phasev posr dirr
where
(w',itid) = getHeldItemLoc cr w
shootDualLaser it cr w =
w'
& cWorld . newBeams . positronBeams .:~ dualRayAt (_lasBeam $ _itParams it) itid w (_lasColor $ _itParams it) dam phasev posl dirl
& cWorld . newBeams . electronBeams .:~ basicBeamAt itid w (_lasColor2 $ _itParams it) dam phasev posr dirr
where
(w', itid) = getHeldItemLoc cr w
dir = _crDir cr
pos = _crPos cr +.+ aimlength *.* unitVectorAtAngle dir
aimlength = aimingMuzzlePos cr it
gap = _dbGap . _itParams $ it
posl = pos +.+ (-gap) *.* vNormal (unitVectorAtAngle dir)
posl = pos +.+ (- gap) *.* vNormal (unitVectorAtAngle dir)
posr = pos +.+ gap *.* vNormal (unitVectorAtAngle dir)
mwp = mouseWorldPos w
mwp' | dist mwp (_crPos cr) < aimlength + 5 = _crPos cr +.+ (aimlength + 5) *.* unitVectorAtAngle dir
mwp'
| dist mwp (_crPos cr) < aimlength + 5 = _crPos cr +.+ (aimlength + 5) *.* unitVectorAtAngle dir
| otherwise = mwp
dirl = argV $ mwp' -.- posl
dirr = argV $ mwp' -.- posr
@@ -323,29 +188,31 @@ shootDualLaser it cr w = w'
dam = _lasDamage $ _itParams it
basicBeamAt :: Int -> World -> Color -> Int -> Float -> Point2 -> Float -> Beam
basicBeamAt itid w col dam phasev pos dir = Beam
{ _bmDraw = BasicBeamDraw --drawBeam
, _bmPos = pos
, _bmDir = dir
, _bmDamage = dam
, _bmRange = 800
, _bmPhaseV = phasev
, _bmColor = col
, _bmPoints = pos:ps
, _bmFirstPoints = []
, _bmOrigin = Just itid
, _bmType = BeamCombine NoBeamCombine
}
basicBeamAt itid w col dam phasev pos dir =
Beam
{ _bmDraw = BasicBeamDraw --drawBeam
, _bmPos = pos
, _bmDir = dir
, _bmDamage = dam
, _bmRange = 800
, _bmPhaseV = phasev
, _bmColor = col
, _bmPoints = pos : ps
, _bmFirstPoints = []
, _bmOrigin = Just itid
, _bmType = BeamCombine NoBeamCombine
}
where
(_,ps) = reflectLaserAlong phasev pos (pos +.+ 800 *.* unitVectorAtAngle dir) w
(_, ps) = reflectLaserAlong phasev pos (pos +.+ 800 *.* unitVectorAtAngle dir) w
dualRayAt :: BeamType -> Int -> World -> Color -> Int -> Float -> Point2 -> Float -> Beam
dualRayAt bt itid w col dam phasev pos dir = basicBeamAt itid w col dam phasev pos dir
& bmType .~ bt
dualRayAt bt itid w col dam phasev pos dir =
basicBeamAt itid w col dam phasev pos dir
& bmType .~ bt
aTractorBeam :: Item -> Creature -> World -> World
aTractorBeam _ cr w = w & cWorld . tractorBeams .:~ tractorBeamAt spos outpos dir power
where
where
cpos = _crPos cr
spos = cpos +.+ (_crRad cr + 10) *.* unitVectorAtAngle dir
xpos = cpos +.+ 400 *.* unitVectorAtAngle dir
@@ -354,12 +221,12 @@ aTractorBeam _ cr w = w & cWorld . tractorBeams .:~ tractorBeamAt spos outpos di
power = _attractionPower . _itParams $ _crInv cr IM.! crSel cr
tractorBeamAt :: Point2 -> Point2 -> Float -> Point2 -> TractorBeam
tractorBeamAt pos outpos dir power = TractorBeam
{ _tbPos = pos
, _tbStartPos = outpos
, _tbVel = d
, _tbTime = 10
}
where
d = unitVectorAtAngle dir * power
tractorBeamAt pos outpos dir power =
TractorBeam
{ _tbPos = pos
, _tbStartPos = outpos
, _tbVel = d
, _tbTime = 10
}
where
d = unitVectorAtAngle dir * power
+41 -32
View File
@@ -1,46 +1,55 @@
module Dodge.Item.Weapon.Bullet
( basicBullet
, hvBullet
) where
import Dodge.Data
module Dodge.Item.Weapon.Bullet (
basicBullet,
hvBullet,
) where
import Dodge.Data.Item.Use.Consumption.Ammo
import Control.Lens
import Geometry.Data
basicBullet :: AmmoType
basicBullet = BulletAmmo
{ _amString = "BASIC"
, _amBullet = defaultBullet
}
basicBullet =
BulletAmmo
{ _amString = "BASIC"
, _amBullet = defaultBullet
}
defaultBullet :: Bullet
defaultBullet = Bullet
{ _buDelayFraction = 1
, _buEffect = DestroyBullet
, _buSpawn = BulSpark
, _buUpdateMod = NoBulletUpdateMod
, _buTrajectory = BasicBulletTrajectory
, _buVel = V2 50 0
, _buDrag = 1
, _buPos = 0
, _buOldPos = 0
, _buWidth = 2
, _buTimer = 100
, _buDamages = basicBulDams
}
defaultBullet =
Bullet
{ _buDelayFraction = 1
, _buEffect = DestroyBullet
, _buSpawn = BulSpark
, _buUpdateMod = NoBulletUpdateMod
, _buTrajectory = BasicBulletTrajectory
, _buVel = V2 50 0
, _buDrag = 1
, _buPos = 0
, _buOldPos = 0
, _buWidth = 2
, _buTimer = 100
, _buDamages = basicBulDams
}
basicBulDams :: [Damage]
basicBulDams =
[ Damage PIERCING 100 0 0 0 NoDamageEffect
, Damage PUSHDAM 1 0 0 0 . PushBackDamage $ 2
, Damage PUSHDAM 1 0 0 0 . PushBackDamage $ 2
]
hvBullet :: AmmoType
hvBullet = BulletAmmo
{ _amString = "HVBULLET"
, _amBullet = defaultBullet
& buWidth .~ 6
& buVel .~ V2 80 0
& buDamages .~ heavyBulDams
}
hvBullet =
BulletAmmo
{ _amString = "HVBULLET"
, _amBullet =
defaultBullet
& buWidth .~ 6
& buVel .~ V2 80 0
& buDamages .~ heavyBulDams
}
heavyBulDams :: [Damage]
heavyBulDams =
[ Damage PIERCING 300 0 0 0 NoDamageEffect
, Damage PUSHDAM 1 0 0 0 $ PushBackDamage 2
, Damage PUSHDAM 1 0 0 0 $ PushBackDamage 2
]
-157
View File
@@ -1,157 +0,0 @@
module Dodge.Item.Weapon.BulletGun.Cane (
volleyGun,
repeater,
rifle,
autoRifle,
burstRifle,
miniGunX,
) where
import Dodge.Data
import Dodge.Default
import Dodge.Reloading.Action
import Geometry
import LensHelp
defaultBangCane :: Item
defaultBangCane =
defaultBulletWeapon
& itParams
.~ BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _gunBarrels =
SingleBarrel
{ _brlInaccuracy = 0.01
}
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
}
& itDimension . dimRad .~ 8
& itDimension . dimCenter .~ V3 5 0 0
& itUse . useDelay . rateMax .~ 6
& itUse . useMods .~ BangCaneMod
& itUse . useAim . aimStance .~ OneHand
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 15
& itType . iyBase .~ error "undefined bangCane baseitemtype"
& itUse . heldConsumption . laMax .~ 1
& itUse . heldConsumption . laCycle .~ [loadPartialInsert 10 1]
volleyGun :: Int -> Item
volleyGun i =
defaultBangCane
& itUse . useDelay . rateMax .~ 6
& itUse . useMods .~ VolleyGunMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandFlat
& itUse . useAim . aimZoom .~ defaultItZoom{_itZoomFac = 1.5}
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 15
& itUse . heldConsumption . laMax .~ i
& itParams
.~ BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _gunBarrels =
SingleBarrel
{ _brlInaccuracy = 0.01
}
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
}
& itParams . gunBarrels
.~ MultiBarrel
{ _brlSpread = AlignedBarrels
, _brlNum = i
, _brlInaccuracy = 0.1
}
& itParams . torqueAfter .~ 0.48 + 0.2 * fromIntegral i
& itType . iyBase .~ HELD (VOLLEYGUN i)
rifle :: Item
rifle =
defaultBangCane
& itUse . useAim . aimStance .~ TwoHandTwist
& itType . iyBase .~ HELD RIFLE
& itUse . heldConsumption . laMax .~ 1
& itUse . heldConsumption . laCycle .~ [loadEject 5, loadInsert 5, loadPrime 5]
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimZoom .~ defaultItZoom{_itZoomFac = 2}
& itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE
repeater :: Item
repeater =
rifle
& itType . iyModules . at ModRifleMag ?~ EMPTYMODULE
& itType . iyBase .~ HELD REPEATER
& itUse . heldConsumption . laCycle .~ [loadEject 20, loadInsert 20, loadPrime 20]
& itUse . heldConsumption . laMax .~ 15
autoRifle :: Item
autoRifle =
repeater
& itType . iyBase .~ HELD AUTORIFLE
& itUse . useMods .~ AutoRifleMod
& itType . iyModules . at ModAutoMag ?~ EMPTYMODULE
-- & itUse . useDelay . rateMax .~ 6
burstRifle :: Item
burstRifle =
repeater
& itType . iyBase .~ HELD BURSTRIFLE
& itParams . gunBarrels . brlInaccuracy .~ 0.05
& itUse . useDelay . rateMax .~ 18
& itUse . useMods .~ BurstRifleMod
miniGunUse :: Int -> ItemUse
miniGunUse i =
defaultrUse
& rUse .~ HeldUseAmmoParams
& useDelay .~ NoDelay
& useMods .~ MiniGunMod i
miniGunX :: Int -> Item
miniGunX i =
defaultAutoGun
{ _itUse =
miniGunUse i
& useDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 100}
& useAim . aimWeight .~ 6
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom{_itZoomFac = 1.5}
& heldConsumption
.~ defaultBulletLoadable
{ _laMax = 1500
, _laLoaded = 1500
}
& heldConsumption . laCycle .~ [loadEject 40, loadInsert 40, loadPrime 40]
, _itParams =
BulletShooter
{ _muzVel = 1
, _rifling = 0.9
, _bore = 2
, _gunBarrels =
MultiBarrel
{ _brlSpread = RotatingBarrels 0.01
, _brlNum = i
, _brlInaccuracy = 0
}
, _recoil = 10
, _torqueAfter = 0
, _randomOffset = 10
}
, _itInvSize = 4
}
& itDimension . dimRad .~ 20
& itDimension . dimCenter .~ V3 5 0 0
& itDimension . dimAttachPos .~ V3 5 (-5) 0
& itType . iyBase .~ HELD (MINIGUNX i)
& itUse . useAim . aimMuzPos .~ 40
-83
View File
@@ -1,83 +0,0 @@
module Dodge.Item.Weapon.BulletGun.Rod
( bangRod
, elephantGun
, amr
, autoAmr
, sniperRifle
, machineGun
) where
import Dodge.Data
import Dodge.Reloading.Action
import Dodge.Default.Weapon
import Dodge.Item.Weapon.Bullet
import Dodge.Default
import Dodge.Item.Weapon.ExtraEffect
import Geometry
import LensHelp
bangRod :: Item
bangRod = defaultBulletWeapon
& itParams .~ BulletShooter
{ _muzVel = 0.8
, _rifling = 1
, _bore = 2
, _gunBarrels = SingleBarrel 0.1
, _recoil = 50
, _torqueAfter = 0.3
, _randomOffset = 0
}
& itUse . useDelay . rateMax .~ 12
& itUse . useMods .~ BangRodMod
& itDimension . dimRad .~ 12
& itDimension . dimCenter .~ V3 5 0 0
& itUse . heldConsumption . laMax .~ 1
& itUse . heldConsumption . laCycle .~ [loadEject 5, loadInsert 10 , loadPrime 5]
& itType . iyBase .~ HELD BANGROD
& itUse . useAim . aimWeight .~ 8
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ OneHand
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 30
& itUse . heldConsumption . laAmmoType .~ hvBullet
elephantGun :: Item
elephantGun = bangRod
& itType . iyBase .~ HELD ELEPHANTGUN
& itUse . useAim . aimStance .~ TwoHandTwist
& itParams . gunBarrels .~ SingleBarrel 0.05
& itUse . useMods .~ ElephantGunMod
& itParams . recoil .~ 50
& itParams . torqueAfter .~ 0.1
amr :: Item
amr = elephantGun
& itType . iyBase .~ HELD AMR
& itUse . heldConsumption . laMax .~ 15
autoAmr :: Item
autoAmr = amr
& itType . iyBase .~ HELD AUTOAMR
& itUse . useMods .~ AutoAmrMod
sniperRifle :: Item
sniperRifle = elephantGun
& itType . iyBase .~ HELD SNIPERRIFLE
& itParams . gunBarrels .~ SingleBarrel 0
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5}
& itUse . heldScroll .~ HeldScrollZoom -- zoomLongGun
& itScope .~ ZoomScope (V2 0 0) 0 1 0.5 False
& itTargeting .~ targetLaser
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1}
machineGun :: Item
machineGun = bangRod
& itType . iyBase .~ HELD MACHINEGUN
& itUse . useDelay . rateMax .~ 25
& itUse . useMods .~ MachineGunMod
& itUse . useAim . aimWeight .~ 8
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itUse . useDelay .~ VariableRate {_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0}
& itUse . heldConsumption . laMax .~ 100
& itUse . heldConsumption . laCycle .~ [loadEject 10, loadInsert 40 , loadPrime 10]
& itInvSize .~ 3
& itParams. torqueAfter .~ 0.2 -- not sure if this is necessary?
-93
View File
@@ -1,93 +0,0 @@
module Dodge.Item.Weapon.BulletGun.Stick
( bangStick
, pistol
, autoPistol
, machinePistol
, smg
, revolver
, revolverX
) where
import Dodge.Reloading.Action
import Dodge.Data
import Dodge.Default.Weapon
import Geometry
import LensHelp
bangStick :: Int -> Item
bangStick i = defaultBulletWeapon
& itParams .~ BulletShooter
{ _muzVel = 0.8
, _rifling = 0.8
, _bore = 2
, _gunBarrels = MultiBarrel
{_brlNum = i
,_brlSpread = SpreadBarrels baseStickSpread
,_brlInaccuracy = 0.01
}
, _recoil = 25
, _torqueAfter = 0.18 + 0.02 * fromIntegral i
, _randomOffset = 0
}
& itInvSize .~ fromIntegral i / 3
& itDimension . dimRad .~ 5
& itDimension . dimCenter .~ V3 5 0 0
& itUse . useDelay . rateMax .~ 8
& itUse . useMods .~ BangStickMod
& itType . iyBase .~ HELD (BANGSTICK i)
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 10
& itUse . heldConsumption . laMax .~ i
& itUse . heldConsumption . laCycle .~ [loadPartialInsert 10 1]
baseStickSpread :: Float
baseStickSpread = 0.2
revolver :: Item
revolver = pistol
& itUse . heldConsumption .~
(defaultBulletLoadable
& laMax .~ 6
& laCycle .~ [loadPartialInsert 10 1] )
& itType . iyBase .~ HELD REVOLVER
pistol :: Item
pistol = bangStick 1
& itUse . heldConsumption .~ ( defaultBulletLoadable
& laMax .~ 15
& laCycle .~ [loadEject 5, loadInsert 5 , loadPrime 5] )
& itUse . useDelay . rateMax .~ 6
& itUse . useMods .~ PistolMod
& itParams %~
( ( muzVel .~ 0.8 )
. ( rifling .~ 0.8 )
. ( bore .~ 2 )
. ( gunBarrels .~ SingleBarrel 0.05 )
. ( recoil .~ 10 )
. ( torqueAfter .~ 0.2 )
)
& itType . iyBase .~ HELD PISTOL
autoPistol :: Item
autoPistol = pistol
& itUse . useMods .~ AutoPistolMod
& itType . iyBase .~ HELD AUTOPISTOL
& itType . iyModules . at ModAutoMag ?~ EMPTYMODULE
machinePistol :: Item
machinePistol = autoPistol
& itUse . useDelay . rateMax .~ 2
& itUse . useMods .~ MachinePistolMod -- (ammoCheckI : machinePistolAfterHamMods)
& itType . iyBase .~ HELD MACHINEPISTOL
& itType . iyModules . at ModAutoMag .~ Nothing
& itParams . recoil .~ 20
smg :: Item
smg = autoPistol -- & some parameter affecting stability
& itUse . useMods .~ SmgMod --(ammoCheckI : smgAfterHamMods)
& itType . iyBase .~ HELD SMG
& itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimHandlePos .~ 2
& itParams . torqueAfter .~ 0.05
revolverX :: Int -> Item
revolverX i = revolver
& itUse . useDelay . rateMax .~ 8
& itUse . useMods .~ RevolverXMod
& itUse . heldConsumption . laMax .~ i * 6
& itType . iyBase .~ HELD (REVOLVERX i)
-110
View File
@@ -1,110 +0,0 @@
module Dodge.Item.Weapon.BulletGuns
( bangCone
, blunderbuss
, grapeCannon
, grenadeLauncher
, autogunSpread
--, autoGunPic
, module Dodge.Item.Weapon.BulletGun.Stick
, module Dodge.Item.Weapon.BulletGun.Cane
, module Dodge.Item.Weapon.BulletGun.Rod
) where
import Dodge.Item.Weapon.BulletGun.Stick
import Dodge.Reloading.Action
import Dodge.Item.Weapon.BulletGun.Cane
import Dodge.Item.Weapon.BulletGun.Rod
import Dodge.Data
import Dodge.Default.Weapon
import Geometry
import LensHelp
--autoGun :: Item
--autoGun = defaultAutoGun
-- { _itConsumption = defaultBulletLoadable
-- { _laMax = 30
-- , _laLoaded = 30
-- }
-- & laCycle .~ [loadEject 30, loadInsert 30 , loadPrime 10]
---- , _itFloorPict = autoGunPic
---- , _itZoom = defaultItZoom
-- , _itAttachment = AttachCharMode $ Seq.fromList "MS"
-- , _itParams = BulletShooter
-- { _muzVel = 1
-- , _rifling = 0.9
-- , _bore = 2
-- , _gunBarrels = SingleBarrel 0.1
-- , _recoil = 0
-- , _torqueAfter = 0
-- , _randomOffset = 0
-- }
-- }
-- & itUse . useDelay . rateMax .~ 4
-- & itUse . useMods .~
-- [ ammoCheckI
-- , charFiringStratI
-- [('S', hammerCheckI)
-- ]
-- , useTimeCheck
-- , charFiringStratI
-- [('M', torqueBefore 0.08)
-- ,('S', torqueBefore 0.05)
-- ]
-- , withSoundForI autoBS 5
-- --, withSoundForI seagullChatterS 5
-- , useAmmoAmount 1
-- , applyInaccuracy
-- , withMuzFlareI
-- , withSmoke 1 black 20 200 5
-- ]
-- & itUse . useAim . aimWeight .~ 6
-- & itUse . useAim . aimRange .~ 1
-- & itUse . useAim . aimStance .~ TwoHandTwist
-- & itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
-- & itUse . heldScroll .~ HeldScrollCharMode
-- & itType . iyBase .~ HELD AUTOGUN
bangCone :: Item
bangCone = defaultBulletWeapon
{ _itParams = BulletShooter
{ _muzVel = 0.7
, _rifling = 0.8
, _bore = 5
, _gunBarrels = SingleBarrel 0.5
, _recoil = 150
, _torqueAfter = 0.1
, _randomOffset = 12
}
}
& itDimension . dimRad .~ 8
& itDimension . dimCenter .~ V3 5 0 0
& itUse . useDelay . rateMax .~ 20
& itUse . useMods .~ BangConeMod
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 15
& itType . iyBase .~ HELD BANGCONE
& itUse . heldConsumption . laMax .~ 5
& itUse . heldConsumption . laCycle .~ [loadEject 5, loadInsert 20 , loadPrime 5]
blunderbuss :: Item
blunderbuss = bangCone
& itUse . heldConsumption . laMax .~ 25
& itUse . heldConsumption . laCycle .~ [loadEject 5, loadInsert 30 , loadPrime 5]
& itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 30
& itType . iyBase .~ HELD BLUNDERBUSS
grapeCannon :: Int -> Item
grapeCannon i = blunderbuss
& itType . iyBase .~ HELD (GRAPECANNON i)
& itUse . heldConsumption . laMax .~ 25 + 25 * i
& itUse . heldConsumption . laCycle .~ [loadEject 5, loadInsert (30 + i * 10) , loadPrime 5]
& itParams . recoil .~ (150 + fromIntegral i * 50)
& itParams . torqueAfter .~ (0.1 + 0.2 * fromIntegral i)
& itParams . randomOffset .~ (12 + 4 * fromIntegral i)
grenadeLauncher :: Int -> Item
grenadeLauncher _ = bangCone
autogunSpread :: Float
autogunSpread = 0.07
+28 -25
View File
@@ -1,41 +1,44 @@
module Dodge.Item.Weapon.Drone where
import Dodge.Data
import Dodge.Default.Weapon
import Dodge.Default.Item
import Control.Lens
import Dodge.Data.World
import Geometry
import Picture
import ShapePicture
import Shape
import Control.Lens
import ShapePicture
droneLauncher :: Item
droneLauncher = defaultWeapon
& itUse . useDelay . rateMax .~ 20
-- & itUse . rUse .~ aDroneWithItemParams
& itUse . useMods .~ AmmoUseCheckMod
& itUse . useAim . aimWeight .~ 8
& itUse . useAim . aimRange .~ 0.5
& itUse . useAim . aimStance .~ TwoHandTwist
& itUse . heldConsumption . laAmmoType .~ DroneAmmo { _amString = "LASDRONE" }
& itUse . heldConsumption . laMax .~ 2
& itType . iyBase .~ HELD DRONELAUNCHER
droneLauncher =
defaultHeldItem
& itUse . heldDelay . rateMax .~ 20
& itUse . heldMods .~ AmmoUseCheckMod
& itUse . heldAim . aimWeight .~ 8
& itUse . heldAim . aimRange .~ 0.5
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldConsumption . laAmmoType .~ DroneAmmo{_amString = "LASDRONE"}
& itUse . heldConsumption . laMax .~ 2
& itType . iyBase .~ HELD DRONELAUNCHER
lasDronesPic :: Item -> SPic
lasDronesPic _ =
( colorSH chartreuse $ prismPoly
(map (+.+.+ V3 10 0 4.5) $ polyCircx 4 5)
(map (+.+.+ V3 (-10) 0 4.5) $ polyCircx 4 5)
lasDronesPic _ =
( colorSH chartreuse $
prismPoly
(map (+.+.+ V3 10 0 4.5) $ polyCircx 4 5)
(map (+.+.+ V3 (-10) 0 4.5) $ polyCircx 4 5)
, mempty
)
aDroneWithItemParams
:: Item -- ^ Firing item
-> Creature
-> World
-> World
aDroneWithItemParams ::
-- | Firing item
Item ->
Creature ->
World ->
World
aDroneWithItemParams = undefined
--aDroneWithItemParams it cr w = over props (IM.insert i theShell) w
-- where
-- where
-- am = _itConsumption it
-- i = IM.newKey $ _props w
-- pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
+109 -102
View File
@@ -1,95 +1,87 @@
--{-# LANGUAGE BangPatterns #-}
{- |
Extra weapon effects, supplementing explicit use effects.
-}
module Dodge.Item.Weapon.ExtraEffect
(-- itemLaserScopeEffect
autoSonarEffect
, autoEffect
, autoRadarEffect
, targetRBPress
, targetRBCreature
, targetCursor
, targetLaser
, targetLaserUpdate
, targetUpdateWith
, targetRBPressUpdate
, targetRBCreatureUp
, targetCursorUpdate
-- , rbSetTarget
) where
import Dodge.Zoning.Creature
import FoldableHelp
import Dodge.Data
import Dodge.Base
import Dodge.RadarSweep
import Dodge.SoundLogic
import Dodge.Item.Weapon.LaserPath
-}
module Dodge.Item.Weapon.ExtraEffect (
-- itemLaserScopeEffect
autoSonarEffect,
autoEffect,
autoRadarEffect,
targetLaserUpdate,
targetUpdateWith,
targetRBPressUpdate,
targetRBCreatureUp,
targetCursorUpdate,
-- , rbSetTarget
) where
--import Dodge.Item.Attachment.Data
import Dodge.Creature.Test
import Picture
import Geometry.Vector
import LensHelp
import Sound.Data
import qualified Data.Map.Strict as M
import Data.Maybe
import Dodge.Base
import Dodge.Creature.Test
import Dodge.Data.World
import Dodge.Item.Weapon.LaserPath
import Dodge.RadarSweep
import Dodge.SoundLogic
import Dodge.Zoning.Creature
import FoldableHelp
import Geometry.Vector
import LensHelp
import Picture
import qualified SDL
import Sound.Data
autoEffect :: (Item -> Creature -> World -> World) -> Int -> SoundID -> Item -> Creature -> World -> World
autoEffect eff t sid itm cr w
| _eparamInt (_eqParams (_eqEq $ _itUse itm)) < 1 = eff itm cr w
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itLocation itm)
. itUse . eqEq . eqParams . eparamInt .~ t
& soundStart OnceSound (_crPos cr) sid Nothing
| otherwise = w
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itLocation itm)
. itUse . eqEq . eqParams . eparamInt -~ 1
| _eparamInt (_eeParams (_equipEffect $ _itUse itm)) < 1 =
eff itm cr w
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itLocation itm)
. itUse
. equipEffect
. eeParams
. eparamInt
.~ t
& soundStart OnceSound (_crPos cr) sid Nothing
| otherwise =
w
& cWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID $ _itLocation itm)
. itUse
. equipEffect
. eeParams
. eparamInt
-~ 1
{- | Automatically send out radar pulses that detect walls. -}
-- | Automatically send out radar pulses that detect walls.
autoRadarEffect :: Item -> Creature -> World -> World
autoRadarEffect = autoEffect (const (aRadarPulse ObWall)) 100 click1S
{- | Automatically send out sonar pulses that detect creatures. -}
-- | Automatically send out sonar pulses that detect creatures.
autoSonarEffect :: Item -> Creature -> World -> World
autoSonarEffect = autoEffect (const (aRadarPulse ObCreature)) 50 click1S
defaultTargeting :: Targeting
defaultTargeting = Targeting
{ _tgPos = Nothing
, _tgUpdate = NoTargetUpdate
, _tgDraw = NoTargetDraw
, _tgID = Nothing
, _tgActive = False
}
targetLaser :: Targeting
targetLaser = defaultTargeting
& tgUpdate .~ TargetLaserUpdate
targetRBPress :: Targeting
targetRBPress = defaultTargeting
& tgUpdate .~ TargetRBPressUpdate
& tgDraw .~ SimpleDrawTarget
targetRBCreature :: Targeting
targetRBCreature = defaultTargeting
& tgUpdate .~ TargetRBCreatureUpdate
& tgDraw .~ TargetRBCreatureDraw
targetCursor :: Targeting
targetCursor = defaultTargeting
& tgUpdate .~ TargetCursorUpdate
& tgDraw .~ SimpleDrawTarget
targetRBCreatureUp :: Item -> Creature -> World -> Targeting -> (World, Targeting)
targetRBCreatureUp it cr w t
| not $ _itIsHeld it = (w, t
& tgID .~ Nothing
& tgPos .~ Nothing
& tgActive .~ False
| not $ _itIsHeld it =
( w
, t
& tgID .~ Nothing
& tgPos .~ Nothing
& tgActive .~ False
)
| SDL.ButtonRight `M.member` _mouseButtons w && isJust (t ^? tgID . _Just)
&& canSeeTarget = (w, t & updatePos & tgActive .~ True)
| otherwise = (w, t & tgID .~ fmap _crID newtarg & updatePos & tgActive .~ False )
&& canSeeTarget =
(w, t & updatePos & tgActive .~ True)
| otherwise = (w, t & tgID .~ fmap _crID newtarg & updatePos & tgActive .~ False)
where
newtarg = safeMinimumOn (dist mwp . _crPos)
. filter (canseepos . _crPos)
$ crsNearCirc mwp 40 w
newtarg =
safeMinimumOn (dist mwp . _crPos)
. filter (canseepos . _crPos)
$ crsNearCirc mwp 40 w
canseepos p = hasLOS (_crPos cr) p w
mwp = mouseWorldPos w
updatePos t' = t' & tgPos .~ posFromMaybeID (_tgID t')
@@ -100,52 +92,67 @@ targetRBCreatureUp it cr w t
cpos <- w ^? cWorld . creatures . ix cid . crPos
Just $ hasLOS cpos (_crPos cr) w
targetUpdateWith :: (World -> Targeting -> Targeting)
-> Item -> Creature -> World -> Targeting -> (World,Targeting)
targetUpdateWith f it _ w t
targetUpdateWith ::
(World -> Targeting -> Targeting) ->
Item ->
Creature ->
World ->
Targeting ->
(World, Targeting)
targetUpdateWith f it _ w t
| _itIsHeld it = (w, f w t)
| otherwise = (w,t)
| otherwise = (w, t)
targetCursorUpdate :: World -> Targeting -> Targeting
targetCursorUpdate w t
| SDL.ButtonRight `M.member` _mouseButtons w = t
& tgPos . _Just .~ mouseWorldPos w
& tgActive .~ True
| otherwise = t & tgPos %~ const Nothing
& tgActive .~ False
| SDL.ButtonRight `M.member` _mouseButtons w =
t
& tgPos . _Just .~ mouseWorldPos w
& tgActive .~ True
| otherwise =
t & tgPos %~ const Nothing
& tgActive .~ False
targetRBPressUpdate :: World -> Targeting -> Targeting
targetRBPressUpdate w t
| SDL.ButtonRight `M.member` _mouseButtons w = t
& tgPos %~ maybe (Just $ mouseWorldPos w) Just
& tgActive .~ True
| otherwise = t & tgPos %~ const Nothing
& tgActive .~ False
| SDL.ButtonRight `M.member` _mouseButtons w =
t
& tgPos %~ maybe (Just $ mouseWorldPos w) Just
& tgActive .~ True
| otherwise =
t & tgPos %~ const Nothing
& tgActive .~ False
targetLaserUpdate :: Item -> Creature -> World -> Targeting -> (World,Targeting)
targetLaserUpdate :: Item -> Creature -> World -> Targeting -> (World, Targeting)
targetLaserUpdate _ cr w t
| crIsAiming cr = (addLaserPic w,t
& tgPos .~ fmap fst mp
& tgActive .~ True
| crIsAiming cr =
( addLaserPic w
, t
& tgPos .~ fmap fst mp
& tgActive .~ True
)
| otherwise = (w,t & tgPos %~ const Nothing
& tgActive .~ False
| otherwise =
( w
, t & tgPos %~ const Nothing
& tgActive .~ False
)
where
(mp, _) = reflectLaserAlong 0.2 sp ep w
sp = _crPos cr +.+ 15 *.* unitVectorAtAngle (_crDir cr)
ep = sp +.+ 5000 *.* normalizeV (mouseWorldPos w -.- sp)
addLaserPic = cWorld . lasers .:~ LaserStart
{ _lpPhaseV = 1
, _lpDir = _crDir cr
, _lpPos = sp
, _lpColor = col
, _lpType = TargetLaser
}
addLaserPic =
cWorld . lasers
.:~ LaserStart
{ _lpPhaseV = 1
, _lpDir = _crDir cr
, _lpPos = sp
, _lpColor = col
, _lpType = TargetLaser
}
--wpammo = _itConsumption it
-- reloadFrac
-- | _laLoaded wpammo == 0 = 1
-- | otherwise = case _laTransfer wpammo of
-- Transfer _ rs -> fromIntegral rs / fromIntegral (_laReloadTime wpammo)
-- NoTransfer -> 1
-- 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
+1 -1
View File
@@ -2,7 +2,7 @@ module Dodge.Item.Weapon.FractionLoaded
( fractionLoadedAmmo
, fractionLoadedAmmo2
) where
import Dodge.Data
import Dodge.Data.Item
---- this shouldn't really be used
loadedAmmo :: Item -> Int
+40 -34
View File
@@ -1,56 +1,62 @@
module Dodge.Item.Weapon.LaserPath
( reflectLaserAlong
) where
import Dodge.Data
module Dodge.Item.Weapon.LaserPath (
reflectLaserAlong,
) where
import Data.Bifunctor
import Data.Tuple
import Dodge.Base.Wall
--import Dodge.Creature.HandPos
import Dodge.Data.World
import Dodge.WorldEvent
import Geometry
--import Data.Maybe
--import Data.List
import Data.Bifunctor
import Data.Tuple
--import Streaming
--import qualified Streaming.Prelude as S
-- this needs to be tested with both reflections and refractions
reflectLaserAlong :: Float -> Point2 -> Point2 -> World
-> (Maybe (Point2,Either Creature Wall),[Point2])
reflectLaserAlong ::
Float ->
Point2 ->
Point2 ->
World ->
(Maybe (Point2, Either Creature Wall), [Point2])
{-# INLINE reflectLaserAlong #-}
reflectLaserAlong phasev sp ep w = case thingHitFilt (const True) _wlUnshadowed sp ep w of
Just (p,Right wl)
| _wlReflect wl -> second (p:) $ reflectLaserAlong phasev
(p +.+ unitVectorAtAngle (reflDirWall sp p wl))
(p +.+ dist p ep *.* unitVectorAtAngle (reflDirWall sp p wl))
w
| wlIsSeeThrough wl -> second (p:) $ reflectLaserAlong phasev
(p +.+ normalizeV (refract phasev sp ep wl p))
(refract phasev sp ep wl p)
w
| otherwise -> (Just (p,Right wl), [p])
Just (p,obj) -> (Just (p,obj), [p])
Just (p, Right wl)
| _wlReflect wl ->
second (p :) $
reflectLaserAlong
phasev
(p +.+ unitVectorAtAngle (reflDirWall sp p wl))
(p +.+ dist p ep *.* unitVectorAtAngle (reflDirWall sp p wl))
w
| wlIsSeeThrough wl ->
second (p :) $
reflectLaserAlong
phasev
(p +.+ normalizeV (refract phasev sp ep wl p))
(refract phasev sp ep wl p)
w
| otherwise -> (Just (p, Right wl), [p])
Just (p, obj) -> (Just (p, obj), [p])
Nothing -> (Nothing, [ep])
refract :: Float -> Point2 -> Point2 -> Wall -> Point2 -> Point2
{-# INLINE refract #-}
refract phasev x y wl p
| isEntering = p +.+ rotateV angleRef (normalDist wlNormal)
| otherwise = p +.+ rotateV angleRef' (normalDist wlNormal')
where
refract phasev x y wl p
| isEntering = p +.+ rotateV angleRef (normalDist wlNormal)
| otherwise = p +.+ rotateV angleRef' (normalDist wlNormal')
where
wlNormal = vNormal $ uncurry (-.-) $ swap (_wlLine wl)
wlNormal' = vNormal $ uncurry (-.-) (_wlLine wl)
normalDist wlnormal = magV (p -.- y) *.* normalizeV wlnormal
normalDist wlnormal = magV (p -.- y) *.* normalizeV wlnormal
angleInc = piRange $ argV wlNormal - argV (x -.- y)
angleRef
angleRef
| reflectExternal = angleInc
| otherwise = asin $ sin angleInc / phasev
piRange a'
piRange a'
| a' > pi = a' - 2 * pi
| a' > negate pi = a'
| otherwise = a' + 2 * pi
| otherwise = a' + 2 * pi
isEntering = not $ isLeftOf (x -.- y) (uncurry (-.-) (_wlLine wl))
angleInc' = piRange $ argV wlNormal' - argV (x -.- y)
angleRef'
angleRef'
| reflectInternal = angleInc'
| otherwise = asin $ phasev * sin angleInc'
reflectInternal = 1 < abs (phasev * sin angleInc')
+2 -96
View File
@@ -1,109 +1,15 @@
module Dodge.Item.Weapon.Launcher (
launcher,
launcherX,
remoteLauncher,
fireTrackingShell,
explodeRemoteRocket,
) where
import Control.Lens
import Dodge.Data
import Dodge.Default.Weapon
import Dodge.Data.World
import Dodge.Item.Location
import Dodge.Payload
import Dodge.Projectile.Create
import Dodge.Reloading.Action
import Geometry
import qualified IntMapHelp as IM
launcher :: Item
launcher =
defaultWeapon
{ _itParams =
ShellLauncher
{ _shellSpinDrag = 1
, _shellSpinAmount = 2
, _shellThrustDelay = 20
}
, _itTweaks =
Tweakable
{ _tweakParams = basicAmPjMoves
}
, _itInvSize = 3
}
& itDimension . dimRad .~ 9
& itDimension . dimCenter .~ V3 10 0 0
& itUse . useDelay . rateMax .~ 20
& itUse . rUse .~ HeldPJCreation --usePjCreation
& itUse . useMods .~ LauncherMod
& itUse . useAim . aimWeight .~ 8
& itUse . useAim . aimRange .~ 0.5
& itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 20
& itUse . heldConsumption . laAmmoType .~ ProjectileAmmo
{ _amPayload = ExplosionPayload
, _amString = "EXPLOSIVE SHELL"
, _amPjDraw = DrawShell
, _amPjCreation = CreateShell
}
& itUse . heldConsumption . laMax .~ 1
& itUse . heldConsumption . laLoaded .~ 1
& itUse . heldConsumption . laCycle .~ [loadEject 30, loadInsert 30, loadPrime 10]
& itType . iyBase .~ HELD LAUNCHER
& itType . iyModules . at ModLauncherHoming ?~ EMPTYMODULE
launcherX :: Int -> Item
launcherX i =
launcher
& itType . iyBase .~ HELD (LAUNCHERX i)
& itUse . heldConsumption . laMax .~ i
& itUse . heldConsumption . laLoaded .~ i
& itUse . rUse .~ HeldPJCreationX i
& itUse . useMods .~ LauncherXMod i
basicAmPjMoves :: IM.IntMap TweakParam
basicAmPjMoves =
IM.fromList . zip [0 ..] $
[ spinDrag
, spinStart
, thrustParam
]
spinDrag :: TweakParam
spinDrag =
TweakParam
{ _tweakType = TweakSpinDrag
, _tweakVal = 1
, _tweakMax = 5
}
spinStart :: TweakParam
spinStart =
TweakParam
{ _tweakType = TweakSpinAmount
, _tweakVal = 2
, _tweakMax = 5
}
thrustParam :: TweakParam
thrustParam =
TweakParam
{ _tweakType = TweakThrustDelay
, _tweakVal = 1
, _tweakMax = 5
}
remoteLauncher :: Item
remoteLauncher =
launcher
& itType . iyBase .~ HELD REMOTELAUNCHER
& itUse . rUse .~ HeldFireRemoteShell --fireRemoteShell
& itScope .~ RemoteScope (V2 0 0) 1 True
& itUse . heldConsumption . laAmmoType . amPjDraw .~ DrawRemoteShell
-- TODO consider allowing tweaking rocket speed
explodeRemoteRocket ::
-- | Item id
Int ->
@@ -115,7 +21,7 @@ explodeRemoteRocket itid pjid w =
w
& cWorld . projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid]
& cWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
& itPoint . itUse . rUse .~ HeldDoNothing
& itPoint . itUse . heldUse .~ HeldDoNothing
& usePayload (_prjPayload thepj) (_prjPos thepj)
where
itPoint = pointerToItemLocation $ _itemLocations (_cWorld w) IM.! itid
+14 -23
View File
@@ -1,32 +1,23 @@
module Dodge.Item.Weapon.Radar where
import Dodge.Data
import Dodge.RadarSweep
import Dodge.Default
import Control.Lens
{- |
Sends out pulses that display walls. -}
clickDetector :: Detector -> Item
clickDetector dt = defaultWeapon
& itUse . useDelay . rateMax .~ 20
& itUse . rUse .~ HeldDetectorEffect dt --detectorEffect dt
& itUse . useMods .~ AmmoUseCheckMod
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1}
& itType . iyBase .~ HELD (HELDDETECTOR dt)
import Dodge.Data.World
import Dodge.Default
import Dodge.RadarSweep
autoDetector :: Detector -> Item
autoDetector dt = defaultEquipment
& itUse . eqEq . eqSite .~ GoesOnWrist
& itUse . eqEq . eqUse .~ EDetector dt --autoEffect (detectorEffect dt) 100 click1S
& itUse . eqEq . eqParams .~ EquipCounter 0
& itUse . eqEq . eqViewDist ?~ 350
& itType . iyBase .~ EQUIP (AUTODETECTOR dt)
autoDetector dt =
defaultEquipment
& itUse . equipEffect . eeSite .~ GoesOnWrist
& itUse . equipEffect . eeUse .~ EDetector dt --autoEffect (detectorEffect dt) 100 click1S
& itUse . equipEffect . eeParams .~ EquipCounter 0
& itUse . equipEffect . eeViewDist ?~ 350
& itType . iyBase .~ EQUIP (AUTODETECTOR dt)
-- , _itEffect = autoRadarEffect
detectorEffect :: Detector -> Item -> Creature -> World -> World
detectorEffect dt = case dt of
ITEMDETECTOR -> const (aRadarPulse ObItem)
CREATUREDETECTOR -> const (aRadarPulse ObCreature)
WALLDETECTOR -> const (aRadarPulse ObWall)
ITEMDETECTOR -> const (aRadarPulse ObItem)
CREATUREDETECTOR -> const (aRadarPulse ObCreature)
WALLDETECTOR -> const (aRadarPulse ObWall)
+21 -17
View File
@@ -1,26 +1,30 @@
module Dodge.Item.Weapon.Remote
( setRemoteScope
, setRemoteBombScope
) where
import Dodge.Data
module Dodge.Item.Weapon.Remote (
setRemoteScope,
setRemoteBombScope,
) where
import Control.Lens
import Dodge.Data.World
import Dodge.Default
import Geometry
import qualified IntMapHelp as IM
import Control.Lens
setRemoteBombScope :: Int -> Prop -> World -> World
setRemoteBombScope itid pj w' = case _itemLocations (_cWorld w') IM.! itid of
InInv cid invid
-> w' & cWorld . creatures . ix cid . crInv . ix invid . itScope
. scopePos .~ (_prPos pj -.- _crPos (_creatures (_cWorld w') IM.! cid))
& cWorld . creatures . ix cid . crInv . ix invid . itUse . useAim . aimZoom
.~ (defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5})
_ -> w'
InInv cid invid ->
w'
& cWorld . creatures . ix cid . crInv . ix invid . itScope
. scopePos
.~ (_prPos pj -.- _crPos (_creatures (_cWorld w') IM.! cid))
& cWorld . creatures . ix cid . crInv . ix invid . itUse . heldAim . aimZoom
.~ (defaultItZoom{_itZoomMax = 0.5, _itZoomMin = 0.5})
_ -> w'
setRemoteScope :: Int -> Point2 -> World -> World
setRemoteScope itid pos w' = case w' ^? cWorld . itemLocations . ix itid of
Just (InInv cid' invid )
-> w' & cWorld . creatures . ix cid' . crInv . ix invid . itScope
. scopePos .~ (pos -.- _crPos (_creatures (_cWorld w') IM.! cid'))
_ -> w'
Just (InInv cid' invid) ->
w'
& cWorld . creatures . ix cid' . crInv . ix invid . itScope
. scopePos
.~ (pos -.- _crPos (_creatures (_cWorld w') IM.! cid'))
_ -> w'
+20 -24
View File
@@ -1,29 +1,19 @@
module Dodge.Item.Weapon.Shatter where
--import Dodge.WorldEvent.HitEffect
--import Dodge.Item.Weapon.BulletGun.Clip
import Dodge.Data
import Dodge.Wall.Damage
--import Dodge.SoundLogic
import Dodge.Block.Debris
import Dodge.Base.Collide
--import Dodge.Zone
import Dodge.Block.Debris
import Dodge.Creature.HandPos
--import Dodge.ChainEffect
import Dodge.Default.Weapon
import Dodge.Data.World
import Dodge.Wall.Damage
import Geometry
import LensHelp
shatterGun :: Item
shatterGun = defaultWeapon
& itType . iyBase .~ HELD SHATTERGUN
& itUse . useDelay . rateMax .~ 10
& itUse . rUse .~ HeldShatter --shootShatter
& itUse . useMods .~ ShatterMod
& itUse . useAim . aimStance .~ TwoHandFlat
shootShatter :: Item -> Creature -> World -> World
shootShatter it cr w = maybe w (uncurry $ shatterWall w sp ep) $ sequence
$ collidePointWallsFilterStream canshatter sp ep w
shootShatter it cr w =
maybe w (uncurry $ shatterWall w sp ep) $
sequence $
collidePointWallsFilterStream canshatter sp ep w
where
canshatter wl = case _wlOpacity wl of
Opaque -> True
@@ -34,9 +24,15 @@ shootShatter it cr w = maybe w (uncurry $ shatterWall w sp ep) $ sequence
ep = sp +.+ 200 *.* unitVectorAtAngle dir
shatterWall :: World -> Point2 -> Point2 -> Point2 -> Wall -> World
shatterWall w sp ep p wl = w
& makeDebris (_wlMaterial wl) (_wlColor wl) p
& makeDebrisDirected 1 2 (pi/2) (argV $ vNormal $ uncurry (-.-) $ _wlLine wl) (_wlMaterial wl)
(_wlColor wl) p
& damageWall (Damage SHATTERING 1000 sp p ep NoDamageEffect) wl
shatterWall w sp ep p wl =
w
& makeDebris (_wlMaterial wl) (_wlColor wl) p
& makeDebrisDirected
1
2
(pi / 2)
(argV $ vNormal $ uncurry (-.-) $ _wlLine wl)
(_wlMaterial wl)
(_wlColor wl)
p
& damageWall (Damage SHATTERING 1000 sp p ep NoDamageEffect) wl
+15 -13
View File
@@ -1,17 +1,19 @@
module Dodge.Item.Weapon.Shell
( decTimMvVel
) where
import Dodge.Data
import Geometry.Vector
module Dodge.Item.Weapon.Shell (
decTimMvVel,
) where
import Control.Lens
import Dodge.Data.World
import Geometry.Vector
decTimMvVel :: Proj -> World -> World
decTimMvVel pj = cWorld . projectiles . ix pjid %~
( (prjTimer -~ 1)
. (prjPos %~ (+.+ vel) )
. (prjAcc %~ rotateV rot )
)
decTimMvVel pj =
cWorld . projectiles . ix pjid
%~ ( (prjTimer -~ 1)
. (prjPos %~ (+.+ vel))
. (prjAcc %~ rotateV rot)
)
where
rot = _prjSpin pj
vel = _prjVel pj
pjid = _prjID pj
rot = _prjSpin pj
vel = _prjVel pj
pjid = _prjID pj
+25 -24
View File
@@ -1,33 +1,34 @@
module Dodge.Item.Weapon.Spawn where
import Dodge.Data
import Dodge.Default.Weapon
import Dodge.Default.Item
import Control.Lens
import Dodge.Data.World
import Geometry
import qualified IntMapHelp as IM
import Data.Function
import Control.Lens
{- |
Creates a creature next to the creature using the item. -}
Creates a creature next to the creature using the item.
-}
spawnGun :: Creature -> Item
spawnGun _ = defaultWeapon
& itUse . useDelay . rateMax .~ 100
& itUse . rUse .~ HeldDoNothing --(\_ -> spawnCrNextTo cr)
& itUse . useMods .~ HeldModNothing
-- [ ammoCheckI
-- , hammerCheckI
-- ]
& itType . iyBase .~ LEFT SPAWNER
spawnCrNextTo
:: Creature -- ^ Creature to spawn
-> Creature -- ^ existing creature that will be spawned next to
-> World
-> World
spawnGun _ =
defaultHeldItem
& itUse . heldDelay . rateMax .~ 100
& itUse . heldUse .~ HeldDoNothing --(\_ -> spawnCrNextTo cr)
& itUse . heldMods .~ HeldModNothing
& itType . iyBase .~ LEFT SPAWNER
spawnCrNextTo ::
-- | Creature to spawn
Creature ->
-- | existing creature that will be spawned next to
Creature ->
World ->
World
spawnCrNextTo cr sCr w = w & cWorld . creatures %~ IM.insert k newCr
where
k = IM.newKey $ _creatures (_cWorld w)
newCr = cr
& crID .~ k
& crPos .~ _crPos sCr +.+ unitVectorAtAngle (_crDir sCr)
& crOldPos .~ _crPos sCr +.+ unitVectorAtAngle (_crDir sCr)
newCr =
cr
& crID .~ k
& crPos .~ _crPos sCr +.+ unitVectorAtAngle (_crDir sCr)
& crOldPos .~ _crPos sCr +.+ unitVectorAtAngle (_crDir sCr)
-107
View File
@@ -1,107 +0,0 @@
module Dodge.Item.Weapon.SprayGuns (
poisonSprayer,
flameSpitter,
blowTorch,
flameThrower,
flameTorrent,
flameWall,
) where
import Dodge.Data
import Dodge.Default
import Dodge.Reloading.Action
import Geometry
import LensHelp
poisonSprayer :: Item
poisonSprayer =
flameThrower
& itType . iyBase .~ HELD POISONSPRAYER
& itUse . heldConsumption . laAmmoType
.~ GasAmmo
{ _amString = "POISONGAS"
, _amCreateGas = CreatePoisonGas --aGasCloud
}
& itUse . useMods .~ PoisonSprayerMod
flameSpitter :: Item
flameSpitter =
flameThrower
& itType . iyBase .~ HELD FLAMESPITTER
& itUse . heldConsumption . laMax .~ 10
& itUse . heldConsumption . laCycle .~ [loadEject 5, loadInsert 10, loadPrime 20]
& itParams . sprayNozzles . ix 0 . nzPressure .~ 4
& itUse . useAim . aimStance .~ OneHand
& itUse . useDelay .~ FixedRate{_rateMax = 12, _rateTime = 0}
& itUse . useMods .~ FlameSpitterMod
flameTorrent :: Item
flameTorrent =
flameThrower
& itType . iyBase .~ HELD FLAMETORRENT
& itUse . useAim . aimZoom .~ defaultItZoom
& itParams . sprayNozzles . ix 0
%~ ( (nzPressure .~ 10)
. (nzMaxWalkAngle .~ 1.5)
. (nzWalkSpeed .~ 0.05)
)
blowTorch :: Item
blowTorch =
flameThrower
& itType . iyBase .~ HELD BLOWTORCH
flameWall :: Item
flameWall =
flameThrower
& itType . iyBase .~ HELD FLAMEWALL
& itParams . sprayNozzles .~ zipWith makeNozzle [0, 0.6, -0.6] [2, 2.5, 2.5]
where
makeNozzle dir pres =
Nozzle
{ _nzPressure = pres
, _nzDir = dir
, _nzMaxWalkAngle = 0
, _nzWalkSpeed = 0
, _nzCurrentWalkAngle = 0
, _nzLength = 20
}
flameThrower :: Item
flameThrower =
defaultAutoGun
{ _itParams =
Sprayer
{ _sprayNozzles =
[ Nozzle
{ _nzPressure = 4
, _nzDir = 0
, _nzMaxWalkAngle = 0.2
, _nzWalkSpeed = 0.01
, _nzCurrentWalkAngle = 0
, _nzLength = 10
}
]
}
}
& itDimension . dimRad .~ 7
& itDimension . dimCenter .~ V3 9 0 0
& itUse . rUse .~ HeldOverNozzlesUseGasParams -- overNozzles useGasParams
& itUse . useDelay .~ NoDelay
& itUse . useMods .~ FlameThrowerMod
& itUse . useAim . aimWeight .~ 5
& itUse . useAim . aimZoom .~ defaultItZoom{_itZoomMax = 5, _itZoomMin = 1.5}
& itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimHandlePos .~ 0
& itUse . useAim . aimMuzPos .~ 18
& itUse . heldConsumption
.~ ( defaultLoadable
& laMax .~ 250
& laAmmoType
.~ GasAmmo
{ _amString = "FLAME"
, _amCreateGas = CreateFlame --aFlame
}
& laCycle .~ [loadEject 5, loadInsert 10, loadPrime 20]
)
& itType . iyBase .~ HELD FLAMETHROWER
+12 -12
View File
@@ -1,17 +1,17 @@
module Dodge.Item.Weapon.Targeting
( useTargetPos
, removeItTarget
) where
import Dodge.Data
import Geometry.Data
module Dodge.Item.Weapon.Targeting (
useTargetPos,
removeItTarget,
) where
import Control.Lens
--import qualified IntMapHelp as IM
useTargetPos
:: (Maybe Point2 -> Creature -> World -> World)
-> Creature
-> World
-> World
import Dodge.Data.World
import Geometry.Data
useTargetPos ::
(Maybe Point2 -> Creature -> World -> World) ->
Creature ->
World ->
World
useTargetPos f cr w = case cr ^? crInv . ix (crSel cr) . itTargeting . tgPos of
Nothing -> w
Just p -> f p cr w
File diff suppressed because it is too large Load Diff
+11 -35
View File
@@ -1,11 +1,11 @@
module Dodge.Item.Weapon.Utility where
import Dodge.Default.Item.Use
import Control.Lens
import Data.Maybe
import Dodge.Base.Coordinate
import Dodge.Data
import Dodge.Data.World
import Dodge.Default
import Dodge.Item.Weapon.ExtraEffect
import Dodge.Wall.ForceField
import Dodge.Wall.Move
import Geometry
@@ -19,9 +19,9 @@ rewindGun =
defaultLeftItem
{ _itInvColor = cyan
, _itUse =
defaultlUse
& lUse .~ LRewind --useRewindGun
& eqEq . eqSite .~ GoesOnChest
defaultLeftUse
& leftUse .~ LRewind --useRewindGun
& equipEffect . eeSite .~ GoesOnChest
}
& itEffect . ieInv .~ RewindEffect
& itType . iyBase .~ LEFT REWINDER
@@ -35,7 +35,7 @@ rewindGun =
shrinkGun :: Item
shrinkGun =
defaultLeftItem
& itUse .~ (defaultlUse & lUse .~ LShrink)
& itUse .~ (defaultLeftUse & leftUse .~ LShrink)
& itParams .~ ShrinkGunParams FullSize
& itType . iyBase .~ LEFT SHRINKER
@@ -47,9 +47,9 @@ blinkGun =
defaultLeftItem
{ _itInvColor = cyan
, _itUse =
defaultlUse
& lUse .~ LBlink --hammerCheckL (shootL $ const blinkAction)
& eqEq . eqSite .~ GoesOnWrist
defaultLeftUse
& leftUse .~ LBlink --hammerCheckL (shootL $ const blinkAction)
& equipEffect . eeSite .~ GoesOnWrist
-- , _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2
}
& itType . iyBase .~ LEFT BLINKER
@@ -58,33 +58,9 @@ unsafeBlinkGun :: Item
unsafeBlinkGun =
blinkGun
& itType . iyBase .~ LEFT BLINKERUNSAFE
& itUse . lUse .~ LUnsafeBlink --hammerCheckL (shootL $ const unsafeBlinkAction)
& itUse . eqEq . eqViewDist ?~ 400
& itUse . leftUse .~ LUnsafeBlink --hammerCheckL (shootL $ const unsafeBlinkAction)
& itUse . equipEffect . eeViewDist ?~ 400
--effectGun :: String -> (Creature -> World -> World) -> Item
--effectGun name eff = defaultWeapon
-- { _itUse = defaultrUse
-- & rUse .~ const eff
-- & useMods .~ [hammerCheckI]
-- }
-- & itType . iyBase .~ EFFGUN name
--autoEffectGun :: String -> (Creature -> World -> World) -> Item
--autoEffectGun name eff = defaultWeapon
-- { _itUse = defaultrUse {_rUse = const eff}
-- }
-- & itType . iyBase .~ AUTOEFFGUN name
forceFieldGun :: Item
forceFieldGun =
defaultWeapon
& itTargeting .~ (targetRBPress & tgDraw .~ TargetDistanceDraw)
& itParams .~ ParamMID Nothing
& itUse . rUse .~ HeldForceField --useForceFieldGun
& itUse . useDelay .~ NoDelay
& itUse . useMods .~ AmmoHammerTimeUseOneMod -- this is slightly different
-- than the list below
--[ hammerCheckI , ammoCheckI , useAmmoAmount 1]
& itType . iyBase .~ HELD FORCEFIELDGUN
& itUse . heldConsumption .~ (defaultLoadable & laAmmoType .~ ForceFieldAmmo forceField)
-- I believe because the targeting returns to nothing straight after you release
-- the rmb, it is possible for this to do nothing
+4 -3
View File
@@ -1,10 +1,11 @@
module Dodge.Item.Weapon.ZoomScope where
import Dodge.Data
import Dodge.Data.Creature
import LensHelp
-- should be possible without the creature
zoomLongGun :: Float -> Creature -> Item -> Item
zoomLongGun x _
| x > 0 = itScope . scopeZoomChange %~ (max 15 . (+4))
| x > 0 = itScope . scopeZoomChange %~ (max 15 . (+ 4))
| x < 0 = itScope . scopeZoomChange %~ (min (-15) . subtract 4)
| otherwise = id
--zoomLongGun x _ = itScope . scopeZoomChange .~ round (signum x)