diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index c8c972c8f..9e80acb00 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -500,12 +500,11 @@ type HitEffect = Particle -> (World,Maybe Particle) data AmmoType - = ShellAmmo + = ProjectileAmmo { _amPayload :: Point2 -> World -> World , _amString :: String - , _amPjParams :: [PjParam] , _amPjDraw :: Prop -> SPic - , _amParamSel :: Int +-- , _aProjectile :: Ammo -> Prop } | BulletAmmo { _amString :: String @@ -520,7 +519,11 @@ data ItemParams = UtilityItem | NoParams | ShellLauncher - { _launchParams :: [PjParam] + { _tweakParams :: [TweakParam] + , _tweakSel :: Int + , _shellSpinDrag :: Int + , _shellSpinAmount :: Int + , _shellThrustDelay :: Int } | MultiBarrel { _barrelSpread :: BarrelSpread @@ -533,12 +536,19 @@ data ItemParams , _currentWalkAngle :: Float , _walkSpeed :: Float } -data PjParam = PjParam - { _pjMoveParam :: Int -> Item -> Creature -> Prop -> World -> World - , _pjIntParam :: Int - , _pjMaxParam :: Int - , _pjDisplayParam :: Int -> String - } +data TweakParam + = PjExtraUpdate + { _pjMoveParam :: Int -> Item -> Creature -> Prop -> World -> World + , _curTweak :: Int + , _pjMaxParam :: Int + , _pjDisplayParam :: Int -> String + } + | TweakItem + { _doTweak :: Int -> Item -> Item + , _curTweak :: Int + , _maxTweak :: Int + , _showTweak :: Int -> String + } data Modification = ModIDTimerPoint3Bool { _mdID :: Int @@ -871,7 +881,7 @@ makeLenses ''ItEffect makeLenses ''FloorItem makeLenses ''ItemConsumption makeLenses ''AmmoType -makeLenses ''PjParam +makeLenses ''TweakParam makeLenses ''Prop makeLenses ''Modification makeLenses ''Particle diff --git a/src/Dodge/Default/Weapon.hs b/src/Dodge/Default/Weapon.hs index a7062488d..474ead8df 100644 --- a/src/Dodge/Default/Weapon.hs +++ b/src/Dodge/Default/Weapon.hs @@ -114,11 +114,3 @@ defaultItemDimension = ItemDimension defaultAutoGun :: Item defaultAutoGun = defaultGun & itUse . useAim . aimStance .~ TwoHandTwist -defaultShellAmmo :: AmmoType -defaultShellAmmo = ShellAmmo - { _amPayload = const id - , _amString = "Shell" - , _amPjParams = [] - , _amPjDraw = const mempty - , _amParamSel = 0 - } diff --git a/src/Dodge/Event.hs b/src/Dodge/Event.hs index f74dd9529..2f63e96cb 100644 --- a/src/Dodge/Event.hs +++ b/src/Dodge/Event.hs @@ -114,8 +114,8 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of (_, TweakInventory) | invKeyDown && rbDown -> w & moveYourAmmoSel yi | invKeyDown -> stopSoundFrom (CrReloadSound 0) $ dirInvPos yi w - | rbDown -> w & moveYourAmmoParam yi - | otherwise -> w & moveYourAmmoSel yi + | rbDown -> w & changeTweakParam yi + | otherwise -> w & moveYourAmmoSel yi (_, _) -> w where yi = round $ signum y @@ -125,14 +125,17 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of invKeyDown = ScancodeCapsLock `S.member` _keys w moveYourAmmoSel :: Int -> World -> World -moveYourAmmoSel i w = case yourItem w ^? itConsumption . aoType. amPjParams of +moveYourAmmoSel i w = case yourItem w ^? itParams . tweakParams of Just l -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w)) - . itConsumption . aoType. amParamSel %~ (`mod` length l) . subtract i + . itParams . tweakSel %~ (`mod` length l) . subtract i _ -> w -moveYourAmmoParam :: Int -> World -> World -moveYourAmmoParam i w = case yourItem w ^? itConsumption . aoType. amPjParams . ix paramid . pjMaxParam of +changeTweakParam :: Int -> World -> World +changeTweakParam i w = + case yourItem w ^? itParams . tweakParams . ix paramid . pjMaxParam of Just n -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w)) - . itConsumption . aoType. amPjParams . ix paramid . pjIntParam %~ (`mod` n) . (+ i) + . itParams . tweakParams . ix paramid . curTweak %~ (`mod` n) . (+ i) _ -> w where - paramid = _amParamSel $ _aoType $ _itConsumption $ yourItem w + it = yourItem w + theparam = it ^? itParams . tweakParams . ix paramid + paramid = _tweakSel $ _itParams $ yourItem w diff --git a/src/Dodge/Item/Weapon/BulletGuns.hs b/src/Dodge/Item/Weapon/BulletGuns.hs index 8ac0b7c50..6f43821f2 100644 --- a/src/Dodge/Item/Weapon/BulletGuns.hs +++ b/src/Dodge/Item/Weapon/BulletGuns.hs @@ -53,7 +53,7 @@ autoGun = defaultAutoGun , withSoundForI autoBS 5 --, withSoundForI seagullChatterS 5 , useAmmo 1 - , withRandomDirI (autogunSpread/2) + , applyInaccuracy , withMuzFlareI , withSmoke 1 black 20 200 5 ] @@ -406,7 +406,5 @@ startZoomInLongGun = itAttachment . scopeZoomChange %~ \x -> max 5 (x + 5) startZoomOutLongGun :: Item -> Item startZoomOutLongGun = itAttachment . scopeZoomChange %~ \x -> min (-5) (x-5) -spreadGunSpread :: Float -spreadGunSpread = 0.5 autogunSpread :: Float autogunSpread = 0.07 diff --git a/src/Dodge/Item/Weapon/Launcher.hs b/src/Dodge/Item/Weapon/Launcher.hs index 9bc910b5d..6a955fb82 100644 --- a/src/Dodge/Item/Weapon/Launcher.hs +++ b/src/Dodge/Item/Weapon/Launcher.hs @@ -40,8 +40,7 @@ launcher = defaultGun , _itConsumption = defaultAmmo { _aoType = defaultShellAmmo { _amPayload = makeExplosionAt - , _amString = "" - , _amPjParams = basicAmPjMoves + , _amString = "EXPLOSIVE SHELL" , _amPjDraw = shellPic } , _wpMaxAmmo = 30 @@ -59,6 +58,20 @@ launcher = defaultGun & useAim . aimStance .~ TwoHandTwist , _itFloorPict = launcherPic , _itEffect = NoItEffect + , _itParams = ShellLauncher + { _tweakSel = 0 + , _tweakParams = basicAmPjMoves + , _shellSpinDrag = 1 + , _shellSpinAmount = 2 + , _shellThrustDelay = 1 + } + } + +defaultShellAmmo :: AmmoType +defaultShellAmmo = ProjectileAmmo + { _amPayload = const id + , _amString = "Shell" + , _amPjDraw = const mempty } launcherPic :: Item -> SPic @@ -69,32 +82,32 @@ launcherPic _ = , mempty ) -basicAmPjMoves :: [PjParam] +basicAmPjMoves :: [TweakParam] basicAmPjMoves = [spinDrag ,spinStart ,thrustParam ] -spinDrag :: PjParam -spinDrag = PjParam +spinDrag :: TweakParam +spinDrag = PjExtraUpdate { _pjMoveParam = \i _ _ -> reduceSpinBy (1 - fromIntegral i*2 / 200) - , _pjIntParam = 1 + , _curTweak = 1 , _pjDisplayParam = pjPadText "SPIN SLOWDOWN" . show , _pjMaxParam = 5 } pjPadText :: String -> String -> String pjPadText s = (rightPad 12 ' ' s ++ ) . (' ':) -spinStart :: PjParam -spinStart = PjParam +spinStart :: TweakParam +spinStart = PjExtraUpdate { _pjMoveParam = \i _ cr -> pjEffAtTime 35 $ trySpinByCID (_crID cr) i - , _pjIntParam = 2 + , _curTweak = 2 , _pjDisplayParam = pjPadText "SPIN AMOUNT" . show , _pjMaxParam = 5 } -thrustParam :: PjParam -thrustParam = PjParam +thrustParam :: TweakParam +thrustParam = PjExtraUpdate { _pjMoveParam = \i _ _ -> pjThrust i - , _pjIntParam = 1 + , _curTweak = 1 , _pjDisplayParam = pjPadText "THRUST DELAY" . show , _pjMaxParam = 5 } @@ -124,25 +137,26 @@ doThrust pj w = w r1 = randInCirc 10 & evalState $ _randGen w smokeGen = shellTrailCloud $ addZ 20 (oldPos +.+ r1 +.+ 30 *.* normalizeV (oldPos -.- newPos)) ---flameLauncher :: Item ---flameLauncher = launcher & wpAmmo . amPayload .~ makeFlameExplosionAt ---poisonLauncher :: Item ---poisonLauncher = launcher & wpAmmo . amPayload .~ makePoisonExplosionAt ---teslaLauncher :: Item ---teslaLauncher = launcher & wpAmmo . amPayload .~ makeTeslaExplosionAt +--aPJtweakParams :: Prop -> Item -> Creature -> World -> World +--aPJtweakParams pr it cr w = -aRocketWithItemParams - :: Item -- ^ Firing item - -> Creature - -> World - -> World +aRocketWithItemParams :: Item -> Creature -> World -> World aRocketWithItemParams it cr w = over props (IM.insert i theShell) w where am = _itConsumption it i = IM.newKey $ _props w pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir) dir = _crDir cr - ammoMvs pj w' = foldr (\pjP -> _pjMoveParam pjP (_pjIntParam pjP) it cr pj) w' (_amPjParams $ _aoType am) + params = _itParams it + spindrag = _shellSpinDrag params + spinamount = _shellSpinAmount params + thrustdelay = _shellThrustDelay params + ammoMvs pj w' = + foldr (\pjP -> _pjMoveParam pjP (_curTweak pjP) it cr pj) w' + (filter ispjupdate $ _tweakParams $ _itParams it) + ispjupdate PjExtraUpdate {} = True + ispjupdate _ = False +-- I feel like this might leak... theShell = defaultShell { _pjPos = pos , _pjStartPos = pos @@ -150,7 +164,12 @@ aRocketWithItemParams it cr w = over props (IM.insert i theShell) w , _pjAcc = rotateV dir (V2 3 0) , _prDraw = _amPjDraw $ _aoType am , _pjID = i - , _pjUpdate = \pj -> ammoMvs pj . decTimMvVel pj . moveShell pj + --, _pjUpdate = \pj -> ammoMvs pj . decTimMvVel pj . moveShell pj + , _pjUpdate = \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj + . pjThrust thrustdelay pj + . reduceSpinBy (1-fromIntegral spindrag*2 / 200) pj + . decTimMvVel pj + . moveShell pj , _pjPayload = _amPayload $ _aoType am , _pjTimer = 50 } @@ -242,7 +261,6 @@ remoteLauncher = defaultGun { _aoType = defaultShellAmmo { _amPayload = makeExplosionAt , _amString = "" - , _amPjParams = basicAmPjMoves , _amPjDraw = shellPic } , _wpMaxAmmo = 30 @@ -258,6 +276,10 @@ remoteLauncher = defaultGun & useAim . aimStance .~ TwoHandTwist , _itFloorPict = launcherPic , _itAttachment = ItScope (V2 0 0) 0 1 True +-- , _itParams = ShellLauncher +-- { _tweakSel = 0 +-- , _tweakParams = basicAmPjMoves -- TODO change to allow tweaking rocket speed +-- } } fireRemoteLauncher :: Creature -> World -> World diff --git a/src/Dodge/Render/HUD.hs b/src/Dodge/Render/HUD.hs index 43c30147f..ef1dcf10b 100644 --- a/src/Dodge/Render/HUD.hs +++ b/src/Dodge/Render/HUD.hs @@ -58,7 +58,7 @@ subInventoryDisplay cfig w = case _inventoryMode w of col = itCol it cursorsZ :: Configuration -> Int -> Item -> Picture -cursorsZ cfig ipos it = case it ^? itConsumption . aoType . amParamSel of +cursorsZ cfig ipos it = case it ^? itParams . tweakSel of Nothing -> f $ zConnect sp (V2 (155- hw) ( hh - 77.5)) Just jpos -> f $ zConnect sp (V2 (155 - hw) ( hh - (20 * fromIntegral jpos + 77.5))) where @@ -75,12 +75,12 @@ topInvCursor col iPos cfig w | otherwise = mainListCursor col iPos cfig ammoTweakStrings :: Item -> [String] -ammoTweakStrings it = case it ^? itConsumption . aoType . amPjParams of +ammoTweakStrings it = case it ^? itParams . tweakParams of Just l -> map pjTweakString l _ -> ["NOT TWEAKABLE"] mCurs :: Item -> Configuration -> World -> Picture -mCurs it cfig w = case it ^? itConsumption . aoType . amParamSel of +mCurs it cfig w = case it ^? itParams . tweakSel of Nothing -> [] Just i | ButtonRight `S.member` _mouseButtons w -> @@ -93,8 +93,8 @@ mCurs it cfig w = case it ^? itConsumption . aoType . amParamSel of x = 117.5 y = 155 -pjTweakString :: PjParam -> String -pjTweakString pj = _pjDisplayParam pj $ _pjIntParam pj +pjTweakString :: TweakParam -> String +pjTweakString pj = _pjDisplayParam pj $ _curTweak pj displayMidList :: Configuration -> [String] -> String -> Picture displayMidList cfig strs s = invHead cfig s