fix(battle): award Air Arcade mini-base score

Use the native health update identified in PR #10 to report enemy mini-base damage and destruction. Preserve fractional personal score across hits and use the selected mode to gate both the HUD reward and settlement.

Verified server and launcher types, MSVC compilation, Quirrel bytecode, and patch resolution on 2.61.0.37, 2.61.0.58, and 2.61.0.60. In-game acceptance is pending.

Co-authored-by: duduyagame <[email protected]>
This commit is contained in:
N0VAN0M4LYandduduyagame committed 2026-12-04 06:13:21 +08:00
1 parent 194417a388
commit 6d0abf9caf
19 files changed
+257 -27

No files matched your search

@@ -16,6 +16,7 @@ export interface BattleEconomyTuning {
readonly eventScores: Readonly<Record<VictimGroup, Readonly<Record<ScoredEvent, number>>>>;
readonly captureZoneScore: Readonly<Record<VictimGroup, number>>;
readonly navalDamageScorePerPoint: number;
readonly bombingZone: { readonly damageScore: number; readonly destructionScore: number };
readonly referenceScore: Readonly<Record<VictimGroup, number>>;
readonly friendlyKillPenaltyMul: number;
}
@@ -30,6 +31,7 @@ export function readBattleEconomyTuning(reader: TuningReader): BattleEconomyTuni
for (const expClass of groups.stringList(group)) victimGroups.set(expClass, group);
}
const scores = reader.object('eventScores');
const bombingZone = reader.object('bombingZone');
const perGroup = (key: string, min: number): Record<VictimGroup, number> => {
const table = reader.object(key);
return Object.fromEntries(VICTIM_GROUPS.map((group) => [group, table.number(group, { min, max: 100000 })])) as Record<VictimGroup, number>;
@@ -42,6 +44,10 @@ export function readBattleEconomyTuning(reader: TuningReader): BattleEconomyTuni
})) as Record<VictimGroup, Record<ScoredEvent, number>>,
captureZoneScore: perGroup('captureZoneScore', 0),
navalDamageScorePerPoint: reader.number('navalDamageScorePerPoint', { min: 0, max: 100 }),
bombingZone: {
damageScore: bombingZone.int('damageScore', { min: 0, max: 100000 }),
destructionScore: bombingZone.int('destructionScore', { min: 0, max: 100000 }),
},
referenceScore: perGroup('referenceScore', 1),
friendlyKillPenaltyMul: reader.number('friendlyKillPenaltyMul', { min: 0, max: 100 }),
};
+42 -13
View File
@@ -16,11 +16,13 @@ import { SCORED_EVENTS, VICTIM_GROUPS, type BattleEconomyTuning, type ScoredEven
/** EXP_EVENT_* codes the LocalMP host reports (gui.vromfs.bin globalScripts/expEventConsts.nut). */
export const ExpEvent = {
CAPTURE_ZONE: 2,
DESTROY_ZONE: 3,
KILL: 5,
KILL_GROUND: 6,
ASSIST: 9,
CRITICAL_HIT: 10,
HIT: 13,
DAMAGE_ZONE: 17,
UNIT_DAMAGE: 24,
SEVERE_DAMAGE: 35,
KILL_HUMAN: 39,
@@ -30,7 +32,14 @@ export const ExpEvent = {
export type DebriefingRow =
| 'AirKills' | 'GroundKills' | 'NavalKills' | 'HumanKills' | 'FriendlyKills'
| 'Assist' | 'AirSevereDamage' | 'ShipSevereDamage' | 'Critical' | 'Hit'
| 'Captures' | 'AwardDamage';
| 'Captures' | 'Damage' | 'Destruction' | 'AwardDamage';
/** LocalMP reports mini-base health as basis points (local_mp_zones.c). */
const ZONE_HEALTH_SCALE = 10_000;
function isBombingZoneEvent(code: number): boolean {
return code === ExpEvent.DAMAGE_ZONE || code === ExpEvent.DESTROY_ZONE;
}
/** What the client reports for one combat event (patches/gui/battle/record-local-battle-awards). */
export interface CombatEventFact {
@@ -38,12 +47,13 @@ export interface CombatEventFact {
readonly expClass: string;
readonly victimIsPlayer: boolean;
readonly friendly: boolean;
/** Naval damage points or, for DAMAGE_ZONE, basis points of the zone's full health. */
readonly damage: number;
}
export interface PricedEvent {
readonly row: DebriefingRow;
/** How much the row's counter grows: 1, or the damage points for AwardDamage. */
/** How much the stock row's counter grows. Damage counts TNT mass, which is unavailable here. */
readonly count: number;
readonly wp: number;
readonly exp: number;
@@ -68,6 +78,7 @@ export interface BannerParams {
readonly rpClass: Readonly<Record<string, number>>;
readonly aiKillK: number;
readonly friendlyKillPenaltyMul: number;
readonly zoneHealthScale: number;
}
export interface RewardMultipliers {
@@ -128,37 +139,46 @@ export class BattleEconomy {
};
}
price(vehicle: string, difficulty: EconomyDifficulty, fact: CombatEventFact): PricedEvent | undefined {
price(vehicle: string, difficulty: EconomyDifficulty, modeName: string, fact: CombatEventFact): PricedEvent | undefined {
const economy = this.vehicle(vehicle);
if (!economy) return undefined;
const isCapture = fact.code === ExpEvent.CAPTURE_ZONE;
const group = isCapture ? this.victimGroup(economy.unitClass) : this.victimGroup(fact.expClass);
const isBombingZone = isBombingZoneEvent(fact.code);
const isZoneDamage = fact.code === ExpEvent.DAMAGE_ZONE;
if (isBombingZone && (modeName !== 'air_arcade' || fact.friendly)) return undefined;
if (isZoneDamage && (!Number.isInteger(fact.damage) || fact.damage < 1 || fact.damage > ZONE_HEALTH_SCALE)) return undefined;
const isObjective = isCapture || isBombingZone;
const group = isBombingZone ? 'ground' : this.victimGroup(isCapture ? economy.unitClass : fact.expClass);
const row = debriefingRow(fact, group);
const base = this.baseReward(vehicle, difficulty, fact.code, group);
if (!row || !base) return undefined;
const count = fact.code === ExpEvent.UNIT_DAMAGE ? Math.max(0, Math.trunc(fact.damage)) : 1;
const ai = isCapture || fact.victimIsPlayer ? 1 : this.data.aiKillK;
const slClass = isCapture ? 1 : this.data.silverLionsClassFactors[fact.expClass] ?? 1;
const rpClass = isCapture ? 1 : this.data.researchClassFactors[fact.expClass] ?? 1;
const quantity = isZoneDamage ? fact.damage / ZONE_HEALTH_SCALE : count;
const ai = isObjective || fact.victimIsPlayer ? 1 : this.data.aiKillK;
const slClass = isObjective ? 1 : this.data.silverLionsClassFactors[fact.expClass] ?? 1;
const rpClass = isObjective ? 1 : this.data.researchClassFactors[fact.expClass] ?? 1;
if (fact.friendly) {
return { row: 'FriendlyKills', count: 1, wp: -Math.round(base.wp * slClass * ai * this.#tuning.friendlyKillPenaltyMul), exp: 0 };
}
return {
row,
count,
wp: Math.round(base.wp * slClass * ai * count),
exp: Math.round(base.exp * rpClass * ai * count),
count: isZoneDamage ? 0 : count,
wp: Math.round(base.wp * slClass * ai * quantity),
exp: Math.round(base.exp * rpClass * ai * quantity),
};
}
bannerParams(vehicles: Iterable<string>, difficulty: EconomyDifficulty): BannerParams {
bannerParams(vehicles: Iterable<string>, difficulty: EconomyDifficulty, modeName: string): BannerParams {
const table: Record<string, Record<string, [number, number]>> = {};
for (const name of vehicles) {
const economy = this.vehicle(name);
if (!economy || table[name]) continue;
const entries: Record<string, [number, number]> = {};
for (const code of Object.values(ExpEvent)) {
const groups: readonly (VictimGroup | 'own')[] = code === ExpEvent.CAPTURE_ZONE ? ['own'] : ['ground', 'air', 'naval', 'human'];
const isBombingZone = isBombingZoneEvent(code);
if (isBombingZone && modeName !== 'air_arcade') continue;
const groups: readonly (VictimGroup | 'own')[] = code === ExpEvent.CAPTURE_ZONE ? ['own']
: isBombingZone ? ['ground'] : VICTIM_GROUPS;
for (const group of groups) {
const priceGroup = group === 'own' ? this.victimGroup(economy.unitClass) : group;
const base = this.baseReward(name, difficulty, code, priceGroup);
@@ -174,6 +194,7 @@ export class BattleEconomy {
rpClass: this.data.researchClassFactors,
aiKillK: this.data.aiKillK,
friendlyKillPenaltyMul: this.#tuning.friendlyKillPenaltyMul,
zoneHealthScale: ZONE_HEALTH_SCALE,
};
}
@@ -183,7 +204,7 @@ export class BattleEconomy {
* the official mission scores of tuning/battle-economy.jsonc, and aiKillK for victims that are
* not players, as in the rewards.
*/
missionScores(): Readonly<Record<string, number>> {
missionScores(modeName: string): Readonly<Record<string, number>> {
const scores: Record<string, number> = {};
for (const group of VICTIM_GROUPS) {
for (const event of SCORED_EVENTS) scores[`wtoScore_${event}_${group}`] = this.#tuning.eventScores[group][event];
@@ -191,6 +212,10 @@ export class BattleEconomy {
}
scores.wtoScore_damagePerPoint = this.#tuning.navalDamageScorePerPoint;
scores.wtoScore_aiMul = this.data.aiKillK;
if (modeName === 'air_arcade') {
scores.wtoScore_zoneDamage = this.#tuning.bombingZone.damageScore;
scores.wtoScore_zoneDestruction = this.#tuning.bombingZone.destructionScore;
}
return scores;
}
@@ -205,6 +230,8 @@ export class BattleEconomy {
case ExpEvent.HIT: return scored('hit');
case ExpEvent.SEVERE_DAMAGE: return scored('severeDamage');
case ExpEvent.CAPTURE_ZONE: return this.#tuning.captureZoneScore[group];
case ExpEvent.DAMAGE_ZONE: return this.#tuning.bombingZone.damageScore;
case ExpEvent.DESTROY_ZONE: return this.#tuning.bombingZone.destructionScore;
case ExpEvent.UNIT_DAMAGE: return this.#tuning.navalDamageScorePerPoint;
default: return undefined;
}
@@ -223,6 +250,8 @@ function debriefingRow(fact: CombatEventFact, group: VictimGroup): DebriefingRow
case ExpEvent.HIT: return 'Hit';
case ExpEvent.SEVERE_DAMAGE: return group === 'naval' ? 'ShipSevereDamage' : 'AirSevereDamage';
case ExpEvent.CAPTURE_ZONE: return 'Captures';
case ExpEvent.DAMAGE_ZONE: return 'Damage';
case ExpEvent.DESTROY_ZONE: return 'Destruction';
case ExpEvent.UNIT_DAMAGE: return 'AwardDamage';
default: return undefined;
}
@@ -58,6 +58,8 @@ const CONTAINER_OF_ROW: Readonly<Record<DebriefingRow, string | undefined>> = {
Critical: 'eventCriticalHit',
Hit: 'eventHit',
Captures: 'eventCaptureZone',
Damage: 'eventDamageZone',
Destruction: 'eventDestroyZone',
// No user log list carries naval damage awards; they show in the debriefing table only.
AwardDamage: undefined,
};
+2 -1
View File
@@ -84,6 +84,7 @@ export interface BattleRewards {
export interface RewardContext {
readonly difficulty: EconomyDifficulty;
readonly modeName: string;
/** The mode's economic name, which selects rank.blk ExpSkillBonus. */
readonly economicName: string;
readonly premiumAccount: boolean;
@@ -133,7 +134,7 @@ export function computeBattleRewards(report: BattleReport, economy: BattleEconom
const events: SettledEvent[] = [];
for (const event of report.events) {
const priced = economy.price(event.unit, ctx.difficulty, event);
const priced = economy.price(event.unit, ctx.difficulty, ctx.modeName, event);
if (!priced) continue;
events.push({ event, priced, bonuses: add(event.unit, priced.row, priced.count, priced.wp, priced.exp, ctx.boosters.forEvent(event)) });
}
@@ -64,6 +64,7 @@ export function settleBattle(profile: BlkBlock, report: BattleReport, session: B
const premiumAccount = remainingPremiumDays(profile, now) > 0;
const rewards = computeBattleRewards(report, deps.economy, {
difficulty,
modeName: session.modeName,
economicName: session.economicName,
premiumAccount,
hasTalisman: (vehicle) => deps.economy.isPremiumVehicle(vehicle) || ownsModification(profile, vehicle, TALISMAN),
@@ -113,11 +113,13 @@ function handleEnqueue(
...(launch.selectedSlot ? [launch.selectedSlot.unitName] : slotVehicles),
...launch.extraBattleSlots.map((slot) => slot.unitName),
]);
const awards = deps.economy.bannerParams(playerVehicles, economyDifficulty(modes[0]!.declaration.difficulty));
setImmediate(() => {
if (!deps.sessions.isPending(userId, launch.sessionId)) return;
deps.sessions.clearPending(userId, launch.sessionId);
deps.notifyLaunch(userId, battleLaunchNotify(launch, awards, deps.economy.missionScores()));
const battle = deps.sessions.findForUser(launch.sessionId, userId);
if (!battle) return;
const awards = deps.economy.bannerParams(playerVehicles, economyDifficulty(battle.difficulty), battle.modeName);
deps.notifyLaunch(userId, battleLaunchNotify(launch, awards, deps.economy.missionScores(battle.modeName)));
});
return {};
}