Compare commits
2 Commits
1a746adad2
...
60e5e6ecae
| Author | SHA1 | Date | |
|---|---|---|---|
| 60e5e6ecae | |||
| b34a9f5b09 |
@@ -29,8 +29,6 @@ updateBullet w bu = case _buDelayFraction bu of
|
||||
|
||||
mvBullet :: Float -> World -> Bullet -> (World, Maybe Bullet)
|
||||
mvBullet x w bu
|
||||
-- | magV (_buVel bu) < 1 = (w, Nothing)
|
||||
-- | _buTimer bu <= 0 = (endspawn w, Nothing)
|
||||
| magV (_buVel bu) < 1 || _buTimer bu <= 0 = (endspawn w, Nothing)
|
||||
| otherwise =
|
||||
second (fmap updateBulVel)
|
||||
|
||||
@@ -56,5 +56,5 @@ chaseCritVocalization =
|
||||
, seagullCry1S
|
||||
, seagullCry2S
|
||||
]
|
||||
50
|
||||
(50,100)
|
||||
0
|
||||
|
||||
@@ -39,7 +39,7 @@ followImpulse cr w imp = case imp of
|
||||
RandomImpulse rimp ->
|
||||
let (newimp, newgen) = runState (doRandImpulse rimp) (_randGen w)
|
||||
in first ((randGen .~ newgen) .) $ followImpulse cr w newimp
|
||||
Bark sid -> (soundStart (CrMouth cid) cpos sid Nothing, resetCrVocCoolDown cr)
|
||||
Bark sid -> (soundStart (CrMouth cid) cpos sid Nothing, resetCrVocCoolDown w cr)
|
||||
Move p -> crup $ crMvBy p cr
|
||||
MoveForward x -> crup $ crMvForward x cr
|
||||
Turn a -> crup $ creatureTurn a cr
|
||||
@@ -83,6 +83,6 @@ followImpulse cr w imp = case imp of
|
||||
rr a = randomR (- a, a) $ _randGen w
|
||||
hitCr i =
|
||||
( cWorld . lWorld . creatures . ix i . crState . csDamage
|
||||
.:~ Damage BLUNT 100 cpos (posFromID i) (posFromID i) (PushBackDamage 3)
|
||||
.:~ Damage BLUNT 100 cpos (posFromID i) (posFromID i) (PushBackDamage 5)
|
||||
)
|
||||
. soundStart (CrSound cid) cpos hitS Nothing
|
||||
|
||||
@@ -80,7 +80,7 @@ chaseCritAwarenessUpdate w cr = case _cpAttention $ _crPerception cr of
|
||||
oldAwareness = _cpAwareness $ _crPerception cr
|
||||
newAwareness = (IM.mapMaybe decreaseAwareness . IM.unionWith combineAwareness is) oldAwareness
|
||||
becomesCognizant = any isCognizant $ IM.unionWith cogRaised oldAwareness newAwareness
|
||||
thejitter = RandImpulseCircMove 2
|
||||
thejitter = RandImpulseCircMove 3
|
||||
maybeBark
|
||||
| becomesCognizant -- && randBool
|
||||
&& cr ^? crVocalization . vcCoolDown == Just 0 =
|
||||
|
||||
@@ -14,12 +14,13 @@ module Dodge.Creature.ReaderUpdate (
|
||||
setViewPos,
|
||||
) where
|
||||
|
||||
import RandomHelp
|
||||
import Dodge.Creature.Perception
|
||||
import qualified IntMapHelp as IM
|
||||
import Data.List (sortOn)
|
||||
import Control.Applicative
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import LensHelp
|
||||
--import Control.Monad
|
||||
import Data.Bifunctor
|
||||
import Data.Maybe
|
||||
import Dodge.Base
|
||||
@@ -114,11 +115,22 @@ chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
|
||||
StrategyActions _ _ -> cr
|
||||
WarningCry -> cr
|
||||
MeleeStrike -> cr
|
||||
CloseToMelee cid | Just 0 == (cr ^? crVocalization . vcCoolDown)
|
||||
-> cr & crActionPlan . apAction
|
||||
.:~ ImpulsesList ( [Bark soundid] : replicate numjits [RandomImpulse thejitter]
|
||||
++ [[ChangeStrategy (CloseToMelee cid)]])
|
||||
& crVocalization . vcCoolDown .~ 10
|
||||
& crActionPlan . apStrategy .~ WarningCry
|
||||
where
|
||||
thejitter = RandImpulseCircMove 3
|
||||
soundid = evalState (takeOne (_vcWarnings (_crVocalization cr))) (_randGen w)
|
||||
numjits = fst $ randomR (15, 25) (_randGen w)
|
||||
_ -> case cr ^? crIntention . mvToPoint . _Just of
|
||||
Just p
|
||||
| dist (_crPos cr) p > _crRad cr -> cr & crActionPlan . apAction .~ [PathTo p]
|
||||
| otherwise ->
|
||||
cr & crActionPlan . apAction .~ [bfsThenReturn 500]
|
||||
cr & crActionPlan . apAction .~ [bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]]
|
||||
& crActionPlan . apStrategy .~ WatchAndWait
|
||||
& crIntention . mvToPoint .~ Nothing
|
||||
_ -> viewTarget w cr
|
||||
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
module Dodge.Creature.Vocalization where
|
||||
|
||||
import Control.Lens
|
||||
import Dodge.Data.Creature
|
||||
import Dodge.Data.World
|
||||
import Sound.Data
|
||||
import System.Random
|
||||
|
||||
vocalizationTest :: Creature -> Maybe SoundID
|
||||
vocalizationTest cr = case cr ^? crVocalization . vcCoolDown of
|
||||
Just 0 -> Just $ _vcSound $ _crVocalization cr
|
||||
_ -> Nothing
|
||||
|
||||
resetCrVocCoolDown :: Creature -> Creature
|
||||
resetCrVocCoolDown cr = case cr ^? crVocalization . vcMaxCoolDown of
|
||||
Just i -> cr & crVocalization . vcCoolDown .~ i
|
||||
resetCrVocCoolDown :: World -> Creature -> Creature
|
||||
resetCrVocCoolDown w cr = case cr ^? crVocalization . vcMaxCoolDown of
|
||||
Just (i,j) -> cr & crVocalization . vcCoolDown .~ x
|
||||
where
|
||||
x = fst $ randomR (i,j) (_randGen w)
|
||||
Nothing -> cr
|
||||
|
||||
@@ -29,7 +29,7 @@ data Vocalization
|
||||
| Vocalization
|
||||
{ _vcSound :: SoundID
|
||||
, _vcWarnings :: [SoundID]
|
||||
, _vcMaxCoolDown :: Int
|
||||
, _vcMaxCoolDown :: (Int, Int)
|
||||
, _vcCoolDown :: Int
|
||||
}
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
@@ -70,6 +70,8 @@ debugSelectCreatureList cid u =
|
||||
(u ^? uvWorld . cWorld . lWorld . creatures . ix cid . crMemory)
|
||||
, debugList "Strategy"
|
||||
(u ^? uvWorld . cWorld . lWorld . creatures . ix cid . crActionPlan . apStrategy)
|
||||
, debugList "Vocalization"
|
||||
(u ^? uvWorld . cWorld . lWorld . creatures . ix cid . crVocalization)
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ defaultLoadable =
|
||||
}
|
||||
|
||||
defaultBulletLoadable :: HeldConsumption
|
||||
defaultBulletLoadable = defaultLoadable & laAmmoType .~ basicBullet
|
||||
defaultBulletLoadable = defaultLoadable & laAmmoType .~ basicBulletAmmo
|
||||
|
||||
defaultLeftLoadable :: LeftConsumption
|
||||
defaultLeftLoadable = AutoRecharging 10 10 100 100
|
||||
|
||||
@@ -23,6 +23,7 @@ updateHumanoid cr = case cr ^?! crType . humanoidAI of
|
||||
, targetYouWhenCognizant
|
||||
, const searchIfDamaged
|
||||
, const (crMeleeCooldown %~ max 0 . subtract 1)
|
||||
, const (crVocalization . vcCoolDown %~ max 0 . subtract 1)
|
||||
]
|
||||
cr
|
||||
SpreadGunAI ->
|
||||
|
||||
@@ -40,7 +40,7 @@ bangRod =
|
||||
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
|
||||
& itUse . heldAim . aimHandlePos .~ 5
|
||||
& itUse . heldAim . aimMuzPos .~ 30
|
||||
& itUse . heldConsumption . laAmmoType .~ hvBullet
|
||||
& itUse . heldConsumption . laAmmoType .~ hvBulletAmmo
|
||||
|
||||
elephantGun :: Item
|
||||
elephantGun =
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module Dodge.Item.Weapon.Bullet (
|
||||
basicBullet,
|
||||
hvBullet,
|
||||
basicBulletAmmo,
|
||||
hvBulletAmmo,
|
||||
defaultBullet,
|
||||
) where
|
||||
|
||||
@@ -8,8 +8,8 @@ import Dodge.Data.Item.Use.Consumption.Ammo
|
||||
import Control.Lens
|
||||
import Geometry.Data
|
||||
|
||||
basicBullet :: AmmoType
|
||||
basicBullet =
|
||||
basicBulletAmmo :: AmmoType
|
||||
basicBulletAmmo =
|
||||
BulletAmmo
|
||||
{ _amString = "BASIC"
|
||||
, _amBullet = defaultBullet
|
||||
@@ -37,8 +37,8 @@ basicBulDams =
|
||||
[ Damage PIERCING 100 0 0 0 $ PushBackDamage 2
|
||||
]
|
||||
|
||||
hvBullet :: AmmoType
|
||||
hvBullet =
|
||||
hvBulletAmmo :: AmmoType
|
||||
hvBulletAmmo =
|
||||
BulletAmmo
|
||||
{ _amString = "HVBULLET"
|
||||
, _amBullet =
|
||||
|
||||
@@ -14,8 +14,6 @@ damageMaterial dm mt = case mt of
|
||||
Stone -> damageStone dm
|
||||
_ -> defDamageMaterial dm
|
||||
|
||||
-- Glass -> damageGlass dm
|
||||
|
||||
defDamageMaterial :: Damage -> Float -> World -> (Int, World)
|
||||
defDamageMaterial dm _ w = (_dmAmount dm, w)
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
module Dodge.Particle.Damage where
|
||||
|
||||
import Dodge.Data.Bullet
|
||||
import Geometry
|
||||
|
||||
simpleDam' :: DamageType -> Int -> Bullet -> Point2 -> [Damage]
|
||||
simpleDam' dt amount bt p = [Damage dt amount sp p ep NoDamageEffect]
|
||||
where
|
||||
sp = _buPos bt
|
||||
bulVel = _buVel bt
|
||||
ep = sp +.+ bulVel
|
||||
|
||||
hvBulDams :: [Damage]
|
||||
hvBulDams =
|
||||
[ Damage PIERCING 25 0 0 0 NoDamageEffect
|
||||
, Damage PIERCING 25 0 0 0 NoDamageEffect
|
||||
, Damage PIERCING 25 0 0 0 NoDamageEffect
|
||||
, Damage PIERCING 25 0 0 0 NoDamageEffect
|
||||
, Damage PIERCING 25 0 0 0 $ TorqueDamage 0.7
|
||||
, Damage PIERCING 25 0 0 0 $ PushBackDamage 3
|
||||
]
|
||||
@@ -58,7 +58,6 @@ makePathBetweenPs a b w = mapMaybe (lab $ w ^. cWorld . pathGraph) <$> makePathB
|
||||
bfsNodePoints :: Int -> World -> [Point2]
|
||||
bfsNodePoints n w = mapMaybe (lab g) $ bfs n g
|
||||
where
|
||||
--g = _pathGraph (_cWorld w)
|
||||
g = w ^. cWorld . pathGraph
|
||||
|
||||
pointTowardsImpulse :: Point2 -> Point2 -> World -> Maybe Point2
|
||||
|
||||
+1
-1
@@ -295,7 +295,7 @@ advanceScrollAmount u =
|
||||
|
||||
updatePastWorlds :: World -> World
|
||||
--updatePastWorlds w = w & pastWorlds %~ (forceFoldable . take 100 . ((w ^. cWorld . lWorld) :))
|
||||
updatePastWorlds w = w & pastWorlds %~ (forceFoldable . take 300 . ((w ^. cWorld . lWorld) :))
|
||||
updatePastWorlds w = w & pastWorlds %~ (forceFoldable . take 600 . ((w ^. cWorld . lWorld) :))
|
||||
|
||||
doWorldEvents :: World -> World
|
||||
doWorldEvents w =
|
||||
|
||||
Reference in New Issue
Block a user