Implement tracking rockets
This commit is contained in:
@@ -54,7 +54,9 @@ itemCombinations =
|
||||
, po [ELEPHANTGUN,HARDWARE,CAN] sniperRifle
|
||||
, 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 [FLAMESTICK,CAN,PUMP] blowTorch
|
||||
@@ -110,7 +112,7 @@ moduleCombinations =
|
||||
]
|
||||
)
|
||||
, ( ModTarget
|
||||
, launcher : bulletWeapons
|
||||
, trackingLauncher : launcher : bulletWeapons
|
||||
, [amod [MICROCHIP,CREATURESENSOR] "+CREATURETARGETING" (itTargeting .~ targetRBCreature)
|
||||
,amod [MICROCHIP,PRISM] "+LASERTARGETING" (itTargeting .~ targetLaser)
|
||||
,amod [MICROCHIP,TIN] "+POSTIONALTARGETING" (itTargeting .~ targetRBPress)
|
||||
@@ -120,7 +122,9 @@ moduleCombinations =
|
||||
, bulletWeapons
|
||||
, [amod [TELEPORTMODULE,MICROCHIP] "+DIRECTEDTELE" makeDirectedTele
|
||||
,amod [MAGNET,MICROCHIP,HARDWARE] "+MAGNETTRAJECTORY"
|
||||
( (itConsumption . aoType . amBulTraj .~ MagnetTrajectory) )
|
||||
( (itConsumption . aoType . amBulTraj .~ MagnetTrajectory)
|
||||
. (itConsumption . aoType . amBulVel .~ V2 10 0)
|
||||
)
|
||||
,amod [MICROCHIP,HARDWARE] "+FLECHETTETRAJECTORY"
|
||||
(itConsumption . aoType . amBulTraj .~ FlechetteTrajectory)
|
||||
,amod [ANTIMATTER,HARDWARE] "+BEZIERTRAJECTORY"
|
||||
|
||||
@@ -38,6 +38,7 @@ data CombineType
|
||||
| SNIPERRIFLE
|
||||
| MACHINEGUN
|
||||
| FLAMESTICK
|
||||
| FLAMER
|
||||
| BLOWTORCH
|
||||
| FLAMETHROWER
|
||||
| AUTOGUN
|
||||
@@ -49,8 +50,9 @@ data CombineType
|
||||
| SONICGUN
|
||||
| TRACTORGUN
|
||||
| LAUNCHER
|
||||
| TRACKINGLAUNCHER
|
||||
| REMOTELAUNCHER
|
||||
| SPRAYER
|
||||
| SQUIRTER
|
||||
| DRONELAUNCHER
|
||||
| GRENADE
|
||||
| REMOTEBOMB
|
||||
@@ -84,8 +86,11 @@ data CombineType
|
||||
| MAGNET
|
||||
| ANTIMATTER
|
||||
| PLATE
|
||||
| TRANSMITTER
|
||||
| MICROCHIP
|
||||
| AIUNIT
|
||||
| CAMERA
|
||||
| MINIDISPLAY -- visual display unit
|
||||
| LED
|
||||
| NAILBOX
|
||||
| IRONBAR
|
||||
|
||||
@@ -180,6 +180,7 @@ testInventory = IM.fromList $ zip [0..]
|
||||
, makeTypeCraftNum 3 PLANK
|
||||
, makeTypeCraftNum 1 MOTOR
|
||||
, makeTypeCraftNum 5 MICROCHIP
|
||||
, makeTypeCraftNum 1 TRANSMITTER
|
||||
, makeTypeCraftNum 5 AIUNIT
|
||||
]
|
||||
stackedInventory :: IM.IntMap Item
|
||||
|
||||
+1
-1
@@ -567,7 +567,7 @@ data ItemParams
|
||||
, _shellThrustDelay :: Int
|
||||
}
|
||||
| Refracting {_phaseV :: Float}
|
||||
| BulletShooter
|
||||
| BulletShooter -- this should possibly be moved into ammo type
|
||||
{ _muzVel :: Float
|
||||
, _rifling :: Float
|
||||
, _bore :: Float
|
||||
|
||||
@@ -33,7 +33,6 @@ defaultAimParams = AimParams
|
||||
, _aimZoom = ItZoom 20 0.2 1
|
||||
, _aimStance = OneHand
|
||||
}
|
||||
|
||||
useAmmoParams :: Maybe Float -> Item -> Creature -> World -> World
|
||||
useAmmoParams vfact it cr w = w & particles .:~ aBulAt
|
||||
vfact
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
module Dodge.Item.Weapon.Grenade
|
||||
where
|
||||
module Dodge.Item.Weapon.Grenade where
|
||||
import Dodge.Data
|
||||
import Dodge.Picture.Layer
|
||||
import Dodge.WorldEvent.Explosion
|
||||
--import Dodge.Item.Weapon.TriggerType
|
||||
import Dodge.Item.Weapon.Remote
|
||||
import Dodge.Default
|
||||
--import Dodge.Default.Weapon
|
||||
import Dodge.Base
|
||||
import Dodge.Zone
|
||||
import Dodge.SoundLogic
|
||||
@@ -199,14 +196,6 @@ moveRemoteBomb itid time pID w
|
||||
(\_ -> (,) 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 = grenade
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.Item.Weapon.Launcher
|
||||
( launcher
|
||||
, trackingLauncher
|
||||
, remoteLauncher
|
||||
) where
|
||||
import Dodge.Data
|
||||
@@ -12,6 +13,7 @@ import Dodge.WorldEvent.Explosion
|
||||
import Dodge.Item.Weapon.Shell
|
||||
import Dodge.Item.Weapon.Remote
|
||||
import Dodge.Item.Weapon.TriggerType
|
||||
import Dodge.Movement.Turn
|
||||
import Dodge.Base
|
||||
import Dodge.Zone
|
||||
import Dodge.SoundLogic
|
||||
@@ -133,6 +135,20 @@ pjThrust i = pjEffTimeRange (st,et) doThrust
|
||||
| otherwise = 40 - (i * 20)
|
||||
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 pj w = w
|
||||
& randGen .~ g
|
||||
@@ -260,11 +276,19 @@ trySpinByCID cid i pj w = w & props . ix pjid . pjSpin .~ newSpin
|
||||
_ -> 0
|
||||
spinFactor = 5 * (6 - fromIntegral i)
|
||||
|
||||
|
||||
trackingLauncher :: Item
|
||||
trackingLauncher = launcher
|
||||
{ _itName = "ROCKO-TRACK"
|
||||
, _itType = TRACKINGLAUNCHER
|
||||
, _itUse = ruseRate 10 fireTrackingLauncher upHammer
|
||||
[ ammoCheckI
|
||||
, hammerCheckI
|
||||
]
|
||||
}
|
||||
remoteLauncher :: Item
|
||||
remoteLauncher = launcher
|
||||
{ _itName = "ROCKO-REM"
|
||||
, _itType = LAUNCHER
|
||||
{ _itName = "ROCKO-REMOTE"
|
||||
, _itType = REMOTELAUNCHER
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _aoType = defaultShellAmmo
|
||||
{ _amPayload = makeExplosionAt
|
||||
@@ -279,9 +303,6 @@ remoteLauncher = launcher
|
||||
[ ammoCheckI
|
||||
, hammerCheckI
|
||||
]
|
||||
& useAim . aimSpeed .~ 0.2
|
||||
& useAim . aimRange .~ 0.5
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
, _itScope = RemoteScope (V2 0 0) 1 True
|
||||
-- , _itParams = ShellLauncher
|
||||
-- { _tweakSel = 0
|
||||
@@ -410,9 +431,46 @@ remoteShellPic t
|
||||
retireRemoteRocket :: Int -> Int -> Int -> World -> World
|
||||
retireRemoteRocket = retireRemoteProj $ const fireRemoteLauncher
|
||||
|
||||
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'
|
||||
|
||||
fireTrackingLauncher :: Item -> Creature -> World -> World
|
||||
fireTrackingLauncher it cr w = setLocation
|
||||
$ soundStart (CrWeaponSound cid 0) pos tap4S Nothing
|
||||
$ over props addTrackRocket 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
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
module Dodge.Item.Weapon.Remote
|
||||
( pointToItem
|
||||
, retireRemoteProj
|
||||
, setRemoteScope
|
||||
, setRemoteBombScope
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Default
|
||||
import Geometry
|
||||
|
||||
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))
|
||||
_ -> w'
|
||||
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'
|
||||
|
||||
@@ -90,7 +90,7 @@ flameWall = undefined
|
||||
flamer :: Item
|
||||
flamer = defaultAutoGun
|
||||
{ _itName = "FLAMER"
|
||||
, _itType = SQUIRTER
|
||||
, _itType = FLAMER
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _ammoBaseMax = 250
|
||||
, _ammoLoaded = 250
|
||||
|
||||
@@ -12,6 +12,17 @@ turnTo turnSpeed sp tp a
|
||||
vdir = unitVectorAtAngle a
|
||||
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 turnSpeed sp tp vdir
|
||||
| angleVV vToTarg vdir <= turnSpeed
|
||||
|
||||
@@ -156,6 +156,7 @@ isLeftOf :: Point2 -> Point2 -> Bool
|
||||
isLeftOf x y = isLeftOfA (argV x) (argV y)
|
||||
-- | Find the difference between two angles.
|
||||
-- Possibly not correct...
|
||||
-- TODO write tests
|
||||
diffAngles :: Float -> Float -> Float
|
||||
diffAngles x y
|
||||
| diff > pi = diffAngles (x - 2*pi) y
|
||||
|
||||
Reference in New Issue
Block a user