Add damage origins
This commit is contained in:
+27
-18
@@ -743,11 +743,11 @@ useLoadedAmmo
|
||||
useLoadedAmmo loc cr mz m w =
|
||||
makeMuzzleFlare pq loc (mz ^. mzFlareType) $ case _mzEffect mz of
|
||||
MuzzleShootBullet -> shootBullets loc cr (mz, x, magtree) w
|
||||
MuzzleLaser -> creatureShootLaser pq' loc (w & randGen .~ g)
|
||||
MuzzleLaser -> creatureShootLaser (CrWeaponO (cr ^. crID)) pq' loc (w & randGen .~ g)
|
||||
MuzzlePulseLaser -> creatureShootPulseLaser pq' cr (w & randGen .~ g)
|
||||
MuzzlePulseBall -> shootPulseBall pq' (w & randGen .~ g)
|
||||
MuzzlePlasmaBall -> shootPlasmaBall pq' (w & randGen .~ g)
|
||||
MuzzleTesla -> shootTeslaArc pq' loc (w & randGen .~ g)
|
||||
MuzzlePulseBall -> shootPulseBall o pq' (w & randGen .~ g)
|
||||
MuzzlePlasmaBall -> shootPlasmaBall o pq' (w & randGen .~ g)
|
||||
MuzzleTesla -> shootTeslaArc o pq' loc (w & randGen .~ g)
|
||||
MuzzleTractor -> shootTractorBeam cr w
|
||||
MuzzleRLauncher -> createProjectileR pq loc magtree cr w
|
||||
MuzzleGLauncher ->
|
||||
@@ -776,6 +776,7 @@ useLoadedAmmo loc cr mz m w =
|
||||
MuzzleStopper -> useStopWatch itm cr w
|
||||
MuzzleScroller -> useTimeScrollGun itm cr w
|
||||
where
|
||||
o = CrWeaponO $ cr ^. crID
|
||||
pq = muzzlePos loc cr mz
|
||||
(pq', g) = muzzleRandPos loc cr mz `runState` (w ^. randGen)
|
||||
itmtree = loc ^. locDT
|
||||
@@ -856,9 +857,10 @@ tractorBeamAt pos outpos dir power =
|
||||
, _tbTime = 10
|
||||
}
|
||||
|
||||
creatureShootLaser :: Point3Q -> LocationDT OItem -> World -> World
|
||||
creatureShootLaser (p, q) loc =
|
||||
creatureShootLaser :: DamageOrigin -> Point3Q -> LocationDT OItem -> World -> World
|
||||
creatureShootLaser o (p, q) loc =
|
||||
shootLaser
|
||||
o
|
||||
(ItemSound (loc ^. locDT . dtValue . _1 . itID . unNInt) 0)
|
||||
(getLaserDamage loc)
|
||||
(getLaserPhaseV loc)
|
||||
@@ -866,6 +868,7 @@ creatureShootLaser (p, q) loc =
|
||||
(Q.qToAng q)
|
||||
|
||||
shootLaser ::
|
||||
DamageOrigin ->
|
||||
SoundOrigin ->
|
||||
LaserType ->
|
||||
Float ->
|
||||
@@ -873,13 +876,14 @@ shootLaser ::
|
||||
Float ->
|
||||
World ->
|
||||
World
|
||||
shootLaser so lt pv p dir =
|
||||
shootLaser o so lt pv p dir =
|
||||
( cWorld . lWorld . lasers
|
||||
.:~ Laser
|
||||
{ _lpType = lt
|
||||
, _lpPhaseV = pv
|
||||
, _lpPos = p
|
||||
, _lpDir = dir
|
||||
, _lpOrigin = o
|
||||
}
|
||||
)
|
||||
. soundContinue so p tone440sawtoothquietS (Just 2)
|
||||
@@ -887,12 +891,13 @@ shootLaser so lt pv p dir =
|
||||
creatureShootPulseLaser :: Point3Q -> Creature -> World -> World
|
||||
creatureShootPulseLaser (p, q) cr =
|
||||
shootPulseLaser
|
||||
(CrWeaponO $ cr ^. crID)
|
||||
(CrWeaponSound (_crID cr) 0)
|
||||
(p ^. _xy)
|
||||
(Q.qToAng q)
|
||||
|
||||
shootPulseLaser :: SoundOrigin -> Point2 -> Float -> World -> World
|
||||
shootPulseLaser so p dir w =
|
||||
shootPulseLaser :: DamageOrigin -> SoundOrigin -> Point2 -> Float -> World -> World
|
||||
shootPulseLaser o so p dir w =
|
||||
w
|
||||
& cWorld . lWorld . pulseLasers
|
||||
.:~ PulseLaser
|
||||
@@ -901,23 +906,25 @@ shootPulseLaser so p dir w =
|
||||
, _pzDir = dir
|
||||
, _pzDamage = 101
|
||||
, _pzTimer = 5
|
||||
, _pzOrigin = o
|
||||
}
|
||||
& soundStart so p lasPulseS Nothing
|
||||
|
||||
shootPlasmaBall :: Point3Q -> World -> World
|
||||
shootPlasmaBall (p, q) w =
|
||||
shootPlasmaBall :: DamageOrigin -> Point3Q -> World -> World
|
||||
shootPlasmaBall o (p, q) w =
|
||||
w
|
||||
& cWorld . lWorld . plasmaBalls .:~
|
||||
PBall
|
||||
{ _pbPos = p ^. _xy
|
||||
, _pbVel = 6 * unitVectorAtAngle (Q.qToAng q)
|
||||
, _pbType = DefaultPlasma
|
||||
, _pbOrigin = o
|
||||
}
|
||||
-- & soundStart (PBSound i) (p ^. _xy) energyReleaseS Nothing
|
||||
|
||||
|
||||
shootPulseBall :: Point3Q -> World -> World
|
||||
shootPulseBall (p, q) w =
|
||||
shootPulseBall :: DamageOrigin -> Point3Q -> World -> World
|
||||
shootPulseBall o (p, q) w =
|
||||
w
|
||||
& cWorld . lWorld . pulseBalls . at i
|
||||
?~ PulseBall
|
||||
@@ -925,6 +932,7 @@ shootPulseBall (p, q) w =
|
||||
, _pzbVel = 3.5 * unitVectorAtAngle (Q.qToAng q)
|
||||
, _pzbTimer = 200
|
||||
, _pzbID = i
|
||||
, _pzbOrigin = o
|
||||
}
|
||||
& soundStart (PBSound i) (p ^. _xy) energyReleaseS Nothing
|
||||
where
|
||||
@@ -990,7 +998,8 @@ shootBullets
|
||||
:: LocationDT OItem -> Creature -> (Muzzle, Int, DTree OItem) -> World -> World
|
||||
shootBullets loc cr (mz, x, magtree) w = fromMaybe w $ do
|
||||
thebullet <- getBulletType magtree
|
||||
return $ foldl' (&) w (replicate x (shootBullet thebullet loc cr mz))
|
||||
let bu = thebullet & buOrigin .~ CrWeaponO (cr ^. crID)
|
||||
return $ foldl' (&) w (replicate x (shootBullet bu loc cr mz))
|
||||
|
||||
shootBullet :: Bullet -> LocationDT OItem -> Creature -> Muzzle -> World -> World
|
||||
shootBullet bu loc cr mz w = makeBullet bu itm pq . (randGen .~ g) $ w
|
||||
@@ -1180,7 +1189,7 @@ doGenFloat (UniRandFloat x y) g = randomR (x, y) g
|
||||
|
||||
mcShootLaser :: Item -> Machine -> World -> World
|
||||
mcShootLaser _ mc =
|
||||
shootLaser (MachinePrimarySound (_mcID mc)) (DamageLaser 11) 1 pos dir
|
||||
shootLaser (McWeaponO (mc ^. mcID)) (MachinePrimarySound (_mcID mc)) (DamageLaser 11) 1 pos dir
|
||||
where
|
||||
pos = _mcPos mc +.+ 20 *.* unitVectorAtAngle dir
|
||||
dir = (mc ^?! mcType . mctTurret . tuDir)
|
||||
@@ -1203,14 +1212,14 @@ mcShootAuto itm mc w
|
||||
-- dir = mc ^?! mcType . _McTurret . tuDir
|
||||
|
||||
-- | assumes that the item is held
|
||||
shootTeslaArc :: Point3Q -> LocationDT OItem -> World -> World
|
||||
shootTeslaArc (p, q) loc w =
|
||||
shootTeslaArc :: DamageOrigin -> Point3Q -> LocationDT OItem -> World -> World
|
||||
shootTeslaArc o (p, q) loc w =
|
||||
w' & cWorld . lWorld . items . ix itid . itParams .~ ip
|
||||
& soundContinue (ItemSound itid 0) pos elecCrackleS (Just 2)
|
||||
where
|
||||
itm = loc ^. locDT . dtValue . _1
|
||||
itid = itm ^. itID . unNInt
|
||||
(w', ip) = makeTeslaArc (itm ^. itParams) pos (Q.qToAng q) w
|
||||
(w', ip) = makeTeslaArc o (itm ^. itParams) pos (Q.qToAng q) w
|
||||
pos = p ^. _xy
|
||||
|
||||
determineProjectileTracking :: DTree OItem -> DTree OItem -> RocketHoming
|
||||
|
||||
Reference in New Issue
Block a user