Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d40623cd47 |
No files matched your search
@@ -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_zones.c", "$src\local_mp_air_ai_sync.c",
|
||||
"$src\local_mp_damage_notifications.c", "$src\local_mp_hit_feedback.c", "$src\local_mp_air_events.c", "$src\local_mp_ground_ai.c", "$src\local_mp_zones.c", "$src\local_mp_captures.c", "$src\local_mp_air_ai_sync.c",
|
||||
"$mh\src\hook.c", "$mh\src\buffer.c", "$mh\src\trampoline.c", "$mh\src\hde\hde64.c"
|
||||
) | ForEach-Object { '"' + (Resolve-Path $_) + '"' }
|
||||
|
||||
|
||||
@@ -58,7 +58,13 @@ const char *local_mp_unit_exp_class(const uint8_t *unit)
|
||||
return (exp_class != NULL && exp_class[0] != '\0') ? exp_class : NULL;
|
||||
}
|
||||
|
||||
void local_mp_report_award_event(const LocalMpAwardEvent *ev)
|
||||
static const char *bare_unit_name(const char *unit_name)
|
||||
{
|
||||
const char *slash = strrchr(unit_name, '/');
|
||||
return (slash != NULL && slash[1] != '\0') ? slash + 1 : unit_name;
|
||||
}
|
||||
|
||||
static void report_award_event(const LocalMpAwardEvent *ev, const char *source_unit)
|
||||
{
|
||||
__declspec(align(16)) uint8_t blk[LMP_BLK_SIZE];
|
||||
uint8_t *gsd = g_game_save_data ? *g_game_save_data : NULL;
|
||||
@@ -72,6 +78,8 @@ void local_mp_report_award_event(const LocalMpAwardEvent *ev)
|
||||
fn_blk_set_str(blk, "expClass", victim_class ? victim_class : "");
|
||||
fn_blk_set_str(blk, "victim", victim_name ? victim_name : "");
|
||||
fn_blk_set_str(blk, "messageModifier", ev->modifier ? ev->modifier : "");
|
||||
if (source_unit != NULL)
|
||||
fn_blk_set_str(blk, "unit", bare_unit_name(source_unit));
|
||||
blk_set_int(blk, "messageCode", (int32_t)ev->exp_event);
|
||||
blk_set_int(blk, "victimIsPlayer", ev->victim_is_player ? 1 : 0);
|
||||
blk_set_int(blk, "friendly", ev->friendly ? 1 : 0);
|
||||
@@ -80,6 +88,17 @@ void local_mp_report_award_event(const LocalMpAwardEvent *ev)
|
||||
fn_blk_dtor(blk);
|
||||
}
|
||||
|
||||
void local_mp_report_award_event(const LocalMpAwardEvent *ev)
|
||||
{
|
||||
report_award_event(ev, NULL);
|
||||
}
|
||||
|
||||
void local_mp_report_capture(const char *unit_name)
|
||||
{
|
||||
const LocalMpAwardEvent award = { LMP_EXP_EVENT_CAPTURE_ZONE, NULL, 0, 0, NULL, 0 };
|
||||
report_award_event(&award, unit_name);
|
||||
}
|
||||
|
||||
/* The fact behind the award killStreak_bomber_nuclear_success, which online the battle server
|
||||
* judges itself; the event carries no fields. */
|
||||
void local_mp_report_nuclear_strike(void)
|
||||
@@ -114,16 +133,11 @@ void local_mp_report_backup_spawn(const char *unit_name, int32_t slot_id, const
|
||||
{
|
||||
__declspec(align(16)) uint8_t blk[LMP_BLK_SIZE];
|
||||
uint8_t *gsd = g_game_save_data ? *g_game_save_data : NULL;
|
||||
const char *slash;
|
||||
|
||||
if (gsd == NULL || fn_hud_notify_script == NULL || unit_name == NULL)
|
||||
return;
|
||||
slash = strrchr(unit_name, '/');
|
||||
if (slash != NULL && slash[1] != '\0')
|
||||
unit_name = slash + 1;
|
||||
memset(blk, 0, sizeof(blk));
|
||||
fn_blk_ctor(blk);
|
||||
fn_blk_set_str(blk, "unit", unit_name);
|
||||
fn_blk_set_str(blk, "unit", bare_unit_name(unit_name));
|
||||
fn_blk_set_str(blk, "backup", backup);
|
||||
blk_set_int(blk, "slot", slot_id);
|
||||
fn_hud_notify_script(gsd + LMP_GSD_OFF_HUD_QUEUE, "wtoLocalMpBackupSpawn", blk);
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
/* Credit completed captures using the mission engine's own unit eligibility checks. */
|
||||
#include "hook_config.h"
|
||||
#include "local_mp_internal.h"
|
||||
#include "local_mp_offsets.h"
|
||||
|
||||
#include <intrin.h>
|
||||
#include <windows.h>
|
||||
|
||||
typedef void (__fastcall *SetZoneOwnerFn)(uint8_t *zone, int32_t team);
|
||||
typedef float (__fastcall *TeamCapturePowerFn)(int32_t team, uint8_t *zone, int32_t *count);
|
||||
typedef float (__fastcall *UnitCapturePowerFn)(uint8_t *zone, const uint8_t *unit);
|
||||
|
||||
typedef struct CaptureAward {
|
||||
uint8_t *player;
|
||||
const char *unit_name;
|
||||
float power;
|
||||
float score;
|
||||
} CaptureAward;
|
||||
|
||||
typedef struct CaptureScan {
|
||||
const uint8_t *zone;
|
||||
int32_t team;
|
||||
CaptureAward awards[UINT8_MAX + 1];
|
||||
} CaptureScan;
|
||||
|
||||
static __declspec(thread) CaptureScan *active_scan;
|
||||
static SetZoneOwnerFn original_set_owner;
|
||||
static UnitCapturePowerFn original_unit_power;
|
||||
static uintptr_t cta_end;
|
||||
|
||||
static float __fastcall hook_unit_power(uint8_t *zone, const uint8_t *unit)
|
||||
{
|
||||
float power = original_unit_power(zone, unit);
|
||||
CaptureScan *scan = active_scan;
|
||||
if (scan == NULL || scan->zone != zone || unit == NULL || !(power > 0.0f))
|
||||
return power;
|
||||
|
||||
uint8_t *player = *(uint8_t *const *)(unit + LMP_UNIT_OFF_MPLAYER);
|
||||
if (player == NULL || player[LMP_MP_OFF_TEAM] != scan->team)
|
||||
return power;
|
||||
|
||||
CaptureAward *award = &scan->awards[player[LMP_MP_OFF_PID]];
|
||||
if (power > award->power) {
|
||||
award->player = player;
|
||||
award->unit_name = local_mp_unit_name(unit);
|
||||
award->power = power;
|
||||
award->score = local_mp_event_score("capture", unit, 1);
|
||||
}
|
||||
return power;
|
||||
}
|
||||
|
||||
static int is_capture_completion(uintptr_t return_address)
|
||||
{
|
||||
return return_address == (uintptr_t)g_lmp.capture_complete_call + LMP_REL32_CALL_SIZE ||
|
||||
(return_address >= (uintptr_t)g_lmp.capture_cta_logic && return_address < cta_end);
|
||||
}
|
||||
|
||||
static void credit_capture(const CaptureAward *award)
|
||||
{
|
||||
uint8_t *player = award->player;
|
||||
local_mp_inc_mplayer_stat(player, LMP_MP_OFF_CAPTURE_ZONE);
|
||||
local_mp_add_personal_score(player, award->score, LMP_EXP_EVENT_CAPTURE_ZONE);
|
||||
local_mp_mark_mplayer_dirty(player);
|
||||
if (local_mp_is_local_mplayer(player))
|
||||
local_mp_report_capture(award->unit_name);
|
||||
}
|
||||
|
||||
static void __fastcall hook_set_owner(uint8_t *zone, int32_t team)
|
||||
{
|
||||
if (!local_mp_is_host() || !is_capture_completion((uintptr_t)_ReturnAddress()) ||
|
||||
(team != 1 && team != 2) || zone[g_lmp.capture_owner] == team) {
|
||||
original_set_owner(zone, team);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Run the same side's eligibility walk immediately before the ownership commit. A player
|
||||
can have several eligible units in that walk, so credit their strongest one once. */
|
||||
CaptureScan scan = { .zone = zone, .team = team };
|
||||
CaptureScan *previous = active_scan;
|
||||
int32_t count = 0;
|
||||
active_scan = &scan;
|
||||
((TeamCapturePowerFn)g_lmp.capture_team_power)(team, zone, &count);
|
||||
active_scan = previous;
|
||||
|
||||
original_set_owner(zone, team);
|
||||
if (zone[g_lmp.capture_owner] != team)
|
||||
return;
|
||||
for (size_t pid = 0; pid < sizeof(scan.awards) / sizeof(scan.awards[0]); ++pid) {
|
||||
if (scan.awards[pid].player != NULL)
|
||||
credit_capture(&scan.awards[pid]);
|
||||
}
|
||||
}
|
||||
|
||||
int install_local_mp_capture_hooks(void)
|
||||
{
|
||||
DWORD64 base;
|
||||
const RUNTIME_FUNCTION *cta = RtlLookupFunctionEntry((DWORD64)g_lmp.capture_cta_logic, &base, NULL);
|
||||
if (cta == NULL || g_lmp.capture_complete_set_owner != g_lmp.capture_set_owner) {
|
||||
log_line("local_mp: local_mp_captures skipped: inconsistent ownership call sites");
|
||||
return 0;
|
||||
}
|
||||
cta_end = (uintptr_t)(base + cta->EndAddress);
|
||||
const LocalMpHookSpec hooks[] = {
|
||||
{ "capture_set_owner", g_lmp.capture_set_owner, (void *)&hook_set_owner, (void **)&original_set_owner },
|
||||
{ "capture_unit_power", g_lmp.capture_unit_power, (void *)&hook_unit_power, (void **)&original_unit_power },
|
||||
};
|
||||
return local_mp_queue_hooks("local_mp_captures", hooks, sizeof(hooks) / sizeof(hooks[0]));
|
||||
}
|
||||
@@ -139,10 +139,12 @@ 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_captures", install_local_mp_capture_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 },
|
||||
{ "local_mp_hit_feedback", install_local_mp_hit_feedback_hooks },
|
||||
{ "local_mp_air_events", install_local_mp_air_event_hooks },
|
||||
{ "local_mp_ground_ai", install_local_mp_ground_ai_hooks },
|
||||
{ "local_mp_air_ai_sync", install_local_mp_air_ai_sync_hooks },
|
||||
|
||||
@@ -56,6 +56,7 @@ static int suppressed_avionics_logged;
|
||||
static int suppressed_optic_logged;
|
||||
static int suppressed_parts_logged;
|
||||
static int suppressed_enemy_mpi_logged;
|
||||
static int damage_hooks_queued;
|
||||
|
||||
static const uint8_t *local_mplayer(void)
|
||||
{
|
||||
@@ -99,17 +100,29 @@ static const uint8_t *watched_unit(const uint8_t *mplayer)
|
||||
}
|
||||
|
||||
/* The owner check also covers projectiles fired before switching to a support vehicle. */
|
||||
static int is_local_enemy_hit(const uint8_t *attacker, const uint8_t *victim)
|
||||
int local_mp_is_view_hit(const uint8_t *attacker, const uint8_t *victim)
|
||||
{
|
||||
const uint8_t *mplayer = local_mplayer();
|
||||
if (attacker == NULL || attacker == victim || mplayer == NULL)
|
||||
return 0;
|
||||
if (victim[LMP_UNIT_OFF_ARMY] != 0 && victim[LMP_UNIT_OFF_ARMY] == attacker[LMP_UNIT_OFF_ARMY])
|
||||
|
||||
const uint8_t *owner = owning_mplayer(attacker);
|
||||
if (owner != NULL && owner == owning_mplayer(victim))
|
||||
return 0;
|
||||
return owning_mplayer(attacker) == mplayer || attacker == controlled_unit(mplayer)
|
||||
return owner == mplayer || attacker == controlled_unit(mplayer)
|
||||
|| attacker == watched_unit(mplayer);
|
||||
}
|
||||
|
||||
int local_mp_has_enemy_hit_feedback(void)
|
||||
{
|
||||
return active_hit_victim != NULL;
|
||||
}
|
||||
|
||||
int local_mp_damage_notifications_ready(void)
|
||||
{
|
||||
return damage_hooks_queued;
|
||||
}
|
||||
|
||||
static uint8_t __fastcall hook_barrel_damage(void *damage, const uint8_t *impact)
|
||||
{
|
||||
/* The stock handler resolves the reference before it emits the notice and tags it in bit 0. */
|
||||
@@ -202,7 +215,9 @@ static uint64_t __fastcall hook_unit_on_event(void *unit, const uint8_t *event,
|
||||
if (unit != NULL && event != NULL && local_mp_is_host()
|
||||
&& *(const uint16_t *)(event + g_lmp.mpi_msg_id_off) == LMP_MPI_MSG_HIT_FEEDBACK) {
|
||||
const uint8_t *attacker = *(const uint8_t *const *)(event + g_lmp.hit_event_offender);
|
||||
if (is_local_enemy_hit(attacker, unit))
|
||||
const uint8_t *victim = unit;
|
||||
if (local_mp_is_view_hit(attacker, victim) &&
|
||||
(victim[LMP_UNIT_OFF_ARMY] == 0 || victim[LMP_UNIT_OFF_ARMY] != attacker[LMP_UNIT_OFF_ARMY]))
|
||||
active_hit_victim = unit;
|
||||
}
|
||||
result = original_unit_on_event(unit, event, arg3, arg4);
|
||||
@@ -288,5 +303,6 @@ int install_local_mp_damage_notification_hooks(void)
|
||||
log_line("local_mp: local_mp_damage_notifications skipped: barrel and breech deliver addresses differ");
|
||||
return 0;
|
||||
}
|
||||
return local_mp_queue_hooks("local_mp_damage_notifications", hooks, sizeof(hooks) / sizeof(hooks[0]));
|
||||
damage_hooks_queued = local_mp_queue_hooks("local_mp_damage_notifications", hooks, sizeof(hooks) / sizeof(hooks[0]));
|
||||
return damage_hooks_queued;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* LocalMP non-fatal combat event dispatchers: deduplicated assists across air/ground/naval,
|
||||
* zone captures, hit results, severe damage, and naval damage awards.
|
||||
* hit results, severe damage, and naval damage awards.
|
||||
*
|
||||
* `IGroundModel::onBecameDead` calls both `IGroundModel::awardAssists` (`0x465540`) and
|
||||
* `Unit::awardAssists` (`0xe5b200` -> `dispatchAssist` `0x35beb0`); deduplicating `(victim, mp)`
|
||||
@@ -27,7 +27,6 @@ typedef struct AssistDedupRecord {
|
||||
|
||||
typedef void (__fastcall *IGroundAwardAssistsFn)(uint8_t *victim);
|
||||
typedef void (__fastcall *DispatchAssistFn)(int64_t uid, uint8_t *victim, uint8_t *offender, float share, int32_t extra);
|
||||
typedef void (__fastcall *DispatchCaptureZoneFn)(int64_t uid, uint8_t *capturer_unit);
|
||||
typedef void (__fastcall *DispatchHitFn)(
|
||||
int64_t uid, uint8_t *victim, uint8_t *offender, float dmg, uint8_t repeat_flush, uint8_t effective_hit, uint8_t extra);
|
||||
typedef void (__fastcall *DispatchSevereDamageFn)(int64_t uid, uint8_t *victim, uint8_t *offender);
|
||||
@@ -35,7 +34,6 @@ typedef void (__fastcall *DispatchNavalDamageFn)(int64_t uid, uint8_t *victim, u
|
||||
|
||||
static IGroundAwardAssistsFn orig_iground_award_assists;
|
||||
static DispatchAssistFn orig_dispatch_assist;
|
||||
static DispatchCaptureZoneFn orig_dispatch_capture_zone;
|
||||
static DispatchHitFn orig_dispatch_hit;
|
||||
static DispatchSevereDamageFn orig_dispatch_severe_damage;
|
||||
static DispatchNavalDamageFn orig_dispatch_naval_damage;
|
||||
@@ -135,27 +133,6 @@ static void __fastcall hook_dispatch_assist(int64_t uid, uint8_t *victim, uint8_
|
||||
orig_dispatch_assist(uid, victim, offender, share, extra);
|
||||
}
|
||||
|
||||
static void __fastcall hook_dispatch_capture_zone(int64_t uid, uint8_t *capturer_unit)
|
||||
{
|
||||
if (local_mp_is_host()) {
|
||||
uint8_t *mp = local_mp_find_mplayer(uid, 0xffu);
|
||||
if (mp == NULL && capturer_unit != NULL)
|
||||
mp = *(uint8_t **)(capturer_unit + LMP_UNIT_OFF_MPLAYER);
|
||||
if (mp != NULL) {
|
||||
const uint8_t *own_unit = capturer_unit != NULL ? capturer_unit
|
||||
: (g_lmp_get_unit_by_eid ? (const uint8_t *)g_lmp_get_unit_by_eid(*(uint32_t *)(mp + LMP_MP_OFF_UNIT_EID)) : NULL);
|
||||
local_mp_inc_mplayer_stat(mp, LMP_MP_OFF_CAPTURE_ZONE);
|
||||
local_mp_add_mplayer_score(mp, local_mp_event_score("capture", own_unit, 1), LMP_EXP_EVENT_CAPTURE_ZONE);
|
||||
local_mp_mark_mplayer_dirty(mp);
|
||||
if (local_mp_is_local_mplayer(mp)) {
|
||||
LocalMpAwardEvent award = { LMP_EXP_EVENT_CAPTURE_ZONE, NULL, 0, 0, NULL, 0 };
|
||||
local_mp_report_award_event(&award);
|
||||
}
|
||||
}
|
||||
}
|
||||
orig_dispatch_capture_zone(uid, capturer_unit);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unit::flushOffenderHitAward passes a repeat marker and an effective-hit flag. Its stock
|
||||
* single-player path (.58 0xffd369) selects HIT / INEFFECTIVE_HIT from that same flag. The
|
||||
@@ -240,7 +217,6 @@ int install_local_mp_event_hooks(void)
|
||||
const LocalMpHookSpec hooks[] = {
|
||||
{ "iground_award_assists", g_lmp.iground_award_assists, (void *)&hook_iground_award_assists, (void **)&orig_iground_award_assists },
|
||||
{ "dispatch_assist", g_lmp.dispatch_assist, (void *)&hook_dispatch_assist, (void **)&orig_dispatch_assist },
|
||||
{ "dispatch_capture_zone", g_lmp.dispatch_capture_zone, (void *)&hook_dispatch_capture_zone, (void **)&orig_dispatch_capture_zone },
|
||||
{ "dispatch_hit", g_lmp.dispatch_hit, (void *)&hook_dispatch_hit, (void **)&orig_dispatch_hit },
|
||||
{ "dispatch_severe_damage", g_lmp.dispatch_severe_damage, (void *)&hook_dispatch_severe_damage, (void **)&orig_dispatch_severe_damage },
|
||||
{ "dispatch_naval_damage", g_lmp.dispatch_naval_damage, (void *)&hook_dispatch_naval_damage, (void **)&orig_dispatch_naval_damage },
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/* Validate recipient ownership at the two outgoing hit-feedback dispatch points. */
|
||||
#include "local_mp_internal.h"
|
||||
#include "local_mp_offsets.h"
|
||||
|
||||
#include <intrin.h>
|
||||
|
||||
typedef void (__fastcall *SendScriptNetEventFn)(void *manager, uint8_t broadcast, uint32_t destination,
|
||||
const void *event, const char *event_name, const void *recipient_args, const void *recipient_filter);
|
||||
typedef void (__fastcall *NotifyHudScriptFn)(void *hud, int32_t event_id, const void *data);
|
||||
|
||||
/* The CmdShowHitMark unicast constructor writes 0x0001001c6c52bfea followed by its victim EID.
|
||||
* The stock sender handles event destruction when its flags require it. This event is plain data. */
|
||||
typedef struct HitMarkEvent {
|
||||
uint32_t type;
|
||||
uint16_t size;
|
||||
uint16_t flags;
|
||||
uint32_t victim;
|
||||
} HitMarkEvent;
|
||||
|
||||
enum { HIT_MARK_EVENT_TYPE = 0x6c52bfea, HIT_MARK_EVENT_SIZE = 0x1c, ECS_EVENT_UNICAST = 1 };
|
||||
enum { HUD_HINT_CHANGE_SHELL_TYPE = 0xc5 };
|
||||
|
||||
static SendScriptNetEventFn original_send_script_event;
|
||||
static NotifyHudScriptFn original_notify_hud_script;
|
||||
|
||||
static int should_drop_hit_mark(uint8_t broadcast, uint32_t destination, const HitMarkEvent *event)
|
||||
{
|
||||
if (event == NULL || event->type != HIT_MARK_EVENT_TYPE || event->size != HIT_MARK_EVENT_SIZE ||
|
||||
event->flags != ECS_EVENT_UNICAST || broadcast || !local_mp_is_host())
|
||||
return 0;
|
||||
|
||||
const uint8_t *attacker = g_lmp_get_unit_by_eid(destination);
|
||||
const uint8_t *victim = g_lmp_get_unit_by_eid(event->victim);
|
||||
return !local_mp_is_view_hit(attacker, victim);
|
||||
}
|
||||
|
||||
static void __fastcall hook_send_script_event(void *manager, uint8_t broadcast, uint32_t destination,
|
||||
const void *event, const char *event_name, const void *recipient_args, const void *recipient_filter)
|
||||
{
|
||||
if (!should_drop_hit_mark(broadcast, destination, event))
|
||||
original_send_script_event(manager, broadcast, destination, event, event_name, recipient_args, recipient_filter);
|
||||
}
|
||||
|
||||
static void __fastcall hook_notify_hud_script(void *hud, int32_t event_id, const void *data)
|
||||
{
|
||||
if (event_id == HUD_HINT_CHANGE_SHELL_TYPE &&
|
||||
(uintptr_t)_ReturnAddress() == (uintptr_t)g_lmp.hit_shell_hint_call + LMP_REL32_CALL_SIZE &&
|
||||
local_mp_is_host() && !local_mp_has_enemy_hit_feedback())
|
||||
return;
|
||||
original_notify_hud_script(hud, event_id, data);
|
||||
}
|
||||
|
||||
int install_local_mp_hit_feedback_hooks(void)
|
||||
{
|
||||
if (!local_mp_damage_notifications_ready())
|
||||
return 0;
|
||||
|
||||
const LocalMpHookSpec hooks[] = {
|
||||
{ "send_script_net_event", g_lmp.hit_mark_send, (void *)&hook_send_script_event, (void **)&original_send_script_event },
|
||||
{ "notify_shell_hint", g_lmp.hit_shell_hint_notify, (void *)&hook_notify_hud_script, (void **)&original_notify_hud_script },
|
||||
};
|
||||
return local_mp_queue_hooks("local_mp_hit_feedback", hooks, sizeof(hooks) / sizeof(hooks[0]));
|
||||
}
|
||||
@@ -62,6 +62,7 @@ void local_mp_players_queue_spawn(int32_t slot_id, int32_t spare_type, int32_t b
|
||||
|
||||
/* Local player events sent to the GUI scripts (local_mp_awards.c). */
|
||||
void local_mp_report_award_event(const LocalMpAwardEvent *ev);
|
||||
void local_mp_report_capture(const char *unit_name);
|
||||
void local_mp_report_nuclear_strike(void);
|
||||
void local_mp_report_airfield_spawn(const char *unit_name, int32_t base_id);
|
||||
void local_mp_report_backup_spawn(const char *unit_name, int32_t slot_id, const char *backup);
|
||||
@@ -103,10 +104,15 @@ int install_local_mp_action_hooks(void);
|
||||
int install_local_mp_award_hooks(void);
|
||||
int install_local_mp_kill_hooks(void);
|
||||
int install_local_mp_event_hooks(void);
|
||||
int install_local_mp_capture_hooks(void);
|
||||
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_hit_feedback_hooks(void);
|
||||
int local_mp_damage_notifications_ready(void);
|
||||
int local_mp_is_view_hit(const uint8_t *attacker, const uint8_t *victim);
|
||||
int local_mp_has_enemy_hit_feedback(void);
|
||||
int install_local_mp_zone_hooks(void);
|
||||
void local_mp_zones_reset(void);
|
||||
int install_local_mp_air_event_hooks(void);
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#include "local_mp_values.h"
|
||||
|
||||
#define LMP_REL32_CALL_SIZE (1 + sizeof(int32_t)) /* x64 E8 + signed displacement */
|
||||
|
||||
#define LMP_GUI_STATE_PILOT_CONTROL 2
|
||||
#define LMP_GUI_STATE_CA_SELECT 6
|
||||
#define LMP_GUI_STATE_CA_READY 8
|
||||
|
||||
@@ -37,10 +37,12 @@ typedef struct LmpValueSpec {
|
||||
#define SCORES "local_mp_scores"
|
||||
#define KILLS "local_mp_kills"
|
||||
#define EVENTS "local_mp_events"
|
||||
#define CAPTURES "local_mp_captures"
|
||||
#define ZONES "local_mp_zones"
|
||||
#define NUKE "local_mp_nuke"
|
||||
#define SUPPORT "local_mp_support"
|
||||
#define DAMAGE_NOTICES "local_mp_damage_notifications"
|
||||
#define HIT_FEEDBACK "local_mp_hit_feedback"
|
||||
#define AIR_EVENTS "local_mp_air_events"
|
||||
#define GROUND_AI "local_mp_ground_ai"
|
||||
#define AIR_AI_SYNC "local_mp_air_ai_sync"
|
||||
@@ -138,10 +140,16 @@ static const LmpValueSpec SPECS[] = {
|
||||
O(KILLS, "stat_award_damage.field", mp_award_damage), O(KILLS, "stat_air_severe.field", mp_air_severe_dmg),
|
||||
O(KILLS, "stat_ship_severe.field", mp_ship_severe_dmg),
|
||||
|
||||
A(EVENTS, "dispatch_assist", dispatch_assist), A(EVENTS, "caller_capture_zone.call", dispatch_capture_zone),
|
||||
A(EVENTS, "dispatch_assist", dispatch_assist),
|
||||
A(EVENTS, "caller_hit_crit.call", dispatch_hit), A(EVENTS, "caller_severe_damage.call", dispatch_severe_damage),
|
||||
A(EVENTS, "caller_naval_damage.call", dispatch_naval_damage), O(EVENTS, "offender_assist.assist_sent", offender_assist_sent),
|
||||
|
||||
A(CAPTURES, "capture_cta_logic", capture_cta_logic),
|
||||
A(CAPTURES, "capture_set_owner", capture_set_owner), O(CAPTURES, "capture_set_owner.owner", capture_owner),
|
||||
A(CAPTURES, "capture_complete_call", capture_complete_call),
|
||||
A(CAPTURES, "capture_complete_call.set_owner", capture_complete_set_owner),
|
||||
A(CAPTURES, "capture_team_power", capture_team_power), A(CAPTURES, "capture_unit_power_call.function", capture_unit_power),
|
||||
|
||||
A(NUKE, "shell_launch", shell_launch), A(NUKE, "shell_explode", shell_explode), A(NUKE, "cta_logic_action", cta_logic_action),
|
||||
O(NUKE, "shell_instant_win.record", shell_launch_record), O(NUKE, "shell_instant_win.instant_win", shell_rec_instant_win),
|
||||
O(NUKE, "mission_vars_data.data", mission_vars_data), O(NUKE, "mission_vars_walk.count", mission_vars_count),
|
||||
@@ -172,6 +180,10 @@ static const LmpValueSpec SPECS[] = {
|
||||
O(DAMAGE_NOTICES, "enemy_part_damage_mpi.msg_id", enemy_part_dmg_mpi_id),
|
||||
O(DAMAGE_NOTICES, "enemy_part_hit_mpi.msg_id", enemy_part_hit_mpi_id),
|
||||
|
||||
A(HIT_FEEDBACK, "hit_mark_send.send", hit_mark_send),
|
||||
A(HIT_FEEDBACK, "hit_shell_hint_call", hit_shell_hint_call),
|
||||
A(HIT_FEEDBACK, "hit_shell_hint_call.notify", hit_shell_hint_notify),
|
||||
|
||||
O(AIR_EVENTS, "mission_mode_name.mode_name", mis_mode_name),
|
||||
A(AIR_EVENTS, "prepare_local_mission", prepare_local_mission),
|
||||
A(AIR_EVENTS, "prepare_local_mission_clear.use_kill_streaks", use_kill_streaks),
|
||||
|
||||
@@ -61,9 +61,14 @@ typedef struct LmpValues {
|
||||
size_t mp_award_damage, mp_air_severe_dmg, mp_ship_severe_dmg;
|
||||
|
||||
/* local_mp_events */
|
||||
uint8_t *dispatch_assist, *dispatch_capture_zone, *dispatch_hit, *dispatch_severe_damage, *dispatch_naval_damage;
|
||||
uint8_t *dispatch_assist, *dispatch_hit, *dispatch_severe_damage, *dispatch_naval_damage;
|
||||
size_t offender_assist_sent;
|
||||
|
||||
/* local_mp_captures */
|
||||
uint8_t *capture_cta_logic, *capture_set_owner, *capture_complete_call, *capture_complete_set_owner;
|
||||
uint8_t *capture_team_power, *capture_unit_power;
|
||||
size_t capture_owner;
|
||||
|
||||
/* local_mp_nuke */
|
||||
uint8_t *shell_launch, *shell_explode, *cta_logic_action;
|
||||
size_t shell_launch_record, shell_rec_instant_win, mission_vars_data, mission_vars_count, mission_var_stride;
|
||||
@@ -82,6 +87,9 @@ 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_hit_feedback */
|
||||
uint8_t *hit_mark_send, *hit_shell_hint_call, *hit_shell_hint_notify;
|
||||
|
||||
/* local_mp_zones */
|
||||
uint8_t *apply_zone_damage;
|
||||
size_t zone_health, zone_max_health, zone_team, zone_flags, zone_airfield_mask;
|
||||
|
||||
@@ -82,7 +82,9 @@ function wtoOnLocalMpExpEvent(ev) {
|
||||
if (battle == null)
|
||||
return
|
||||
let wtoMission = require("mission")
|
||||
let unit = ndbTryRead(["wto", "battleLog", "openLife"])?.unit ?? require("unit").get_player_unit_name()
|
||||
let sourceUnit = ev?.unit ?? ""
|
||||
let unit = battle?.awards?.vehicles?[sourceUnit] != null ? sourceUnit
|
||||
: ndbTryRead(["wto", "battleLog", "openLife"])?.unit ?? require("unit").get_player_unit_name()
|
||||
let entry = {
|
||||
time = wtoMission.get_mission_time()
|
||||
unit
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
// Award capture credit to players whose units contribute to a completed LocalMP capture.
|
||||
// Only the mission engine knows when a zone changes owner and which units it counted.
|
||||
// Without this module, the scoreboard and settlement miss completed captures.
|
||||
{
|
||||
"module": "local_mp_captures",
|
||||
"features": ["K-Kill, assist and capture scoring"],
|
||||
"requires": ["local_mp_core", "local_mp_kills", "local_mp_scores", "local_mp_awards"],
|
||||
"sites": {
|
||||
// cta_logic_action contains the zone-update timing diagnostic and the inline airfield completion path.
|
||||
"capture_cta_logic": {
|
||||
"variants": [{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": { "method": "string_ref", "string": "update_capture_zones", "target": "function" }
|
||||
}]
|
||||
},
|
||||
// CaptureZone::setArmy. Read the old owner before the native replicated setter runs.
|
||||
// 2.61.0.37: 0x11b7f70; 2.61.0.60: 0x11bcba0.
|
||||
"capture_set_owner": {
|
||||
"variants": [{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "signature",
|
||||
"pattern": "41 57 41 56 41 55 41 54 56 57 55 53 48 81 ec 28 01 00 00 0f 29 b4 24 10 01 00 00 0f b6 71 ?? 89 54 24 2c 39 f2 0f 84 ?? ?? ?? ?? 49 89 cd",
|
||||
"captures": { "owner": { "offset": 30, "type": "u8" } }
|
||||
}
|
||||
}]
|
||||
},
|
||||
// The setArmy call made when the ordinary progress helper reaches the capturing team's limit.
|
||||
// 2.61.0.37: 0x11c2095; 2.61.0.60: 0x11c7605.
|
||||
"capture_complete_call": {
|
||||
"variants": [{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "signature",
|
||||
"pattern": "e8 ?? ?? ?? ?? 48 8b 0d ?? ?? ?? ?? 48 8b 05 ?? ?? ?? ?? 48 85 c0 74 ?? 80 3d ?? ?? ?? ?? 00 75 ?? 80 3d ?? ?? ?? ?? 00 75 ?? 48 8d 50 70",
|
||||
"captures": { "set_owner": { "offset": 1, "type": "rel32" } }
|
||||
}
|
||||
}]
|
||||
},
|
||||
// sumCapturePower(army, zone, &count) walks eligible mission units for one team.
|
||||
// 2.61.0.37: 0x11b90a0; 2.61.0.60: 0x11bdd30.
|
||||
"capture_team_power": {
|
||||
"variants": [{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "signature",
|
||||
"pattern": "41 57 41 56 41 55 41 54 56 57 55 53 48 81 ec b8 00 00 00 0f 29 b4 24 a0 00 00 00 48 89 d7 89 4c 24 3c 4c 89 44 24 40 41 c7 00 00 00 00 00 48 b8 32 00 00 00 ff ff ff ff"
|
||||
}
|
||||
}]
|
||||
},
|
||||
// sumCapturePower calls this helper after accepting a unit and increments its count.
|
||||
// 2.61.0.37: 0x11b9214 -> 0x11b8f10; 2.61.0.60: 0x11bdea4 -> 0x11bdba0.
|
||||
"capture_unit_power_call": {
|
||||
"variants": [{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "within",
|
||||
"in": "capture_team_power",
|
||||
"pattern": "ff 00 48 89 f9 48 89 ea e8 ?? ?? ?? ?? f3 0f 58 f0",
|
||||
"captures": { "function": { "offset": 9, "type": "rel32" } }
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// Combat events on the LocalMP host (native/wto-net/src/local_mp_events.c): assists, captures,
|
||||
// Combat events on the LocalMP host (native/wto-net/src/local_mp_events.c): assists,
|
||||
// effective and ineffective hits, and severe damage, reported as award facts.
|
||||
// Without it: assists, captures and damage events score nothing in LocalMP battles.
|
||||
// Without it: assists and damage events score nothing in LocalMP battles.
|
||||
{
|
||||
"module": "local_mp_events",
|
||||
"features": [
|
||||
@@ -26,25 +26,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
// A caller of the capture zone dispatch; captures the callee.
|
||||
// 2.61.0.37: 0x3db0e0
|
||||
"caller_capture_zone": {
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "signature",
|
||||
"pattern": "41 57 41 56 41 55 41 54 56 57 55 53 48 83 ec 38 44 0f b7 72 02 44 8b 7a 04 4c 8b 62 08 4c 8b 6a 18 49 8d 85 88 06 00 00 48 89 44 24 30 49 8d 85 50 06 00 00 48 89 44 24 28 eb ?? 48 8b 90 08 0e 00 00 89 d1 83 e1 01 0b 0d ?? ?? ?? ?? 3b 88 14 0e 00 00 0f 85 ?? ?? ?? ?? 48 83 e2 fe 48 8b 82 98 0f 00 00 48 8b 88 b8 00 00 00 e8 ?? ?? ?? ??",
|
||||
"captures": {
|
||||
"call": {
|
||||
"offset": 108,
|
||||
"type": "rel32"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// Flushes effective / ineffective hits. The site key also identifies this capture in version records.
|
||||
// 2.61.0.37: 0xff85ea
|
||||
"caller_hit_crit": {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// Keep outgoing hit markers and shell advice tied to the firing unit on a LocalMP host.
|
||||
// The local daScript send path bypasses the recipient filter. The native shell hint has its own dispatch.
|
||||
// Without this module, impacts by other units can reach the local attack feedback paths.
|
||||
{
|
||||
"module": "local_mp_hit_feedback",
|
||||
"features": ["K-Player damage notices"],
|
||||
"requires": ["local_mp_core", "local_mp_damage_notifications"],
|
||||
"sites": {
|
||||
// CmdShowHitMark unicast wrapper calls the common daScript network event sender. The inline
|
||||
// damage script and the interpreted wrapper use that same sender.
|
||||
// 2.61.0.37: 0x1eaa106 -> 0x50a06e0; 2.61.0.60: 0x1eb79b6 -> 0x50b13c0.
|
||||
"hit_mark_send": {
|
||||
"variants": [{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "string_ref",
|
||||
"string": "CmdShowHitMark",
|
||||
"lea_at": 0,
|
||||
"pattern": "48 8d 15 ?? ?? ?? ?? 66 48 0f 6e ca 66 0f 7f 8c 24 f0 00 00 00 66 0f 7f 84 24 00 01 00 00 41 0f 10 01 4c 8d 4c 24 70 4c 89 4c 24 40 4c 8d 4c 24 40 4c 89 4c 24 50 4c 8d 0d ?? ?? ?? ?? 4c 89 4c 24 48 c6 44 24 68 01 0f 11 44 24 58 48 8b 89 30 03 00 00 4c 8d 4c 24 48 4c 89 4c 24 30 4c 8d 4c 24 58 4c 89 4c 24 28 48 89 54 24 20 31 d2 49 89 c1 e8 ?? ?? ?? ??",
|
||||
"captures": { "send": { "offset": 114, "type": "rel32" } }
|
||||
}
|
||||
}]
|
||||
},
|
||||
// The shell-change hint's call in Unit::onEvent, just before it queues enemy damage parts.
|
||||
// 2.61.0.37: 0x1045fbe -> 0x183bcc0; 2.61.0.60: 0x104a8e4 -> 0x1844c30.
|
||||
"hit_shell_hint_call": {
|
||||
"variants": [{
|
||||
"written_for": "2.61.0.37",
|
||||
"locate": {
|
||||
"method": "within",
|
||||
"in": "unit_on_event",
|
||||
"pattern": "e8 ?? ?? ?? ?? 48 8b 0d ?? ?? ?? ?? 4c 8d b4 24 00 01 00 00 4c 89 ea 4d 89 f0 e8 ?? ?? ?? ??",
|
||||
"captures": { "notify": { "offset": 1, "type": "rel32" } }
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user