155 lines
4.5 KiB
Haskell
155 lines
4.5 KiB
Haskell
module Dodge.Item.Weapon.SprayGuns
|
|
( poisonSprayer
|
|
, flamer
|
|
, flameStick
|
|
, blowTorch
|
|
, flameThrower
|
|
, flameWall
|
|
) where
|
|
import Dodge.Data
|
|
--import Dodge.Data.SoundOrigin
|
|
--import Dodge.Base
|
|
--import Dodge.Zone
|
|
--import Dodge.Picture.Layer
|
|
--import Dodge.SoundLogic
|
|
import Dodge.SoundLogic.LoadSound
|
|
--import Dodge.Creature.Action
|
|
import Dodge.WorldEvent
|
|
import Dodge.Default
|
|
--import Dodge.Item.Weapon.BulletGuns
|
|
--import Dodge.Item.Weapon.InventoryDisplay
|
|
import Dodge.Item.Weapon.TriggerType
|
|
--import Dodge.Item.Weapon.ExtraEffect
|
|
--import Dodge.Item.Weapon.UseEffect
|
|
import Dodge.Item.Weapon.AmmoParams
|
|
import Dodge.Default.Weapon
|
|
--import Dodge.Item.Attachment
|
|
import Geometry
|
|
--import Geometry.Vector3D
|
|
import Picture
|
|
import Shape
|
|
import ShapePicture
|
|
import LensHelp
|
|
|
|
import Data.Traversable
|
|
import qualified Data.IntMap.Strict as IM
|
|
--import Data.Function
|
|
import System.Random
|
|
poisonSprayer :: Item
|
|
poisonSprayer = defaultAutoGun
|
|
{ _itName = "POISON"
|
|
, _itType = SPRAYER
|
|
, _itConsumption = defaultAmmo
|
|
{ _ammoBaseMax = 500
|
|
, _ammoLoaded = 500
|
|
, _reloadTime = 100
|
|
}
|
|
, _itUse = ruseInstant (const aGasCloud) NoHammer
|
|
[ ammoCheckI
|
|
, withSoundForI foamSprayLoopS 5
|
|
, useAmmoAmount 1
|
|
-- , spreadNumI
|
|
]
|
|
& useAim . aimSpeed .~ 0.2
|
|
& useAim . aimRange .~ 0
|
|
& useAim . aimStance .~ TwoHandTwist
|
|
, _itParams = Sprayer
|
|
{ _nozzleSpread = 0.2
|
|
, _nozzleNum = 3
|
|
}
|
|
, _itDimension = ItemDimension
|
|
{ _dimRad = 7
|
|
, _dimCenter = V3 9 0 0
|
|
, _dimPortage = HeldItem
|
|
{ _handlePos = 5
|
|
, _muzPos = 18
|
|
}
|
|
, _dimSPic = flamerPic
|
|
}
|
|
-- , _itFloorPict = flamerPic
|
|
}
|
|
flamerPic :: Item -> SPic
|
|
flamerPic it =
|
|
( colorSH yellow $
|
|
translateSHf tx ty (upperPrismPoly tz $ polyCirc 3 r)
|
|
++ upperPrismPoly 5 (rectNESW 2 18 (-2) 0)
|
|
, color black $ translate3 (V3 tx ty (tz+0.01)) $ circleSolid (r * am)
|
|
)
|
|
where
|
|
tx = 4
|
|
ty = - 6
|
|
tz = 3
|
|
r = 5
|
|
am = fractionLoadedAmmo2 it
|
|
flameStick :: Item
|
|
flameStick = flamer
|
|
& itUse . rUse .~ const aFlame
|
|
blowTorch :: Item
|
|
blowTorch = flamer
|
|
flameThrower :: Item
|
|
flameThrower = flamer
|
|
flameWall :: Item
|
|
flameWall = flamer
|
|
flamer :: Item
|
|
flamer = defaultAutoGun
|
|
{ _itName = "FLAMER"
|
|
, _itType = FLAMER
|
|
, _itConsumption = defaultAmmo
|
|
{ _ammoBaseMax = 250
|
|
, _ammoLoaded = 250
|
|
, _reloadTime = 100
|
|
}
|
|
, _itUse = ruseInstant (\_ -> randWalkAngle aFlame) NoHammer
|
|
[ ammoCheckI
|
|
, useAmmoAmount 1
|
|
, withSidePushI 5
|
|
--, withTempLight 1 100 (V3 1 0 0)
|
|
, withSidePushAfterI 20
|
|
]
|
|
& useAim . aimSpeed .~ 0.5
|
|
& useAim . aimZoom .~ defaultItZoom {_itZoomMax = 5, _itZoomMin = 1.5}
|
|
& useAim . aimStance .~ TwoHandTwist
|
|
-- , _itFloorPict = flamerPic
|
|
-- , _itZoom = defaultItZoom
|
|
, _itAttachment = NoItAttachment
|
|
, _itParams = AngleWalk
|
|
{_maxWalkAngle = 0.2
|
|
,_walkSpeed = 0.01
|
|
,_currentWalkAngle = 0
|
|
}
|
|
}
|
|
aGasCloud :: Creature -> World -> World
|
|
aGasCloud cr w = insertCloud $ set randGen g w
|
|
where
|
|
(a,g) = randomR (-0.1,0.1) (_randGen w)
|
|
dir = _crDir cr + a
|
|
pos = _crPos cr +.+ ((_crRad cr + 2.9) *.* unitVectorAtAngle (_crDir cr))
|
|
vel = (_crPos cr -.- _crOldPos cr) +.+ 10 *.* unitVectorAtAngle dir
|
|
insertCloud = makeGasCloud pos vel
|
|
|
|
overNozzles :: (Creature -> World -> Nozzle -> (World,Nozzle))
|
|
-> Item -> Creature -> World -> World
|
|
overNozzles eff it cr w = neww & creatures . ix cid . crInv . ix i . itParams . sprayerNozzles .~ newNozzles
|
|
where
|
|
cid = _crID cr
|
|
i = _crInvSel $ _creatures w IM.! cid
|
|
(neww,newNozzles) = mapAccumR (eff cr) w $ _sprayerNozzles (_itParams it)
|
|
|
|
overNozzle :: (Creature -> World -> World)
|
|
-> Creature -> World -> Nozzle -> (World, Nozzle)
|
|
overNozzle eff cr w nz = (eff (cr & crDir +~ wa) w & randGen .~ g,nz & nzCurrentWalkAngle .~ wa)
|
|
where
|
|
(walkamount, g) = randomR (-aspeed,aspeed) (_randGen w)
|
|
aspeed = _nzWalkSpeed nz
|
|
maxa = _nzMaxWalkAngle nz
|
|
wa = min maxa $ max (negate maxa) (_nzCurrentWalkAngle nz + walkamount)
|
|
|
|
aFlame :: Creature -> World -> World
|
|
aFlame cr w = w & particles .:~ aFlameParticle t pos vel (Just cid)
|
|
where
|
|
(t,_) = randomR (99,101) (_randGen w)
|
|
cid = _crID cr
|
|
dir = _crDir cr
|
|
pos = _crPos cr +.+ ((_crRad cr + 2.9) *.* unitVectorAtAngle (_crDir cr))
|
|
vel = (_crPos cr -.- _crOldPos cr) +.+ 4 *.* unitVectorAtAngle dir
|