From 163d0c584a7f7ebd1200edc256ed55b2adbc4cbd Mon Sep 17 00:00:00 2001 From: justin Date: Wed, 2 Mar 2022 18:05:42 +0000 Subject: [PATCH] Move launcher homing to module, add double launcher --- src/Dodge/Combine/Combinations.hs | 16 ++++++++-- src/Dodge/Combine/Data.hs | 3 +- src/Dodge/Data.hs | 2 ++ src/Dodge/Item/Weapon/Launcher.hs | 51 ++++++++++++++++++++----------- 4 files changed, 52 insertions(+), 20 deletions(-) diff --git a/src/Dodge/Combine/Combinations.hs b/src/Dodge/Combine/Combinations.hs index 4dfda162c..35ddbc64f 100644 --- a/src/Dodge/Combine/Combinations.hs +++ b/src/Dodge/Combine/Combinations.hs @@ -55,7 +55,7 @@ itemCombinations = , po [BANGROD,PLATE,DRUM,MOTOR] machineGun , p [p 2 TUBE,o HARDWARE] launcher - , po [MICROCHIP,TRANSMITTER,LAUNCHER] trackingLauncher + , p [p 2 TUBE,o LAUNCHER] doubleLauncher , po [TRANSMITTER,MINIDISPLAY,LAUNCHER] remoteLauncher , po [LIGHTER,PIPE,CAN] flameStick @@ -112,7 +112,7 @@ moduleCombinations = ] ) , ( ModTarget - , trackingLauncher : launcher : bulletWeapons + , homingLaunchers ++ bulletWeapons , [amod [MICROCHIP,CREATURESENSOR] "+CREATURETARGETING" (itTargeting .~ targetRBCreature) ,amod [MICROCHIP,PRISM] "+LASERTARGETING" (itTargeting .~ targetLaser) ,amod [MICROCHIP,TIN] "+POSTIONALTARGETING" (itTargeting .~ targetRBPress) @@ -131,6 +131,12 @@ moduleCombinations = (itConsumption . aoType . amBulTraj .~ BezierTrajectory) ] ) + , ( ModLauncherHoming + , homingLaunchers + , [ amod [MICROCHIP,TRANSMITTER] "+TARGET HOMING" + (itConsumption . aoType . amPjCreation .~ fireTrackingShell) + ] + ) ] where makeDirectedTele it = it @@ -148,6 +154,12 @@ moduleCombinations = f ameff = itConsumption . aoType . amBulEff .~ ameff amod cts str func = (cts,ItemModule [str] 1 func) +homingLaunchers :: [Item] +homingLaunchers = + [ launcher + , doubleLauncher + ] + bulletWeapons :: [Item] bulletWeapons = [bangStick i | i <- [1..9] ] ++ [bangCaneX i | i <- [1..6] ] diff --git a/src/Dodge/Combine/Data.hs b/src/Dodge/Combine/Data.hs index 53a00efce..5b261c9f7 100644 --- a/src/Dodge/Combine/Data.hs +++ b/src/Dodge/Combine/Data.hs @@ -50,7 +50,8 @@ data CombineType | SONICGUN | TRACTORGUN | LAUNCHER - | TRACKINGLAUNCHER + | DOUBLELAUNCHER +-- | TRACKINGLAUNCHER | REMOTELAUNCHER | SPRAYER | DRONELAUNCHER diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index 98326964a..49b5a6f48 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -393,6 +393,7 @@ data ModuleSlot | ModAutoMag | ModTarget | ModBulletTrajectory + | ModLauncherHoming deriving (Eq,Ord) data ItemModule @@ -522,6 +523,7 @@ data AmmoType { _amPayload :: Point2 -> World -> World , _amString :: String , _amPjDraw :: Prop -> SPic + , _amPjCreation :: Item -> Creature -> World -> World -- , _aProjectile :: Ammo -> Prop } | BulletAmmo diff --git a/src/Dodge/Item/Weapon/Launcher.hs b/src/Dodge/Item/Weapon/Launcher.hs index d5c1a0559..3acb6e347 100644 --- a/src/Dodge/Item/Weapon/Launcher.hs +++ b/src/Dodge/Item/Weapon/Launcher.hs @@ -1,7 +1,8 @@ module Dodge.Item.Weapon.Launcher ( launcher - , trackingLauncher + , doubleLauncher , remoteLauncher + , fireTrackingShell ) where import Dodge.Data import Dodge.Default @@ -43,12 +44,13 @@ launcher = defaultGun { _amPayload = makeExplosionAt , _amString = "EXPLOSIVE SHELL" , _amPjDraw = drawShell + , _amPjCreation = fireShell } , _ammoBaseMax = 1 , _ammoLoaded = 1 , _reloadTime = 80 } - , _itUse = ruseRate 20 fireLauncher upHammer + , _itUse = ruseRate 20 usePjCreation upHammer [ hammerCheckI , ammoCheckI , useTimeCheck @@ -58,7 +60,6 @@ launcher = defaultGun & useAim . aimSpeed .~ 0.2 & useAim . aimRange .~ 0.5 & useAim . aimStance .~ TwoHandTwist - , _itEffect = NoItEffect , _itParams = ShellLauncher { _shellSpinDrag = 1 , _shellSpinAmount = 2 @@ -80,6 +81,28 @@ launcher = defaultGun , _dimSPic = launcherPic } } + & itModules . at ModLauncherHoming ?~ DefaultModule + +doubleLauncher :: Item +doubleLauncher = launcher + & itName .~ "DOUBLEROCKO" + & itType .~ DOUBLELAUNCHER + & itUse . rUse .~ usePjCreationDouble + & itUse . useMods .~ + [ hammerCheckI + , ammoCheckI + , useTimeCheck + , withSoundStart tap4S + , useAmmoAmount 1 + ] + +usePjCreation :: Item -> Creature -> World -> World +usePjCreation it = _amPjCreation (_aoType (_itConsumption it)) it + +usePjCreationDouble :: Item -> Creature -> World -> World +usePjCreationDouble it cr = _amPjCreation (_aoType (_itConsumption it)) it cr + . _amPjCreation (_aoType (_itConsumption it)) it (cr & crDir +~ pi) + launcherPic :: Item -> SPic launcherPic _ = ( colorSH cyan $ prismPoly @@ -155,8 +178,8 @@ doThrust pj w = w (sparkD,_) = randomR (-0.2,0.2) $ _randGen w r1 = randInCirc 10 & evalState $ _randGen w -fireLauncher :: Item -> Creature -> World -> World -fireLauncher it cr = makeShell it cr $ \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj +fireShell :: Item -> Creature -> World -> World +fireShell it cr = makeShell it cr $ \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj . pjThrust thrustdelay pj . reduceSpinBy (1-fromIntegral spindrag*2 / 200) pj . decTimMvVel pj @@ -253,12 +276,6 @@ trySpinByCID cid i pj w = w & props . ix pjid . pjSpin .~ newSpin _ -> 0 spinFactor = 5 * (6 - fromIntegral i) -trackingLauncher :: Item -trackingLauncher = launcher - & itName .~ "ROCKO-TRACK" - & itType .~ TRACKINGLAUNCHER - & itUse . rUse .~ fireTrackingLauncher - remoteLauncherName :: String remoteLauncherName = "ROCKO-REMOTE" @@ -266,13 +283,13 @@ remoteLauncher :: Item remoteLauncher = launcher & itName .~ remoteLauncherName & itType .~ REMOTELAUNCHER - & itUse . rUse .~ fireRemoteLauncher + & itUse . rUse .~ fireRemoteShell & itScope .~ RemoteScope (V2 0 0) 1 True & itConsumption . aoType . amPjDraw .~ drawRemoteShell -- TODO consider allowing tweaking rocket speed -fireRemoteLauncher :: Item -> Creature -> World -> World -fireRemoteLauncher it cr w = setLocation +fireRemoteShell :: Item -> Creature -> World -> World +fireRemoteShell it cr w = setLocation $ set (creatures . ix cid . crInv . ix j . itUse . rUse) (\_ _ -> explodeRemoteRocket itid i) $ set (creatures . ix cid . crInv . ix j . itName) remoteLauncherName @@ -340,7 +357,7 @@ explodeRemoteRocket -> World -> World explodeRemoteRocket itid pjid w = w - & props . ix pjid . pjUpdate .~ (\_ -> retireRemoteProj fireRemoteLauncher itid 30 pjid) + & props . ix pjid . pjUpdate .~ (\_ -> retireRemoteProj fireRemoteShell itid 30 pjid) & props . ix pjid . prDraw .~ const mempty & itPoint . itUse . rUse .~ (\_ _ -> id) & itPoint . itName .~ "REMOTELAUNCHER" @@ -349,8 +366,8 @@ explodeRemoteRocket itid pjid w = w itPoint = pointToItem $ _itemPositions w IM.! itid thepj = _props w IM.! pjid -fireTrackingLauncher :: Item -> Creature -> World -> World -fireTrackingLauncher it cr w = setLocation +fireTrackingShell :: Item -> Creature -> World -> World +fireTrackingShell it cr w = setLocation $ addTrackRocket w where cid = _crID cr