Implement teleporting bullets

This commit is contained in:
2022-02-21 20:51:01 +00:00
parent 724ee21afc
commit f626fce105
23 changed files with 245 additions and 154 deletions
+16
View File
@@ -29,6 +29,22 @@ bounceModule :: Item
bounceModule = makeTypeCraft BOUNCEMODULE
& itInvSize .~ 1
& itInvColor .~ chartreuse
teleportModule :: Item
teleportModule = makeTypeCraft TELEPORTMODULE
& itInvSize .~ 1
& itInvColor .~ chartreuse
timeModule :: Item
timeModule = makeTypeCraft TIMEMODULE
& itInvSize .~ 1
& itInvColor .~ chartreuse
sizeModule :: Item
sizeModule = makeTypeCraft SIZEMODULE
& itInvSize .~ 1
& itInvColor .~ chartreuse
gravityModule :: Item
gravityModule = makeTypeCraft GRAVITYMODULE
& itInvSize .~ 1
& itInvColor .~ chartreuse
pipe :: Item
pipe = makeTypeCraft PIPE
+1
View File
@@ -54,6 +54,7 @@ data AimStance
| LeaveHolstered
deriving
(Eq,Show,Ord,Enum)
-- TODO check how much of this is necessary
data ItZoom = ItZoom
{ _itZoomMax :: Float
, _itZoomMin :: Float
-12
View File
@@ -1,12 +0,0 @@
module Dodge.Item.MaxAmmo where
import Dodge.Data
import Control.Lens
itMaxAmmo :: Item -> Int
itMaxAmmo it = _ammoBaseMax (_itConsumption it)
+ maybe 0 f (it ^? itModules . modRifleMag . theModule)
where
f DrumMag = 45
f BeltMag = 135
f MagnetMag = 0
+12 -12
View File
@@ -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
+16 -13
View File
@@ -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
+5 -6
View File
@@ -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 .~
+2
View File
@@ -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)
+1 -1
View File
@@ -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)]
+2 -4
View File
@@ -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
+28
View File
@@ -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