This commit is contained in:
2026-04-24 21:46:21 +03:00
parent f2000b5626
commit 3f57eff615
2 changed files with 65 additions and 59 deletions

View File

@@ -1,7 +1,7 @@
// ==UserScript==
// @name Grepolis Remote Control
// @namespace http://tampermonkey.net/
// @version 3.6.1
// @version 3.6.2
// @description Polls grepo.haunter-pets.top for remote commands and executes them in-game (Multi-Player)
// @author Dimitrios
// @match https://*.grepolis.com/game/*
@@ -817,75 +817,80 @@
// Auto Bandit Camp: if enabled, attack/claim when ready
if (farmSettings.bandit_camp_enabled) {
try {
const spotModels = uw.MM.getModels().PlayerAttackSpot;
if (spotModels) {
const spotId = Object.keys(spotModels)[0];
if (spotId) {
const spot = spotModels[spotId];
const nowTs = Math.floor(Date.now() / 1000);
const townId = spot.attributes.town_id;
// Debug log to confirm it's checking
log(`⚔️ Bandit Monitor -> Cooldown in: ${Math.max(0, spot.attributes.cooldown_at - nowTs)}s | Reward: ${spot.attributes.reward_available}`);
if (spot.attributes.reward_available) {
log('⚔️ Bandit Camp: Reward available! Waiting before claiming...');
await sleep(randInt(8000, 24000));
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
model_url: `PlayerAttackSpot/${spotId}`,
action_name: 'useReward',
captcha: null,
arguments: {},
town_id: townId,
nl_init: true
});
log('⚔️ Bandit Camp: Reward claimed!');
} else if (spot.attributes.cooldown_at <= nowTs) {
// Check if there are active movements to make sure troops are home
let hasMovements = false;
try {
const movements = uw.MM.getOnlyCollectionByName('MovementCommand')?.models || [];
hasMovements = movements.length > 0;
} catch (e) {}
const spotColl = uw.MM.getOnlyCollectionByName('PlayerAttackSpot');
const spotModel = spotColl?.models?.[0];
if (spotModel) {
const spotId = spotModel.id || spotModel.attributes.id;
const nowTs = Math.floor(Date.now() / 1000);
const townId = spotModel.attributes.town_id;
if (!hasMovements) {
// Gather troops
const town = uw.ITowns?.getTown?.(townId) || uw.ITowns?.towns?.[townId];
if (town) {
const myUnits = town.units() || {};
const allowedUnits = ['sword', 'slinger', 'archer', 'hoplite', 'rider', 'chariot', 'catapult'];
const sendUnits = {};
let totalUnits = 0;
for (let u of allowedUnits) {
if (myUnits[u] > 0) {
sendUnits[u] = myUnits[u];
totalUnits += myUnits[u];
}
}
// Debug log every cycle
log(`⚔️ Bandit Monitor -> Cooldown in: ${Math.max(0, spotModel.attributes.cooldown_at - nowTs)}s | Reward: ${spotModel.attributes.reward_available} | TownID: ${townId}`);
if (totalUnits > 0) {
log(`⚔️ Bandit Camp: Cooldown over! Preparing to attack with ${totalUnits} units...`);
await sleep(randInt(8000, 24000));
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
model_url: `PlayerAttackSpot/${spotId}`,
action_name: 'attack',
captcha: null,
arguments: sendUnits,
town_id: townId,
nl_init: true
});
log('⚔️ Bandit Camp: Attack sent!');
if (spotModel.attributes.reward_available) {
log('⚔️ Bandit Camp: Reward available! Waiting before claiming...');
await sleep(randInt(8000, 24000));
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
model_url: `PlayerAttackSpot/${spotId}`,
action_name: 'useReward',
captcha: null,
arguments: {},
town_id: townId,
nl_init: true
});
log('⚔️ Bandit Camp: Reward claimed!');
} else if (spotModel.attributes.cooldown_at <= nowTs) {
// Check if troops are still marching back
let hasMovements = false;
try {
const movements = uw.MM.getOnlyCollectionByName('MovementCommand')?.models || [];
hasMovements = movements.length > 0;
} catch (e) {}
if (!hasMovements) {
const town = uw.ITowns?.getTown?.(townId) || uw.ITowns?.towns?.[townId];
if (town) {
const myUnits = town.units() || {};
const allowedUnits = ['sword', 'slinger', 'archer', 'hoplite', 'rider', 'chariot', 'catapult'];
const sendUnits = {};
let totalUnits = 0;
for (let u of allowedUnits) {
if ((myUnits[u] || 0) > 0) {
sendUnits[u] = myUnits[u];
totalUnits += myUnits[u];
}
}
if (totalUnits > 0) {
log(`⚔️ Bandit Camp: Cooldown over! Attacking with ${totalUnits} units...`);
await sleep(randInt(8000, 24000));
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
model_url: `PlayerAttackSpot/${spotId}`,
action_name: 'attack',
captcha: null,
arguments: sendUnits,
town_id: townId,
nl_init: true
});
log('⚔️ Bandit Camp: Attack sent!');
} else {
log('⚔️ Bandit Camp: No units available to send.');
}
} else {
log(`⚔️ Bandit Camp: Town ${townId} not found in local state.`);
}
} else {
log('⚔️ Bandit Camp: Troops still marching — waiting for them to return...');
}
}
} else {
log('⚔️ Bandit Camp: PlayerAttackSpot collection not found in memory. Is the camp open in-game?');
}
} catch (e) {
log(`Bandit camp error: ${e.message}`);
log(`⚔️ Bandit camp error: ${e.message}`);
}
}
if (cmdData.sync_requested) {
log('Sync requested by server — pushing state immediately');
pushState();

View File

@@ -104,10 +104,11 @@ def get_pending_command():
# Also return current farm settings so TM knows loot_option
farm_row = c.execute(
'SELECT enabled, loot_option FROM farm_settings WHERE player_id = ?', (player_id,)
'SELECT enabled, bandit_camp_enabled, loot_option FROM farm_settings WHERE player_id = ?', (player_id,)
).fetchone()
farm_settings = {
'enabled': bool(farm_row['enabled']) if farm_row else False,
'bandit_camp_enabled': bool(farm_row['bandit_camp_enabled']) if farm_row else False,
'loot_option': farm_row['loot_option'] if farm_row else 1
}