applyPenalty
Definition
-- @/lua/ge/extensions/gameplay/crawl/utils.lua:56
local function applyPenalty(crawlerId, penaltyType, points)
local state = crawlStates[crawlerId]
if not state or not state.active then
return
end
if not points then
points = infractionPoints[penaltyType]
if not points then
log('E', logTag, string.format('Unknown penalty/infraction type: %s', penaltyType))
return
end
end
state.crawlerData.points = (state.crawlerData.points or 0) + points
if state.crawlerData.points < 0 then
state.crawlerData.points = 0
end
table.insert(state.eventLog, {
time = state.currentTime,
type = 'penalty',
penaltyType = penaltyType,
points = points,
totalPoints = state.crawlerData.points
})
end
Callers
@/lua/ge/extensions/flowgraph/nodes/gameplay/crawl/applyPenalty.lua
-- Apply penalty through bridge (bridge will validate penalty type and get points from utils)
self.bridge.applyPenalty(penaltyType)
end
@/lua/ge/extensions/gameplay/crawl/boundary.lua
if gameplay_crawl_utils and gameplay_crawl_utils.applyPenalty then
gameplay_crawl_utils.applyPenalty(crawler.id, 'dnf')
crawlerDNFApplied[crawler.id] = true
if gameplay_crawl_utils and gameplay_crawl_utils.applyPenalty then
gameplay_crawl_utils.applyPenalty(crawler.id, 'dnf')
crawlerDNFApplied[crawler.id] = true
@/lua/ge/extensions/gameplay/crawl/crawlFlowgraphBridge.lua
gameplay_crawl_utils.applyPenalty(bridgeState.activeCrawlerId, penaltyType, points)
end
@/lua/ge/extensions/gameplay/crawl/flowgraphBridge.lua
gameplay_crawl_utils.applyPenalty(activeCrawlerId, penaltyType, points)
end
@/lua/ge/extensions/gameplay/crawl/utils.lua
local penaltyReduction = math.abs(infractionPoints.gateCleared)
applyPenalty(crawlerId, 'gateCleared')
gameplay_crawl_display.showGateClearedMessage(penaltyReduction)
local bonusReduction = math.abs(infractionPoints.bonusGateCleared)
applyPenalty(crawlerId, 'bonusGateCleared')
gameplay_crawl_display.showBonusCheckpointMessage(bonusReduction)
gameplay_crawl_display.showSkippedCheckpointsMessage(skippedCheckpoints)
applyPenalty(crawlerId, 'skippedCheckpoint', skippedCheckpoints * infractionPoints.skippedCheckpoint)
end
infractionData.drivingBackwardsCooldown = infractionCooldowns.drivingBackwards
applyPenalty(crawlerId, 'drivingBackwards')
end
if collisionData and not collisionData.hasBeenTouched and objectCollisions[objId] == 1 then
applyPenalty(crawlerId, 'gateTouch')
collisionData.hasBeenTouched = true
end
applyPenalty(crawlerId, 'vehicleFlippedUpright')
gameplay_crawl_display.showVehicleFlippedUprightMessage()
applyPenalty(crawlerId, 'dnf')
gameplay_crawl_display.showDNFMessage()
applyPenalty(crawlerId, 'boundaryViolation')
infractionData.boundaryViolationCooldown = infractionCooldowns.boundaryViolation