Defunction-ify item modules, requires more cleanup

This commit is contained in:
2022-06-08 12:28:11 +01:00
parent d91a53f76c
commit bcbfd7d2fa
48 changed files with 762 additions and 740 deletions
+2 -2
View File
@@ -14,13 +14,13 @@ import qualified Data.IntMap.Strict as IM
medkit :: Int -> Item
medkit i = defaultConsumable
{ _itName = "MEDKIT" ++ show i
, _itUse = ConsumeUse
{ _itUse = ConsumeUse
{_cUse = \_ cr w -> w & creatures . ix (_crID cr) . crHP +~ i
}
, _itEquipPict = pictureWeaponAim $ const $ (,) emptySH $ color blue $ circleSolid 3
, _itID = Nothing
}
& itType . iyBase .~ MEDKIT i
heal25 :: Int -> World -> Maybe World
heal25 = heal 25
+4 -5
View File
@@ -9,19 +9,18 @@ import Color
--import Geometry
import Control.Lens
makeTypeCraftNum :: Int -> CombineType -> Item
makeTypeCraftNum :: Int -> ItemBaseType -> Item
makeTypeCraftNum i ct = defaultCraftable
{ _itInvSize = 0.5
, _itCurseStatus = Uncursed
, _itName = show ct
, _itType = ct
, _itConsumption = ItemItselfConsumable i
}
& itType . iyBase .~ ct
makeTypeCraft :: CombineType -> Item
makeTypeCraft :: ItemBaseType -> Item
makeTypeCraft = makeTypeCraftNum 1
makeModule :: CombineType -> Item
makeModule :: ItemBaseType -> Item
makeModule ct = makeTypeCraft ct
& itInvSize .~ 1
& itInvColor .~ chartreuse
+23 -38
View File
@@ -22,14 +22,13 @@ import LensHelp
import Data.Maybe
magShield :: Item
magShield = defaultEquipment
{ _itType = MAGSHIELD
, _itName = "MAGSHIELD"
, _itEquipPict = \_ _ -> (,) emptySH blank
{ _itEquipPict = \_ _ -> (,) emptySH blank
, _itID = Nothing
, _itAttachment = ItMInt Nothing
}
& itUse . eqEq . eqUse .~ useMagShield
& itUse . eqEq . eqSite .~ GoesOnWrist
& itType . iyBase .~ MAGSHIELD
useMagShield :: Item -> Creature -> World -> World
useMagShield it cr w = w & magnets . at mgid ?~ themagnet
where
@@ -46,37 +45,34 @@ useMagShield it cr w = w & magnets . at mgid ?~ themagnet
flameShield :: Item
flameShield = defaultEquipment
{ _itType = FLAMESHIELD
, _itName = "FLAMESHIELD"
, _itEquipPict = \cr _ -> (,) emptySH $ setDepth 20 $ pictures [color cyan $ circle (_crRad cr+2)]
{ _itEquipPict = \cr _ -> (,) emptySH $ setDepth 20 $ pictures [color cyan $ circle (_crRad cr+2)]
, _itID = Nothing
} & itUse . eqEq . eqSite .~ GoesOnChest
& itType . iyBase .~ FLAMESHIELD
{- | Slows you down, blocks forward projectiles. -}
frontArmour :: Item
frontArmour = defaultEquipment
{ _itType = FRONTARMOUR
, _itName = "FARMOUR"
, _itEquipPict = pictureOnEquip (emptySH , setDepth 20 $ pictures
{ _itEquipPict = pictureOnEquip (emptySH , setDepth 20 $ pictures
[color thecol $ thickArc 0 (pi/2) 10 5
,color thecol $ thickArc (3*pi/2) (2*pi) 10 5
])
, _itID = Nothing
}
& itUse . eqEq . eqSite .~ GoesOnChest
& itType . iyBase .~ FRONTARMOUR
where
thecol = yellow -- (greyN 0.1)
wristArmour :: Item
wristArmour = defaultEquipment
{ _itType = WRISTARMOUR
, _itName = "WRISTARMOUR"
, _itEquipPict = spicForWrist mempty
{ _itEquipPict = spicForWrist mempty
, _itID = Nothing
}
& itUse . eqEq . eqSite .~ GoesOnWrist
& itUse . eqEq . eqOnEquip .~ onEquipWristShield
& itUse . eqEq . eqUse .~ setWristShieldPos
& itUse . eqEq . eqOnRemove .~ onRemoveWristShield
& itType . iyBase .~ WRISTARMOUR
onEquipWristShield :: Item -> Creature -> World -> World
onEquipWristShield itm cr w = w
@@ -114,8 +110,6 @@ flatShield = defaultEquipment
, _itEffect = effectOnOffHeld createShieldWall removeShieldWall
-- the above seems to work, but I am not sure why: it may break on edge
-- cases
, _itName = "FLATSHIELD"
, _itType = FLATSHIELD
, _itUse = RightUse
{ _rUse = \_ _ -> id
, _useDelay = NoDelay
@@ -135,6 +129,7 @@ flatShield = defaultEquipment
,"*" ++ replicate 13 ' ' ++ "*"
]
}
& itType . iyBase .~ FLATSHIELD
flatShieldEquipSPic :: Item -> SPic
flatShieldEquipSPic _ =
( colorSH yellow $ upperPrismPoly 10 (rectWH 2 10)
@@ -215,29 +210,25 @@ effectOnOffHeld f f' = ItInvEffectID
{- | Increases speed, reduces friction, cannot only move forwards. -}
jetPack :: Item
jetPack = defaultEquipment
{ _itType = JETPACK
, _itName = "JETPACK"
, _itEquipPict = \_ _ -> (,) emptySH $ setDepth 20
{ _itEquipPict = \_ _ -> (,) emptySH $ setDepth 20
$ pictures [color yellow $ polygon $ rectNSEW 5 (-5) (-3) (-11) ]
, _itEffect = NoItEffect
, _itID = Nothing
} & itUse . eqEq . eqSite .~ GoesOnBack
& itType . iyBase .~ JETPACK
brainHat :: Item
brainHat = defaultEquipment
{ _itType = BRAINHAT
, _itName = "BRAINHAT"
, _itEquipPict = pictureOnEquip (noPic $ colorSH yellow $ upperPrismPoly 3 $ rectWH 4 4)
{ _itEquipPict = pictureOnEquip (noPic $ colorSH yellow $ upperPrismPoly 3 $ rectWH 4 4)
, _itEffect = NoItEffect
, _itID = Nothing
}
& itUse . eqEq . eqSite .~ GoesOnHead
& itType . iyBase .~ BRAINHAT
headLamp1 :: Item
headLamp1 = defaultEquipment
{ _itType = HEADLAMP
, _itName = "HEADLAMP1"
, _itEquipPict = pictureOnEquip (noPic $ colorSH yellow $
{ _itEquipPict = pictureOnEquip (noPic $ colorSH yellow $
translateSHf 5 2 (upperPrismPoly 8 $ rectWH 4 1)
<> translateSHf 5 (-2) (upperPrismPoly 8 $ rectWH 4 1)
-- <> (upperPrismPoly 3 $ rectWH 4 4)
@@ -247,16 +238,16 @@ headLamp1 = defaultEquipment
}
& itUse . eqEq . eqUse .~ createHeadLamp
& itUse . eqEq . eqSite .~ GoesOnHead
& itType . iyBase .~ HEADLAMP1
headLamp :: Item
headLamp = defaultEquipment
{ _itType = HEADLAMP
, _itName = "HEADLAMP"
, _itEquipPict = pictureOnEquip (noPic headLampShape)
{ _itEquipPict = pictureOnEquip (noPic headLampShape)
, _itEffect = NoItEffect
, _itID = Nothing
}
& itUse . eqEq . eqUse .~ createHeadLamp
& itUse . eqEq . eqSite .~ GoesOnHead
& itType . iyBase .~ HEADLAMP
headLampShape :: Shape
headLampShape = colorSH yellow $
@@ -271,34 +262,28 @@ createHeadLamp _ cr = tempLightSources .:~ tlsTimeRadColPos 1 200 0.7
powerLegs :: Item
powerLegs = defaultEquipment
{ _itType = POWERLEGS
, _itName = "POWERLEGS"
, _itEquipPict = pictureOnEquip (noPic $ translateSH (V3 0 4 0) $ colorSH yellow $ upperPrismPoly 3 $ rectWH 2 2)
{ _itEquipPict = pictureOnEquip (noPic $ translateSH (V3 0 4 0) $ colorSH yellow $ upperPrismPoly 3 $ rectWH 2 2)
, _itEffect = NoItEffect
, _itID = Nothing
}
& itUse . eqEq . eqSite .~ GoesOnLegs
& itType . iyBase .~ POWERLEGS
speedLegs :: Item
speedLegs = powerLegs
{ _itType = SPEEDLEGS
, _itName = "SPEEDLEGS"
}
& itType . iyBase .~ SPEEDLEGS
jumpLegs :: Item
jumpLegs = powerLegs
{ _itType = JUMPLEGS
, _itName = "JUMPLEGS"
}
& itType . iyBase .~ JUMPLEGS
wristInvisibility :: Item
wristInvisibility = defaultEquipment
{ _itType = INVISIBILITYEQUIPMENT GoesOnWrist
, _itName = "WRISTINVISIBILITY"
, _itEquipPict = shapeForWrist (colorSH chartreuse $ upperPrismPoly 3 $ rectWH 2 2)
{ _itEquipPict = shapeForWrist (colorSH chartreuse $ upperPrismPoly 3 $ rectWH 2 2)
, _itID = Nothing
}
& itUse . eqEq . eqSite .~ GoesOnWrist
& itUse . eqEq . eqOnEquip .~ overCID (crCamouflage .~ Invisible)
& itUse . eqEq . eqOnRemove .~ overCID (crCamouflage .~ FullyVisible)
& itType . iyBase .~ INVISIBILITYEQUIPMENT GoesOnWrist
overCID :: (Creature -> Creature) -> Item -> Creature -> World -> World
overCID f _ cr = creatures . ix (_crID cr) %~ f
+5 -7
View File
@@ -3,19 +3,19 @@ import Dodge.Data
import Dodge.Default
import Picture
import Geometry.Data
import LensHelp
--import ShapePicture
import Shape
keyCard :: Int -> Item
keyCard n = defaultEquipment
{ _itType = KEYCARD n
, _itName = "KEYCARD-"++show n
, _itEquipPict = \_ _ -> (,) emptySH $ setDepth 0 $ translate (-5) (-5) $ rotate (pi/2.5) keyPic
{ _itEquipPict = \_ _ -> (,) emptySH $ setDepth 0 $ translate (-5) (-5) $ rotate (pi/2.5) keyPic
, _itEffect = NoItEffect
, _itID = Nothing
-- , _itZoom = defaultItZoom
, _itInvColor = aquamarine
, _itInvDisplay = (:[]) . _itName
}
& itType . iyBase .~ KEYCARD n
keyPic :: Picture
keyPic = color green $
pictures [translate (-4) 0 $ thickCircle 4 2
@@ -25,9 +25,7 @@ keyPic = color green $
latchkey :: Int -> Item
latchkey n = defaultEquipment
{ _itType = NOTDEFINED
, _itName = "KEY "++show n
, _itEquipPict = \_ _ -> (,) emptySH $ setDepth 0 $ translate (-5) (-5) $ rotate (pi/2.5) latchkeyPic
{ _itEquipPict = \_ _ -> (,) emptySH $ setDepth 0 $ translate (-5) (-5) $ rotate (pi/2.5) latchkeyPic
, _itEffect = NoItEffect
, _itID = Nothing
-- , _itZoom = defaultItZoom
+24 -175
View File
@@ -17,6 +17,8 @@ module Dodge.Item.Weapon.BatteryGuns
, splitBeamCombine
) where
import Dodge.Data
import Dodge.Tesla
import Dodge.Beam
import Dodge.Item.Weapon.LaserPath
import Dodge.Item.Location
import Dodge.Creature.HandPos
@@ -52,28 +54,25 @@ import Control.Monad.State
defaultBatteryGun :: Item
defaultBatteryGun = defaultGun
& itModules .~ batteryModules
& itType . iyModules .~ batteryModules
batteryModules :: M.Map ModuleSlot ItemModule
batteryModules :: M.Map ModuleSlot ItemModuleType
batteryModules = M.fromList
[(ModBattery, DefaultModule)
,(ModTeleport, DefaultModule)
[(ModBattery, EMPTYMODULE)
,(ModTeleport, EMPTYMODULE)
]
defaultAutoBatteryGun :: Item
defaultAutoBatteryGun = defaultAutoGun
& itModules .~ batteryModules
& itType . iyModules .~ batteryModules
sparkGun :: Item
sparkGun = teslaGun
& itName .~ "SPARKGUN"
& itType .~ SPARKGUN
& itType . iyBase .~ SPARKGUN
& itParams . arcSize .~ 10
teslaGun :: Item
teslaGun = defaultBatteryGun
{ _itName = "TESLA"
, _itType = TESLAGUN
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laMax = 200
, _laLoaded = 200
, _laReloadTime = 80
@@ -97,14 +96,7 @@ teslaGun = defaultBatteryGun
}
, _itParams = teslaParams
}
teslaParams :: ItemParams
teslaParams = Arcing
{ _currentArc = Nothing
, _arcSize = 20
, _arcNumber = 10
, _newArcStep = defaultArcStep
, _previousArcEffect = NoPreviousArcEffect
}
& itType . iyBase .~ TESLAGUN
teslaGunPic :: Item -> SPic
teslaGunPic _ = noPic $ colorSH blue $
upperPrismPoly 5 (rectNESW xb 8 xa 0)
@@ -114,8 +106,7 @@ teslaGunPic _ = noPic $ colorSH blue $
xb = 9
lasGunPulse :: Item
lasGunPulse = lasGun
& itName .~ "PULSELAS"
& itType .~ LASPULSE
& itType . iyBase .~ LASPULSE
& itUse . useMods .~
[ ammoCheckI
, withItem $ \it -> withTempLight 1 (100 * frac it) (xyzV4 (_lasColor $ _itParams it))
@@ -134,8 +125,7 @@ lasGunPulse = lasGun
lasGunWide :: Int -> Item
lasGunWide n = lasGun
& itName .~ "PARALELLAS"++show n
& itType .~ LASGUNWIDE n
& itType . iyBase .~ LASGUNWIDE n
& itParams . lasColor .~ orange
& itParams . lasDamage .~ 2
& itUse .~ ( ruseInstant shootLaser NoHammer
@@ -155,8 +145,7 @@ lasGunWide n = lasGun
xs = [ 0.25 * (fromIntegral x - fromIntegral (n'-1) /2) | x <- [0..n'-1] ]
lasGunWidePulse :: Item
lasGunWidePulse = lasGun
& itName .~ "LASWIDEPULSE"
& itType .~ LASGUNWIDEPULSE
& itType . iyBase .~ LASGUNWIDEPULSE
& itParams . lasColor .~ orange
& itParams . lasDamage .~ 2
& itUse .~ ( ruseInstant shootLaser NoHammer
@@ -183,8 +172,7 @@ lasGunWidePulse = lasGun
n' = (ceiling $ (150 :: Float) * frac it) :: Int
lasGunSway :: Item
lasGunSway = lasGun
& itName .~ "SWAYLAS"
& itType .~ LASGUNSWAY
& itType . iyBase .~ LASGUNSWAY
& itParams . lasColor .~ orange
& itParams . lasDamage .~ 11
& itUse .~ ( ruseInstant shootLaser NoHammer
@@ -206,8 +194,7 @@ lasGunSway = lasGun
x' = _lasCycle $ _itParams it
lasGunFocus :: Int -> Item
lasGunFocus n = lasGunWide n
& itName .~ "FOCALAS"++show n
& itType .~ LASGUNFOCUS n
& itType . iyBase .~ LASGUNFOCUS n
& itParams . lasColor .~ red
& itUse . useMods .~
[ ammoCheckI
@@ -223,8 +210,7 @@ lasGunFocus n = lasGunWide n
lasGunDual :: Item
lasGunDual = lasGun
& itName .~ "DUALAS"
& itType .~ LASGUNDUAL
& itType . iyBase .~ LASGUNDUAL
& itParams .~ DualBeam
{ _phaseV = 1
, _lasColor = orange
@@ -246,11 +232,10 @@ lasGunDual = lasGun
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
)
& itModules . at ModDualBeam ?~ DefaultModule
& itType . iyModules . at ModDualBeam ?~ EMPTYMODULE
lasGunSwing :: Item
lasGunSwing = lasGun
& itName .~ "SWINGLAS"
& itType .~ LASGUNSWING
& itType . iyBase .~ LASGUNSWING
& itParams . lasColor .~ orange
& itUse . useMods .~
[ ammoCheckI
@@ -268,9 +253,7 @@ lasGunSwing = lasGun
x' = _lasCycle $ _itParams it
lasGun :: Item
lasGun = defaultAutoBatteryGun
{ _itName = "LASGUN"
, _itType = LASGUN
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laMax = 200
, _laLoaded = 200
, _laReloadTime = 80
@@ -303,6 +286,8 @@ lasGun = defaultAutoBatteryGun
, _dimSPic = lasGunPic
}
}
& itType . iyBase .~ LASGUN
lasGunPic :: Item -> SPic
lasGunPic it =
( colorSH blue $
@@ -335,9 +320,7 @@ lasGunTweak = TweakParam
tractorGun :: Item
tractorGun = lasGun
{ _itName = "TRACTORGUN"
, _itType = TRACTORGUN
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laMax = 10000
, _laLoaded = 10000
, _laReloadTime = 40
@@ -360,6 +343,8 @@ tractorGun = lasGun
, _tweakSel = 0
}
}
& itType . iyBase .~ TRACTORGUN
tractorGunTweak :: TweakParam
tractorGunTweak = TweakParam
{ _doTweak = thetweak
@@ -400,84 +385,6 @@ shootTeslaArc it cr w = w'
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
dir = _crDir cr
shootTeslaArc' :: ItemParams -> Point2 -> Float -> World -> (World,ItemParams)
shootTeslaArc' ip pos dir w =
(w & randGen .~ g
& instantParticles .:~ aTeslaArcAt col newarc
, ip & currentArc ?~ newarc
)
where
(col,g) = takeOne [white,azure,blue,cyan] & runState $ _randGen w
newarc = createArc ip w pos dir & evalState $ _randGen w
createArc :: ItemParams
-> World
-> Point2
-> Float
-> State StdGen [ArcStep]
createArc arcparams@Arcing{_currentArc = Nothing} w p dir = createNewArc arcparams w p dir
createArc arcparams w p dir = updateArc arcparams w p dir
createNewArc :: ItemParams -> World -> Point2 -> Float
-> State StdGen [ArcStep]
createNewArc arcparams w p dir = take (_arcNumber arcparams)
<$> unfoldrMID (_newArcStep arcparams arcparams w) (ArcStep p dir Nothing)
defaultArcStep :: RandomGen g => ItemParams -> World -> ArcStep
-> State g (Maybe ArcStep)
defaultArcStep _ _ (ArcStep _ _ (Just _)) = return Nothing
defaultArcStep itparams w (ArcStep p dir _) = do
let csize = _arcSize itparams
--rot <- takeOne [pi/4,negate pi/4]
rot <- takeOne [0]
let center = csize *.* rotateV rot (unitVectorAtAngle dir) +.+ p
newp <- (center +.+) <$> randInCirc csize
let mcr = listToMaybe
. sortOn (dist center . _crPos)
. filter (\cr -> dist center (_crPos cr) < csize)
. IM.elems
$ _creatures w
wlsnearpoint = wallsNearPoint p w
mwl = listToMaybe
. sortOn (dist p . fst)
. mapMaybe (\ q -> collidePointWallsWall p (center +.+ q) wlsnearpoint)
$ polyCirc 6 csize
f (q,wl) = ArcStep q dir (Just $ Right wl)
g cr = ArcStep (_crPos cr +.+ csize *.* unitVectorAtAngle dir) dir (Just $ Left cr)
return . listToMaybe . sortOn (dist p . (^. asPos))
$ ArcStep newp dir Nothing : catMaybes [fmap f mwl,fmap g mcr]
updateArc :: ItemParams
-> World
-> Point2
-> Float
-> State StdGen [ArcStep]
updateArc ip w p dir = take (_arcNumber ip) <$> zipArcs ip w (ArcStep p dir Nothing) carc
where
carc = tail $ fromJust $ _currentArc ip
zipArcs :: ItemParams
-> World
-> ArcStep
-> [ArcStep]
-> State StdGen [ArcStep]
zipArcs ip w x (y:ys) = (x :) <$> do
defaultnext <- _newArcStep ip ip w x
case defaultnext of
Nothing -> return []
Just z@(ArcStep _ _ (Just _)) -> return [z]
Just z -> do
p <- randInCirc 5
let csize = _arcSize ip
center = _asPos x +.+ csize *.* unitVectorAtAngle (_asDir x)
newp = _asPos y +.+ p
--newdir = argV $ newp -.- _asPos x
newdir = _asDir x
if dist newp center < csize
then zipArcs ip w (y & asPos .~ newp & asDir .~ newdir) ys
else zipArcs ip w z ys
zipArcs ip w y _ = createNewArc ip w (_asPos y) (_asDir y)
shootLaser :: Item -> Creature -> World -> World
shootLaser it cr = instantParticles .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
@@ -537,64 +444,6 @@ dualRayAt :: BeamType -> Int -> World -> Color -> Int -> Float -> Point2 -> Floa
dualRayAt bt itid w col dam phasev pos dir = basicBeamAt itid w col dam phasev pos dir
& bmType .~ bt
flameBeamCombine :: (Point2,(Point2,Point2,Beam),(Point2,Point2,Beam))
-> World -> World
flameBeamCombine (p,(a,b,_),(x,y,_))
= makeFlame p (2 *.* normalizeV (normalizeV (b-.-a)+.+normalizeV (y-.-x)))
lasBeamCombine :: (Point2,(Point2,Point2,Beam),(Point2,Point2,Beam))
-> World -> World
lasBeamCombine (p,(a,b,_),(x,y,_))
= instantParticles .:~ lasRayAt yellow 11 1 p (argV (normalizeV (b-.-a)+.+normalizeV (y-.-x)))
splitBeamCombine :: (Point2,(Point2,Point2,Beam),(Point2,Point2,Beam))
-> World -> World
splitBeamCombine (p,(a,b,_),(x,y,_))
= (instantParticles .:~ lasRayAt yellow 11 1 p (dir+0.5*pi))
. (instantParticles .:~ lasRayAt yellow 11 1 p (dir-0.5*pi))
where
dir = argV (normalizeV (b-.-a)+.+normalizeV (y-.-x))
teslaBeamCombine :: (Point2,(Point2,Point2,Beam),(Point2,Point2,Beam))
-> World -> World
teslaBeamCombine (p,(a,b,bm),(x,y,_)) w
= w' & pointToItem (_itemPositions w IM.! itid) . itParams . subParams ?~ ip
where
itid = fromJust $ _bmOrigin bm
dir = argV (normalizeV (b-.-a)+.+normalizeV (y-.-x))
(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 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
-> Float
-> World
-> Particle
-> (World, Maybe Particle)
mvLaser phasev pos dir w pt
= ( 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 BloomNoZWrite $ pictures
[ 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
where
+2 -3
View File
@@ -110,9 +110,7 @@ maxT = 20
boosterGun :: Item
boosterGun = defaultGun
{ _itName = "BOOSTER"
, _itType = BOOSTER
, _itInvColor = cyan
{ _itInvColor = cyan
, _itConsumption = defaultAmmo
{ _laMax = 100
, _laLoaded = 100
@@ -121,6 +119,7 @@ boosterGun = defaultGun
, _itUse = luseInstantNoH $ boostSelfL 10
, _itEffect = resetAttachmentID
}
& itType . iyBase .~ BOOSTER
resetAttachmentID :: ItEffect
resetAttachmentID = ItInvEffect f 0
where
+15 -25
View File
@@ -41,9 +41,7 @@ import Data.Maybe
bangCane :: Item
bangCane = defaultGun
{ _itName = "BANGCANE"
, _itType = BANGCANE
, _itParams = BulletShooter
{ _itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
@@ -82,11 +80,10 @@ bangCane = defaultGun
<> makeSingleClipAt (V3 5 0 3) it
}
} & itUse . useAim . aimStance .~ OneHand
& itType . iyBase .~ BANGCANE
bangCaneX :: Int -> Item
bangCaneX i = bangCane
{ _itName = "BANGCANEx"++show i
, _itType = BANGCANEX i
, _itUse = ruseAmmoParamsRate 6 upHammer
{ _itUse = ruseAmmoParamsRate 6 upHammer
[ ammoHammerCheck
, useTimeCheck
, withSoundItemChoiceStart caneStickSoundChoice
@@ -121,6 +118,7 @@ bangCaneX i = bangCane
,_brlInaccuracy = 0.1
}
& itParams . torqueAfter .~ 0.48 + 0.2 * fromIntegral i
& itType . iyBase .~ BANGCANEX i
caneStickSoundChoice :: Item -> SoundID
caneStickSoundChoice it
| _laLoaded (_itConsumption it) < 2 = tap3S
@@ -146,8 +144,7 @@ rifle = bangCane
}
}
& itUse . useAim . aimStance .~ TwoHandTwist
& itName .~ "RIFLE"
& itType .~ RIFLE
& itType . iyBase .~ RIFLE
& itConsumption . laMax .~ 1
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
@@ -155,9 +152,8 @@ rifle = bangCane
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 2}
repeater :: Item
repeater = rifle
& itModules . at ModRifleMag ?~ DefaultModule
& itName .~ "REPEATER"
& itType .~ REPEATER
& itType . iyModules . at ModRifleMag ?~ EMPTYMODULE
& itType . iyBase .~ REPEATER
& itConsumption . laReloadType .~ ActiveClear
& itConsumption . laReloadTime .~ 80
& itConsumption . laMax .~ 15
@@ -173,15 +169,13 @@ baseRifleShape = colorSH red $ upperPrismPoly 3 $ rectXH 25 2
autoRifle :: Item
autoRifle = repeater
& itName .~ "AUTORIFLE"
& itType .~ AUTORIFLE
& itType . iyBase .~ AUTORIFLE
& itUse . useMods %~ ((ammoCheckI :) . tail)
& itModules . at ModAutoMag ?~ DefaultModule
& itType . iyModules . at ModAutoMag ?~ EMPTYMODULE
-- & itUse . useDelay . rateMax .~ 6
burstRifle :: Item
burstRifle = repeater
& itName .~ "BURSTRIFLE"
& itType .~ BURSTRIFLE
& itType . iyBase .~ BURSTRIFLE
& itParams . gunBarrels . brlInaccuracy .~ 0.05
& itUse . useDelay . rateMax .~ 18
& itUse . useMods .~
@@ -198,8 +192,7 @@ burstRifle = repeater
]
fastBurstRifle :: Item
fastBurstRifle = repeater
& itName .~ "FASTBURSTRIFLE"
& itType .~ FASTBURSTRIFLE
& itType . iyBase .~ FASTBURSTRIFLE
& itParams . gunBarrels . brlInaccuracy .~ 0.06
& itUse . useDelay . rateMax .~ 18
& itUse . useMods .~
@@ -216,9 +209,8 @@ fastBurstRifle = repeater
]
completeBurstRifle :: Item
completeBurstRifle = repeater
& itName .~ "COMPLETEBURSTRIFLE"
& itType .~ COMPLETEBURSTRIFLE
& itModules . at ModRifleMag .~ Nothing
& itType . iyBase .~ COMPLETEBURSTRIFLE
& itType . iyModules . at ModRifleMag .~ Nothing
& itParams . gunBarrels . brlInaccuracy .~ 0.1
& itUse . useDelay . rateMax .~ 28
& itUse . useMods .~
@@ -262,9 +254,7 @@ miniGunUse i = ruseInstant (useAmmoParams $ Just 1) NoHammer $
miniGunX :: Int -> Item
miniGunX i = defaultAutoGun
{ _itName = "MINIGUN-" ++ show i
, _itType = MINIGUNX i
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 1500
, _laLoaded = 1500
@@ -308,7 +298,7 @@ miniGunX i = defaultAutoGun
}
}
& itDimension . dimPortage . muzPos .~ 40
& itType . iyBase .~ MINIGUNX i
miniGunXPictItem :: Int -> Item -> SPic
miniGunXPictItem i it = miniGunXPict i spin (_laLoaded $ _itConsumption it)
where
+8 -13
View File
@@ -7,6 +7,7 @@ module Dodge.Item.Weapon.BulletGun.Rod
, machineGun
) where
import Dodge.Data
import Dodge.Default.Item
import Dodge.Item.Weapon.BulletGun.Clip
import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Particle.HitEffect
@@ -41,9 +42,7 @@ import Data.Maybe
bangRod :: Item
bangRod = defaultGun
{ _itName = "BANGROD"
, _itType = BANGROD
, _itParams = BulletShooter
{ _itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 1
, _bore = 2
@@ -79,6 +78,7 @@ bangRod = defaultGun
, _laReloadTime = 20
}
}
& itType . iyBase .~ BANGROD
& itUse . useAim . aimWeight .~ 8
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ OneHand
@@ -90,8 +90,7 @@ baseAMRShape :: Shape
baseAMRShape = colorSH orange $ upperPrismPoly 3 $ rectXH 30 2
elephantGun :: Item
elephantGun = bangRod
& itName .~ "ELEPHANTGUN"
& itType .~ ELEPHANTGUN
& itType . iyBase .~ ELEPHANTGUN
& itUse . useAim . aimStance .~ TwoHandTwist
& itParams . gunBarrels .~ SingleBarrel 0.05
& itDimension . dimSPic .~ (\it -> noPic $ baseAMRShape
@@ -112,8 +111,7 @@ elephantGun = bangRod
& itParams . torqueAfter .~ 0.1
amr :: Item
amr = elephantGun
& itName .~ "ANTIMATERIELRIFLE"
& itType .~ AMR
& itType . iyBase .~ AMR
& itConsumption . laMax .~ 15
& itDimension . dimSPic .~ (\it -> noPic $ baseAMRShape
<> makeTinClipAt 0 (V3 10 (-2) 0) it
@@ -121,14 +119,12 @@ amr = elephantGun
autoAmr :: Item
autoAmr = amr
& itName .~ "AUTOAMR"
& itType .~ AUTOAMR
& itType . iyBase .~ AUTOAMR
& itUse . useMods %~ ((ammoCheckI :) . tail)
sniperRifle :: Item
sniperRifle = elephantGun
& itName .~ "SNIPERRIFLE"
& itType .~ SNIPERRIFLE
& itType . iyBase .~ SNIPERRIFLE
& itParams . gunBarrels .~ SingleBarrel 0
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5}
& itUse . heldScroll .~ zoomLongGun
@@ -137,8 +133,7 @@ sniperRifle = elephantGun
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1}
machineGun :: Item
machineGun = bangRod
& itName .~ "MACHINEGUN"
& itType .~ MACHINEGUN
& itType . iyBase .~ MACHINEGUN
& itUse .~ (ruseAmmoParamsRate 25 NoHammer
[ ammoCheckI
, rateIncAB (torqueBeforeAtLeast 0.1 0.1) withTorqueAfter
+13 -26
View File
@@ -41,11 +41,7 @@ bangStickSoundChoice it
bangStick :: Int -> Item
bangStick i = defaultGun
{ _itName = case i of
1 -> "BANGSTICK"
_ -> "BANGSTICKx"++ show i
, _itType = BANGSTICK i
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = i
, _laReloadTime = 10
@@ -62,8 +58,6 @@ bangStick i = defaultGun
-- , applyInaccuracy
, withRecoil
]
, _itID = Nothing
, _itInvColor = white
, _itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 0.8
@@ -89,6 +83,7 @@ bangStick i = defaultGun
<> stickClip it
}
}
& itType . iyBase .~ BANGSTICK i
baseStickShapeX :: Int -> Shape
baseStickShapeX i = foldMap f [0..i-1]
where
@@ -115,9 +110,7 @@ stickClip it = case it ^? itConsumption . laLoaded of
revolver :: Item
revolver = pistol
{ _itName = "REVOLVER"
, _itType = REVOLVER
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 6
, _laLoaded = 0
@@ -126,6 +119,7 @@ revolver = pistol
}
}
& itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> revolverClip it)
& itType . iyBase .~ REVOLVER
revolverClip :: Item -> Shape
revolverClip it = case it ^? itConsumption . laLoaded of
@@ -170,9 +164,7 @@ smgAfterHamMods =
pistol :: Item
pistol = (bangStick 1)
{ _itName = "PISTOL"
, _itType = PISTOL
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 15
, _laLoaded = 0
@@ -183,8 +175,6 @@ pistol = (bangStick 1)
(ammoHammerCheck : pistolAfterHamMods)
-- , _itZoom = defaultItZoom
-- , _itEquipPict = pictureWeaponAim pistolPic
, _itID = Nothing
, _itInvColor = white
} & itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> makeTinClipAt pi (V3 5 2 0) it)
& itParams %~
( ( muzVel .~ 0.8 )
@@ -194,25 +184,23 @@ pistol = (bangStick 1)
. ( recoil .~ 10 )
. ( torqueAfter .~ 0.2 )
)
& itType . iyBase .~ PISTOL
autoPistol :: Item
autoPistol = pistol
& itUse . useMods .~ (ammoCheckI : pistolAfterHamMods)
& itName .~ "AUTOPISTOL"
& itType .~ AUTOPISTOL
& itModules . at ModAutoMag ?~ DefaultModule
& itType . iyBase .~ AUTOPISTOL
& itType . iyModules . at ModAutoMag ?~ EMPTYMODULE
machinePistol :: Item
machinePistol = autoPistol
& itUse . useDelay . rateMax .~ 2
& itUse . useMods .~ (ammoCheckI : machinePistolAfterHamMods)
& itName .~ "MACHINEPISTOL"
& itType .~ MACHINEPISTOL
& itModules . at ModAutoMag .~ Nothing
& itType . iyBase .~ MACHINEPISTOL
& itType . iyModules . at ModAutoMag .~ Nothing
& itParams . recoil .~ 20
smg :: Item
smg = autoPistol -- & some parameter affecting stability
& itUse . useMods .~ (ammoCheckI : smgAfterHamMods)
& itName .~ "SMG"
& itType .~ SMG
& itType . iyBase .~ SMG
& itUse . useAim . aimStance .~ TwoHandTwist
& itDimension . dimPortage . handlePos .~ 2
& itParams . torqueAfter .~ 0.05
@@ -220,9 +208,7 @@ smg = autoPistol -- & some parameter affecting stability
<> makeTinClipAt 0 (V3 7 (-2) 0) it)
revolverX :: Int -> Item
revolverX i = revolver
{ _itName = "REVx"++show i
, _itType = REVOLVERX i
, _itUse = ruseAmmoParamsRate 8 upHammer
{ _itUse = ruseAmmoParamsRate 8 upHammer
[ ammoHammerCheck
, useTimeCheck
-- rather than locking the inventory, a better solution may be to check
@@ -238,3 +224,4 @@ revolverX i = revolver
, withRecoil
]
} & itConsumption . laMax .~ i * 6
& itType . iyBase .~ REVOLVERX i
+11 -50
View File
@@ -5,7 +5,6 @@ module Dodge.Item.Weapon.BulletGuns
, biggerBlunderbuss
, biggestBlunderbuss
, grenadeLauncher
, ltAutoGun
, autogunSpread
, autoGun
, autoGunPic
@@ -44,9 +43,7 @@ import System.Random
autoGun :: Item
autoGun = defaultAutoGun
{ _itName = "AUTOGUN"
, _itType = AUTOGUN
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 30
, _laLoaded = 30
@@ -88,6 +85,7 @@ autoGun = defaultAutoGun
}
}
& itUse . heldScroll .~ scrollCharMode
& itType . iyBase .~ AUTOGUN
autoGunPic :: Item -> SPic
autoGunPic it = noPic $
colorSH red (prismPoly
@@ -100,9 +98,7 @@ autoGunPic it = noPic $
bangCone :: Item
bangCone = defaultGun
{ _itName = "BANGCONE"
, _itType = BANGCONE
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 5
, _laReloadTime = 25
@@ -143,6 +139,7 @@ bangCone = defaultGun
<> upperPrismPoly 6 (rectNSEW 4 (-4) 15 5)
}
}
& itType . iyBase .~ BANGCONE
coneRandItemUpdate :: State StdGen (Item -> Item)
coneRandItemUpdate = do
wth <- state $ randomR (1,5)
@@ -158,9 +155,7 @@ coneRandItemParams = do
blunderbuss :: Item
blunderbuss = bangCone
{_itName = "BLUNDERBUSS"
,_itType = BLUNDERBUSS
, _itDimension = ItemDimension
{_itDimension = ItemDimension
{ _dimRad = 8
, _dimCenter = V3 5 0 0
, _dimPortage = HeldItem
@@ -175,11 +170,10 @@ blunderbuss = bangCone
& itConsumption . laReloadTime .~ 30
& itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimWeight .~ 6
& itType . iyBase .~ BLUNDERBUSS
bigBlunderbuss :: Item
bigBlunderbuss = blunderbuss
{_itName = "BIGBLUNDERBUSS"
,_itType = BIGBLUNDERBUSS
}
& itType . iyBase .~ BIGBLUNDERBUSS
& itConsumption . laMax .~ 50
& itConsumption . laReloadTime .~ 36
& itParams . recoil .~ 200
@@ -187,9 +181,7 @@ bigBlunderbuss = blunderbuss
& itParams . randomOffset .~ 16
biggerBlunderbuss :: Item
biggerBlunderbuss = bigBlunderbuss
{_itName = "BIGGERBLUNDERBUSS"
,_itType = BIGGERBLUNDERBUSS
}
& itType . iyBase .~ BIGGERBLUNDERBUSS
& itConsumption . laMax .~ 75
& itConsumption . laReloadTime .~ 43
& itParams . recoil .~ 250
@@ -197,9 +189,7 @@ biggerBlunderbuss = bigBlunderbuss
& itParams . randomOffset .~ 20
biggestBlunderbuss :: Item
biggestBlunderbuss = biggerBlunderbuss
{_itName = "BIGGESTBLUNDERBUSS"
,_itType = BIGGESTBLUNDERBUSS
}
& itType . iyBase .~ BIGGESTBLUNDERBUSS
& itConsumption . laMax .~ 100
& itConsumption . laReloadTime .~ 50
& itParams . recoil .~ 300
@@ -209,39 +199,9 @@ biggestBlunderbuss = biggerBlunderbuss
grenadeLauncher :: Int -> Item
grenadeLauncher _ = bangCone
ltAutoGun :: Item
ltAutoGun = defaultAutoGun
{ _itName = "AUTO-LT"
, _itType = LTAUTOGUN
, _itConsumption = defaultAmmo
{ _laType = basicBullet
, _laMax = 15
, _laLoaded = 0
, _laReloadTime = 90
}
, _itUse = ruseAmmoParamsRate 2 NoHammer
[ ammoCheckI
, useTimeCheck
, withSoundStart tap1S
, useAmmoAmount 1
, applyInaccuracy
, withTorqueAfter
, withSidePushI 50
, modClock 2 withMuzFlareI
]
-- , _itFloorPict = ltAutoGunPic
, _itParams = defBulletShooter
{ _muzVel = 1
, _rifling = 0.8
, _bore = 2
, _gunBarrels = SingleBarrel autogunSpread
}
}
longGun :: Item
longGun = defaultGun
{ _itName = "LONGGUN"
, _itType = LONGGUN
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laType = hvBullet
, _laMax = 1
, _laLoaded = 1
@@ -267,6 +227,7 @@ longGun = defaultGun
, _itScope = ZoomScope (V2 0 0) 0 1 0.1 False
-- , _itEffect = itemLaserScopeEffect
}
& itType . iyBase .~ LONGGUN
autogunSpread :: Float
autogunSpread = 0.07
+2 -3
View File
@@ -20,9 +20,7 @@ import Control.Lens
lasDrones :: Item
lasDrones = defaultGun
{ _itName = "DRONES"
, _itType = DRONELAUNCHER
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laType = DroneAmmo { _amString = "LASDRONE" }
, _laMax = 2
, _laLoaded = 2
@@ -39,6 +37,7 @@ lasDrones = defaultGun
& useAim . aimStance .~ TwoHandTwist
, _itEffect = NoItEffect
}
& itType . iyBase .~ DRONELAUNCHER
lasDronesPic :: Item -> SPic
lasDronesPic _ =
+4 -4
View File
@@ -220,7 +220,7 @@ throwRemoteBomb :: Creature -> World -> World
throwRemoteBomb cr w = setLocation
$ removePict
$ resetFire
$ resetName
-- $ resetName
$ over props addG w
where
cid = _crID cr
@@ -237,7 +237,7 @@ throwRemoteBomb cr w = setLocation
v | magV v' > 6 = 6 *.* normalizeV v'
| otherwise = v'
j = _crInvSel cr
resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTE"
-- resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTE"
removePict = set (creatures . ix cid . crInv . ix j . itEquipPict) $ \ _ _ -> emptyBlank
resetFire = set (creatures . ix cid . crInv . ix j . itUse . rUse)
$ \_ -> explodeRemoteBomb itid i
@@ -258,14 +258,14 @@ explodeRemoteBomb itid pjid cr w
= set (props . ix pjid . pjUpdate) (\_ -> retireRemoteBomb itid 30 pjid)
-- $ set (props . ix pjid . pjDraw) (\_ -> blank)
$ set (creatures . ix cid . crInv . ix j . itUse . rUse) (\_ -> const id)
$ resetName
-- $ resetName
$ resetPict
-- $ resetScope
$ makeExplosionAt (_pjPos (_props w IM.! pjid)) w
-- - $ makeShrapnelBombAt (_pjPos (_props w IM.! pjid)) w
where
cid = _crID cr
resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTEBOMB"
-- resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTEBOMB"
resetPict = set (creatures . ix cid . crInv . ix j . itEquipPict )
(pictureWeaponAim $ \_ -> (,) emptySH remoteBombUnarmedPic)
-- resetScope = creatures . ix cid . crInv . ix j . itScope . _Just . scopePos .~ (0,0)
+1 -47
View File
@@ -2,11 +2,7 @@
Display of weapon strings in the inventory.
-}
module Dodge.Item.Weapon.InventoryDisplay
( basicItemDisplay
, maybeWarmupStatus
, maybeRateStatus
, moduleStrings
) where
where
import Dodge.Data
import Padding
import Dodge.Inventory.ItemSpace
@@ -15,46 +11,4 @@ import Dodge.Module
import Data.Maybe
import Data.Sequence
import Control.Lens
{- | Displays the item name, ammo if loaded, and any selected '_itCharMode'. -}
basicItemDisplay :: Item -> [String]
basicItemDisplay it = Prelude.take (itSlotsTaken it) $
(midPadL 15 ' ' thename (' ' : thenumber) ++ theparam)
: moduleStrings it ++ repeat "*"
where
thename = _itName it
thenumber = case it ^? itConsumption of
Just am@LoadableAmmo{} -> case _laReloadState am of
Nothing' -> show (_laLoaded am)
Just' x -> show x ++ "R" ++ show (_laLoaded am)
Just am@ChargeableAmmo{} -> show $ _wpCharge am
Just x@ItemItselfConsumable{} -> "x" ++ show (_itAmount x)
Just NoConsumption -> ""
Nothing -> ""
theparam = fromMaybe []
. listToMaybe
$ mapMaybe ($ it)
[ maybeModeStatus
-- , maybeWarmupStatus
-- , maybeRateStatus
]
-- this can be moved to Dodge/Module and unified with moduleSizes
maybeModeStatus :: Item -> Maybe String
maybeModeStatus it = case it ^? itAttachment of
Just ItCharMode {_itCharMode = (c :<| _)} -> Just [' ',c]
Just ItMode {_itMode = i} -> Just $ show i
_ -> Nothing
maybeRateStatus :: Item -> Maybe String
maybeRateStatus it = case it ^? itUse . useDelay . rateMaxMax of
Nothing -> Nothing
_ -> Just $ leftPad 3 ' ' (show (_rateMax . _useDelay $ _itUse it))
maybeWarmupStatus :: Item -> Maybe String
maybeWarmupStatus it = case it ^? itUse . useDelay . warmMax of
Nothing -> Nothing
Just m -> case m - (_warmTime . _useDelay $ _itUse it) of
x | x <= 1 -> Just "WARM"
| otherwise -> let n = show x
in Just $ Prelude.take (4 - Prelude.length n) "WARM" ++ n
+7 -11
View File
@@ -38,9 +38,7 @@ import System.Random
launcher :: Item
launcher = defaultGun
{ _itName = "ROCKO"
, _itType = LAUNCHER
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laType = ProjectileAmmo
{ _amPayload = makeExplosionAt
, _amString = "EXPLOSIVE SHELL"
@@ -71,7 +69,6 @@ launcher = defaultGun
, _tweakParams = basicAmPjMoves
}
, _itInvSize = 3
, _itInvDisplay = basicItemDisplay
, _itDimension = ItemDimension
{ _dimRad = 9
, _dimCenter = V3 10 0 0
@@ -82,12 +79,12 @@ launcher = defaultGun
, _dimSPic = launcherPic
}
}
& itModules . at ModLauncherHoming ?~ DefaultModule
& itType . iyBase .~ LAUNCHER
& itType . iyModules . at ModLauncherHoming ?~ EMPTYMODULE
launcherX :: Int -> Item
launcherX i = launcher
& itName .~ ("ROCKO-" ++ show i)
& itType .~ LAUNCHERX i
& itType . iyBase .~ LAUNCHERX i
& itConsumption . laMax .~ i
& itConsumption . laLoaded .~ i
& itUse . rUse .~ usePjCreationX i
@@ -287,8 +284,7 @@ remoteLauncherName = "ROCKO-REMOTE"
remoteLauncher :: Item
remoteLauncher = launcher
& itName .~ remoteLauncherName
& itType .~ REMOTELAUNCHER
& itType . iyBase .~ REMOTELAUNCHER
& itUse . rUse .~ fireRemoteShell
& itScope .~ RemoteScope (V2 0 0) 1 True
& itConsumption . laType . amPjDraw .~ drawRemoteShell
@@ -297,7 +293,7 @@ remoteLauncher = launcher
fireRemoteShell :: Item -> Creature -> World -> World
fireRemoteShell it cr w = set (creatures . ix cid . crInv . ix j . itUse . rUse)
(\_ _ -> explodeRemoteRocket itid i)
$ set (creatures . ix cid . crInv . ix j . itName) remoteLauncherName
-- $ set (creatures . ix cid . crInv . ix j . itName) remoteLauncherName
$ addRemRocket w'
where
(w',itid) = getHeldItemLoc cr w
@@ -358,7 +354,7 @@ explodeRemoteRocket itid pjid w = w
& props . ix pjid . pjUpdate .~ (\_ -> retireRemoteProj fireRemoteShell itid 30 pjid)
& props . ix pjid . prDraw .~ const mempty
& itPoint . itUse . rUse .~ (\_ _ -> id)
& itPoint . itName .~ "REMOTELAUNCHER"
-- & itPoint . itName .~ "REMOTELAUNCHER"
& _pjPayload thepj (_pjPos thepj)
where
itPoint = pointToItem $ _itemPositions w IM.! itid
+4 -6
View File
@@ -23,9 +23,7 @@ import Control.Lens
Sends out pulses that display walls. -}
clickDetector :: Detector -> Item
clickDetector dt = defaultGun
{ _itName = show dt
, _itType = CLICKDETECTOR dt
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
, _itUse = ruseRate 20 (detectorEffect dt) upHammer
[ ammoUseCheck
]
@@ -34,12 +32,11 @@ clickDetector dt = defaultGun
-- , _itZoom = defaultItZoom { _itZoomMax = 1}
, _itEquipPict = pictureWeaponAim $ \_ -> (,) emptySH $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
}
& itType . iyBase .~ CLICKDETECTOR dt
autoDetector :: Detector -> Item
autoDetector dt = defaultEquipment
{ _itType = AUTODETECTOR dt
, _itName = "AUTO-" ++ show dt
, _itEquipPict = shapeForWrist (colorSH (detectorColor dt) $ upperPrismPoly 3 $ rectWH 2 2)
{_itEquipPict = shapeForWrist (colorSH (detectorColor dt) $ upperPrismPoly 3 $ rectWH 2 2)
-- , _itEffect = autoRadarEffect
, _itID = Nothing
}
@@ -47,6 +44,7 @@ autoDetector dt = defaultEquipment
& itUse . eqEq . eqUse .~ autoEffect (detectorEffect dt) 100 click1S
& itUse . eqEq . eqParams .~ EquipCounter 0
& itUse . eqEq . eqViewDist ?~ 350
& itType . iyBase .~ AUTODETECTOR dt
detectorColor :: Detector -> Color
detectorColor dt = case dt of
+2 -3
View File
@@ -30,9 +30,7 @@ import LensHelp
sonicGun :: Item
sonicGun = defaultAutoGun
{ _itName = "SONICGUN"
, _itType = SONICGUN
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laMax = 10
, _laLoaded = 10
, _laReloadTime = 80
@@ -54,6 +52,7 @@ sonicGun = defaultAutoGun
, _dimSPic = const $ noPic baseSonicShape
}
}
& itType . iyBase .~ SONICGUN
baseSonicShape :: Shape
baseSonicShape = colorSH rose $ upperPrismPoly 3 $ rectXH 25 2
+2 -2
View File
@@ -16,8 +16,7 @@ import Control.Lens
Creates a creature next to the creature using the item. -}
spawnGun :: Creature -> Item
spawnGun cr = defaultGun
{ _itName = "SPAWNER"
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laMax = 1
, _laLoaded = 1
, _laReloadTime = 80
@@ -29,6 +28,7 @@ spawnGun cr = defaultGun
, hammerCheckI
]
}
& itType . iyBase .~ SPAWNER
spawnCrNextTo
:: Creature -- ^ Creature to spawn
-> Creature -- ^ existing creature that will be spawned next to
+7 -15
View File
@@ -39,9 +39,7 @@ import Control.Monad.State
import System.Random
poisonSprayer :: Item
poisonSprayer = flameThrower
{ _itName = "POISONSPRAYER"
, _itType = POISONSPRAYER
}
& itType . iyBase .~ POISONSPRAYER
& itConsumption . laType .~ GasAmmo
{ _amString = "POISONGAS"
, _amCreateGas = aGasCloud
@@ -68,8 +66,7 @@ flamerPic it =
am = fractionLoadedAmmo2 it
flameSpitter :: Item
flameSpitter = flameThrower
& itName .~ "FLAMESPITTER"
& itType .~ FLAMESPITTER
& itType . iyBase .~ FLAMESPITTER
& itConsumption . laMax .~ 10
& itConsumption . laReloadTime .~ 20
& itParams . sprayNozzles . ix 0 . nzPressure .~ 4
@@ -92,8 +89,7 @@ flameSpitter = flameThrower
flameTorrent :: Item
flameTorrent = flameThrower
& itName .~ "FLAMETORRENT"
& itType .~ FLAMETORRENT
& itType . iyBase .~ FLAMETORRENT
& itUse . useAim . aimZoom .~ defaultItZoom
& itParams . sprayNozzles . ix 0 %~
( (nzPressure .~ 10)
@@ -103,12 +99,10 @@ flameTorrent = flameThrower
blowTorch :: Item
blowTorch = flameThrower
& itName .~ "BLOWTORCH"
& itType .~ BLOWTORCH
& itType . iyBase .~ BLOWTORCH
flameWall :: Item
flameWall = flameThrower
& itName .~ "FLAMEWALL"
& itType .~ FLAMEWALL
& itType . iyBase .~ FLAMEWALL
& itParams . sprayNozzles .~ zipWith makeNozzle [0,0.6,-0.6] [2,2.5,2.5]
where
makeNozzle dir pres = Nozzle
@@ -122,9 +116,7 @@ flameWall = flameThrower
flameThrower :: Item
flameThrower = defaultAutoGun
{ _itName = "FLAMETHROWER"
, _itType = FLAMETHROWER
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
{ _laMax = 250
, _laLoaded = 0
, _laReloadTime = 100
@@ -145,7 +137,6 @@ flameThrower = defaultAutoGun
& useAim . aimStance .~ TwoHandTwist
-- , _itFloorPict = flamerPic
-- , _itZoom = defaultItZoom
, _itAttachment = NoItAttachment
, _itParams = Sprayer
{ _sprayNozzles =
[ Nozzle
@@ -169,6 +160,7 @@ flameThrower = defaultAutoGun
}
-- , _itFloorPict = flamerPic
}
& itType . iyBase .~ FLAMETHROWER
aGasCloud :: Float -> Point2 -> Float -> Creature -> World -> World
aGasCloud pressure pos dir cr = makeGasCloud pos
+14 -24
View File
@@ -23,9 +23,7 @@ import Control.Lens
rewindGun :: Item
rewindGun = defaultGun
{ _itName = "REWINDER"
, _itType = REWINDER
, _itInvColor = cyan
{ _itInvColor = cyan
, _itConsumption = ChargeableAmmo
{ _wpMaxCharge = 250
, _wpCharge = 0
@@ -35,6 +33,7 @@ rewindGun = defaultGun
& lUse .~ useRewindGun
& eqEq . eqSite .~ GoesOnChest
}
& itType . iyBase .~ REWINDER
rewindEffect :: Item -> Creature -> World -> World
rewindEffect itm cr w
| Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take maxcharge . (w' : ))
@@ -65,14 +64,13 @@ useRewindGun _ _ w = case _rewindWorlds w of
-- needs to shift this item to the current inventory slot
shrinkGun :: Item
shrinkGun = defaultGun
{ _itName = "SHRINKER"
, _itType = SHRINKER
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
, _itUse = defaultlUse {_lUse = hammerCheckL useShrinkGun}
& useHammer .~ upHammer
-- , _itFloorPict = shrinkGunPic
, _itAttachment = ItBool True
}
& itType . iyBase .~ SHRINKER
shrinkGunPic :: Item -> SPic
shrinkGunPic _ = noPic $ colorSH violet $ upperPrismPoly 5 $ square 5
@@ -92,9 +90,7 @@ useShrinkGun it cr w = if _itBool $ _itAttachment it
blinkGun :: Item
blinkGun = defaultGun
{ _itName = "BLINKER"
, _itType = BLINKER
, _itInvColor = cyan
{ _itInvColor = cyan
, _itConsumption = defaultAmmo
, _itUse = defaultlUse
& lUse .~ hammerCheckL (shootL $ const blinkAction)
@@ -102,42 +98,36 @@ blinkGun = defaultGun
& eqEq . eqSite .~ GoesOnWrist
-- , _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2
}
& itType . iyBase .~ BLINKER
unsafeBlinkGun :: Item
unsafeBlinkGun = blinkGun
& itName .~ "BLINKER-UNSAFE"
& itType .~ BLINKERUNSAFE
& itType . iyBase .~ BLINKERUNSAFE
& itUse . lUse .~ hammerCheckL (shootL $ const unsafeBlinkAction)
& itUse . eqEq . eqViewDist ?~ 400
effectGun :: String -> (Creature -> World -> World) -> Item
effectGun name eff = defaultGun
{ _itName = name ++ "Gun"
, _itUse = defaultrUse
{ _itUse = defaultrUse
& rUse .~ const eff
& useMods .~ [hammerCheckI]
}
effectGunCont :: String -> (Creature -> World -> World) -> Item
effectGunCont name eff = defaultGun
{ _itName = name ++ "Gun"
, _itUse = defaultrUse {_rUse = const eff}
}
& itType . iyBase .~ EFFGUN name
autoEffectGun :: String -> (Creature -> World -> World) -> Item
autoEffectGun name eff = defaultAutoGun
{ _itName = name ++ "Gun"
, _itUse = defaultrUse {_rUse = const eff}
autoEffectGun name eff = defaultGun
{ _itUse = defaultrUse {_rUse = const eff}
}
& itType . iyBase .~ AUTOEFFGUN name
forceFieldGun :: Item
forceFieldGun = defaultGun
{ _itName = "FORCEFIELDGUN"
, _itType = FORCEFIELDGUN
, _itConsumption = defaultAmmo & laType .~ ForceFieldAmmo forceField
{ _itConsumption = defaultAmmo & laType .~ ForceFieldAmmo forceField
, _itUse = ruseInstant useForceFieldGun (HasHammer HammerUp)
[ hammerCheckI , ammoCheckI , useAmmoAmount 1]
-- , _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-4,-4),(-4,4),(4,4),(4,0),(0,0),(0,-4)]
, _itTargeting = targetRBPress & tgDraw .~ targetDistanceDraw
, _itParams = ParamMID Nothing
}
& itType . iyBase .~ FORCEFIELDGUN
-- I believe because the targeting returns to nothing straight after you release
-- the rmb, it is possible for this to do nothing
-- TODO investigate more and fix