Separate out bullet effects, allow for tweaking to change these

This commit is contained in:
2021-11-30 13:11:34 +00:00
parent e75cbdf6cb
commit 4d21c0f31a
13 changed files with 207 additions and 81 deletions
+41 -24
View File
@@ -11,11 +11,11 @@ import Dodge.SoundLogic.LoadSound
import Dodge.WorldEvent
import Dodge.WorldEvent.Damage
--import Dodge.Default
import Dodge.Item.Weapon.InventoryDisplay
--import Dodge.Item.Weapon.InventoryDisplay
import Dodge.Item.Weapon.TriggerType
import Dodge.Item.Weapon.AmmoParams
import Dodge.Default.Weapon
import Dodge.Item.Attachment
--import Dodge.Item.Attachment
import Dodge.WorldEvent.HelperParticle
import Dodge.Base
import Dodge.Zone
@@ -26,11 +26,11 @@ import ShapePicture
import Dodge.Picture
import Data.Function
import qualified Data.Sequence as Seq
--import qualified Data.Sequence as Seq
import Data.List
import Control.Lens
import System.Random
import Data.Maybe
--import Data.Maybe
import Data.Tuple
import qualified Data.IntMap.Strict as IM
teslaGun :: Item
@@ -51,7 +51,6 @@ teslaGun = defaultGun
& useAim . aimSpeed .~ 0.4
& useAim . aimStance .~ TwoHandFlat
, _itFloorPict = teslaGunPic
-- , _itZoom = defaultItZoom
}
teslaGunPic :: Item -> SPic
teslaGunPic _ = noPic $ colorSH blue $
@@ -80,11 +79,30 @@ lasGun = defaultAutoGun
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
, _itFloorPict = lasGunPic
, _itAttachment = ItCharMode $ Seq.fromList "/VZ"
, _itScroll = scrollCharMode
, _itInvDisplay = basicWeaponDisplay
, _itParams = Refracting {_phaseVel = 1}
, _itParams = Refracting {_phaseV = 1}
, _itTweaks = Tweakable
{ _tweakParams = IM.fromList [(0,lasGunTweak)]
, _tweakSel = 0
}
}
lasGunTweak :: TweakParam
lasGunTweak = TweakParam
{ _doTweak = thetweak
, _curTweak = 1
, _maxTweak = 3
, _showTweak = showPhaseV
, _nameTweak = "PHASE VELOCITY"
}
where
thetweak 0 = itParams . phaseV .~ 0.2
thetweak 1 = itParams . phaseV .~ 1
thetweak 2 = itParams . phaseV .~ 5
thetweak _ = id
showPhaseV 0 = "V"
showPhaseV 1 = "/"
showPhaseV 2 = "Z"
showPhaseV i = "THIS SHOULD NOT BE POSSIBLE" ++ show i
lasGunPic :: Item -> SPic
lasGunPic it =
( colorSH blue $
@@ -133,24 +151,23 @@ aTeslaArc cr w = set randGen g w
chooseColor _ = cyan
aLaser :: Creature -> World -> World
aLaser cr = particles %~ (makeLaserAt phaseV pos dir : )
aLaser cr = particles %~ (makeLaserAt phasev pos dir : )
where
pos = _crPos cr +.+ ((_crRad cr +3) *.* unitVectorAtAngle dir)
dir = _crDir cr
phaseV = charToPhaseV
$ fromMaybe '/' $ Seq.lookup 0 =<< cr ^? crInv . ix j . itAttachment . itCharMode
phasev = _phaseV . _itParams $ _crInv cr IM.! j
j = _crInvSel cr
charToPhaseV :: Fractional p => Char -> p
charToPhaseV 'V' = 0.2
charToPhaseV '/' = 1
charToPhaseV 'Z' = 5
charToPhaseV _ = error "Trying to set an undefined phaseV"
--charToPhaseV :: Fractional p => Char -> p
--charToPhaseV 'V' = 0.2
--charToPhaseV '/' = 1
--charToPhaseV 'Z' = 5
--charToPhaseV _ = error "Trying to set an undefined phaseV"
makeLaserAt :: Float -> Point2 -> Float -> Particle
makeLaserAt phaseV pos dir = Particle
makeLaserAt phasev pos dir = Particle
{ _ptDraw = const blank
, _ptUpdate = moveLaser phaseV pos dir
, _ptUpdate = moveLaser phasev pos dir
}
moveLaser
:: Float -- ^ Phase velocity, controls deflection through windows
@@ -159,7 +176,7 @@ moveLaser
-> World
-> Particle
-> (World, Maybe Particle)
moveLaser phaseV pos dir w pt
moveLaser phasev pos dir w pt
= ( hitEffect w
, Just pt {_ptDraw = const pic ,_ptUpdate = ptSimpleTime 0 }
)
@@ -183,7 +200,7 @@ moveLaser phaseV pos dir w pt
angleInc = piRange $ argV wlNormal - argV (x -.- y)
angleRef
| reflectExternal = angleInc
| otherwise = asin $ sin angleInc / phaseV
| otherwise = asin $ sin angleInc / phasev
piRange a'
| a' > pi = a' - 2 * pi
| a' > negate pi = a'
@@ -194,9 +211,9 @@ moveLaser phaseV pos dir w pt
angleInc' = piRange $ argV wlNormal' - argV (x -.- y)
angleRef'
| reflectInternal = angleInc'
| otherwise = asin $ phaseV * sin angleInc'
reflectInternal = 1 < abs (phaseV * sin angleInc')
reflectExternal = 1 < abs (sin angleInc / phaseV)
| otherwise = asin $ phasev * sin angleInc'
reflectInternal = 1 < abs (phasev * sin angleInc')
reflectExternal = 1 < abs (sin angleInc / phasev)
h' ws (_,Right wl) = not $ any (\w' -> _wlID w' == _wlID wl) ws
h' _ _ = True