Cleanup, slight improvements to item location references
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
|||||||
All good (620 modules, at 21:50:15)
|
All good (620 modules, at 22:05:15)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ data Huse
|
|||||||
-- | HeldLaser
|
-- | HeldLaser
|
||||||
-- | HeldCircleLaser
|
-- | HeldCircleLaser
|
||||||
-- | HeldDualLaser
|
-- | HeldDualLaser
|
||||||
| HeldTractor
|
-- | HeldTractor
|
||||||
| HeldForceField
|
| HeldForceField
|
||||||
| HeldShatter
|
| HeldShatter
|
||||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ bulGunEffect' t cr w = fromMaybe (error "error in bulGunEffect") $ do
|
|||||||
& doWeaponRepetitions upitm cr
|
& doWeaponRepetitions upitm cr
|
||||||
-- & cWorld . lWorld . lTestInt +~ 1
|
-- & cWorld . lWorld . lTestInt +~ 1
|
||||||
|
|
||||||
|
-- need to be careful about inventory lock or item ids here
|
||||||
doWeaponRepetitions :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
doWeaponRepetitions :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||||
doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponRepeat of
|
doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponRepeat of
|
||||||
Just (x:xs) -> cWorld . lWorld . delayedEvents .++~ ((x:xs) <&> (,WdWdFromItCrixWdWd upitm (_crID cr) ItCrWdItemEffect))
|
Just (x:xs) -> cWorld . lWorld . delayedEvents .++~ ((x:xs) <&> (,WdWdFromItCrixWdWd upitm (_crID cr) ItCrWdItemEffect))
|
||||||
@@ -218,18 +219,17 @@ walkNozzle mzid mz itm cr w = fromMaybe w $ do
|
|||||||
|
|
||||||
|
|
||||||
shootTractorBeam :: Item -> Creature -> World -> World
|
shootTractorBeam :: Item -> Creature -> World -> World
|
||||||
shootTractorBeam _ cr w = w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt' spos outpos dir power
|
shootTractorBeam itm cr w = w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt spos outpos dir power
|
||||||
where
|
where
|
||||||
cpos = _crPos cr
|
cpos = _crPos cr
|
||||||
spos = cpos +.+ (_crRad cr + 10) *.* unitVectorAtAngle dir
|
spos = cpos +.+ (_crRad cr + 10) *.* unitVectorAtAngle dir
|
||||||
xpos = cpos +.+ 400 *.* unitVectorAtAngle dir
|
xpos = cpos +.+ 400 *.* unitVectorAtAngle dir
|
||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
outpos = fst $ collidePointWallsFilter (const True) cpos xpos w
|
outpos = fst $ collidePointWallsFilter (const True) cpos xpos w
|
||||||
power = _attractionPower . _itParams $ _crInv cr IM.! itRef
|
power = _attractionPower . _itParams $ itm
|
||||||
itRef = cr ^?! crManipulation . manObject . imRootItem -- unsafe!! TODO change
|
|
||||||
|
|
||||||
tractorBeamAt' :: Point2 -> Point2 -> Float -> Point2 -> TractorBeam
|
tractorBeamAt :: Point2 -> Point2 -> Float -> Point2 -> TractorBeam
|
||||||
tractorBeamAt' pos outpos dir power =
|
tractorBeamAt pos outpos dir power =
|
||||||
TractorBeam
|
TractorBeam
|
||||||
{ _tbPos = pos
|
{ _tbPos = pos
|
||||||
, _tbStartPos = outpos
|
, _tbStartPos = outpos
|
||||||
@@ -316,7 +316,7 @@ useHeld hu = case hu of
|
|||||||
-- HeldLaser -> shootLaser . _ldtValue
|
-- HeldLaser -> shootLaser . _ldtValue
|
||||||
-- HeldCircleLaser -> circleLaser . _ldtValue
|
-- HeldCircleLaser -> circleLaser . _ldtValue
|
||||||
-- HeldDualLaser -> shootDualLaser . _ldtValue
|
-- HeldDualLaser -> shootDualLaser . _ldtValue
|
||||||
HeldTractor -> aTractorBeam . _ldtValue
|
-- HeldTractor -> aTractorBeam . _ldtValue
|
||||||
-- HeldSonicWave -> aSonicWave
|
-- HeldSonicWave -> aSonicWave
|
||||||
HeldForceField -> useForceFieldGun . _ldtValue
|
HeldForceField -> useForceFieldGun . _ldtValue
|
||||||
HeldShatter -> shootShatter . _ldtValue
|
HeldShatter -> shootShatter . _ldtValue
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ module Dodge.Item.Weapon.BatteryGuns (
|
|||||||
shootLaser,
|
shootLaser,
|
||||||
--circleLaser,
|
--circleLaser,
|
||||||
--shootDualLaser,
|
--shootDualLaser,
|
||||||
aTractorBeam,
|
-- aTractorBeam,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Dodge.Base
|
--import Dodge.Base
|
||||||
import Dodge.Beam
|
import Dodge.Beam
|
||||||
--import Dodge.Creature.HandPos
|
--import Dodge.Creature.HandPos
|
||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
--import Dodge.Item.Weapon.LaserPath
|
--import Dodge.Item.Weapon.LaserPath
|
||||||
import Geometry
|
--import Geometry
|
||||||
--import qualified IntMapHelp as IM
|
--import qualified IntMapHelp as IM
|
||||||
import LensHelp
|
import LensHelp
|
||||||
--import Picture
|
--import Picture
|
||||||
@@ -146,23 +146,23 @@ shootLaser it cr =
|
|||||||
-- basicBeamAt itid w col dam phasev pos dir
|
-- basicBeamAt itid w col dam phasev pos dir
|
||||||
-- & bmType .~ bt
|
-- & bmType .~ bt
|
||||||
|
|
||||||
aTractorBeam :: Item -> Creature -> World -> World
|
--aTractorBeam :: Item -> Creature -> World -> World
|
||||||
aTractorBeam itm cr w = w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt spos outpos dir power
|
--aTractorBeam itm cr w = w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt spos outpos dir power
|
||||||
where
|
-- where
|
||||||
cpos = _crPos cr
|
-- cpos = _crPos cr
|
||||||
spos = cpos +.+ (_crRad cr + 10) *.* unitVectorAtAngle dir
|
-- spos = cpos +.+ (_crRad cr + 10) *.* unitVectorAtAngle dir
|
||||||
xpos = cpos +.+ 400 *.* unitVectorAtAngle dir
|
-- xpos = cpos +.+ 400 *.* unitVectorAtAngle dir
|
||||||
dir = _crDir cr
|
-- dir = _crDir cr
|
||||||
outpos = fst $ collidePointWallsFilter (const True) cpos xpos w
|
-- outpos = fst $ collidePointWallsFilter (const True) cpos xpos w
|
||||||
power = _attractionPower . _itParams $ itm
|
-- power = _attractionPower . _itParams $ itm
|
||||||
|
--
|
||||||
tractorBeamAt :: Point2 -> Point2 -> Float -> Point2 -> TractorBeam
|
--tractorBeamAt :: Point2 -> Point2 -> Float -> Point2 -> TractorBeam
|
||||||
tractorBeamAt pos outpos dir power =
|
--tractorBeamAt pos outpos dir power =
|
||||||
TractorBeam
|
-- TractorBeam
|
||||||
{ _tbPos = pos
|
-- { _tbPos = pos
|
||||||
, _tbStartPos = outpos
|
-- , _tbStartPos = outpos
|
||||||
, _tbVel = d
|
-- , _tbVel = d
|
||||||
, _tbTime = 10
|
-- , _tbTime = 10
|
||||||
}
|
-- }
|
||||||
where
|
-- where
|
||||||
d = unitVectorAtAngle dir * power
|
-- d = unitVectorAtAngle dir * power
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ module Dodge.Item.Weapon.TriggerType (
|
|||||||
withPositionOffset,
|
withPositionOffset,
|
||||||
withPositionWallCheck,
|
withPositionWallCheck,
|
||||||
withPosDirWallCheck,
|
withPosDirWallCheck,
|
||||||
withWarmUp,
|
--withWarmUp,
|
||||||
hammerCheckL,
|
hammerCheckL,
|
||||||
hammerCheck,
|
hammerCheck,
|
||||||
shootL,
|
shootL,
|
||||||
@@ -173,31 +173,6 @@ itUseCharge x = itUse . leftConsumption . arLoaded %~ (max 0 . subtract x)
|
|||||||
-- repeatFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item')) == 1
|
-- repeatFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item')) == 1
|
||||||
-- firstFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item')) == 0
|
-- firstFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item')) == 0
|
||||||
|
|
||||||
-- | Apply effect after a warm up.
|
|
||||||
|
|
||||||
-- note this is quite unsafe, requires the item to have the correct delay type
|
|
||||||
withWarmUp ::
|
|
||||||
-- | warm up sound id
|
|
||||||
SoundID ->
|
|
||||||
ChainEffect
|
|
||||||
withWarmUp soundID f item cr w
|
|
||||||
-- | curWarmUp < maxWarmUp && crWeaponReady cr =
|
|
||||||
| curWarmUp < maxWarmUp =
|
|
||||||
w
|
|
||||||
& pointertoitem . itUse . heldDelay . warmTime +~ 2
|
|
||||||
& soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2)
|
|
||||||
| otherwise =
|
|
||||||
w
|
|
||||||
& pointertoitem . itUse . heldDelay . warmTime .~ (maxWarmUp + 1)
|
|
||||||
& f item cr
|
|
||||||
where
|
|
||||||
item' = _ldtValue item
|
|
||||||
cid = _crID cr
|
|
||||||
itRef = cr ^?! crManipulation . manObject . imRootItem -- unsafe!! TODO change
|
|
||||||
pointertoitem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
|
|
||||||
curWarmUp = _warmTime . _heldDelay $ _itUse item'
|
|
||||||
maxWarmUp = _warmMax . _heldDelay $ _itUse item'
|
|
||||||
|
|
||||||
withSoundItemChoiceStart ::
|
withSoundItemChoiceStart ::
|
||||||
(Item -> SoundID) ->
|
(Item -> SoundID) ->
|
||||||
ChainEffect
|
ChainEffect
|
||||||
@@ -284,8 +259,9 @@ useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
|
|||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
setUseRate = cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTime
|
setUseRate = cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTime
|
||||||
+~ userate
|
+~ userate
|
||||||
-- this should use the ITEMS invid location!
|
-- the following is unsafe, but if ilInvID isn't correctly set we probably
|
||||||
itRef = cr ^?! crManipulation . manObject . imRootItem -- unsafe!! TODO change
|
-- will have problems elsewhere also
|
||||||
|
itRef = item ^?! ldtValue . itLocation . ilInvID
|
||||||
userate = fromMaybe 0 $ item ^? ldtValue . itUse . heldDelay . rateMax
|
userate = fromMaybe 0 $ item ^? ldtValue . itUse . heldDelay . rateMax
|
||||||
|
|
||||||
-- | Applies a world effect after a hammer position check.
|
-- | Applies a world effect after a hammer position check.
|
||||||
|
|||||||
Reference in New Issue
Block a user