Cleanup, work towards unifying spayguns
This commit is contained in:
@@ -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