feat(ground-ai): return bot movement control on failure

Grant custom physics control per LocalMP bot and let the native layer release it when the script stops renewing control. Verified both TypeScript checks, the MSVC build, native resolution and check-patches on .37 and .58, and isolated .58 script loading.
This commit is contained in:
N0VAN0M4LY committed 2026-12-03 14:24:32 +08:00
1 parent bb680c6abd
commit 885e3bbb5d
15 files changed
+325 -63

No files matched your search

@@ -106,6 +106,7 @@ function readNavigationSection(nav: TuningReader): GroundAiTuning['navigation']
maxPhysBots: nav.int('maxPhysBots', { min: 0, max: 64 }),
steerSign,
deadEchoSec: nav.number('deadEchoSec', { min: 0.3, max: 10 }),
controlTimeoutSec: nav.number('controlTimeoutSec', { min: 0.3, max: 10 }),
cornerBrakeAccel: nav.number('cornerBrakeAccel', { min: 0.5, max: 8 }),
pivotAngleDeg: nav.number('pivotAngleDeg', { min: 25, max: 150 }),
stuckWindowSec: nav.number('stuckWindowSec', { min: 1, max: 15 }),
+2
View File
@@ -51,10 +51,12 @@
},
"navigation": {
// "vehicle_phys" uses custom inputs with native ownership. "movesys" keeps stock movement.
"driveMode": "vehicle_phys",
"maxPhysBots": 64,
"steerSign": 1.0,
"deadEchoSec": 1.2,
"controlTimeoutSec": 1.0,
"cornerBrakeAccel": 1.75,
"pivotAngleDeg": 75.0,
"stuckWindowSec": 3.6,
+58 -55
View File
@@ -1,6 +1,6 @@
// Chassis drive actuator: translates `WtoDriveCmd` into closed-loop `VehiclePhysActor` axes
// (throttle, steering, brakes, auto-transmission) with space-aware 3-point turns, smooth
// long-distance reverse control, and dead-echo watchdog fallback to `MoveSys`.
// long-distance reverse control, and dead-echo watchdog return to stock movement.
options indenting = 2
options no_global_heap = true
module wto_ai_drive_common shared
@@ -19,33 +19,11 @@ require %appGame.wtoai.wto_ai_math_common
require %appGame.wtoai.wto_ai_types_common
[never_inline]
def public wto_drive_prepare_unit(unitMissionName : string)
if empty(unitMissionName)
return
def public wto_drive_request_control(eid : EntityId; holdMs : int)
using() <| $(var blk : DataBlock)
add(blk, "object", unitMissionName)
add(blk, "avoidObstacles", false)
add(blk, "movementTraceRI", true)
add(blk, "destroyRIByCollision", true)
call_mission_action("unitSetProperties", blk)
[never_inline]
def public wto_drive_apply_movesys(var unit : Unit?; cmd : WtoDriveCmd const&)
if unit == null || !cmd.valid
return
let gm = as_gm(unit)
if gm == null || gm.moveSys == null
return
if cmd.mode == WTO_DRIVE_HALT || cmd.speedMps <= 0.05
set_destination_way_point(unit, "HALT", unit.unitTm, 0.0)
return
var tm = unit.unitTm
tm[3] = cmd.targetPos
let dir = wto_xz_normalize(cmd.desiredDir, float3(1.0, 0.0, 0.0))
tm[0] = cmd.mode == WTO_DRIVE_REVERSE ? -dir : dir
tm[1] = float3(0.0, 1.0, 0.0)
tm[2] = float3(-tm[0].z, 0.0, tm[0].x)
set_destination_way_point(unit, "MOVE_TO_STRAIGHT", tm, cmd.speedMps)
add(blk, "eid", "{uint(eid)}")
add(blk, "holdMs", "{holdMs}")
call_mission_action("wtoGroundAiDriveControl", blk)
[never_inline]
def private wto_set_phys_axes(var actor : VehiclePhysActor&; thr, str, brk, handBrk : float)
@@ -59,20 +37,18 @@ def private wto_set_phys_axes(var actor : VehiclePhysActor&; thr, str, brk, hand
actor.phys.producedCT |> ground_control_state_setAxisValue(EGroundControlAxis.GCA_HAND_BRAKE, clamp(handBrk, 0.0, 1.0))
[never_inline]
def private wto_check_echo_watchdog(unitMissionName : string; var gm : IGroundModel?;
var actor : VehiclePhysActor&; dt : float; var slot : WtoBotSlot&) : bool
def private wto_check_echo_watchdog(unitMissionName : string; var actor : VehiclePhysActor&;
dt : float; var slot : WtoBotSlot&) : bool
assume st = slot.drive
let appThr = ground_control_state_getAxisValue(actor.phys.appliedCT, EGroundControlAxis.GCA_THROTTLE)
let appStr = ground_control_state_getAxisValue(actor.phys.appliedCT, EGroundControlAxis.GCA_STEERING)
let wanted = abs(st.prevThr) >= 0.35 || abs(st.prevStr) >= 0.45
let echoed = abs(appThr) >= 0.05 || abs(appStr) >= 0.05
if wanted && !echoed
let wantsThrottle = abs(st.prevThr) >= 0.35
let wantsSteering = abs(st.prevStr) >= 0.45
let throttleEchoed = !wantsThrottle || abs(appThr) >= 0.05
let steeringEchoed = !wantsSteering || abs(appStr) >= 0.05
if !throttleEchoed || !steeringEchoed
st.deadEchoSec += clamp(dt, 0.0, 0.15)
if st.deadEchoSec >= WTO_AI_NAV_DEAD_ECHO_SEC
wto_set_phys_axes(actor, 0.0, 0.0, 0.0, 0.0)
if gm != null && gm.moveSys != null
gm.moveSys.inactive = false
st.routeBOwned = false
st.routeAFallback = true
print("WTO_AI|PHYS_FALLBACK|actor={unitMissionName}|eid={uint(slot.eid)}\n")
return false
@@ -150,35 +126,62 @@ def private wto_compute_cruise_axes(cmd : WtoDriveCmd const&; spec : WtoVehicleS
outThr = clamp(0.32 + vErr * 0.28, 0.12, 1.0)
[never_inline]
def private wto_prepare_phys_owner(var unit : Unit?; unitMissionName : string;
var gm : IGroundModel?; var actor : VehiclePhysActor&;
dt : float; var slot : WtoBotSlot&) : bool
def private wto_release_phys_owner(gm : IGroundModel const?; var actor : VehiclePhysActor&;
var slot : WtoBotSlot&)
assume st = slot.drive
if !st.routeBOwned
slot.spec.isTracked = actor.phys.trackWidth > 0.01
slot.spec.canPivot = slot.spec.isTracked && actor.phys.haveSeparateBrakes
if gm != null && gm.moveSys != null
set_destination_way_point(unit, "HALT", unit.unitTm, 0.0)
gm.moveSys.inactive = true
st.routeBOwned = true
elif gm != null && gm.moveSys != null
gm.moveSys.inactive = true
assume dmg = actor.phys.currentState.damageState
if !dmg.allowMoveControl || dmg.engineReadyness <= 0.0 || dmg.driverReadyness <= 0.0 || (dmg.trackLBroken && dmg.trackRBroken)
st.deadEchoSec = 0.0
wto_set_phys_axes(actor, 0.0, 0.0, 1.0, 1.0)
return
if gm != null && gm.moveSys != null && gm.moveSys.inactive
wto_set_phys_axes(actor, 0.0, 0.0, 0.0, 0.0)
wto_drive_request_control(slot.eid, 0)
st.routeBOwned = false
st.prevThr = 0.0
st.prevStr = 0.0
st.deadEchoSec = 0.0
[never_inline]
def private wto_prepare_phys_owner(gm : IGroundModel const?; var actor : VehiclePhysActor&;
now : float; var slot : WtoBotSlot&) : bool
assume st = slot.drive
if gm == null || gm.moveSys == null
wto_release_phys_owner(gm, actor, slot)
return false
vehicle_actor_set_allow_move_control(actor, true)
return wto_check_echo_watchdog(unitMissionName, gm, actor, dt, slot)
assume dmg = actor.phys.currentState.damageState
if (!slot.driveCmd.valid || (!slot.macro.valid && !WTO_AI_LAYER_TACTICS) ||
now > slot.nextNavAt + WTO_AI_NAV_TICK_SEC ||
!dmg.allowMoveControl || dmg.engineReadyness <= 0.0 || dmg.driverReadyness <= 0.0 ||
(dmg.trackLBroken && dmg.trackRBroken))
wto_release_phys_owner(gm, actor, slot)
return false
if st.routeBOwned && !gm.moveSys.inactive
wto_release_phys_owner(gm, actor, slot)
return false
if now >= st.nextControlRequestAt
if !st.routeBOwned && gm.moveSys.inactive
return false
wto_drive_request_control(slot.eid, int(WTO_AI_NAV_CONTROL_TIMEOUT_SEC * 1000.0))
if !gm.moveSys.inactive
st.nextControlRequestAt = now + WTO_AI_NAV_CONTROL_TIMEOUT_SEC
return false
st.nextControlRequestAt = now + min(WTO_AI_NAV_TICK_SEC, WTO_AI_NAV_CONTROL_TIMEOUT_SEC * 0.5)
if !st.routeBOwned
slot.spec.isTracked = actor.phys.trackWidth > 0.01
slot.spec.canPivot = slot.spec.isTracked && actor.phys.haveSeparateBrakes
st.routeBOwned = true
return st.routeBOwned
[never_inline]
def public wto_drive_step_phys(var unit : Unit?; unitMissionName : string;
var gm : IGroundModel?; var actor : VehiclePhysActor&;
gm : IGroundModel const?; var actor : VehiclePhysActor&;
dt, now : float; var slot : WtoBotSlot&)
if unit == null || actor.physEdit == null || slot.drive.routeAFallback
return
if !wto_prepare_phys_owner(unit, unitMissionName, gm, actor, dt, slot)
if !wto_prepare_phys_owner(gm, actor, now, slot)
return
if !wto_check_echo_watchdog(unitMissionName, actor, dt, slot)
wto_release_phys_owner(gm, actor, slot)
return
vehicle_actor_set_allow_move_control(actor, true)
assume st = slot.drive
assume cmd = slot.driveCmd
let fwd = wto_xz_normalize(unit.unitTm[0], float3(1.0, 0.0, 0.0))
+9 -6
View File
@@ -49,6 +49,8 @@ def private wto_reset_runtime()
g_next_macro_at = 0.0
g_next_diag_at = 0.0
for i in range(WTO_MAX_BOTS)
if g_bots[i].drive.routeBOwned
wto_drive_request_control(g_bots[i].eid, 0)
g_bots[i] = WtoBotSlot()
[never_inline]
@@ -157,12 +159,16 @@ def wto_ai_unit_dead_es(evt : Event; eid : EntityId; unit__ref : UnitRef)
wto_world_record_death(g_world, int(u.army), u.pos, float(get_app().usefulTotalTime))
let idx = wto_find_slot(eid)
if idx >= 0
if g_bots[idx].drive.routeBOwned
wto_drive_request_control(eid, 0)
g_bots[idx] = WtoBotSlot()
[es(tag=server, on_disappear, on_event=EventUnitRespawn)]
def wto_ai_unit_cleanup_es(evt : Event; eid : EntityId)
let idx = wto_find_slot(eid)
if idx >= 0
if g_bots[idx].drive.routeBOwned
wto_drive_request_control(eid, 0)
g_bots[idx] = WtoBotSlot()
[es(tag=server)]
@@ -192,6 +198,8 @@ def wto_ai_world_tick_es(act : UpdateStageInfoAct)
for i in range(WTO_MAX_BOTS)
if g_bots[i].used && (now - g_bots[i].lastSeenAt) > 3.5
g_bots[i] = WtoBotSlot()
if !g_world.valid
print("WTO_AI|RUNTIME_READY\n")
wto_world_refresh(now, g_world)
wto_crowd_update_all(g_world, g_bots, g_crowd)
if WTO_AI_LAYER_MACRO && now >= g_next_macro_at
@@ -203,7 +211,7 @@ def wto_ai_world_tick_es(act : UpdateStageInfoAct)
[es(tag=server, no_order)]
def wto_ai_pipeline_es(act : UpdateStageInfoAct; eid : EntityId; var unit__ref : UnitRef&;
unit__missionName : string; unit__className : string = "")
unit__className : string = "")
if !wto_any_layer_active() || !g_world.valid
return
var unit = unit__ref.unit
@@ -221,17 +229,12 @@ def wto_ai_pipeline_es(act : UpdateStageInfoAct; eid : EntityId; var unit__ref :
if !slot.prepared
slot.prepared = true
wto_specs_load(eid, unit__className, unit, gm, slot.spec)
if WTO_AI_LAYER_NAVIGATION
wto_drive_prepare_unit(unit__missionName)
if now >= slot.nextTacticsAt
slot.nextTacticsAt = now + WTO_AI_TACTICS_TICK_SEC
wto_tactics_update(g_world, now, WTO_AI_TACTICS_TICK_SEC, unit.pos, unit.unitTm[0], unit.isBurn, slot, g_crowd)
if now >= slot.nextNavAt
slot.nextNavAt = now + WTO_AI_NAV_TICK_SEC
wto_nav_update(g_world, now, unit.pos, unit.unitTm[0], slot)
let usingPhys = WTO_AI_NAV_DRIVE_MODE == "vehicle_phys" && slot.drive.routeBOwned && !slot.drive.routeAFallback
if !usingPhys
wto_drive_apply_movesys(unit, slot.driveCmd)
wto_fire_update(g_world, unit, now, act.dt, slot)
[es(tag=server, after=wto_ai_pipeline_es)]
+1
View File
@@ -242,6 +242,7 @@ struct public WtoDriveCmd
struct public WtoDriveState
routeBOwned : bool = false
routeAFallback : bool = false
nextControlRequestAt : float = -1.0
deadEchoSec : float = 0.0
prevYaw : float = 0.0
prevYawAt : float = -100.0
+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_damage_notifications.c", "$src\local_mp_air_events.c", "$src\local_mp_ground_ai.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
@@ -143,6 +143,7 @@ static const LocalMpModule MODULES[] = {
{ "local_mp_support", install_local_mp_support_hooks },
{ "local_mp_damage_notifications", install_local_mp_damage_notification_hooks },
{ "local_mp_air_events", install_local_mp_air_event_hooks },
{ "local_mp_ground_ai", install_local_mp_ground_ai_hooks },
};
static void use_core_values(void)
+166
View File
@@ -0,0 +1,166 @@
/*
* Temporarily pause stock tank movement for a LocalMP bot receiving custom physics inputs.
* Only the native side changes the MoveSystem flag, so it can give control back if the script
* stops renewing it. All other mission actions still go through the original daScript binding.
*/
#include "hook_config.h"
#include "local_mp_internal.h"
#include "local_mp_offsets.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#define DRIVE_CONTROL_ACTION "wtoGroundAiDriveControl"
typedef void (__fastcall *MissionActionFn)(const char *name, const void *blk);
typedef uint8_t *(__fastcall *AsGroundModelFn)(uint8_t *unit);
typedef struct GroundAiDriveControl {
uint8_t *unit;
uint8_t *move_system;
uint32_t eid;
float remaining_seconds;
} GroundAiDriveControl;
static MissionActionFn orig_mission_action;
static AsGroundModelFn as_ground_model;
/* Player IDs are one byte in the engine. */
static GroundAiDriveControl controls[UINT8_MAX + 1];
static SRWLOCK control_lock = SRWLOCK_INIT;
static uint8_t *get_move_system(uint8_t *unit)
{
uint8_t *ground_model = as_ground_model(unit);
return ground_model ? *(uint8_t **)(ground_model + g_lmp.ground_ai_move_system) : NULL;
}
static uint8_t *get_bot_owner(uint8_t *unit, uint32_t eid)
{
uint8_t *owner = *(uint8_t **)(unit + LMP_UNIT_OFF_MPLAYER);
if (owner == NULL || local_mp_is_local_mplayer(owner) ||
owner != local_mp_find_mplayer(-1, owner[LMP_MP_OFF_PID]) ||
*(int64_t *)(owner + LMP_MP_OFF_USER_ID) >= -1 ||
*(uint32_t *)(owner + LMP_MP_OFF_UNIT_EID) != eid)
return NULL;
return owner;
}
static void give_back_drive(GroundAiDriveControl *control, const char *reason)
{
uint8_t *unit = (uint8_t *)g_lmp_get_unit_by_eid(control->eid);
/* The old unit or its movement component may already have been destroyed. */
if (unit == control->unit && get_move_system(unit) == control->move_system)
control->move_system[g_lmp.ground_ai_move_inactive] = 0;
log_line("local_mp: ground AI returned drive eid=%#lx (%s)", (unsigned long)control->eid, reason);
memset(control, 0, sizeof(*control));
}
static void update_drive_control(uint32_t eid, uint32_t hold_ms)
{
uint8_t *unit = (uint8_t *)g_lmp_get_unit_by_eid(eid);
uint8_t *move_system = get_move_system(unit);
uint8_t *owner = move_system ? get_bot_owner(unit, eid) : NULL;
GroundAiDriveControl *control;
uint8_t *inactive;
if (owner == NULL)
return;
control = &controls[owner[LMP_MP_OFF_PID]];
if (control->unit != NULL &&
(control->eid != eid || control->unit != unit || control->move_system != move_system))
give_back_drive(control, "vehicle changed");
if (hold_ms == 0) {
if (control->unit != NULL)
give_back_drive(control, "script released");
return;
}
inactive = move_system + g_lmp.ground_ai_move_inactive;
if (control->unit == NULL) {
if (*inactive)
return; /* Leave mission-disabled vehicles under their existing owner. */
control->unit = unit;
control->move_system = move_system;
control->eid = eid;
*inactive = 1;
log_line("local_mp: ground AI acquired drive eid=%#lx", (unsigned long)eid);
}
control->remaining_seconds = (float)hold_ms / 1000.0f;
}
static int read_uint(const void *blk, const char *key, uint32_t *out)
{
const char *value = g_lmp_datablock_get_str(blk, key, "");
char *end;
unsigned long parsed;
if (value == NULL || *value < '0' || *value > '9')
return 0;
errno = 0;
parsed = strtoul(value, &end, 0);
if (errno != 0 || *end != 0)
return 0;
*out = (uint32_t)parsed;
return 1;
}
static void __fastcall hook_mission_action(const char *name, const void *blk)
{
uint32_t eid, hold_ms;
if (name == NULL || strcmp(name, DRIVE_CONTROL_ACTION) != 0) {
orig_mission_action(name, blk);
return;
}
if (blk == NULL || !local_mp_is_host() ||
!read_uint(blk, "eid", &eid) || eid == 0 || !read_uint(blk, "holdMs", &hold_ms))
return;
AcquireSRWLockExclusive(&control_lock);
update_drive_control(eid, hold_ms);
ReleaseSRWLockExclusive(&control_lock);
}
void local_mp_ground_ai_update(float dt)
{
size_t i;
int hosting;
if (orig_mission_action == NULL)
return;
hosting = local_mp_is_host();
AcquireSRWLockExclusive(&control_lock);
for (i = 0; i < sizeof(controls) / sizeof(controls[0]); i++) {
GroundAiDriveControl *control = &controls[i];
uint8_t *unit, *owner;
if (control->unit == NULL)
continue;
if (!hosting) {
give_back_drive(control, "session ended");
continue;
}
unit = (uint8_t *)g_lmp_get_unit_by_eid(control->eid);
owner = unit == control->unit ? get_bot_owner(unit, control->eid) : NULL;
if (owner == NULL || owner[LMP_MP_OFF_PID] != i || get_move_system(unit) != control->move_system) {
give_back_drive(control, "vehicle changed");
continue;
}
if (dt > 0.0f)
control->remaining_seconds -= dt;
if (control->remaining_seconds <= 0.0f)
give_back_drive(control, "script stopped renewing control");
}
ReleaseSRWLockExclusive(&control_lock);
}
int install_local_mp_ground_ai_hooks(void)
{
LocalMpHookSpec hooks[] = {
{ "das_call_mission_action", g_lmp.ground_ai_mission_action, (void *)&hook_mission_action, (void **)&orig_mission_action },
};
as_ground_model = (AsGroundModelFn)g_lmp.ground_ai_as_ground_model;
return local_mp_queue_hooks("local_mp_ground_ai", hooks, sizeof(hooks) / sizeof(hooks[0]));
}
+2
View File
@@ -106,3 +106,5 @@ 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_air_event_hooks(void);
int install_local_mp_ground_ai_hooks(void);
void local_mp_ground_ai_update(float dt);
+1
View File
@@ -166,6 +166,7 @@ static void __fastcall hook_gui_state_update(uint8_t *gui_state_obj, float dt)
uint8_t *mplayer;
orig_gui_state_update(gui_state_obj, dt);
local_mp_ground_ai_update(dt);
if (!local_mp_is_host()) {
g_accept_pending = 0;
+6
View File
@@ -41,6 +41,7 @@ typedef struct LmpValueSpec {
#define SUPPORT "local_mp_support"
#define DAMAGE_NOTICES "local_mp_damage_notifications"
#define AIR_EVENTS "local_mp_air_events"
#define GROUND_AI "local_mp_ground_ai"
static const LmpValueSpec SPECS[] = {
A(CORE, "do_respawn_player", do_respawn_player), O(CORE, "do_respawn_player.app_score_rules", app_score_rules),
@@ -186,6 +187,11 @@ static const LmpValueSpec SPECS[] = {
A(AIR_EVENTS, "air_event_orientation.call", air_event_orientation),
A(AIR_EVENTS, "send_unit_respawn", send_unit_respawn),
A(AIR_EVENTS, "send_unit_respawn_broadcast.mpi_sendto", mpi_sendto),
A(GROUND_AI, "ground_ai_mission_binding.action", ground_ai_mission_action),
A(GROUND_AI, "ground_ai_as_ground_model", ground_ai_as_ground_model),
O(GROUND_AI, "ground_ai_move_properties.move_system", ground_ai_move_system),
O(GROUND_AI, "ground_ai_move_annotation.inactive", ground_ai_move_inactive),
};
static void store(const LmpValueSpec *spec, int64_t value, uint8_t *base)
+3
View File
@@ -87,6 +87,9 @@ typedef struct LmpValues {
uint8_t *air_event_orientation, *send_unit_respawn, *mpi_sendto;
size_t mis_mode_name, gp_ks_rules, gp_ks_rule_count, ks_rule_tag, ks_rule_air_ai_mult, ks_rule_ground_ai_mult;
size_t ks_rule_spawn_pos, ks_rule_spawn_pos_count, ks_spawn_pos_stride, mp_ks_progress, app_terrain;
/* local_mp_ground_ai */
uint8_t *ground_ai_mission_action, *ground_ai_as_ground_model;
size_t ground_ai_move_system, ground_ai_move_inactive;
} LmpValues;
extern LmpValues g_lmp;
+5 -1
View File
@@ -130,7 +130,11 @@ export function buildGameCopy(inputs: GameCopyInputs): GameCopyBuild {
const executable = patchExecutableWithMods(inputs.stock.executable, folders.exe, enabledMods);
const stockImage = new PeImage(inputs.stock.executable);
const native = resolveNativeModules(stockImage, loadNativeModules(folders.native));
const customGroundDrive = groundAiActive && inputs.groundAi?.config.layers.navigation &&
inputs.groundAi.config.navigation.driveMode === 'vehicle_phys';
const nativeDefinitions = loadNativeModules(folders.native)
.filter((module) => customGroundDrive || module.module !== 'local_mp_ground_ai');
const native = resolveNativeModules(stockImage, nativeDefinitions);
const core = buildCorePacks(inputs, endpoint, folders.gui, enabledMods, packOverlays);
const executableFolder = dirname(GAME_FILES.executable);
@@ -51,6 +51,7 @@ export interface GroundAiConfig {
readonly maxPhysBots: number;
readonly steerSign: number;
readonly deadEchoSec: number;
readonly controlTimeoutSec: number;
readonly cornerBrakeAccel: number;
readonly pivotAngleDeg: number;
readonly stuckWindowSec: number;
@@ -148,6 +149,7 @@ function collectConfigEntries(c: GroundAiConfig): readonly DasEntry[] {
['WTO_AI_NAV_MAX_PHYS_BOTS', 'int', c.navigation.maxPhysBots],
['WTO_AI_NAV_STEER_SIGN', 'float', c.navigation.steerSign],
['WTO_AI_NAV_DEAD_ECHO_SEC', 'float', c.navigation.deadEchoSec],
['WTO_AI_NAV_CONTROL_TIMEOUT_SEC', 'float', c.navigation.controlTimeoutSec],
['WTO_AI_NAV_CORNER_BRAKE_ACCEL', 'float', c.navigation.cornerBrakeAccel],
['WTO_AI_NAV_PIVOT_ANGLE_DEG', 'float', c.navigation.pivotAngleDeg],
['WTO_AI_NAV_STUCK_WINDOW_SEC', 'float', c.navigation.stuckWindowSec],
+67
View File
@@ -0,0 +1,67 @@
// Temporary movement ownership for custom ground AI on a LocalMP host.
// The local server cannot restore the MoveSystem flag if a game script stops running.
// Without this module, stock tank movement keeps ownership of the vehicle.
{
"module": "local_mp_ground_ai",
"features": ["K-AI opponents and teammates"],
"requires": ["local_mp_core", "local_mp_players"],
"sites": {
// daScript call_mission_action binding, capturing the registered native function.
// 2.61.0.37: 0xa6be4d -> 0xa63750. 2.61.0.58: 0xa6eb0d -> 0xa66410.
"ground_ai_mission_binding": {
"variants": [{
"written_for": "2.61.0.37",
"locate": {
"method": "string_ref",
"string": "call_mission_action",
"lea_at": 0,
"pattern": "48 8d 15 ?? ?? ?? ?? 4c 8d 05 ?? ?? ?? ?? e8 ?? ?? ?? ?? 80 8e 30 01 00 00 04 48 8d 05 ?? ?? ?? ?? 48 89 06 48 8d 05 ?? ?? ?? ?? 48 89 86 b0 01 00 00",
"captures": {
"action": { "offset": 39, "type": "rel32" }
}
}
}]
},
// Leaf shared by the two daScript as_gm overloads. The mask is the engine's ground-model check.
// 2.61.0.37: 0xa1f1f0. 2.61.0.58: 0xa21ea0.
"ground_ai_as_ground_model": {
"variants": [{
"written_for": "2.61.0.37",
"locate": {
"method": "signature",
"pattern": "48 85 c9 74 15 8b 91 ?? ?? ?? ?? f7 d2 31 c0 f7 c2 00 80 01 00 48 0f 44 c1 c3 31 c0 c3"
}
}]
},
// IGroundModel's avoidObstacles property handler reads its MoveSystem pointer.
// 2.61.0.37: 0x424334. 2.61.0.58: 0x4248d4.
"ground_ai_move_properties": {
"variants": [{
"written_for": "2.61.0.37",
"locate": {
"method": "string_ref",
"string": "avoidObstacles",
"lea_at": 0,
"pattern": "48 8d 15 ?? ?? ?? ?? 4c 8d 44 24 24 48 89 d9 e8 ?? ?? ?? ?? 84 c0 74 13 48 8b 87 ?? ?? ?? ?? 48 85 c0 74 07 c6 80 ?? ?? ?? ?? 01",
"captures": {
"move_system": { "offset": 27, "type": "u32" }
}
}
}]
},
// The MoveSystem daScript annotation registers the bool field named "inactive".
// 2.61.0.37: 0xa1c374. 2.61.0.58: 0xa1f024.
"ground_ai_move_annotation": {
"variants": [{
"written_for": "2.61.0.37",
"locate": {
"method": "signature",
"pattern": "48 b8 69 6e 61 63 74 69 76 65 48 89 44 24 30 c6 44 24 38 00 c6 44 24 67 0f 48 89 44 24 50 c6 44 24 58 00 48 8b 8b a8 01 00 00 e8 ?? ?? ?? ?? 48 89 84 24 a0 00 00 00 4c 89 74 24 20 48 8d 54 24 50 4c 8d 44 24 30 48 89 d9 41 b9 ?? ?? ?? ?? e8 ?? ?? ?? ??",
"captures": {
"inactive": { "offset": 75, "type": "u32" }
}
}
}]
}
}
}