Improve weapon handle offsets

This commit is contained in:
2023-05-28 13:59:58 +01:00
parent 4b35a683af
commit 7fc36ab028
8 changed files with 23 additions and 22 deletions
+8 -8
View File
@@ -9,14 +9,14 @@ import Geometry
import ShapePicture import ShapePicture
-- the position of a weapon handle -- the position of a weapon handle
aimingWeaponHandlePos :: Creature -> Item -> Float aimingWeaponHandlePos :: Creature -> Item -> Point2
aimingWeaponHandlePos cr it = case it ^? itUse . heldAim . aimStance of aimingWeaponHandlePos _ it = case it ^? itUse . heldAim . aimStance of
Just TwoHandTwist -> -5 Just TwoHandTwist -> 0
Just OneHand -> 14 Just OneHand -> V2 10 0
Just TwoHandFlat -> 1.2 * _crRad cr Just TwoHandFlat -> V2 10 0
Nothing -> 0 Nothing -> 0
aimingWeaponZeroPos :: Creature -> Item -> Float aimingWeaponZeroPos :: Creature -> Item -> Point2
aimingWeaponZeroPos cr it = aimingWeaponZeroPos cr it =
aimingWeaponHandlePos cr it aimingWeaponHandlePos cr it
- fromMaybe 0 (it ^? itUse . heldAim . aimHandlePos) - fromMaybe 0 (it ^? itUse . heldAim . aimHandlePos)
@@ -24,12 +24,12 @@ aimingWeaponZeroPos cr it =
aimingMuzzlePos :: Creature -> Item -> [Point2] aimingMuzzlePos :: Creature -> Item -> [Point2]
aimingMuzzlePos cr it = fmap ((+ zp) . _mzPos) (it ^.. itUse . heldAim . aimMuzzles . folded) aimingMuzzlePos cr it = fmap ((+ zp) . _mzPos) (it ^.. itUse . heldAim . aimMuzzles . folded)
where where
zp = V2 (aimingWeaponZeroPos cr it) 0 zp = aimingWeaponZeroPos cr it
aimingMuzzleOff :: Creature -> Item -> [Point2] aimingMuzzleOff :: Creature -> Item -> [Point2]
aimingMuzzleOff cr it = fmap (rotateV (_crDir cr) . (+ zp) . _mzPos) (it ^.. itUse . heldAim . aimMuzzles . folded) aimingMuzzleOff cr it = fmap (rotateV (_crDir cr) . (+ zp) . _mzPos) (it ^.. itUse . heldAim . aimMuzzles . folded)
where where
zp = V2 (aimingWeaponZeroPos cr it) 0 zp = aimingWeaponZeroPos cr it
aimingMuzzleLength :: Creature -> Item -> Float aimingMuzzleLength :: Creature -> Item -> Float
aimingMuzzleLength cr it = head (aimingMuzzlePos cr it) ^. _x aimingMuzzleLength cr it = head (aimingMuzzlePos cr it) ^. _x
+1 -1
View File
@@ -72,7 +72,7 @@ data AimParams = AimParams
, _aimRange :: Float , _aimRange :: Float
, _aimZoom :: ItZoom , _aimZoom :: ItZoom
, _aimStance :: AimStance , _aimStance :: AimStance
, _aimHandlePos :: Float , _aimHandlePos :: V2 Float
, _aimMuzzles :: [Muzzle] , _aimMuzzles :: [Muzzle]
} }
--deriving (Eq, Ord, Show, Read) --Generic, Flat) --deriving (Eq, Ord, Show, Read) --Generic, Flat)
+2 -1
View File
@@ -11,7 +11,8 @@ defaultAimParams =
, _aimRange = 0 , _aimRange = 0
, _aimZoom = ItZoom 20 0.2 1 , _aimZoom = ItZoom 20 0.2 1
, _aimStance = OneHand , _aimStance = OneHand
, _aimHandlePos = 10 --, _aimHandlePos = 10
, _aimHandlePos = 3
, _aimMuzzles = [Muzzle (V2 20 0) 0 0] , _aimMuzzles = [Muzzle (V2 20 0) 0 0]
-- , _aimMuzPos = 20 -- , _aimMuzPos = 20
} }
+1
View File
@@ -70,6 +70,7 @@ rifle =
& itUse . heldAim . aimWeight .~ 6 & itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1 & itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5} & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 25 0) 0 0.01]
& itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE & itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE
repeater :: Item repeater :: Item
-1
View File
@@ -33,7 +33,6 @@ bangStick i =
& itDimension . dimCenter .~ V3 5 0 0 & itDimension . dimCenter .~ V3 5 0 0
& itUse . heldDelay . rateMax .~ 8 & itUse . heldDelay . rateMax .~ 8
& itUse . heldMods .~ BangStickMod & itUse . heldMods .~ BangStickMod
& itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 10 0) a 0.01 | a <- spreadAroundCenter i baseStickSpread] & itUse . heldAim . aimMuzzles .~ [Muzzle (V2 10 0) a 0.01 | a <- spreadAroundCenter i baseStickSpread]
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ i & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ i
& itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadPartialInsert 10 1] & itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadPartialInsert 10 1]
+3 -3
View File
@@ -14,13 +14,13 @@ turretItemOffset it tu mc =
transToHandle :: Item -> Point3 -> Point3 transToHandle :: Item -> Point3 -> Point3
transToHandle itm = fromMaybe id $ do transToHandle itm = fromMaybe id $ do
x <- itm ^? itUse . heldAim . aimHandlePos V2 x y <- itm ^? itUse . heldAim . aimHandlePos
return (-.-.- V3 x 0 0) return (-.-.- V3 x y 0)
heldItemOffset :: Item -> Creature -> Point3 -> Point3 heldItemOffset :: Item -> Creature -> Point3 -> Point3
heldItemOffset itm cr heldItemOffset itm cr
| isSelected && _posture (_crStance cr) == Aiming = | isSelected && _posture (_crStance cr) == Aiming =
(+.+.+ V3 (aimingWeaponZeroPos cr itm) 0 shoulderHeight) (+.+.+ aimingWeaponZeroPos cr itm `v2z` shoulderHeight)
| isSelected && isTwoHandFlat = | isSelected && isTwoHandFlat =
(+.+.+ V3 (_crRad cr) 0 handD) (+.+.+ V3 (_crRad cr) 0 handD)
. rotate3 (twoFlatHRot cr) . rotate3 (twoFlatHRot cr)
+5 -4
View File
@@ -59,6 +59,7 @@ module Dodge.Item.Weapon.TriggerType (
blCheck, blCheck,
) where ) where
import Dodge.Creature.HandPos
import Data.Foldable import Data.Foldable
import Data.Maybe import Data.Maybe
import Dodge.Base import Dodge.Base
@@ -456,9 +457,9 @@ withMuzFlareI :: ChainEffect
withMuzFlareI f it cr = withMuzFlareI f it cr =
makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) (cpos `v2z` 20) makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) (cpos `v2z` 20)
-- . muzFlareAt (V4 5 5 0 2) (cpos `v2z` 20) cdir -- . muzFlareAt (V4 5 5 0 2) (cpos `v2z` 20) cdir
. muzFlareAt (V4 5 5 1 3) (cpos `v2z` 20) cdir . muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. muzFlareAt (V4 5 5 1 3) (cpos `v2z` 20) cdir . muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. muzFlareAt (V4 5 5 1 3) (cpos `v2z` 20) cdir . muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. f it cr . f it cr
where where
cdir = _crDir cr cdir = _crDir cr
@@ -634,7 +635,7 @@ duplicateNumBarrels n eff itm cr w = foldr f w (take n $ itm ^?! itUse . heldAim
f brl w' = f brl w' =
eff eff
itm itm
( cr & crPos +~ rotateV (_crDir cr) (_mzPos brl) ( cr & crPos +~ rotateV (_crDir cr) (_mzPos brl + aimingWeaponZeroPos cr itm)
& crDir +~ (_mzRot brl + a) & crDir +~ (_mzRot brl + a)
) )
(w' & randGen .~ g) (w' & randGen .~ g)
+3 -4
View File
@@ -35,7 +35,6 @@ module Shape (
overPosSH, overPosSH,
upperCylinder, upperCylinder,
upperRounded, upperRounded,
xCylinder',
) where ) where
import Color import Color
@@ -130,10 +129,10 @@ upperPrismPoly ::
upperPrismPoly size shad h ps = prismPoly size shad (map (addZ h) ps) (map (addZ 0) ps) upperPrismPoly size shad h ps = prismPoly size shad (map (addZ h) ps) (map (addZ 0) ps)
xCylinderST :: Float -> Float -> Shape xCylinderST :: Float -> Float -> Shape
xCylinderST = xCylinder' Small Typical xCylinderST = xCylinder Small Typical
xCylinder' :: Size -> Importance -> Float -> Float -> Shape xCylinder :: Size -> Importance -> Float -> Float -> Shape
xCylinder' size shad r x = xCylinder size shad r x =
translateSHz r . rotateSHq (V3 0 1 0) (pi / 2) . upperCylinder size shad x $ translateSHz r . rotateSHq (V3 0 1 0) (pi / 2) . upperCylinder size shad x $
[ V2 r r [ V2 r r
, V2 (- r / 2) (r / 2) , V2 (- r / 2) (r / 2)