Add (ugly) support for fractional volumes
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
module Dodge.Item.Weapon.BatteryGuns
|
||||
( lasGun
|
||||
, lasGunWide
|
||||
, lasGunSway
|
||||
, lasGunSwing
|
||||
, lasGunFocus
|
||||
, lasGunPulse
|
||||
, sparkGun
|
||||
, teslaGun
|
||||
, tractorGun
|
||||
@@ -93,32 +96,126 @@ teslaGunPic _ = noPic $ colorSH blue $
|
||||
where
|
||||
xa = 1
|
||||
xb = 9
|
||||
lasGunPulse :: Item
|
||||
lasGunPulse = lasGun
|
||||
& itName .~ "PULSELAS"
|
||||
& itType .~ LASPULSE
|
||||
& itUse . useMods .~
|
||||
[ ammoCheckI
|
||||
, withItem $ \it -> withTempLight 1 (100 * frac it) (xyzV4 (_lasColor $ _itParams it))
|
||||
, withItem $ \it -> withSoundForVol (frac it) tone440sawtoothquietS 2
|
||||
, withItemUpdate itup
|
||||
$ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) (frac it * 0.8)
|
||||
, useAmmoAmount 1
|
||||
]
|
||||
where
|
||||
itup it = it
|
||||
& itParams . lasCycle %~ (\i -> (i+1) `mod` 20)
|
||||
& itParams . lasDamage .~ ceiling ((22 :: Float) * frac it)
|
||||
& itParams . lasColor .~ frac it * orange
|
||||
frac it = 0.5 * (1 + sin (pi * fromIntegral (_lasCycle $ _itParams it) * 0.1))
|
||||
|
||||
|
||||
lasGunWide :: Int -> Item
|
||||
lasGunWide n = lasGun
|
||||
lasGunWide n = lasGun
|
||||
& itName .~ "PARALELLAS"++show n
|
||||
& itType .~ LASGUNWIDE n
|
||||
& itUse . useMods .~
|
||||
& itParams . lasColor .~ orange
|
||||
& itParams . lasDamage .~ 2
|
||||
& itUse .~ ( ruseInstant shootLaser NoHammer
|
||||
[ ammoCheckI
|
||||
, withTempLight 1 100 (V3 1 1 0)
|
||||
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
|
||||
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, withSoundForI tone440sawtoothquietS 2
|
||||
, duplicateOffsets xs
|
||||
, useAmmoAmount 1
|
||||
, duplicateOffsets xs
|
||||
]
|
||||
& useAim . aimSpeed .~ 0.4
|
||||
& useAim . aimRange .~ 1
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
)
|
||||
where
|
||||
xs = [ 3 * (fromIntegral x - fromIntegral (n-1) /2) | x <- [0..n-1] ]
|
||||
n' = 9 * n
|
||||
xs = [ 0.25 * (fromIntegral x - fromIntegral (n'-1) /2) | x <- [0..n'-1] ]
|
||||
lasGunWidePulse :: Int -> Item
|
||||
lasGunWidePulse n = lasGun
|
||||
& itName .~ "PARALELLASPULSE"++show n
|
||||
& itType .~ LASGUNWIDE n
|
||||
& itParams . lasColor .~ orange
|
||||
& itParams . lasDamage .~ 2
|
||||
& itUse .~ ( ruseInstant shootLaser NoHammer
|
||||
[ ammoCheckI
|
||||
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
|
||||
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, withSoundForI tone440sawtoothquietS 2
|
||||
, useAmmoAmount 1
|
||||
, duplicateOffsets xs
|
||||
]
|
||||
& useAim . aimSpeed .~ 0.4
|
||||
& useAim . aimRange .~ 1
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
)
|
||||
where
|
||||
n' = 9 * n
|
||||
xs = [ 0.25 * (fromIntegral x - fromIntegral (n'-1) /2) | x <- [0..n'-1] ]
|
||||
lasGunSway :: Item
|
||||
lasGunSway = lasGun
|
||||
& itName .~ "SWAYLAS"
|
||||
& itType .~ LASGUNSWAY
|
||||
& itParams . lasColor .~ orange
|
||||
& itParams . lasDamage .~ 11
|
||||
& itUse .~ ( ruseInstant shootLaser NoHammer
|
||||
[ ammoCheckI
|
||||
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
|
||||
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, withSoundForI tone440sawtoothquietS 2
|
||||
, useAmmoAmount 1
|
||||
, withItemUpdate itup $ \it -> duplicateOffsets (x it)
|
||||
]
|
||||
& useAim . aimSpeed .~ 0.4
|
||||
& useAim . aimRange .~ 1
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
)
|
||||
where
|
||||
itup = itParams . lasCycle %~ (\i -> (i+1) `mod` 40)
|
||||
x it = [ 15 * sin (pi * fromIntegral x' * 0.05) ]
|
||||
where
|
||||
x' = _lasCycle $ _itParams it
|
||||
lasGunFocus :: Int -> Item
|
||||
lasGunFocus n = lasGun
|
||||
lasGunFocus n = lasGunWide n
|
||||
& itName .~ "FOCALAS"++show n
|
||||
& itType .~ LASGUNFOCUS n
|
||||
& itParams . lasColor .~ red
|
||||
& itUse . useMods .~
|
||||
[ ammoCheckI
|
||||
, withTempLight 1 100 (V3 1 1 0)
|
||||
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
|
||||
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, withSoundForI tone440sawtoothquietS 2
|
||||
, duplicateOffsetsFocus xs
|
||||
, useAmmoAmount 1
|
||||
, duplicateOffsetsFocus xs
|
||||
]
|
||||
where
|
||||
xs = [ 3 * (fromIntegral x - fromIntegral (n-1) /2) | x <- [0..n-1] ]
|
||||
n' = 9 * n
|
||||
xs = [ 0.25 * (fromIntegral x - fromIntegral (n'-1) /2) | x <- [0..n'-1] ]
|
||||
lasGunSwing :: Item
|
||||
lasGunSwing = lasGun
|
||||
& itName .~ "SWINGLAS"
|
||||
& itType .~ LASGUNSWING
|
||||
& itParams . lasColor .~ orange
|
||||
& itUse . useMods .~
|
||||
[ ammoCheckI
|
||||
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
|
||||
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, withSoundForI tone440sawtoothquietS 2
|
||||
, useAmmoAmount 1
|
||||
, withItemUpdate itup $ \it -> duplicateOffsetsFocus (x it)
|
||||
]
|
||||
where
|
||||
itup = itParams . lasCycle %~ (\i -> (i+1) `mod` 200)
|
||||
x it = [-y,y]
|
||||
where
|
||||
y = 15 * sin (pi * fromIntegral x' * 0.01)
|
||||
x' = _lasCycle $ _itParams it
|
||||
lasGun :: Item
|
||||
lasGun = defaultAutoBatteryGun
|
||||
{ _itName = "LASGUN"
|
||||
@@ -130,14 +227,20 @@ lasGun = defaultAutoBatteryGun
|
||||
}
|
||||
, _itUse = ruseInstant shootLaser NoHammer
|
||||
[ ammoCheckI
|
||||
, withTempLight 1 100 (V3 1 1 0)
|
||||
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
|
||||
, withSoundForI tone440sawtoothquietS 2
|
||||
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, useAmmoAmount 1
|
||||
]
|
||||
& useAim . aimSpeed .~ 0.4
|
||||
& useAim . aimRange .~ 1
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
, _itParams = Refracting {_phaseV = 1}
|
||||
, _itParams = Refracting
|
||||
{ _phaseV = 1
|
||||
, _lasColor = yellow
|
||||
, _lasCycle = 0
|
||||
, _lasDamage = 11
|
||||
}
|
||||
, _itTweaks = Tweakable
|
||||
{ _tweakParams = IM.fromList [(0,lasGunTweak)]
|
||||
, _tweakSel = 0
|
||||
@@ -294,17 +397,21 @@ updateArc :: ItemParams
|
||||
updateArc = createNewArc
|
||||
|
||||
shootLaser :: Item -> Creature -> World -> World
|
||||
shootLaser it cr = (instantParticles .:~ lasRayAt phasev pos dir)
|
||||
. flareCircleAt yellow 0.8 (pos `v2z` 20)
|
||||
shootLaser it cr = instantParticles .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
|
||||
where
|
||||
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
|
||||
dir = _crDir cr
|
||||
phasev = _phaseV . _itParams $ _crInv cr IM.! _crInvSel cr
|
||||
dam = _lasDamage $ _itParams it
|
||||
|
||||
lasRayAt :: Float -> Point2 -> Float -> Particle
|
||||
lasRayAt phasev pos dir = Particle
|
||||
lasRayAt :: Color -> Int -> Float -> Point2 -> Float -> Particle
|
||||
lasRayAt col dam phasev pos dir = LaserParticle
|
||||
{ _ptDraw = const blank
|
||||
, _ptUpdate = mvLaser phasev pos dir
|
||||
, _ptRange = 800
|
||||
, _ptDamage = dam
|
||||
, _ptPhaseV = phasev
|
||||
, _ptColor = col
|
||||
}
|
||||
mvLaser :: Float -- ^ Phase velocity, controls deflection through windows
|
||||
-> Point2
|
||||
@@ -313,15 +420,17 @@ mvLaser :: Float -- ^ Phase velocity, controls deflection through windows
|
||||
-> Particle
|
||||
-> (World, Maybe Particle)
|
||||
mvLaser phasev pos dir w pt
|
||||
= ( damThingHitWith (\p1 p2 p3 -> Damage Lasering 11 p1 p2 p3 NoDamageEffect) pos xp thHit w
|
||||
= ( damThingHitWith (\p1 p2 p3 -> Damage Lasering dam p1 p2 p3 NoDamageEffect) pos xp thHit w
|
||||
, Just pt {_ptDraw = const pic ,_ptUpdate = ptSimpleTime 0 }
|
||||
)
|
||||
where
|
||||
dam = _ptDamage pt
|
||||
xp = pos +.+ 800 *.* unitVectorAtAngle dir
|
||||
(thHit, ps) = reflectLaserAlong phasev [] pos xp w
|
||||
col = _ptColor pt
|
||||
pic = setLayer 1 $ pictures
|
||||
[ setDepth 19 . color (brightX 0 0.5 yellow) $ thickLine 20 (pos:ps)
|
||||
, setDepth 19.5 . color (brightX 10 1 yellow) $ thickLine 3 (pos:ps)
|
||||
[ setDepth 19 . color (brightX 0 0.5 col) $ thickLine 20 (pos:ps)
|
||||
, setDepth 19.5 . color (brightX 10 1 col) $ thickLine 3 (pos:ps)
|
||||
]
|
||||
aTractorBeam :: Item -> Creature -> World -> World
|
||||
aTractorBeam _ cr w = w & props . at i ?~ tractorBeamAt i spos outpos dir power
|
||||
|
||||
Reference in New Issue
Block a user