refactor: pass creature to weapon use function, as opposed to just id
This commit is contained in:
+81
-79
@@ -70,7 +70,7 @@ pistol = Weapon
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 8
|
||||
, _itUseTime = 0
|
||||
, _wpFire =
|
||||
, _itUse =
|
||||
hammerCheck
|
||||
. shootWithSound 0
|
||||
. withRandomDir 0.1
|
||||
@@ -102,15 +102,15 @@ defaultAutoGun = autoGun
|
||||
, _itScrollDown = const id
|
||||
, _itInvDisplay = basicWeaponDisplay
|
||||
}
|
||||
effectGun :: String -> (Int -> World -> World) -> Item
|
||||
effectGun :: String -> (Creature -> World -> World) -> Item
|
||||
effectGun name eff = defaultGun
|
||||
{ _itName = name ++ "Gun"
|
||||
, _wpFire = eff
|
||||
, _itUse = eff
|
||||
}
|
||||
autoEffectGun :: String -> (Int -> World -> World) -> Item
|
||||
autoEffectGun :: String -> (Creature -> World -> World) -> Item
|
||||
autoEffectGun name eff = defaultAutoGun
|
||||
{ _itName = name ++ "Gun"
|
||||
, _wpFire = eff
|
||||
, _itUse = eff
|
||||
}
|
||||
autoGun :: Item
|
||||
autoGun = defaultGun
|
||||
@@ -122,7 +122,7 @@ autoGun = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 6
|
||||
, _itUseTime = 0
|
||||
, _wpFire = charFiringStrat
|
||||
, _itUse = charFiringStrat
|
||||
[('M',autoFireMode)
|
||||
,('S',singleFireMode)
|
||||
]
|
||||
@@ -142,7 +142,7 @@ autoGun = defaultGun
|
||||
, _itScrollDown = decCharMode
|
||||
, _itInvDisplay = basicWeaponDisplay
|
||||
}
|
||||
autoFireMode, singleFireMode, autoGunNonTwistEff :: Int -> World -> World
|
||||
autoFireMode, singleFireMode, autoGunNonTwistEff :: Creature -> World -> World
|
||||
autoFireMode = shootWithSound (fromIntegral autoGunSound)
|
||||
. torqueBefore 0.05
|
||||
$ autoGunNonTwistEff
|
||||
@@ -161,7 +161,7 @@ rezGun = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _wpFire = shoot aTeslaArc
|
||||
, _itUse = shoot aTeslaArc
|
||||
, _wpSpread = 0.001
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = onLayer FlItLayer $ color chartreuse $ pictures
|
||||
@@ -186,7 +186,7 @@ teslaGun = defaultAutoGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _wpFire = shoot aTeslaArc
|
||||
, _itUse = shoot aTeslaArc
|
||||
, _wpSpread = 0.001
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = onLayer FlItLayer $ color blue $ pictures
|
||||
@@ -212,7 +212,7 @@ lasGun = defaultAutoGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _wpFire = shoot aLaser
|
||||
, _itUse = shoot aLaser
|
||||
, _wpSpread = 0.001
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = onLayer FlItLayer $ color blue $ polygon $ rectNESW 3 3 (-3) (-3)
|
||||
@@ -235,7 +235,7 @@ forceFieldGun = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 10
|
||||
, _itUseTime = 0
|
||||
, _wpFire = undefined
|
||||
, _itUse = undefined
|
||||
, _wpSpread = 0.02
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = onLayer FlItLayer $ polygon [(-4,-4),(-4,4),(4,4),(4,0),(0,0),(0,-4)]
|
||||
@@ -253,7 +253,7 @@ forceFieldGun = defaultGun
|
||||
-- , _wpReloadState = 0
|
||||
-- , _itUseRate = 10
|
||||
-- , _itUseTime = 0
|
||||
-- , _wpFire = grapFire
|
||||
-- , _itUse = grapFire
|
||||
-- , _wpSpread = 0.002
|
||||
-- , _wpRange = 20
|
||||
-- , _wpIsAuto = False
|
||||
@@ -272,7 +272,7 @@ tractorGun = defaultAutoGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _wpFire = shoot $ aTractorBeam 0
|
||||
, _itUse = shoot $ aTractorBeam 0
|
||||
, _wpSpread = 0.00001
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = onLayer FlItLayer $ color blue $ pictures [polygon $ rectNESW 1.5 6 (-1.5) 0 ]
|
||||
@@ -291,7 +291,7 @@ launcher = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 20
|
||||
, _itUseTime = 0
|
||||
, _wpFire = shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makeExplosionAt
|
||||
, _itUse = shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makeExplosionAt
|
||||
, _wpSpread = 0.02
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = onLayer FlItLayer $ color cyan $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
@@ -305,34 +305,34 @@ launcher = defaultGun
|
||||
}
|
||||
flameLauncher = launcher
|
||||
{ _itName = "FLROCKO"
|
||||
, _wpFire = shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makeFlameExplosionAt
|
||||
, _itUse = shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makeFlameExplosionAt
|
||||
}
|
||||
|
||||
poisonLauncher = launcher
|
||||
{ _itName = "POISROCK"
|
||||
, _wpFire = shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makePoisonExplosionAt
|
||||
, _itUse = shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makePoisonExplosionAt
|
||||
}
|
||||
|
||||
teslaLauncher = launcher
|
||||
{ _itName = "TESLROCK"
|
||||
, _wpFire = shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makeTeslaExplosionAt
|
||||
, _itUse = shootWithSound (fromIntegral launcherSound) $ aRocketWithPayload makeTeslaExplosionAt
|
||||
}
|
||||
|
||||
useTargetPos
|
||||
:: (Point2 -> Int -> World -> World)
|
||||
-> Int
|
||||
:: (Point2 -> Creature -> World -> World)
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
useTargetPos f cid w = case cr ^? crInv . ix (_crInvSel cr) . itAttachment . _Just . itTargetPos of
|
||||
useTargetPos f cr w = case cr ^? crInv . ix (_crInvSel cr) . itAttachment . _Just . itTargetPos of
|
||||
Nothing -> w
|
||||
Just p -> f p cid w
|
||||
Just p -> f p cr w
|
||||
where
|
||||
cr = _creatures w IM.! cid
|
||||
cid = _crID cr
|
||||
|
||||
bezierGun :: Item
|
||||
bezierGun = defaultAutoGun
|
||||
{ _itName = "B-GUN"
|
||||
, _wpFire = useTargetPos $ \p ->
|
||||
, _itUse = useTargetPos $ \p ->
|
||||
shootWithSound 0
|
||||
. withMuzFlare
|
||||
. withRecoil 40
|
||||
@@ -347,8 +347,8 @@ bezierGun = defaultAutoGun
|
||||
, _itAimingRange = 0
|
||||
}
|
||||
|
||||
shootBezier :: Point2 -> Int -> World -> World
|
||||
shootBezier targetp cid w = w & particles %~ (theBullet :)
|
||||
shootBezier :: Point2 -> Creature -> World -> World
|
||||
shootBezier targetp cr w = w & particles %~ (theBullet :)
|
||||
where
|
||||
theBullet = aCurveBulAt
|
||||
(Just cid)
|
||||
@@ -359,7 +359,7 @@ shootBezier targetp cid w = w & particles %~ (theBullet :)
|
||||
(destroyOnImpact bulHitCr bulHitWall' bulHitFF')
|
||||
5
|
||||
controlp = mouseWorldPos w
|
||||
cr = _creatures w IM.! cid
|
||||
cid = _crID cr
|
||||
dir = _crDir cr
|
||||
startp = _crPos cr +.+ rotateV dir (_crRad cr + 1,0)
|
||||
(randPos,randPos') = flip evalState (_randGen w) $ do
|
||||
@@ -382,7 +382,7 @@ remoteLauncher = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 10
|
||||
, _itUseTime = 0
|
||||
, _wpFire = hammerCheck fireRemoteLauncher
|
||||
, _itUse = hammerCheck fireRemoteLauncher
|
||||
, _wpSpread = 0.02
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = onLayer FlItLayer $ color cyan $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
@@ -402,7 +402,7 @@ hvAutoGun = defaultAutoGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 25
|
||||
, _itUseTime = 0
|
||||
, _wpFire = rateIncAB 24 10 (torqueBeforeForced 0.1 mkHvBul) $ torqueAfter 0.2 mkHvBul
|
||||
, _itUse = rateIncAB 24 10 (torqueBeforeForced 0.1 mkHvBul) $ torqueAfter 0.2 mkHvBul
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = onLayer FlItLayer $ color orange $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
, _itAmount = 1
|
||||
@@ -427,7 +427,7 @@ ltAutoGun = defaultAutoGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 4
|
||||
, _itUseTime = 0
|
||||
, _wpFire = shootWithSound 0 . withRandomDir 0.3 . withSidePush 50
|
||||
, _itUse = shootWithSound 0 . withRandomDir 0.3 . withSidePush 50
|
||||
. withMuzFlare $ withVelWthHiteff (30,0) 2 basicBulletEffect
|
||||
, _wpSpread = 0.5
|
||||
, _wpRange = 20
|
||||
@@ -452,7 +452,7 @@ miniGun = defaultAutoGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 2
|
||||
, _itUseTime = 0
|
||||
, _wpFire = withWarmUp 50 . torqueBefore 0.03 . withSidePush 50 . withRecoil 15
|
||||
, _itUse = withWarmUp 50 . torqueBefore 0.03 . withSidePush 50 . withRecoil 15
|
||||
. withRandomDir 0.1
|
||||
. withRandomOffset 9
|
||||
. withMuzFlare
|
||||
@@ -475,7 +475,7 @@ spreadGun = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 20
|
||||
, _itUseTime = 0
|
||||
, _wpFire = shootWithSound (fromIntegral shotgunSound)
|
||||
, _itUse = shootWithSound (fromIntegral shotgunSound)
|
||||
. withRecoil 100
|
||||
. withMuzFlare
|
||||
$ spreadNumVelWthHiteff spreadGunSpread 9 (30,0) 2 basicBulletEffect
|
||||
@@ -497,7 +497,7 @@ multGun = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 20
|
||||
, _itUseTime = 0
|
||||
, _wpFire = shootWithSound (fromIntegral shotgunSound)
|
||||
, _itUse = shootWithSound (fromIntegral shotgunSound)
|
||||
. withRecoil 200
|
||||
. withMuzFlare
|
||||
$ numVelWthHitEff 5 (50,0) 5 basicBulletEffect
|
||||
@@ -529,7 +529,7 @@ longGun = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 100
|
||||
, _itUseTime = 0
|
||||
, _wpFire = shootWithSound (fromIntegral longGunSound)
|
||||
, _itUse = shootWithSound (fromIntegral longGunSound)
|
||||
. withThickSmoke
|
||||
. torqueAfter 0.05
|
||||
. withMuzFlare
|
||||
@@ -566,7 +566,7 @@ poisonSprayer = defaultAutoGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _wpFire = shoot aGasCloud
|
||||
, _itUse = shoot aGasCloud
|
||||
, _wpSpread = 0.3
|
||||
, _wpRange = 8
|
||||
, _itFloorPict = onLayer FlItLayer $ color yellow $ polygon $ rectNESW 4 4 (-4) (-4)
|
||||
@@ -587,7 +587,7 @@ flamer = defaultAutoGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _wpFire = shoot $ withSidePush 5 $ withSidePushAfter 10 $ randWalkAngle 0.5 0.05 aFlame
|
||||
, _itUse = shoot $ withSidePush 5 $ withSidePushAfter 10 $ randWalkAngle 0.5 0.05 aFlame
|
||||
, _wpSpread = 0
|
||||
, _wpRange = 8
|
||||
, _itFloorPict = onLayer FlItLayer $ color yellow $ polygon $ rectNESW 4 4 (-4) (-4)
|
||||
@@ -608,7 +608,7 @@ blinkGun = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _wpFire = shoot aSelf
|
||||
, _itUse = shoot aSelf
|
||||
, _wpSpread = 0.05
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = onLayer FlItLayer $ polygon [(-2,-2),(-2,2),(2,2),(2,0),(0,0),(0,-2)]
|
||||
@@ -619,17 +619,18 @@ blinkGun = defaultGun
|
||||
}
|
||||
|
||||
|
||||
aTeslaArc :: Int -> World -> World
|
||||
aTeslaArc cid w = aTeslaArc' cid
|
||||
$ soundFrom (CrWeaponSound cid) 25 1 0 w
|
||||
aTeslaArc :: Creature -> World -> World
|
||||
aTeslaArc cr w = aTeslaArc' cr $ soundFrom (CrWeaponSound cid) 25 1 0 w
|
||||
where
|
||||
cid = _crID cr
|
||||
|
||||
aTeslaArc' :: Int -> World -> World
|
||||
aTeslaArc' cid w
|
||||
aTeslaArc' :: Creature -> World -> World
|
||||
aTeslaArc' cr w
|
||||
= teslaGunFlashAt (pos +.+ 5 *.* unitVectorAtAngle dir)
|
||||
$ over projectiles (IM.insert i (makeTeslaArcAt i pos dir))
|
||||
$ set randGen g w
|
||||
where
|
||||
cr = _creatures w IM.! cid
|
||||
cid = _crID cr
|
||||
i = newProjectileKey w
|
||||
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
|
||||
+.+ sideOffset *.* vNormal (unitVectorAtAngle dir)
|
||||
@@ -638,13 +639,13 @@ aTeslaArc' cid w
|
||||
|
||||
aRocketWithPayload
|
||||
:: (Point2 -> World -> World) -- ^ Payload
|
||||
-> Int -- ^ Creature id
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
aRocketWithPayload pl cid w = over projectiles (IM.insert i theShell) w
|
||||
aRocketWithPayload pl cr w = over projectiles (IM.insert i theShell) w
|
||||
where
|
||||
cid = _crID cr
|
||||
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
|
||||
@@ -746,11 +747,11 @@ remoteShellPic i
|
||||
shellExplosionAt :: Point2 -> World -> World
|
||||
shellExplosionAt = makeExplosionAt
|
||||
|
||||
aGasCloud :: Int -> World -> World
|
||||
aGasCloud cid w = insertCloud $ set randGen g w
|
||||
aGasCloud :: Creature -> World -> World
|
||||
aGasCloud cr w = insertCloud $ set randGen g w
|
||||
where
|
||||
(a,g) = randomR (-0.1,0.1) (_randGen w)
|
||||
cr = _creatures w IM.! cid
|
||||
cid = _crID cr
|
||||
dir = _crDir cr + a
|
||||
pos = _crPos cr +.+ ((_crRad cr + 2.9) *.* unitVectorAtAngle (_crDir cr))
|
||||
--pos2 = (0.5 *.* vel) +.+
|
||||
@@ -758,17 +759,17 @@ aGasCloud cid w = insertCloud $ set randGen g w
|
||||
vel = (_crPos cr -.- _crOldPos cr) +.+ 10 *.* unitVectorAtAngle dir
|
||||
insertCloud = makeGasCloud pos vel -- . makeFlame pos2 vel (Just cid)
|
||||
|
||||
aFlame :: Int -> World -> World
|
||||
aFlame cid w = insertFlame w
|
||||
aFlame :: Creature -> World -> World
|
||||
aFlame cr w = insertFlame w
|
||||
where
|
||||
(t,_) = randomR (99,101) (_randGen w)
|
||||
cr = _creatures w IM.! cid
|
||||
cid = _crID cr
|
||||
dir = _crDir cr
|
||||
pos = _crPos cr +.+ ((_crRad cr + 2.9) *.* unitVectorAtAngle (_crDir cr))
|
||||
vel = (_crPos cr -.- _crOldPos cr) +.+ 4 *.* unitVectorAtAngle dir
|
||||
insertFlame = makeFlame t pos vel (Just cid) -- . makeFlame pos2 vel (Just cid)
|
||||
|
||||
aSelf :: Int -> World -> World
|
||||
aSelf :: Creature -> World -> World
|
||||
aSelf = blinkAction
|
||||
|
||||
reflect :: Float -> Float -> Float
|
||||
@@ -783,7 +784,7 @@ pointToItem (OnFloor flid) = floorItems . ix flid . flIt
|
||||
retireRemoteRocket :: Int -> Int -> Int -> World -> World
|
||||
retireRemoteRocket itid 0 pjid w =
|
||||
set (pointToItem (_itemPositions w IM.! itid) . itAttachment . _Just . scopePos) (0,0)
|
||||
$ set (pointToItem (_itemPositions w IM.! itid) . wpFire) (hammerCheck fireRemoteLauncher)
|
||||
$ set (pointToItem (_itemPositions w IM.! itid) . itUse) (hammerCheck fireRemoteLauncher)
|
||||
(w & projectiles %~ IM.delete pjid)
|
||||
retireRemoteRocket itid t pjid w = setScope w
|
||||
& projectiles . ix pjid . pjUpdate .~ retireRemoteRocket itid (t-1) pjid
|
||||
@@ -799,7 +800,7 @@ retireRemoteBomb :: Int -> Int -> Int -> World -> World
|
||||
retireRemoteBomb itid 0 pjid w =
|
||||
set (pointToItem (_itemPositions w IM.! itid) . itAttachment . _Just . scopePos) (0,0)
|
||||
$ set (pointToItem (_itemPositions w IM.! itid) . itZoom) defaultItZoom
|
||||
$ set (pointToItem (_itemPositions w IM.! itid) . twFire) (hammerCheck throwRemoteBomb)
|
||||
$ set (pointToItem (_itemPositions w IM.! itid) . itUse) (hammerCheck throwRemoteBomb)
|
||||
(w & projectiles %~ IM.delete pjid)
|
||||
retireRemoteBomb itid t pjid w = setScope w
|
||||
& projectiles . ix pjid . pjUpdate .~ retireRemoteBomb itid (t-1) pjid
|
||||
@@ -870,7 +871,7 @@ grenade = Throwable
|
||||
, _itFloorPict = onLayer FlItLayer $ polygon [(-3,-3),(-3,3),(3,3),(3,-3)]
|
||||
, _twMaxRange = 150
|
||||
, _twAccuracy = 30
|
||||
, _twFire = useTimeCheck $ throwGrenade makeExplosionAt
|
||||
, _itUse = useTimeCheck $ throwGrenade makeExplosionAt
|
||||
, _itAimingSpeed = 1
|
||||
, _itAimingRange = 0
|
||||
, _itZoom = defaultItZoom {_itAimZoomMax = f fuseTime, _itAimZoomMin = f fuseTime}
|
||||
@@ -893,7 +894,7 @@ grenade = Throwable
|
||||
flameGrenade :: Item
|
||||
flameGrenade = grenade {
|
||||
_itName = "FLMGREN " ++ show fuseTime
|
||||
, _twFire = throwGrenade makeFlameExplosionAt
|
||||
, _itUse = throwGrenade makeFlameExplosionAt
|
||||
}
|
||||
where
|
||||
fuseTime = 50 :: Int
|
||||
@@ -902,7 +903,7 @@ flameGrenade = grenade {
|
||||
teslaGrenade :: Item
|
||||
teslaGrenade = grenade {
|
||||
_itName = "TLSGREN " ++ show fuseTime
|
||||
, _twFire = throwGrenade makeTeslaExplosionAt
|
||||
, _itUse = throwGrenade makeTeslaExplosionAt
|
||||
}
|
||||
where
|
||||
fuseTime = 50 :: Int
|
||||
@@ -917,22 +918,22 @@ remoteBomb = defaultThrowable
|
||||
, _itFloorPict = onLayer FlItLayer $ polygon [(-3,-3),(-3,3),(3,3),(3,-3)]
|
||||
, _twMaxRange = 150
|
||||
, _twAccuracy = 30
|
||||
, _twFire = hammerCheck throwRemoteBomb
|
||||
, _itUse = hammerCheck throwRemoteBomb
|
||||
, _itAttachment = Just $ ItScope (0,0) 0 1 True
|
||||
, _itEquipPict = pictureWeaponOnAim remoteBombUnarmedPic
|
||||
}
|
||||
|
||||
|
||||
|
||||
fireRemoteLauncher :: Int -> World -> World
|
||||
fireRemoteLauncher cid w = setLocation
|
||||
fireRemoteLauncher :: Creature -> World -> World
|
||||
fireRemoteLauncher cr w = setLocation
|
||||
$ resetFire
|
||||
$ resetName
|
||||
$ soundOnce (fromIntegral launcherSound)
|
||||
$ over projectiles remRocket w
|
||||
where
|
||||
i = IM.newKey $ _projectiles w
|
||||
cr = _creatures w IM.! cid
|
||||
cid = _crID cr
|
||||
dir = _crDir cr
|
||||
pos = _crPos cr +.+ rotateV dir (_crRad cr + 1,0)
|
||||
remRocket = IM.insert i $ Projectile
|
||||
@@ -946,8 +947,8 @@ fireRemoteLauncher cid w = setLocation
|
||||
j = _crInvSel $ _creatures w IM.! cid
|
||||
newitid = IM.newKey $ _itemPositions w
|
||||
maybeitid = w ^? creatures . ix cid . crInv . ix j . itID . _Just
|
||||
resetFire = set (creatures . ix cid . crInv . ix j . wpFire)
|
||||
$ hammerCheck $ explodeRemoteRocket itid i
|
||||
resetFire = set (creatures . ix cid . crInv . ix j . itUse)
|
||||
$ hammerCheck $ \cr -> explodeRemoteRocket itid i
|
||||
resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTEROCKET"
|
||||
setLocation :: World -> World
|
||||
setLocation w' = case maybeitid of
|
||||
@@ -1025,7 +1026,7 @@ moveRemoteShell time i cid itid _ w
|
||||
|
||||
r1 = _randGen w & evalState (randInCirc 10)
|
||||
smokeGen = makeSmokeCloudAt $ oldPos +.+ r1 +.+ 30 *.* normalizeV (oldPos -.- newPos)
|
||||
doExplosion = explodeRemoteRocket itid i cid
|
||||
doExplosion = explodeRemoteRocket itid i
|
||||
setScope w' = case _itemPositions w' IM.! itid of
|
||||
InInv cid' invid
|
||||
-> w' & creatures . ix cid' . crInv . ix invid . itAttachment
|
||||
@@ -1035,23 +1036,23 @@ moveRemoteShell time i cid itid _ w
|
||||
explodeRemoteRocket
|
||||
:: Int -- ^ Item id
|
||||
-> Int -- ^ Projectile id
|
||||
-> Int -- ^ (Probably) firing creature id
|
||||
-> World
|
||||
-> World
|
||||
explodeRemoteRocket itid pjid _ w
|
||||
explodeRemoteRocket itid pjid w
|
||||
= set (projectiles . ix pjid . pjUpdate) (retireRemoteRocket itid 30 pjid)
|
||||
$ set (projectiles . ix pjid . pjPict) blank
|
||||
$ set (itPoint . wpFire) (const id)
|
||||
$ set (itPoint . itUse) (const id)
|
||||
$ resetName
|
||||
$ makeExplosionAt (_pjPos (_projectiles w IM.! pjid)) w
|
||||
where
|
||||
resetName = set (itPoint . itName) "REMOTELAUNCHER"
|
||||
itPoint = pointToItem $ _itemPositions w IM.! itid
|
||||
|
||||
throwRemoteBomb :: Int -> World -> World
|
||||
throwRemoteBomb n w = setLocation $ removePict $ resetFire
|
||||
throwRemoteBomb :: Creature -> World -> World
|
||||
throwRemoteBomb cr w = setLocation $ removePict $ resetFire
|
||||
$ resetName $ over projectiles addG w
|
||||
where
|
||||
n = _crID cr -- to change to cid
|
||||
addG = IM.insert i $ Projectile
|
||||
{ _pjPos = p
|
||||
, _pjStartPos = p
|
||||
@@ -1072,7 +1073,7 @@ throwRemoteBomb n w = setLocation $ removePict $ resetFire
|
||||
j = _crInvSel $ _creatures w IM.! n
|
||||
resetName = set (creatures . ix n . crInv . ix j . itName) "REMOTE"
|
||||
removePict = set (creatures . ix n . crInv . ix j . itEquipPict) $ \ _ _ -> blank
|
||||
resetFire = set (creatures . ix n . crInv . ix j . twFire)
|
||||
resetFire = set (creatures . ix n . crInv . ix j . itUse)
|
||||
$ hammerCheck $ explodeRemoteBomb itid i
|
||||
cr = _creatures w IM.! n
|
||||
p' = _crPos cr +.+ rotateV (_crDir cr) (_crRad cr,0)
|
||||
@@ -1087,17 +1088,18 @@ throwRemoteBomb n w = setLocation $ removePict $ resetFire
|
||||
newitid = IM.newKey $ _itemPositions w
|
||||
itid = fromMaybe newitid maybeitid
|
||||
|
||||
explodeRemoteBomb :: Int -> Int -> Int -> World -> World
|
||||
explodeRemoteBomb itid pjid n w
|
||||
explodeRemoteBomb :: Int -> Int -> Creature -> World -> World
|
||||
explodeRemoteBomb itid pjid cr w
|
||||
= set (projectiles . ix pjid . pjUpdate) (retireRemoteBomb itid 30 pjid)
|
||||
$ set (projectiles . ix pjid . pjPict) blank
|
||||
$ set (creatures . ix n . crInv . ix j . twFire) (const id)
|
||||
$ set (creatures . ix n . crInv . ix j . itUse) (const id)
|
||||
$ resetName
|
||||
$ resetPict
|
||||
-- $ resetScope
|
||||
$ makeExplosionAt (_pjPos (_projectiles w IM.! pjid)) w
|
||||
-- - $ makeShrapnelBombAt (_pjPos (_projectiles w IM.! pjid)) w
|
||||
where
|
||||
n = _crID cr
|
||||
resetName = set (creatures . ix n . crInv . ix j . itName) "REMOTEBOMB"
|
||||
resetPict = set (creatures . ix n . crInv . ix j . itEquipPict )
|
||||
(pictureWeaponOnAim remoteBombUnarmedPic)
|
||||
@@ -1140,7 +1142,7 @@ radar = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 120
|
||||
, _itUseTime = 0
|
||||
, _wpFire = shoot aRadarPulse
|
||||
, _itUse = shoot aRadarPulse
|
||||
, _wpSpread = autogunSpread
|
||||
, _wpRange = 20
|
||||
, _itHammer = HammerUp
|
||||
@@ -1163,7 +1165,7 @@ sonar = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 120
|
||||
, _itUseTime = 0
|
||||
, _wpFire = shoot aSonarPulse
|
||||
, _itUse = shoot aSonarPulse
|
||||
, _wpRange = 20
|
||||
, _itHammer = HammerUp
|
||||
, _itFloorPict = onLayer FlItLayer $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
@@ -1215,17 +1217,17 @@ spawnGun cr = defaultGun
|
||||
, _wpReloadTime = 80
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 100
|
||||
, _wpFire = spawnCrNextTo cr
|
||||
, _itUse = spawnCrNextTo cr
|
||||
}
|
||||
spawnCrNextTo
|
||||
:: Creature -- ^ Creature to spawn
|
||||
-> Int -- ^ ID of existing creature that will be spawned next to
|
||||
-> Creature -- ^ existing creature that will be spawned next to
|
||||
-> World
|
||||
-> World
|
||||
spawnCrNextTo cr i w = w & creatures %~ IM.insert k newCr
|
||||
spawnCrNextTo cr sCr w = w & creatures %~ IM.insert k newCr
|
||||
where
|
||||
k = IM.newKey $ _creatures w
|
||||
sCr = _creatures w IM.! i
|
||||
i = _crID cr
|
||||
newCr = cr
|
||||
& crID .~ k
|
||||
& crPos .~ _crPos sCr +.+ unitVectorAtAngle (_crDir sCr)
|
||||
|
||||
Reference in New Issue
Block a user