Abstract out random offset for weapons
This commit is contained in:
@@ -457,8 +457,10 @@ miniGun = defaultAutoGun
|
|||||||
, _wpReloadState = 0
|
, _wpReloadState = 0
|
||||||
, _wpFireRate = 2
|
, _wpFireRate = 2
|
||||||
, _wpFireState = 0
|
, _wpFireState = 0
|
||||||
, _wpFire = withWarmUp 50 $ torqueBefore 0.03 $ withSidePush 50 $ withRecoil 15
|
, _wpFire = withWarmUp 50 . torqueBefore 0.03 . withSidePush 50 . withRecoil 15
|
||||||
$ withOffsetAccVelWthHiteff' 9 0.1 (30,0) 2 bulletEffect'
|
. withRandomDir 0.1
|
||||||
|
. withRandomOffset 9
|
||||||
|
$ withVelWthHiteff (30,0) 2 bulletEffect'
|
||||||
, _wpSpread = autogunSpread
|
, _wpSpread = autogunSpread
|
||||||
, _wpRange = 20
|
, _wpRange = 20
|
||||||
, _itFloorPict = onLayer FlItLayer $ color red $ polygon $ rectNESW 9 5 (-9) (-5)
|
, _itFloorPict = onLayer FlItLayer $ color red $ polygon $ rectNESW 9 5 (-9) (-5)
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ withSound soundid f cid = soundOnce soundid . f cid
|
|||||||
withRecoil :: Float -> (Int -> World -> World) -> Int -> World -> World
|
withRecoil :: Float -> (Int -> World -> World) -> Int -> World -> World
|
||||||
withRecoil recoilAmount eff cid w = eff cid . over (creatures . ix cid) pushback $ w
|
withRecoil recoilAmount eff cid w = eff cid . over (creatures . ix cid) pushback $ w
|
||||||
where pushback cr = over crPos
|
where pushback cr = over crPos
|
||||||
-- where pushback cr = colCrWall w $ over crPos
|
|
||||||
(+.+ rotateV (_crDir cr) ((-recoilAmount) / _crMass cr ,0))
|
(+.+ rotateV (_crDir cr) ((-recoilAmount) / _crMass cr ,0))
|
||||||
cr
|
cr
|
||||||
withSidePush :: Float -> (Int -> World -> World) -> Int -> World -> World
|
withSidePush :: Float -> (Int -> World -> World) -> Int -> World -> World
|
||||||
@@ -126,22 +125,15 @@ withVelWthHiteff vel width hiteff cid w
|
|||||||
pos = _crPos cr +.+ _crRad cr *.* unitVectorAtAngle (_crDir cr)
|
pos = _crPos cr +.+ _crRad cr *.* unitVectorAtAngle (_crDir cr)
|
||||||
pos2 = _crPos cr +.+ (2 * _crRad cr) *.* unitVectorAtAngle (_crDir cr)
|
pos2 = _crPos cr +.+ (2 * _crRad cr) *.* unitVectorAtAngle (_crDir cr)
|
||||||
|
|
||||||
|
withRandomOffset :: Float -> (Int -> World -> World) -> Int -> World -> World
|
||||||
|
withRandomOffset offsetAmount f cid w = over (creatures . ix cid . crPos) (-.- offV)
|
||||||
withOffsetAccVelWthHiteff' :: Float -> Float -> Point2 -> Float -> HitEffect' -> Int -> World -> World
|
. f cid
|
||||||
withOffsetAccVelWthHiteff' offsetAmount acc vel width hiteff cid w
|
. over (creatures . ix cid . crPos) (+.+ offV)
|
||||||
= over particles' ((:) newbul )
|
$ set randGen g
|
||||||
$ muzFlareAt pos
|
w
|
||||||
$ set randGen g
|
where (offsetVal , g) = randomR (-offsetAmount,offsetAmount) $ _randGen w
|
||||||
w
|
cr = _creatures w IM.! cid
|
||||||
where cr = _creatures w IM.! cid
|
offV = rotateV (_crDir cr) (0,offsetVal)
|
||||||
newbul = aGenBulAt' (Just cid) (numColor colid) pos (rotateV dir vel) hiteff width
|
|
||||||
(colid, g) = randomR (0,11) $ _randGen w
|
|
||||||
(a, _) = randomR (-acc,acc) $ _randGen w
|
|
||||||
dir = _crDir cr + a
|
|
||||||
pos = _crPos cr +.+ _crRad cr *.* unitVectorAtAngle (_crDir cr) +.+ offset
|
|
||||||
(offsetVal , _) = randomR (-offsetAmount,offsetAmount) $ _randGen w
|
|
||||||
offset = rotateV (_crDir cr) (0,offsetVal)
|
|
||||||
|
|
||||||
torqueBeforeForced :: Float -> (Int -> World -> World) -> Int -> World -> World
|
torqueBeforeForced :: Float -> (Int -> World -> World) -> Int -> World -> World
|
||||||
torqueBeforeForced torque feff cid w
|
torqueBeforeForced torque feff cid w
|
||||||
|
|||||||
Reference in New Issue
Block a user