Work on rocket/grenade launcher

This commit is contained in:
2024-12-27 21:46:46 +00:00
parent 0ef28c132e
commit 5c749bff63
19 changed files with 400 additions and 324 deletions
+35 -18
View File
@@ -1,5 +1,5 @@
module Dodge.Projectile.Create (
createShell,
-- createShell,
createGShell,
) where
@@ -23,8 +23,10 @@ homingDrawType ht = case ht of
createShell :: ProjectileHoming
-> Maybe (NewInt ItmInt)
-> Maybe (NewInt ItmInt)
-> Bool
-> ProjectileType
-> Payload -> Muzzle -> Creature -> World -> World
createShell homing mdetonator mscreen payload muz cr w = w
createShell homing mdetonator mscreen smokestatus pjtype payload muz cr w = w
& updatescreen
& updatedetonator
& cWorld . lWorld . projectiles . at i
@@ -39,27 +41,30 @@ createShell homing mdetonator mscreen payload muz cr w = w
, _prjDir = dir
, _prjSpin = 0
, _prjPayload = payload
, _prjTimer = 350
, _prjTimer = lifespan
, _prjUpdates =
[ CollisionEffectPU (homing ^? phRemoteID) mdetonator mscreen
, TimePU
, StartSpinPU 335 (_crID cr) spinamount
, RemoteDirectionPU (350 - thrustdelay) 0 homing
, ThrustPU (350 - thrustdelay) 0
, RemoteDirectionPU (lifespan - thrustdelay) 0 homing
, ThrustPU (lifespan - thrustdelay) 0 smokestatus
, ReduceSpinPU (1 - spindrag * 2 / 200)
]
, _prjType = pjtype
}
where
lifespan = 350
spindrag = 1
spinamount = 2
thrustdelay = 20
updatedetonator = fromMaybe id $ do
screenid <- mdetonator
return $ pointerToItemID screenid . itUse . uaParams
. apLinkedProjectile
?~ i
. apProjectiles
.:~ i
updatescreen = fromMaybe id $ do
screenid <- homing ^? phRemoteID
--screenid <- homing ^? phRemoteID
screenid <- mscreen
return $ pointerToItemID screenid . itUse . uaParams
. apLinkedProjectile
?~ i
@@ -71,8 +76,10 @@ createShell homing mdetonator mscreen payload muz cr w = w
createGShell :: ProjectileHoming
-> Maybe (NewInt ItmInt)
-> Maybe (NewInt ItmInt)
-> Bool
-> ProjectileType
-> Payload -> Muzzle -> Creature -> World -> World
createGShell homing mdetonator mscreen payload muz cr w = w
createGShell homing mdetonator mscreen smokestatus pjtype payload muz cr w = w
& updatescreen
& updatedetonator
& cWorld . lWorld . projectiles . at i
@@ -80,34 +87,44 @@ createGShell homing mdetonator mscreen payload muz cr w = w
{ _prjPos = pos
, _prjZ = 20
, _prjZVel = 5
, _prjVel = rotateV dir (V2 4 0) + cr ^. crPos - cr ^. crOldPos
, _prjVel = rotateV dir (V2 speed 0) + cr ^. crPos - cr ^. crOldPos
, _prjDraw = homingDrawType homing
, _prjID = i
, _prjAcc = rotateV dir (V2 3 0)
, _prjDir = dir
, _prjSpin = 0
, _prjPayload = payload
, _prjTimer = 350
, _prjTimer = lifespan
, _prjUpdates =
[ CollisionEffectPU (homing ^? phRemoteID) mdetonator mscreen
, TimePU
, StartSpinPU 335 (_crID cr) spinamount
, RemoteDirectionPU (350 - thrustdelay) 0 homing
, StartSpinPU (lifespan - 15) (_crID cr) spinamount
, RemoteDirectionPU (lifespan - thrustdelay) 0 homing
, ReduceSpinPU (1 - spindrag * 2 / 200)
, ApplyGravityPU
]
] <> thrustorgrav
, _prjType = pjtype
}
where
speed = case pjtype of
Grenade -> 4
Rocket -> 1
lifespan = case pjtype of
Grenade -> 150
Rocket -> 350
thrustorgrav = case pjtype of
Grenade -> [ApplyGravityPU]
Rocket -> [ThrustPU (lifespan - thrustdelay) 0 smokestatus]
spindrag = 1
spinamount = 2
thrustdelay = 20
updatedetonator = fromMaybe id $ do
screenid <- mdetonator
return $ pointerToItemID screenid . itUse . uaParams
. apLinkedProjectile
?~ i
. apProjectiles
.:~ i
updatescreen = fromMaybe id $ do
screenid <- homing ^? phRemoteID
--screenid <- homing ^? phRemoteID
screenid <- mscreen
return $ pointerToItemID screenid . itUse . uaParams
. apLinkedProjectile
?~ i