Implement tracking rockets

This commit is contained in:
2022-03-01 18:22:47 +00:00
parent fd62b5a3b7
commit 910542a96a
11 changed files with 118 additions and 31 deletions
+7 -3
View File
@@ -54,7 +54,9 @@ itemCombinations =
, po [ELEPHANTGUN,HARDWARE,CAN] sniperRifle , po [ELEPHANTGUN,HARDWARE,CAN] sniperRifle
, po [BANGROD,PLATE,DRUM,MOTOR] machineGun , po [BANGROD,PLATE,DRUM,MOTOR] machineGun
, p [p 3 TUBE,o HARDWARE] launcher , p [p 2 TUBE,o HARDWARE] launcher
, po [MICROCHIP,TRANSMITTER,LAUNCHER] trackingLauncher
, po [MICROCHIP,TRANSMITTER,MINIDISPLAY,LAUNCHER] remoteLauncher
, po [LIGHTER,PIPE,CAN] flameStick , po [LIGHTER,PIPE,CAN] flameStick
, po [FLAMESTICK,CAN,PUMP] blowTorch , po [FLAMESTICK,CAN,PUMP] blowTorch
@@ -110,7 +112,7 @@ moduleCombinations =
] ]
) )
, ( ModTarget , ( ModTarget
, launcher : bulletWeapons , trackingLauncher : launcher : bulletWeapons
, [amod [MICROCHIP,CREATURESENSOR] "+CREATURETARGETING" (itTargeting .~ targetRBCreature) , [amod [MICROCHIP,CREATURESENSOR] "+CREATURETARGETING" (itTargeting .~ targetRBCreature)
,amod [MICROCHIP,PRISM] "+LASERTARGETING" (itTargeting .~ targetLaser) ,amod [MICROCHIP,PRISM] "+LASERTARGETING" (itTargeting .~ targetLaser)
,amod [MICROCHIP,TIN] "+POSTIONALTARGETING" (itTargeting .~ targetRBPress) ,amod [MICROCHIP,TIN] "+POSTIONALTARGETING" (itTargeting .~ targetRBPress)
@@ -120,7 +122,9 @@ moduleCombinations =
, bulletWeapons , bulletWeapons
, [amod [TELEPORTMODULE,MICROCHIP] "+DIRECTEDTELE" makeDirectedTele , [amod [TELEPORTMODULE,MICROCHIP] "+DIRECTEDTELE" makeDirectedTele
,amod [MAGNET,MICROCHIP,HARDWARE] "+MAGNETTRAJECTORY" ,amod [MAGNET,MICROCHIP,HARDWARE] "+MAGNETTRAJECTORY"
( (itConsumption . aoType . amBulTraj .~ MagnetTrajectory) ) ( (itConsumption . aoType . amBulTraj .~ MagnetTrajectory)
. (itConsumption . aoType . amBulVel .~ V2 10 0)
)
,amod [MICROCHIP,HARDWARE] "+FLECHETTETRAJECTORY" ,amod [MICROCHIP,HARDWARE] "+FLECHETTETRAJECTORY"
(itConsumption . aoType . amBulTraj .~ FlechetteTrajectory) (itConsumption . aoType . amBulTraj .~ FlechetteTrajectory)
,amod [ANTIMATTER,HARDWARE] "+BEZIERTRAJECTORY" ,amod [ANTIMATTER,HARDWARE] "+BEZIERTRAJECTORY"
+6 -1
View File
@@ -38,6 +38,7 @@ data CombineType
| SNIPERRIFLE | SNIPERRIFLE
| MACHINEGUN | MACHINEGUN
| FLAMESTICK | FLAMESTICK
| FLAMER
| BLOWTORCH | BLOWTORCH
| FLAMETHROWER | FLAMETHROWER
| AUTOGUN | AUTOGUN
@@ -49,8 +50,9 @@ data CombineType
| SONICGUN | SONICGUN
| TRACTORGUN | TRACTORGUN
| LAUNCHER | LAUNCHER
| TRACKINGLAUNCHER
| REMOTELAUNCHER
| SPRAYER | SPRAYER
| SQUIRTER
| DRONELAUNCHER | DRONELAUNCHER
| GRENADE | GRENADE
| REMOTEBOMB | REMOTEBOMB
@@ -84,8 +86,11 @@ data CombineType
| MAGNET | MAGNET
| ANTIMATTER | ANTIMATTER
| PLATE | PLATE
| TRANSMITTER
| MICROCHIP | MICROCHIP
| AIUNIT | AIUNIT
| CAMERA
| MINIDISPLAY -- visual display unit
| LED | LED
| NAILBOX | NAILBOX
| IRONBAR | IRONBAR
+1
View File
@@ -180,6 +180,7 @@ testInventory = IM.fromList $ zip [0..]
, makeTypeCraftNum 3 PLANK , makeTypeCraftNum 3 PLANK
, makeTypeCraftNum 1 MOTOR , makeTypeCraftNum 1 MOTOR
, makeTypeCraftNum 5 MICROCHIP , makeTypeCraftNum 5 MICROCHIP
, makeTypeCraftNum 1 TRANSMITTER
, makeTypeCraftNum 5 AIUNIT , makeTypeCraftNum 5 AIUNIT
] ]
stackedInventory :: IM.IntMap Item stackedInventory :: IM.IntMap Item
+1 -1
View File
@@ -567,7 +567,7 @@ data ItemParams
, _shellThrustDelay :: Int , _shellThrustDelay :: Int
} }
| Refracting {_phaseV :: Float} | Refracting {_phaseV :: Float}
| BulletShooter | BulletShooter -- this should possibly be moved into ammo type
{ _muzVel :: Float { _muzVel :: Float
, _rifling :: Float , _rifling :: Float
, _bore :: Float , _bore :: Float
-1
View File
@@ -33,7 +33,6 @@ defaultAimParams = AimParams
, _aimZoom = ItZoom 20 0.2 1 , _aimZoom = ItZoom 20 0.2 1
, _aimStance = OneHand , _aimStance = OneHand
} }
useAmmoParams :: Maybe Float -> Item -> Creature -> World -> World useAmmoParams :: Maybe Float -> Item -> Creature -> World -> World
useAmmoParams vfact it cr w = w & particles .:~ aBulAt useAmmoParams vfact it cr w = w & particles .:~ aBulAt
vfact vfact
+1 -12
View File
@@ -1,12 +1,9 @@
module Dodge.Item.Weapon.Grenade module Dodge.Item.Weapon.Grenade where
where
import Dodge.Data import Dodge.Data
import Dodge.Picture.Layer import Dodge.Picture.Layer
import Dodge.WorldEvent.Explosion import Dodge.WorldEvent.Explosion
--import Dodge.Item.Weapon.TriggerType --import Dodge.Item.Weapon.TriggerType
import Dodge.Item.Weapon.Remote import Dodge.Item.Weapon.Remote
import Dodge.Default
--import Dodge.Default.Weapon
import Dodge.Base import Dodge.Base
import Dodge.Zone import Dodge.Zone
import Dodge.SoundLogic import Dodge.SoundLogic
@@ -199,14 +196,6 @@ moveRemoteBomb itid time pID w
(\_ -> (,) mempty $ onLayer PtLayer $ uncurryV translate newPos $ remoteBombPic time) (\_ -> (,) mempty $ onLayer PtLayer $ uncurryV translate newPos $ remoteBombPic time)
setRemoteBombScope :: Int -> Prop -> World -> World
setRemoteBombScope itid pj w' = case _itemPositions w' IM.! itid of
InInv cid invid
-> w' & creatures . ix cid . crInv . ix invid . itScope
. scopePos .~ (_pjPos pj -.- _crPos (_creatures w' IM.! cid))
& creatures . ix cid . crInv . ix invid . itUse . useAim . aimZoom
.~ (defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5})
_ -> w'
--defaultThrowable :: Item --defaultThrowable :: Item
--defaultThrowable = grenade --defaultThrowable = grenade
+70 -12
View File
@@ -1,5 +1,6 @@
module Dodge.Item.Weapon.Launcher module Dodge.Item.Weapon.Launcher
( launcher ( launcher
, trackingLauncher
, remoteLauncher , remoteLauncher
) where ) where
import Dodge.Data import Dodge.Data
@@ -12,6 +13,7 @@ import Dodge.WorldEvent.Explosion
import Dodge.Item.Weapon.Shell import Dodge.Item.Weapon.Shell
import Dodge.Item.Weapon.Remote import Dodge.Item.Weapon.Remote
import Dodge.Item.Weapon.TriggerType import Dodge.Item.Weapon.TriggerType
import Dodge.Movement.Turn
import Dodge.Base import Dodge.Base
import Dodge.Zone import Dodge.Zone
import Dodge.SoundLogic import Dodge.SoundLogic
@@ -133,6 +135,20 @@ pjThrust i = pjEffTimeRange (st,et) doThrust
| otherwise = 40 - (i * 20) | otherwise = 40 - (i * 20)
st = et - 100 st = et - 100
pjTrack :: Int -> Int -> Prop -> World -> World
pjTrack itid i pj w = pjEffTimeRange (st,et) rotateToTarget pj w
where
et | i == 0 = 36
| otherwise = 40 - (i * 20)
st = et - 100
pjpos = _pjPos pj
rotateToTarget _ = fromMaybe id $ do
tpos <- w ^? itPoint . itTargeting . tgPos . _Just
--let tdir = argV $ tpos -.- pjpos
--return $ props . ix (_pjID pj) . pjSpin .~ tdir - turnTo 0.1 pjpos tpos tdir
return $ (props . ix (_pjID pj) . pjSpin .~ turnToAmount 0.15 pjpos tpos (argV $ _pjAcc pj))
itPoint = pointToItem $ _itemPositions w IM.! itid
doThrust :: Prop -> World -> World doThrust :: Prop -> World -> World
doThrust pj w = w doThrust pj w = w
& randGen .~ g & randGen .~ g
@@ -260,11 +276,19 @@ trySpinByCID cid i pj w = w & props . ix pjid . pjSpin .~ newSpin
_ -> 0 _ -> 0
spinFactor = 5 * (6 - fromIntegral i) spinFactor = 5 * (6 - fromIntegral i)
trackingLauncher :: Item
trackingLauncher = launcher
{ _itName = "ROCKO-TRACK"
, _itType = TRACKINGLAUNCHER
, _itUse = ruseRate 10 fireTrackingLauncher upHammer
[ ammoCheckI
, hammerCheckI
]
}
remoteLauncher :: Item remoteLauncher :: Item
remoteLauncher = launcher remoteLauncher = launcher
{ _itName = "ROCKO-REM" { _itName = "ROCKO-REMOTE"
, _itType = LAUNCHER , _itType = REMOTELAUNCHER
, _itConsumption = defaultAmmo , _itConsumption = defaultAmmo
{ _aoType = defaultShellAmmo { _aoType = defaultShellAmmo
{ _amPayload = makeExplosionAt { _amPayload = makeExplosionAt
@@ -279,9 +303,6 @@ remoteLauncher = launcher
[ ammoCheckI [ ammoCheckI
, hammerCheckI , hammerCheckI
] ]
& useAim . aimSpeed .~ 0.2
& useAim . aimRange .~ 0.5
& useAim . aimStance .~ TwoHandTwist
, _itScope = RemoteScope (V2 0 0) 1 True , _itScope = RemoteScope (V2 0 0) 1 True
-- , _itParams = ShellLauncher -- , _itParams = ShellLauncher
-- { _tweakSel = 0 -- { _tweakSel = 0
@@ -410,9 +431,46 @@ remoteShellPic t
retireRemoteRocket :: Int -> Int -> Int -> World -> World retireRemoteRocket :: Int -> Int -> Int -> World -> World
retireRemoteRocket = retireRemoteProj $ const fireRemoteLauncher retireRemoteRocket = retireRemoteProj $ const fireRemoteLauncher
setRemoteScope :: Int -> Prop -> World -> World
setRemoteScope itid pj w' = case w' ^? itemPositions . ix itid of fireTrackingLauncher :: Item -> Creature -> World -> World
Just (InInv cid' invid ) fireTrackingLauncher it cr w = setLocation
-> w' & creatures . ix cid' . crInv . ix invid . itScope $ soundStart (CrWeaponSound cid 0) pos tap4S Nothing
. scopePos .~ (_pjPos pj -.- _crPos (_creatures w' IM.! cid')) $ over props addTrackRocket w
_ -> w' where
i = IM.newKey $ _props w
am = _itConsumption it
cid = _crID cr
dir = _crDir cr
pos = _crPos cr +.+ rotateV dir (V2 (_crRad cr + 1) 0)
addTrackRocket = IM.insert i $ Shell
{ _pjPos = pos
, _pjZ = 20
, _pjStartPos = pos
, _pjVel = rotateV dir (V2 1 0)
, _prDraw = _amPjDraw $ _aoType am
, _pjID = i
, _pjUpdate = \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj
. pjThrust thrustdelay pj
. reduceSpinBy (1-fromIntegral spindrag*2 / 200) pj
. decTimMvVel pj
. pjTrack itid thrustdelay pj
. moveShell pj
, _pjAcc = rotateV dir (V2 3 0)
, _pjDir = dir
, _pjSpin = 0
, _pjPayload = makeExplosionAt
, _pjTimer = 50
}
j = _crInvSel cr
newitid = IM.newKey $ _itemPositions w
maybeitid = cr ^? crInv . ix j . itID . _Just
setLocation :: World -> World
setLocation w' = case maybeitid of
Nothing -> w' & creatures . ix cid . crInv . ix j . itID ?~ newitid
& itemPositions %~ IM.insert newitid (InInv cid j)
_ -> w'
itid = fromMaybe newitid maybeitid
spinamount = _shellSpinAmount params
thrustdelay = _shellThrustDelay params
spindrag = _shellSpinDrag params
params = _itParams it
+19
View File
@@ -1,8 +1,11 @@
module Dodge.Item.Weapon.Remote module Dodge.Item.Weapon.Remote
( pointToItem ( pointToItem
, retireRemoteProj , retireRemoteProj
, setRemoteScope
, setRemoteBombScope
) where ) where
import Dodge.Data import Dodge.Data
import Dodge.Default
import Geometry import Geometry
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
@@ -31,3 +34,19 @@ retireRemoteProj resetFire itid t pjid w = setScope w
. scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid)) . scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid))
_ -> w' _ -> w'
pos = fromMaybe (V2 0 0) $ w ^? props . ix pjid . pjPos pos = fromMaybe (V2 0 0) $ w ^? props . ix pjid . pjPos
setRemoteBombScope :: Int -> Prop -> World -> World
setRemoteBombScope itid pj w' = case _itemPositions w' IM.! itid of
InInv cid invid
-> w' & creatures . ix cid . crInv . ix invid . itScope
. scopePos .~ (_pjPos pj -.- _crPos (_creatures w' IM.! cid))
& creatures . ix cid . crInv . ix invid . itUse . useAim . aimZoom
.~ (defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5})
_ -> w'
setRemoteScope :: Int -> Prop -> World -> World
setRemoteScope itid pj w' = case w' ^? itemPositions . ix itid of
Just (InInv cid' invid )
-> w' & creatures . ix cid' . crInv . ix invid . itScope
. scopePos .~ (_pjPos pj -.- _crPos (_creatures w' IM.! cid'))
_ -> w'
+1 -1
View File
@@ -90,7 +90,7 @@ flameWall = undefined
flamer :: Item flamer :: Item
flamer = defaultAutoGun flamer = defaultAutoGun
{ _itName = "FLAMER" { _itName = "FLAMER"
, _itType = SQUIRTER , _itType = FLAMER
, _itConsumption = defaultAmmo , _itConsumption = defaultAmmo
{ _ammoBaseMax = 250 { _ammoBaseMax = 250
, _ammoLoaded = 250 , _ammoLoaded = 250
+11
View File
@@ -12,6 +12,17 @@ turnTo turnSpeed sp tp a
vdir = unitVectorAtAngle a vdir = unitVectorAtAngle a
vToTarg = tp -.- sp vToTarg = tp -.- sp
turnToAmount :: Float -> Point2 -> Point2 -> Float -> Float
turnToAmount turnSpeed sp tp a
| vToTarg == V2 0 0 = 0
| angleVV vToTarg vdir <= turnSpeed
= diffAngles a (argV vToTarg) -- TODO check correctness
| isLHS (sp +.+ vdir) sp tp = negate turnSpeed
| otherwise = turnSpeed
where
vdir = unitVectorAtAngle a
vToTarg = tp -.- sp
vecTurnTo :: Float -> Point2 -> Point2 -> Point2 -> Point2 vecTurnTo :: Float -> Point2 -> Point2 -> Point2 -> Point2
vecTurnTo turnSpeed sp tp vdir vecTurnTo turnSpeed sp tp vdir
| angleVV vToTarg vdir <= turnSpeed | angleVV vToTarg vdir <= turnSpeed
+1
View File
@@ -156,6 +156,7 @@ isLeftOf :: Point2 -> Point2 -> Bool
isLeftOf x y = isLeftOfA (argV x) (argV y) isLeftOf x y = isLeftOfA (argV x) (argV y)
-- | Find the difference between two angles. -- | Find the difference between two angles.
-- Possibly not correct... -- Possibly not correct...
-- TODO write tests
diffAngles :: Float -> Float -> Float diffAngles :: Float -> Float -> Float
diffAngles x y diffAngles x y
| diff > pi = diffAngles (x - 2*pi) y | diff > pi = diffAngles (x - 2*pi) y