This commit is contained in:
2026-05-05 21:00:54 +03:00
parent 4f7e0fae51
commit bedf25b6f6

View File

@@ -17,18 +17,27 @@ function gatherState() {
const total_points = uw.Game?.player_points ?? 0;
const world = uw.Game?.world_id || '';
let battle_points = { att: 0, def: 0, available: 0, used: 0 };
let battle_points = { available: 0, used: 0 };
try {
const pk = uw.MM?.getModels?.()?.PlayerKillpoints;
if (pk) {
const m = pk[player_id] || Object.values(pk)[0];
if (m && m.attributes) {
battle_points = {
att: m.attributes.att || 0,
def: m.attributes.def || 0,
available: m.attributes.available || 0,
used: m.attributes.used || 0
};
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;
}
}
}
} catch (e) { log(`Failed to extract battle_points: ${e}`); }