Implement dual laser tesla
This commit is contained in:
@@ -148,7 +148,10 @@ moduleCombinations =
|
|||||||
, ( ModDualBeam
|
, ( ModDualBeam
|
||||||
, [lasGunDual]
|
, [lasGunDual]
|
||||||
, [amod [INCENDIARYMODULE] "+INCENDIARY" (itParams . lasBeam .~ BeamCombine flameBeamCombine)
|
, [amod [INCENDIARYMODULE] "+INCENDIARY" (itParams . lasBeam .~ BeamCombine flameBeamCombine)
|
||||||
,amod [STATICMODULE] "+STATIC" (itParams . lasBeam .~ BeamCombine teslaBeamCombine)
|
,amod [STATICMODULE] "+STATIC"
|
||||||
|
( (itParams . lasBeam .~ BeamCombine teslaBeamCombine)
|
||||||
|
. (itParams . subParams .~ Just teslaParams)
|
||||||
|
)
|
||||||
,amod [TRANSFORMER] "+SPLIT" (itParams . lasBeam .~ BeamCombine splitBeamCombine)
|
,amod [TRANSFORMER] "+SPLIT" (itParams . lasBeam .~ BeamCombine splitBeamCombine)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-4
@@ -520,15 +520,12 @@ data Beam = Beam
|
|||||||
, _bmFirstPoints :: [Point2]
|
, _bmFirstPoints :: [Point2]
|
||||||
, _bmRange :: Float
|
, _bmRange :: Float
|
||||||
, _bmPhaseV :: Float
|
, _bmPhaseV :: Float
|
||||||
|
, _bmOrigin :: Maybe Int
|
||||||
, _bmType :: BeamType
|
, _bmType :: BeamType
|
||||||
}
|
}
|
||||||
data BeamType
|
data BeamType
|
||||||
= BeamCombine
|
= BeamCombine
|
||||||
{_beamCombine :: (Point2 , (Point2,Point2,Beam) , (Point2,Point2,Beam)) -> World -> World}
|
{_beamCombine :: (Point2 , (Point2,Point2,Beam) , (Point2,Point2,Beam)) -> World -> World}
|
||||||
| BeamItemParamsCombine
|
|
||||||
{_beamCombine :: (Point2 , (Point2,Point2,Beam) , (Point2,Point2,Beam)) -> World -> World
|
|
||||||
,_beamItemParams :: ItemParams
|
|
||||||
}
|
|
||||||
| BeamSimple
|
| BeamSimple
|
||||||
|
|
||||||
{- Objects without ids.
|
{- Objects without ids.
|
||||||
@@ -682,6 +679,7 @@ data ItemParams
|
|||||||
, _lasCycle :: Int
|
, _lasCycle :: Int
|
||||||
, _lasDamage :: Int
|
, _lasDamage :: Int
|
||||||
, _lasBeam :: BeamType
|
, _lasBeam :: BeamType
|
||||||
|
, _subParams :: Maybe ItemParams
|
||||||
}
|
}
|
||||||
| Attracting {_attractionPower :: Point2}
|
| Attracting {_attractionPower :: Point2}
|
||||||
| BulletShooter
|
| BulletShooter
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import qualified IntMapHelp as IM
|
|||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
|
||||||
setHeldItemPos :: Creature -> World -> World
|
setHeldItemLoc :: Creature -> World -> World
|
||||||
setHeldItemPos cr = fst . getHeldItemPos cr
|
setHeldItemLoc cr = fst . getHeldItemLoc cr
|
||||||
|
|
||||||
getHeldItemPos :: Creature -> World -> (World,Int)
|
getHeldItemLoc :: Creature -> World -> (World,Int)
|
||||||
getHeldItemPos cr w = case maybeitid of
|
getHeldItemLoc cr w = case maybeitid of
|
||||||
Nothing ->
|
Nothing ->
|
||||||
( w & creatures . ix cid . crInv . ix j . itID ?~ newitid
|
( w & creatures . ix cid . crInv . ix j . itID ?~ newitid
|
||||||
& itemPositions %~ IM.insert newitid (InInv cid j)
|
& itemPositions %~ IM.insert newitid (InInv cid j)
|
||||||
@@ -21,3 +21,16 @@ getHeldItemPos cr w = case maybeitid of
|
|||||||
newitid = IM.newKey $ _itemPositions w
|
newitid = IM.newKey $ _itemPositions w
|
||||||
maybeitid = cr ^? crInv . ix j . itID . _Just
|
maybeitid = cr ^? crInv . ix j . itID . _Just
|
||||||
itid = fromMaybe newitid maybeitid
|
itid = fromMaybe newitid maybeitid
|
||||||
|
|
||||||
|
getItem :: Int -> World -> Maybe Item
|
||||||
|
getItem itid w = do
|
||||||
|
itpos <- w ^? itemPositions . ix itid
|
||||||
|
case itpos of
|
||||||
|
OnFloor flitid -> w ^? floorItems . ix flitid . flIt
|
||||||
|
InInv cid invid -> w ^? creatures . ix cid . crInv . ix invid
|
||||||
|
|
||||||
|
pointToItem :: Applicative f =>
|
||||||
|
ItemPos -> (Item -> f Item) -> World -> f World
|
||||||
|
pointToItem (InInv cid invid) = creatures . ix cid . crInv . ix invid
|
||||||
|
pointToItem (OnFloor flid) = floorItems . ix flid . flIt
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ module Dodge.Item.Weapon.BatteryGuns
|
|||||||
, lasGunPulse
|
, lasGunPulse
|
||||||
, sparkGun
|
, sparkGun
|
||||||
, teslaGun
|
, teslaGun
|
||||||
|
, teslaParams
|
||||||
, tractorGun
|
, tractorGun
|
||||||
, lasRayAt
|
, lasRayAt
|
||||||
, flameBeamCombine
|
, flameBeamCombine
|
||||||
@@ -17,6 +18,7 @@ module Dodge.Item.Weapon.BatteryGuns
|
|||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Item.Weapon.LaserPath
|
import Dodge.Item.Weapon.LaserPath
|
||||||
|
import Dodge.Item.Location
|
||||||
import Dodge.Creature.HandPos
|
import Dodge.Creature.HandPos
|
||||||
import Dodge.Particle.TeslaArc
|
import Dodge.Particle.TeslaArc
|
||||||
import Dodge.Particle.Flame
|
import Dodge.Particle.Flame
|
||||||
@@ -93,13 +95,15 @@ teslaGun = defaultBatteryGun
|
|||||||
}
|
}
|
||||||
, _dimSPic = teslaGunPic
|
, _dimSPic = teslaGunPic
|
||||||
}
|
}
|
||||||
, _itParams = Arcing
|
, _itParams = teslaParams
|
||||||
{ _currentArc = Nothing
|
}
|
||||||
, _arcSize = 20
|
teslaParams :: ItemParams
|
||||||
, _arcNumber = 10
|
teslaParams = Arcing
|
||||||
, _newArcStep = defaultArcStep
|
{ _currentArc = Nothing
|
||||||
, _previousArcEffect = NoPreviousArcEffect
|
, _arcSize = 20
|
||||||
}
|
, _arcNumber = 10
|
||||||
|
, _newArcStep = defaultArcStep
|
||||||
|
, _previousArcEffect = NoPreviousArcEffect
|
||||||
}
|
}
|
||||||
teslaGunPic :: Item -> SPic
|
teslaGunPic :: Item -> SPic
|
||||||
teslaGunPic _ = noPic $ colorSH blue $
|
teslaGunPic _ = noPic $ colorSH blue $
|
||||||
@@ -228,6 +232,7 @@ lasGunDual = lasGun
|
|||||||
, _lasCycle = 0
|
, _lasCycle = 0
|
||||||
, _lasDamage = 11
|
, _lasDamage = 11
|
||||||
, _lasBeam = BeamCombine lasBeamCombine
|
, _lasBeam = BeamCombine lasBeamCombine
|
||||||
|
, _subParams = Nothing
|
||||||
}
|
}
|
||||||
& itUse .~ (ruseInstant shootDualLaser NoHammer
|
& itUse .~ (ruseInstant shootDualLaser NoHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
@@ -483,10 +488,11 @@ shootLaser it cr = instantParticles .:~ lasRayAt (_lasColor $ _itParams it) dam
|
|||||||
dam = _lasDamage $ _itParams it
|
dam = _lasDamage $ _itParams it
|
||||||
|
|
||||||
shootDualLaser :: Item -> Creature -> World -> World
|
shootDualLaser :: Item -> Creature -> World -> World
|
||||||
shootDualLaser it cr w = w
|
shootDualLaser it cr w = w'
|
||||||
& newBeams . positronBeams .:~ dualRayAt (_lasBeam $ _itParams it) w (_lasColor $ _itParams it) dam phasev posl dirl
|
& newBeams . positronBeams .:~ dualRayAt (_lasBeam $ _itParams it) itid w (_lasColor $ _itParams it) dam phasev posl dirl
|
||||||
& newBeams . electronBeams .:~ basicBeamAt w (_lasColor2 $ _itParams it) dam phasev posr dirr
|
& newBeams . electronBeams .:~ basicBeamAt itid w (_lasColor2 $ _itParams it) dam phasev posr dirr
|
||||||
where
|
where
|
||||||
|
(w',itid) = getHeldItemLoc cr w
|
||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
pos = _crPos cr +.+ aimlength *.* unitVectorAtAngle dir
|
pos = _crPos cr +.+ aimlength *.* unitVectorAtAngle dir
|
||||||
aimlength = aimingMuzzlePos cr it
|
aimlength = aimingMuzzlePos cr it
|
||||||
@@ -509,8 +515,8 @@ drawBeam bm = setLayer 1 $ pictures
|
|||||||
col = _bmColor bm
|
col = _bmColor bm
|
||||||
ps = _bmFirstPoints bm
|
ps = _bmFirstPoints bm
|
||||||
|
|
||||||
basicBeamAt :: World -> Color -> Int -> Float -> Point2 -> Float -> Beam
|
basicBeamAt :: Int -> World -> Color -> Int -> Float -> Point2 -> Float -> Beam
|
||||||
basicBeamAt w col dam phasev pos dir = Beam
|
basicBeamAt itid w col dam phasev pos dir = Beam
|
||||||
{ _bmDraw = drawBeam
|
{ _bmDraw = drawBeam
|
||||||
, _bmPos = pos
|
, _bmPos = pos
|
||||||
, _bmDir = dir
|
, _bmDir = dir
|
||||||
@@ -520,13 +526,14 @@ basicBeamAt w col dam phasev pos dir = Beam
|
|||||||
, _bmColor = col
|
, _bmColor = col
|
||||||
, _bmPoints = pos:ps
|
, _bmPoints = pos:ps
|
||||||
, _bmFirstPoints = []
|
, _bmFirstPoints = []
|
||||||
|
, _bmOrigin = Just itid
|
||||||
, _bmType = BeamCombine $ const id
|
, _bmType = BeamCombine $ const id
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
(_,ps) = reflectLaserAlong phasev [] pos (pos +.+ 800 *.* unitVectorAtAngle dir) w
|
(_,ps) = reflectLaserAlong phasev [] pos (pos +.+ 800 *.* unitVectorAtAngle dir) w
|
||||||
|
|
||||||
dualRayAt :: BeamType -> World -> Color -> Int -> Float -> Point2 -> Float -> Beam
|
dualRayAt :: BeamType -> Int -> World -> Color -> Int -> Float -> Point2 -> Float -> Beam
|
||||||
dualRayAt bt w col dam phasev pos dir = basicBeamAt w col dam phasev pos dir
|
dualRayAt bt itid w col dam phasev pos dir = basicBeamAt itid w col dam phasev pos dir
|
||||||
& bmType .~ bt
|
& bmType .~ bt
|
||||||
|
|
||||||
flameBeamCombine :: (Point2,(Point2,Point2,Beam),(Point2,Point2,Beam))
|
flameBeamCombine :: (Point2,(Point2,Point2,Beam),(Point2,Point2,Beam))
|
||||||
@@ -550,10 +557,14 @@ splitBeamCombine (p,(a,b,_),(x,y,_))
|
|||||||
teslaBeamCombine :: (Point2,(Point2,Point2,Beam),(Point2,Point2,Beam))
|
teslaBeamCombine :: (Point2,(Point2,Point2,Beam),(Point2,Point2,Beam))
|
||||||
-> World -> World
|
-> World -> World
|
||||||
teslaBeamCombine (p,(a,b,bm),(x,y,_)) w
|
teslaBeamCombine (p,(a,b,bm),(x,y,_)) w
|
||||||
= w'
|
= w' & pointToItem (_itemPositions w IM.! itid) . itParams . subParams ?~ ip
|
||||||
where
|
where
|
||||||
|
itid = fromJust $ _bmOrigin bm
|
||||||
dir = argV (normalizeV (b-.-a)+.+normalizeV (y-.-x))
|
dir = argV (normalizeV (b-.-a)+.+normalizeV (y-.-x))
|
||||||
(w',ip) = shootTeslaArc' (_beamItemParams $ _bmType bm) p dir w
|
(w',ip) = shootTeslaArc' (fromJust . _subParams $ _itParams it) p dir w
|
||||||
|
it = case getItem itid w of
|
||||||
|
Nothing -> error "tried to get item use teslaBeamCombine that doesn't exist"
|
||||||
|
Just itm -> itm
|
||||||
|
|
||||||
lasRayAt :: Color -> Int -> Float -> Point2 -> Float -> Particle
|
lasRayAt :: Color -> Int -> Float -> Point2 -> Float -> Particle
|
||||||
lasRayAt col dam phasev pos dir = LaserParticle
|
lasRayAt col dam phasev pos dir = LaserParticle
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import Dodge.Data
|
|||||||
import Dodge.Default
|
import Dodge.Default
|
||||||
import Dodge.Default.Weapon
|
import Dodge.Default.Weapon
|
||||||
import Dodge.Item.Weapon.InventoryDisplay
|
import Dodge.Item.Weapon.InventoryDisplay
|
||||||
|
import Dodge.Item.Location
|
||||||
import Dodge.SoundLogic.LoadSound
|
import Dodge.SoundLogic.LoadSound
|
||||||
import Dodge.WorldEvent.Explosion
|
import Dodge.WorldEvent.Explosion
|
||||||
import Dodge.Item.Weapon.Shell
|
import Dodge.Item.Weapon.Shell
|
||||||
@@ -294,25 +295,17 @@ remoteLauncher = launcher
|
|||||||
-- TODO consider allowing tweaking rocket speed
|
-- TODO consider allowing tweaking rocket speed
|
||||||
|
|
||||||
fireRemoteShell :: Item -> Creature -> World -> World
|
fireRemoteShell :: Item -> Creature -> World -> World
|
||||||
fireRemoteShell it cr w = setLocation
|
fireRemoteShell it cr w = set (creatures . ix cid . crInv . ix j . itUse . rUse)
|
||||||
$ set (creatures . ix cid . crInv . ix j . itUse . rUse)
|
|
||||||
(\_ _ -> explodeRemoteRocket itid i)
|
(\_ _ -> explodeRemoteRocket itid i)
|
||||||
$ set (creatures . ix cid . crInv . ix j . itName) remoteLauncherName
|
$ set (creatures . ix cid . crInv . ix j . itName) remoteLauncherName
|
||||||
$ addRemRocket w
|
$ addRemRocket w'
|
||||||
where
|
where
|
||||||
|
(w',itid) = getHeldItemLoc cr w
|
||||||
i = IM.newKey $ _props w
|
i = IM.newKey $ _props w
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
addRemRocket = makeShell it cr $ \pj ->
|
addRemRocket = makeShell it cr $ \pj ->
|
||||||
decTimMvVel pj . setRemoteScope itid pj . moveRemoteShell cid itid pj
|
decTimMvVel pj . setRemoteScope itid pj . moveRemoteShell cid itid pj
|
||||||
j = _crInvSel cr
|
j = _crInvSel cr
|
||||||
newitid = IM.newKey $ _itemPositions w
|
|
||||||
maybeitid = cr ^? crInv . ix j . itID . _Just
|
|
||||||
setLocation :: World -> World
|
|
||||||
setLocation w' = case maybeitid of
|
|
||||||
Nothing -> w' & creatures . ix cid . crInv . ix j . itID ?~ newitid
|
|
||||||
& itemPositions %~ IM.insert newitid (InInv cid j)
|
|
||||||
_ -> w'
|
|
||||||
itid = fromMaybe newitid maybeitid
|
|
||||||
|
|
||||||
moveRemoteShell :: Int -> Int -> Prop -> World -> World
|
moveRemoteShell :: Int -> Int -> Prop -> World -> World
|
||||||
moveRemoteShell cid itid pj w
|
moveRemoteShell cid itid pj w
|
||||||
@@ -372,25 +365,15 @@ explodeRemoteRocket itid pjid w = w
|
|||||||
thepj = _props w IM.! pjid
|
thepj = _props w IM.! pjid
|
||||||
|
|
||||||
fireTrackingShell :: Item -> Creature -> World -> World
|
fireTrackingShell :: Item -> Creature -> World -> World
|
||||||
fireTrackingShell it cr w = setLocation
|
fireTrackingShell it cr w = addTrackRocket w'
|
||||||
$ addTrackRocket w
|
|
||||||
where
|
where
|
||||||
cid = _crID cr
|
(w',itid) = getHeldItemLoc cr w
|
||||||
addTrackRocket = makeShell it cr $ \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj
|
addTrackRocket = makeShell it cr $ \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj
|
||||||
. pjThrust thrustdelay pj
|
. pjThrust thrustdelay pj
|
||||||
. reduceSpinBy (1-fromIntegral spindrag*2 / 200) pj
|
. reduceSpinBy (1-fromIntegral spindrag*2 / 200) pj
|
||||||
. decTimMvVel pj
|
. decTimMvVel pj
|
||||||
. pjTrack itid thrustdelay pj
|
. pjTrack itid thrustdelay pj
|
||||||
. moveShell pj
|
. moveShell pj
|
||||||
j = _crInvSel cr
|
|
||||||
newitid = IM.newKey $ _itemPositions w
|
|
||||||
maybeitid = cr ^? crInv . ix j . itID . _Just
|
|
||||||
setLocation :: World -> World
|
|
||||||
setLocation w' = case maybeitid of
|
|
||||||
Nothing -> w' & creatures . ix cid . crInv . ix j . itID ?~ newitid
|
|
||||||
& itemPositions %~ IM.insert newitid (InInv cid j)
|
|
||||||
_ -> w'
|
|
||||||
itid = fromMaybe newitid maybeitid
|
|
||||||
spinamount = _shellSpinAmount params
|
spinamount = _shellSpinAmount params
|
||||||
thrustdelay = _shellThrustDelay params
|
thrustdelay = _shellThrustDelay params
|
||||||
spindrag = _shellSpinDrag params
|
spindrag = _shellSpinDrag params
|
||||||
|
|||||||
@@ -7,16 +7,12 @@ module Dodge.Item.Weapon.Remote
|
|||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Default
|
import Dodge.Default
|
||||||
import Geometry
|
import Geometry
|
||||||
|
import Dodge.Item.Location
|
||||||
|
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
|
||||||
pointToItem :: Applicative f =>
|
|
||||||
ItemPos -> (Item -> f Item) -> World -> f World
|
|
||||||
pointToItem (InInv cid invid) = creatures . ix cid . crInv . ix invid
|
|
||||||
pointToItem (OnFloor flid) = floorItems . ix flid . flIt
|
|
||||||
|
|
||||||
retireRemoteProj :: (Item -> Creature -> World -> World)
|
retireRemoteProj :: (Item -> Creature -> World -> World)
|
||||||
-> Int -> Int -> Int -> World -> World
|
-> Int -> Int -> Int -> World -> World
|
||||||
retireRemoteProj resetFire itid 0 pjid w = w
|
retireRemoteProj resetFire itid 0 pjid w = w
|
||||||
|
|||||||
Reference in New Issue
Block a user