diff --git a/GrepolisRemoteControl.user.js b/GrepolisRemoteControl.user.js index 121b44b..03acd87 100644 --- a/GrepolisRemoteControl.user.js +++ b/GrepolisRemoteControl.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Grepolis Remote Control // @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) // @author Dimitrios // @match https://*.grepolis.com/game/* @@ -817,8 +817,41 @@ // Auto Bandit Camp: if enabled, attack/claim when ready if (farmSettings.bandit_camp_enabled) { try { - const spotColl = uw.MM.getOnlyCollectionByName('PlayerAttackSpot'); - const spotModel = spotColl?.models?.[0]; + // Try to get the collection — it's only loaded if the camp UI was opened. + // 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) { const spotId = spotModel.id || spotModel.attributes.id; const nowTs = Math.floor(Date.now() / 1000);