Allow for different item drops on creature death
This commit is contained in:
+61
-68
@@ -6,7 +6,7 @@ module Dodge.Item.Weapon
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.CreatureAction
|
||||
import Dodge.Creature.Action
|
||||
import Dodge.RandomHelp
|
||||
import Dodge.WorldEvent
|
||||
import Dodge.Debug
|
||||
@@ -320,7 +320,7 @@ launcher = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _wpFireRate = 20
|
||||
, _wpFireState = 0
|
||||
, _wpFire = shoot $ aRocket
|
||||
, _wpFire = shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makeExplosionAt
|
||||
, _wpSpread = 0.02
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = onLayer FlItLayer $ color cyan $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
@@ -334,17 +334,17 @@ launcher = defaultGun
|
||||
}
|
||||
flameLauncher = launcher
|
||||
{ _itName = "FLROCKO"
|
||||
, _wpFire = shoot . aRocket' $ makeShellAt makeFlameExplosionAt
|
||||
, _wpFire = shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makeFlameExplosionAt
|
||||
}
|
||||
|
||||
poisonLauncher = launcher
|
||||
{ _itName = "POISROCK"
|
||||
, _wpFire = shoot . aRocket' $ makeShellAt makePoisonExplosionAt
|
||||
, _wpFire = shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makePoisonExplosionAt
|
||||
}
|
||||
|
||||
teslaLauncher = launcher
|
||||
{ _itName = "TESLROCK"
|
||||
, _wpFire = shoot . aRocket' $ makeShellAt makeTeslaExplosionAt
|
||||
, _wpFire = shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makeTeslaExplosionAt
|
||||
}
|
||||
|
||||
bezierGun = defaultAutoGun
|
||||
@@ -700,7 +700,6 @@ aLaser cid w = over particles' ( (:) (makeLaserAt phaseV pos dir (Just cid)))
|
||||
phaseV = fromMaybe 1 $ cr ^? crInv . ix j . itAttachment . _Just . itPhaseV
|
||||
j = _crInvSel cr
|
||||
|
||||
|
||||
aTractorBeam :: Int -> Int -> World -> World
|
||||
aTractorBeam col cid w
|
||||
= set (creatures . ix cid . crInv . ix itRef . wpFire)
|
||||
@@ -712,21 +711,23 @@ aTractorBeam col cid w
|
||||
dir = _crDir cr
|
||||
itRef = _crInvSel cr
|
||||
|
||||
-- | The aRocket' function allows us to define the shell to be used
|
||||
aRocket' :: (Int -> Int -> Point2 -> Float -> Projectile) -> Int -> World -> World
|
||||
aRocket' shell cid w
|
||||
= soundOnce (fromIntegral launcherSound)
|
||||
$ over projectiles (IM.insert i (shell i cid pos dir)) w
|
||||
where i = newProjectileKey w
|
||||
cr = (_creatures w IM.! cid)
|
||||
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
|
||||
dir = _crDir cr
|
||||
|
||||
aRocket :: Int -> World -> World
|
||||
aRocket = aRocket' (makeShellAt shellExplosionAt)
|
||||
|
||||
aRocketWithPayload
|
||||
:: (Point2 -> World -> World)
|
||||
-- ^ Payload
|
||||
-> Int -- ^ Creature id
|
||||
-> World
|
||||
-> World
|
||||
aRocketWithPayload pl cid w = over projectiles (IM.insert i theShell) w
|
||||
where
|
||||
i = newProjectileKey w
|
||||
cr = (_creatures w IM.! cid)
|
||||
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
|
||||
dir = _crDir cr
|
||||
theShell = makeShellAt pl i cid pos dir
|
||||
|
||||
makeShellAt
|
||||
:: (Point2 -> World -> World) -- ^ Payload
|
||||
:: (Point2 -> World -> World)
|
||||
-- ^ Payload
|
||||
-> Int -- ^ Projectile id
|
||||
-> Int -- ^ Creature id
|
||||
-> Point2 -- ^ Start position
|
||||
@@ -736,68 +737,61 @@ makeShellAt pl i cid pos dir = Shell
|
||||
{ _pjPos = pos
|
||||
, _pjStartPos = pos
|
||||
, _pjVel = rotateV dir (1,0)
|
||||
, _pjPict = blank -- onLayer PtLayer $ uncurry translate pos $ rotate (radToDeg dir) shellPic
|
||||
, _pjPict = blank
|
||||
, _pjID = i
|
||||
, _pjUpdate = moveShell 50 i cid 0 (rotateV dir (3,0))
|
||||
, _pjPayload = pl
|
||||
}
|
||||
|
||||
moveShell :: Int -> Int -> Int -> Float -> Point2 -> World -> World
|
||||
moveShell
|
||||
:: Int -- ^ Timer (frames)
|
||||
-> Int -- ^ Projectile id
|
||||
-> Int -- ^ Creature id
|
||||
-> Float -- ^ Rotation
|
||||
-> Point2 -- ^ Acceleration
|
||||
-> World -> World
|
||||
moveShell time i cid rot accel w
|
||||
| time > 40 = if circOnSomeWall oldPos 4 w
|
||||
then doExplode
|
||||
else over (projectiles . ix i . pjPos) (+.+ vel)
|
||||
$ set (projectiles . ix i . pjPict) piclow
|
||||
$ set (projectiles . ix i . pjUpdate)
|
||||
(moveShell (time-1) i cid rot (rotateV rot accel))
|
||||
w
|
||||
| time == 35 = case thingHit of
|
||||
Just p -> doExplode
|
||||
Nothing -> over (projectiles . ix i . pjPos) (+.+ vel)
|
||||
$ set (projectiles . ix i . pjPict) pic
|
||||
$ set (projectiles . ix i . pjUpdate)
|
||||
(moveShell (time-1) i cid spin accel)
|
||||
w
|
||||
| time >= 20 = case thingHit of
|
||||
Just p -> projectileExplosion oldPos
|
||||
$ over projectiles (IM.delete i) w
|
||||
Nothing -> over (projectiles . ix i . pjPos) (+.+ vel)
|
||||
$ set (projectiles . ix i . pjPict) pic
|
||||
$ set (projectiles . ix i . pjUpdate)
|
||||
(moveShell (time-1) i cid rot (rotateV rot accel))
|
||||
w
|
||||
| time > -99 = case thingHit of
|
||||
Just p -> doExplode
|
||||
Nothing -> over (projectiles . ix i . pjPos) (+.+ vel)
|
||||
$ set randGen g
|
||||
$ set (projectiles . ix i . pjPict) pic
|
||||
$ set (projectiles . ix i . pjUpdate)
|
||||
(moveShell (time-1) i cid rot (rotateV rot accel))
|
||||
$ over (projectiles . ix i . pjVel) (\v -> accel +.+ frict *.* v)
|
||||
$ soundFromPos (ShellSound i) newPos (fromIntegral smokeTrailSound) (1) 250
|
||||
$ makeFlameletTimed oldPos
|
||||
(0.5 *.* rotateV (pi+sparkD) accel) Nothing 3 10
|
||||
$ smokeGen
|
||||
w
|
||||
| time > -200 = case thingHit of
|
||||
Just p -> doExplode
|
||||
Nothing -> over (projectiles . ix i . pjPos) (+.+ vel)
|
||||
$ set (projectiles . ix i . pjPict) pic
|
||||
$ set (projectiles . ix i . pjUpdate)
|
||||
(moveShell (time-1) i cid rot (rotateV rot accel))
|
||||
w
|
||||
else w
|
||||
& projectiles . ix i . pjPos %~ (+.+ vel)
|
||||
& projectiles . ix i . pjPict .~ piclow
|
||||
& projectiles . ix i . pjUpdate .~ moveShell (time-1) i cid rot (rotateV rot accel)
|
||||
| isJust thingHit = doExplode
|
||||
| time == 35 = w
|
||||
& projectiles . ix i . pjPos %~ (+.+ vel)
|
||||
& projectiles . ix i . pjPict .~ pic
|
||||
& projectiles . ix i . pjUpdate .~ moveShell (time-1) i cid spin accel
|
||||
| time >= 20 = w
|
||||
& projectiles . ix i . pjPos %~ (+.+ vel)
|
||||
& projectiles . ix i . pjPict .~ pic
|
||||
& projectiles . ix i . pjUpdate .~ moveShell (time-1) i cid rot (rotateV rot accel)
|
||||
| time > -99 = w
|
||||
& projectiles . ix i . pjPos %~ (+.+ vel)
|
||||
& randGen .~ g
|
||||
& projectiles . ix i . pjPict .~ pic
|
||||
& projectiles . ix i . pjUpdate .~ (moveShell (time-1) i cid rot (rotateV rot accel))
|
||||
& projectiles . ix i . pjVel %~ (\v -> accel +.+ frict *.* v)
|
||||
& soundFromPos (ShellSound i) newPos (fromIntegral smokeTrailSound) (1) 250
|
||||
& makeFlameletTimed (oldPos -.- vel) (vel +.+ rotateV (pi+sparkD) accel) Nothing 3 10
|
||||
& smokeGen
|
||||
| time > -200 = w
|
||||
& projectiles . ix i . pjPos %~ (+.+ vel)
|
||||
& projectiles . ix i . pjPict .~ pic
|
||||
& projectiles . ix i . pjUpdate .~ moveShell (time-1) i cid rot (rotateV rot accel)
|
||||
| otherwise = doExplode
|
||||
where
|
||||
doExplode = projectileExplosion oldPos
|
||||
$ stopSoundFrom (ShellSound i)
|
||||
$ over projectiles (IM.delete i) w
|
||||
doExplode = w
|
||||
& projectileExplosion oldPos
|
||||
& stopSoundFrom (ShellSound i)
|
||||
& projectiles %~ IM.delete i
|
||||
pj = _projectiles w IM.! i
|
||||
oldPos = _pjPos pj
|
||||
vel = _pjVel pj
|
||||
projectileExplosion = _pjPayload pj
|
||||
newPos = oldPos +.+ vel
|
||||
(frict,g) = randomR (0.6,0.9) $ _randGen w
|
||||
(sparkD,_) = randomR (-0.5,0.5) $ _randGen w
|
||||
(frict,g) = randomR (0.6,0.9) $ _randGen w
|
||||
(sparkD,_) = randomR (-0.2,0.2) $ _randGen w
|
||||
dir = argV $ vel
|
||||
pic = onLayer PtLayer $ uncurry translate newPos $ rotate (argV accel) shellPic
|
||||
piclow = onLayerL [levLayer CrLayer - 2]
|
||||
@@ -812,7 +806,6 @@ moveShell time i cid rot accel w
|
||||
r1 = _randGen w & evalState (randInCirc 10)
|
||||
smokeGen = makeSmokeCloudAt (oldPos +.+ r1 +.+ 30 *.* (normalizeV (oldPos -.- newPos)))
|
||||
|
||||
|
||||
normalizeAnglePi angle | normalizeAngle angle > pi = normalizeAngle angle - 2*pi
|
||||
| otherwise = normalizeAngle angle
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ module Dodge.Item.Weapon.TriggerType
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.CreatureAction (reloadWeapon)
|
||||
import Dodge.Creature.Action (reloadWeapon)
|
||||
import Dodge.WorldEvent (muzzleFlashAt,tempLightForAt)
|
||||
import Dodge.WorldEvent.Cloud
|
||||
import Dodge.RandomHelp
|
||||
|
||||
Reference in New Issue
Block a user