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
|
doTranslate p = p -.- _carteCenter w
|
||||||
doZoom p = _carteZoom w *.* p
|
doZoom p = _carteZoom w *.* p
|
||||||
doRotate p = rotateV (negate $ _carteRot 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. -}
|
{- | The mouse position in world coordinates. -}
|
||||||
mouseWorldPos :: World -> Point2
|
mouseWorldPos :: World -> Point2
|
||||||
mouseWorldPos w = _cameraCenter w +.+ (1/_cameraZoom w) *.* rotateV (_cameraRot w) (_mousePos w)
|
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
|
hasLOS :: Point2 -> Point2 -> World -> Bool
|
||||||
{-# INLINE hasLOS #-}
|
{-# 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
|
--hitPointLines
|
||||||
-- :: Point2
|
-- :: Point2
|
||||||
|
|||||||
+44
-23
@@ -21,6 +21,7 @@ import Data.Bifunctor
|
|||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
--import qualified Data.IntSet as IS
|
--import qualified Data.IntSet as IS
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
|
import Data.Map.Merge.Strict
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.List (scanl',sortOn)
|
import Data.List (scanl',sortOn)
|
||||||
|
|
||||||
@@ -34,21 +35,25 @@ combinationsTrie = foldr
|
|||||||
-- trie going through each combine type in your inventory in order, rather than
|
-- trie going through each combine type in your inventory in order, rather than
|
||||||
-- creating all multisets of combine types.
|
-- 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
|
lookupItems xs = lookupItemsUsingTrie (sortOn (\(_,ct,_,_) -> ct) xs) combinationsTrie
|
||||||
|
|
||||||
lookupItemsUsingTrie :: [(ItemModules,CombineType,Int,Int)]
|
lookupItemsUsingTrie :: [(M.Map ModuleSlot ItemModule,CombineType,Int,Int)]
|
||||||
-> Trie (Int,CombineType) Item -> [ ([(ItemModules,Int)],Item) ]
|
-> Trie (Int,CombineType) Item
|
||||||
|
-> [ ([(M.Map ModuleSlot ItemModule,Int)],Item) ]
|
||||||
lookupItemsUsingTrie [] t = maybeToList $ ([],) <$> _trieMVal t
|
lookupItemsUsingTrie [] t = maybeToList $ ([],) <$> _trieMVal t
|
||||||
lookupItemsUsingTrie ((mods,ct,i,n):xs) t = do
|
lookupItemsUsingTrie ((mods,ct,i,n):xs) t = do
|
||||||
n' <- [1..min n 4]
|
n' <- [1..min n 4]
|
||||||
let is = replicate n' (mods,i)
|
let is = replicate n' (mods,i)
|
||||||
concatMap (map (first (is ++)) . lookupItemsUsingTrie xs) $ maybeToList (_trieChildren t M.!? (n',ct))
|
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
|
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
|
invertListInv = IM.foldrWithKey
|
||||||
(\k it -> ((_itModules it,_itType it, k, itStackAmount it) :) )
|
(\k it -> ((_itModules it,_itType it, k, itStackAmount it) :) )
|
||||||
[]
|
[]
|
||||||
@@ -60,29 +65,45 @@ combineItemListYou :: World -> [([Int],Item)]
|
|||||||
combineItemListYou = map (second fst) . combineItemListYou'
|
combineItemListYou = map (second fst) . combineItemListYou'
|
||||||
|
|
||||||
combineItemListYou' :: World -> [([Int],(Item,[String]))]
|
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 :: ([(M.Map ModuleSlot ItemModule,Int)],Item)
|
||||||
addModules (ps,it) = (is , ) <$> [ (it & itModules .~ themodules,s) | (themodules,s) <- combinedmodules]
|
-> ([Int],(Item,[String]))
|
||||||
|
addModules (ps,it) = (is , (applyModules newm it, ss))
|
||||||
where
|
where
|
||||||
(ms,is) = unzip ps
|
(ms,is) = unzip ps
|
||||||
combinedmodules = foldr f [(_itModules it,[])] ms
|
m = ([],_itModules it)
|
||||||
f :: ItemModules -> [(ItemModules,[String])] -> [(ItemModules,[String])]
|
(ss,newm) = foldr f m ms
|
||||||
f ims imss = concatMap (g ims) imss
|
f m' (s,m'') = (s ++ s',m''')
|
||||||
g ims (ims',s) = map (second (s++)) $ combineModules ims ims'
|
where
|
||||||
|
(s',m''') = combineModules m' m''
|
||||||
|
|
||||||
combineModules :: ItemModules -> ItemModules -> [(ItemModules,[String])]
|
applyModules :: M.Map ModuleSlot ItemModule -> Item -> Item
|
||||||
combineModules (ItemModules a1 b1) (ItemModules a2 b2)
|
applyModules ms it = foldr f (it & itModules .~ ms) ms
|
||||||
= [(ItemModules a b,as++bs) | (a,as) <- combineModule a1 a2
|
where
|
||||||
, (b,bs) <- combineModule b1 b2]
|
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])]
|
combineModules :: M.Map ModuleSlot ItemModule
|
||||||
combineModule ItemModule{_modName=ss} BlockedModule = [(BlockedModule, "WARNING:REMOVES":ss)]
|
-> M.Map ModuleSlot ItemModule
|
||||||
combineModule _ BlockedModule = [(BlockedModule, [])]
|
-> ([String],M.Map ModuleSlot ItemModule)
|
||||||
combineModule BlockedModule m = [(m,[])]
|
combineModules = mergeA
|
||||||
combineModule DefaultModule m = [(m,[])]
|
(traverseMaybeMissing f)
|
||||||
combineModule ItemModule{_modName=ss} m@ItemModule{} = [(m,"WARNING:REMOVES":ss)]
|
(traverseMissing g)
|
||||||
combineModule m _ = [(m,[])]
|
(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 :: World -> World
|
||||||
toggleCombineInv w = case _inventoryMode w of
|
toggleCombineInv w = case _inventoryMode w of
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{-# LANGUAGE TupleSections #-}
|
{-# LANGUAGE TupleSections #-}
|
||||||
module Dodge.Combine.Combinations where
|
module Dodge.Combine.Combinations where
|
||||||
|
import Geometry
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.WorldEvent.HitEffect
|
import Dodge.WorldEvent.HitEffect
|
||||||
import Dodge.Particle.Bullet.HitEffect
|
import Dodge.Particle.Bullet.HitEffect
|
||||||
@@ -9,8 +10,14 @@ 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.ExtraEffect
|
||||||
|
import Dodge.Base
|
||||||
|
import LensHelp
|
||||||
|
|
||||||
|
import Data.Maybe
|
||||||
|
|
||||||
import Control.Lens
|
|
||||||
itemCombinations :: [([(Int,CombineType)],Item)]
|
itemCombinations :: [([(Int,CombineType)],Item)]
|
||||||
itemCombinations =
|
itemCombinations =
|
||||||
[ po [PIPE, HARDWARE] (bangStick 1)
|
[ po [PIPE, HARDWARE] (bangStick 1)
|
||||||
@@ -34,6 +41,7 @@ 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
|
||||||
@@ -67,52 +75,77 @@ itemCombinations =
|
|||||||
++ map (\i -> po [REVOLVERX i,CAN] $ revolverX (i+1)) [1..5]
|
++ 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 -> p [o (BANGCANEX i),p 2 PIPE] $ bangCaneX (i+1)) [1..5]
|
||||||
++ map (\i -> po [MINIGUNX i,BANGCANE] $ miniGunX (i+1)) [3..15]
|
++ map (\i -> po [MINIGUNX i,BANGCANE] $ miniGunX (i+1)) [3..15]
|
||||||
++ [ po [itype,mtype] $ it & itModules . modHitEffect .~ m
|
++ [ po (_itType it:mtype) $ it & itModules . ix modtype .~ m
|
||||||
| (itype,it) <- firearmTypes , (mtype,m) <- bulletModules
|
| (modtype,is,ms) <- moduleCombinations
|
||||||
]
|
, it <- is
|
||||||
++ [ po (itype : ctypes) $ it & itModules . modRifleMag .~ m
|
, (mtype,m) <- ms
|
||||||
| (itype,it) <- rifleMagTypes , (ctypes,m) <- rifleMagModules
|
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
p = (,)
|
p = (,)
|
||||||
po xs it = (map o xs,it)
|
po xs it = (map o xs,it)
|
||||||
o = (1,)
|
o = (1,)
|
||||||
|
|
||||||
rifleMagTypes :: [(CombineType,Item)]
|
moduleCombinations :: [( ModuleSlot, [Item], [([CombineType],ItemModule)] )]
|
||||||
rifleMagTypes
|
moduleCombinations =
|
||||||
= [(REPEATER,repeater)
|
[ ( ModRifleMag
|
||||||
,(AUTORIFLE,autoRifle)
|
, [repeater
|
||||||
,(BURSTRIFLE,burstRifle)
|
,autoRifle
|
||||||
,(FASTBURSTRIFLE,fastBurstRifle)
|
,burstRifle
|
||||||
]
|
,fastBurstRifle
|
||||||
rifleMagModules :: [([CombineType],ItemModule RifleMag)]
|
]
|
||||||
rifleMagModules =
|
, [amod [DRUM,HARDWARE] "+DRUM MAG" (itConsumption . ammoBaseMax .~ 45)
|
||||||
[([DRUM,HARDWARE], ItemModule DrumMag ["+DRUM MAGAZINE"] 1 id)
|
,amod [MOTOR,HARDWARE] "+BELT FEED" (itConsumption . ammoBaseMax .~ 150)
|
||||||
,([MOTOR,HARDWARE], ItemModule BeltMag ["+BELT MAGAZINE"] 1 id)
|
]
|
||||||
,([MAGNET,HARDWARE],ItemModule MagnetMag ["+MAGNET MAGAZINE"] 1 id)
|
)
|
||||||
|
, ( 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)]
|
bulletWeapons :: [Item]
|
||||||
firearmTypes
|
bulletWeapons = [bangStick i | i <- [1..9] ]
|
||||||
= [(BANGSTICK i,bangStick i) | i <- [1..9] ]
|
++ [bangCaneX i | i <- [1..6] ]
|
||||||
++ [(BANGCANEX i,bangCaneX i) | i <- [1..6] ]
|
++ [revolverX i | i <- [1..5] ]
|
||||||
++ [(REVOLVERX i,revolverX i) | i <- [1..5] ]
|
++ [miniGunX i | i <- [3..16] ]
|
||||||
++ [(MINIGUNX i,miniGunX i) | i <- [3..16] ]
|
++ [bangCane
|
||||||
++ [(BANGCANE,bangCane)
|
,pistol
|
||||||
,(PISTOL,pistol)
|
,autoPistol
|
||||||
,(AUTOPISTOL,autoPistol)
|
,smg
|
||||||
,(SMG,smg)
|
,machinePistol
|
||||||
,(MACHINEPISTOL,machinePistol)
|
,revolver
|
||||||
,(REVOLVER,revolver)
|
,rifle
|
||||||
,(RIFLE,rifle)
|
,repeater
|
||||||
,(REPEATER,repeater)
|
,autoRifle
|
||||||
,(AUTORIFLE,autoRifle)
|
,burstRifle
|
||||||
,(BURSTRIFLE,burstRifle)
|
,fastBurstRifle
|
||||||
,(FASTBURSTRIFLE,fastBurstRifle)
|
,completeBurstRifle
|
||||||
,(COMPLETEBURSTRIFLE,completeBurstRifle)
|
]
|
||||||
]
|
|
||||||
bulletModules :: [(CombineType,ItemModule HitEffect)]
|
|
||||||
bulletModules =
|
|
||||||
[(INCENDIARYMODULE, ItemModule (destroyOnImpact bulIncCr bulIncWall) ["+INCENDIARY"] 1 id)
|
|
||||||
,(BOUNCEMODULE, ItemModule (destroyOnImpact bulBounceArmCr' bulBounceWall) ["+BOUNCE"] 1 id)
|
|
||||||
]
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ data CombineType
|
|||||||
| LIGHTER
|
| LIGHTER
|
||||||
| MAGNET
|
| MAGNET
|
||||||
| PLATE
|
| PLATE
|
||||||
| MCHIP
|
| MICROCHIP
|
||||||
| LED
|
| LED
|
||||||
| NAILBOX
|
| NAILBOX
|
||||||
| IRONBAR
|
| IRONBAR
|
||||||
@@ -98,4 +98,9 @@ data CombineType
|
|||||||
| INCENDIARYMODULE
|
| INCENDIARYMODULE
|
||||||
| BOUNCEMODULE
|
| BOUNCEMODULE
|
||||||
| NoCombineType
|
| NoCombineType
|
||||||
|
--
|
||||||
|
| TELEPORTMODULE
|
||||||
|
| TIMEMODULE
|
||||||
|
| SIZEMODULE
|
||||||
|
| GRAVITYMODULE
|
||||||
deriving (Eq,Ord,Show)
|
deriving (Eq,Ord,Show)
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ testInventory = IM.fromList $ zip [0..]
|
|||||||
[ makeTypeCraftNum 9 PIPE
|
[ makeTypeCraftNum 9 PIPE
|
||||||
, incendiaryModule
|
, incendiaryModule
|
||||||
, bounceModule
|
, bounceModule
|
||||||
|
, teleportModule
|
||||||
, makeTypeCraftNum 5 TUBE
|
, makeTypeCraftNum 5 TUBE
|
||||||
, makeTypeCraftNum 1 MAGNET
|
, makeTypeCraftNum 1 MAGNET
|
||||||
, makeTypeCraftNum 5 HARDWARE
|
, makeTypeCraftNum 5 HARDWARE
|
||||||
@@ -177,10 +178,12 @@ testInventory = IM.fromList $ zip [0..]
|
|||||||
, makeTypeCraftNum 3 TIN
|
, makeTypeCraftNum 3 TIN
|
||||||
, makeTypeCraftNum 3 PLANK
|
, makeTypeCraftNum 3 PLANK
|
||||||
, makeTypeCraftNum 1 MOTOR
|
, makeTypeCraftNum 1 MOTOR
|
||||||
|
, makeTypeCraftNum 1 MICROCHIP
|
||||||
]
|
]
|
||||||
stackedInventory :: IM.IntMap Item
|
stackedInventory :: IM.IntMap Item
|
||||||
stackedInventory = IM.fromList $ zip [0..]
|
stackedInventory = IM.fromList $ zip [0..]
|
||||||
[sonicGun
|
[sonicGun
|
||||||
|
,teleGun
|
||||||
,spreadGun
|
,spreadGun
|
||||||
, pipe
|
, pipe
|
||||||
,rewindGun
|
,rewindGun
|
||||||
|
|||||||
+7
-13
@@ -375,25 +375,20 @@ data Item
|
|||||||
, _itCurseStatus :: CurseStatus
|
, _itCurseStatus :: CurseStatus
|
||||||
, _itParams :: ItemParams
|
, _itParams :: ItemParams
|
||||||
, _itTweaks :: ItemTweaks
|
, _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
|
data ModuleSlot
|
||||||
= ModBullet
|
= ModBullet
|
||||||
| ModRifleMag
|
| ModRifleMag
|
||||||
|
| ModAutoMag
|
||||||
|
| ModBulletTarget
|
||||||
|
deriving (Eq,Ord)
|
||||||
|
|
||||||
data ItemModule a
|
data ItemModule
|
||||||
= BlockedModule
|
= DefaultModule
|
||||||
| DefaultModule
|
|
||||||
| ItemModule
|
| ItemModule
|
||||||
{ _theModule :: a
|
{ _modName :: [String]
|
||||||
, _modName :: [String]
|
|
||||||
, _modSize :: Int
|
, _modSize :: Int
|
||||||
, _modModification :: Item -> Item
|
, _modModification :: Item -> Item
|
||||||
}
|
}
|
||||||
@@ -938,5 +933,4 @@ makeLenses ''ItemPortage
|
|||||||
makeLenses ''Magnet
|
makeLenses ''Magnet
|
||||||
makeLenses ''Gust
|
makeLenses ''Gust
|
||||||
makeLenses ''GunBarrels
|
makeLenses ''GunBarrels
|
||||||
makeLenses ''ItemModules
|
|
||||||
makeLenses ''ItemModule
|
makeLenses ''ItemModule
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import Shape
|
|||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
|
import qualified Data.Map.Strict as M
|
||||||
import qualified Data.Vector as V
|
import qualified Data.Vector as V
|
||||||
import Data.List
|
import Data.List
|
||||||
--import Data.Monoid
|
--import Data.Monoid
|
||||||
@@ -154,10 +155,7 @@ defaultEquipment = Item
|
|||||||
, _itParams = NoParams
|
, _itParams = NoParams
|
||||||
, _itTweaks = NoTweaks
|
, _itTweaks = NoTweaks
|
||||||
, _itTargeting = Nothing
|
, _itTargeting = Nothing
|
||||||
, _itModules = ItemModules
|
, _itModules = M.empty
|
||||||
{ _modHitEffect = BlockedModule
|
|
||||||
, _modRifleMag = BlockedModule
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
defaultItZoom :: ItZoom
|
defaultItZoom :: ItZoom
|
||||||
defaultItZoom = ItZoom 20 0.2 1
|
defaultItZoom = ItZoom 20 0.2 1
|
||||||
@@ -181,10 +179,7 @@ defaultConsumable = Item
|
|||||||
, _itParams = NoParams
|
, _itParams = NoParams
|
||||||
, _itDimension = defItDimCol blue
|
, _itDimension = defItDimCol blue
|
||||||
, _itTweaks = NoTweaks
|
, _itTweaks = NoTweaks
|
||||||
, _itModules = ItemModules
|
, _itModules = M.empty
|
||||||
{ _modHitEffect = BlockedModule
|
|
||||||
, _modRifleMag = BlockedModule
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
defaultApplyDamage :: [DamageType] -> Creature -> (World -> World, Creature)
|
defaultApplyDamage :: [DamageType] -> Creature -> (World -> World, Creature)
|
||||||
defaultApplyDamage ds cr = (id, doPoisonDam $ foldl' (flip $ \d c -> snd $ applyIndividualDamage d c) cr ds')
|
defaultApplyDamage ds cr = (id, doPoisonDam $ foldl' (flip $ \d c -> snd $ applyIndividualDamage d c) cr ds')
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import Shape
|
|||||||
import Geometry
|
import Geometry
|
||||||
--import Dodge.TweakBullet
|
--import Dodge.TweakBullet
|
||||||
|
|
||||||
--import qualified Data.IntMap.Strict as IM
|
import qualified Data.Map.Strict as M
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
|
||||||
defaultAmmo :: ItemConsumption
|
defaultAmmo :: ItemConsumption
|
||||||
@@ -100,10 +100,9 @@ defaultGun = Item
|
|||||||
, _itTargeting = Nothing
|
, _itTargeting = Nothing
|
||||||
, _itParams = NoParams
|
, _itParams = NoParams
|
||||||
, _itTweaks = NoTweaks
|
, _itTweaks = NoTweaks
|
||||||
, _itModules = ItemModules
|
, _itModules = M.fromList [(ModBullet , DefaultModule)
|
||||||
{ _modHitEffect = DefaultModule
|
,(ModBulletTarget,DefaultModule)
|
||||||
, _modRifleMag = BlockedModule
|
]
|
||||||
}
|
|
||||||
}
|
}
|
||||||
defaultCraftable :: Item
|
defaultCraftable :: Item
|
||||||
defaultCraftable = Item
|
defaultCraftable = Item
|
||||||
@@ -126,10 +125,7 @@ defaultCraftable = Item
|
|||||||
, _itParams = NoParams
|
, _itParams = NoParams
|
||||||
, _itDimension = defItDimCol green
|
, _itDimension = defItDimCol green
|
||||||
, _itTweaks = NoTweaks
|
, _itTweaks = NoTweaks
|
||||||
, _itModules = ItemModules
|
, _itModules = M.empty
|
||||||
{ _modHitEffect = BlockedModule
|
|
||||||
, _modRifleMag = BlockedModule
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
defItDim :: ItemDimension
|
defItDim :: ItemDimension
|
||||||
defItDim = ItemDimension
|
defItDim = ItemDimension
|
||||||
|
|||||||
@@ -11,4 +11,3 @@ itSlotsTaken :: Item -> Int
|
|||||||
itSlotsTaken it = case it ^? itConsumption . itAmount of
|
itSlotsTaken it = case it ^? itConsumption . itAmount of
|
||||||
Nothing -> moduleSizes it + ceiling (_itInvSize it)
|
Nothing -> moduleSizes it + ceiling (_itInvSize it)
|
||||||
Just i -> moduleSizes it + ceiling (_itInvSize it * fromIntegral i)
|
Just i -> moduleSizes it + ceiling (_itInvSize it * fromIntegral i)
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,22 @@ bounceModule :: Item
|
|||||||
bounceModule = makeTypeCraft BOUNCEMODULE
|
bounceModule = makeTypeCraft BOUNCEMODULE
|
||||||
& itInvSize .~ 1
|
& itInvSize .~ 1
|
||||||
& itInvColor .~ chartreuse
|
& 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 :: Item
|
||||||
pipe = makeTypeCraft PIPE
|
pipe = makeTypeCraft PIPE
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ data AimStance
|
|||||||
| LeaveHolstered
|
| LeaveHolstered
|
||||||
deriving
|
deriving
|
||||||
(Eq,Show,Ord,Enum)
|
(Eq,Show,Ord,Enum)
|
||||||
|
-- TODO check how much of this is necessary
|
||||||
data ItZoom = ItZoom
|
data ItZoom = ItZoom
|
||||||
{ _itZoomMax :: Float
|
{ _itZoomMax :: Float
|
||||||
, _itZoomMin :: 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
|
, fractionLoadedAmmo2
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Item.MaxAmmo
|
|
||||||
import Dodge.Particle.Bullet.Spawn
|
import Dodge.Particle.Bullet.Spawn
|
||||||
import Dodge.Creature.HandPos
|
import Dodge.Creature.HandPos
|
||||||
import Dodge.WorldEvent.HitEffect
|
|
||||||
import Dodge.Particle.Bullet.HitEffect
|
|
||||||
import Geometry
|
import Geometry
|
||||||
import LensHelp
|
import LensHelp
|
||||||
|
|
||||||
import Data.Maybe
|
--import Data.Maybe
|
||||||
--import Control.Lens
|
--import Control.Lens
|
||||||
|
|
||||||
useAmmoParamsRate :: Int
|
useAmmoParamsRate :: Int
|
||||||
@@ -43,25 +40,24 @@ useAmmoParams it cr = withVelWthHiteff
|
|||||||
(_rifling $ _itParams it)
|
(_rifling $ _itParams it)
|
||||||
(_amBulWth b)
|
(_amBulWth b)
|
||||||
muzlength
|
muzlength
|
||||||
bulHitEff
|
(_amBulEff b)
|
||||||
-- (_amBulEff b)
|
|
||||||
cr
|
cr
|
||||||
where
|
where
|
||||||
muzlength = aimingMuzzlePos cr it
|
muzlength = aimingMuzzlePos cr it
|
||||||
muzvel = _muzVel $ _itParams it
|
muzvel = _muzVel $ _itParams it
|
||||||
b = _aoType $ _itConsumption it
|
b = _aoType $ _itConsumption it
|
||||||
bulHitEff = fromMaybe (destroyOnImpact bulHitCr bulHitWall)
|
-- bulHitEff = fromMaybe (destroyOnImpact bulHitCr bulHitWall)
|
||||||
$ it ^? itModules . modHitEffect . theModule
|
-- $ it ^? itModules . modHitEffect . theModule
|
||||||
|
|
||||||
useAmmoParamsVelMod :: Float -> Item -> Creature -> World -> World
|
useAmmoParamsVelMod :: Float -> Item -> Creature -> World -> World
|
||||||
useAmmoParamsVelMod vfact it = withDelayedVelWthHiteff vfact (_amBulVel b) (_rifling $ _itParams it)
|
useAmmoParamsVelMod vfact it = withDelayedVelWthHiteff vfact (_amBulVel b) (_rifling $ _itParams it)
|
||||||
(_amBulWth b)
|
(_amBulWth b)
|
||||||
-- (_amBulEff b)
|
(_amBulEff b)
|
||||||
bulHitEff
|
-- bulHitEff
|
||||||
where
|
where
|
||||||
b = _aoType $ _itConsumption it
|
b = _aoType $ _itConsumption it
|
||||||
bulHitEff = fromMaybe (destroyOnImpact bulHitCr bulHitWall)
|
-- bulHitEff = fromMaybe (destroyOnImpact bulHitCr bulHitWall)
|
||||||
$ it ^? itModules . modHitEffect . theModule
|
-- $ it ^? itModules . modHitEffect . theModule
|
||||||
|
|
||||||
{- | Creates a bullet with a given velocity, width, and 'HitEffect' -}
|
{- | Creates a bullet with a given velocity, width, and 'HitEffect' -}
|
||||||
withVelWthHiteff
|
withVelWthHiteff
|
||||||
@@ -104,7 +100,11 @@ loadedAmmo it
|
|||||||
|
|
||||||
fractionLoadedAmmo :: Item -> Float
|
fractionLoadedAmmo :: Item -> Float
|
||||||
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (itMaxAmmo it)
|
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (itMaxAmmo it)
|
||||||
|
where
|
||||||
|
itMaxAmmo = _ammoBaseMax . _itConsumption
|
||||||
|
|
||||||
fractionLoadedAmmo2 :: Item -> Float
|
fractionLoadedAmmo2 :: Item -> Float
|
||||||
fractionLoadedAmmo2 it = 1 -
|
fractionLoadedAmmo2 it = 1 -
|
||||||
(1 - fromIntegral (loadedAmmo it) / fromIntegral (itMaxAmmo it))**2
|
(1 - fromIntegral (loadedAmmo it) / fromIntegral (itMaxAmmo it))**2
|
||||||
|
where
|
||||||
|
itMaxAmmo = _ammoBaseMax . _itConsumption
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
module Dodge.Item.Weapon.Bezier
|
module Dodge.Item.Weapon.Bezier
|
||||||
( bezierGun
|
( bezierGun
|
||||||
|
, teleGun
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
@@ -16,14 +17,14 @@ import Dodge.RandomHelp
|
|||||||
import Dodge.SoundLogic.LoadSound
|
import Dodge.SoundLogic.LoadSound
|
||||||
import Geometry
|
import Geometry
|
||||||
--import ShapePicture
|
--import ShapePicture
|
||||||
|
import LensHelp
|
||||||
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Control.Lens
|
|
||||||
import Control.Monad.State
|
import Control.Monad.State
|
||||||
bezierGun :: Item
|
bezierGun :: Item
|
||||||
bezierGun = defaultGun
|
bezierGun = defaultGun
|
||||||
{ _itName = "B-GUN"
|
{ _itName = "BEZIERGUN"
|
||||||
, _itUse = ruseRate 6 (\_ -> useTargetPos $ \p -> shootBezier $ fromJust p) -- <- the start point
|
, _itUse = ruseRate 6 (\_ -> useTargetPos $ \p -> shootBezier $ fromJust p) -- <- the start point
|
||||||
NoHammer
|
NoHammer
|
||||||
[ ammoCheckI
|
[ ammoCheckI
|
||||||
, useTimeCheck
|
, useTimeCheck
|
||||||
@@ -43,21 +44,20 @@ bezierGun = defaultGun
|
|||||||
, _itEffect = rbSetTarget
|
, _itEffect = rbSetTarget
|
||||||
-- , _itZoom = defaultItZoom
|
-- , _itZoom = defaultItZoom
|
||||||
, _itConsumption = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _ammoBaseMax = 50
|
{ _ammoBaseMax = 15
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shootBezier :: Point2 -> Creature -> World -> World
|
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
|
where
|
||||||
theBullet = aCurveBulAt
|
|
||||||
(Just cid)
|
|
||||||
(V4 200 200 200 1)
|
|
||||||
startp
|
|
||||||
(controlp +.+ randPos)
|
|
||||||
(targetp +.+ randPos')
|
|
||||||
(destroyOnImpact bulHitCr bulHitWall)
|
|
||||||
5
|
|
||||||
controlp = mouseWorldPos w
|
controlp = mouseWorldPos w
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
@@ -66,3 +66,6 @@ shootBezier targetp cr w = w & particles %~ (theBullet :)
|
|||||||
a <- randInCirc 10
|
a <- randInCirc 10
|
||||||
b <- randInCirc 20
|
b <- randInCirc 20
|
||||||
return (a,b)
|
return (a,b)
|
||||||
|
|
||||||
|
teleGun :: Item
|
||||||
|
teleGun = bezierGun
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import Sound.Data
|
|||||||
import LensHelp
|
import LensHelp
|
||||||
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
--import qualified Data.Map.Strict as M
|
||||||
--import qualified Data.Sequence as Seq
|
--import qualified Data.Sequence as Seq
|
||||||
--import Control.Lens
|
--import Control.Lens
|
||||||
--import Control.Monad.State
|
--import Control.Monad.State
|
||||||
@@ -64,9 +65,9 @@ bangCane = defaultGun
|
|||||||
, useAmmoAmount 1
|
, useAmmoAmount 1
|
||||||
, torqueAfterI 0.1
|
, torqueAfterI 0.1
|
||||||
, applyInaccuracy
|
, applyInaccuracy
|
||||||
, withMuzFlareI
|
|
||||||
, withRecoilI 50
|
, withRecoilI 50
|
||||||
, withSmoke 1 black 20 200 5
|
, withSmoke 1 black 20 200 5
|
||||||
|
, withMuzFlareI
|
||||||
]
|
]
|
||||||
, _itTweaks = defaultBulletSelTweak
|
, _itTweaks = defaultBulletSelTweak
|
||||||
, _itDimension = ItemDimension
|
, _itDimension = ItemDimension
|
||||||
@@ -153,10 +154,7 @@ rifle = bangCane
|
|||||||
|
|
||||||
repeater :: Item
|
repeater :: Item
|
||||||
repeater = rifle
|
repeater = rifle
|
||||||
& itModules .~ ItemModules
|
& itModules . at ModRifleMag ?~ DefaultModule
|
||||||
{ _modHitEffect = DefaultModule
|
|
||||||
, _modRifleMag = DefaultModule
|
|
||||||
}
|
|
||||||
& itName .~ "REPEATER"
|
& itName .~ "REPEATER"
|
||||||
& itType .~ REPEATER
|
& itType .~ REPEATER
|
||||||
& itConsumption . reloadType .~ ActiveClear
|
& itConsumption . reloadType .~ ActiveClear
|
||||||
@@ -177,6 +175,7 @@ autoRifle = repeater
|
|||||||
& itName .~ "AUTORIFLE"
|
& itName .~ "AUTORIFLE"
|
||||||
& itType .~ AUTORIFLE
|
& itType .~ AUTORIFLE
|
||||||
& itUse . useMods %~ ((ammoCheckI :) . tail)
|
& itUse . useMods %~ ((ammoCheckI :) . tail)
|
||||||
|
& itModules . at ModAutoMag ?~ DefaultModule
|
||||||
-- & itUse . useDelay . rateMax .~ 6
|
-- & itUse . useDelay . rateMax .~ 6
|
||||||
burstRifle :: Item
|
burstRifle :: Item
|
||||||
burstRifle = repeater
|
burstRifle = repeater
|
||||||
@@ -218,7 +217,7 @@ completeBurstRifle :: Item
|
|||||||
completeBurstRifle = repeater
|
completeBurstRifle = repeater
|
||||||
& itName .~ "COMPLETEBURSTRIFLE"
|
& itName .~ "COMPLETEBURSTRIFLE"
|
||||||
& itType .~ COMPLETEBURSTRIFLE
|
& itType .~ COMPLETEBURSTRIFLE
|
||||||
& itModules . modRifleMag .~ BlockedModule
|
& itModules . at ModRifleMag .~ Nothing
|
||||||
& itParams . gunBarrels . brlInaccuracy .~ 0.1
|
& itParams . gunBarrels . brlInaccuracy .~ 0.1
|
||||||
& itUse . useDelay . rateMax .~ 28
|
& itUse . useDelay . rateMax .~ 28
|
||||||
& itUse . useMods .~
|
& itUse . useMods .~
|
||||||
|
|||||||
@@ -199,12 +199,14 @@ autoPistol = pistol
|
|||||||
& itUse . useMods .~ (ammoCheckI : pistolAfterHamMods)
|
& itUse . useMods .~ (ammoCheckI : pistolAfterHamMods)
|
||||||
& itName .~ "AUTOPISTOL"
|
& itName .~ "AUTOPISTOL"
|
||||||
& itType .~ AUTOPISTOL
|
& itType .~ AUTOPISTOL
|
||||||
|
& itModules . at ModAutoMag ?~ DefaultModule
|
||||||
machinePistol :: Item
|
machinePistol :: Item
|
||||||
machinePistol = autoPistol
|
machinePistol = autoPistol
|
||||||
& itUse . useDelay . rateMax .~ 2
|
& itUse . useDelay . rateMax .~ 2
|
||||||
& itUse . useMods .~ (ammoCheckI : machinePistolAfterHamMods)
|
& itUse . useMods .~ (ammoCheckI : machinePistolAfterHamMods)
|
||||||
& itName .~ "MACHINEPISTOL"
|
& itName .~ "MACHINEPISTOL"
|
||||||
& itType .~ MACHINEPISTOL
|
& itType .~ MACHINEPISTOL
|
||||||
|
& itModules . at ModAutoMag .~ Nothing
|
||||||
smg :: Item
|
smg :: Item
|
||||||
smg = autoPistol -- & some parameter affecting stability
|
smg = autoPistol -- & some parameter affecting stability
|
||||||
& itUse . useMods .~ (ammoCheckI : smgAfterHamMods)
|
& itUse . useMods .~ (ammoCheckI : smgAfterHamMods)
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ targetRBMousePos w = (f, \_ _ _ w' -> cursorPic w')
|
|||||||
where
|
where
|
||||||
f _ = Just mwp
|
f _ = Just mwp
|
||||||
mwp = mouseWorldPos w
|
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')
|
$ rotate (_cameraRot w')
|
||||||
$ pictures
|
$ pictures
|
||||||
[line [V2 x x, V2 (-x) (-x)]
|
[line [V2 x x, V2 (-x) (-x)]
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ module Dodge.Item.Weapon.InventoryDisplay
|
|||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Padding
|
import Padding
|
||||||
import Dodge.Inventory.ItemSpace
|
import Dodge.Inventory.ItemSpace
|
||||||
|
import Dodge.Module
|
||||||
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Sequence
|
import Data.Sequence
|
||||||
@@ -37,10 +38,7 @@ basicItemDisplay it = Prelude.take (itSlotsTaken it) $
|
|||||||
-- , maybeRateStatus
|
-- , maybeRateStatus
|
||||||
]
|
]
|
||||||
|
|
||||||
moduleStrings :: Item -> [String]
|
-- this can be moved to Dodge/Module and unified with moduleSizes
|
||||||
moduleStrings it = map (" " ++)
|
|
||||||
$ (fromMaybe [] $ it ^? itModules . modHitEffect . modName)
|
|
||||||
++ (fromMaybe [] $ it ^? itModules . modRifleMag . modName)
|
|
||||||
|
|
||||||
maybeModeStatus :: Item -> Maybe String
|
maybeModeStatus :: Item -> Maybe String
|
||||||
maybeModeStatus it = case it ^? itAttachment of
|
maybeModeStatus it = case it ^? itAttachment of
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ module Dodge.Item.Weapon.TriggerType
|
|||||||
, withSmoke
|
, withSmoke
|
||||||
, withThickSmokeI
|
, withThickSmokeI
|
||||||
, withThinSmokeI
|
, withThinSmokeI
|
||||||
|
, withPositionOffset
|
||||||
|
, withPositionWallCheck
|
||||||
|
, withPosDirWallCheck
|
||||||
, withRandomOffsetI
|
, withRandomOffsetI
|
||||||
, withRandomDirI
|
, withRandomDirI
|
||||||
, withRecoilI
|
, withRecoilI
|
||||||
@@ -51,6 +54,7 @@ module Dodge.Item.Weapon.TriggerType
|
|||||||
)
|
)
|
||||||
where
|
where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
|
import Dodge.Base.Collide
|
||||||
import Dodge.SoundLogic
|
import Dodge.SoundLogic
|
||||||
import Dodge.Reloading
|
import Dodge.Reloading
|
||||||
import Dodge.WorldEvent
|
import Dodge.WorldEvent
|
||||||
@@ -398,6 +402,30 @@ withRandomItemParams rip eff it cr w = eff (it & itParams .~ it') cr $ w & randG
|
|||||||
where
|
where
|
||||||
(it',g) = runState rip (_randGen w)
|
(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. -}
|
{- | Apply the effect to a translated creature. -}
|
||||||
withRandomOffsetI
|
withRandomOffsetI
|
||||||
:: Float -- ^ Max possible translate
|
:: Float -- ^ Max possible translate
|
||||||
|
|||||||
+10
-3
@@ -1,10 +1,17 @@
|
|||||||
module Dodge.Module
|
module Dodge.Module
|
||||||
where
|
( moduleSizes
|
||||||
|
, moduleStrings
|
||||||
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
|
||||||
moduleSizes :: Item -> Int
|
moduleSizes :: Item -> Int
|
||||||
moduleSizes it = (fromMaybe 0 $ it ^? itModules . modHitEffect . modSize)
|
moduleSizes = moduleFold (+) (^? modSize) 0
|
||||||
+ (fromMaybe 0 $ it ^? itModules . modRifleMag . modSize)
|
|
||||||
|
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
|
module Dodge.Reloading where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
import Dodge.Item.MaxAmmo
|
|
||||||
--import qualified Data.IntMap.Strict as IM
|
--import qualified Data.IntMap.Strict as IM
|
||||||
|
|
||||||
--import Data.Maybe
|
--import Data.Maybe
|
||||||
@@ -14,7 +13,7 @@ startReloadingWeapon cr = (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr)
|
|||||||
|
|
||||||
icTryStartReloading :: Item -> Maybe Item
|
icTryStartReloading :: Item -> Maybe Item
|
||||||
icTryStartReloading it
|
icTryStartReloading it
|
||||||
| _ammoLoaded am < itMaxAmmo it && _reloadState am == Nothing'
|
| _ammoLoaded am < _ammoBaseMax (_itConsumption it) && _reloadState am == Nothing'
|
||||||
= Just $ it & itConsumption . reloadState .~ Just' (_reloadTime am)
|
= Just $ it & itConsumption . reloadState .~ Just' (_reloadTime am)
|
||||||
& if _reloadType am == ActiveClear then itConsumption . ammoLoaded .~ 0 else id
|
& if _reloadType am == ActiveClear then itConsumption . ammoLoaded .~ 0 else id
|
||||||
| otherwise = Nothing
|
| otherwise = Nothing
|
||||||
@@ -36,14 +35,15 @@ stepReloading cr = case cr ^? crInv . ix isel . itConsumption . reloadState . _J
|
|||||||
isel = _crInvSel cr
|
isel = _crInvSel cr
|
||||||
doload it = case _reloadType itcon of
|
doload it = case _reloadType itcon of
|
||||||
ActivePartial x
|
ActivePartial x
|
||||||
| x + _ammoLoaded itcon < itMaxAmmo it -> it & itConsumption . ammoLoaded %~ (+ x)
|
| x + _ammoLoaded itcon < itMaxAmmo -> it & itConsumption . ammoLoaded %~ (+ x)
|
||||||
& itConsumption . reloadState .~ Just' (_reloadTime itcon)
|
& itConsumption . reloadState .~ Just' (_reloadTime itcon)
|
||||||
| otherwise -> it & itConsumption . ammoLoaded .~ itMaxAmmo it
|
| otherwise -> it & itConsumption . ammoLoaded .~ itMaxAmmo
|
||||||
& itConsumption . reloadState .~ Nothing'
|
& itConsumption . reloadState .~ Nothing'
|
||||||
_ -> it & itConsumption . ammoLoaded .~ itMaxAmmo it
|
_ -> it & itConsumption . ammoLoaded .~ itMaxAmmo
|
||||||
& itConsumption . reloadState .~ Nothing'
|
& itConsumption . reloadState .~ Nothing'
|
||||||
where
|
where
|
||||||
itcon = _itConsumption it
|
itcon = _itConsumption it
|
||||||
|
itMaxAmmo = _ammoBaseMax itcon
|
||||||
|
|
||||||
--{- | Start reloading if clip is empty. -}
|
--{- | Start reloading if clip is empty. -}
|
||||||
--crAutoReload :: Creature -> Creature
|
--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 $ second $ overPos (\(x,y,z) -> (x,y,z+d))
|
||||||
addDepth d = map $ overPos (\(V3 x y z) -> V3 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
|
setLayer :: Int -> Picture -> Picture
|
||||||
{-# INLINE setLayer #-}
|
{-# INLINE setLayer #-}
|
||||||
setLayer i = map f
|
setLayer i = map f
|
||||||
|
|||||||
Reference in New Issue
Block a user