From 0c5eeb405f6943bc5d8e80c26d7e38585350df26 Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 3 Jun 2022 10:18:47 +0100 Subject: [PATCH] Add unsafe blink gun --- src/Dodge/Combine/Data.hs | 1 + src/Dodge/Creature.hs | 64 +++++++++++++++++--------------- src/Dodge/Creature/Action.hs | 30 ++++++++++++++- src/Dodge/Data.hs | 4 -- src/Dodge/Data/DamageType.hs | 1 + src/Dodge/Debug/Terminal.hs | 12 +++--- src/Dodge/Item/Weapon/Utility.hs | 13 +++---- src/Dodge/Room/Warning.hs | 6 --- src/Dodge/Wall/Damage.hs | 1 + src/Dodge/Wall/DamageEffect.hs | 1 + 10 files changed, 79 insertions(+), 54 deletions(-) diff --git a/src/Dodge/Combine/Data.hs b/src/Dodge/Combine/Data.hs index bbe37dcba..7b13f5aa5 100644 --- a/src/Dodge/Combine/Data.hs +++ b/src/Dodge/Combine/Data.hs @@ -73,6 +73,7 @@ data CombineType | BOOSTER | REWINDER | BLINKER + | BLINKERUNSAFE | FORCEFIELDGUN | SHRINKER -- Equipment diff --git a/src/Dodge/Creature.hs b/src/Dodge/Creature.hs index 8422832d4..3a327fa56 100644 --- a/src/Dodge/Creature.hs +++ b/src/Dodge/Creature.hs @@ -163,35 +163,41 @@ startInvList :: [Item] startInvList = [ ] startInventory :: IM.IntMap Item startInventory = IM.fromList $ zip [0..] startInvList -inventoryA :: IM.IntMap Item -inventoryA = IM.fromList $ zip [0..] - [ clickDetector ITEMDETECTOR - , makeTypeCraftNum 1 TRANSFORMER - , makeTypeCraftNum 2 CAN - , makeTypeCraftNum 2 PIPE - ] -inventoryB :: IM.IntMap Item -inventoryB = IM.fromList $ zip [0..] - [ forceFieldGun - , wristArmour - , wristArmour - , autoRifle - , smg - , machinePistol - , makeTypeCraftNum 4 MICROCHIP - , makeTypeCraftNum 2 TIN - , makeTypeCraftNum 2 HARDWARE - , makeTypeCraftNum 2 CAN - , makeTypeCraftNum 2 PIPE - , makeTypeCraftNum 1 CREATURESENSOR - ] -inventoryC :: IM.IntMap Item -inventoryC = IM.fromList $ zip [0..] - [ autoDetector CREATUREDETECTOR - , autoDetector WALLDETECTOR - , autoDetector ITEMDETECTOR - , wristInvisibility - ] + +inventoryX :: Char -> [Item] +inventoryX c = case c of + 'A' -> + [ clickDetector ITEMDETECTOR + , makeTypeCraftNum 1 TRANSFORMER + , makeTypeCraftNum 2 CAN + , makeTypeCraftNum 2 PIPE + ] + 'B' -> + [ forceFieldGun + , wristArmour + , wristArmour + , autoRifle + , smg + , machinePistol + , makeTypeCraftNum 4 MICROCHIP + , makeTypeCraftNum 2 TIN + , makeTypeCraftNum 2 HARDWARE + , makeTypeCraftNum 2 CAN + , makeTypeCraftNum 2 PIPE + , makeTypeCraftNum 1 CREATURESENSOR + ] + 'C' -> + [ autoDetector CREATUREDETECTOR + , autoDetector WALLDETECTOR + , autoDetector ITEMDETECTOR + , wristInvisibility + ] + 'D' -> + [ blinkGun + , unsafeBlinkGun + , autoDetector WALLDETECTOR + ] + _ -> [] testInventory :: IM.IntMap Item testInventory = IM.fromList $ zip [0..] diff --git a/src/Dodge/Creature/Action.hs b/src/Dodge/Creature/Action.hs index ed900bd72..e45385438 100644 --- a/src/Dodge/Creature/Action.hs +++ b/src/Dodge/Creature/Action.hs @@ -9,6 +9,7 @@ module Dodge.Creature.Action , dropExcept -- , startReloadingWeapon , blinkAction + , unsafeBlinkAction , sizeSelf -- , crAutoReload , copyInvItemToFloor @@ -35,8 +36,8 @@ import Dodge.FloorItem import Geometry import Picture import qualified IntMapHelp as IM +import LensHelp -import Control.Lens --import Control.Monad --import Control.Applicative import Data.Maybe @@ -177,6 +178,33 @@ blinkAction cr w r = 1.5 * _crRad cr p3 = maybe p1 (mvPointTowardAtSpeed r cpos . fst) p2 +{- | Teleport a creature to the mouse position. +Can go through walls, if ending up in wall does big damage. -} +unsafeBlinkAction + :: Creature + -> World + -> World +unsafeBlinkAction cr w + | success = soundMultiFrom [TeleSound 0,TeleSound 1] mwp teleS Nothing + . over distortions (distortionBulge ++) + . set (creatures . ix cid . crPos) mwp + . blinkShockwave cid mwp + $ inverseShockwaveAt cpos 40 2 2 w + | otherwise = blinkAction cr w & creatures . ix cid . crState . crDamage .:~ + Damage ENTERREMENT 10000 mwp mwp mwp NoDamageEffect + where + success = fromMaybe True $ do + (_,wl) <- collidePointWallsWall mwp cpos $ wallsAlongLine mwp cpos w + return (isLHS mwp `uncurry` _wlLine wl) + distR = 120 + distortionBulge = + [RadialDistortion mwp (mwp +.+ V2 distR 0) (mwp +.+ V2 0 distR) 0.1 + ,RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9 + ] + cid = _crID cr + mwp = mouseWorldPos w + cpos = _crPos cr + blinkShockwave :: Int -- ^ Blinking creature ID. -> Point2 diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index e7034f7f8..d47695734 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -410,10 +410,6 @@ data TerminalLine {_tlPause :: Int ,_tlString :: World -> (String, Color) } --- | TerminalLineChoice --- {_tlPause :: Int --- ,_tlOptions :: [(String,World -> World)] --- } | TerminalLineInput {_tlPause :: Int ,_tlScrollCommands :: [TerminalCommand] diff --git a/src/Dodge/Data/DamageType.hs b/src/Dodge/Data/DamageType.hs index b3e0f9411..6f3ac40b5 100644 --- a/src/Dodge/Data/DamageType.hs +++ b/src/Dodge/Data/DamageType.hs @@ -17,4 +17,5 @@ data DamageType | TORQUEDAM | PUSHDAM | POISONDAM + | ENTERREMENT deriving (Eq,Ord,Show,Read) diff --git a/src/Dodge/Debug/Terminal.hs b/src/Dodge/Debug/Terminal.hs index 656912b65..816d15c52 100644 --- a/src/Dodge/Debug/Terminal.hs +++ b/src/Dodge/Debug/Terminal.hs @@ -14,6 +14,7 @@ import Data.List --(isPrefixOf, isInfixOf, intercalate) import Data.Maybe import LensHelp import qualified Data.Text as T +import qualified IntMapHelp as IM --import qualified Debug.Trace --import Graphics.Rendering.OpenGL.GL.Shaders (validateProgram) --import Dodge.Data (Universe(Universe)) @@ -22,18 +23,15 @@ applyTerminalString :: String -> Universe -> Universe applyTerminalString "NOCLIP" = config . debug_noclip %~ not applyTerminalString "LOADME" = (uvWorld . creatures . ix 0 . crInv .~ stackedInventory) . (uvWorld . creatures . ix 0 . crInvCapacity .~ 50) -applyTerminalString "LA" = (uvWorld . creatures . ix 0 . crInv .~ inventoryA) - . (uvWorld . creatures . ix 0 . crInvCapacity .~ 50) -applyTerminalString "LB" = (uvWorld . creatures . ix 0 . crInv .~ inventoryB) - . (uvWorld . creatures . ix 0 . crInvCapacity .~ 50) -applyTerminalString "LC" = (uvWorld . creatures . ix 0 . crInv .~ inventoryC) +applyTerminalString "LM" = applyTerminalString "LOADME" +applyTerminalString "LT" = applyTerminalString "LOADTEST" +applyTerminalString ['L',x] = + (uvWorld . creatures . ix 0 . crInv .~ IM.fromList (zip [0..] $ inventoryX x)) . (uvWorld . creatures . ix 0 . crInvCapacity .~ 50) applyTerminalString "GODON" = uvWorld . creatures . ix 0 . crApplyDamage .~ applyNoDamage applyTerminalString "GODOFF" = uvWorld . creatures . ix 0 . crApplyDamage .~ defaultApplyDamage applyTerminalString "LOADTEST" = (uvWorld . creatures . ix 0 . crInv .~ testInventory) . (uvWorld . creatures . ix 0 . crInvCapacity .~ 50) -applyTerminalString "LM" = applyTerminalString "LOADME" -applyTerminalString "LT" = applyTerminalString "LOADTEST" applyTerminalString ('s': 'e': 't': '_': 'h': 'p': ' ': hp) | isNothing (readMaybe hp :: Maybe Int) = id | otherwise = uvWorld . creatures . ix 0 . crHP .~ read hp diff --git a/src/Dodge/Item/Weapon/Utility.hs b/src/Dodge/Item/Weapon/Utility.hs index 47d1afda5..e331b8407 100644 --- a/src/Dodge/Item/Weapon/Utility.hs +++ b/src/Dodge/Item/Weapon/Utility.hs @@ -104,18 +104,17 @@ blinkGun = defaultGun , _reloadTime = 20 } , _itUse = defaultlUse - & lUse .~ hammerCheckL (shootL aSelfL) + & lUse .~ hammerCheckL (shootL $ const blinkAction) & useHammer .~ upHammer & eqSite .~ GoesOnWrist -- , _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2 } - -aSelf :: Creature -> World -> World -aSelf = blinkAction - -aSelfL :: Item -> Creature -> World -> World -aSelfL _ = blinkAction +unsafeBlinkGun :: Item +unsafeBlinkGun = blinkGun + & itName .~ "BLINKER-UNSAFE" + & itType .~ BLINKERUNSAFE + & itUse . lUse .~ hammerCheckL (shootL $ const unsafeBlinkAction) effectGun :: String -> (Creature -> World -> World) -> Item effectGun name eff = defaultGun diff --git a/src/Dodge/Room/Warning.hs b/src/Dodge/Room/Warning.hs index 69def9bae..ae932d171 100644 --- a/src/Dodge/Room/Warning.hs +++ b/src/Dodge/Room/Warning.hs @@ -17,7 +17,6 @@ import Dodge.Room.Link --import Dodge.Room.RoadBlock import Dodge.Placement.Instance --import Dodge.Default.Room ---import Dodge.Item.Weapon.BulletGuns --import Dodge.Item.Weapon.Utility --import Dodge.LevelGen.Data --import Geometry.Data @@ -57,11 +56,6 @@ addWarningTerminal outplid = (rmName .++~ "warningTerm-") termMessages trid _ = defaultTermParams & addInputLine [unlockCommand trid,quitCommand] [helpCommand,infoCommand theinfo,commandsCommand] - --termMessages trid = ops trid (genTermMessage $ const ["OPEN DOOR?"]) - --ops trid f gw w = f gw w & termFutureLines ++.~ [ TerminalLineInput 0 - -- [unlockCommand trid,quitCommand,damageCodeCommand] - -- [helpCommand,infoCommand theinfo,commandsCommand] - -- ] unlockCommand trid = singleCommand "OPEN" ["YES","Y"] "OPEN THE CONNECTED DOOR." (toggledoor trid) toggledoor trid w' = w' & triggers . ix (fromJust $ _plMID trid) .~ const True theinfo = "DOOR CONTROLABLE WITH THE \"OPEN\" COMMAND. THIS TERMINAL CANNOT CLOSE THE DOOR." diff --git a/src/Dodge/Wall/Damage.hs b/src/Dodge/Wall/Damage.hs index 5a770b0df..ec52dc4d1 100644 --- a/src/Dodge/Wall/Damage.hs +++ b/src/Dodge/Wall/Damage.hs @@ -29,6 +29,7 @@ damageBlockWith dm = case _dmType dm of TORQUEDAM -> id PUSHDAM -> id POISONDAM -> id + ENTERREMENT -> id where dam = _dmAmount dm diff --git a/src/Dodge/Wall/DamageEffect.hs b/src/Dodge/Wall/DamageEffect.hs index 696096aae..a47aa8fa9 100644 --- a/src/Dodge/Wall/DamageEffect.hs +++ b/src/Dodge/Wall/DamageEffect.hs @@ -23,6 +23,7 @@ defaultWallDamage dm wl = wallDamageEffect dm wl . case _dmType dm of TORQUEDAM -> id PUSHDAM -> id POISONDAM -> id + ENTERREMENT -> id where sp = _dmFrom dm p = _dmAt dm