More aggressive NPC running
Less aggressive NPC batting :D Updated Player sprites - now with belt!
|
@ -178,6 +178,7 @@ function Baserunning:updateRunner(runner, runnerIndex, appliedSpeed, deltaSecond
|
||||||
|
|
||||||
-- TODO: Do a better job drifting runners toward their bases when appliedSpeed is low/zero
|
-- TODO: Do a better job drifting runners toward their bases when appliedSpeed is low/zero
|
||||||
if distance < 2 then
|
if distance < 2 then
|
||||||
|
runner.prevBase = runner.nextBase
|
||||||
runner.nextBase = C.NextBaseMap[runner.nextBase]
|
runner.nextBase = C.NextBaseMap[runner.nextBase]
|
||||||
runner.forcedTo = nil
|
runner.forcedTo = nil
|
||||||
return false, false
|
return false, false
|
||||||
|
|
|
@ -71,7 +71,7 @@ C.BallOffscreen = 999
|
||||||
C.PitchAfterSeconds = 6
|
C.PitchAfterSeconds = 6
|
||||||
C.ReturnToPitcherAfterSeconds = 2.4
|
C.ReturnToPitcherAfterSeconds = 2.4
|
||||||
C.PitchFlyMs = 1050
|
C.PitchFlyMs = 1050
|
||||||
C.PitchStartX = 190
|
C.PitchStartX = 195
|
||||||
C.PitchStartY, C.PitchEndY = 105, 240
|
C.PitchStartY, C.PitchEndY = 105, 240
|
||||||
|
|
||||||
C.DefaultLaunchPower = 4
|
C.DefaultLaunchPower = 4
|
||||||
|
@ -84,7 +84,7 @@ C.BallCatchHitbox = 3
|
||||||
--- The max distance at which a runner can be considered on base.
|
--- The max distance at which a runner can be considered on base.
|
||||||
C.BaseHitbox = 10
|
C.BaseHitbox = 10
|
||||||
|
|
||||||
C.BattingPower = 20
|
C.BattingPower = 25
|
||||||
C.BatterHandPos = utils.xy(25, 15)
|
C.BatterHandPos = utils.xy(25, 15)
|
||||||
|
|
||||||
C.SmallestBallRadius = 6
|
C.SmallestBallRadius = 6
|
||||||
|
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.7 KiB |
|
@ -397,7 +397,7 @@ local function updateGameState()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif offenseState == C.Offense.running then
|
elseif offenseState == C.Offense.running then
|
||||||
local appliedSpeed = userOnOffense and crankLimited or npc:runningSpeed()
|
local appliedSpeed = userOnOffense and crankLimited or npc:runningSpeed(ball)
|
||||||
if updateNonBatterRunners(appliedSpeed) then
|
if updateNonBatterRunners(appliedSpeed) then
|
||||||
secondsSinceLastRunnerMove = 0
|
secondsSinceLastRunnerMove = 0
|
||||||
else
|
else
|
||||||
|
|
30
src/npc.lua
|
@ -33,18 +33,38 @@ function Npc:updateBatAngle(ball, catcherThrownBall, deltaSec)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Npc:batSpeed()
|
function Npc:batSpeed()
|
||||||
return npcBatSpeed
|
return npcBatSpeed / 1.5
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local baseRunningSpeed = 25
|
||||||
|
|
||||||
|
--- TODO: Individual runner control.
|
||||||
|
---@param ball Point3d
|
||||||
---@return number
|
---@return number
|
||||||
function Npc:runningSpeed()
|
function Npc:runningSpeed(ball)
|
||||||
if #self.runners == 0 then
|
if #self.runners == 0 then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
local touchedBase = utils.isTouchingBase(self.runners[1].x, self.runners[1].y)
|
|
||||||
if not touchedBase or touchedBase == C.Bases[C.Home] then
|
local runner1 = self.runners[1]
|
||||||
return 10
|
|
||||||
|
local ballIsFar = utils.distanceBetweenZ(ball.x, ball.y, ball.z, runner1.x, runner1.y, 0) > 250
|
||||||
|
|
||||||
|
if ballIsFar or runner1.forcedTo then
|
||||||
|
return baseRunningSpeed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local touchedBase = utils.isTouchingBase(runner1.x, runner1.y)
|
||||||
|
if not touchedBase then
|
||||||
|
local distToNext = utils.distanceBetween(runner1.x, runner1.y, runner1.nextBase.x, runner1.nextBase.y)
|
||||||
|
local distToPrev = utils.distanceBetween(runner1.x, runner1.y, runner1.prevBase.x, runner1.prevBase.y)
|
||||||
|
if distToNext < distToPrev then
|
||||||
|
return baseRunningSpeed
|
||||||
|
else
|
||||||
|
return -1 * baseRunningSpeed
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|