Add more weapons to attachment chain effects
This commit is contained in:
+80
-30
@@ -5,6 +5,7 @@ module Dodge.HeldUse
|
||||
-- )
|
||||
where
|
||||
|
||||
import Dodge.Base.Collide
|
||||
import Dodge.Inventory.Lock
|
||||
import Dodge.WorldEvent.Cloud
|
||||
import Dodge.LightSource
|
||||
@@ -79,12 +80,12 @@ heldEffect effecttype = case effecttype of
|
||||
-- , ammoCheckI
|
||||
, blCheck
|
||||
]
|
||||
TeslaMod -> foldl' (&) (shootTeslaArc . _ldtValue)
|
||||
[ useAmmoAmount 1
|
||||
, withSoundForI elecCrackleS 1
|
||||
, withTempLight 1 100 (V3 0 0 1)
|
||||
, ammoCheckI
|
||||
]
|
||||
-- TeslaMod -> foldl' (&) (shootTeslaArc . _ldtValue)
|
||||
-- [ useAmmoAmount 1
|
||||
-- , withSoundForI elecCrackleS 1
|
||||
-- , withTempLight 1 100 (V3 0 0 1)
|
||||
-- , ammoCheckI
|
||||
-- ]
|
||||
LasWideMod n -> foldl' (&) (shootLaser . _ldtValue)
|
||||
[ useAmmoAmount 1
|
||||
, withItem $ \it ->
|
||||
@@ -454,6 +455,8 @@ makeMuzzleFlare mz itm cr = case mz ^. mzFlareType of
|
||||
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
|
||||
HeavySmokeFlare -> basicMuzFlare pos dir
|
||||
LasGunFlare -> flareCircleAt (_lasColor $ _itParams itm) 0.8 (pos `v2z` 20)
|
||||
TeslaGunFlare -> cWorld . lWorld . tempLightSources .:~
|
||||
tlsTimeRadColPos 1 100 (V3 0 0 1) (pos `v2z` 10)
|
||||
where
|
||||
pos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm)
|
||||
dir = _crDir cr + _mzRot mz
|
||||
@@ -464,6 +467,7 @@ basicMuzFlare pos dir = makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) (pos `v2z` 20)
|
||||
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
|
||||
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
|
||||
|
||||
-- need to add these to muzzle flare
|
||||
makeMuzzleSmoke :: Muzzle -> Item -> Creature -> World -> World
|
||||
makeMuzzleSmoke mz itm cr w = case mz ^. mzFlareType of
|
||||
DefaultFlareType -> w
|
||||
@@ -471,6 +475,7 @@ makeMuzzleSmoke mz itm cr w = case mz ^. mzFlareType of
|
||||
MiniGunFlare -> smokeCloudAt (greyN 0.5) 5 400 5 pos w
|
||||
HeavySmokeFlare -> foldl' (flip $ smokeCloudAt black 20 400 5 . (+.+.+ pos) . (* 8)) w ps'
|
||||
LasGunFlare -> w
|
||||
TeslaGunFlare -> w
|
||||
where
|
||||
ps = replicateM 2 randOnUnitSphere & evalState $ _randGen w
|
||||
ps' = replicateM 4 randOnUnitSphere & evalState $ _randGen w
|
||||
@@ -484,20 +489,65 @@ isAmmoIntLink _ _ = False
|
||||
useLoadedAmmo :: Item -> Creature -> (CumulativeMuzzleEffect,World) -> (Muzzle,Int,Maybe Int)
|
||||
-> (CumulativeMuzzleEffect,World)
|
||||
useLoadedAmmo _ _ (cme,w) (_,0,_) = (cme, w)
|
||||
useLoadedAmmo itm cr (cme,w) (mz,x,mid) = case _mzEffect mz of
|
||||
MuzzleShootBullet ->
|
||||
useLoadedAmmo itm cr (cme,w) (mz,x,mid) = (,) (cme & cmeSound .~ True) $
|
||||
removeAmmoFromMag x mid cr . makeMuzzleFlare mz itm cr $ case _mzEffect mz of
|
||||
MuzzleShootBullet -> shootBullet itm cr w (mz,x,mid)
|
||||
MuzzleLaser -> shootLaser' itm cr mz w
|
||||
MuzzleTesla -> shootTeslaArc itm cr mz w
|
||||
MuzzleTractor -> shootTractorBeam itm cr w
|
||||
MuzzleLauncher -> createProjectile' mid mz itm cr w
|
||||
|
||||
shootTractorBeam :: Item -> Creature -> World -> World
|
||||
shootTractorBeam _ cr w = w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt' spos outpos dir power
|
||||
where
|
||||
cpos = _crPos cr
|
||||
spos = cpos +.+ (_crRad cr + 10) *.* unitVectorAtAngle dir
|
||||
xpos = cpos +.+ 400 *.* unitVectorAtAngle dir
|
||||
dir = _crDir cr
|
||||
outpos = fst $ collidePointWallsFilter (const True) cpos xpos w
|
||||
power = _attractionPower . _itParams $ _crInv cr IM.! itRef
|
||||
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||
|
||||
fromMaybe (cme,w) $ do
|
||||
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
|
||||
|
||||
shootLaser' :: Item -> Creature -> Muzzle -> World -> World
|
||||
shootLaser' itm cr mz w = w
|
||||
& randGen .~ g
|
||||
&
|
||||
cWorld . lWorld . lasers
|
||||
.:~ lasRayAt
|
||||
(_lasColor $ _itParams itm)
|
||||
(_lasDamage $ _itParams itm)
|
||||
(_phaseV $ _itParams itm)
|
||||
pos
|
||||
dir
|
||||
where
|
||||
pos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm)
|
||||
(a,g) = randomR (-inacc,inacc) $ _randGen w
|
||||
inacc = _mzInaccuracy mz
|
||||
dir = _crDir cr + _mzRot mz + a
|
||||
|
||||
removeAmmoFromMag x mid cr = fromMaybe id $ do
|
||||
magid <- mid
|
||||
return $ cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix magid . itUse . amagLoadStatus . iaLoaded -~ x
|
||||
|
||||
shootBullet :: Item -> Creature -> World -> (Muzzle,Int,Maybe Int) -> World
|
||||
shootBullet itm cr w (mz,x,mid) = fromMaybe w $ do
|
||||
magid <- mid
|
||||
-- should be able to pass the magazine in from elsewhere?
|
||||
thebullet <- cr ^? crInv . ix magid . itUse . amagParams . ampBullet
|
||||
return $ (cme & cmeSound .~ True,
|
||||
w & cWorld . lWorld . creatures . ix cid . crInv . ix magid . itUse . amagLoadStatus . iaLoaded -~ x
|
||||
& flip (foldl' (&)) (replicate x (makeBullet thebullet itm cr mz))
|
||||
return $ w & flip (foldl' (&)) (replicate x (makeBullet thebullet itm cr mz))
|
||||
& makeMuzzleFlare mz itm cr
|
||||
& makeMuzzleSmoke mz itm cr
|
||||
)
|
||||
where
|
||||
cid = _crID cr
|
||||
|
||||
@@ -543,7 +593,7 @@ useMod :: HeldMod ->
|
||||
[(LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World)
|
||||
-> LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World]
|
||||
useMod hm = case hm of
|
||||
TractorMod -> undefined
|
||||
-- TractorMod -> undefined
|
||||
FireRemoteShellMod -> undefined
|
||||
ExplodeRemoteShellMod -> undefined
|
||||
DoNothingMod -> undefined
|
||||
@@ -586,12 +636,12 @@ useMod hm = case hm of
|
||||
-- , ammoCheckI
|
||||
, blCheck
|
||||
]
|
||||
TeslaMod ->
|
||||
[ useAmmoAmount 1
|
||||
, withSoundForI elecCrackleS 1
|
||||
, withTempLight 1 100 (V3 0 0 1)
|
||||
, ammoCheckI
|
||||
]
|
||||
-- TeslaMod ->
|
||||
-- [ useAmmoAmount 1
|
||||
-- , withSoundForI elecCrackleS 1
|
||||
-- , withTempLight 1 100 (V3 0 0 1)
|
||||
-- , ammoCheckI
|
||||
-- ]
|
||||
-- CircleLaserMod ->
|
||||
-- [ duplicateItem fLasCircle
|
||||
-- , useAmmoAmount 1
|
||||
@@ -733,13 +783,13 @@ useMod hm = case hm of
|
||||
-- , useTimeCheck
|
||||
-- , ammoCheckI -- cf ElephantGun
|
||||
-- ]
|
||||
MachineGunMod ->
|
||||
[ withFlare
|
||||
, withThinSmokeI
|
||||
, withSoundStart bangEchoS
|
||||
, rateIncAB (torqueBeforeAtLeast 0.1 0.1) withTorqueAfter
|
||||
, ammoCheckI
|
||||
]
|
||||
-- MachineGunMod ->
|
||||
-- [ withFlare
|
||||
-- , withThinSmokeI
|
||||
-- , withSoundStart bangEchoS
|
||||
-- , rateIncAB (torqueBeforeAtLeast 0.1 0.1) withTorqueAfter
|
||||
-- , ammoCheckI
|
||||
-- ]
|
||||
-- ModWithDirectedTeleport hm' ->
|
||||
-- reverse $ withPosDirWallCheck directedTelPos : useMod hm'
|
||||
-- BangStickMod ->
|
||||
@@ -878,7 +928,7 @@ useHeld hu = case hu of
|
||||
HeldPJCreationX _ -> usePjCreationX
|
||||
HeldFireRemoteShell -> fireRemoteShell
|
||||
HeldDetectorEffect dt -> detectorEffect dt . _ldtValue
|
||||
HeldTeslaArc -> shootTeslaArc . _ldtValue
|
||||
-- HeldTeslaArc -> shootTeslaArc . _ldtValue
|
||||
HeldLaser -> shootLaser . _ldtValue
|
||||
HeldCircleLaser -> circleLaser . _ldtValue
|
||||
HeldDualLaser -> shootDualLaser . _ldtValue
|
||||
@@ -1029,8 +1079,8 @@ mcShootLaser it mc = cWorld . lWorld . lasers .:~ lasRayAt (_lasColor $ _itParam
|
||||
dam = _lasDamage $ _itParams it
|
||||
|
||||
-- | assumes that the item is held
|
||||
shootTeslaArc :: Item -> Creature -> World -> World
|
||||
shootTeslaArc it cr w =
|
||||
shootTeslaArc :: Item -> Creature -> Muzzle -> World -> World
|
||||
shootTeslaArc it cr mz w =
|
||||
w'
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itParams .~ ip
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user