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 -1
View File
@@ -38,7 +38,7 @@ moduleModification imt = case imt of
WEPTELE -> makeDirectedTele
LAUNCHHOME -> itConsumption . laAmmoType . amPjCreation .~ fireTrackingShell
EXTRABATTERY -> itConsumption . laMax +~ 1000
ATTACHTORCH -> itUse . heldAttachment .~ Torch
ATTACHTORCH -> id
where
f ameff = itConsumption . laAmmoType . amBulEff .~ ameff
makeDirectedTele it = it
+1 -19
View File
@@ -7,38 +7,20 @@ import Dodge.Damage
import Dodge.Hammer
import Dodge.Reloading
import Dodge.Prop.Gib
--import Dodge.Base.Arithmetic
import Dodge.Base
import Dodge.Creature.State.WalkCycle
import Dodge.Creature.Impulse.Movement
import Dodge.LightSource.Torch
--import Dodge.Base
import Dodge.SoundLogic
import RandomHelp
import Dodge.WorldEvent
--import Dodge.WallCreatureCollisions
import Dodge.Creature.Action
--import Dodge.Hammer
import Geometry
import Picture
import Shape
import ShapePicture
import qualified IntMapHelp as IM
import LensHelp
--import StrictHelp
--import FoldableHelp
import Data.Function
--import qualified Data.IntSet as IS
--import Data.Maybe
--import Control.Applicative
--import qualified SDL
--import qualified SDL.Mixer as Mix
--import qualified Data.Set as S
--import qualified Data.Map as M
--import qualified Data.Vector as V
--import qualified Data.Vector.Mutable as MV
foldCr :: [Creature -> World -> World]
-> Creature -> World -> World
@@ -225,7 +207,7 @@ itemInvSideEffect cr it
createAttachLight :: Creature -> Item -> World -> World
createAttachLight cr it = createTorchLightOffset cr it attachoff
where
attachoff = it ^?! itUse . heldAttachPos
attachoff = it ^?! itDimension . dimAttachPos
itemUpdate :: Creature -> Int -> Item -> Item
itemUpdate cr i
+3 -6
View File
@@ -482,8 +482,6 @@ data ItemUse
, _useMods :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
, _useHammer :: HammerPosition
, _useAim :: AimParams
, _heldAttachPos :: Point3
, _heldAttachment :: HeldAttachment
, _heldScroll :: Float -> Creature -> Item -> Item
}
| LeftUse
@@ -572,10 +570,9 @@ data Targeting
, _tgActive :: Bool
}
data ItemDimension = ItemDimension
{ _dimRad :: Float
, _dimCenter :: Point3
-- , _dimPortage :: ItemPortage
-- , _dimSPic :: Item -> SPic
{ _dimRad :: Float
, _dimCenter :: Point3
, _dimAttachPos :: Point3
}
data ItemPortage
= HeldItem
+2 -1
View File
@@ -3,6 +3,7 @@ module Dodge.Default.Item
) where
import Dodge.Data
import Picture
import Geometry.Data
--import Shape
defaultItem :: Item
@@ -16,7 +17,7 @@ defaultItem = Item
, _itInvColor = yellow
, _itInvSize = 1
, _itPos = VoidItm
, _itDimension = ItemDimension 2 0
, _itDimension = ItemDimension 2 0 (V3 10 (-5) 3)
, _itConsumption = NoConsumption
, _itUse = NoUse
, _itAttachment = NoItAttachment
-3
View File
@@ -8,7 +8,6 @@ import Dodge.Default.Item
import Dodge.Default.AimParams
--import Dodge.Item.Draw
import Picture
import Geometry.Data
import qualified Data.Map.Strict as M
import Control.Lens
@@ -66,8 +65,6 @@ defaultrUse = RightUse
, _useMods = []
, _useHammer = HammerUp
, _useAim = defaultAimParams
, _heldAttachPos = V3 0 (-10) 0
, _heldAttachment = NoHeldAttachment
, _heldScroll = \_ _ -> id
}
defaultlUse :: ItemUse
+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 .~
+12
View File
@@ -0,0 +1,12 @@
module Dodge.LightSource.Torch where
import Dodge.Data
import Geometry
import LensHelp
import Dodge.Item.Draw -- heldItemOffset needs to be moved somewhere more sensible
import Dodge.LightSource -- this needs to be split!
createTorchLightOffset :: Creature -> Item -> Point3 -> World -> World
createTorchLightOffset cr it off = tempLightSources .:~ tlsTimeRadColPos 1 250 0.7
(p +.+.+ rotate3 (_crDir cr) (heldItemOffset it cr (off +.+.+ V3 8 0 1.5)))
where
p = addZ 0 $ _crPos cr
+1 -1
View File
@@ -327,7 +327,7 @@ spawnerRoom = do
corDoor :: State StdGen (MetaTree Room String)
corDoor = do
cor <- (shuffleLinks $ cleatOnward corridor) <&> rmPmnts .~ []
cor <- shuffleLinks (cleatOnward corridor) <&> rmPmnts .~ []
return $ tToBTree "corDoor" $ treePost [door,cor]
-- cor <- shuffleLinks corridor
-- return $ tToBTree "corDoor" $ treePost [door,cor,cleatOnward door]