This commit is contained in:
2026-05-05 21:09:38 +03:00
parent bedf25b6f6
commit 781a2b92de
2 changed files with 12 additions and 23 deletions

View File

@@ -17,28 +17,16 @@ function gatherState() {
const total_points = uw.Game?.player_points ?? 0;
const world = uw.Game?.world_id || '';
let battle_points = { available: 0, used: 0 };
// Battle points: att+def = total earned, used = spent, available = att+def-used
// Source: ModernBot.user.js line 1635: let available = killpoints.att + killpoints.def - killpoints.used;
let battle_points = { att: 0, def: 0, used: 0, available: 0 };
try {
const pkModels = uw.MM?.getModels?.()?.PlayerKillpoints;
if (pkModels && pkModels[player_id]) {
const pk = pkModels[player_id];
battle_points.used = pk.attributes?.used || 0;
if (typeof pk.getUnusedPoints === 'function') {
battle_points.available = pk.getUnusedPoints();
} else if (pk.attributes?.available !== undefined) {
battle_points.available = pk.attributes.available;
}
}
// Force sync with the exact UI number if available (e.g. 1986)
if (uw.$) {
const uiText = uw.$('.nui_battlepoints_container .points').text();
if (uiText) {
const parsed = parseInt(uiText.replace(/[^\d]/g, ''), 10);
if (!isNaN(parsed)) {
battle_points.available = parsed;
}
}
const pk = uw.MM?.getModelByNameAndPlayerId?.('PlayerKillpoints')?.attributes;
if (pk) {
battle_points.att = pk.att || 0;
battle_points.def = pk.def || 0;
battle_points.used = pk.used || 0;
battle_points.available = battle_points.att + battle_points.def - battle_points.used;
}
} catch (e) { log(`Failed to extract battle_points: ${e}`); }