diff --git a/src/Dodge/Combine/Module.hs b/src/Dodge/Combine/Module.hs index 47faa88aa..fa33378ac 100644 --- a/src/Dodge/Combine/Module.hs +++ b/src/Dodge/Combine/Module.hs @@ -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 diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index 059c4ab38..f167b18c3 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -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 diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index 79f1908f9..981e1e38c 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -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 diff --git a/src/Dodge/Default/Item.hs b/src/Dodge/Default/Item.hs index b16123c7c..9d4b0d39c 100644 --- a/src/Dodge/Default/Item.hs +++ b/src/Dodge/Default/Item.hs @@ -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 diff --git a/src/Dodge/Default/Weapon.hs b/src/Dodge/Default/Weapon.hs index bad8b0970..eb07d4e2d 100644 --- a/src/Dodge/Default/Weapon.hs +++ b/src/Dodge/Default/Weapon.hs @@ -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 diff --git a/src/Dodge/Item/Draw.hs b/src/Dodge/Item/Draw.hs index 9d759c77c..d2803ea85 100644 --- a/src/Dodge/Item/Draw.hs +++ b/src/Dodge/Item/Draw.hs @@ -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 diff --git a/src/Dodge/Item/Draw/SPic.hs b/src/Dodge/Item/Draw/SPic.hs index 689416ae9..616ffd96d 100644 --- a/src/Dodge/Item/Draw/SPic.hs +++ b/src/Dodge/Item/Draw/SPic.hs @@ -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 diff --git a/src/Dodge/Item/HeldOffset.hs b/src/Dodge/Item/HeldOffset.hs new file mode 100644 index 000000000..ed75ba3d7 --- /dev/null +++ b/src/Dodge/Item/HeldOffset.hs @@ -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 diff --git a/src/Dodge/Item/Weapon/BatteryGuns.hs b/src/Dodge/Item/Weapon/BatteryGuns.hs index 3c199c26d..2f8b811b4 100644 --- a/src/Dodge/Item/Weapon/BatteryGuns.hs +++ b/src/Dodge/Item/Weapon/BatteryGuns.hs @@ -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)] diff --git a/src/Dodge/Item/Weapon/BulletGun/Cane.hs b/src/Dodge/Item/Weapon/BulletGun/Cane.hs index 72bd646a7..c882a81cb 100644 --- a/src/Dodge/Item/Weapon/BulletGun/Cane.hs +++ b/src/Dodge/Item/Weapon/BulletGun/Cane.hs @@ -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 diff --git a/src/Dodge/Item/Weapon/BulletGun/Rod.hs b/src/Dodge/Item/Weapon/BulletGun/Rod.hs index bfce4c918..a29fc2bfa 100644 --- a/src/Dodge/Item/Weapon/BulletGun/Rod.hs +++ b/src/Dodge/Item/Weapon/BulletGun/Rod.hs @@ -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 diff --git a/src/Dodge/Item/Weapon/BulletGun/Stick.hs b/src/Dodge/Item/Weapon/BulletGun/Stick.hs index 9b76c09d9..155cf9e6b 100644 --- a/src/Dodge/Item/Weapon/BulletGun/Stick.hs +++ b/src/Dodge/Item/Weapon/BulletGun/Stick.hs @@ -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 diff --git a/src/Dodge/Item/Weapon/BulletGuns.hs b/src/Dodge/Item/Weapon/BulletGuns.hs index f24de9196..86de6fce9 100644 --- a/src/Dodge/Item/Weapon/BulletGuns.hs +++ b/src/Dodge/Item/Weapon/BulletGuns.hs @@ -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 diff --git a/src/Dodge/Item/Weapon/Launcher.hs b/src/Dodge/Item/Weapon/Launcher.hs index 1c22fe9d4..168c62160 100644 --- a/src/Dodge/Item/Weapon/Launcher.hs +++ b/src/Dodge/Item/Weapon/Launcher.hs @@ -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 .~ diff --git a/src/Dodge/Item/Weapon/SonicGuns.hs b/src/Dodge/Item/Weapon/SonicGuns.hs index a9623b1dd..cf5dee048 100644 --- a/src/Dodge/Item/Weapon/SonicGuns.hs +++ b/src/Dodge/Item/Weapon/SonicGuns.hs @@ -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 .~ diff --git a/src/Dodge/Item/Weapon/SprayGuns.hs b/src/Dodge/Item/Weapon/SprayGuns.hs index 22a53a5e9..82f40b686 100644 --- a/src/Dodge/Item/Weapon/SprayGuns.hs +++ b/src/Dodge/Item/Weapon/SprayGuns.hs @@ -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 .~ diff --git a/src/Dodge/LightSource/Torch.hs b/src/Dodge/LightSource/Torch.hs new file mode 100644 index 000000000..1673f8191 --- /dev/null +++ b/src/Dodge/LightSource/Torch.hs @@ -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 diff --git a/src/Dodge/Room/Room.hs b/src/Dodge/Room/Room.hs index 0584998ed..8ae3d3688 100644 --- a/src/Dodge/Room/Room.hs +++ b/src/Dodge/Room/Room.hs @@ -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]