Make items recoverable from base type
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
module Dodge.Item.Weapon.BatteryGuns
|
||||
( lasGun
|
||||
, lasGunDual
|
||||
, lasGunWide
|
||||
, lasGunWidePulse
|
||||
, lasGunSway
|
||||
, lasGunSwing
|
||||
, lasGunFocus
|
||||
, lasGunPulse
|
||||
, lasDual
|
||||
, lasWide
|
||||
, lasWidePulse
|
||||
, lasSway
|
||||
, lasSwing
|
||||
, lasFocus
|
||||
, lasPulse
|
||||
, sparkGun
|
||||
, teslaGun
|
||||
, teslaParams
|
||||
@@ -104,8 +104,8 @@ teslaGunPic _ = noPic $ colorSH blue $
|
||||
where
|
||||
xa = 1
|
||||
xb = 9
|
||||
lasGunPulse :: Item
|
||||
lasGunPulse = lasGun
|
||||
lasPulse :: Item
|
||||
lasPulse = lasGun
|
||||
& itType . iyBase .~ LASPULSE
|
||||
& itUse . useMods .~
|
||||
[ ammoCheckI
|
||||
@@ -123,8 +123,8 @@ lasGunPulse = lasGun
|
||||
frac it = 0.5 * (1 + sin (pi * fromIntegral (_lasCycle $ _itParams it) * 0.1))
|
||||
|
||||
|
||||
lasGunWide :: Int -> Item
|
||||
lasGunWide n = lasGun
|
||||
lasWide :: Int -> Item
|
||||
lasWide n = lasGun
|
||||
& itType . iyBase .~ LASGUNWIDE n
|
||||
& itParams . lasColor .~ orange
|
||||
& itParams . lasDamage .~ 2
|
||||
@@ -143,8 +143,8 @@ lasGunWide n = lasGun
|
||||
where
|
||||
n' = 9 * n
|
||||
xs = [ 0.25 * (fromIntegral x - fromIntegral (n'-1) /2) | x <- [0..n'-1] ]
|
||||
lasGunWidePulse :: Item
|
||||
lasGunWidePulse = lasGun
|
||||
lasWidePulse :: Item
|
||||
lasWidePulse = lasGun
|
||||
& itType . iyBase .~ LASGUNWIDEPULSE
|
||||
& itParams . lasColor .~ orange
|
||||
& itParams . lasDamage .~ 2
|
||||
@@ -170,8 +170,8 @@ lasGunWidePulse = lasGun
|
||||
xs it = [ 0.25 * (fromIntegral x - fromIntegral (n'-1) /2) | x <- [0..n'-1] ]
|
||||
where
|
||||
n' = (ceiling $ (150 :: Float) * frac it) :: Int
|
||||
lasGunSway :: Item
|
||||
lasGunSway = lasGun
|
||||
lasSway :: Item
|
||||
lasSway = lasGun
|
||||
& itType . iyBase .~ LASGUNSWAY
|
||||
& itParams . lasColor .~ orange
|
||||
& itParams . lasDamage .~ 11
|
||||
@@ -192,8 +192,8 @@ lasGunSway = lasGun
|
||||
x it = [ 15 * sin (pi * fromIntegral x' * 0.05) ]
|
||||
where
|
||||
x' = _lasCycle $ _itParams it
|
||||
lasGunFocus :: Int -> Item
|
||||
lasGunFocus n = lasGunWide n
|
||||
lasFocus :: Int -> Item
|
||||
lasFocus n = lasWide n
|
||||
& itType . iyBase .~ LASGUNFOCUS n
|
||||
& itParams . lasColor .~ red
|
||||
& itUse . useMods .~
|
||||
@@ -208,8 +208,8 @@ lasGunFocus n = lasGunWide n
|
||||
n' = 9 * n
|
||||
xs = [ 0.25 * (fromIntegral x - fromIntegral (n'-1) /2) | x <- [0..n'-1] ]
|
||||
|
||||
lasGunDual :: Item
|
||||
lasGunDual = lasGun
|
||||
lasDual :: Item
|
||||
lasDual = lasGun
|
||||
& itType . iyBase .~ LASGUNDUAL
|
||||
& itParams .~ DualBeam
|
||||
{ _phaseV = 1
|
||||
@@ -233,8 +233,8 @@ lasGunDual = lasGun
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
)
|
||||
& itType . iyModules . at ModDualBeam ?~ EMPTYMODULE
|
||||
lasGunSwing :: Item
|
||||
lasGunSwing = lasGun
|
||||
lasSwing :: Item
|
||||
lasSwing = lasGun
|
||||
& itType . iyBase .~ LASGUNSWING
|
||||
& itParams . lasColor .~ orange
|
||||
& itUse . useMods .~
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
module Dodge.Item.Weapon.Booster
|
||||
( boosterGun
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
import Dodge.Zone
|
||||
import Dodge.Default.Weapon
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import Picture
|
||||
import ShapePicture
|
||||
--import Shape
|
||||
|
||||
import Data.Maybe
|
||||
import Control.Lens
|
||||
{- | Move a creature towards the mouse position, with shockwave -}
|
||||
boostPoint
|
||||
:: Float -- ^ boost amount
|
||||
-> Creature
|
||||
-> World
|
||||
-> Either Point2 Point2
|
||||
boostPoint x cr w = case mayp2 of
|
||||
Nothing -> Right p1
|
||||
Just p2 -> Left $ mvPointTowardAtSpeed r cpos $ fst p2
|
||||
where
|
||||
cpos = _crPos cr
|
||||
r = 1.5 * _crRad cr
|
||||
p1 = cpos +.+ x *.* squashNormalizeV (mouseWorldPos w -.- cpos)
|
||||
mayp2 = reflectPointWalls cpos p1 $ wallsAlongLine cpos p1 w
|
||||
|
||||
boostSelfL
|
||||
:: Float -- ^ boost amount
|
||||
-> Item
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
boostSelfL x itm cr w = case boostPoint x cr w of
|
||||
Left p -> crEff p (itConsumption . laLoaded .~ 0)
|
||||
Right p -> crEff p (itConsumption . laLoaded -~ 1)
|
||||
where
|
||||
invid = fromJust $ _itInvPos itm
|
||||
cid = _crID cr
|
||||
cpos = _crPos cr
|
||||
r = _crRad cr
|
||||
pid = fromMaybe (IM.newKey $ _props w)
|
||||
(cr ^? crInv . ix invid . itAttachment . itInt)
|
||||
crEff p ammoEff = addBoostShockwave pid p (r *.* normalizeV (p -.- cpos)) w
|
||||
& creatures . ix cid %~
|
||||
(crPos .~ p)
|
||||
. (crInv . ix invid %~
|
||||
ammoEff
|
||||
. (itEffect . ieCounter .~ 1)
|
||||
. (itAttachment .~ ItInt pid)
|
||||
)
|
||||
|
||||
addBoostShockwave
|
||||
:: Int
|
||||
-> Point2
|
||||
-> Point2
|
||||
-> World
|
||||
-> World
|
||||
addBoostShockwave pjid p v w = w & props %~
|
||||
IM.insertWith f pjid thePJ
|
||||
where
|
||||
thePJ = LinearShockwave
|
||||
{ _prDraw = drawBoostShockwave
|
||||
, _prPos = p
|
||||
, _pjID = pjid
|
||||
, _pjUpdate = updateLinearShockwave
|
||||
, _pjPoints = [(p,v)]
|
||||
, _pjTimer = maxT
|
||||
}
|
||||
f newVal oldVal = newVal & pjPoints %~ (++ _pjPoints oldVal)
|
||||
|
||||
updateLinearShockwave :: Prop -> World -> World
|
||||
updateLinearShockwave pj w
|
||||
| t < 1 = w & props %~ IM.delete pjid
|
||||
| otherwise = w & props . ix (_pjID pj) . pjTimer -~ 1
|
||||
where
|
||||
pjid = _pjID pj
|
||||
t = _pjTimer pj
|
||||
|
||||
drawBoostShockwave :: Prop -> SPic
|
||||
drawBoostShockwave pj = (,) mempty $ setLayer BloomLayer $ setDepth 20 $ pictures $
|
||||
theArc ++
|
||||
[ lineCol $ zip (reverse lps) $ map (`withAlpha` white) [0,0.05..]
|
||||
, lineCol $ zip (reverse rps) $ map (`withAlpha` white) [0,0.05..]
|
||||
]
|
||||
where
|
||||
-- drawing half a circle here is not perfect, a slightly smaller arc would fit
|
||||
-- better, but this depends upon the angle formed by the following lines, which
|
||||
-- is not fixed (it varies with speed and angle of last turn)
|
||||
theArc = maybeToList $ do
|
||||
(hp,hv) <- safeHead pvs
|
||||
r <- safeHead xs
|
||||
return $ color (snd $ last lpairs) $ uncurryV translate hp
|
||||
$ arc (argV hv - pi/2) (argV hv + pi/2) $ r * magV hv
|
||||
cols = map (`withAlpha` white) [0,0.05..]
|
||||
lpairs = zip (reverse lps) cols
|
||||
pvs = _pjPoints pj
|
||||
t = _pjTimer pj
|
||||
xs = take t $ drop (20 - t) [1,1.2..]
|
||||
lps = zipWith f pvs xs
|
||||
rps = zipWith g pvs xs
|
||||
f (p,v) x = p +.+ x *.* vNormal v
|
||||
g (p,v) x = p -.- x *.* vNormal v
|
||||
|
||||
maxT :: Int
|
||||
maxT = 20
|
||||
|
||||
boosterGun :: Item
|
||||
boosterGun = defaultGun
|
||||
{ _itInvColor = cyan
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _laMax = 100
|
||||
, _laLoaded = 100
|
||||
, _laReloadTime = 20
|
||||
}
|
||||
, _itUse = luseInstantNoH $ boostSelfL 10
|
||||
, _itEffect = resetAttachmentID
|
||||
}
|
||||
& itType . iyBase .~ BOOSTER
|
||||
resetAttachmentID :: ItEffect
|
||||
resetAttachmentID = ItInvEffect f 0
|
||||
where
|
||||
f itm cr w
|
||||
| _ieCounter iteff < 0 = w & pointToIt . itAttachment .~ NoItAttachment
|
||||
| otherwise = w & pointToIt . itEffect . ieCounter -~ 1
|
||||
where
|
||||
iteff = _itEffect itm
|
||||
invid = fromJust $ _itInvPos itm
|
||||
pointToIt = creatures . ix (_crID cr) . crInv . ix invid
|
||||
@@ -18,8 +18,8 @@ import Control.Lens
|
||||
--import Control.Monad.State
|
||||
--import System.Random
|
||||
|
||||
lasDrones :: Item
|
||||
lasDrones = defaultGun
|
||||
droneLauncher :: Item
|
||||
droneLauncher = defaultGun
|
||||
{ _itConsumption = defaultAmmo
|
||||
{ _laType = DroneAmmo { _amString = "LASDRONE" }
|
||||
, _laMax = 2
|
||||
|
||||
Reference in New Issue
Block a user