Trippy flamer

This commit is contained in:
2021-08-28 14:33:23 +01:00
parent 882a8e9824
commit 3a8b28a916
10 changed files with 81 additions and 28 deletions
+1
View File
@@ -149,6 +149,7 @@ data TempLightSource = TLS
, _tlsRad :: !Float , _tlsRad :: !Float
, _tlsIntensity :: !Point3 , _tlsIntensity :: !Point3
, _tlsUpdate :: World -> TempLightSource -> (World, Maybe TempLightSource) , _tlsUpdate :: World -> TempLightSource -> (World, Maybe TempLightSource)
, _tlsTime :: !Int
} }
data Creature = Creature data Creature = Creature
{ _crPos :: Point2 { _crPos :: Point2
+13 -1
View File
@@ -179,5 +179,17 @@ defaultPP = PressPlate
, _ppText = "Pressure plate" , _ppText = "Pressure plate"
} }
defaultTLS :: TempLightSource
defaultTLS = TLS
{ _tlsPos = 0
, _tlsRad = 0
, _tlsIntensity = 0.5
, _tlsUpdate = f
, _tlsTime = 1
}
where
f w t
| _tlsTime t <= 0
= (w, Nothing)
| otherwise = (w, Just $ t & tlsTime -~ 1)
+2 -1
View File
@@ -94,6 +94,7 @@ youLight =
,_tlsRad = 300 ,_tlsRad = 300
,_tlsIntensity = 0.1 ,_tlsIntensity = 0.1
,_tlsUpdate = \w _ -> (w, Just (youLight {_tlsPos = f $ _crPos (you w)})) ,_tlsUpdate = \w _ -> (w, Just (youLight {_tlsPos = f $ _crPos (you w)}))
,_tlsTime = 0
} }
where where
f (V2 x y) = V3 x y 0 f (V2 x y) = V3 x y 25
+7 -6
View File
@@ -290,7 +290,7 @@ hvAutoGun = defaultAutoGun
, _itUse = useAmmoParams , _itUse = useAmmoParams
, _itUseModifiers = , _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, rateIncABI 24 7 (torqueBeforeForcedI 0.1) (torqueAfterI 0.2) , rateIncABI 24 7 (torqueBeforeAtLeast 0.1 0.1) (torqueAfterI 0.2)
, withSoundI longGunSound , withSoundI longGunSound
, withThinSmokeI , withThinSmokeI
, withMuzFlareI , withMuzFlareI
@@ -347,8 +347,8 @@ miniGun = defaultAutoGun
, _wpLoadedAmmo = 1500 , _wpLoadedAmmo = 1500
, _wpReloadTime = 200 , _wpReloadTime = 200
, _wpReloadState = 0 , _wpReloadState = 0
, _wpMaxWarmUp = 50 , _wpMaxWarmUp = 100
, _itUseRate = 1 , _itUseRate = 0
, _itUseTime = 0 , _itUseTime = 0
, _itUse = useAmmoParamsVelMod vm4 , _itUse = useAmmoParamsVelMod vm4
, _itUseModifiers = , _itUseModifiers =
@@ -358,8 +358,8 @@ miniGun = defaultAutoGun
, withRecoilI 25 , withRecoilI 25
, withSoundForI 28 2 , withSoundForI 28 2
, torqueAfterI 0.05 , torqueAfterI 0.05
--, withSidePushI 53 , withSidePushI 53
--, withRandomOffsetI 12 , withRandomOffsetI 12
, trigDoAlso (useAmmoParamsVelMod vm1) , trigDoAlso (useAmmoParamsVelMod vm1)
--, torqueBeforeForcedI 0.001 --, torqueBeforeForcedI 0.001
, withSidePushI 52 , withSidePushI 52
@@ -565,7 +565,8 @@ flamer = defaultAutoGun
, _itUseModifiers = , _itUseModifiers =
[ ammoUseCheckI [ ammoUseCheckI
, withSidePushI 5 , withSidePushI 5
, withSidePushAfterI 10 , withTempLight 1 100 (V3 1 0 0)
--, withSidePushAfterI 20
] ]
, _wpSpread = 0 , _wpSpread = 0
, _wpRange = 8 , _wpRange = 8
+1 -1
View File
@@ -34,7 +34,7 @@ autoGun = defaultAutoGun
[ ammoCheckI [ ammoCheckI
, useTimeCheckI , useTimeCheckI
, charFiringStratI , charFiringStratI
[('M', torqueBeforeForcedI 0.05) [('M', torqueBefore 0.05)
,('S', hammerCheckI) ,('S', hammerCheckI)
] ]
, withSoundI autoGunSound , withSoundI autoGunSound
+1 -1
View File
@@ -31,7 +31,7 @@ bezierGun = defaultGun
, useAmmo 1 , useAmmo 1
, withMuzFlareI , withMuzFlareI
. withRecoilI 40 . withRecoilI 40
. torqueBeforeForcedI 0.05 . torqueBefore 0.05
] ]
, _itFloorPict = onLayer FlItLayer bezierGunPic , _itFloorPict = onLayer FlItLayer bezierGunPic
, _itEquipPict = pictureWeaponOnAim bezierGunPic , _itEquipPict = pictureWeaponOnAim bezierGunPic
+44 -13
View File
@@ -5,10 +5,12 @@ module Dodge.Item.Weapon.TriggerType
, withMuzFlareI , withMuzFlareI
, withOldDir , withOldDir
, trigDoAlso , trigDoAlso
, withTempLight
--, withVelWthHiteff --, withVelWthHiteff
, ammoUseCheckI , ammoUseCheckI
, rateIncABI , rateIncABI
, torqueBeforeForcedI , torqueBefore
, torqueBeforeAtLeast
, torqueAfterI , torqueAfterI
, withSoundI , withSoundI
, withSoundForI , withSoundForI
@@ -38,6 +40,7 @@ import Dodge.WorldEvent.Cloud
import Dodge.RandomHelp import Dodge.RandomHelp
import Dodge.Item.Attachment.Data import Dodge.Item.Attachment.Data
import Dodge.Item.Data import Dodge.Item.Data
import Dodge.Default
import Geometry import Geometry
import System.Random import System.Random
@@ -162,23 +165,25 @@ Applied before the underlying effect. -}
withSidePushI withSidePushI
:: Float -- ^ Maximal possible side push amount :: Float -- ^ Maximal possible side push amount
-> ChainEffect -> ChainEffect
withSidePushI maxSide eff item cr w = eff item cr $ withSidePushI maxSide eff item cr w = eff item (push cr) $
w & creatures . ix cid %~ push w & creatures . ix cid %~ push
& randGen .~ g
where where
cid = _crID cr cid = _crID cr
push = over crPos (+.+ rotateV (_crDir cr) (V2 0 (pushAmount / _crMass cr))) push = over crPos (+.+ rotateV (_crDir cr) (V2 0 (pushAmount / _crMass cr)))
(pushAmount, _) = randomR (-maxSide,maxSide) $ _randGen w (pushAmount, g) = randomR (-maxSide,maxSide) $ _randGen w
-- consider unifying the pushes using a direction vector -- consider unifying the pushes using a direction vector
{- | Pushes a creature sideways by a random amount. {- | Pushes a creature sideways by a random amount.
Applied after the underlying effect. -} Applied after the underlying effect. -}
withSidePushAfterI withSidePushAfterI
:: Float -- ^ Maximal possible side push amount :: Float -- ^ Maximal possible side push amount
-> ChainEffect -> ChainEffect
withSidePushAfterI maxSide eff item cr w = over (creatures . ix cid) push . eff item cr $ w withSidePushAfterI maxSide eff item cr w = over (creatures . ix cid) push . eff item cr $
w & randGen .~ g
where where
cid = _crID cr cid = _crID cr
push = over crPos (+.+ rotateV (_crDir cr) (V2 0 (pushAmount / _crMass cr))) push = over crPos (+.+ rotateV (_crDir cr) (V2 0 (pushAmount / _crMass cr)))
(pushAmount, _) = randomR (-maxSide,maxSide) $ _randGen w (pushAmount, g) = randomR (-maxSide,maxSide) $ _randGen w
useAmmo useAmmo
:: Int -- ^ amount of ammo to use :: Int -- ^ amount of ammo to use
-> ChainEffect -> ChainEffect
@@ -253,6 +258,18 @@ shootL f cr invid w
&& _itUseTime item == 0 && _itUseTime item == 0
&& _wpLoadedAmmo item > 0 && _wpLoadedAmmo item > 0
reloadCondition = _wpLoadedAmmo item == 0 reloadCondition = _wpLoadedAmmo item == 0
withTempLight :: Int -> Float -> V3 Float -> ChainEffect
withTempLight time rad col eff item cr = eff item cr
. over tempLightSources (theTLS :)
where
theTLS = defaultTLS
{ _tlsPos = V3 x y 20
, _tlsRad=rad
, _tlsIntensity = col
, _tlsTime = time
}
V2 x y = _crPos cr +.+ 5 *.* unitVectorAtAngle (_crDir cr)
withMuzFlareI :: ChainEffect withMuzFlareI :: ChainEffect
withMuzFlareI f it cr w = tempLightForAt 3 pos . muzzleFlashAt pos2 $ f it cr w withMuzFlareI f it cr w = tempLightForAt 3 pos . muzzleFlashAt pos2 $ f it cr w
where where
@@ -278,12 +295,26 @@ withRandomOffsetI offsetAmount f item cr w = f item (cr & crPos %~ (+.+ offV)) $
where where
(offsetVal , g) = randomR (-offsetAmount,offsetAmount) $ _randGen w (offsetVal , g) = randomR (-offsetAmount,offsetAmount) $ _randGen w
offV = rotateV (_crDir cr) (V2 0 offsetVal) offV = rotateV (_crDir cr) (V2 0 offsetVal)
-- | Rotates a creature with minimum rotation at least 0.1. -- | Rotates a creature
-- Rotates the player creature before applying the effect, other creatures after. torqueBefore
torqueBeforeForcedI :: Float -- ^ Max possible rotation
:: Float -- ^ Max possible rotation (less the 0.1 forced rotation)
-> ChainEffect -> ChainEffect
torqueBeforeForcedI torque feff item cr w torqueBefore torque feff item cr w
| cid == 0 = feff item (cr & crDir +~ rot) $ w
& randGen .~ g
& creatures . ix cid . crDir +~ rot
& cameraRot +~ rot
| otherwise = feff item cr $ set randGen g $ over (creatures . ix cid . crDir) (+rot) w
where
cid = _crID cr
(rot, g) = randomR (-torque,torque) $ _randGen w
-- | Rotates a creature with minimum rotation
-- Rotates the player creature before applying the effect, other creatures after.
torqueBeforeAtLeast
:: Float -- ^ Minimal possible rotation
-> Float -- ^ Extra possible rotation
-> ChainEffect
torqueBeforeAtLeast minTorque exTorque feff item cr w
| cid == 0 = feff item (cr & crDir +~ rot') $ w | cid == 0 = feff item (cr & crDir +~ rot') $ w
& randGen .~ g & randGen .~ g
& creatures . ix cid . crDir +~ rot' & creatures . ix cid . crDir +~ rot'
@@ -291,9 +322,9 @@ torqueBeforeForcedI torque feff item cr w
| otherwise = feff item cr $ set randGen g $ over (creatures . ix cid . crDir) (+rot') w | otherwise = feff item cr $ set randGen g $ over (creatures . ix cid . crDir) (+rot') w
where where
cid = _crID cr cid = _crID cr
(rot, g) = randomR (-torque,torque) $ _randGen w (rot, g) = randomR (-exTorque,exTorque) $ _randGen w
rot' | rot < 0 = rot - 0.1 rot' | rot < 0 = rot - minTorque
| otherwise = rot + 0.1 | otherwise = rot + minTorque
-- | Rotate a randomly creature after applying an effect. -- | Rotate a randomly creature after applying an effect.
torqueAfterI torqueAfterI
:: Float -- ^ Max possible rotation :: Float -- ^ Max possible rotation
+4
View File
@@ -26,6 +26,7 @@ tLightFade 0 rmax intensityF (V2 x y) = TLS
, _tlsRad = rmax , _tlsRad = rmax
, _tlsIntensity = f $ intensityF 0 , _tlsIntensity = f $ intensityF 0
, _tlsUpdate = \w _ -> (w, Nothing) , _tlsUpdate = \w _ -> (w, Nothing)
, _tlsTime = 0
} }
where where
f x' = V3 x' x' x' f x' = V3 x' x' x'
@@ -34,6 +35,7 @@ tLightFade i rmax intensityF p@(V2 x y) = TLS
, _tlsRad = rmax , _tlsRad = rmax
, _tlsIntensity = f $ intensityF i , _tlsIntensity = f $ intensityF i
, _tlsUpdate = \w _ -> (w, Just $ tLightFade (i-1) rmax intensityF p) , _tlsUpdate = \w _ -> (w, Just $ tLightFade (i-1) rmax intensityF p)
, _tlsTime = 0
} }
where where
f x' = V3 x' x' x' f x' = V3 x' x' x'
@@ -49,12 +51,14 @@ tLightRad 0 rmax _ (V2 x y) = TLS
, _tlsRad = rmax , _tlsRad = rmax
, _tlsIntensity = 0.5 , _tlsIntensity = 0.5
, _tlsUpdate = \w _ -> (w, Nothing) , _tlsUpdate = \w _ -> (w, Nothing)
, _tlsTime = 0
} }
tLightRad i rmax rmin p@(V2 x y) = TLS tLightRad i rmax rmin p@(V2 x y) = TLS
{ _tlsPos = V3 x y 0 { _tlsPos = V3 x y 0
, _tlsRad = rmax , _tlsRad = rmax
, _tlsIntensity = V3 0.5 0.5 0 , _tlsIntensity = V3 0.5 0.5 0
, _tlsUpdate = \w _ -> (w, Just $ tLightRad (i-1) rmax rmin p) , _tlsUpdate = \w _ -> (w, Just $ tLightRad (i-1) rmax rmin p)
, _tlsTime = 0
} }
tLightAt :: Int -> Point2 -> TempLightSource tLightAt :: Int -> Point2 -> TempLightSource
+1 -1
View File
@@ -61,4 +61,4 @@ damCrsOnLine dam p1 p2 = over creatures (IM.map damIfOnLine)
| otherwise = cr | otherwise = cr
tempLightForAt :: Int -> Point2 -> World -> World tempLightForAt :: Int -> Point2 -> World -> World
tempLightForAt i p w = w & tempLightSources %~ (:) (tLightAt i p) tempLightForAt i p w = w & tempLightSources %~ (tLightAt i p :)
+7 -4
View File
@@ -59,9 +59,12 @@ drawFlame rotd pt = thePic
ep = _btPos' pt ep = _btPos' pt
thePic = pictures thePic = pictures
[ glow [ glow
, aPic 3 prot2 18 (V2 (scaleChange + 1) 2 ) red , aPic 1 prot2 18 (V2 (scaleChange + 1) 2 ) $ V4 2 0 (-10) 0.5
, aPic 4 prot 19 (V2 (scaleChange + 0.5) 1.5) orange , aPic 1 prot 19 (V2 (scaleChange + 0.5) 1.5) $ V4 2 0.5 (-10) 2
, aPic 5 prot3 20 (V2 scaleChange 1 ) white , aPic 1 prot3 20 (V2 scaleChange 1 ) $ V4 1 1 1 2
--, aPic 3 prot2 18 (V2 (scaleChange + 1) 2 ) red
--, aPic 4 prot 19 (V2 (scaleChange + 0.5) 1.5) orange
--, aPic 5 prot3 20 (V2 scaleChange 1 ) white
] ]
aPic :: Int -> (Point2 -> Point2) -> Float -> Point2 -> Color -> Picture aPic :: Int -> (Point2 -> Point2) -> Float -> Point2 -> Color -> Picture
aPic lay offset depth (V2 scalex scaley) col aPic lay offset depth (V2 scalex scaley) col
@@ -96,7 +99,7 @@ moveFlame rotd w pt
_ -> (soundAndGlare damcrs , mvPt) _ -> (soundAndGlare damcrs , mvPt)
where where
time = _btTimer' pt time = _btTimer' pt
soundAndGlare = soundFrom Flame fireSound 2 500 . over worldEvents ((.) $ flameGlareAt ep) soundAndGlare = soundFrom Flame fireSound 2 500 -- . over worldEvents ((.) $ flameGlareAt ep)
sp = _btPos' pt sp = _btPos' pt
vel = _btVel' pt vel = _btVel' pt
ep = sp +.+ vel ep = sp +.+ vel