Implement teleporting bullets
This commit is contained in:
@@ -429,6 +429,8 @@ cartePosToScreen cfig w = doWindowScale cfig . doRotate . doZoom . doTranslate
|
||||
doTranslate p = p -.- _carteCenter w
|
||||
doZoom p = _carteZoom w *.* p
|
||||
doRotate p = rotateV (negate $ _carteRot w) p
|
||||
crToMousePosOffset :: Creature -> World -> (Point2,Float)
|
||||
crToMousePosOffset cr w = (mouseWorldPos w -.- _crPos cr,0)
|
||||
{- | The mouse position in world coordinates. -}
|
||||
mouseWorldPos :: World -> Point2
|
||||
mouseWorldPos w = _cameraCenter w +.+ (1/_cameraZoom w) *.* rotateV (_cameraRot w) (_mousePos w)
|
||||
|
||||
@@ -23,7 +23,7 @@ import qualified FoldlHelp as L
|
||||
|
||||
hasLOS :: Point2 -> Point2 -> World -> Bool
|
||||
{-# INLINE hasLOS #-}
|
||||
hasLOS p1 p2 w = not $ pointHitsWalls p1 p2 $ wallsAlongLine p1 p2 w
|
||||
hasLOS p1 p2 = not . pointHitsWalls p1 p2 . wallsAlongLine p1 p2
|
||||
|
||||
--hitPointLines
|
||||
-- :: Point2
|
||||
|
||||
+44
-23
@@ -21,6 +21,7 @@ import Data.Bifunctor
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
--import qualified Data.IntSet as IS
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Map.Merge.Strict
|
||||
import Data.Maybe
|
||||
import Data.List (scanl',sortOn)
|
||||
|
||||
@@ -34,21 +35,25 @@ combinationsTrie = foldr
|
||||
-- trie going through each combine type in your inventory in order, rather than
|
||||
-- creating all multisets of combine types.
|
||||
|
||||
lookupItems :: [(ItemModules,CombineType,Int,Int)] -> [ ([(ItemModules,Int)],Item) ]
|
||||
lookupItems :: [(M.Map ModuleSlot ItemModule,CombineType,Int,Int)]
|
||||
-> [ ([(M.Map ModuleSlot ItemModule,Int)],Item) ]
|
||||
lookupItems xs = lookupItemsUsingTrie (sortOn (\(_,ct,_,_) -> ct) xs) combinationsTrie
|
||||
|
||||
lookupItemsUsingTrie :: [(ItemModules,CombineType,Int,Int)]
|
||||
-> Trie (Int,CombineType) Item -> [ ([(ItemModules,Int)],Item) ]
|
||||
lookupItemsUsingTrie :: [(M.Map ModuleSlot ItemModule,CombineType,Int,Int)]
|
||||
-> Trie (Int,CombineType) Item
|
||||
-> [ ([(M.Map ModuleSlot ItemModule,Int)],Item) ]
|
||||
lookupItemsUsingTrie [] t = maybeToList $ ([],) <$> _trieMVal t
|
||||
lookupItemsUsingTrie ((mods,ct,i,n):xs) t = do
|
||||
n' <- [1..min n 4]
|
||||
let is = replicate n' (mods,i)
|
||||
concatMap (map (first (is ++)) . lookupItemsUsingTrie xs) $ maybeToList (_trieChildren t M.!? (n',ct))
|
||||
|
||||
invertListInvMult :: IM.IntMap Item -> [[(ItemModules,CombineType,Int,Int)]]
|
||||
invertListInvMult :: IM.IntMap Item
|
||||
-> [[(M.Map ModuleSlot ItemModule,CombineType,Int,Int)]]
|
||||
invertListInvMult = powlistUpToN 4 . invertListInv
|
||||
|
||||
invertListInv :: IM.IntMap Item -> [(ItemModules,CombineType,Int,Int)]
|
||||
invertListInv :: IM.IntMap Item
|
||||
-> [(M.Map ModuleSlot ItemModule,CombineType,Int,Int)]
|
||||
invertListInv = IM.foldrWithKey
|
||||
(\k it -> ((_itModules it,_itType it, k, itStackAmount it) :) )
|
||||
[]
|
||||
@@ -60,29 +65,45 @@ combineItemListYou :: World -> [([Int],Item)]
|
||||
combineItemListYou = map (second fst) . combineItemListYou'
|
||||
|
||||
combineItemListYou' :: World -> [([Int],(Item,[String]))]
|
||||
combineItemListYou' = concatMap addModules . concatMap lookupItems . invertListInvMult . yourInv
|
||||
combineItemListYou' = map addModules . concatMap lookupItems . invertListInvMult . yourInv
|
||||
|
||||
addModules :: ([(ItemModules,Int)],Item) -> [([Int],(Item,[String]))]
|
||||
addModules (ps,it) = (is , ) <$> [ (it & itModules .~ themodules,s) | (themodules,s) <- combinedmodules]
|
||||
addModules :: ([(M.Map ModuleSlot ItemModule,Int)],Item)
|
||||
-> ([Int],(Item,[String]))
|
||||
addModules (ps,it) = (is , (applyModules newm it, ss))
|
||||
where
|
||||
(ms,is) = unzip ps
|
||||
combinedmodules = foldr f [(_itModules it,[])] ms
|
||||
f :: ItemModules -> [(ItemModules,[String])] -> [(ItemModules,[String])]
|
||||
f ims imss = concatMap (g ims) imss
|
||||
g ims (ims',s) = map (second (s++)) $ combineModules ims ims'
|
||||
m = ([],_itModules it)
|
||||
(ss,newm) = foldr f m ms
|
||||
f m' (s,m'') = (s ++ s',m''')
|
||||
where
|
||||
(s',m''') = combineModules m' m''
|
||||
|
||||
combineModules :: ItemModules -> ItemModules -> [(ItemModules,[String])]
|
||||
combineModules (ItemModules a1 b1) (ItemModules a2 b2)
|
||||
= [(ItemModules a b,as++bs) | (a,as) <- combineModule a1 a2
|
||||
, (b,bs) <- combineModule b1 b2]
|
||||
applyModules :: M.Map ModuleSlot ItemModule -> Item -> Item
|
||||
applyModules ms it = foldr f (it & itModules .~ ms) ms
|
||||
where
|
||||
f m = fromMaybe id (m ^? modModification)
|
||||
-- (is , ) <$> [ (it & itModules .~ themodules,s) | (themodules,s) <- combinedmodules]
|
||||
-- where
|
||||
-- (ms,is) = unzip ps
|
||||
-- combinedmodules = foldr f [(_itModules it,[])] ms
|
||||
-- f :: M.Map ModuleSlot ItemModule -> [(M.Map ModuleSlot ItemModule,[String])] -> [(M.Map ModuleSlot ItemModule,[String])]
|
||||
-- f ims imss = concatMap (g ims) imss
|
||||
-- g ims (ims',s) = map (second (s++)) $ combineModules ims ims'
|
||||
|
||||
combineModule :: ItemModule a -> ItemModule a -> [(ItemModule a,[String])]
|
||||
combineModule ItemModule{_modName=ss} BlockedModule = [(BlockedModule, "WARNING:REMOVES":ss)]
|
||||
combineModule _ BlockedModule = [(BlockedModule, [])]
|
||||
combineModule BlockedModule m = [(m,[])]
|
||||
combineModule DefaultModule m = [(m,[])]
|
||||
combineModule ItemModule{_modName=ss} m@ItemModule{} = [(m,"WARNING:REMOVES":ss)]
|
||||
combineModule m _ = [(m,[])]
|
||||
combineModules :: M.Map ModuleSlot ItemModule
|
||||
-> M.Map ModuleSlot ItemModule
|
||||
-> ([String],M.Map ModuleSlot ItemModule)
|
||||
combineModules = mergeA
|
||||
(traverseMaybeMissing f)
|
||||
(traverseMissing g)
|
||||
(zipWithAMatched h)
|
||||
where
|
||||
f _ ItemModule{_modName=ss} = ("WARNING:REMOVES":ss,Nothing)
|
||||
f _ _ = ([],Nothing)
|
||||
g _ m = ([], m)
|
||||
h _ ItemModule{_modName=ss} im@ItemModule{} = ("WARNING:REMOVES":ss,im)
|
||||
h _ _ im@ItemModule{} = ([],im)
|
||||
h _ im _ = ([],im)
|
||||
|
||||
toggleCombineInv :: World -> World
|
||||
toggleCombineInv w = case _inventoryMode w of
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
module Dodge.Combine.Combinations where
|
||||
import Geometry
|
||||
import Dodge.Data
|
||||
import Dodge.WorldEvent.HitEffect
|
||||
import Dodge.Particle.Bullet.HitEffect
|
||||
@@ -9,8 +10,14 @@ import Dodge.Item.Weapon.BulletGuns
|
||||
import Dodge.Item.Weapon.BatteryGuns
|
||||
import Dodge.Item.Weapon.Launcher
|
||||
import Dodge.Item.Weapon.SprayGuns
|
||||
import Dodge.Item.Weapon.Bezier
|
||||
import Dodge.Item.Weapon.TriggerType
|
||||
import Dodge.Item.Weapon.ExtraEffect
|
||||
import Dodge.Base
|
||||
import LensHelp
|
||||
|
||||
import Data.Maybe
|
||||
|
||||
import Control.Lens
|
||||
itemCombinations :: [([(Int,CombineType)],Item)]
|
||||
itemCombinations =
|
||||
[ po [PIPE, HARDWARE] (bangStick 1)
|
||||
@@ -34,6 +41,7 @@ itemCombinations =
|
||||
, po [BANGCANE,TIN] rifle
|
||||
, po [RIFLE,PLANK] repeater
|
||||
, po [REPEATER,SPRING,HARDWARE] autoRifle
|
||||
, po [AUTORIFLE,MICROCHIP,MAGNET] bezierGun
|
||||
, po [REPEATER,SPRING,CAN] burstRifle
|
||||
, po [BURSTRIFLE,SPRING,HARDWARE] fastBurstRifle
|
||||
, po [FASTBURSTRIFLE,SPRING,HARDWARE] completeBurstRifle
|
||||
@@ -67,52 +75,77 @@ itemCombinations =
|
||||
++ map (\i -> po [REVOLVERX i,CAN] $ revolverX (i+1)) [1..5]
|
||||
++ map (\i -> p [o (BANGCANEX i),p 2 PIPE] $ bangCaneX (i+1)) [1..5]
|
||||
++ map (\i -> po [MINIGUNX i,BANGCANE] $ miniGunX (i+1)) [3..15]
|
||||
++ [ po [itype,mtype] $ it & itModules . modHitEffect .~ m
|
||||
| (itype,it) <- firearmTypes , (mtype,m) <- bulletModules
|
||||
]
|
||||
++ [ po (itype : ctypes) $ it & itModules . modRifleMag .~ m
|
||||
| (itype,it) <- rifleMagTypes , (ctypes,m) <- rifleMagModules
|
||||
++ [ po (_itType it:mtype) $ it & itModules . ix modtype .~ m
|
||||
| (modtype,is,ms) <- moduleCombinations
|
||||
, it <- is
|
||||
, (mtype,m) <- ms
|
||||
]
|
||||
where
|
||||
p = (,)
|
||||
po xs it = (map o xs,it)
|
||||
o = (1,)
|
||||
|
||||
rifleMagTypes :: [(CombineType,Item)]
|
||||
rifleMagTypes
|
||||
= [(REPEATER,repeater)
|
||||
,(AUTORIFLE,autoRifle)
|
||||
,(BURSTRIFLE,burstRifle)
|
||||
,(FASTBURSTRIFLE,fastBurstRifle)
|
||||
]
|
||||
rifleMagModules :: [([CombineType],ItemModule RifleMag)]
|
||||
rifleMagModules =
|
||||
[([DRUM,HARDWARE], ItemModule DrumMag ["+DRUM MAGAZINE"] 1 id)
|
||||
,([MOTOR,HARDWARE], ItemModule BeltMag ["+BELT MAGAZINE"] 1 id)
|
||||
,([MAGNET,HARDWARE],ItemModule MagnetMag ["+MAGNET MAGAZINE"] 1 id)
|
||||
moduleCombinations :: [( ModuleSlot, [Item], [([CombineType],ItemModule)] )]
|
||||
moduleCombinations =
|
||||
[ ( ModRifleMag
|
||||
, [repeater
|
||||
,autoRifle
|
||||
,burstRifle
|
||||
,fastBurstRifle
|
||||
]
|
||||
, [amod [DRUM,HARDWARE] "+DRUM MAG" (itConsumption . ammoBaseMax .~ 45)
|
||||
,amod [MOTOR,HARDWARE] "+BELT FEED" (itConsumption . ammoBaseMax .~ 150)
|
||||
]
|
||||
)
|
||||
, ( ModAutoMag
|
||||
, [autoRifle
|
||||
,autoPistol
|
||||
,smg
|
||||
]
|
||||
, [amod [MAGNET,HARDWARE] "+MAGNET FEED" (itUse . useDelay . rateMax .~ 4)
|
||||
]
|
||||
)
|
||||
, ( ModBullet
|
||||
, bulletWeapons
|
||||
, [amod [INCENDIARYMODULE] "+INCENDIARY" (f $ destroyOnImpact bulIncCr bulIncWall)
|
||||
,amod [BOUNCEMODULE] "+BOUNCE" (f $ destroyOnImpact bulBounceArmCr' bulBounceWall)
|
||||
]
|
||||
)
|
||||
, ( ModBulletTarget
|
||||
, bulletWeapons
|
||||
, [amod [TELEPORTMODULE,MICROCHIP] "+TELEPORT" (itUse . useMods .:~ withPositionWallCheck (const . const mouseWorldPos))
|
||||
,amod [TELEPORTMODULE] "+DIRECTEDTELE" makeDirectedTele
|
||||
]
|
||||
)
|
||||
]
|
||||
where
|
||||
makeDirectedTele it = it & itEffect .~ rbSetTarget
|
||||
& itUse . useMods .:~ withPosDirWallCheck directedTelPos
|
||||
& itUse . useAim . aimZoom . itZoomFac .~ 1
|
||||
directedTelPos it cr w = (p,a)
|
||||
where
|
||||
p = fromMaybe (_crPos cr) $ do
|
||||
(g,_) <- _itTargeting it
|
||||
g w
|
||||
a = argV (mouseWorldPos w -.- p)
|
||||
f ameff = itConsumption . aoType . amBulEff .~ ameff
|
||||
amod cts str func = (cts,ItemModule [str] 1 func)
|
||||
|
||||
firearmTypes :: [(CombineType,Item)]
|
||||
firearmTypes
|
||||
= [(BANGSTICK i,bangStick i) | i <- [1..9] ]
|
||||
++ [(BANGCANEX i,bangCaneX i) | i <- [1..6] ]
|
||||
++ [(REVOLVERX i,revolverX i) | i <- [1..5] ]
|
||||
++ [(MINIGUNX i,miniGunX i) | i <- [3..16] ]
|
||||
++ [(BANGCANE,bangCane)
|
||||
,(PISTOL,pistol)
|
||||
,(AUTOPISTOL,autoPistol)
|
||||
,(SMG,smg)
|
||||
,(MACHINEPISTOL,machinePistol)
|
||||
,(REVOLVER,revolver)
|
||||
,(RIFLE,rifle)
|
||||
,(REPEATER,repeater)
|
||||
,(AUTORIFLE,autoRifle)
|
||||
,(BURSTRIFLE,burstRifle)
|
||||
,(FASTBURSTRIFLE,fastBurstRifle)
|
||||
,(COMPLETEBURSTRIFLE,completeBurstRifle)
|
||||
]
|
||||
bulletModules :: [(CombineType,ItemModule HitEffect)]
|
||||
bulletModules =
|
||||
[(INCENDIARYMODULE, ItemModule (destroyOnImpact bulIncCr bulIncWall) ["+INCENDIARY"] 1 id)
|
||||
,(BOUNCEMODULE, ItemModule (destroyOnImpact bulBounceArmCr' bulBounceWall) ["+BOUNCE"] 1 id)
|
||||
]
|
||||
bulletWeapons :: [Item]
|
||||
bulletWeapons = [bangStick i | i <- [1..9] ]
|
||||
++ [bangCaneX i | i <- [1..6] ]
|
||||
++ [revolverX i | i <- [1..5] ]
|
||||
++ [miniGunX i | i <- [3..16] ]
|
||||
++ [bangCane
|
||||
,pistol
|
||||
,autoPistol
|
||||
,smg
|
||||
,machinePistol
|
||||
,revolver
|
||||
,rifle
|
||||
,repeater
|
||||
,autoRifle
|
||||
,burstRifle
|
||||
,fastBurstRifle
|
||||
,completeBurstRifle
|
||||
]
|
||||
|
||||
@@ -83,7 +83,7 @@ data CombineType
|
||||
| LIGHTER
|
||||
| MAGNET
|
||||
| PLATE
|
||||
| MCHIP
|
||||
| MICROCHIP
|
||||
| LED
|
||||
| NAILBOX
|
||||
| IRONBAR
|
||||
@@ -98,4 +98,9 @@ data CombineType
|
||||
| INCENDIARYMODULE
|
||||
| BOUNCEMODULE
|
||||
| NoCombineType
|
||||
--
|
||||
| TELEPORTMODULE
|
||||
| TIMEMODULE
|
||||
| SIZEMODULE
|
||||
| GRAVITYMODULE
|
||||
deriving (Eq,Ord,Show)
|
||||
|
||||
@@ -169,6 +169,7 @@ testInventory = IM.fromList $ zip [0..]
|
||||
[ makeTypeCraftNum 9 PIPE
|
||||
, incendiaryModule
|
||||
, bounceModule
|
||||
, teleportModule
|
||||
, makeTypeCraftNum 5 TUBE
|
||||
, makeTypeCraftNum 1 MAGNET
|
||||
, makeTypeCraftNum 5 HARDWARE
|
||||
@@ -177,10 +178,12 @@ testInventory = IM.fromList $ zip [0..]
|
||||
, makeTypeCraftNum 3 TIN
|
||||
, makeTypeCraftNum 3 PLANK
|
||||
, makeTypeCraftNum 1 MOTOR
|
||||
, makeTypeCraftNum 1 MICROCHIP
|
||||
]
|
||||
stackedInventory :: IM.IntMap Item
|
||||
stackedInventory = IM.fromList $ zip [0..]
|
||||
[sonicGun
|
||||
,teleGun
|
||||
,spreadGun
|
||||
, pipe
|
||||
,rewindGun
|
||||
|
||||
+7
-13
@@ -375,25 +375,20 @@ data Item
|
||||
, _itCurseStatus :: CurseStatus
|
||||
, _itParams :: ItemParams
|
||||
, _itTweaks :: ItemTweaks
|
||||
, _itModules :: ItemModules
|
||||
, _itModules :: M.Map ModuleSlot ItemModule
|
||||
}
|
||||
|
||||
data ItemModules = ItemModules
|
||||
{ _modHitEffect :: ItemModule HitEffect
|
||||
, _modRifleMag :: ItemModule RifleMag
|
||||
}
|
||||
data RifleMag = DrumMag | BeltMag | MagnetMag
|
||||
|
||||
data ModuleSlot
|
||||
= ModBullet
|
||||
| ModRifleMag
|
||||
| ModAutoMag
|
||||
| ModBulletTarget
|
||||
deriving (Eq,Ord)
|
||||
|
||||
data ItemModule a
|
||||
= BlockedModule
|
||||
| DefaultModule
|
||||
data ItemModule
|
||||
= DefaultModule
|
||||
| ItemModule
|
||||
{ _theModule :: a
|
||||
, _modName :: [String]
|
||||
{ _modName :: [String]
|
||||
, _modSize :: Int
|
||||
, _modModification :: Item -> Item
|
||||
}
|
||||
@@ -938,5 +933,4 @@ makeLenses ''ItemPortage
|
||||
makeLenses ''Magnet
|
||||
makeLenses ''Gust
|
||||
makeLenses ''GunBarrels
|
||||
makeLenses ''ItemModules
|
||||
makeLenses ''ItemModule
|
||||
|
||||
@@ -17,6 +17,7 @@ import Shape
|
||||
|
||||
import Control.Lens
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.Map.Strict as M
|
||||
import qualified Data.Vector as V
|
||||
import Data.List
|
||||
--import Data.Monoid
|
||||
@@ -154,10 +155,7 @@ defaultEquipment = Item
|
||||
, _itParams = NoParams
|
||||
, _itTweaks = NoTweaks
|
||||
, _itTargeting = Nothing
|
||||
, _itModules = ItemModules
|
||||
{ _modHitEffect = BlockedModule
|
||||
, _modRifleMag = BlockedModule
|
||||
}
|
||||
, _itModules = M.empty
|
||||
}
|
||||
defaultItZoom :: ItZoom
|
||||
defaultItZoom = ItZoom 20 0.2 1
|
||||
@@ -181,10 +179,7 @@ defaultConsumable = Item
|
||||
, _itParams = NoParams
|
||||
, _itDimension = defItDimCol blue
|
||||
, _itTweaks = NoTweaks
|
||||
, _itModules = ItemModules
|
||||
{ _modHitEffect = BlockedModule
|
||||
, _modRifleMag = BlockedModule
|
||||
}
|
||||
, _itModules = M.empty
|
||||
}
|
||||
defaultApplyDamage :: [DamageType] -> Creature -> (World -> World, Creature)
|
||||
defaultApplyDamage ds cr = (id, doPoisonDam $ foldl' (flip $ \d c -> snd $ applyIndividualDamage d c) cr ds')
|
||||
|
||||
@@ -10,7 +10,7 @@ import Shape
|
||||
import Geometry
|
||||
--import Dodge.TweakBullet
|
||||
|
||||
--import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.Map.Strict as M
|
||||
import Control.Lens
|
||||
|
||||
defaultAmmo :: ItemConsumption
|
||||
@@ -100,10 +100,9 @@ defaultGun = Item
|
||||
, _itTargeting = Nothing
|
||||
, _itParams = NoParams
|
||||
, _itTweaks = NoTweaks
|
||||
, _itModules = ItemModules
|
||||
{ _modHitEffect = DefaultModule
|
||||
, _modRifleMag = BlockedModule
|
||||
}
|
||||
, _itModules = M.fromList [(ModBullet , DefaultModule)
|
||||
,(ModBulletTarget,DefaultModule)
|
||||
]
|
||||
}
|
||||
defaultCraftable :: Item
|
||||
defaultCraftable = Item
|
||||
@@ -126,10 +125,7 @@ defaultCraftable = Item
|
||||
, _itParams = NoParams
|
||||
, _itDimension = defItDimCol green
|
||||
, _itTweaks = NoTweaks
|
||||
, _itModules = ItemModules
|
||||
{ _modHitEffect = BlockedModule
|
||||
, _modRifleMag = BlockedModule
|
||||
}
|
||||
, _itModules = M.empty
|
||||
}
|
||||
defItDim :: ItemDimension
|
||||
defItDim = ItemDimension
|
||||
|
||||
@@ -11,4 +11,3 @@ itSlotsTaken :: Item -> Int
|
||||
itSlotsTaken it = case it ^? itConsumption . itAmount of
|
||||
Nothing -> moduleSizes it + ceiling (_itInvSize it)
|
||||
Just i -> moduleSizes it + ceiling (_itInvSize it * fromIntegral i)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
+10
-3
@@ -1,10 +1,17 @@
|
||||
module Dodge.Module
|
||||
where
|
||||
( moduleSizes
|
||||
, moduleStrings
|
||||
) where
|
||||
import Dodge.Data
|
||||
|
||||
import Control.Lens
|
||||
import Data.Maybe
|
||||
|
||||
moduleSizes :: Item -> Int
|
||||
moduleSizes it = (fromMaybe 0 $ it ^? itModules . modHitEffect . modSize)
|
||||
+ (fromMaybe 0 $ it ^? itModules . modRifleMag . modSize)
|
||||
moduleSizes = moduleFold (+) (^? modSize) 0
|
||||
|
||||
moduleStrings :: Item -> [String]
|
||||
moduleStrings = moduleFold (++) (^? modName) []
|
||||
|
||||
moduleFold :: (m -> m -> m) -> (ItemModule -> Maybe m) -> m -> Item -> m
|
||||
moduleFold g f e = foldr (g . fromMaybe e . f) e . _itModules
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
module Dodge.Reloading where
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
import Dodge.Item.MaxAmmo
|
||||
--import qualified Data.IntMap.Strict as IM
|
||||
|
||||
--import Data.Maybe
|
||||
@@ -14,7 +13,7 @@ startReloadingWeapon cr = (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr)
|
||||
|
||||
icTryStartReloading :: Item -> Maybe Item
|
||||
icTryStartReloading it
|
||||
| _ammoLoaded am < itMaxAmmo it && _reloadState am == Nothing'
|
||||
| _ammoLoaded am < _ammoBaseMax (_itConsumption it) && _reloadState am == Nothing'
|
||||
= Just $ it & itConsumption . reloadState .~ Just' (_reloadTime am)
|
||||
& if _reloadType am == ActiveClear then itConsumption . ammoLoaded .~ 0 else id
|
||||
| otherwise = Nothing
|
||||
@@ -36,14 +35,15 @@ stepReloading cr = case cr ^? crInv . ix isel . itConsumption . reloadState . _J
|
||||
isel = _crInvSel cr
|
||||
doload it = case _reloadType itcon of
|
||||
ActivePartial x
|
||||
| x + _ammoLoaded itcon < itMaxAmmo it -> it & itConsumption . ammoLoaded %~ (+ x)
|
||||
| x + _ammoLoaded itcon < itMaxAmmo -> it & itConsumption . ammoLoaded %~ (+ x)
|
||||
& itConsumption . reloadState .~ Just' (_reloadTime itcon)
|
||||
| otherwise -> it & itConsumption . ammoLoaded .~ itMaxAmmo it
|
||||
| otherwise -> it & itConsumption . ammoLoaded .~ itMaxAmmo
|
||||
& itConsumption . reloadState .~ Nothing'
|
||||
_ -> it & itConsumption . ammoLoaded .~ itMaxAmmo it
|
||||
_ -> it & itConsumption . ammoLoaded .~ itMaxAmmo
|
||||
& itConsumption . reloadState .~ Nothing'
|
||||
where
|
||||
itcon = _itConsumption it
|
||||
itMaxAmmo = _ammoBaseMax itcon
|
||||
|
||||
--{- | Start reloading if clip is empty. -}
|
||||
--crAutoReload :: Creature -> Creature
|
||||
|
||||
@@ -164,6 +164,7 @@ addDepth :: Float -> Picture -> Picture
|
||||
--addDepth d = map $ second $ overPos (\(x,y,z) -> (x,y,z+d))
|
||||
addDepth d = map $ overPos (\(V3 x y z) -> V3 x y (z+d))
|
||||
|
||||
-- TODO change the Int here to a dedicated type
|
||||
setLayer :: Int -> Picture -> Picture
|
||||
{-# INLINE setLayer #-}
|
||||
setLayer i = map f
|
||||
|
||||
Reference in New Issue
Block a user