Enable duct taping torches to rifles

This commit is contained in:
2022-07-14 11:32:32 +01:00
parent 2cfa3ca3a7
commit 79791d0df2
18 changed files with 109 additions and 154 deletions
+1 -52
View File
@@ -7,15 +7,13 @@ module Dodge.Item.Draw
, heldItemOffset
) where
import Dodge.Data
import Dodge.Item.HeldOffset
import ShapePicture
import Dodge.Creature.HandPos
import Dodge.Item.Equipment.Shape
import Dodge.Item.Draw.SPic
import Geometry
import qualified Data.IntMap.Strict as IM
import Control.Lens
import Data.Maybe
itemEquipPict :: Creature -> Item -> SPic
itemEquipPict cr it = case it ^?! itUse of
@@ -81,53 +79,4 @@ pictureWeaponOnAimItem p' cr posInInv
-- f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
-- sLen = _strideLength $ _crStance cr
heldItemOffset :: Item -> Creature -> Point3 -> Point3
heldItemOffset itm cr
| isSelected && _posture (_crStance cr) == Aiming =
(+.+.+ V3 (aimingWeaponZeroPos cr itm) 0 shoulderD)
| isSelected && isTwoHandFlat
= (+.+.+ V3 (_crRad cr) 0 handD)
. rotate3 (twoFlatHRot cr)
. transToHandle
| isSelected && isOneHand
= (+.+.+ V3 0 0 handD)
. (+.+.+ V3 (_crRad cr * 0.7 + handPos) (_crRad cr * negate 0.7) 0)
. (+.+.+ V3 (-2) 0 0)
. transToHandle
| isSelected
= (+.+.+ V3 0 0 handD)
. (+.+.+ V3 (_crRad cr) 0 0)
. rotate3 (strideRot cr + 1.2)
. (+.+.+ V3 (-5) 0 0)
-- . (+.+.+ V3 (-5) 0 0)
. transToHandle
| otherwise = id
where
transToHandle = fromMaybe id $ do
x <- itm ^? itUse . useAim . aimHandlePos
return (-.-.- V3 x 0 0)
shoulderD = 18
handD = 15
isSelected = _itIsHeld itm
handPos = case cr^? crStance . carriage of
Just (Walking x LeftForward) -> f x * 50
_ -> 0
theIt = itm
isOneHand = theIt ^? itUseAimStance == Just OneHand
|| isNothing (theIt ^? itUseAimStance)
isTwoHandFlat = theIt ^? itUseAimStance == Just TwoHandFlat
itUseAimStance = itUse . useAim . aimStance
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
sLen = _strideLength $ _crStance cr
strideRot :: Creature -> Float
strideRot cr = case cr ^? crStance . carriage of
Just (Walking x LeftForward) -> f x
Just (Walking x RightForward) -> - f x
_ -> 0
where
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
sLen = _strideLength $ _crStance cr
twoFlatHRot :: Creature -> Float
twoFlatHRot cr = 2*strideRot cr
+3 -3
View File
@@ -54,7 +54,7 @@ heldItemSPic :: HeldItemType -> Item -> SPic
heldItemSPic ht it = case ht of
FLATSHIELD -> flatShieldEquipSPic
FORCEFIELDGUN -> defSPic
TORCH -> noPic $ torchShape
TORCH -> noPic torchShape
BANGSTICK i -> noPic $ baseStickShapeX it i <> stickClip it
PISTOL -> noPic $ baseStickShape <> makeTinClipAt pi (V3 5 2 0) it
REVOLVER -> noPic $ baseStickShape <> revolverClip it
@@ -108,7 +108,7 @@ torchShape = colorSH blue
<> translateSHf 0 (-1.5) side
<> translateSHz 2.5 top
<> translateSHz (-0.5) bot
<> translateSHf (-3) 0 back
<> back
where
side = upperPrismPoly 3 $ rectXH 10 0.5
top = upperPrismPoly 0.5 $ rectXH 10 2
@@ -118,7 +118,7 @@ torchShape = colorSH blue
modulesSPic :: Item -> ItemModuleType -> SPic -> SPic
modulesSPic it imt = case imt of
ATTACHTORCH -> (<> noPic (overPosSH (+.+.+ _heldAttachPos (_itUse it)) torchShape))
ATTACHTORCH -> (<> noPic (overPosSH (+.+.+ _dimAttachPos (_itDimension it)) torchShape))
_ -> id
baseStickShapeX :: Item -> Int -> Shape
+58
View File
@@ -0,0 +1,58 @@
module Dodge.Item.HeldOffset where
import Dodge.Data
import Dodge.Creature.HandPos
import Geometry
import LensHelp
import Data.Maybe
heldItemOffset :: Item -> Creature -> Point3 -> Point3
heldItemOffset itm cr
| isSelected && _posture (_crStance cr) == Aiming =
(+.+.+ V3 (aimingWeaponZeroPos cr itm) 0 shoulderD)
| isSelected && isTwoHandFlat
= (+.+.+ V3 (_crRad cr) 0 handD)
. rotate3 (twoFlatHRot cr)
. transToHandle
| isSelected && isOneHand
= (+.+.+ V3 0 0 handD)
. (+.+.+ V3 (_crRad cr * 0.7 + handPos) (_crRad cr * negate 0.7) 0)
. (+.+.+ V3 (-2) 0 0)
. transToHandle
| isSelected
= (+.+.+ V3 0 0 handD)
. (+.+.+ V3 (_crRad cr) 0 0)
. rotate3 (strideRot cr + 1.2)
. (+.+.+ V3 (-5) 0 0)
-- . (+.+.+ V3 (-5) 0 0)
. transToHandle
| otherwise = id
where
transToHandle = fromMaybe id $ do
x <- itm ^? itUse . useAim . aimHandlePos
return (-.-.- V3 x 0 0)
shoulderD = 18
handD = 15
isSelected = _itIsHeld itm
handPos = case cr^? crStance . carriage of
Just (Walking x LeftForward) -> f x * 50
_ -> 0
theIt = itm
isOneHand = theIt ^? itUseAimStance == Just OneHand
|| isNothing (theIt ^? itUseAimStance)
isTwoHandFlat = theIt ^? itUseAimStance == Just TwoHandFlat
itUseAimStance = itUse . useAim . aimStance
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
sLen = _strideLength $ _crStance cr
strideRot :: Creature -> Float
strideRot cr = case cr ^? crStance . carriage of
Just (Walking x LeftForward) -> f x
Just (Walking x RightForward) -> - f x
_ -> 0
where
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
sLen = _strideLength $ _crStance cr
twoFlatHRot :: Creature -> Float
twoFlatHRot cr = 2*strideRot cr
+7 -17
View File
@@ -70,15 +70,11 @@ sparkGun = teslaGun
& itParams . arcSize .~ 10
teslaGun :: Item
teslaGun = defaultBatteryGun
{ _itConsumption = defaultLoadable
& laMax .~ 200
& laCycle .~ [loadEject 10, loadInsert 10 , loadPrime 60]
, _itDimension = ItemDimension
{ _dimRad = 9
, _dimCenter = V3 4 0 0
}
, _itParams = teslaParams
}
& itConsumption . laMax .~ 200
& itConsumption . laCycle .~ [loadEject 10, loadInsert 10 , loadPrime 60]
& itDimension . dimRad .~ 9
& itDimension . dimCenter .~ V3 4 0 0
& itParams .~ teslaParams
& itUse . rUse .~ shootTeslaArc
& itUse . useDelay .~ NoDelay
& itUse . useMods .~
@@ -288,10 +284,8 @@ lasGun = defaultAutoBatteryGun
{ _tweakParams = IM.fromList [(0,lasGunTweak)]
, _tweakSel = 0
}
& itDimension .~ ItemDimension
{ _dimRad = 10
, _dimCenter = V3 15 0 0
}
& itDimension . dimRad .~ 10
& itDimension . dimCenter .~ V3 15 0 0
& itUse . rUse .~ shootLaser
& itUse . useDelay .~ NoDelay
& itUse . useMods .~
@@ -332,10 +326,6 @@ tractorGun = lasGun
{ _itConsumption = defaultLoadable
& laMax .~ 10000
& laCycle .~ [loadEject 10, loadInsert 10 , loadPrime 60]
, _itDimension = ItemDimension
{ _dimRad = 10
, _dimCenter = V3 15 0 0
}
, _itParams = Attracting {_attractionPower = 1}
, _itTweaks = Tweakable
{ _tweakParams = IM.fromList [(0,tractorGunTweak)]
+7 -20
View File
@@ -28,7 +28,7 @@ import LensHelp
defaultBangCane :: Item
defaultBangCane = defaultBulletWeapon
{ _itParams = BulletShooter
& itParams .~ BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
@@ -39,11 +39,8 @@ defaultBangCane = defaultBulletWeapon
, _torqueAfter = 0.1
, _randomOffset = 0
}
, _itDimension = ItemDimension
{ _dimRad = 8
, _dimCenter = V3 5 0 0
}
}
& itDimension . dimRad .~ 8
& itDimension . dimCenter .~ V3 5 0 0
& itUse . useDelay . rateMax .~ 6
& itUse . useMods .~
[ ammoHammerCheck
@@ -63,7 +60,7 @@ defaultBangCane = defaultBulletWeapon
& itConsumption . laMax .~ 1
& itConsumption . laCycle .~ [loadPartialInsert 10 1]
volleyGun :: Int -> Item
volleyGun i = defaultBulletWeapon
volleyGun i = defaultBangCane
& itUse . useDelay . rateMax .~ 6
& itUse . useMods .~
[ ammoHammerCheck
@@ -76,10 +73,6 @@ volleyGun i = defaultBulletWeapon
, withMuzFlareI
, withRecoil
]
& itDimension .~ ItemDimension
{ _dimRad = 8
, _dimCenter = V3 5 0 0
}
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandFlat
@@ -111,11 +104,6 @@ caneStickSoundChoice it
| otherwise = shotgunS
rifle :: Item
rifle = defaultBangCane
{ _itDimension = ItemDimension
{ _dimRad = 8
, _dimCenter = V3 5 0 0
}
}
& itUse . useAim . aimStance .~ TwoHandTwist
& itType . iyBase .~ HELD RIFLE
& itConsumption . laMax .~ 1
@@ -249,10 +237,9 @@ miniGunX i = defaultAutoGun
, _randomOffset = 10
}
, _itInvSize = 4
, _itDimension = ItemDimension
{ _dimRad = 20
, _dimCenter = V3 5 0 0
}
}
& itDimension . dimRad .~ 20
& itDimension . dimCenter .~ V3 5 0 0
& itDimension . dimAttachPos .~ V3 5 (-5) 0
& itType . iyBase .~ HELD (MINIGUNX i)
& itUse . useAim . aimMuzPos .~ 40
+2 -4
View File
@@ -52,10 +52,8 @@ bangRod = defaultBulletWeapon
, withMuzFlareI
, withRecoil
]
& itDimension .~ ItemDimension
{ _dimRad = 12
, _dimCenter = V3 5 0 0
}
& itDimension . dimRad .~ 12
& itDimension . dimCenter .~ V3 5 0 0
& itConsumption . laMax .~ 1
& itConsumption . laCycle .~ [loadEject 5, loadInsert 10 , loadPrime 5]
& itType . iyBase .~ HELD BANGROD
+2 -4
View File
@@ -44,10 +44,8 @@ bangStick i = defaultBulletWeapon
, _randomOffset = 0
}
& itInvSize .~ fromIntegral i / 3
& itDimension .~ ItemDimension
{ _dimRad = 5
, _dimCenter = V3 5 0 0
}
& itDimension . dimRad .~ 5
& itDimension . dimCenter .~ V3 5 0 0
& itUse . useDelay . rateMax .~ 8
& itUse . useMods .~
[ ammoHammerCheck
+3 -10
View File
@@ -100,11 +100,9 @@ bangCone = defaultBulletWeapon
, _torqueAfter = 0.1
, _randomOffset = 12
}
, _itDimension = ItemDimension
{ _dimRad = 8
, _dimCenter = V3 5 0 0
}
}
}
& itDimension . dimRad .~ 8
& itDimension . dimCenter .~ V3 5 0 0
& itUse . useDelay . rateMax .~ 20
& itUse . useMods .~
[ ammoCheckI
@@ -141,11 +139,6 @@ coneRandItemParams = do
blunderbuss :: Item
blunderbuss = bangCone
{_itDimension = ItemDimension
{ _dimRad = 8
, _dimCenter = V3 5 0 0
}
}
& itConsumption . laMax .~ 25
& itConsumption . laCycle .~ [loadEject 5, loadInsert 30 , loadPrime 5]
& itUse . useAim . aimStance .~ TwoHandTwist
+2 -4
View File
@@ -57,11 +57,9 @@ launcher = defaultWeapon
, _tweakParams = basicAmPjMoves
}
, _itInvSize = 3
, _itDimension = ItemDimension
{ _dimRad = 9
, _dimCenter = V3 10 0 0
}
}
& itDimension . dimRad .~ 9
& itDimension . dimCenter .~ V3 10 0 0
& itUse . useDelay . rateMax .~ 20
& itUse . rUse .~ usePjCreation
& itUse . useMods .~
+2 -4
View File
@@ -33,11 +33,9 @@ sonicGun = defaultAutoGun
& laCycle .~ [loadEject 10, loadInsert 10 , loadPrime 60]
, _itParams = NoParams
, _itTweaks = NoTweaks
, _itDimension = ItemDimension
{ _dimRad = 10
, _dimCenter = V3 15 0 0
}
}
& itDimension . dimRad .~ 10
& itDimension . dimCenter .~ V3 15 0 0
& itUse . useDelay . rateMax .~ 8
& itUse . rUse .~ aSonicWave
& itUse . useMods .~
+2 -5
View File
@@ -115,12 +115,9 @@ flameThrower = defaultAutoGun
}
]
}
, _itDimension = ItemDimension
{ _dimRad = 7
, _dimCenter = V3 9 0 0
}
-- , _itFloorPict = flamerPic
}
& itDimension . dimRad .~ 7
& itDimension . dimCenter .~ V3 9 0 0
& itUse . rUse .~ overNozzles useGasParams
& itUse . useDelay .~ NoDelay
& itUse . useMods .~