Cleanup, work towards unifying spayguns
This commit is contained in:
@@ -91,7 +91,7 @@ applyModules ms it = foldr f (it & itModules .~ ms) ms
|
||||
-- g ims (ims',s) = map (second (s++)) $ combineModules ims ims'
|
||||
|
||||
combineModules :: M.Map ModuleSlot ItemModule
|
||||
-> M.Map ModuleSlot ItemModule
|
||||
-> M.Map ModuleSlot ItemModule
|
||||
-> ([String],M.Map ModuleSlot ItemModule)
|
||||
combineModules = mergeA
|
||||
(traverseMaybeMissing f)
|
||||
|
||||
@@ -50,12 +50,14 @@ itemCombinations =
|
||||
|
||||
, p [p 3 PIPE,o HARDWARE] bangRod
|
||||
, po [BANGROD,PLANK,HARDWARE] elephantGun
|
||||
, po [ELEPHANTGUN,HARDWARE,PRISM] sniperRifle
|
||||
, po [ELEPHANTGUN,HARDWARE,TIN] amr
|
||||
, po [ELEPHANTGUN,HARDWARE,CAN] sniperRifle
|
||||
, po [AMR,HARDWARE,SPRING] autoAmr
|
||||
, po [BANGROD,PLATE,DRUM,MOTOR] machineGun
|
||||
|
||||
, p [p 2 TUBE,o HARDWARE] launcher
|
||||
, p [p 2 TUBE,o LAUNCHER] doubleLauncher
|
||||
, p [p 2 TUBE,o LAUNCHER] (launcherX 2)
|
||||
, p [p 2 TUBE,o $ LAUNCHERX 2] (launcherX 3)
|
||||
, po [TRANSMITTER,MINIDISPLAY,LAUNCHER] remoteLauncher
|
||||
|
||||
, po [LIGHTER,PIPE,CAN] flameStick
|
||||
@@ -155,10 +157,7 @@ moduleCombinations =
|
||||
amod cts str func = (cts,ItemModule [str] 1 func)
|
||||
|
||||
homingLaunchers :: [Item]
|
||||
homingLaunchers =
|
||||
[ launcher
|
||||
, doubleLauncher
|
||||
]
|
||||
homingLaunchers = launcher : [launcherX i | i <- [2..3]]
|
||||
|
||||
bulletWeapons :: [Item]
|
||||
bulletWeapons = [bangStick i | i <- [1..9] ]
|
||||
|
||||
@@ -35,6 +35,7 @@ data CombineType
|
||||
| BANGROD
|
||||
| ELEPHANTGUN
|
||||
| AMR
|
||||
| AUTOAMR
|
||||
| SNIPERRIFLE
|
||||
| MACHINEGUN
|
||||
| FLAMESTICK
|
||||
@@ -50,7 +51,7 @@ data CombineType
|
||||
| SONICGUN
|
||||
| TRACTORGUN
|
||||
| LAUNCHER
|
||||
| DOUBLELAUNCHER
|
||||
| LAUNCHERX Int
|
||||
-- | TRACKINGLAUNCHER
|
||||
| REMOTELAUNCHER
|
||||
| SPRAYER
|
||||
|
||||
@@ -170,8 +170,9 @@ testInventory = IM.fromList $ zip [0..]
|
||||
, incendiaryModule
|
||||
, bounceModule
|
||||
, teleportModule
|
||||
, makeTypeCraftNum 1 LIGHTER
|
||||
, makeTypeCraftNum 5 TUBE
|
||||
, makeTypeCraftNum 5 CREATURESENSOR
|
||||
-- , makeTypeCraftNum 5 CREATURESENSOR
|
||||
, makeTypeCraftNum 3 PRISM
|
||||
, makeTypeCraftNum 1 MAGNET
|
||||
, makeTypeCraftNum 5 HARDWARE
|
||||
@@ -181,8 +182,8 @@ testInventory = IM.fromList $ zip [0..]
|
||||
, makeTypeCraftNum 3 PLANK
|
||||
, makeTypeCraftNum 1 MOTOR
|
||||
, makeTypeCraftNum 5 MICROCHIP
|
||||
, makeTypeCraftNum 1 TRANSMITTER
|
||||
, makeTypeCraftNum 5 AIUNIT
|
||||
-- , makeTypeCraftNum 1 TRANSMITTER
|
||||
-- , makeTypeCraftNum 5 AIUNIT
|
||||
]
|
||||
stackedInventory :: IM.IntMap Item
|
||||
stackedInventory = IM.fromList $ zip [0..]
|
||||
|
||||
+15
-3
@@ -399,9 +399,9 @@ data ModuleSlot
|
||||
data ItemModule
|
||||
= DefaultModule
|
||||
| ItemModule
|
||||
{ _modName :: [String]
|
||||
, _modSize :: Int
|
||||
, _modModification :: Item -> Item
|
||||
{ _modName :: [String]
|
||||
, _modSize :: Int
|
||||
, _modModification :: Item -> Item
|
||||
}
|
||||
|
||||
data ItemDimension = ItemDimension
|
||||
@@ -549,6 +549,14 @@ data TweakParam = TweakParam
|
||||
, _showTweak :: Int -> String
|
||||
, _nameTweak :: String
|
||||
}
|
||||
data Nozzle = Nozzle
|
||||
{ _nzPressure :: Int
|
||||
, _nzDir :: Float
|
||||
, _nzMaxWalkAngle :: Float
|
||||
, _nzCurrentWalkAngle :: Float
|
||||
, _nzWalkSpeed :: Float
|
||||
, _nzLength :: Float
|
||||
}
|
||||
data GunBarrels
|
||||
= MultiBarrel
|
||||
{ _brlSpread :: BarrelSpread
|
||||
@@ -579,6 +587,9 @@ data ItemParams
|
||||
{ _nozzleSpread :: Float
|
||||
, _nozzleNum :: Int
|
||||
}
|
||||
| Sprayer'
|
||||
{ _sprayerNozzles :: [Nozzle]
|
||||
}
|
||||
| AngleWalk
|
||||
{ _maxWalkAngle :: Float
|
||||
, _currentWalkAngle :: Float
|
||||
@@ -963,3 +974,4 @@ makeLenses ''Gust
|
||||
makeLenses ''GunBarrels
|
||||
makeLenses ''ItemModule
|
||||
makeLenses ''Targeting
|
||||
makeLenses ''Nozzle
|
||||
|
||||
@@ -2,6 +2,7 @@ module Dodge.Item.Weapon.BulletGun.Rod
|
||||
( bangRod
|
||||
, elephantGun
|
||||
, amr
|
||||
, autoAmr
|
||||
, sniperRifle
|
||||
, machineGun
|
||||
) where
|
||||
@@ -12,8 +13,9 @@ import Dodge.Item.Weapon.BulletGun.Clip
|
||||
import Dodge.Default.Weapon
|
||||
--import Dodge.Item.Weapon.InventoryDisplay
|
||||
import Dodge.Default
|
||||
import Dodge.Item.Weapon.ZoomScope
|
||||
--import Dodge.Item.Attachment
|
||||
--import Dodge.Item.Weapon.ExtraEffect
|
||||
import Dodge.Item.Weapon.ExtraEffect
|
||||
--import Dodge.Item.Weapon.InventoryDisplay
|
||||
import Dodge.Item.Weapon.AmmoParams
|
||||
--import Dodge.Item.Draw
|
||||
@@ -43,13 +45,14 @@ bangRod = defaultGun
|
||||
, _bore = 2
|
||||
, _gunBarrels = SingleBarrel 0.1
|
||||
}
|
||||
, _itUse = ruseAmmoParamsRate 6 upHammer
|
||||
, _itUse = ruseAmmoParamsRate 12 upHammer
|
||||
[ ammoHammerCheck
|
||||
, useTimeCheck
|
||||
, withSoundStart autoGunS
|
||||
, withSoundStart bangEchoS
|
||||
, useAmmoAmount 1
|
||||
, torqueAfterI 0.3
|
||||
, applyInaccuracy
|
||||
, withThickSmokeI
|
||||
, withMuzFlareI
|
||||
, withRecoilI 50
|
||||
]
|
||||
@@ -90,26 +93,38 @@ elephantGun = bangRod
|
||||
& itUse . useMods .~
|
||||
[ ammoHammerCheck
|
||||
, useTimeCheck
|
||||
, withSoundStart autoGunS
|
||||
, withSoundStart bangEchoS
|
||||
, useAmmoAmount 1
|
||||
, torqueAfterI 0.1
|
||||
, applyInaccuracy
|
||||
, withThickSmokeI
|
||||
, withMuzFlareI
|
||||
, withRecoilI 50
|
||||
]
|
||||
amr :: Item
|
||||
amr = elephantGun
|
||||
& itName .~ "AMR"
|
||||
& itName .~ "ANTIMATERIELRIFLE"
|
||||
& itType .~ AMR
|
||||
& itConsumption . ammoBaseMax .~ 15
|
||||
& itDimension . dimSPic .~ (\it -> noPic $ baseAMRShape
|
||||
<> makeTinClipAt 0 (V3 10 (-2) 0) it
|
||||
)
|
||||
|
||||
autoAmr :: Item
|
||||
autoAmr = amr
|
||||
& itName .~ "AUTOAMR"
|
||||
& itType .~ AUTOAMR
|
||||
& itUse . useMods %~ ((ammoCheckI :) . tail)
|
||||
|
||||
sniperRifle :: Item
|
||||
sniperRifle = elephantGun
|
||||
& itName .~ "SNIPERRIFLE"
|
||||
& itType .~ SNIPERRIFLE
|
||||
& itParams . gunBarrels .~ SingleBarrel 0
|
||||
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5}
|
||||
& itScroll .~ zoomLongGun
|
||||
& itScope .~ ZoomScope (V2 0 0) 0 1 False
|
||||
& itTargeting .~ targetLaser
|
||||
machineGun :: Item
|
||||
machineGun = bangRod
|
||||
& itName .~ "MACHINEGUN"
|
||||
|
||||
@@ -21,6 +21,7 @@ module Dodge.Item.Weapon.BulletGuns
|
||||
import Dodge.Item.Weapon.BulletGun.Stick
|
||||
import Dodge.Item.Weapon.BulletGun.Cane
|
||||
import Dodge.Item.Weapon.BulletGun.Rod
|
||||
import Dodge.Item.Weapon.ZoomScope
|
||||
--import Dodge.Item.Weapon.BulletGun.Clip
|
||||
import Dodge.Data
|
||||
--import Dodge.ChainEffect
|
||||
@@ -29,7 +30,6 @@ import Dodge.Default.Weapon
|
||||
import Dodge.Item.Weapon.InventoryDisplay
|
||||
import Dodge.Default
|
||||
import Dodge.Item.Attachment
|
||||
import Dodge.Item.Weapon.ExtraEffect
|
||||
--import Dodge.Item.Weapon.InventoryDisplay
|
||||
import Dodge.Item.Weapon.AmmoParams
|
||||
import Dodge.Item.Draw
|
||||
@@ -456,14 +456,8 @@ longGun = defaultGun
|
||||
, _itScroll = zoomLongGun
|
||||
, _itAttachment = NoItAttachment
|
||||
, _itScope = ZoomScope (V2 0 0) 0 1 False
|
||||
, _itEffect = itemLaserScopeEffect
|
||||
-- , _itEffect = itemLaserScopeEffect
|
||||
}
|
||||
|
||||
zoomLongGun :: Float -> Creature -> Item -> Item
|
||||
zoomLongGun x _
|
||||
| x > 0 = itScope . scopeZoomChange %~ (max 5 . (+5))
|
||||
| x < 0 = itScope . scopeZoomChange %~ (min (-5) . subtract 5)
|
||||
| otherwise = id
|
||||
|
||||
autogunSpread :: Float
|
||||
autogunSpread = 0.07
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{-# LANGUAGE BangPatterns #-}
|
||||
--{-# LANGUAGE BangPatterns #-}
|
||||
{- |
|
||||
Extra weapon effects, supplementing explicit use effects.
|
||||
-}
|
||||
module Dodge.Item.Weapon.ExtraEffect
|
||||
( itemLaserScopeEffect
|
||||
, autoSonarEffect
|
||||
(-- itemLaserScopeEffect
|
||||
autoSonarEffect
|
||||
, autoRadarEffect
|
||||
, targetRBPress
|
||||
, targetRBCreature
|
||||
@@ -14,11 +14,10 @@ module Dodge.Item.Weapon.ExtraEffect
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
import Dodge.Item.Weapon.Decoration
|
||||
--import Dodge.Item.Weapon.Decoration
|
||||
import Dodge.Item.Weapon.UseEffect
|
||||
import Dodge.Item.Weapon.LaserPath
|
||||
--import Dodge.Item.Attachment.Data
|
||||
import Dodge.WorldEvent.ThingsHit
|
||||
import Dodge.Picture.Layer
|
||||
import Dodge.Creature.Test
|
||||
import Picture
|
||||
@@ -27,43 +26,8 @@ import Geometry.Data
|
||||
|
||||
import Data.Maybe
|
||||
import Control.Lens
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.Set as S
|
||||
import qualified SDL
|
||||
{- |
|
||||
Creates a laser scope and recocks the weapon.
|
||||
TODO add the laser scope!
|
||||
-}
|
||||
itemLaserScopeEffect :: ItEffect
|
||||
itemLaserScopeEffect
|
||||
= ItInvEffect {_itInvEffect = f ,_itEffectCounter = 0 }
|
||||
where
|
||||
moveHammerUp HammerDown = HammerReleased
|
||||
moveHammerUp !_ = HammerUp
|
||||
f _ cr invid w
|
||||
| invid == _crInvSel cr && crIsAiming' cr = w
|
||||
& particles %~ (:) (makeLaserScope sp ep reloadFrac)
|
||||
& creatures . ix (_crID cr) . crInv . ix invid . itUse . useHammer . hammerPosition %~ moveHammerUp
|
||||
| otherwise = w
|
||||
where
|
||||
p = _crPos cr
|
||||
d = _crDir cr
|
||||
r = _crRad cr
|
||||
sp = p +.+ (r + 3) *.* unitVectorAtAngle d
|
||||
xp = sp +.+ 3000 *.* unitVectorAtAngle d
|
||||
ep = case listToMaybe $ thingsHitLongLine sp xp w of
|
||||
Just (pos,_) -> pos
|
||||
Nothing -> xp
|
||||
--glowPoint = case listToMaybe $ thingsHitLongLine sp xp w of
|
||||
-- Just (pos,E3x2 wl) -> pos +.+ 2 *.* wallNormal wl
|
||||
-- _ -> ep -.- 2 *.* unitVectorAtAngle d
|
||||
wpammo = _itConsumption $ (cr ^. crInv) IM.! invid
|
||||
reloadFrac
|
||||
| _ammoLoaded wpammo == 0 = 1
|
||||
| otherwise = case _reloadState wpammo of
|
||||
Just' rs -> fromIntegral rs / fromIntegral (_reloadTime wpammo)
|
||||
Nothing' -> 1
|
||||
--col = mixColors reloadFrac (1-reloadFrac) red green
|
||||
{- | Automatically send out radar pulses that detect walls. -}
|
||||
autoRadarEffect :: ItEffect
|
||||
autoRadarEffect = ItInvEffect {_itInvEffect = f 50 ,_itEffectCounter = 0 }
|
||||
@@ -97,7 +61,7 @@ defaultTargeting = TargetingOnHeld
|
||||
targetLaser :: Targeting
|
||||
targetLaser = defaultTargeting
|
||||
& tgUpdate .~ targetLaserUpdate
|
||||
& tgDraw .~ targetLaserDraw
|
||||
& tgDraw .~ targetLaserDraw
|
||||
targetRBPress :: Targeting
|
||||
targetRBPress = defaultTargeting
|
||||
& tgUpdate .~ targetRBPressUpdate
|
||||
@@ -170,15 +134,22 @@ targetLaserDraw :: Int -> Item -> Creature -> World -> Picture
|
||||
targetLaserDraw _ it _ _ = fromMaybe mempty $ do
|
||||
ps <- it ^? itTargeting . tgPoints
|
||||
return $ setLayer 1 $ pictures
|
||||
[ setDepth 19 . color (brightX 0 0.5 red) $ thickLine 5 ps
|
||||
, setDepth 19.5 . color (brightX 5 1 red) $ thickLine 1 ps
|
||||
[ setDepth 19 . color (brightX 0 0.5 col) $ thickLine 5 ps
|
||||
, setDepth 19.5 . color (brightX 5 1 col) $ thickLine 1 ps
|
||||
]
|
||||
|
||||
where
|
||||
wpammo = _itConsumption it
|
||||
reloadFrac
|
||||
| _ammoLoaded wpammo == 0 = 1
|
||||
| otherwise = case _reloadState wpammo of
|
||||
Just' rs -> fromIntegral rs / fromIntegral (_reloadTime wpammo)
|
||||
Nothing' -> 1
|
||||
col = mixColors reloadFrac (1-reloadFrac) red green
|
||||
targetLaserUpdate :: Item -> Creature -> World -> Targeting -> Targeting
|
||||
targetLaserUpdate _ cr w t
|
||||
| SDL.ButtonRight `S.member` _mouseButtons w = t
|
||||
& tgPos .~ fmap fst mp
|
||||
& tgPoints .~ ps ++ [sp]
|
||||
| crIsAiming cr = t
|
||||
& tgPos .~ fmap fst mp
|
||||
& tgPoints .~ sp:ps
|
||||
& tgActive .~ True
|
||||
| otherwise = t & tgPos %~ const Nothing
|
||||
& tgPoints .~ []
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module Dodge.Item.Weapon.Launcher
|
||||
( launcher
|
||||
, doubleLauncher
|
||||
, launcherX
|
||||
, remoteLauncher
|
||||
, fireTrackingShell
|
||||
) where
|
||||
@@ -83,25 +83,30 @@ launcher = defaultGun
|
||||
}
|
||||
& itModules . at ModLauncherHoming ?~ DefaultModule
|
||||
|
||||
doubleLauncher :: Item
|
||||
doubleLauncher = launcher
|
||||
& itName .~ "DOUBLEROCKO"
|
||||
& itType .~ DOUBLELAUNCHER
|
||||
& itUse . rUse .~ usePjCreationDouble
|
||||
launcherX :: Int -> Item
|
||||
launcherX i = launcher
|
||||
& itName .~ ("ROCKO-" ++ show i)
|
||||
& itType .~ LAUNCHERX i
|
||||
& itConsumption . ammoBaseMax .~ i
|
||||
& itConsumption . ammoLoaded .~ i
|
||||
& itUse . rUse .~ usePjCreationX i
|
||||
& itUse . useMods .~
|
||||
[ hammerCheckI
|
||||
, ammoCheckI
|
||||
, useTimeCheck
|
||||
, withSoundStart tap4S
|
||||
, useAmmoAmount 1
|
||||
, useAmmoAmount i
|
||||
]
|
||||
|
||||
usePjCreation :: Item -> Creature -> World -> World
|
||||
usePjCreation it = _amPjCreation (_aoType (_itConsumption it)) it
|
||||
|
||||
usePjCreationDouble :: Item -> Creature -> World -> World
|
||||
usePjCreationDouble it cr = _amPjCreation (_aoType (_itConsumption it)) it cr
|
||||
. _amPjCreation (_aoType (_itConsumption it)) it (cr & crDir +~ pi)
|
||||
usePjCreationX :: Int -> Item -> Creature -> World -> World
|
||||
usePjCreationX i it cr = foldr f
|
||||
(_amPjCreation (_aoType (_itConsumption it)) it cr)
|
||||
[1..i-1]
|
||||
where
|
||||
f n = (. _amPjCreation (_aoType (_itConsumption it)) it (cr & crDir +~ (2*pi*fromIntegral n / fromIntegral i)))
|
||||
|
||||
launcherPic :: Item -> SPic
|
||||
launcherPic _ =
|
||||
|
||||
@@ -29,9 +29,11 @@ import Geometry
|
||||
import Picture
|
||||
import Shape
|
||||
import ShapePicture
|
||||
import LensHelp
|
||||
|
||||
import Data.Function
|
||||
import Control.Lens
|
||||
import Data.Traversable
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
--import Data.Function
|
||||
import System.Random
|
||||
poisonSprayer :: Item
|
||||
poisonSprayer = defaultAutoGun
|
||||
@@ -80,13 +82,14 @@ flamerPic it =
|
||||
r = 5
|
||||
am = fractionLoadedAmmo2 it
|
||||
flameStick :: Item
|
||||
flameStick = undefined
|
||||
flameStick = flamer
|
||||
& itUse . rUse .~ const aFlame
|
||||
blowTorch :: Item
|
||||
blowTorch = undefined
|
||||
blowTorch = flamer
|
||||
flameThrower :: Item
|
||||
flameThrower = undefined
|
||||
flameThrower = flamer
|
||||
flameWall :: Item
|
||||
flameWall = undefined
|
||||
flameWall = flamer
|
||||
flamer :: Item
|
||||
flamer = defaultAutoGun
|
||||
{ _itName = "FLAMER"
|
||||
@@ -124,8 +127,25 @@ aGasCloud cr w = insertCloud $ set randGen g w
|
||||
vel = (_crPos cr -.- _crOldPos cr) +.+ 10 *.* unitVectorAtAngle dir
|
||||
insertCloud = makeGasCloud pos vel
|
||||
|
||||
overNozzles :: (Creature -> World -> Nozzle -> (World,Nozzle))
|
||||
-> Item -> Creature -> World -> World
|
||||
overNozzles eff it cr w = neww & creatures . ix cid . crInv . ix i . itParams . sprayerNozzles .~ newNozzles
|
||||
where
|
||||
cid = _crID cr
|
||||
i = _crInvSel $ _creatures w IM.! cid
|
||||
(neww,newNozzles) = mapAccumR (eff cr) w $ _sprayerNozzles (_itParams it)
|
||||
|
||||
overNozzle :: (Creature -> World -> World)
|
||||
-> Creature -> World -> Nozzle -> (World, Nozzle)
|
||||
overNozzle eff cr w nz = (eff (cr & crDir +~ wa) w & randGen .~ g,nz & nzCurrentWalkAngle .~ wa)
|
||||
where
|
||||
(walkamount, g) = randomR (-aspeed,aspeed) (_randGen w)
|
||||
aspeed = _nzWalkSpeed nz
|
||||
maxa = _nzMaxWalkAngle nz
|
||||
wa = min maxa $ max (negate maxa) (_nzCurrentWalkAngle nz + walkamount)
|
||||
|
||||
aFlame :: Creature -> World -> World
|
||||
aFlame cr w = w & particles %~ (aFlameParticle t pos vel (Just cid) :)
|
||||
aFlame cr w = w & particles .:~ aFlameParticle t pos vel (Just cid)
|
||||
where
|
||||
(t,_) = randomR (99,101) (_randGen w)
|
||||
cid = _crID cr
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
module Dodge.Item.Weapon.ZoomScope where
|
||||
import Dodge.Data
|
||||
import LensHelp
|
||||
|
||||
zoomLongGun :: Float -> Creature -> Item -> Item
|
||||
zoomLongGun x _
|
||||
| x > 0 = itScope . scopeZoomChange %~ (max 5 . (+5))
|
||||
| x < 0 = itScope . scopeZoomChange %~ (min (-5) . subtract 5)
|
||||
| otherwise = id
|
||||
Reference in New Issue
Block a user