Implement teleporting bullets
This commit is contained in:
@@ -7,15 +7,12 @@ module Dodge.Item.Weapon.AmmoParams
|
||||
, fractionLoadedAmmo2
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Item.MaxAmmo
|
||||
import Dodge.Particle.Bullet.Spawn
|
||||
import Dodge.Creature.HandPos
|
||||
import Dodge.WorldEvent.HitEffect
|
||||
import Dodge.Particle.Bullet.HitEffect
|
||||
import Geometry
|
||||
import LensHelp
|
||||
|
||||
import Data.Maybe
|
||||
--import Data.Maybe
|
||||
--import Control.Lens
|
||||
|
||||
useAmmoParamsRate :: Int
|
||||
@@ -43,25 +40,24 @@ useAmmoParams it cr = withVelWthHiteff
|
||||
(_rifling $ _itParams it)
|
||||
(_amBulWth b)
|
||||
muzlength
|
||||
bulHitEff
|
||||
-- (_amBulEff b)
|
||||
(_amBulEff b)
|
||||
cr
|
||||
where
|
||||
muzlength = aimingMuzzlePos cr it
|
||||
muzvel = _muzVel $ _itParams it
|
||||
b = _aoType $ _itConsumption it
|
||||
bulHitEff = fromMaybe (destroyOnImpact bulHitCr bulHitWall)
|
||||
$ it ^? itModules . modHitEffect . theModule
|
||||
-- bulHitEff = fromMaybe (destroyOnImpact bulHitCr bulHitWall)
|
||||
-- $ it ^? itModules . modHitEffect . theModule
|
||||
|
||||
useAmmoParamsVelMod :: Float -> Item -> Creature -> World -> World
|
||||
useAmmoParamsVelMod vfact it = withDelayedVelWthHiteff vfact (_amBulVel b) (_rifling $ _itParams it)
|
||||
(_amBulWth b)
|
||||
-- (_amBulEff b)
|
||||
bulHitEff
|
||||
(_amBulEff b)
|
||||
-- bulHitEff
|
||||
where
|
||||
b = _aoType $ _itConsumption it
|
||||
bulHitEff = fromMaybe (destroyOnImpact bulHitCr bulHitWall)
|
||||
$ it ^? itModules . modHitEffect . theModule
|
||||
-- bulHitEff = fromMaybe (destroyOnImpact bulHitCr bulHitWall)
|
||||
-- $ it ^? itModules . modHitEffect . theModule
|
||||
|
||||
{- | Creates a bullet with a given velocity, width, and 'HitEffect' -}
|
||||
withVelWthHiteff
|
||||
@@ -104,7 +100,11 @@ loadedAmmo it
|
||||
|
||||
fractionLoadedAmmo :: Item -> Float
|
||||
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (itMaxAmmo it)
|
||||
where
|
||||
itMaxAmmo = _ammoBaseMax . _itConsumption
|
||||
|
||||
fractionLoadedAmmo2 :: Item -> Float
|
||||
fractionLoadedAmmo2 it = 1 -
|
||||
(1 - fromIntegral (loadedAmmo it) / fromIntegral (itMaxAmmo it))**2
|
||||
where
|
||||
itMaxAmmo = _ammoBaseMax . _itConsumption
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.Item.Weapon.Bezier
|
||||
( bezierGun
|
||||
, teleGun
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
@@ -16,14 +17,14 @@ import Dodge.RandomHelp
|
||||
import Dodge.SoundLogic.LoadSound
|
||||
import Geometry
|
||||
--import ShapePicture
|
||||
import LensHelp
|
||||
|
||||
import Data.Maybe
|
||||
import Control.Lens
|
||||
import Control.Monad.State
|
||||
bezierGun :: Item
|
||||
bezierGun = defaultGun
|
||||
{ _itName = "B-GUN"
|
||||
, _itUse = ruseRate 6 (\_ -> useTargetPos $ \p -> shootBezier $ fromJust p) -- <- the start point
|
||||
{ _itName = "BEZIERGUN"
|
||||
, _itUse = ruseRate 6 (\_ -> useTargetPos $ \p -> shootBezier $ fromJust p) -- <- the start point
|
||||
NoHammer
|
||||
[ ammoCheckI
|
||||
, useTimeCheck
|
||||
@@ -43,21 +44,20 @@ bezierGun = defaultGun
|
||||
, _itEffect = rbSetTarget
|
||||
-- , _itZoom = defaultItZoom
|
||||
, _itConsumption = defaultAmmo
|
||||
{ _ammoBaseMax = 50
|
||||
{ _ammoBaseMax = 15
|
||||
}
|
||||
}
|
||||
|
||||
shootBezier :: Point2 -> Creature -> World -> World
|
||||
shootBezier targetp cr w = w & particles %~ (theBullet :)
|
||||
shootBezier targetp cr w = w & particles .:~ aCurveBulAt
|
||||
(Just cid)
|
||||
(V4 200 200 200 1)
|
||||
startp
|
||||
(controlp +.+ randPos)
|
||||
(targetp +.+ randPos')
|
||||
(destroyOnImpact bulHitCr bulHitWall)
|
||||
5
|
||||
where
|
||||
theBullet = aCurveBulAt
|
||||
(Just cid)
|
||||
(V4 200 200 200 1)
|
||||
startp
|
||||
(controlp +.+ randPos)
|
||||
(targetp +.+ randPos')
|
||||
(destroyOnImpact bulHitCr bulHitWall)
|
||||
5
|
||||
controlp = mouseWorldPos w
|
||||
cid = _crID cr
|
||||
dir = _crDir cr
|
||||
@@ -66,3 +66,6 @@ shootBezier targetp cr w = w & particles %~ (theBullet :)
|
||||
a <- randInCirc 10
|
||||
b <- randInCirc 20
|
||||
return (a,b)
|
||||
|
||||
teleGun :: Item
|
||||
teleGun = bezierGun
|
||||
|
||||
@@ -34,6 +34,7 @@ import Sound.Data
|
||||
import LensHelp
|
||||
|
||||
import Data.Maybe
|
||||
--import qualified Data.Map.Strict as M
|
||||
--import qualified Data.Sequence as Seq
|
||||
--import Control.Lens
|
||||
--import Control.Monad.State
|
||||
@@ -64,9 +65,9 @@ bangCane = defaultGun
|
||||
, useAmmoAmount 1
|
||||
, torqueAfterI 0.1
|
||||
, applyInaccuracy
|
||||
, withMuzFlareI
|
||||
, withRecoilI 50
|
||||
, withSmoke 1 black 20 200 5
|
||||
, withMuzFlareI
|
||||
]
|
||||
, _itTweaks = defaultBulletSelTweak
|
||||
, _itDimension = ItemDimension
|
||||
@@ -153,10 +154,7 @@ rifle = bangCane
|
||||
|
||||
repeater :: Item
|
||||
repeater = rifle
|
||||
& itModules .~ ItemModules
|
||||
{ _modHitEffect = DefaultModule
|
||||
, _modRifleMag = DefaultModule
|
||||
}
|
||||
& itModules . at ModRifleMag ?~ DefaultModule
|
||||
& itName .~ "REPEATER"
|
||||
& itType .~ REPEATER
|
||||
& itConsumption . reloadType .~ ActiveClear
|
||||
@@ -177,6 +175,7 @@ autoRifle = repeater
|
||||
& itName .~ "AUTORIFLE"
|
||||
& itType .~ AUTORIFLE
|
||||
& itUse . useMods %~ ((ammoCheckI :) . tail)
|
||||
& itModules . at ModAutoMag ?~ DefaultModule
|
||||
-- & itUse . useDelay . rateMax .~ 6
|
||||
burstRifle :: Item
|
||||
burstRifle = repeater
|
||||
@@ -218,7 +217,7 @@ completeBurstRifle :: Item
|
||||
completeBurstRifle = repeater
|
||||
& itName .~ "COMPLETEBURSTRIFLE"
|
||||
& itType .~ COMPLETEBURSTRIFLE
|
||||
& itModules . modRifleMag .~ BlockedModule
|
||||
& itModules . at ModRifleMag .~ Nothing
|
||||
& itParams . gunBarrels . brlInaccuracy .~ 0.1
|
||||
& itUse . useDelay . rateMax .~ 28
|
||||
& itUse . useMods .~
|
||||
|
||||
@@ -199,12 +199,14 @@ autoPistol = pistol
|
||||
& itUse . useMods .~ (ammoCheckI : pistolAfterHamMods)
|
||||
& itName .~ "AUTOPISTOL"
|
||||
& itType .~ AUTOPISTOL
|
||||
& itModules . at ModAutoMag ?~ DefaultModule
|
||||
machinePistol :: Item
|
||||
machinePistol = autoPistol
|
||||
& itUse . useDelay . rateMax .~ 2
|
||||
& itUse . useMods .~ (ammoCheckI : machinePistolAfterHamMods)
|
||||
& itName .~ "MACHINEPISTOL"
|
||||
& itType .~ MACHINEPISTOL
|
||||
& itModules . at ModAutoMag .~ Nothing
|
||||
smg :: Item
|
||||
smg = autoPistol -- & some parameter affecting stability
|
||||
& itUse . useMods .~ (ammoCheckI : smgAfterHamMods)
|
||||
|
||||
@@ -128,7 +128,7 @@ targetRBMousePos w = (f, \_ _ _ w' -> cursorPic w')
|
||||
where
|
||||
f _ = Just mwp
|
||||
mwp = mouseWorldPos w
|
||||
cursorPic w' = setLayer 1 $ onLayer InvLayer $ uncurryV translate mwp
|
||||
cursorPic w' = setLayer 1 $ color red $ onLayer InvLayer $ uncurryV translate mwp
|
||||
$ rotate (_cameraRot w')
|
||||
$ pictures
|
||||
[line [V2 x x, V2 (-x) (-x)]
|
||||
|
||||
@@ -10,6 +10,7 @@ module Dodge.Item.Weapon.InventoryDisplay
|
||||
import Dodge.Data
|
||||
import Padding
|
||||
import Dodge.Inventory.ItemSpace
|
||||
import Dodge.Module
|
||||
|
||||
import Data.Maybe
|
||||
import Data.Sequence
|
||||
@@ -37,10 +38,7 @@ basicItemDisplay it = Prelude.take (itSlotsTaken it) $
|
||||
-- , maybeRateStatus
|
||||
]
|
||||
|
||||
moduleStrings :: Item -> [String]
|
||||
moduleStrings it = map (" " ++)
|
||||
$ (fromMaybe [] $ it ^? itModules . modHitEffect . modName)
|
||||
++ (fromMaybe [] $ it ^? itModules . modRifleMag . modName)
|
||||
-- this can be moved to Dodge/Module and unified with moduleSizes
|
||||
|
||||
maybeModeStatus :: Item -> Maybe String
|
||||
maybeModeStatus it = case it ^? itAttachment of
|
||||
|
||||
@@ -25,6 +25,9 @@ module Dodge.Item.Weapon.TriggerType
|
||||
, withSmoke
|
||||
, withThickSmokeI
|
||||
, withThinSmokeI
|
||||
, withPositionOffset
|
||||
, withPositionWallCheck
|
||||
, withPosDirWallCheck
|
||||
, withRandomOffsetI
|
||||
, withRandomDirI
|
||||
, withRecoilI
|
||||
@@ -51,6 +54,7 @@ module Dodge.Item.Weapon.TriggerType
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.Base.Collide
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.Reloading
|
||||
import Dodge.WorldEvent
|
||||
@@ -398,6 +402,30 @@ withRandomItemParams rip eff it cr w = eff (it & itParams .~ it') cr $ w & randG
|
||||
where
|
||||
(it',g) = runState rip (_randGen w)
|
||||
|
||||
withPositionOffset
|
||||
:: (Item -> Creature -> World -> (Point2,Float))
|
||||
-> ChainEffect
|
||||
withPositionOffset h f it cr w = f it (cr & crPos .+.+~ p & crDir +~ a) w
|
||||
where
|
||||
(p,a) = h it cr w
|
||||
|
||||
withPositionWallCheck
|
||||
:: (Item -> Creature -> World -> Point2)
|
||||
-> ChainEffect
|
||||
withPositionWallCheck h f it cr w
|
||||
| hasLOS p (_crPos cr) w = f it (cr & crPos .~ p) w
|
||||
| otherwise = w
|
||||
where
|
||||
p = h it cr w
|
||||
withPosDirWallCheck
|
||||
:: (Item -> Creature -> World -> (Point2,Float))
|
||||
-> ChainEffect
|
||||
withPosDirWallCheck h f it cr w
|
||||
| hasLOS p (_crPos cr) w = f it (cr & crPos .~ p & crDir .~ a) w
|
||||
| otherwise = w
|
||||
where
|
||||
(p,a) = h it cr w
|
||||
|
||||
{- | Apply the effect to a translated creature. -}
|
||||
withRandomOffsetI
|
||||
:: Float -- ^ Max possible translate
|
||||
|
||||
Reference in New Issue
Block a user