Cleanup projectile firing
This commit is contained in:
@@ -729,15 +729,13 @@ useLoadedAmmo loc cr mz m w =
|
||||
MuzzlePulseBall -> creatureShootPulseBall loc cr mz w
|
||||
MuzzleTesla -> shootTeslaArc loc cr mz w
|
||||
MuzzleTractor -> shootTractorBeam cr w
|
||||
MuzzleRLauncher -> createProjectileR loc magtree mz cr w
|
||||
MuzzleRLauncher -> createProjectileR pq loc magtree cr w
|
||||
MuzzleGLauncher ->
|
||||
createProjectile
|
||||
pq
|
||||
-- (itmtree ^. dtValue . _3)
|
||||
(Grenade (getGrenadeHitEffect itmtree))
|
||||
magtree
|
||||
(getPJStabiliser itmtree)
|
||||
mz
|
||||
cr
|
||||
w
|
||||
MuzzleNozzle{} -> useGasParams mitid mz loc cr $ walkNozzle mz itm w
|
||||
@@ -1267,15 +1265,15 @@ determineProjectileTracking magtree itmtree =
|
||||
_ -> False
|
||||
|
||||
createProjectileR ::
|
||||
Point3Q ->
|
||||
LocationDT OItem ->
|
||||
DTree OItem ->
|
||||
Muzzle ->
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
createProjectileR loc magtree =
|
||||
createProjectileR pq loc magtree =
|
||||
createProjectile
|
||||
(loc ^. locDT . dtValue . _3)
|
||||
pq
|
||||
( Rocket
|
||||
(determineProjectileTracking magtree itmtree)
|
||||
smoke
|
||||
@@ -1322,11 +1320,10 @@ createProjectile ::
|
||||
ProjectileType ->
|
||||
DTree OItem ->
|
||||
Maybe PJStabiliser ->
|
||||
Muzzle ->
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
createProjectile x pjtype mtree stab muz cr w = fromMaybe (failsound w) $ do
|
||||
createProjectile x pjtype mtree stab cr w = fromMaybe (failsound w) $ do
|
||||
magitid <- mtree ^? dtValue . _1 . itID . unNInt
|
||||
ammoitem <- w ^? cWorld . lWorld . items . ix magitid
|
||||
let rdetonate =
|
||||
@@ -1336,7 +1333,7 @@ createProjectile x pjtype mtree stab muz cr w = fromMaybe (failsound w) $ do
|
||||
aparams <-
|
||||
((mtree ^? dtLeft) >>= find isampay >>= (^? dtValue . _1 . itType . ibtAttach . shellPayload))
|
||||
<|> magAmmoParams ammoitem ^? _Just . ampPayload
|
||||
return . makesound $ createShell x rdetonate rscreen stab pjtype aparams muz cr w
|
||||
return . makesound $ createShell x rdetonate rscreen stab pjtype aparams cr w
|
||||
where
|
||||
isrdet :: DTree OItem -> Bool
|
||||
isrdet y = case y ^. dtValue . _2 of
|
||||
|
||||
@@ -3,16 +3,15 @@ module Dodge.Projectile.Create (
|
||||
PJStabiliser (..),
|
||||
) where
|
||||
|
||||
import qualified Quaternion as Q
|
||||
import Dodge.Data.Muzzle
|
||||
import Data.Maybe
|
||||
import Dodge.Data.World
|
||||
import Dodge.Item.Location
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import NewInt
|
||||
import Linear
|
||||
import NewInt
|
||||
import qualified Quaternion as Q
|
||||
|
||||
data PJStabiliser
|
||||
= StabOrthReduce
|
||||
@@ -20,41 +19,38 @@ data PJStabiliser
|
||||
|
||||
-- assumes the mscreen is in your inventory
|
||||
createShell ::
|
||||
(Point3, Q.Quaternion Float) ->
|
||||
Point3Q ->
|
||||
Maybe (NewInt ItmInt) ->
|
||||
Maybe (NewInt ItmInt) ->
|
||||
Maybe PJStabiliser ->
|
||||
ProjectileType ->
|
||||
Payload ->
|
||||
Muzzle ->
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
createShell (p,q) mdetonator mscreen stab pjtype payload muz cr w =
|
||||
createShell (p, q) mdetonator mscreen stab pjtype payload cr w =
|
||||
w
|
||||
& updatescreen
|
||||
& updatedetonator
|
||||
& setuaparam mscreen
|
||||
& setuaparam mdetonator
|
||||
& cWorld . lWorld . projectiles . at i
|
||||
?~ Shell
|
||||
-- { _pjPos = pos
|
||||
{ _pjPos = p
|
||||
-- , _pjVel = (rotateV dir' (V2 speed 0) + crvelcomponent) `v2z` 0
|
||||
, _pjVel = (rotateV ddd (V2 speed 0) + crvelcomponent) `v2z` 0
|
||||
, _pjVel = (rotateV dir (V2 speed 0) + crvelcomponent) `v2z` 0
|
||||
, _pjID = i
|
||||
-- , _pjDir = dir'
|
||||
, _pjDir = ddd
|
||||
, _pjDir = dir
|
||||
, _pjSpin = 0
|
||||
, _pjPayload = payload
|
||||
, _pjTimer = lifespan
|
||||
, _pjTimer = 350
|
||||
, _pjBarrelSpin = bs
|
||||
, _pjType = pjtype
|
||||
, _pjDetonatorID = mdetonator
|
||||
, _pjScreenID = mscreen
|
||||
}
|
||||
where
|
||||
ddd = Q.qToAng q
|
||||
dir = Q.qToAng q
|
||||
crvelcomponent = case stab of
|
||||
Just StabOrthReduce -> projV (cr ^. crPos . _xy - cr ^. crOldPos . _xy) (unitVectorAtAngle dir)
|
||||
Just StabOrthReduce ->
|
||||
projV (cr ^. crPos . _xy - cr ^. crOldPos . _xy) (unitVectorAtAngle dir)
|
||||
_ -> (cr ^. crPos - cr ^. crOldPos) ^. _xy
|
||||
bs = case stab of
|
||||
Just StabOrthReduce -> Nothing
|
||||
@@ -64,21 +60,7 @@ createShell (p,q) mdetonator mscreen stab pjtype payload muz cr w =
|
||||
Grenade{} -> 4
|
||||
Rocket{} -> 1
|
||||
RetiredProjectile -> 0
|
||||
lifespan = 350
|
||||
updatedetonator = fromMaybe id $ do
|
||||
screenid <- mdetonator
|
||||
return $
|
||||
pointerToItemID screenid . itUse . uaParams
|
||||
. apProjectiles
|
||||
.:~ i
|
||||
updatescreen = fromMaybe id $ do
|
||||
screenid <- mscreen
|
||||
return $
|
||||
pointerToItemID screenid . itUse . uaParams
|
||||
. apProjectiles
|
||||
.:~ i
|
||||
setuaparam m = fromMaybe id $ do
|
||||
j <- m
|
||||
return $ pointerToItemID j . itUse . uaParams . apProjectiles .:~ i
|
||||
i = IM.newKey $ w ^. cWorld . lWorld . projectiles
|
||||
dir = _crDir cr + _mzRot muz
|
||||
--pos = _crPos cr + rotateV dir (xyV3 p + rotateV (argV (Q.qToV2 q)) (_mzPos muz))
|
||||
pos = _crPos cr + over _xy (rotateV dir) (p + addZ 0 (rotateV (argV (Q.qToV2 q)) (_mzPos muz)))
|
||||
dir' = dir + argV (Q.qToV2 q)
|
||||
|
||||
@@ -279,10 +279,10 @@ moveProjectile' pj w
|
||||
shellHitWall p n wl pj w
|
||||
| (p, Just (_, OFloor)) <- collide3 sp (sp + 2*^ _pjVel pj) w =
|
||||
shellHitFloor p pj w
|
||||
| (p, Just (_, OCreature cr)) <- collide3 sp (sp + _pjVel pj) w =
|
||||
| (p, Just (_, OCreature cr)) <- collide3 sp (sp + 2 *^ _pjVel pj) w =
|
||||
shellHitCreature p cr pj w
|
||||
& cWorld . lWorld . flares <>~ test p cr w sp (_pjVel pj)
|
||||
| (_, Just (_, OChasmWall)) <- collide3 sp (sp + _pjVel pj) w =
|
||||
| (_, Just (_, OChasmWall)) <- collide3 sp (sp + 2 *^_pjVel pj) w =
|
||||
-- no stick or bounce for now
|
||||
w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjTimer .~ 0
|
||||
| otherwise =
|
||||
@@ -293,10 +293,11 @@ moveProjectile' pj w
|
||||
where
|
||||
sp = _pjPos pj
|
||||
|
||||
test :: Point3 -> Creature -> World -> Point3 -> Point3 -> Picture
|
||||
test p cr w sp v =
|
||||
(setLayer FixedCoordLayer
|
||||
$ uncurryV translate (worldPosToScreen (w ^. wCam) (p ^. _xy))
|
||||
$ drawList [text (shortShow p),text $shortShow sp, text $ shortShow $ sp + 2*v, text $ shortShow v]
|
||||
$ drawList [text (shortShow p),text $ shortShow sp, text $ shortShow $ sp + 2*v, text $ shortShow v]
|
||||
<> color white (crossPic 5)
|
||||
) <>
|
||||
(setLayer DebugLayer
|
||||
|
||||
@@ -2634,7 +2634,7 @@ anythingHitCirc src/Dodge/Base/Collide.hs 337;" f
|
||||
applyCME src/Dodge/HeldUse.hs 362;" f
|
||||
applyCreatureDamage src/Dodge/Creature/Damage.hs 14;" f
|
||||
applyEventIO src/Loop.hs 89;" f
|
||||
applyGravityPU src/Dodge/Projectile/Update.hs 42;" f
|
||||
applyGravityPU src/Dodge/Projectile/Update.hs 44;" f
|
||||
applyIndividualDamage src/Dodge/Creature/Damage.hs 17;" f
|
||||
applyInvLock src/Dodge/HeldUse.hs 421;" f
|
||||
applyMagnetsToBul src/Dodge/Bullet.hs 32;" f
|
||||
@@ -3211,7 +3211,7 @@ destroyMatS src/Dodge/Material/Sound.hs 7;" f
|
||||
destroyMcType src/Dodge/Machine/Destroy.hs 22;" f
|
||||
destroyMount src/Dodge/Block.hs 100;" f
|
||||
destroyMounts src/Dodge/Block.hs 97;" f
|
||||
destroyProjectile src/Dodge/Projectile/Update.hs 160;" f
|
||||
destroyProjectile src/Dodge/Projectile/Update.hs 162;" f
|
||||
detV src/Geometry/Vector.hs 94;" f
|
||||
detector src/Dodge/Item/Held/Utility.hs 27;" f
|
||||
detectorColor src/Dodge/Item/Draw/SPic.hs 453;" f
|
||||
@@ -3246,7 +3246,7 @@ dmType src/Dodge/Damage.hs 38;" f
|
||||
doAimTwist src/Dodge/Creature/YourControl.hs 154;" f
|
||||
doAnyEquipmentEffect src/Dodge/Creature/State.hs 141;" f
|
||||
doBackspace src/Dodge/Update/Input/Text.hs 31;" f
|
||||
doBarrelSpin src/Dodge/Projectile/Update.hs 212;" f
|
||||
doBarrelSpin src/Dodge/Projectile/Update.hs 214;" f
|
||||
doBlBl src/Dodge/BlBl.hs 5;" f
|
||||
doBlSh src/Dodge/Block/Draw.hs 14;" f
|
||||
doBounce src/Dodge/Base/Collide.hs 67;" f
|
||||
@@ -3277,7 +3277,7 @@ doDrawing src/Dodge/Render.hs 34;" f
|
||||
doDrawing' src/Dodge/Render.hs 45;" f
|
||||
doFloatFloat src/Dodge/FloatFunction.hs 5;" f
|
||||
doGenFloat src/Dodge/HeldUse.hs 1196;" f
|
||||
doGravityPU src/Dodge/Projectile/Update.hs 36;" f
|
||||
doGravityPU src/Dodge/Projectile/Update.hs 38;" f
|
||||
doHeldUseEffect src/Dodge/HeldUse.hs 344;" f
|
||||
doInPlacements src/Dodge/Layout.hs 82;" f
|
||||
doIndividualPlacements src/Dodge/Layout.hs 96;" f
|
||||
@@ -3308,7 +3308,7 @@ doStrategyActions src/Dodge/Creature/ReaderUpdate.hs 167;" f
|
||||
doTestDrawing src/Dodge/Render.hs 41;" f
|
||||
doTextInputOver src/Dodge/Update/Input/Text.hs 15;" f
|
||||
doTextInputOverUniverse src/Dodge/Update/Input/Text.hs 12;" f
|
||||
doThrust src/Dodge/Projectile/Update.hs 182;" f
|
||||
doThrust src/Dodge/Projectile/Update.hs 184;" f
|
||||
doTimeScroll src/Dodge/Update.hs 196;" f
|
||||
doTmWdWd src/Dodge/WorldEffect.hs 89;" f
|
||||
doWallRotate src/Dodge/Update/Camera.hs 220;" f
|
||||
@@ -3544,7 +3544,7 @@ expandPolyByFixed src/Dodge/LevelGen/StaticWalls.hs 97;" f
|
||||
expandPolyCorners src/Dodge/LevelGen/StaticWalls.hs 103;" f
|
||||
expandToSquare src/Dodge/LevelGen/StaticWalls/Deprecated.hs 83;" f
|
||||
expireAndDamage src/Dodge/Bullet.hs 187;" f
|
||||
explodeShell src/Dodge/Projectile/Update.hs 285;" f
|
||||
explodeShell src/Dodge/Projectile/Update.hs 320;" f
|
||||
explosionS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 556;" f
|
||||
explosiveBarrel src/Dodge/Creature/Inanimate.hs 25;" f
|
||||
extTrigLitPos src/Dodge/Placement/Instance/Button.hs 84;" f
|
||||
@@ -3854,8 +3854,8 @@ interpWith src/Dodge/Creature/Boid.hs 12;" f
|
||||
intersectCircLine src/Geometry/Intersect.hs 354;" f
|
||||
intersectCircLineAlong src/Geometry/Intersect.hs 345;" f
|
||||
intersectCircSeg src/Geometry/Intersect.hs 324;" f
|
||||
intersectCircSegFirst src/Geometry/Intersect.hs 398;" f
|
||||
intersectCircSegTest src/Geometry/Intersect.hs 390;" f
|
||||
intersectCircSegFirst src/Geometry/Intersect.hs 395;" f
|
||||
intersectCircSegTest src/Geometry/Intersect.hs 387;" f
|
||||
intersectCylSeg src/Geometry/Intersect.hs 363;" f
|
||||
intersectLineLine src/Geometry/Intersect.hs 18;" f
|
||||
intersectLinePlaneAlong src/Geometry/Intersect.hs 27;" f
|
||||
@@ -4298,10 +4298,11 @@ moveCombineSel src/Dodge/Update/Scroll.hs 121;" f
|
||||
moveInverseShockwave src/Dodge/Shockwave/Update.hs 44;" f
|
||||
moveLSThen src/Dodge/Placement/Instance/LightSource.hs 43;" f
|
||||
movePenBullet src/Dodge/Bullet.hs 202;" f
|
||||
moveProjectile src/Dodge/Projectile/Update.hs 260;" f
|
||||
moveProjectile src/Dodge/Projectile/Update.hs 262;" f
|
||||
moveProjectile' src/Dodge/Projectile/Update.hs 273;" f
|
||||
moveRoomBy src/Dodge/Room/Link.hs 53;" f
|
||||
moveShockwave src/Dodge/Shockwave/Update.hs 13;" f
|
||||
moveStuckGrenade src/Dodge/Projectile/Update.hs 246;" f
|
||||
moveStuckGrenade src/Dodge/Projectile/Update.hs 248;" f
|
||||
moveToSideNthOutLink src/Dodge/Room/Warning.hs 69;" f
|
||||
moveWall src/Dodge/Wall/Move.hs 29;" f
|
||||
moveWallID src/Dodge/Wall/Move.hs 24;" f
|
||||
@@ -4467,7 +4468,7 @@ pingPongBetween src/Render.hs 221;" f
|
||||
pipe src/Dodge/Item/Craftable.hs 32;" f
|
||||
pistol src/Dodge/Item/Held/Stick.hs 40;" f
|
||||
pistolerRoom src/Dodge/Room/Room.hs 330;" f
|
||||
pjRemoteSetDirection src/Dodge/Projectile/Update.hs 225;" f
|
||||
pjRemoteSetDirection src/Dodge/Projectile/Update.hs 227;" f
|
||||
plBlock src/Dodge/Placement/PlaceSpot/Block.hs 18;" f
|
||||
plDoor src/Dodge/Placement/PlaceSpot/TriggerDoor.hs 22;" f
|
||||
plLineBlock src/Dodge/Placement/PlaceSpot/Block.hs 50;" f
|
||||
@@ -5004,10 +5005,10 @@ shapeVerxSize src/Shape/Parameters.hs 10;" f
|
||||
shatterGun src/Dodge/Item/Held/Weapons.hs 8;" f
|
||||
shatterGunSPic src/Dodge/Item/Draw/SPic.hs 312;" f
|
||||
shatterWall src/Dodge/Item/Weapon/Shatter.hs 27;" f
|
||||
shellExplosionCheck src/Dodge/Projectile/Update.hs 56;" f
|
||||
shellHitCreature src/Dodge/Projectile/Update.hs 84;" f
|
||||
shellHitFloor src/Dodge/Projectile/Update.hs 100;" f
|
||||
shellHitWall src/Dodge/Projectile/Update.hs 67;" f
|
||||
shellExplosionCheck src/Dodge/Projectile/Update.hs 58;" f
|
||||
shellHitCreature src/Dodge/Projectile/Update.hs 86;" f
|
||||
shellHitFloor src/Dodge/Projectile/Update.hs 102;" f
|
||||
shellHitWall src/Dodge/Projectile/Update.hs 69;" f
|
||||
shellMag src/Dodge/Item/Ammo.hs 49;" f
|
||||
shellModule src/Dodge/Item/Scope.hs 123;" f
|
||||
shellShape src/Dodge/Projectile/Draw.hs 35;" f
|
||||
@@ -5256,7 +5257,7 @@ terminalWheelEvent src/Dodge/Update/Scroll.hs 131;" f
|
||||
teslaGun src/Dodge/Item/Held/BatteryGuns.hs 19;" f
|
||||
teslaGunPic src/Dodge/Item/Draw/SPic.hs 409;" f
|
||||
teslaParams src/Dodge/Item/Held/BatteryGuns.hs 25;" f
|
||||
test src/Dodge/Projectile/Update.hs 283;" f
|
||||
test src/Dodge/Projectile/Update.hs 296;" f
|
||||
testCrossWalls src/Dodge/Room/Path.hs 41;" f
|
||||
testEvent src/Dodge/Event/Test.hs 9;" f
|
||||
testInventory src/Dodge/Creature.hs 292;" f
|
||||
@@ -5400,9 +5401,9 @@ tryPlay src/Sound.hs 84;" f
|
||||
tryPutItemInInv src/Dodge/Inventory/Add.hs 24;" f
|
||||
tryPutItemInInvAt src/Dodge/Inventory/Add.hs 53;" f
|
||||
trySeedFromClipboard src/Dodge/Menu.hs 96;" f
|
||||
trySpin src/Dodge/Projectile/Update.hs 170;" f
|
||||
trySpin src/Dodge/Projectile/Update.hs 172;" f
|
||||
trySynthBullet src/Dodge/Creature/State.hs 167;" f
|
||||
tryThrust src/Dodge/Projectile/Update.hs 176;" f
|
||||
tryThrust src/Dodge/Projectile/Update.hs 178;" f
|
||||
tryUseParent src/Dodge/Creature/State.hs 145;" f
|
||||
turnTo src/Dodge/Movement/Turn.hs 8;" f
|
||||
turret src/Dodge/Placement/Instance/Turret.hs 37;" f
|
||||
@@ -5518,7 +5519,7 @@ updateObjCatMaybes src/Dodge/Update.hs 533;" f
|
||||
updateObjMapMaybe src/Dodge/Update.hs 526;" f
|
||||
updatePastWorlds src/Dodge/Update.hs 408;" f
|
||||
updatePreload src/Preload/Update.hs 20;" f
|
||||
updateProjectile src/Dodge/Projectile/Update.hs 27;" f
|
||||
updateProjectile src/Dodge/Projectile/Update.hs 29;" f
|
||||
updateProp src/Dodge/Prop/Update.hs 11;" f
|
||||
updatePulse src/Dodge/Creature/Update.hs 146;" f
|
||||
updatePulseBall src/Dodge/Update.hs 433;" f
|
||||
|
||||
Reference in New Issue
Block a user