Unify bullet creation
This commit is contained in:
@@ -10,7 +10,6 @@ import Dodge.Item.Weapon.BulletGuns
|
|||||||
import Dodge.Item.Weapon.BatteryGuns
|
import Dodge.Item.Weapon.BatteryGuns
|
||||||
import Dodge.Item.Weapon.Launcher
|
import Dodge.Item.Weapon.Launcher
|
||||||
import Dodge.Item.Weapon.SprayGuns
|
import Dodge.Item.Weapon.SprayGuns
|
||||||
import Dodge.Item.Weapon.Bezier
|
|
||||||
import Dodge.Item.Weapon.TriggerType
|
import Dodge.Item.Weapon.TriggerType
|
||||||
import Dodge.Item.Weapon.ExtraEffect
|
import Dodge.Item.Weapon.ExtraEffect
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
@@ -41,7 +40,6 @@ itemCombinations =
|
|||||||
, po [BANGCANE,TIN] rifle
|
, po [BANGCANE,TIN] rifle
|
||||||
, po [RIFLE,PLANK] repeater
|
, po [RIFLE,PLANK] repeater
|
||||||
, po [REPEATER,SPRING,HARDWARE] autoRifle
|
, po [REPEATER,SPRING,HARDWARE] autoRifle
|
||||||
, po [AUTORIFLE,MICROCHIP,MAGNET] bezierGun
|
|
||||||
, po [REPEATER,SPRING,CAN] burstRifle
|
, po [REPEATER,SPRING,CAN] burstRifle
|
||||||
, po [BURSTRIFLE,SPRING,HARDWARE] fastBurstRifle
|
, po [BURSTRIFLE,SPRING,HARDWARE] fastBurstRifle
|
||||||
, po [FASTBURSTRIFLE,SPRING,HARDWARE] completeBurstRifle
|
, po [FASTBURSTRIFLE,SPRING,HARDWARE] completeBurstRifle
|
||||||
@@ -120,13 +118,12 @@ moduleCombinations =
|
|||||||
)
|
)
|
||||||
, ( ModBulletTrajectory
|
, ( ModBulletTrajectory
|
||||||
, bulletWeapons
|
, bulletWeapons
|
||||||
, [amod [TELEPORTMODULE,MICROCHIP] "+TELEPORT" (itUse . useMods .:~ withPositionWallCheck (const . const mouseWorldPos))
|
, [amod [TELEPORTMODULE,MICROCHIP] "+DIRECTEDTELE" makeDirectedTele
|
||||||
,amod [TELEPORTMODULE] "+DIRECTEDTELE" makeDirectedTele
|
|
||||||
,amod [MAGNET,MICROCHIP,HARDWARE] "+MAGNETTRAJECTORY"
|
,amod [MAGNET,MICROCHIP,HARDWARE] "+MAGNETTRAJECTORY"
|
||||||
(itConsumption . aoType . amBulTraj .~ MagnetTrajectory)
|
( (itConsumption . aoType . amBulTraj .~ MagnetTrajectory) )
|
||||||
,amod [MICROCHIP,HARDWARE] "+FLECHETTETRAJECTORY"
|
,amod [MICROCHIP,HARDWARE] "+FLECHETTETRAJECTORY"
|
||||||
(itConsumption . aoType . amBulTraj .~ FlechetteTrajectory)
|
(itConsumption . aoType . amBulTraj .~ FlechetteTrajectory)
|
||||||
,amod [MAGNET,AIUNIT,HARDWARE] "+BEZIERTRAJECTORY"
|
,amod [ANTIMATTER,HARDWARE] "+BEZIERTRAJECTORY"
|
||||||
(itConsumption . aoType . amBulTraj .~ BezierTrajectory)
|
(itConsumption . aoType . amBulTraj .~ BezierTrajectory)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ data CombineType
|
|||||||
| PRISM
|
| PRISM
|
||||||
| LIGHTER
|
| LIGHTER
|
||||||
| MAGNET
|
| MAGNET
|
||||||
|
| ANTIMATTER
|
||||||
| PLATE
|
| PLATE
|
||||||
| MICROCHIP
|
| MICROCHIP
|
||||||
| AIUNIT
|
| AIUNIT
|
||||||
|
|||||||
@@ -197,7 +197,6 @@ stackedInventory = IM.fromList $ zip [0..]
|
|||||||
,teslaGun
|
,teslaGun
|
||||||
,blinkGun
|
,blinkGun
|
||||||
,miniGunX 3
|
,miniGunX 3
|
||||||
,bezierGun
|
|
||||||
-- ,multGun
|
-- ,multGun
|
||||||
,boosterGun
|
,boosterGun
|
||||||
,remoteLauncher
|
,remoteLauncher
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ module Dodge.Item.Weapon
|
|||||||
, module Dodge.Item.Weapon.SprayGuns
|
, module Dodge.Item.Weapon.SprayGuns
|
||||||
, module Dodge.Item.Weapon.BatteryGuns
|
, module Dodge.Item.Weapon.BatteryGuns
|
||||||
, module Dodge.Item.Weapon.Launcher
|
, module Dodge.Item.Weapon.Launcher
|
||||||
, module Dodge.Item.Weapon.Bezier
|
|
||||||
) where
|
) where
|
||||||
import Dodge.Item.Weapon.BulletGuns
|
import Dodge.Item.Weapon.BulletGuns
|
||||||
import Dodge.Item.Weapon.TriggerType
|
import Dodge.Item.Weapon.TriggerType
|
||||||
@@ -28,4 +27,3 @@ import Dodge.Item.Weapon.Radar
|
|||||||
import Dodge.Item.Weapon.SprayGuns
|
import Dodge.Item.Weapon.SprayGuns
|
||||||
import Dodge.Item.Weapon.BatteryGuns
|
import Dodge.Item.Weapon.BatteryGuns
|
||||||
import Dodge.Item.Weapon.Launcher
|
import Dodge.Item.Weapon.Launcher
|
||||||
import Dodge.Item.Weapon.Bezier
|
|
||||||
|
|||||||
@@ -1,31 +1,29 @@
|
|||||||
module Dodge.Item.Weapon.AmmoParams
|
module Dodge.Item.Weapon.AmmoParams
|
||||||
( useAmmoParams
|
( useAmmoParams
|
||||||
, useAmmoParamsRate
|
, ruseAmmoParamsRate
|
||||||
-- , loadedAmmo
|
|
||||||
, useAmmoParamsVelMod
|
|
||||||
, fractionLoadedAmmo
|
, fractionLoadedAmmo
|
||||||
, fractionLoadedAmmo2
|
, fractionLoadedAmmo2
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
|
import Dodge.Base
|
||||||
import Dodge.Particle.Bullet.Spawn
|
import Dodge.Particle.Bullet.Spawn
|
||||||
import Dodge.Creature.HandPos
|
import Dodge.Creature.HandPos
|
||||||
import Dodge.Item.Weapon.Targeting
|
import Dodge.Movement.Turn
|
||||||
import Dodge.Item.Weapon.Bezier
|
|
||||||
import Geometry
|
import Geometry
|
||||||
import LensHelp
|
import LensHelp
|
||||||
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
--import Control.Lens
|
--import Control.Lens
|
||||||
|
|
||||||
useAmmoParamsRate :: Int
|
ruseAmmoParamsRate :: Int
|
||||||
-> HammerType
|
-> HammerType
|
||||||
-> [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
|
-> [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
|
||||||
-> ItemUse
|
-> ItemUse
|
||||||
useAmmoParamsRate rate ht usemods = RightUse
|
ruseAmmoParamsRate rate ht usemods = RightUse
|
||||||
{ _rUse = useAmmoParams
|
{ _rUse = useAmmoParams Nothing
|
||||||
, _useDelay = FixedRate {_rateMax = rate,_rateTime = 0}
|
, _useDelay = FixedRate {_rateMax = rate,_rateTime = 0}
|
||||||
, _useMods = usemods
|
, _useMods = usemods
|
||||||
, _useHammer = ht
|
, _useHammer = ht
|
||||||
, _useAim = defaultAimParams
|
, _useAim = defaultAimParams
|
||||||
}
|
}
|
||||||
defaultAimParams :: AimParams
|
defaultAimParams :: AimParams
|
||||||
@@ -36,67 +34,37 @@ defaultAimParams = AimParams
|
|||||||
, _aimStance = OneHand
|
, _aimStance = OneHand
|
||||||
}
|
}
|
||||||
|
|
||||||
useAmmoParams :: Item -> Creature -> World -> World
|
useAmmoParams :: Maybe Float -> Item -> Creature -> World -> World
|
||||||
useAmmoParams it cr = case _amBulTraj b of
|
useAmmoParams vfact it cr w = w & particles .:~ aBulAt
|
||||||
BasicBulletTrajectory -> withVelWthHiteff
|
vfact
|
||||||
(muzvel *.* _amBulVel b)
|
thetraj -- extra update
|
||||||
(_rifling $ _itParams it)
|
Nothing -- color (default)
|
||||||
(_amBulWth b)
|
(Just cid) -- pass through creature
|
||||||
muzlength
|
sp
|
||||||
(_amBulEff b)
|
(rotateV dir (muzvel *.* _amBulVel bultype)) -- vel
|
||||||
cr
|
(_rifling $ _itParams it) -- drag
|
||||||
BezierTrajectory -> useTargetPos (\p -> shootBezier $ fromJust p) cr
|
(_amBulEff bultype)
|
||||||
FlechetteTrajectory -> undefined
|
(_amBulWth bultype)
|
||||||
MagnetTrajectory -> undefined
|
|
||||||
where
|
where
|
||||||
muzlength = aimingMuzzlePos cr it
|
sp = _crPos cr +.+ muzlength *.* unitVectorAtAngle dir
|
||||||
muzvel = _muzVel $ _itParams it
|
|
||||||
b = _aoType $ _itConsumption it
|
|
||||||
-- 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
|
|
||||||
where
|
|
||||||
b = _aoType $ _itConsumption it
|
|
||||||
-- bulHitEff = fromMaybe (destroyOnImpact bulHitCr bulHitWall)
|
|
||||||
-- $ it ^? itModules . modHitEffect . theModule
|
|
||||||
|
|
||||||
{- | Creates a bullet with a given velocity, width, and 'HitEffect' -}
|
|
||||||
withVelWthHiteff
|
|
||||||
:: Point2 -- ^ Velocity, x direction is forward with respect to the creature
|
|
||||||
-> Float -- ^ drag
|
|
||||||
-> Float -- ^ Bullet width
|
|
||||||
-> Float -- ^ Distance away from creature to create
|
|
||||||
-> HitEffect -- ^ Bullet effect when hitting creature, wall etc
|
|
||||||
-> Creature
|
|
||||||
-> World
|
|
||||||
-> World
|
|
||||||
withVelWthHiteff vel drag width muzlength hiteff cr = particles .:~ newbul
|
|
||||||
where
|
|
||||||
newbul = aGenBulAt (Just (_crID cr)) pos (rotateV dir vel) drag hiteff width
|
|
||||||
pos = _crPos cr +.+ muzlength *.* unitVectorAtAngle dir
|
|
||||||
dir = _crDir cr
|
|
||||||
|
|
||||||
{- | Creates a bullet with a given velocity, width, and 'HitEffect' -}
|
|
||||||
withDelayedVelWthHiteff
|
|
||||||
:: Float -- ^ Velocity factor for first step
|
|
||||||
-> Point2 -- ^ Velocity, x direction is forward with respect to the creature
|
|
||||||
-> Float -- ^ Drag
|
|
||||||
-> Float -- ^ Bullet width
|
|
||||||
-> HitEffect -- ^ Bullet effect when hitting creature, wall etc
|
|
||||||
-> Creature -- ^ Creature id
|
|
||||||
-> World
|
|
||||||
-> World
|
|
||||||
withDelayedVelWthHiteff vfact vel drag width hiteff cr = particles .:~ newbul
|
|
||||||
where
|
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
newbul = aDelayedBulAt vfact (Just cid) pos (rotateV dir vel) drag hiteff width
|
|
||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
pos = _crPos cr +.+ _crRad cr *.* unitVectorAtAngle (_crDir cr)
|
bultype = _aoType $ _itConsumption it
|
||||||
|
muzvel = _muzVel $ _itParams it
|
||||||
|
muzlength = aimingMuzzlePos cr it
|
||||||
|
thetraj = case _amBulTraj bultype of
|
||||||
|
BasicBulletTrajectory -> id
|
||||||
|
MagnetTrajectory -> fromMaybe id $ do
|
||||||
|
tpos <- it ^? itTargeting . tgPos . _Just
|
||||||
|
return $ \pt -> pt & ptVel .+.+~ 5 *.* normalizeV (tpos -.- head (_ptTrail pt))
|
||||||
|
FlechetteTrajectory -> fromMaybe id $ do
|
||||||
|
tpos <- it ^? itTargeting . tgPos . _Just
|
||||||
|
return $ \pt -> pt & ptVel %~ vecTurnTo 0.1 (head $ _ptTrail pt) tpos
|
||||||
|
BezierTrajectory -> fromMaybe id $ do
|
||||||
|
tpos <- it ^? itTargeting . tgPos . _Just
|
||||||
|
let bf t = bQuadToF (sp,mouseWorldPos w,tpos) $ (100 - t) * 0.05
|
||||||
|
return $ \pt -> pt
|
||||||
|
& ptVel .~ bf (fromIntegral $ _ptTimer pt - 1) -.- bf (fromIntegral $ _ptTimer pt)
|
||||||
|
|
||||||
-- this shouldn't really be used
|
-- this shouldn't really be used
|
||||||
loadedAmmo :: Item -> Int
|
loadedAmmo :: Item -> Int
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
module Dodge.Item.Weapon.Bezier
|
|
||||||
( bezierGun
|
|
||||||
, shootBezier
|
|
||||||
) where
|
|
||||||
import Dodge.Data
|
|
||||||
import Dodge.Base
|
|
||||||
import Dodge.Default.Weapon
|
|
||||||
import Dodge.Item.Weapon.Targeting
|
|
||||||
--import Dodge.Item.Weapon.BulletGuns
|
|
||||||
import Dodge.Item.Weapon.TriggerType
|
|
||||||
import Dodge.Item.Weapon.ExtraEffect
|
|
||||||
--import Dodge.Default
|
|
||||||
import Dodge.Particle.Bullet.Spawn
|
|
||||||
import Dodge.Particle.Bullet.HitEffect
|
|
||||||
import Dodge.WorldEvent.HitEffect
|
|
||||||
import Dodge.RandomHelp
|
|
||||||
import Dodge.SoundLogic.LoadSound
|
|
||||||
import Geometry
|
|
||||||
--import ShapePicture
|
|
||||||
import LensHelp
|
|
||||||
|
|
||||||
import Data.Maybe
|
|
||||||
import Control.Monad.State
|
|
||||||
bezierGun :: Item
|
|
||||||
bezierGun = defaultGun
|
|
||||||
{ _itName = "BEZIERGUN"
|
|
||||||
, _itUse = ruseRate 6 (\_ -> useTargetPos $ \p -> shootBezier $ fromJust p) -- <- the start point
|
|
||||||
NoHammer
|
|
||||||
[ ammoCheckI
|
|
||||||
, useTimeCheck
|
|
||||||
, withSoundStart tap2S
|
|
||||||
, useAmmoAmount 1
|
|
||||||
, withMuzFlareI
|
|
||||||
. withRecoilI 40
|
|
||||||
. torqueBefore 0.05
|
|
||||||
]
|
|
||||||
& useAim . aimSpeed .~ 0.4
|
|
||||||
& useAim . aimRange .~ 0
|
|
||||||
& useAim . aimStance .~ TwoHandTwist
|
|
||||||
-- & useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
|
|
||||||
-- , _itFloorPict = bezierGunSPic
|
|
||||||
, _itAttachment = NoItAttachment
|
|
||||||
, _itScroll = \_ _ -> removeItTarget
|
|
||||||
-- , _itEffect = rbSetTarget
|
|
||||||
-- , _itZoom = defaultItZoom
|
|
||||||
, _itConsumption = defaultAmmo
|
|
||||||
{ _ammoBaseMax = 15
|
|
||||||
}
|
|
||||||
, _itTargeting = targetRBPress
|
|
||||||
}
|
|
||||||
shootBezier :: Point2 -> Creature -> World -> World
|
|
||||||
shootBezier targetp cr w = w & particles .:~ aCurveBulAt
|
|
||||||
(Just cid)
|
|
||||||
(V4 200 200 200 1)
|
|
||||||
startp
|
|
||||||
(controlp +.+ randPos)
|
|
||||||
(targetp +.+ randPos')
|
|
||||||
(destroyOnImpact bulHitCr bulHitWall)
|
|
||||||
5
|
|
||||||
where
|
|
||||||
controlp = mouseWorldPos w
|
|
||||||
cid = _crID cr
|
|
||||||
dir = _crDir cr
|
|
||||||
startp = _crPos cr +.+ rotateV dir (V2 (_crRad cr + 1) 0)
|
|
||||||
(randPos,randPos') = flip evalState (_randGen w) $ do
|
|
||||||
a <- randInCirc 10
|
|
||||||
b <- randInCirc 20
|
|
||||||
return (a,b)
|
|
||||||
@@ -58,7 +58,7 @@ bangCane = defaultGun
|
|||||||
, _reloadTime = 20
|
, _reloadTime = 20
|
||||||
, _reloadType = ActivePartial 1
|
, _reloadType = ActivePartial 1
|
||||||
}
|
}
|
||||||
, _itUse = useAmmoParamsRate 6 upHammer
|
, _itUse = ruseAmmoParamsRate 6 upHammer
|
||||||
[ ammoHammerCheck
|
[ ammoHammerCheck
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
, withSoundStart tap3S
|
, withSoundStart tap3S
|
||||||
@@ -88,7 +88,7 @@ bangCaneX :: Int -> Item
|
|||||||
bangCaneX i = bangCane
|
bangCaneX i = bangCane
|
||||||
{ _itName = "BANGCANEx"++show i
|
{ _itName = "BANGCANEx"++show i
|
||||||
, _itType = BANGCANEX i
|
, _itType = BANGCANEX i
|
||||||
, _itUse = useAmmoParamsRate 6 upHammer
|
, _itUse = ruseAmmoParamsRate 6 upHammer
|
||||||
[ ammoHammerCheck
|
[ ammoHammerCheck
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
, withSoundItemChoiceStart caneStickSoundChoice
|
, withSoundItemChoiceStart caneStickSoundChoice
|
||||||
@@ -233,7 +233,7 @@ completeBurstRifle = repeater
|
|||||||
, withRecoilI 50
|
, withRecoilI 50
|
||||||
]
|
]
|
||||||
miniGunUse :: Int -> ItemUse
|
miniGunUse :: Int -> ItemUse
|
||||||
miniGunUse i = ruseInstant (useAmmoParamsVelMod 1) NoHammer $
|
miniGunUse i = ruseInstant (useAmmoParams $ Just 1) NoHammer $
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, withWarmUp crankSlowS
|
, withWarmUp crankSlowS
|
||||||
, withSoundForI mini1S 2
|
, withSoundForI mini1S 2
|
||||||
@@ -248,7 +248,7 @@ miniGunUse i = ruseInstant (useAmmoParamsVelMod 1) NoHammer $
|
|||||||
, afterRecoil recoilAmount
|
, afterRecoil recoilAmount
|
||||||
, withRandomOffsetI 10
|
, withRandomOffsetI 10
|
||||||
, withOldDir x
|
, withOldDir x
|
||||||
, trigDoAlso (useAmmoParamsVelMod x)
|
, trigDoAlso (useAmmoParams $ Just x)
|
||||||
] | x <- map ((/fromIntegral i) . fromIntegral) [1..i-1]
|
] | x <- map ((/fromIntegral i) . fromIntegral) [1..i-1]
|
||||||
]
|
]
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ bangRod = defaultGun
|
|||||||
, _bore = 2
|
, _bore = 2
|
||||||
, _gunBarrels = SingleBarrel 0.1
|
, _gunBarrels = SingleBarrel 0.1
|
||||||
}
|
}
|
||||||
, _itUse = useAmmoParamsRate 6 upHammer
|
, _itUse = ruseAmmoParamsRate 6 upHammer
|
||||||
[ ammoHammerCheck
|
[ ammoHammerCheck
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
, withSoundStart autoGunS
|
, withSoundStart autoGunS
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ bangStick i = defaultGun
|
|||||||
, _reloadTime = 15
|
, _reloadTime = 15
|
||||||
, _reloadType = ActivePartial 1
|
, _reloadType = ActivePartial 1
|
||||||
}
|
}
|
||||||
, _itUse = useAmmoParamsRate 8 upHammer
|
, _itUse = ruseAmmoParamsRate 8 upHammer
|
||||||
[ ammoHammerCheck
|
[ ammoHammerCheck
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
, withSoundItemChoiceStart bangStickSoundChoice
|
, withSoundItemChoiceStart bangStickSoundChoice
|
||||||
@@ -178,7 +178,7 @@ pistol = (bangStick 1)
|
|||||||
, _reloadTime = 70
|
, _reloadTime = 70
|
||||||
, _reloadType = ActiveClear
|
, _reloadType = ActiveClear
|
||||||
}
|
}
|
||||||
, _itUse = useAmmoParamsRate 6 upHammer
|
, _itUse = ruseAmmoParamsRate 6 upHammer
|
||||||
(ammoHammerCheck : pistolAfterHamMods)
|
(ammoHammerCheck : pistolAfterHamMods)
|
||||||
-- , _itZoom = defaultItZoom
|
-- , _itZoom = defaultItZoom
|
||||||
-- , _itEquipPict = pictureWeaponAim pistolPic
|
-- , _itEquipPict = pictureWeaponAim pistolPic
|
||||||
@@ -218,7 +218,7 @@ revolverX :: Int -> Item
|
|||||||
revolverX i = revolver
|
revolverX i = revolver
|
||||||
{ _itName = "REVx"++show i
|
{ _itName = "REVx"++show i
|
||||||
, _itType = REVOLVERX i
|
, _itType = REVOLVERX i
|
||||||
, _itUse = useAmmoParamsRate 8 upHammer
|
, _itUse = ruseAmmoParamsRate 8 upHammer
|
||||||
[ ammoHammerCheck
|
[ ammoHammerCheck
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
-- rather than locking the inventory, a better solution may be to check
|
-- rather than locking the inventory, a better solution may be to check
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ autoGun = defaultAutoGun
|
|||||||
, _ammoLoaded = 30
|
, _ammoLoaded = 30
|
||||||
, _reloadTime = 80
|
, _reloadTime = 80
|
||||||
}
|
}
|
||||||
, _itUse = useAmmoParamsRate 4 NoHammer
|
, _itUse = ruseAmmoParamsRate 4 NoHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, charFiringStratI
|
, charFiringStratI
|
||||||
[('S', hammerCheckI)
|
[('S', hammerCheckI)
|
||||||
@@ -113,7 +113,7 @@ bangCone = defaultGun
|
|||||||
, _reloadTime = 25
|
, _reloadTime = 25
|
||||||
, _reloadType = ActiveClear
|
, _reloadType = ActiveClear
|
||||||
}
|
}
|
||||||
, _itUse = useAmmoParamsRate 20 upHammer
|
, _itUse = ruseAmmoParamsRate 20 upHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, hammerCheckI
|
, hammerCheckI
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
@@ -166,7 +166,7 @@ blunderbuss :: Item
|
|||||||
blunderbuss = bangCone
|
blunderbuss = bangCone
|
||||||
{_itName = "BLUNDERBUSS"
|
{_itName = "BLUNDERBUSS"
|
||||||
,_itType = BLUNDERBUSS
|
,_itType = BLUNDERBUSS
|
||||||
,_itUse = useAmmoParamsRate 20 upHammer
|
,_itUse = ruseAmmoParamsRate 20 upHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, hammerCheckI
|
, hammerCheckI
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
@@ -200,7 +200,7 @@ bigBlunderbuss :: Item
|
|||||||
bigBlunderbuss = blunderbuss
|
bigBlunderbuss = blunderbuss
|
||||||
{_itName = "BIGBLUNDERBUSS"
|
{_itName = "BIGBLUNDERBUSS"
|
||||||
,_itType = BIGBLUNDERBUSS
|
,_itType = BIGBLUNDERBUSS
|
||||||
,_itUse = useAmmoParamsRate 20 upHammer
|
,_itUse = ruseAmmoParamsRate 20 upHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, hammerCheckI
|
, hammerCheckI
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
@@ -224,7 +224,7 @@ biggerBlunderbuss :: Item
|
|||||||
biggerBlunderbuss = bigBlunderbuss
|
biggerBlunderbuss = bigBlunderbuss
|
||||||
{_itName = "BIGGERBLUNDERBUSS"
|
{_itName = "BIGGERBLUNDERBUSS"
|
||||||
,_itType = BIGGERBLUNDERBUSS
|
,_itType = BIGGERBLUNDERBUSS
|
||||||
,_itUse = useAmmoParamsRate 20 upHammer
|
,_itUse = ruseAmmoParamsRate 20 upHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, hammerCheckI
|
, hammerCheckI
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
@@ -248,7 +248,7 @@ biggestBlunderbuss :: Item
|
|||||||
biggestBlunderbuss = biggerBlunderbuss
|
biggestBlunderbuss = biggerBlunderbuss
|
||||||
{_itName = "BIGGESTBLUNDERBUSS"
|
{_itName = "BIGGESTBLUNDERBUSS"
|
||||||
,_itType = BIGGESTBLUNDERBUSS
|
,_itType = BIGGESTBLUNDERBUSS
|
||||||
,_itUse = useAmmoParamsRate 20 upHammer
|
,_itUse = ruseAmmoParamsRate 20 upHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, hammerCheckI
|
, hammerCheckI
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
@@ -273,7 +273,7 @@ grapeShotCannon :: Item
|
|||||||
grapeShotCannon = blunderbuss
|
grapeShotCannon = blunderbuss
|
||||||
{_itName = "GRAPESHOTCANNON"
|
{_itName = "GRAPESHOTCANNON"
|
||||||
,_itType = GRAPESHOTCANNON
|
,_itType = GRAPESHOTCANNON
|
||||||
,_itUse = useAmmoParamsRate 20 upHammer
|
,_itUse = ruseAmmoParamsRate 20 upHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, hammerCheckI
|
, hammerCheckI
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
@@ -309,7 +309,7 @@ hvAutoGun = defaultAutoGun
|
|||||||
, _ammoLoaded = 100
|
, _ammoLoaded = 100
|
||||||
, _reloadTime = 200
|
, _reloadTime = 200
|
||||||
}
|
}
|
||||||
, _itUse = useAmmoParamsRate 25 NoHammer
|
, _itUse = ruseAmmoParamsRate 25 NoHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, rateIncAB (torqueBeforeAtLeast 0.1 0.1) (torqueAfterI 0.2)
|
, rateIncAB (torqueBeforeAtLeast 0.1 0.1) (torqueAfterI 0.2)
|
||||||
, withSoundStart bangEchoS
|
, withSoundStart bangEchoS
|
||||||
@@ -338,7 +338,7 @@ ltAutoGun = defaultAutoGun
|
|||||||
, _ammoLoaded = 0
|
, _ammoLoaded = 0
|
||||||
, _reloadTime = 90
|
, _reloadTime = 90
|
||||||
}
|
}
|
||||||
, _itUse = useAmmoParamsRate 2 NoHammer
|
, _itUse = ruseAmmoParamsRate 2 NoHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
, withSoundStart tap1S
|
, withSoundStart tap1S
|
||||||
@@ -367,7 +367,7 @@ spreadGun = defaultGun
|
|||||||
, _ammoLoaded = 5
|
, _ammoLoaded = 5
|
||||||
, _reloadTime = 80
|
, _reloadTime = 80
|
||||||
}
|
}
|
||||||
, _itUse = useAmmoParamsRate 20 upHammer
|
, _itUse = ruseAmmoParamsRate 20 upHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, hammerCheckI
|
, hammerCheckI
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
@@ -401,7 +401,7 @@ multGun = defaultGun
|
|||||||
, _reloadTime = 10
|
, _reloadTime = 10
|
||||||
, _reloadType = ActivePartial 1
|
, _reloadType = ActivePartial 1
|
||||||
}
|
}
|
||||||
, _itUse = useAmmoParamsRate 20 upHammer
|
, _itUse = ruseAmmoParamsRate 20 upHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, hammerCheckI
|
, hammerCheckI
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
@@ -439,7 +439,7 @@ longGun = defaultGun
|
|||||||
, _reloadTime = 100
|
, _reloadTime = 100
|
||||||
, _reloadType = PassiveReload skwareFadeTwoSecS
|
, _reloadType = PassiveReload skwareFadeTwoSecS
|
||||||
}
|
}
|
||||||
, _itUse = useAmmoParamsRate 100 upHammer
|
, _itUse = ruseAmmoParamsRate 100 upHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, hammerCheckI
|
, hammerCheckI
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ turnTo turnSpeed sp tp a
|
|||||||
vecTurnTo :: Float -> Point2 -> Point2 -> Point2 -> Point2
|
vecTurnTo :: Float -> Point2 -> Point2 -> Point2 -> Point2
|
||||||
vecTurnTo turnSpeed sp tp vdir
|
vecTurnTo turnSpeed sp tp vdir
|
||||||
| angleVV vToTarg vdir <= turnSpeed
|
| angleVV vToTarg vdir <= turnSpeed
|
||||||
= argV vdir *.* normalizeV vToTarg
|
= magV vdir *.* normalizeV vToTarg
|
||||||
| isLHS (sp +.+ vdir) sp tp = rotateV (negate turnSpeed) vdir
|
| isLHS (sp +.+ vdir) sp tp = rotateV (negate turnSpeed) vdir
|
||||||
| otherwise = rotateV turnSpeed vdir
|
| otherwise = rotateV turnSpeed vdir
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ bulBounceArmCr' bt p cr w
|
|||||||
pOut = p +.+ 2 *.* newDir
|
pOut = p +.+ 2 *.* newDir
|
||||||
reflectVel = magV bulVel *.* newDir
|
reflectVel = magV bulVel *.* newDir
|
||||||
addBouncer = instantParticles .:~ bouncer
|
addBouncer = instantParticles .:~ bouncer
|
||||||
bouncer = (aGenBulAt Nothing pOut reflectVel (_btDrag bt)
|
bouncer = (aBulAt Nothing id (Just (_ptColor bt)) Nothing pOut reflectVel (_btDrag bt)
|
||||||
(_ptHitEff bt) (_ptWidth bt)
|
(_ptHitEff bt) (_ptWidth bt)
|
||||||
) {_ptTimer = _ptTimer bt - 1}
|
) {_ptTimer = _ptTimer bt - 1}
|
||||||
{- | Bullet pass through creatures. -}
|
{- | Bullet pass through creatures. -}
|
||||||
@@ -70,7 +70,7 @@ bulPenCr' bt p cr w = w
|
|||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
sp = head $ _ptTrail bt
|
sp = head $ _ptTrail bt
|
||||||
ep = sp +.+ _ptVel bt
|
ep = sp +.+ _ptVel bt
|
||||||
piercer = (aGenBulAt (Just cid) p (_ptVel bt) (_btDrag bt)
|
piercer = (aBulAt Nothing id (Just (_ptColor bt)) (Just cid) p (_ptVel bt) (_btDrag bt)
|
||||||
(_ptHitEff bt) (_ptWidth bt)
|
(_ptHitEff bt) (_ptWidth bt)
|
||||||
) {_ptTimer = _ptTimer bt - 1}
|
) {_ptTimer = _ptTimer bt - 1}
|
||||||
{- | Heavy bullet effects when hitting creature:
|
{- | Heavy bullet effects when hitting creature:
|
||||||
@@ -123,7 +123,7 @@ bulBounceWall bt p wl = damageWall (Blunt 50 sp p ep) wl
|
|||||||
ep = sp +.+ _ptVel bt
|
ep = sp +.+ _ptVel bt
|
||||||
sp = head $ _ptTrail bt
|
sp = head $ _ptTrail bt
|
||||||
pOut = p +.+ squashNormalizeV (sp -.- p)
|
pOut = p +.+ squashNormalizeV (sp -.- p)
|
||||||
bouncer = (aGenBulAt Nothing pOut reflectVel (_btDrag bt) (_ptHitEff bt) (_ptWidth bt)
|
bouncer = (aBulAt Nothing id (Just (_ptColor bt)) Nothing pOut reflectVel (_btDrag bt) (_ptHitEff bt) (_ptWidth bt)
|
||||||
) {_ptTimer = _ptTimer bt - 1}
|
) {_ptTimer = _ptTimer bt - 1}
|
||||||
reflectVel = reflVelWall wl (_ptVel bt)
|
reflectVel = reflVelWall wl (_ptVel bt)
|
||||||
-- the hack is to get around the fact that the particles list gets reset after
|
-- the hack is to get around the fact that the particles list gets reset after
|
||||||
|
|||||||
@@ -1,41 +1,20 @@
|
|||||||
module Dodge.Particle.Bullet.Spawn
|
module Dodge.Particle.Bullet.Spawn
|
||||||
( aGenBulAt
|
( aBulAt
|
||||||
, aDelayedBulAt
|
|
||||||
, aCurveBulAt
|
|
||||||
, accelBulAt
|
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Particle.Bullet.Draw
|
import Dodge.Particle.Bullet.Draw
|
||||||
import Dodge.Particle.Bullet.Update
|
import Dodge.Particle.Bullet.Update
|
||||||
import Dodge.Movement.Turn
|
|
||||||
import Geometry
|
import Geometry
|
||||||
import Picture
|
import Picture
|
||||||
import LensHelp
|
import LensHelp
|
||||||
|
|
||||||
|
import Data.Maybe
|
||||||
import Data.Bifunctor
|
import Data.Bifunctor
|
||||||
|
|
||||||
aGenBulAt
|
aBulAt
|
||||||
:: Maybe Int -- ^ Pass-through creature id
|
:: Maybe Float -- ^ Start velocity step factor
|
||||||
-> Point2 -- ^ Start position
|
-> (Particle -> Particle)
|
||||||
-> Point2 -- ^ Velocity
|
-> Maybe Color
|
||||||
-> Float -- ^ Slowdown
|
|
||||||
-> HitEffect
|
|
||||||
-> Float -- ^ Bullet width
|
|
||||||
-> Particle
|
|
||||||
aGenBulAt maycid pos vel drag hiteff width = BulletPt
|
|
||||||
{ _ptDraw = drawBul
|
|
||||||
, _ptUpdate = mvBullet
|
|
||||||
, _ptVel = vel
|
|
||||||
, _btDrag = drag
|
|
||||||
, _ptColor = V4 2 2 2 2
|
|
||||||
, _ptTrail = [pos]
|
|
||||||
, _ptCrIgnore = maycid
|
|
||||||
, _ptWidth = width
|
|
||||||
, _ptTimer = 100
|
|
||||||
, _ptHitEff = hiteff
|
|
||||||
}
|
|
||||||
aDelayedBulAt
|
|
||||||
:: Float -- ^ Start velocity step factor
|
|
||||||
-> Maybe Int -- ^ Pass-through creature id
|
-> Maybe Int -- ^ Pass-through creature id
|
||||||
-> Point2 -- ^ Start position
|
-> Point2 -- ^ Start position
|
||||||
-> Point2 -- ^ Velocity
|
-> Point2 -- ^ Velocity
|
||||||
@@ -43,12 +22,13 @@ aDelayedBulAt
|
|||||||
-> HitEffect
|
-> HitEffect
|
||||||
-> Float -- ^ Bullet width
|
-> Float -- ^ Bullet width
|
||||||
-> Particle
|
-> Particle
|
||||||
aDelayedBulAt vfact maycid pos vel drag hiteff width = BulletPt
|
aBulAt vfact updatemod mcol maycid pos vel drag hiteff width = BulletPt
|
||||||
{ _ptDraw = drawBul
|
{ _ptDraw = drawBul
|
||||||
, _ptUpdate = \w -> resetVel . mvBullet w
|
, _ptUpdate = theupdate
|
||||||
, _ptVel = vfact *.* vel
|
, _ptVel = fromMaybe 1 vfact *.* vel
|
||||||
, _btDrag = drag
|
, _btDrag = drag
|
||||||
, _ptColor = V4 2 2 2 2
|
, _ptColor = fromMaybe (V4 200 200 200 2) mcol
|
||||||
|
-- , _ptColor = V4 2 2 2 2
|
||||||
, _ptTrail = [pos]
|
, _ptTrail = [pos]
|
||||||
, _ptCrIgnore = maycid
|
, _ptCrIgnore = maycid
|
||||||
, _ptWidth = width
|
, _ptWidth = width
|
||||||
@@ -56,78 +36,7 @@ aDelayedBulAt vfact maycid pos vel drag hiteff width = BulletPt
|
|||||||
, _ptHitEff = hiteff
|
, _ptHitEff = hiteff
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
resetVel = second $ fmap $ (ptUpdate .~ mvBullet) . (ptVel .~ vel)
|
theupdate = case vfact of
|
||||||
|
Just _ -> \w -> resetVel . mvBullet w . updatemod
|
||||||
aCurveBulAt
|
Nothing -> \w -> mvBullet w . updatemod
|
||||||
:: Maybe Int -- ^ Pass-through creature id
|
resetVel = second $ fmap $ (ptUpdate .~ (\w -> mvBullet w . updatemod)) . (ptVel .~ vel)
|
||||||
-> Color
|
|
||||||
-> Point2 -- ^ Start position
|
|
||||||
-> Point2 -- ^ Control position
|
|
||||||
-> Point2 -- ^ Target position
|
|
||||||
-> HitEffect
|
|
||||||
-> Float -- ^ Bullet width
|
|
||||||
-> Particle
|
|
||||||
aCurveBulAt maycid col pos control targ hiteff width = BulletPt
|
|
||||||
{ _ptDraw = drawBul
|
|
||||||
, _ptUpdate = \w -> mvBullet w . setVel
|
|
||||||
, _ptVel = V2 0 0
|
|
||||||
, _btDrag = 1
|
|
||||||
, _ptColor = col
|
|
||||||
, _ptTrail = [pos]
|
|
||||||
, _ptCrIgnore = maycid
|
|
||||||
, _ptWidth = width
|
|
||||||
, _ptTimer = 100
|
|
||||||
, _ptHitEff = hiteff
|
|
||||||
}
|
|
||||||
where
|
|
||||||
setVel pt = pt & ptVel .~ bf (fromIntegral $ _ptTimer pt - 1) -.- bf (fromIntegral $ _ptTimer pt)
|
|
||||||
bf t = bQuadToF (pos,control,targ) $ (100 - t) * 0.05
|
|
||||||
|
|
||||||
accelBulAt
|
|
||||||
:: Maybe Int -- ^ Pass-through creature id
|
|
||||||
-> Color
|
|
||||||
-> Point2 -- ^ Start position
|
|
||||||
-> Point2 -- ^ Velocity
|
|
||||||
-> Point2 -- ^ Acceleration
|
|
||||||
-> HitEffect
|
|
||||||
-> Float -- ^ Bullet width
|
|
||||||
-> Particle
|
|
||||||
accelBulAt maycid col pos vel acc hiteff width = BulletPt
|
|
||||||
{ _ptDraw = drawBul
|
|
||||||
, _ptUpdate = \w -> mvBullet w . setVel
|
|
||||||
, _ptVel = vel
|
|
||||||
, _btDrag = 1
|
|
||||||
, _ptColor = col
|
|
||||||
, _ptTrail = [pos]
|
|
||||||
, _ptCrIgnore = maycid
|
|
||||||
, _ptWidth = width
|
|
||||||
, _ptTimer = 100
|
|
||||||
, _ptHitEff = hiteff
|
|
||||||
}
|
|
||||||
where
|
|
||||||
setVel pt = pt & ptVel .+.+~ acc
|
|
||||||
|
|
||||||
turnBulAt
|
|
||||||
:: Maybe Int -- ^ Pass-through creature id
|
|
||||||
-> Color
|
|
||||||
-> Point2 -- ^ Start position
|
|
||||||
-> Point2 -- ^ Velocity
|
|
||||||
-> Point2 -- ^ Acceleration
|
|
||||||
-> HitEffect
|
|
||||||
-> Float -- ^ Bullet width
|
|
||||||
-> Point2 -- ^ Target position
|
|
||||||
-> Particle
|
|
||||||
turnBulAt maycid col pos vel acc hiteff width tpos = BulletPt
|
|
||||||
{ _ptDraw = drawBul
|
|
||||||
, _ptUpdate = \w -> mvBullet w . setVel
|
|
||||||
, _ptVel = vel
|
|
||||||
, _btDrag = 1
|
|
||||||
, _ptColor = col
|
|
||||||
, _ptTrail = [pos]
|
|
||||||
, _ptCrIgnore = maycid
|
|
||||||
, _ptWidth = width
|
|
||||||
, _ptTimer = 100
|
|
||||||
, _ptHitEff = hiteff
|
|
||||||
}
|
|
||||||
where
|
|
||||||
setVel pt = pt & ptVel %~ vecTurnTo 0.1 (head $ _ptTrail pt) tpos
|
|
||||||
|
|||||||
Reference in New Issue
Block a user