Work on held item usage

This commit is contained in:
2023-05-27 12:32:09 +01:00
parent 4cfb7d431a
commit ec8317c14e
19 changed files with 150 additions and 173 deletions
+4 -4
View File
@@ -121,7 +121,7 @@ bangStickAmmoPos :: Int -> Item -> AmmoPosition
bangStickAmmoPos _ itm =
Bullets
[(rotate3z a (V3 5 0 3), Q.axisAngle (V3 0 0 1) a)
| a <- map _barlRot (itm ^?! itParams . gunBarrels)]
| a <- map _mzRot (itm ^?! itUse . heldAim . aimMuzzles)]
volleygunAmmoPos :: Int -> AmmoPosition
volleygunAmmoPos i =
@@ -208,9 +208,9 @@ modulesSPic it _ imt = case imt of
_ -> mempty
baseStickShapeX :: Item -> Int -> Shape
baseStickShapeX it _ = foldMap f (it ^?! itParams . gunBarrels)
baseStickShapeX it _ = foldMap f (it ^?! itUse . heldAim . aimMuzzles)
where
f brl = rotateSH (_barlRot brl) baseStickShape
f brl = rotateSH (_mzRot brl) baseStickShape
baseStickShape :: Shape
baseStickShape = colorSH green $ xCylinderST 3 10
@@ -219,7 +219,7 @@ bangConeShape :: Float -> Shape
bangConeShape x =
colorSH cyan $
xCylinderST 3 x
<> upperPrismPolyST 6 (reverse $ rectNSWE 4 (-4) x (10 + x))
<> upperPrismPolyST 6 ( rectNSWE 4 (-4) x (10 + x))
defSPic :: SPic
defSPic = noPic $ colorSH green $ upperPrismPolyST 3 $ square 4
+6 -4
View File
@@ -31,7 +31,8 @@ teslaGun =
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimStance .~ TwoHandFlat
& itUse . heldAim . aimHandlePos .~ 4
& itUse . heldAim . aimMuzPos .~ 4
-- & itUse . heldAim . aimMuzPos .~ 4
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 4 0) 0 0]
& itType . iyBase .~ HELD TESLAGUN
lasGun :: Item
@@ -63,7 +64,8 @@ lasGun =
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 30
-- & itUse . heldAim . aimMuzPos .~ 30
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0]
& itType . iyBase .~ HELD LASGUN
lasGunTweak :: TweakParam
@@ -94,7 +96,7 @@ tractorGun =
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 30
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0]
& itType . iyBase .~ HELD TRACTORGUN
tractorGunTweak :: TweakParam
@@ -149,7 +151,7 @@ dualBeam :: Item
dualBeam =
lasGun
& itType . iyBase .~ HELD DUALBEAM
& itUse . heldAim . aimMuzPos .~ 0
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0]
& itParams
.~ DualBeam
{ _phaseV = 1
+4 -8
View File
@@ -22,7 +22,6 @@ defaultBangCane =
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _gunBarrels = [GunBarrel 0 0 0.01]
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
@@ -33,7 +32,7 @@ defaultBangCane =
& itUse . heldMods .~ BangCaneMod
& itUse . heldAim . aimStance .~ OneHand
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 15
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 0) 0 0.01]
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 1
& itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadPartialInsert 10 1]
@@ -47,20 +46,17 @@ volleyGun i =
& itUse . heldAim . aimStance .~ TwoHandFlat
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 15
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 3]
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ i
& itParams
.~ BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _gunBarrels = [GunBarrel 0 0 0.01]
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
}
& itParams . gunBarrels
.~ [ GunBarrel (V2 0 x) 0 0.1 | x <- spreadAroundCenter i 3]
& itParams . torqueAfter .~ 0.48 + 0.2 * fromIntegral i
& itType . iyBase .~ HELD (VOLLEYGUN i)
@@ -96,7 +92,7 @@ burstRifle :: Item
burstRifle =
repeater
& itType . iyBase .~ HELD BURSTRIFLE
& itParams . gunBarrels . ix 0 . barlInaccuracy .~ 0.05
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0.05
& itUse . heldDelay . rateMax .~ 18
& itUse . heldMods .~ BurstRifleMod
@@ -124,12 +120,12 @@ miniGunX i =
autoRifle
& itUse .~ miniGunUse i
& itUse . heldAim . aimTurnSpeed .~ 0.5
& itUse . heldAim . aimMuzzles .~ replicate i (Muzzle (V2 15 0) 0 0.05)
& itParams
.~ BulletShooter
{ _muzVel = 1
, _rifling = 0.9
, _bore = 2
, _gunBarrels = replicate i (GunBarrel 0 0 0.05)
, _recoil = 10
, _torqueAfter = 0
, _randomOffset = 10
+8 -8
View File
@@ -1,10 +1,11 @@
module Dodge.Item.Held.Cone
where
import Dodge.Default.Item
import Dodge.Data.Item
import Dodge.Reloading.Action
module Dodge.Item.Held.Cone where
import Control.Lens
import Dodge.Data.Item
import Dodge.Default.Item
import Dodge.Reloading.Action
import Geometry.Data
import Linear
bangCone :: Item
bangCone =
@@ -14,7 +15,6 @@ bangCone =
{ _muzVel = 0.7
, _rifling = 0.8
, _bore = 5
, _gunBarrels = [GunBarrel 0 0 0.5]
, _recoil = 150
, _torqueAfter = 0.1
, _randomOffset = 12
@@ -25,7 +25,7 @@ bangCone =
& itUse . heldDelay . rateMax .~ 20
& itUse . heldMods .~ BangConeMod
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 15
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 0) 0 0.5]
& itType . iyBase .~ HELD BANGCONE
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 5
& itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 5, loadInsert 20, loadPrime 5]
@@ -38,7 +38,7 @@ blunderbuss =
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 30
& itUse . heldAim . aimMuzzles . ix 0 . mzPos . _x .~ 30
& itType . iyBase .~ HELD BLUNDERBUSS
grapeCannon :: Int -> Item
+2 -1
View File
@@ -30,7 +30,8 @@ launcher =
& itUse . heldAim . aimRange .~ 0.5
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 20
-- & itUse . heldAim . aimMuzPos .~ 20
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 20 0) 0 0]
& itUse . heldConsumption . laAmmoType
.~ ProjectileAmmo
{ _amPayload = ExplosionPayload
+3 -4
View File
@@ -22,7 +22,6 @@ bangRod =
{ _muzVel = 0.8
, _rifling = 1
, _bore = 2
, _gunBarrels = [GunBarrel 0 0 0.1]
, _recoil = 50
, _torqueAfter = 0.3
, _randomOffset = 0
@@ -39,7 +38,7 @@ bangRod =
& itUse . heldAim . aimStance .~ OneHand
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 30
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0.1]
& itUse . heldConsumption . laAmmoType .~ hvBulletAmmo
elephantGun :: Item
@@ -47,7 +46,7 @@ elephantGun =
bangRod
& itType . iyBase .~ HELD ELEPHANTGUN
& itUse . heldAim . aimStance .~ TwoHandTwist
& itParams . gunBarrels .~ [GunBarrel 0 0 0.05]
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0.05
& itUse . heldMods .~ ElephantGunMod
& itParams . recoil .~ 50
& itParams . torqueAfter .~ 0.1
@@ -68,7 +67,7 @@ sniperRifle :: Item
sniperRifle =
elephantGun
& itType . iyBase .~ HELD SNIPERRIFLE
& itParams . gunBarrels .~ [GunBarrel 0 0 0]
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0
& itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 0.5, _izMin = 0.5,_izFac = 1}
& itUse . heldScroll .~ HeldScrollZoom -- zoomLongGun
& itScope .~ ZoomScope (V2 0 0) 1 0.5 False
+1 -1
View File
@@ -93,7 +93,7 @@ flameThrower =
& itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 5, _izMin = 1.5}
& itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimHandlePos .~ 0
& itUse . heldAim . aimMuzPos .~ 18
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 18 0) 0 0]
& itUse . heldConsumption
.~ ( defaultLoadable
& laSource . _InternalSource . iaMax .~ 250
+2 -3
View File
@@ -23,7 +23,6 @@ bangStick i =
{ _muzVel = 0.8
, _rifling = 0.8
, _bore = 2
, _gunBarrels = [GunBarrel 0 a 0.01 | a <- spreadAroundCenter i baseStickSpread]
, _recoil = 25
, _torqueAfter = 0.18 + 0.02 * fromIntegral i
, _randomOffset = 0
@@ -35,7 +34,7 @@ bangStick i =
& itUse . heldDelay . rateMax .~ 8
& itUse . heldMods .~ BangStickMod
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 10
& itUse . heldAim . aimMuzzles .~ [Muzzle 10 a 0.01 | a <- spreadAroundCenter i baseStickSpread]
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ i
& itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadPartialInsert 10 1]
@@ -62,11 +61,11 @@ pistol =
)
& itUse . heldDelay . rateMax .~ 6
& itUse . heldMods .~ PistolMod
& itUse . heldAim . aimMuzzles .~ [Muzzle 0 0 0.05]
& itParams
%~ ( (muzVel .~ 0.8)
. (rifling .~ 0.8)
. (bore .~ 2)
. (gunBarrels .~ [GunBarrel 0 0 0.05])
. (recoil .~ 10)
. (torqueAfter .~ 0.2)
)
+4 -4
View File
@@ -1,10 +1,11 @@
module Dodge.Item.Held.Utility where
import Linear
import Dodge.Default.Item
import Color
import Control.Lens
import Dodge.Data.Item
import Geometry.Data
--import Geometry.Data
flatShield :: Item
flatShield =
@@ -14,7 +15,6 @@ flatShield =
& itUse . heldAim . aimTurnSpeed .~ 0.5
& itUse . heldAim . aimStance .~ TwoHandFlat
& itUse . heldAim . aimHandlePos .~ 0
& itUse . heldAim . aimMuzPos .~ 0
& itInvSize .~ 3
& itType . iyBase .~ HELD FLATSHIELD
@@ -35,7 +35,7 @@ binoculars =
& itScope .~ ZoomScope (V2 0 0) 1 0.5 False
& itType . iyBase .~ HELD BINOCULARS
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 10
-- & itUse . heldAim . aimMuzPos .~ 10
& itUse . heldAim . aimStance .~ TwoHandFlat
& itUse . heldScroll .~ HeldScrollZoom -- zoomLongGun
& itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 0.5, _izMin = 0.5, _izFac = 1}
@@ -47,7 +47,7 @@ torch =
& itEffect . ieInv .~ EffectWhileHeld CreateHeldLight
& itType . iyBase .~ HELD TORCH
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 10
& itUse . heldAim . aimMuzzles . ix 0 . mzPos . _x .~ 10
forceFieldGun :: Item
forceFieldGun =
+1 -1
View File
@@ -165,7 +165,7 @@ shootDualLaser it cr w =
itid = _itID it
dir = _crDir cr
pos = _crPos cr +.+ aimlength *.* unitVectorAtAngle dir
aimlength = aimingMuzzlePos cr it
aimlength = aimingMuzzleLength cr it
gap = _dbGap . _itParams $ it
posl = pos +.+ (- gap) *.* vNormal (unitVectorAtAngle dir)
posr = pos +.+ gap *.* vNormal (unitVectorAtAngle dir)
+1 -1
View File
@@ -19,7 +19,7 @@ shootShatter it cr w =
Opaque {} -> True
SeeThrough -> True
_ -> False
sp = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
sp = _crPos cr +.+ aimingMuzzleLength cr it *.* unitVectorAtAngle dir
dir = _crDir cr
ep = sp +.+ 200 *.* unitVectorAtAngle dir
+60 -86
View File
@@ -44,30 +44,24 @@ module Dodge.Item.Weapon.TriggerType (
withSidePushAfterI,
withSidePushI,
withWarmUp,
--spreadNumI,
--spreadLoaded,
repeatOnFrames,
sideEffectOnFrame,
duplicateItem,
duplicateLoadedBarrels,
duplicateLoaded,
duplicateOffsets,
duplicateOffsetsV2,
duplicateOffsetsFocus,
hammerCheckL,
shootL,
useTimeCheck,
ammoCheckI,
applyInaccuracy,
modClock,
blCheck,
) where
import qualified SDL
import Data.Foldable
import Data.Maybe
import Dodge.Base
import Dodge.Creature.HandPos
import Dodge.Creature.Test
import Dodge.Data.World
import Dodge.Inventory.Lock
@@ -76,10 +70,11 @@ import Dodge.Reloading
import Dodge.SoundLogic
import Dodge.WorldEvent
import Geometry
import qualified IntMapHelp as IM
import LensHelp
import RandomHelp
import qualified SDL
import Sound.Data
import qualified IntMapHelp as IM
type ChainEffect =
(Item -> Creature -> World -> World) ->
@@ -137,14 +132,16 @@ withThickSmokeI eff item cr w =
-- fire.
ammoCheckI :: ChainEffect
ammoCheckI eff itm cr w = case itm ^? itUse . heldConsumption . laSource of
Just (InternalSource ia) | _iaLoaded ia <= 0 || not (_iaPrimed ia)
-> failsound w
Just AboveSource | fromMaybe True $ do
Just (InternalSource ia)
| _iaLoaded ia <= 0 || not (_iaPrimed ia) ->
failsound w
Just AboveSource
| fromMaybe True $ do
invid <- itm ^? itLocation . ipInvID
x <- cr ^? crInv . ix (invid - 1) . itUse . equipEffect . eeUse . euseAmmoAmount
return $ x <= 0
-> failsound w
_ -> eff itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
return $ x <= 0 ->
failsound w
_ -> eff itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
where
failsound = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> soundStart (CrReloadSound (_crID cr)) (_crPos cr) click1S Nothing
@@ -360,11 +357,12 @@ useAmmoAmount amAmount eff item cr =
useAmmoAmount' :: Int -> Int -> IM.IntMap Item -> IM.IntMap Item
useAmmoAmount' itref x inv = case inv ^? ix itref . itUse . heldConsumption . laSource of
Just InternalSource{}
-> inv & ix itref . itUse . heldConsumption . laSource . _InternalSource . iaLoaded -~ x
Just AboveSource
-> inv & ix (itref - 1) . itUse . equipEffect . eeUse . euseAmmoAmount -~ x
Just InternalSource{} ->
inv & ix itref . itUse . heldConsumption . laSource . _InternalSource . iaLoaded -~ x
Just AboveSource ->
inv & ix (itref - 1) . itUse . equipEffect . eeUse . euseAmmoAmount -~ x
_ -> inv
-- . crInv . ix itRef . itUse . heldConsumption . laSource
{- |
@@ -380,7 +378,6 @@ useTimeCheck f item cr w = case item ^? itUse . heldDelay . rateTime of
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
userate = fromMaybe 0 $ item ^? itUse . heldDelay . rateMax
-- | Applies a world effect after a hammer position check.
blCheck :: ChainEffect
blCheck f it cr w = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
@@ -457,47 +454,44 @@ modClock n chainEff eff it cr w
withMuzFlareI :: ChainEffect
withMuzFlareI f it cr w =
makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) flashPos
. muzFlareAt (V4 5 5 0 2) flarePos cdir
makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) (cpos `v2z` 20)
. muzFlareAt (V4 5 5 0 2) (cpos `v2z` 20) cdir
$ 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 cr it +.+.+ V3 0 0 20)
flashPos = addZ 0 (_crPos cr) +.+.+ rotate3z cdir (muzzleOffset cr it +.+.+ V3 5 0 20)
-- muzzleOffset = V3 (_muzPos (_dimPortage (_itDimension it))) 0 0
-- flarePos = addZ 0 (_crPos cr) +.+.+ rotate3z cdir (muzzleOffset cr it +.+.+ V3 0 0 20)
-- flashPos = addZ 0 (_crPos cr) +.+.+ rotate3z cdir (muzzleOffset cr it +.+.+ V3 5 0 20)
-- -- muzzleOffset = V3 (_muzPos (_dimPortage (_itDimension it))) 0 0
cdir = _crDir cr
cpos = _crPos cr
muzzleOffset :: Creature -> Item -> Point3
muzzleOffset cr it = V3 (holdOffset + 5 + _aimMuzPos dimPort - _aimHandlePos dimPort) 0 0
where
dimPort = _heldAim $ _itUse it
holdOffset
| crInAimStance OneHand cr = 10
| otherwise = 0
--muzzleOffset :: Creature -> Item -> Point3
--muzzleOffset cr it = V3 (holdOffset + 5 + _aimMuzPos dimPort - _aimHandlePos dimPort) 0 0
-- where
-- dimPort = _heldAim $ _itUse it
-- holdOffset
-- | crInAimStance OneHand cr = 10
-- | otherwise = 0
withMuzPos :: (Point3 -> World -> World) -> ChainEffect
withMuzPos = withMuzPosShift (V2 0 0)
withMuzPosShift :: Point2 -> (Point3 -> World -> World) -> ChainEffect
withMuzPosShift p g f it cr w =
g (pos `v2z` 20) $
f it cr w
withMuzPosShift p g f it cr = g thepos . f it cr
where
pos =
_crPos cr
+.+ rotateV dir p
+.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
dir = _crDir cr
thepos = (_crPos cr `v2z` 20)
--thepos = (pos `v2z` 20)
--pos =
-- _crPos cr
-- +.+ rotateV dir p
-- +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
--dir = _crDir cr
crAtMuzPos :: ChainEffect
crAtMuzPos f it cr = f it (cr & crPos +.+.~ (aimingMuzzlePos cr it *.* unitVectorAtAngle (_crDir cr)))
{- | Applies the effect to a randomly rotated creature,
- rotation amount given by inaccuracy in itParams
-}
applyInaccuracy :: ChainEffect
applyInaccuracy f it = withRandomDirI acc f it
where
acc = fromMaybe 0 $ it ^? itParams . gunBarrels . ix 0 . barlInaccuracy
--crAtMuzPos f it cr = f it (cr & crPos +.+.~ (aimingMuzzlePos cr it *.* unitVectorAtAngle (_crDir cr)))
crAtMuzPos f it cr = f it cr
-- | Applies the effect to a randomly rotated creature.
withRandomDirI ::
@@ -612,27 +606,6 @@ withTorqueAfter feff item cr w
(rot, g) = randomR (- torque, torque) $ _randGen w
torque = fromMaybe 0 $ item ^? itParams . torqueAfter
--spreadNumI :: ChainEffect
--spreadNumI eff item cr w = foldr f w dirs
-- where
-- dirs =
-- zipWith
-- (+)
-- [- spread, - spread + (2 * spread / fromIntegral numBul) .. spread]
-- (randomRs (0, spread / fromIntegral numBul) (_randGen w))
-- f dir = eff item (cr & crDir +~ dir)
-- spread = _spreadAngle . _brlSpread . _gunBarrels $ _itParams item
-- numBul = _brlNum . _gunBarrels $ _itParams item
--spreadLoaded :: ChainEffect
--spreadLoaded eff item cr w = foldr f w dirs
-- where
-- cd = 0.5 * spread * fromIntegral (numBulLoaded -1)
-- dirs = subtract cd . (spread *) . fromIntegral <$> [0 .. numBulLoaded - 1]
-- f dir = eff item (cr & crDir +~ dir)
-- spread = _spreadAngle . _brlSpread . _gunBarrels $ _itParams item
-- numBulLoaded = item ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded
sideEffectOnFrame ::
Int ->
(Item -> Creature -> WdWd) ->
@@ -669,12 +642,19 @@ duplicateLoaded eff it cr w = foldr f w [1 .. numBul]
numBul = it ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded
duplicateLoadedBarrels :: ChainEffect
duplicateLoadedBarrels eff itm cr w = foldr f w (take numbul $ itm ^?! itParams . gunBarrels)
duplicateLoadedBarrels eff itm cr w = foldr f w (take numbul $ itm ^?! itUse . heldAim . aimMuzzles)
where
numbul = itm ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded
f brl = eff itm (cr & crPos +~ _barlPos brl
& crDir +~ _barlRot brl
) -- worry about inaccuracy later
f brl w' =
eff
itm
( cr & crPos +~ (rotateV (_crDir cr) (_mzPos brl))
& crDir +~ (_mzRot brl + a)
)
(w' & randGen .~ g)
where
inacc = _mzInaccuracy brl
(a,g) = randomR (-inacc,inacc) $ _randGen w'
duplicateOffsetsFocus :: [Float] -> ChainEffect
duplicateOffsetsFocus xs eff item cr w = foldr f w poss
@@ -686,13 +666,14 @@ duplicateOffsetsFocus xs eff item cr w = foldr f w poss
cr
& crPos %~ (+.+ pos)
& crDir .~ thedir pos
thedir pos
| dist (mouseWorldPos (w ^. input) (w ^. wCam)) (_crPos cr) < aimingMuzzlePos cr item =
argV
( _crPos cr +.+ aimingMuzzlePos cr item *.* unitVectorAtAngle (_crDir cr)
-.- (_crPos cr +.+ pos)
)
| otherwise = argV (mouseWorldPos (w ^. input) (w ^. wCam) -.- (_crPos cr +.+ pos))
--thedir pos
-- | dist (mouseWorldPos (w ^. input) (w ^. wCam)) (_crPos cr) < aimingMuzzlePos cr item =
-- argV
-- ( _crPos cr +.+ aimingMuzzlePos cr item *.* unitVectorAtAngle (_crDir cr)
-- -.- (_crPos cr +.+ pos)
-- )
-- | otherwise = argV (mouseWorldPos (w ^. input) (w ^. wCam) -.- (_crPos cr +.+ pos))
thedir pos = argV (mouseWorldPos (w ^. input) (w ^. wCam) -.- (_crPos cr +.+ pos))
duplicateItem :: (Item -> [Item]) -> ChainEffect
duplicateItem fit eff itm cr w = foldr f w (fit itm)
@@ -704,10 +685,3 @@ duplicateOffsetsV2 xs eff item cr w = foldr f w poss
where
poss = map (rotateV (_crDir cr)) xs
f pos = eff item (cr & crPos +.+.~ pos)
duplicateOffsets :: [Float] -> ChainEffect
duplicateOffsets xs eff item cr w = foldr f w poss
where
poss :: [V2 Float]
poss = map (rotateV (_crDir cr) . V2 0) xs
f pos = eff item (cr & crPos +.+.~ pos)