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 {};
}
+4
View File
@@ -49,6 +49,10 @@
// Naval mission score per point of damage dealt: official ("0.15 -> 0.18", same update).
"navalDamageScorePerPoint": 0.18,
// Offline Air Arcade balance. Damage pays proportionally to health removed from an enemy
// mini-base. The final hit also earns the destruction score.
"bombingZone": { "damageScore": 150, "destructionScore": 30 },
// The score at which an event pays exactly one reference kill (warpoints.blk aKill), by victim
// group. ground 180 and air 450 are the official base kill scores; naval 216 is the official
// example of a boat destruction ("now awarded with 216 points instead of 180").
+1 -1
View File
@@ -23,7 +23,7 @@ New-Item -ItemType Directory -Force $obj | Out-Null
$sources = @(
"$src\dll_main.c", "$src\hook_config.c", "$src\redirect_rules.c", "$src\resolver_hooks.c", "$src\connection_hooks.c",
"$src\local_mp_core.c", "$src\local_mp_values.c", "$src\local_mp_players.c", "$src\local_mp_loadout.c", "$src\local_mp_actions.c", "$src\local_mp_awards.c", "$src\local_mp_kills.c", "$src\local_mp_events.c", "$src\local_mp_scores.c", "$src\local_mp_nuke.c", "$src\local_mp_support.c",
"$src\local_mp_damage_notifications.c", "$src\local_mp_air_events.c", "$src\local_mp_ground_ai.c",
"$src\local_mp_damage_notifications.c", "$src\local_mp_air_events.c", "$src\local_mp_ground_ai.c", "$src\local_mp_zones.c",
"$mh\src\hook.c", "$mh\src\buffer.c", "$mh\src\trampoline.c", "$mh\src\hde\hde64.c"
) | ForEach-Object { '"' + (Resolve-Path $_) + '"' }
+1
View File
@@ -139,6 +139,7 @@ static const LocalMpModule MODULES[] = {
{ "local_mp_scores", install_local_mp_score_reader },
{ "local_mp_kills", install_local_mp_kill_hooks },
{ "local_mp_events", install_local_mp_event_hooks },
{ "local_mp_zones", install_local_mp_zone_hooks },
{ "local_mp_nuke", install_local_mp_nuke_hooks },
{ "local_mp_support", install_local_mp_support_hooks },
{ "local_mp_damage_notifications", install_local_mp_damage_notification_hooks },
+5 -2
View File
@@ -25,11 +25,11 @@ typedef const char *(__fastcall *LmpDataBlockGetStrFn)(const void *blk, const ch
/* One combat event of the local player, as facts only (see local_mp_awards.c). */
typedef struct LocalMpAwardEvent {
uint32_t exp_event; /* EXP_EVENT_* code (globalScripts/expEventConsts.nut) */
const uint8_t *victim; /* destroyed or damaged unit; NULL for a zone capture */
const uint8_t *victim; /* destroyed or damaged unit; NULL for zone events */
int victim_is_player; /* victim belongs to an MPlayer (player or bound bot) */
int friendly; /* victim was on the local player's team */
const char *modifier; /* stock messageModifier, e.g. "from_severe_damage", or NULL */
int32_t damage; /* naval award damage for EXP_EVENT_UNIT_DAMAGE, else 0 */
int32_t damage; /* naval damage points or bombing zone health in basis points */
} LocalMpAwardEvent;
extern uint8_t **g_local_mp_multiplayer;
@@ -81,6 +81,7 @@ void local_mp_events_begin_death(const uint8_t *victim);
/* Shared MPlayer scoreboard helpers exposed by local_mp_kills.c. */
void local_mp_add_mplayer_score(uint8_t *mp, float delta, uint32_t event_id);
void local_mp_add_personal_score(uint8_t *mp, float delta, uint32_t event_id);
void local_mp_mark_mplayer_dirty(uint8_t *mp);
void local_mp_inc_mplayer_stat(uint8_t *mp, size_t off);
@@ -105,6 +106,8 @@ int install_local_mp_score_reader(void);
int install_local_mp_nuke_hooks(void);
int install_local_mp_support_hooks(void);
int install_local_mp_damage_notification_hooks(void);
int install_local_mp_zone_hooks(void);
void local_mp_zones_reset(void);
int install_local_mp_air_event_hooks(void);
int install_local_mp_ground_ai_hooks(void);
void local_mp_ground_ai_update(float dt);
+12 -2
View File
@@ -47,7 +47,7 @@ static void dec_mplayer_stat_pos(uint8_t *mp, size_t off)
*(int16_t *)(mp + off) = (int16_t)(v - 1);
}
void local_mp_add_mplayer_score(uint8_t *mp, float delta, uint32_t event_id)
static void add_mplayer_score(uint8_t *mp, float delta, uint32_t event_id, uint8_t add_team)
{
uint8_t *app = g_local_mp_app ? *g_local_mp_app : NULL;
int32_t total;
@@ -55,11 +55,21 @@ void local_mp_add_mplayer_score(uint8_t *mp, float delta, uint32_t event_id)
return;
if (app == NULL || *(void **)(app + LMP_APP_OFF_SCORE_RULES) == NULL)
return;
fn_mplayer_add_score(mp, delta, event_id, 1);
fn_mplayer_add_score(mp, delta, event_id, add_team);
total = *(int32_t *)(mp + LMP_MP_OFF_SCORE);
*(int16_t *)(mp + LMP_MP_OFF_FALLBACK_SCORE) = (total > 32767) ? (int16_t)32767 : (int16_t)total;
}
void local_mp_add_mplayer_score(uint8_t *mp, float delta, uint32_t event_id)
{
add_mplayer_score(mp, delta, event_id, 1);
}
void local_mp_add_personal_score(uint8_t *mp, float delta, uint32_t event_id)
{
add_mplayer_score(mp, delta, event_id, 0);
}
static int is_same_severe_offender(const uint8_t *victim, const uint8_t *killer_mp)
{
if (victim == NULL || killer_mp == NULL || *(const int16_t *)(victim + LMP_UNIT_OFF_SEVERE_IDX) == -1)
+2
View File
@@ -20,10 +20,12 @@
#define LMP_GUI_STATE_CA_READY 8
#define LMP_EXP_EVENT_CAPTURE_ZONE 2u
#define LMP_EXP_EVENT_DESTROY_ZONE 3u
#define LMP_EXP_EVENT_KILL 5u
#define LMP_EXP_EVENT_KILL_GROUND 6u
#define LMP_EXP_EVENT_ASSIST 9u
#define LMP_EXP_EVENT_HIT 13u
#define LMP_EXP_EVENT_DAMAGE_ZONE 17u
#define LMP_EXP_EVENT_INEFFECTIVE_HIT 20u
#define LMP_EXP_EVENT_UNIT_DAMAGE 24u
#define LMP_EXP_EVENT_SEVERE_DAMAGE 35u
+1
View File
@@ -111,6 +111,7 @@ static void __fastcall hook_mplayer_init_from_matching(uint8_t *mplayer, uint8_t
if (*(int32_t *)(info + LMP_MATCH_INFO_OFF_SQUAD_ID) == 0)
*(int32_t *)(info + LMP_MATCH_INFO_OFF_SQUAD_ID) = 1;
local_mp_events_reset();
local_mp_zones_reset();
log_line("local_mp: initialized local player team=%d squad=%d",
(int)(*(int32_t *)(info + LMP_MATCH_INFO_OFF_TEAM)),
(int)(*(int32_t *)(info + LMP_MATCH_INFO_OFF_SQUAD_ID)));
+2
View File
@@ -9,6 +9,8 @@
* group: ground, air, naval, human (the victim's; the capturer's own
* for capture)
* wtoScore_damagePerPoint naval award damage
* wtoScore_zoneDamage health removed from an enemy mini-base in Air Arcade
* wtoScore_zoneDestruction final hit on an enemy mini-base in Air Arcade
* wtoScore_aiMul victims that are not players (warpoints.blk aiKillK)
* A missing key scores 0, so nothing here carries a score of its own.
*/
+6
View File
@@ -37,6 +37,7 @@ typedef struct LmpValueSpec {
#define SCORES "local_mp_scores"
#define KILLS "local_mp_kills"
#define EVENTS "local_mp_events"
#define ZONES "local_mp_zones"
#define NUKE "local_mp_nuke"
#define SUPPORT "local_mp_support"
#define DAMAGE_NOTICES "local_mp_damage_notifications"
@@ -44,6 +45,11 @@ typedef struct LmpValueSpec {
#define GROUND_AI "local_mp_ground_ai"
static const LmpValueSpec SPECS[] = {
A(ZONES, "apply_zone_damage", apply_zone_damage),
O(ZONES, "zone_damage_health.health", zone_health), O(ZONES, "zone_damage_health.max_health", zone_max_health),
O(ZONES, "zone_damage_team.team", zone_team),
O(ZONES, "zone_damage_airfield.flags", zone_flags), O(ZONES, "zone_damage_airfield.airfield_mask", zone_airfield_mask),
A(CORE, "do_respawn_player", do_respawn_player), O(CORE, "do_respawn_player.app_score_rules", app_score_rules),
A(CORE, "do_respawn_player.hero", hero),
A(CORE, "disabled_slots_mask.multiplayer", multiplayer), A(CORE, "disabled_slots_mask.app", app),
+4
View File
@@ -82,6 +82,10 @@ typedef struct LmpValues {
size_t barrel_unit_ref, breech_unit, barrel_notice_id, breech_notice_id, avionics_unit, hit_event_offender;
size_t mpi_msg_id_off, enemy_part_dmg_mpi_id, enemy_part_hit_mpi_id;
/* local_mp_zones */
uint8_t *apply_zone_damage;
size_t zone_health, zone_max_health, zone_team, zone_flags, zone_airfield_mask;
/* local_mp_air_events */
uint8_t *prepare_local_mission, *use_kill_streaks, *gameplay, *kill_streak_name_map, *add_kill_streak_points;
uint8_t *air_event_battle_center, *mission_max_rank, *air_event_terrain_height, *air_event_switch_unit;
+90
View File
@@ -0,0 +1,90 @@
/* Observe the stock health update for enemy bombing zones in LocalMP Air Arcade. */
#include "local_mp_internal.h"
#include "local_mp_offsets.h"
#include <math.h>
/* DAMAGE_ZONE uses basis points of the zone's full health, as read by BattleEconomy. */
#define ZONE_HEALTH_SCALE 10000
typedef void (__fastcall *ApplyZoneDamageFn)(uint8_t *zone, const uint8_t *offender, float damage, float contribution);
static ApplyZoneDamageFn orig_apply_zone_damage;
static int32_t damage_score_remainder;
void local_mp_zones_reset(void)
{
damage_score_remainder = 0;
}
static uint8_t *local_zone_attacker(const uint8_t *zone, const uint8_t *offender)
{
if (zone == NULL || offender == NULL || *(const uint16_t *)offender == UINT16_MAX)
return NULL;
if ((*(const uint16_t *)(zone + g_lmp.zone_flags) & g_lmp.zone_airfield_mask) != 0)
return NULL;
int zone_team = zone[g_lmp.zone_team];
int attacker_team = *(const int32_t *)(offender + LMP_OFFENDER_OFF_ARMY);
if ((zone_team != 1 && zone_team != 2) || attacker_team != 3 - zone_team)
return NULL;
uint8_t *mp = local_mp_find_mplayer(*(const int64_t *)(offender + LMP_OFFENDER_OFF_UID), offender[LMP_OFFENDER_OFF_PID]);
return local_mp_is_local_mplayer(mp) && mp[LMP_MP_OFF_TEAM] == attacker_team ? mp : NULL;
}
static void report_zone_award(uint8_t *mp, uint32_t code, int32_t score, int32_t damage)
{
LocalMpAwardEvent award = { code, NULL, 0, 0, NULL, damage };
if (score > 0) {
local_mp_add_personal_score(mp, (float)score, code);
local_mp_mark_mplayer_dirty(mp);
}
local_mp_report_award_event(&award);
}
static void award_zone_damage(uint8_t *mp, float before, float after, float max_health, int32_t full_score)
{
int32_t previous = (int32_t)(before / max_health * ZONE_HEALTH_SCALE + 0.5f);
int32_t remaining = (int32_t)(after / max_health * ZONE_HEALTH_SCALE + 0.5f);
int32_t lost = previous - remaining;
if (lost <= 0)
return;
/* MPlayer::addScore truncates every delta. Carry fractional points across hits. */
int64_t scaled = (int64_t)full_score * lost + damage_score_remainder;
damage_score_remainder = (int32_t)(scaled % ZONE_HEALTH_SCALE);
report_zone_award(mp, LMP_EXP_EVENT_DAMAGE_ZONE, (int32_t)(scaled / ZONE_HEALTH_SCALE), lost);
}
static void __fastcall hook_apply_zone_damage(uint8_t *zone, const uint8_t *offender, float damage, float contribution)
{
uint8_t *mp = NULL;
if (local_mp_is_host() && isfinite(damage) && damage > 0)
mp = local_zone_attacker(zone, offender);
int32_t damage_score = mp ? (int32_t)local_mp_score_param("wtoScore_zoneDamage") : 0;
int32_t destroy_score = mp ? (int32_t)local_mp_score_param("wtoScore_zoneDestruction") : 0;
if (damage_score <= 0 && destroy_score <= 0) {
orig_apply_zone_damage(zone, offender, damage, contribution);
return;
}
float before = *(const float *)(zone + g_lmp.zone_health);
float max_health = *(const float *)(zone + g_lmp.zone_max_health);
orig_apply_zone_damage(zone, offender, damage, contribution);
float after = *(const float *)(zone + g_lmp.zone_health);
if (!isfinite(max_health) || !(before <= max_health && after >= 0 && after < before) ||
*(const float *)(zone + g_lmp.zone_max_health) != max_health)
return;
if (damage_score > 0)
award_zone_damage(mp, before, after, max_health, damage_score);
if (destroy_score > 0 && after == 0)
report_zone_award(mp, LMP_EXP_EVENT_DESTROY_ZONE, destroy_score, 0);
}
int install_local_mp_zone_hooks(void)
{
const LocalMpHookSpec hook = {
"apply_zone_damage", g_lmp.apply_zone_damage, (void *)&hook_apply_zone_damage, (void **)&orig_apply_zone_damage,
};
return local_mp_queue_hooks("local_mp_zones", &hook, 1);
}
@@ -52,17 +52,24 @@ function wtoBannerReward(awards, unit, ev) {
if (code == EXP_EVENT_INEFFECTIVE_HIT)
return { wp = 0, exp = 0 }
let isCapture = code == EXP_EVENT_CAPTURE_ZONE
let isZoneDamage = code == EXP_EVENT_DAMAGE_ZONE
let isBombingZone = isZoneDamage || code == EXP_EVENT_DESTROY_ZONE
let friendly = (ev?.friendly ?? 0) != 0
if (isBombingZone && friendly)
return null
let isObjective = isCapture || isBombingZone
let expClass = ev?.expClass ?? ""
let group = isCapture ? "own" : (awards?.groups?[expClass] ?? "ground")
let group = isCapture ? "own" : isBombingZone ? "ground" : (awards?.groups?[expClass] ?? "ground")
let baseReward = awards?.vehicles?[unit]?[$"{code}:{group}"]
if (baseReward == null)
return null
let ai = (isCapture || (ev?.victimIsPlayer ?? 0) != 0) ? 1.0 : awards.aiKillK
let slClass = isCapture ? 1.0 : (awards?.slClass?[expClass] ?? 1.0)
let rpClass = isCapture ? 1.0 : (awards?.rpClass?[expClass] ?? 1.0)
if ((ev?.friendly ?? 0) != 0)
let ai = (isObjective || (ev?.victimIsPlayer ?? 0) != 0) ? 1.0 : awards.aiKillK
let slClass = isObjective ? 1.0 : (awards?.slClass?[expClass] ?? 1.0)
let rpClass = isObjective ? 1.0 : (awards?.rpClass?[expClass] ?? 1.0)
if (friendly)
return { wp = -(baseReward[0] * slClass * ai * awards.friendlyKillPenaltyMul + 0.5).tointeger(), exp = 0 }
let count = code == EXP_EVENT_UNIT_DAMAGE ? (ev?.damage ?? 0) : 1
let damage = ev?.damage ?? 0
let count = isZoneDamage ? damage.tofloat() / awards.zoneHealthScale : code == EXP_EVENT_UNIT_DAMAGE ? damage : 1
return {
wp = (baseReward[0] * slClass * ai * count + 0.5).tointeger()
exp = (baseReward[1] * rpClass * ai * count + 0.5).tointeger()
+59
View File
@@ -0,0 +1,59 @@
// Score enemy mini-base damage and destruction in LocalMP Air Arcade.
// The local service cannot see the offender or the health actually lost. The engine has both at the damage update.
{
"module": "local_mp_zones",
"features": ["K-Kill, assist and capture scoring", "K-Scoreboard"],
"requires": ["local_mp_kills", "local_mp_players"],
"sites": {
// Damage application and EventOnBombingZoneDamaged. Verified at .37 0x11ad500,
// .58 0x11b20f0 and .60 0x11b1f90. Match the entry through the native host check.
"apply_zone_damage": {
"variants": [{
"written_for": "2.61.0.37",
"locate": {
"method": "signature",
"pattern": "41 56 56 57 53 48 81 ec 68 01 00 00 44 0f 29 8c 24 50 01 00 00 44 0f 29 84 24 40 01 00 00 0f 29 bc 24 30 01 00 00 0f 29 b4 24 20 01 00 00 48 89 d7 48 89 ce 48 8b 05 ?? ?? ?? ?? 48 85 c0 74 ?? 80 78 ?? 01"
}
}]
},
// Read current HP before subtracting XMM2 and maximum HP from the upper clamp.
"zone_damage_health": {
"variants": [{
"written_for": "2.61.0.37",
"locate": {
"method": "within", "in": "apply_zone_damage",
"pattern": "0f 28 fb f3 0f 10 b6 ?? ?? ?? ?? 44 0f 28 c6 44 0f 28 ca f3 44 0f 5c c2 f3 44 0f 5f c0 f3 44 0f 5d 86 ?? ?? ?? ?? f3 44 0f 11 86",
"captures": {
"health": { "offset": 7, "type": "u32" },
"max_health": { "offset": 34, "type": "u32" }
}
}
}]
},
// The call after the HP write forwards the zone's one-byte team and actual damage.
"zone_damage_team": {
"variants": [{
"written_for": "2.61.0.37",
"locate": {
"method": "within", "in": "apply_zone_damage",
"pattern": "48 8d 8e ?? ?? ?? ?? f3 0f 59 c7 f3 0f 5c b6 ?? ?? ?? ?? 4c 8d 86 ?? ?? ?? ?? 0f b6 56 ?? f3 0f 11 44 24 20 0f 28 de e8",
"captures": { "team": { "offset": 29, "type": "u8" } }
}
}]
},
// The destruction branch reads a flag and forwards it as the airfield discriminator.
"zone_damage_airfield": {
"variants": [{
"written_for": "2.61.0.37",
"locate": {
"method": "within", "in": "apply_zone_damage",
"pattern": "48 8d 8e ?? ?? ?? ?? 0f b7 86 ?? ?? ?? ?? 83 e0 ?? c1 e8 02 f3 0f 10 86 ?? ?? ?? ??",
"captures": {
"flags": { "offset": 10, "type": "u32" },
"airfield_mask": { "offset": 16, "type": "u8" }
}
}
}]
}
}
}