Make item handle position slightly more sensible
This commit is contained in:
@@ -116,8 +116,7 @@ data AimParams = AimParams
|
||||
, _aimTurnSpeed :: Float
|
||||
, _aimRange :: Float
|
||||
, _aimZoom :: ItZoom
|
||||
-- , _aimStance :: AimStance
|
||||
, _aimHandlePos :: V2 Float
|
||||
-- , _aimHandlePos :: V2 Float
|
||||
, _aimMuzzles :: [Muzzle]
|
||||
}
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
@@ -13,7 +13,7 @@ defaultAimParams =
|
||||
, _aimTurnSpeed = 1
|
||||
, _aimRange = 0
|
||||
, _aimZoom = defaultItZoom
|
||||
, _aimHandlePos = V2 3 0
|
||||
--, _aimHandlePos = V2 3 0
|
||||
, _aimMuzzles =
|
||||
[ Muzzle
|
||||
{ _mzPos = V2 20 0
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
module Dodge.Item.HeldOffset (
|
||||
turretItemOffset,
|
||||
twoFlatHRot,
|
||||
@@ -8,7 +9,6 @@ module Dodge.Item.HeldOffset (
|
||||
|
||||
import Dodge.Item.AimStance
|
||||
import qualified Quaternion as Q
|
||||
import Data.Maybe
|
||||
import Dodge.Data.Creature
|
||||
import Dodge.Data.Machine
|
||||
import Geometry
|
||||
@@ -20,9 +20,9 @@ turretItemOffset it tu mc =
|
||||
. transToHandle it
|
||||
|
||||
transToHandle :: Item -> Point3 -> Point3
|
||||
transToHandle itm = fromMaybe id $ do
|
||||
V2 x y <- itm ^? itUse . heldAim . aimHandlePos
|
||||
return (-.-.- V3 x y 0)
|
||||
transToHandle itm = (-.-.- V3 x y 0)
|
||||
where
|
||||
V2 x y = handlePos itm
|
||||
|
||||
heldItemOrient2D :: Item -> Creature -> Point2 -> Float -> (Point2, Float)
|
||||
heldItemOrient2D itm cr p a = (V2 x y, argV . Q.qToV2 $ q )
|
||||
@@ -34,11 +34,11 @@ heldItemRelativeOrient
|
||||
heldItemRelativeOrient itm cr (p,q)
|
||||
| Aiming {} <- _posture (_crStance cr) =
|
||||
(p + aimingWeaponZeroPos cr itm `v2z` shoulderHeight, Q.qID * q)
|
||||
| isTwoHandFlat =
|
||||
| TwoHandFlat <- aStance itm =
|
||||
( V3 (_crRad cr) 0 handD + rotate3 (twoFlatHRot cr) (transToHandle itm p)
|
||||
, Q.axisAngle (V3 0 0 1) (twoFlatHRot cr) * q
|
||||
)
|
||||
| isOneHand =
|
||||
| OneHand <- aStance itm =
|
||||
( V3 (_crRad cr * 0.7 + handPos) (_crRad cr * negate 0.7) handD
|
||||
+ transToHandle itm p
|
||||
, Q.qID * q
|
||||
@@ -53,23 +53,15 @@ heldItemRelativeOrient itm cr (p,q)
|
||||
handPos = case cr ^? crStance . carriage of
|
||||
Just (Walking x LeftForward) -> f x * 50 -2
|
||||
_ -> 0 - 2
|
||||
isOneHand = aStance itm == OneHand
|
||||
-- itm ^? itUseAimStance == Just OneHand
|
||||
-- || isNothing (itm ^? itUseAimStance)
|
||||
isTwoHandFlat = aStance itm == TwoHandFlat
|
||||
--itm ^? itUseAimStance == Just TwoHandFlat
|
||||
--itUseAimStance = itUse . heldAim . aimStance
|
||||
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
|
||||
sLen = _strideLength $ _crStance cr
|
||||
|
||||
aimingWeaponZeroPos :: Creature -> Item -> Point2
|
||||
aimingWeaponZeroPos cr it =
|
||||
aimingWeaponHandlePos cr it
|
||||
- fromMaybe 0 (it ^? itUse . heldAim . aimHandlePos)
|
||||
aimingWeaponZeroPos cr it = aimStanceHandlePos cr it - handlePos it
|
||||
|
||||
-- the position of a weapon handle
|
||||
aimingWeaponHandlePos :: Creature -> Item -> Point2
|
||||
aimingWeaponHandlePos _ it = case aStance it of
|
||||
aimStanceHandlePos :: Creature -> Item -> Point2
|
||||
aimStanceHandlePos _ it = case aStance it of
|
||||
TwoHandUnder -> V2 (-2) 0
|
||||
TwoHandOver -> V2 (-7) 0
|
||||
OneHand -> V2 10 (-2)
|
||||
@@ -92,3 +84,52 @@ strideRot cr = case cr ^? crStance . carriage of
|
||||
|
||||
twoFlatHRot :: Creature -> Float
|
||||
twoFlatHRot = (2 *) . strideRot
|
||||
|
||||
handlePos :: Item -> Point2
|
||||
handlePos itm = case itm ^. itType of
|
||||
HELD hit -> heldHandlePos hit
|
||||
_ -> 0
|
||||
|
||||
heldHandlePos :: HeldItemType -> Point2
|
||||
heldHandlePos = \case
|
||||
BANGSTICK{} -> V2 3 0
|
||||
REWINDER -> V2 3 0
|
||||
TIMESTOPPER -> V2 3 0
|
||||
TIMESCROLLER -> V2 3 0
|
||||
PISTOL -> V2 3 0
|
||||
MACHINEPISTOL -> V2 3 0
|
||||
AUTOPISTOL -> V2 3 0
|
||||
SMG -> V2 3 0
|
||||
BANGCONE -> V2 3 0
|
||||
BLUNDERBUSS -> V2 3 0
|
||||
GRAPECANNON{} -> V2 3 0
|
||||
MINIGUNX{} -> V2 3 0
|
||||
VOLLEYGUN{} -> V2 3 0
|
||||
RIFLE -> V2 3 0
|
||||
ALTERIFLE -> V2 3 0
|
||||
AUTORIFLE -> V2 3 0
|
||||
BURSTRIFLE -> V2 3 0
|
||||
BANGROD -> V2 3 0
|
||||
ELEPHANTGUN -> V2 3 0
|
||||
AMR -> V2 3 0
|
||||
AUTOAMR -> V2 3 0
|
||||
SNIPERRIFLE -> V2 3 0
|
||||
FLAMESPITTER -> V2 3 0
|
||||
FLAMETHROWER -> V2 3 0
|
||||
FLAMETORRENT -> V2 3 0
|
||||
FLAMEWALL -> V2 3 0
|
||||
BLOWTORCH -> V2 3 0
|
||||
SPARKGUN -> V2 3 0
|
||||
TESLAGUN -> V2 3 0
|
||||
LASER -> V2 3 0
|
||||
TRACTORGUN -> V2 3 0
|
||||
RLAUNCHER -> V2 3 0
|
||||
RLAUNCHERX{} -> V2 3 0
|
||||
GLAUNCHER -> V2 3 0
|
||||
POISONSPRAYER -> V2 3 0
|
||||
SHATTERGUN -> V2 3 0
|
||||
TORCH -> V2 3 0
|
||||
FLATSHIELD -> V2 3 0
|
||||
KEYCARD {} -> V2 3 0
|
||||
BLINKER -> V2 3 0
|
||||
BLINKERUNSAFE -> V2 3 0
|
||||
|
||||
Reference in New Issue
Block a user