Refactor creature ai
This commit is contained in:
+23
-22
@@ -59,7 +59,6 @@ pistol
|
||||
,teslaLauncher
|
||||
,remoteLauncher
|
||||
,bezierGun
|
||||
,poisonSprayer
|
||||
,defaultThrowable
|
||||
-- ,shatterGun
|
||||
,longGun,flamer,blinkGun,forceFieldGun :: Item
|
||||
@@ -88,7 +87,7 @@ pistol = Weapon
|
||||
, _itAimingSpeed = 1
|
||||
, _itAimingRange = 0
|
||||
, _itZoom = defaultItZoom
|
||||
, _itEquipPict = drawWeapon $ color green $ polygon $ rectNESW 3 3 (-3) (-3)
|
||||
, _itEquipPict = pictureWeaponOnAim $ color green $ polygon $ rectNESW 3 3 (-3) (-3)
|
||||
, _itScrollUp = const id
|
||||
, _itScrollDown = const id
|
||||
, _itAttachment = Nothing
|
||||
@@ -137,7 +136,7 @@ autoGun = defaultGun
|
||||
, _itAimingSpeed = 0.4
|
||||
, _itAimingRange = 1
|
||||
, _itZoom = defaultItZoom {_itAimZoomFac = 1.5}
|
||||
, _itEquipPict = drawWeapon $ color red $ polygon $ rectNESW 4 4 (-4) (-4)
|
||||
, _itEquipPict = pictureWeaponOnAim $ color red $ polygon $ rectNESW 4 4 (-4) (-4)
|
||||
, _itEffect = wpRecock
|
||||
, _itAttachment = Just $ ItCharMode $ Seq.fromList "MS"
|
||||
, _itScrollUp = incCharMode
|
||||
@@ -174,7 +173,7 @@ rezGun = defaultGun
|
||||
, _itMaxStack = 1
|
||||
, _itAimingSpeed = 0.4
|
||||
, _itAimingRange = 0
|
||||
, _itEquipPict = drawWeapon $ color chartreuse $ pictures
|
||||
, _itEquipPict = pictureWeaponOnAim $ color chartreuse $ pictures
|
||||
[polygon $ rectNESW 7 3 1 (-3)
|
||||
,polygon $ rectNESW (-1) 3 (-7) (-3)
|
||||
]
|
||||
@@ -200,7 +199,7 @@ teslaGun = defaultAutoGun
|
||||
, _itAimingSpeed = 0.4
|
||||
, _itZoom = defaultItZoom
|
||||
, _itAimingRange = 0
|
||||
, _itEquipPict = drawWeapon $ color blue $ pictures
|
||||
, _itEquipPict = pictureWeaponOnAim $ color blue $ pictures
|
||||
[polygon $ rectNESW 7 3 1 (-3)
|
||||
,polygon $ rectNESW (-1) 3 (-7) (-3)
|
||||
]
|
||||
@@ -222,7 +221,7 @@ lasGun = defaultAutoGun
|
||||
, _itMaxStack = 1
|
||||
, _itAimingSpeed = 0.4
|
||||
, _itAimingRange = 1
|
||||
, _itEquipPict = drawWeapon $ color blue $ polygon $ rectNESW 3 3 (-3) (-3)
|
||||
, _itEquipPict = pictureWeaponOnAim $ color blue $ polygon $ rectNESW 3 3 (-3) (-3)
|
||||
, _itAttachment = Just $ ItCharMode $ Seq.fromList "/VZ"
|
||||
, _itScrollUp = incCharMode
|
||||
, _itScrollDown = decCharMode
|
||||
@@ -282,7 +281,7 @@ tractorGun = defaultAutoGun
|
||||
, _itMaxStack = 1
|
||||
, _itAimingSpeed = 0.4
|
||||
, _itAimingRange = 0.5
|
||||
, _itEquipPict = drawWeapon $ color blue $ pictures [polygon $ rectNESW 1.5 6 (-1.5) 0 ]
|
||||
, _itEquipPict = pictureWeaponOnAim $ color blue $ pictures [polygon $ rectNESW 1.5 6 (-1.5) 0 ]
|
||||
}
|
||||
launcher = defaultGun
|
||||
{ _itName = "ROCKO"
|
||||
@@ -301,7 +300,7 @@ launcher = defaultGun
|
||||
, _itMaxStack = 1
|
||||
, _itAimingSpeed = 0.2
|
||||
, _itAimingRange = 0.5
|
||||
, _itEquipPict = drawWeapon $ color cyan $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
, _itEquipPict = pictureWeaponOnAim $ color cyan $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
, _itHammer = NoHammer
|
||||
, _itEffect = NoItEffect
|
||||
}
|
||||
@@ -390,7 +389,7 @@ remoteLauncher = defaultGun
|
||||
, _itMaxStack = 1
|
||||
, _itAimingSpeed = 0.2
|
||||
, _itAimingRange = 0.5
|
||||
, _itEquipPict = drawWeapon $ color cyan $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
, _itEquipPict = pictureWeaponOnAim $ color cyan $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
, _itAttachment = Just $ ItScope (0,0) 0 1 True
|
||||
}
|
||||
hvAutoGun = defaultAutoGun
|
||||
@@ -409,7 +408,7 @@ hvAutoGun = defaultAutoGun
|
||||
, _itMaxStack = 1
|
||||
, _itAimingSpeed = 0.2
|
||||
, _itAimingRange = 1
|
||||
, _itEquipPict = drawWeapon $ color orange $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
, _itEquipPict = pictureWeaponOnAim $ color orange $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
}
|
||||
where
|
||||
mkHvBul = withSound (fromIntegral longGunSound)
|
||||
@@ -439,7 +438,7 @@ ltAutoGun = defaultAutoGun
|
||||
, _itAimingSpeed = 1
|
||||
, _itAimingRange = 0
|
||||
, _itZoom = defaultItZoom
|
||||
, _itEquipPict = drawWeapon $ color green $ pictures [polygon $ rectNSWE 4 (-4) (-4) 0
|
||||
, _itEquipPict = pictureWeaponOnAim $ color green $ pictures [polygon $ rectNSWE 4 (-4) (-4) 0
|
||||
,circleSolid 4
|
||||
]
|
||||
}
|
||||
@@ -464,7 +463,7 @@ miniGun = defaultAutoGun
|
||||
, _itMaxStack = 1
|
||||
, _itAimingSpeed = 0.4
|
||||
, _itAimingRange = 1
|
||||
, _itEquipPict = drawWeapon $ color red $ polygon $ rectNESW 9 5 (-9) (-5)
|
||||
, _itEquipPict = pictureWeaponOnAim $ color red $ polygon $ rectNESW 9 5 (-9) (-5)
|
||||
}
|
||||
spreadGun = defaultGun
|
||||
{ _itName = "SPREAD"
|
||||
@@ -486,7 +485,7 @@ spreadGun = defaultGun
|
||||
, _itMaxStack = 1
|
||||
, _itAimingSpeed = 1
|
||||
, _itAimingRange = 0
|
||||
, _itEquipPict = drawWeapon $ color green $ pictures [ polygon [(-3,0),(3,6),(3,-6)] ]
|
||||
, _itEquipPict = pictureWeaponOnAim $ color green $ pictures [ polygon [(-3,0),(3,6),(3,-6)] ]
|
||||
}
|
||||
multGun = defaultGun
|
||||
{ _itName = "MULTGUN"
|
||||
@@ -509,7 +508,7 @@ multGun = defaultGun
|
||||
, _itAimingSpeed = 0.4
|
||||
, _itAimingRange = 1
|
||||
, _itZoom = defaultItZoom {_itAimZoomFac = 1.5}
|
||||
, _itEquipPict = drawWeapon multGunPic
|
||||
, _itEquipPict = pictureWeaponOnAim multGunPic
|
||||
}
|
||||
where
|
||||
multGunPic = color red $ pictures
|
||||
@@ -542,7 +541,7 @@ longGun = defaultGun
|
||||
, _itAimingSpeed = 0.2
|
||||
, _itAimingRange = 1
|
||||
, _itZoom = defaultItZoom {_itAimZoomMax = 0.5, _itAimZoomMin = 0.5}
|
||||
, _itEquipPict = drawWeapon $ pictures [color orange $ polygon $ rectNESW 3 6 (-3) (-6) ]
|
||||
, _itEquipPict = pictureWeaponOnAim $ pictures [color orange $ polygon $ rectNESW 3 6 (-3) (-6) ]
|
||||
, _itScrollUp = startZoomInLongGun
|
||||
, _itScrollDown = startZoomOutLongGun
|
||||
, _itAttachment = Just $ ItScope (0,0) 0 1 False
|
||||
@@ -556,6 +555,7 @@ startZoomOutLongGun :: Int -> World -> World
|
||||
startZoomOutLongGun _ w = w & creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
||||
. itAttachment . _Just . scopeZoomChange %~ \x -> min (-5) (x-5)
|
||||
|
||||
poisonSprayer :: Item
|
||||
poisonSprayer = defaultAutoGun
|
||||
{ _itName = "POISON"
|
||||
, _itIdentity = PoisonSprayer
|
||||
@@ -574,7 +574,7 @@ poisonSprayer = defaultAutoGun
|
||||
, _itAimingSpeed = 0.2
|
||||
, _itAimingRange = 0
|
||||
, _itZoom = defaultItZoom
|
||||
, _itEquipPict = drawWeapon $ color yellow $ polygon $ rectNESW 4 4 (-4) (-4)
|
||||
, _itEquipPict = pictureWeaponOnAim $ color yellow $ polygon $ rectNESW 4 4 (-4) (-4)
|
||||
}
|
||||
|
||||
flamer = defaultAutoGun
|
||||
@@ -595,7 +595,7 @@ flamer = defaultAutoGun
|
||||
, _itAimingSpeed = 0.5
|
||||
, _itAimingRange = 0
|
||||
, _itZoom = defaultItZoom {_itAimZoomMax = 5, _itAimZoomMin = 1.5}
|
||||
, _itEquipPict = drawWeapon $ color yellow $ polygon $ rectNESW 4 4 (-4) (-4)
|
||||
, _itEquipPict = pictureWeaponOnAim $ color yellow $ polygon $ rectNESW 4 4 (-4) (-4)
|
||||
, _itAttachment = Nothing
|
||||
}
|
||||
blinkGun = defaultGun
|
||||
@@ -873,7 +873,7 @@ grenade = Throwable
|
||||
, _itAimingSpeed = 1
|
||||
, _itAimingRange = 0
|
||||
, _itZoom = defaultItZoom {_itAimZoomMax = f fuseTime, _itAimZoomMin = f fuseTime}
|
||||
, _itEquipPict = drawWeapon $ grenadePic fuseTime
|
||||
, _itEquipPict = pictureWeaponOnAim $ grenadePic fuseTime
|
||||
, _itID = Nothing
|
||||
, _itUseRate = 50
|
||||
, _itUseTime = 0
|
||||
@@ -918,7 +918,7 @@ remoteBomb = defaultThrowable
|
||||
, _twAccuracy = 30
|
||||
, _twFire = hammerCheck throwRemoteBomb
|
||||
, _itAttachment = Just $ ItScope (0,0) 0 1 True
|
||||
, _itEquipPict = drawWeapon remoteBombUnarmedPic
|
||||
, _itEquipPict = pictureWeaponOnAim remoteBombUnarmedPic
|
||||
}
|
||||
|
||||
|
||||
@@ -1099,7 +1099,7 @@ explodeRemoteBomb itid pjid n w
|
||||
where
|
||||
resetName = set (creatures . ix n . crInv . ix j . itName) "REMOTEBOMB"
|
||||
resetPict = set (creatures . ix n . crInv . ix j . itEquipPict )
|
||||
(drawWeapon remoteBombUnarmedPic)
|
||||
(pictureWeaponOnAim remoteBombUnarmedPic)
|
||||
-- resetScope = creatures . ix n . crInv . ix j . itScope . _Just . scopePos .~ (0,0)
|
||||
j = _crInvSel $ _creatures w IM.! n
|
||||
remoteBombPic
|
||||
@@ -1148,7 +1148,7 @@ radar = defaultGun
|
||||
, _itMaxStack = 1
|
||||
, _itAimingRange = 1
|
||||
, _itZoom = defaultItZoom {_itAimZoomMax = 1, _itZoomMax = 1}
|
||||
, _itEquipPict = drawWeapon $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
, _itEquipPict = pictureWeaponOnAim $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
}
|
||||
{- |
|
||||
Sends out pulses that display creatures. -}
|
||||
@@ -1170,7 +1170,7 @@ sonar = defaultGun
|
||||
, _itMaxStack = 1
|
||||
, _itAimingRange = 1
|
||||
, _itZoom = defaultItZoom {_itAimZoomMax = 1, _itZoomMax = 1}
|
||||
, _itEquipPict = drawWeapon $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
, _itEquipPict = pictureWeaponOnAim $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
}
|
||||
{- |
|
||||
Automatically sends out pulses that display creatures. -}
|
||||
@@ -1229,3 +1229,4 @@ spawnCrNextTo cr i w = w & creatures %~ IM.insert k newCr
|
||||
& crID .~ k
|
||||
& crPos .~ _crPos sCr +.+ unitVectorAtAngle (_crDir sCr)
|
||||
& crOldPos .~ _crPos sCr +.+ unitVectorAtAngle (_crDir sCr)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user