Move toward adding multiple equipable items that are not directly usable

This commit is contained in:
2021-12-08 17:09:24 +00:00
parent 9f6e5af991
commit a9139db0a8
22 changed files with 260 additions and 137 deletions
+17 -9
View File
@@ -1,6 +1,7 @@
module Dodge.Item.Weapon.BulletGun.Cane
( bangCane
, bangCaneX
, repeater
, rifle
, autoRifle
, assaultRifle
@@ -69,16 +70,12 @@ bangCane = defaultGun
,_muzPos = 20
}
, _dimSPic = \it -> noPic $ baseCaneShape
<> caneClip it
<> makeSingleClipAt (V3 5 0 3) it
}
} & itUse . useAim . aimSpeed .~ 0.4
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ OneHand
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
caneClip :: Item -> Shape
caneClip it = case it ^? itConsumption . ammoLoaded of
Just 0 -> mempty
_ -> translateSH (V3 5 0 3) $ upperPrismPoly 1 $ square 1.5
bangCaneX :: Int -> Item
bangCaneX i = bangCane
{ _itName = "BANGCANEx"++show i
@@ -129,7 +126,6 @@ caneClipX i it = case it ^? itConsumption . ammoLoaded of
[0..la-1]
_ -> mempty
rifle :: Item
rifle = bangCane
{ _itDimension = ItemDimension
@@ -139,20 +135,32 @@ rifle = bangCane
{_handlePos = 5
,_muzPos = 25
}
, _dimSPic = \it -> noPic $ baseCaneShape
<> makeClipAt 0 (V3 10 (-2) 0) it
, _dimSPic = \it -> noPic $ baseRifleShape
<> makeSingleClipAt (V3 5 0 3) it
}
}
& itUse . useAim . aimStance .~ TwoHandTwist
& itName .~ "RIFLE"
& itType .~ RIFLE
& itConsumption . ammoMax .~ 15
& itConsumption . ammoMax .~ 1
repeater :: Item
repeater = rifle
& itName .~ "REPEATER"
& itType .~ REPEATER
& itConsumption . reloadType .~ ActiveClear
& itConsumption . reloadTime .~ 80
& itConsumption . ammoMax .~ 15
& itDimension . dimSPic .~ (\it -> noPic $ baseRifleShape
<> makeTinClipAt 0 (V3 10 (-2) 0) it
)
baseCaneShape :: Shape
baseCaneShape = colorSH red $ upperPrismPoly 3 $ rectXH 15 2
baseRifleShape :: Shape
baseRifleShape = colorSH red $ upperPrismPoly 3 $ rectXH 25 2
autoRifle :: Item
autoRifle = rifle
+7 -2
View File
@@ -5,8 +5,13 @@ import Geometry
import Data.Maybe
import Control.Lens
makeClipAt :: Float -> Point3 -> Item -> Shape
makeClipAt r p it = translateSH p . overPosSH (rotate3z r) $ upperPrismPoly 1 $ rectNSEW 0 (-y) (-2) 2
makeSingleClipAt :: Point3 -> Item -> Shape
makeSingleClipAt p it = case it ^? itConsumption . ammoLoaded of
Just 0 -> mempty
_ -> translateSH p $ upperPrismPoly 1 $ square 1.5
makeTinClipAt :: Float -> Point3 -> Item -> Shape
makeTinClipAt r p it = translateSH p . overPosSH (rotate3z r) $ upperPrismPoly 1 $ rectNSEW 0 (-y) (-2) 2
where
y = fromIntegral y' * 0.3
y' = fromMaybe 0 $ it ^? itConsumption . ammoLoaded
+116
View File
@@ -0,0 +1,116 @@
module Dodge.Item.Weapon.BulletGun.Rod
( bangRod
, elephantGun
, amr
, sniperRifle
, machineGun
) where
import Dodge.Data
import Dodge.Item.Weapon.BulletGun.Clip
--import Dodge.ChainEffect
--import Dodge.TweakBullet
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
import Dodge.Item.Weapon.Bullet
import Dodge.Item.Weapon.TriggerType
import Dodge.SoundLogic.LoadSound
import Picture
import Geometry
import ShapePicture
import Shape
--import Sound.Data
import LensHelp
--import Data.Maybe
--import qualified Data.Sequence as Seq
--import Control.Lens
--import Control.Monad.State
--import System.Random
bangRod :: Item
bangRod = defaultGun
{ _itName = "BANGROD"
, _itType = BANGROD
, _itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 1
, _bore = 2
, _gunBarrels = SingleBarrel 0.1
}
, _itUse = useAmmoParamsRate 6 upHammer
[ ammoHammerCheck
, useTimeCheck
, withSoundStart autoGunS
, useAmmoAmount 1
, torqueAfterI 0.3
, applyInaccuracy
, withMuzFlareI
, withRecoilI 50
]
, _itDimension = ItemDimension
{ _dimRad = 12
, _dimCenter = V3 5 0 0
, _dimPortage = HeldItem
{_handlePos = 5
,_muzPos = 30
}
, _dimSPic = \it -> noPic $ baseRodShape
<> makeSingleClipAt (V3 5 0 3) it
}
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 1
, _reloadTime = 20
, _reloadType = ActiveClear
}
}
& itUse . useAim . aimSpeed .~ 0.2
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ OneHand
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
baseRodShape :: Shape
baseRodShape = colorSH orange $ upperPrismPoly 3 $ rectXH 20 2
baseAMRShape :: Shape
baseAMRShape = colorSH orange $ upperPrismPoly 3 $ rectXH 30 2
elephantGun :: Item
elephantGun = bangRod
& itName .~ "ELEPHANTGUN"
& itType .~ ELEPHANTGUN
& itUse . useAim . aimStance .~ TwoHandTwist
& itParams . gunBarrels .~ SingleBarrel 0.05
& itDimension . dimSPic .~ (\it -> noPic $ baseAMRShape
<> makeSingleClipAt (V3 5 0 3) it
)
& itUse . useMods .~
[ ammoHammerCheck
, useTimeCheck
, withSoundStart autoGunS
, useAmmoAmount 1
, torqueAfterI 0.1
, applyInaccuracy
, withMuzFlareI
, withRecoilI 50
]
amr :: Item
amr = elephantGun
& itName .~ "AMR"
& itType .~ AMR
& itConsumption . ammoMax .~ 15
& itDimension . dimSPic .~ (\it -> noPic $ baseAMRShape
<> makeTinClipAt 0 (V3 10 (-2) 0) it
)
sniperRifle :: Item
sniperRifle = elephantGun
& itName .~ "SNIPERRIFLE"
& itType .~ SNIPERRIFLE
& itParams . gunBarrels .~ SingleBarrel 0
machineGun :: Item
machineGun = bangRod
& itName .~ "MACHINEGUN"
& itType .~ MACHINEGUN
+29 -8
View File
@@ -57,9 +57,10 @@ bangStick i = defaultGun
, useTimeCheck
, withSoundItemChoiceStart bangStickSoundChoice
, useAllAmmo
-- , applyInaccuracy
, withMuzFlareI
, torqueAfterI (0.18 + 0.02 * fromIntegral i)
, spreadLoaded
, applyInaccuracy
, withRecoilI 25
]
, _itID = Nothing
@@ -71,8 +72,8 @@ bangStick i = defaultGun
, _bore = 2
, _gunBarrels = MultiBarrel
{_brlNum = i
,_brlSpread = SpreadBarrels 0.2
,_brlInaccuracy = 0
,_brlSpread = SpreadBarrels baseStickSpread
,_brlInaccuracy = 0.05
}
}
, _itTweaks = defaultBulletSelTweak
@@ -84,16 +85,33 @@ bangStick i = defaultGun
{_handlePos = 5
,_muzPos = 10
}
, _dimSPic = \it -> noPic $ baseStickShape
, _dimSPic = \it -> noPic $ baseStickShapeX i
<> stickClip it
}
}
baseStickShapeX :: Int -> Shape
baseStickShapeX i = foldMap f [0..i-1]
where
f j = rotateSH ang baseStickShape
where
ang = fromIntegral j * baseStickSpread - (fromIntegral i - 1) * baseStickSpread * 0.5
baseStickSpread :: Float
baseStickSpread = 0.2
baseSMGShape :: Shape
baseSMGShape = colorSH green $ upperPrismPoly 3 $ rectXH 20 2
baseStickShape :: Shape
baseStickShape = colorSH green $ upperPrismPoly 3 $ rectXH 10 2
stickClip :: Item -> Shape
stickClip it = case it ^? itConsumption . ammoLoaded of
Just 0 -> mempty
_ -> translateSH (V3 5 0 3) $ upperPrismPoly 1 $ square 1.5
Just x | x > 0 -> foldMap f [0..x-1]
_ -> mempty
where
f i = rotateSH ang $ translateSH (V3 5 0 3) $ upperPrismPoly 2 $ square 1.5
where
ang = baseStickSpread * fromIntegral i
- 0.5 * baseStickSpread * fromIntegral (_brlNum (_gunBarrels (_itParams it))-1)
revolver :: Item
revolver = pistol
@@ -133,7 +151,7 @@ machinePistolAfterHamMods =
, useAmmoAmount 1
, withSoundStart tap1S
, applyInaccuracy
, torqueAfterI 0.3
, torqueAfterI 0.2
, withSidePushI 50
, withRecoilI 20
, withMuzFlareI
@@ -175,7 +193,7 @@ pistol = (bangStick 1)
, _gunBarrels = SingleBarrel 0.05
}
, _itTweaks = defaultBulletSelTweak
} & itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> makeClipAt pi (V3 5 2 0) it)
} & itDimension . dimSPic .~ (\it -> noPic $ baseStickShape <> makeTinClipAt pi (V3 5 2 0) it)
autoPistol :: Item
autoPistol = pistol
& itUse . useMods .~ (ammoCheckI : pistolAfterHamMods)
@@ -193,6 +211,9 @@ smg = autoPistol -- & some parameter affecting stability
& itName .~ "SMG"
& itType .~ SMG
& itUse . useAim . aimStance .~ TwoHandTwist
& itDimension . dimPortage . handlePos .~ 2
& itDimension . dimSPic .~ \it -> noPic (baseSMGShape
<> makeTinClipAt 0 (V3 7 (-2) 0) it)
revolverX :: Int -> Item
revolverX i = revolver
{ _itName = "REVx"++show i
+3 -71
View File
@@ -1,10 +1,5 @@
module Dodge.Item.Weapon.BulletGuns
( bangRod
, elephantGun
, amr
, sniperRifle
, machineGun
, bangCone
( bangCone
, blunderbuss
, grapeShotCannon
, grenadeLauncher
@@ -18,9 +13,11 @@ module Dodge.Item.Weapon.BulletGuns
, longGun
, module Dodge.Item.Weapon.BulletGun.Stick
, module Dodge.Item.Weapon.BulletGun.Cane
, module Dodge.Item.Weapon.BulletGun.Rod
) where
import Dodge.Item.Weapon.BulletGun.Stick
import Dodge.Item.Weapon.BulletGun.Cane
import Dodge.Item.Weapon.BulletGun.Rod
--import Dodge.Item.Weapon.BulletGun.Clip
import Dodge.Data
--import Dodge.ChainEffect
@@ -103,71 +100,6 @@ autoGunPic it = noPic $
where
x = fromIntegral $ _ammoLoaded $ _itConsumption it
bangRod :: Item
bangRod = defaultGun
{ _itName = "BANGROD"
, _itType = BANGROD
, _itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 1
, _bore = 2
, _gunBarrels = SingleBarrel 0.1
}
, _itUse = useAmmoParamsRate 6 upHammer
[ ammoHammerCheck
, useTimeCheck
, withSoundStart autoGunS
, useAmmoAmount 1
, torqueAfterI 0.3
, applyInaccuracy
, withMuzFlareI
, withRecoilI 50
]
, _itDimension = ItemDimension
{ _dimRad = 12
, _dimCenter = V3 5 0 0
, _dimPortage = HeldItem
{_handlePos = 5
,_muzPos = 30
}
, _dimSPic = const $ noPic $ colorSH orange $ upperPrismPoly 3 $ rectXH 30 2
}
}
& itConsumption . reloadType .~ ActiveClear
& itUse . useAim . aimSpeed .~ 0.2
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
elephantGun :: Item
elephantGun = bangRod
& itName .~ "ELEPHANTGUN"
& itType .~ ELEPHANTGUN
& itUse . useAim . aimStance .~ TwoHandTwist
& itParams . gunBarrels .~ SingleBarrel 0.05
& itUse . useMods .~
[ ammoHammerCheck
, useTimeCheck
, withSoundStart autoGunS
, useAmmoAmount 1
, torqueAfterI 0.1
, applyInaccuracy
, withMuzFlareI
, withRecoilI 50
]
amr :: Item
amr = elephantGun
& itName .~ "AMR"
& itType .~ AMR
& itConsumption . ammoMax .~ 15
sniperRifle :: Item
sniperRifle = elephantGun
& itName .~ "SNIPERRIFLE"
& itType .~ SNIPERRIFLE
& itParams . gunBarrels .~ SingleBarrel 0
machineGun :: Item
machineGun = bangRod
& itName .~ "MACHINEGUN"
& itType .~ MACHINEGUN
bangCone :: Item
bangCone = defaultGun
+4 -11
View File
@@ -353,12 +353,12 @@ modClock n chainEff eff it cr w
| otherwise = eff it cr w
withMuzFlareI :: ChainEffect
withMuzFlareI f it cr w = makeTlsTimeRadColPos 3 100 (V3 1 1 0.5) flashPos
withMuzFlareI f it cr w = makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) flashPos
. muzFlareAt (V4 5 5 0 2) flarePos cdir
$ f it cr w
where
flarePos = addZ 0 (_crPos cr) +.+.+ rotate3z cdir muzzleOffset
flashPos = addZ 0 (_crPos cr) +.+.+ rotate3z cdir (muzzleOffset +.+.+ V3 5 0 5)
flarePos = addZ 0 (_crPos cr) +.+.+ rotate3z cdir (muzzleOffset +.+.+ V3 0 0 20)
flashPos = addZ 0 (_crPos cr) +.+.+ rotate3z cdir (muzzleOffset +.+.+ V3 5 0 20)
muzzleOffset = V3 (_muzPos (_dimPortage (_itDimension it))) 0 0
cdir = _crDir cr
{- | Applies the effect to a randomly rotated creature,
@@ -452,16 +452,9 @@ spreadLoaded :: ChainEffect
spreadLoaded eff item cr w = foldr f w dirs
where
cd = 0.5 * spread * fromIntegral (numBulLoaded -1)
ds = subtract cd . (spread *) . fromIntegral <$> [0 .. numBulLoaded - 1]
-- dirs = ds
dirs = zipWith (+)
ds
(randomRs (-spread,spread) (_randGen w))
dirs = subtract cd . (spread *) . fromIntegral <$> [0 .. numBulLoaded - 1]
f dir = eff item (cr & crDir +~ dir)
spread = _spreadAngle . _brlSpread . _gunBarrels $ _itParams item
-- numBarrels = _brlNum . _gunBarrels $ _itParams item
-- spread = (_spreadAngle . _brlSpread . _gunBarrels $ _itParams item) * loadedSpreadParam
-- loadedSpreadParam = 0.5 * (fromIntegral (numBulLoaded - numBarrels) + 1)
numBulLoaded = _ammoLoaded $ _itConsumption item
-- pump the updated creature into the chain in later frames