This commit is contained in:
2022-07-24 13:53:35 +01:00
parent ac069d08f6
commit 2c1bc67a51
16 changed files with 185 additions and 199 deletions
+1 -1
View File
@@ -91,7 +91,7 @@ heldItemSPic ht it = case ht of
LASCIRCLE -> lasGunPic it
DUALBEAM -> dualBeamPic it
LASWIDE _ -> lasGunPic it
SONICGUN -> noPic baseSonicShape
--SONICGUN -> noPic baseSonicShape
TRACTORGUN -> tractorGunPic it
LAUNCHER -> launcherPic it
LAUNCHERX _ -> launcherPic it
-2
View File
@@ -1,7 +1,6 @@
{- | Rexport all weapons -}
module Dodge.Item.Weapon
( module Dodge.Item.Weapon.BulletGuns
, module Dodge.Item.Weapon.SonicGuns
, module Dodge.Item.Weapon.Shatter
, module Dodge.Item.Weapon.TriggerType
, module Dodge.Item.Weapon.ExtraEffect
@@ -19,7 +18,6 @@ import Dodge.Item.Weapon.Utility
import Dodge.Item.Weapon.BulletGuns
import Dodge.Item.Weapon.Drone
import Dodge.Item.Weapon.TriggerType
import Dodge.Item.Weapon.SonicGuns
import Dodge.Item.Weapon.Shatter
import Dodge.Item.Weapon.ExtraEffect
import Dodge.Item.Weapon.Remote
+132 -132
View File
@@ -1,133 +1,133 @@
module Dodge.Item.Weapon.SonicGuns where
import Dodge.Data
import Dodge.Reloading.Action
import Dodge.Creature.HandPos
import Dodge.Default.Weapon
--import Dodge.Item.Attachment
--import Dodge.WorldEvent.HelperParticle
--import Dodge.Base
--import Dodge.Zone
import Geometry
import Picture
import LensHelp
--import Data.Maybe
--import Data.List
--import Data.Bifunctor
--import System.Random
--import Data.Tuple
--import qualified IntMapHelp as IM
sonicGun :: Item
sonicGun = defaultAutoGun
{ _itConsumption = defaultLoadable
& laMax .~ 10
& laCycle .~ [loadEject 10, loadInsert 10 , loadPrime 60]
, _itParams = NoParams
, _itTweaks = NoTweaks
}
& itDimension . dimRad .~ 10
& itDimension . dimCenter .~ V3 15 0 0
& itUse . useDelay . rateMax .~ 8
& itUse . rUse .~ HeldSonicWave --aSonicWave
& itUse . useMods .~ AmmoHammerTimeUseOneMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandTwist
& itUse . useAim . aimMuzPos .~ 25
& itType . iyBase .~ HELD SONICGUN
aSonicWave :: Item -> Creature -> World -> World
aSonicWave it cr = instantParticles .:~ sonicWave pos dir cpos
where
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
cpos = _crPos cr
dir = _crDir cr
sonicWave :: Point2 -> Float -> Point2 -> Particle
sonicWave pos dir cpos = ShockLine
{ _ptUpdate = mvSonicWave
, _ptPointDirs = [[makePointDir $ pos +.+ clockOrth,makePointDir $ pos -.- clockOrth]]
, _ptTimer = 1000
, _ptColor = white
, _ptCenter = cpos
}
where
clockOrth = 10 *.* unitVectorAtAngle (dir + pi*0.5)
makePointDir p = (p, argV $ p -.- cpos)
drawSonicWave :: Particle -> Picture
drawSonicWave pt = foldMap (color (_ptColor pt) . setLayer BloomNoZWrite . setDepth 20
. lineThick 20
. map fst)
$ _ptPointDirs pt
mvSonicWave :: World -> Particle -> (World, Maybe Particle)
mvSonicWave w pt
| _ptTimer pt <= 0 = (w,Nothing)
| otherwise = (w, Just $ pt & ptTimer -~ 1)
-- | otherwise = (w, Just pt')
-- where
-- mvPointDir (p,a) = case wallsHit p ep w of
-- [] -> Just ((ep, a), (True,True))
-- (hp,wl):_ -> reflectShockLine wl p hp ep
-- where
-- ep = p +.+ 5 *.* unitVectorAtAngle a
-- dividePointDir (x:y:xs) = f x y ++ dividePointDir (y:xs)
-- dividePointDir xs = xs
-- f (p,a) (q,b)
-- | dist p q > 10 = [(p,a),(0.5 *.* (p +.+ q),mixAngles 0.5 a b)]
-- | otherwise = [(p,a)]
-- combineClose ((p,a):(q,b):pairs)
-- | dist p q < 5 = combineClose (( 0.5 *.* (p+.+q), mixa) : pairs)
-- | otherwise = (p,a) : combineClose ((q,b):pairs)
-- where
-- mixa = mixAngles 0.5 a b
-- combineClose pairs = pairs
-- pt' = pt & ptTimer -~ 10
-- -- & ptPointDirs %~ (map dividePointDir . filter (not . null) . dosplit . map mvPointDir)
-- & ptPointDirs %~ (map (dividePointDir . combineClose) . filter (not . null)
-- . concatMap (dosplit . map mvPointDir))
-- -- & ptPointDirs %~ (filter (not . null) . concatMap (dosplit . map mvPointDir))
-- dosplit :: [Maybe ((Point2,Float),(Bool,Bool))] -> [[(Point2,Float)]]
-- dosplit (x:xs) = case x of
-- Nothing -> [] : dosplit xs
-- Just (pair,(True,True)) -> overHead (pair:) $ dosplit xs
-- Just (pair,(False,True)) -> [] : overHead (pair:) (dosplit xs)
-- Just (pair,(True,False)) -> [pair] : dosplit xs
-- Just (_,(False,False)) -> [] : dosplit xs
-- dosplit [] = [[]]
overHead :: (a -> a) -> [a] -> [a]
overHead f (x:xs) = f x: xs
overHead _ [] = []
reflectShockLine :: Wall -> Point2 -> Point2 -> Point2 -> Maybe ((Point2,Float),(Bool,Bool))
reflectShockLine wl sp hitp ep
| angleVV wlV v < pi/3 = Just (pair, (False,True))
| angleVV wlV v < 2 *pi/3 = Nothing
| otherwise = Just (pair, (True,False))
where
reflv = reflectIn wlV (ep -.- hitp)
np = hitp +.+ reflv
pair = (np, argV reflv)
wlV = uncurry (-.-) $ _wlLine wl
v = hitp -.- sp
reflectShockLine' :: Wall -> Point2 -> Point2 -> Point2 -> Maybe ((Point2,Float),(Bool,Bool))
reflectShockLine' wl sp hitp ep
| angleVV wlV v < pi/3 = Just ((np +.+ wlVN,argV wlV), (False,True))
| angleVV wlV v < 2 *pi/3 = Nothing
| otherwise = Just ((np -.- wlVN,argV $ V2 0 0 -.- wlV), (True,False))
where
np = hitp +.+ normalizeV (sp -.- hitp)
wlV = uncurry (-.-) $ _wlLine wl
wlVN = dist hitp ep *.* normalizeV wlV
v = hitp -.- sp
dividePoly :: Float -> [Point2] -> [Point2]
dividePoly x (a:b:bs) = init (divideLine x a b) ++ dividePoly x (b:bs)
dividePoly _ [a] = [a]
dividePoly _ _ = []
--import Dodge.Data
--import Dodge.Reloading.Action
--import Dodge.Creature.HandPos
--import Dodge.Default.Weapon
----import Dodge.Item.Attachment
----import Dodge.WorldEvent.HelperParticle
----import Dodge.Base
----import Dodge.Zone
--import Geometry
--import Picture
--import LensHelp
--
----import Data.Maybe
----import Data.List
----import Data.Bifunctor
----import System.Random
----import Data.Tuple
----import qualified IntMapHelp as IM
--
----sonicGun :: Item
----sonicGun = defaultAutoGun
---- { _itConsumption = defaultLoadable
---- & laMax .~ 10
---- & laCycle .~ [loadEject 10, loadInsert 10 , loadPrime 60]
---- , _itParams = NoParams
---- , _itTweaks = NoTweaks
---- }
---- & itDimension . dimRad .~ 10
---- & itDimension . dimCenter .~ V3 15 0 0
---- & itUse . useDelay . rateMax .~ 8
---- & itUse . rUse .~ HeldSonicWave --aSonicWave
---- & itUse . useMods .~ AmmoHammerTimeUseOneMod
---- & itUse . useAim . aimWeight .~ 6
---- & itUse . useAim . aimRange .~ 1
---- & itUse . useAim . aimStance .~ TwoHandTwist
---- & itUse . useAim . aimMuzPos .~ 25
---- & itType . iyBase .~ HELD SONICGUN
--
----aSonicWave :: Item -> Creature -> World -> World
----aSonicWave it cr = instantParticles .:~ sonicWave pos dir cpos
---- where
---- pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
---- cpos = _crPos cr
---- dir = _crDir cr
--
----sonicWave :: Point2 -> Float -> Point2 -> Particle
----sonicWave pos dir cpos = ShockLine
---- { _ptUpdate = mvSonicWave
---- , _ptPointDirs = [[makePointDir $ pos +.+ clockOrth,makePointDir $ pos -.- clockOrth]]
---- , _ptTimer = 1000
---- , _ptColor = white
---- , _ptCenter = cpos
---- }
---- where
---- clockOrth = 10 *.* unitVectorAtAngle (dir + pi*0.5)
---- makePointDir p = (p, argV $ p -.- cpos)
--
----drawSonicWave :: Particle -> Picture
----drawSonicWave pt = foldMap (color (_ptColor pt) . setLayer BloomNoZWrite . setDepth 20
---- . lineThick 20
---- . map fst)
---- $ _ptPointDirs pt
----
----mvSonicWave :: World -> Particle -> (World, Maybe Particle)
----mvSonicWave w pt
---- | _ptTimer pt <= 0 = (w,Nothing)
---- | otherwise = (w, Just $ pt & ptTimer -~ 1)
------ | otherwise = (w, Just pt')
------ where
------ mvPointDir (p,a) = case wallsHit p ep w of
------ [] -> Just ((ep, a), (True,True))
------ (hp,wl):_ -> reflectShockLine wl p hp ep
------ where
------ ep = p +.+ 5 *.* unitVectorAtAngle a
------ dividePointDir (x:y:xs) = f x y ++ dividePointDir (y:xs)
------ dividePointDir xs = xs
------ f (p,a) (q,b)
------ | dist p q > 10 = [(p,a),(0.5 *.* (p +.+ q),mixAngles 0.5 a b)]
------ | otherwise = [(p,a)]
------ combineClose ((p,a):(q,b):pairs)
------ | dist p q < 5 = combineClose (( 0.5 *.* (p+.+q), mixa) : pairs)
------ | otherwise = (p,a) : combineClose ((q,b):pairs)
------ where
------ mixa = mixAngles 0.5 a b
------ combineClose pairs = pairs
------ pt' = pt & ptTimer -~ 10
------ -- & ptPointDirs %~ (map dividePointDir . filter (not . null) . dosplit . map mvPointDir)
------ & ptPointDirs %~ (map (dividePointDir . combineClose) . filter (not . null)
------ . concatMap (dosplit . map mvPointDir))
------ -- & ptPointDirs %~ (filter (not . null) . concatMap (dosplit . map mvPointDir))
------ dosplit :: [Maybe ((Point2,Float),(Bool,Bool))] -> [[(Point2,Float)]]
------ dosplit (x:xs) = case x of
------ Nothing -> [] : dosplit xs
------ Just (pair,(True,True)) -> overHead (pair:) $ dosplit xs
------ Just (pair,(False,True)) -> [] : overHead (pair:) (dosplit xs)
------ Just (pair,(True,False)) -> [pair] : dosplit xs
------ Just (_,(False,False)) -> [] : dosplit xs
------ dosplit [] = [[]]
--
----overHead :: (a -> a) -> [a] -> [a]
----overHead f (x:xs) = f x: xs
----overHead _ [] = []
----
----
----reflectShockLine :: Wall -> Point2 -> Point2 -> Point2 -> Maybe ((Point2,Float),(Bool,Bool))
----reflectShockLine wl sp hitp ep
---- | angleVV wlV v < pi/3 = Just (pair, (False,True))
---- | angleVV wlV v < 2 *pi/3 = Nothing
---- | otherwise = Just (pair, (True,False))
---- where
---- reflv = reflectIn wlV (ep -.- hitp)
---- np = hitp +.+ reflv
---- pair = (np, argV reflv)
---- wlV = uncurry (-.-) $ _wlLine wl
---- v = hitp -.- sp
----
----reflectShockLine' :: Wall -> Point2 -> Point2 -> Point2 -> Maybe ((Point2,Float),(Bool,Bool))
----reflectShockLine' wl sp hitp ep
---- | angleVV wlV v < pi/3 = Just ((np +.+ wlVN,argV wlV), (False,True))
---- | angleVV wlV v < 2 *pi/3 = Nothing
---- | otherwise = Just ((np -.- wlVN,argV $ V2 0 0 -.- wlV), (True,False))
---- where
---- np = hitp +.+ normalizeV (sp -.- hitp)
---- wlV = uncurry (-.-) $ _wlLine wl
---- wlVN = dist hitp ep *.* normalizeV wlV
---- v = hitp -.- sp
----
----dividePoly :: Float -> [Point2] -> [Point2]
----dividePoly x (a:b:bs) = init (divideLine x a b) ++ dividePoly x (b:bs)
----dividePoly _ [a] = [a]
----dividePoly _ _ = []
--