fix 2
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Grepolis Remote Control
|
// @name Grepolis Remote Control
|
||||||
// @namespace http://tampermonkey.net/
|
// @namespace http://tampermonkey.net/
|
||||||
// @version 3.6.2
|
// @version 3.6.3
|
||||||
// @description Polls grepo.haunter-pets.top for remote commands and executes them in-game (Multi-Player)
|
// @description Polls grepo.haunter-pets.top for remote commands and executes them in-game (Multi-Player)
|
||||||
// @author Dimitrios
|
// @author Dimitrios
|
||||||
// @match https://*.grepolis.com/game/*
|
// @match https://*.grepolis.com/game/*
|
||||||
@@ -817,8 +817,41 @@
|
|||||||
// Auto Bandit Camp: if enabled, attack/claim when ready
|
// Auto Bandit Camp: if enabled, attack/claim when ready
|
||||||
if (farmSettings.bandit_camp_enabled) {
|
if (farmSettings.bandit_camp_enabled) {
|
||||||
try {
|
try {
|
||||||
const spotColl = uw.MM.getOnlyCollectionByName('PlayerAttackSpot');
|
// Try to get the collection — it's only loaded if the camp UI was opened.
|
||||||
const spotModel = spotColl?.models?.[0];
|
// If not found, actively fetch it from the game server.
|
||||||
|
let spotModel = uw.MM.getOnlyCollectionByName('PlayerAttackSpot')?.models?.[0];
|
||||||
|
|
||||||
|
if (!spotModel) {
|
||||||
|
// Log available collections once for diagnostics
|
||||||
|
try {
|
||||||
|
const allColls = uw.MM.getAllCollections ? uw.MM.getAllCollections() : null;
|
||||||
|
if (allColls) {
|
||||||
|
const names = Object.keys(allColls).filter(k => k.toLowerCase().includes('attack') || k.toLowerCase().includes('spot') || k.toLowerCase().includes('bandit'));
|
||||||
|
if (names.length) log(`⚔️ Bandit: Possible collection names: ${names.join(', ')}`);
|
||||||
|
}
|
||||||
|
} catch(e) {}
|
||||||
|
|
||||||
|
// Actively fetch the spot state from the game server
|
||||||
|
log('⚔️ Bandit Camp: Collection not in memory — fetching from server...');
|
||||||
|
try {
|
||||||
|
const player_id = uw.Game?.player_id;
|
||||||
|
const currentTownId = uw.Game?.town_id;
|
||||||
|
if (player_id && currentTownId) {
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
uw.gpAjax.ajaxPost('frontend_bridge', 'get_own', {
|
||||||
|
model_url: `PlayerAttackSpot/${player_id}`,
|
||||||
|
town_id: currentTownId,
|
||||||
|
nl_init: true
|
||||||
|
});
|
||||||
|
setTimeout(resolve, 2000); // wait 2s for the model to load
|
||||||
|
});
|
||||||
|
spotModel = uw.MM.getOnlyCollectionByName('PlayerAttackSpot')?.models?.[0];
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
log(`⚔️ Bandit fetch error: ${e.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (spotModel) {
|
if (spotModel) {
|
||||||
const spotId = spotModel.id || spotModel.attributes.id;
|
const spotId = spotModel.id || spotModel.attributes.id;
|
||||||
const nowTs = Math.floor(Date.now() / 1000);
|
const nowTs = Math.floor(Date.now() / 1000);
|
||||||
|
|||||||
Reference in New Issue
Block a user