fix 1
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.1
|
// @version 3.6.2
|
||||||
// @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,75 +817,80 @@
|
|||||||
// 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 spotModels = uw.MM.getModels().PlayerAttackSpot;
|
const spotColl = uw.MM.getOnlyCollectionByName('PlayerAttackSpot');
|
||||||
if (spotModels) {
|
const spotModel = spotColl?.models?.[0];
|
||||||
const spotId = Object.keys(spotModels)[0];
|
if (spotModel) {
|
||||||
if (spotId) {
|
const spotId = spotModel.id || spotModel.attributes.id;
|
||||||
const spot = spotModels[spotId];
|
const nowTs = Math.floor(Date.now() / 1000);
|
||||||
const nowTs = Math.floor(Date.now() / 1000);
|
const townId = spotModel.attributes.town_id;
|
||||||
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) {}
|
|
||||||
|
|
||||||
if (!hasMovements) {
|
// Debug log every cycle
|
||||||
// Gather troops
|
log(`⚔️ Bandit Monitor -> Cooldown in: ${Math.max(0, spotModel.attributes.cooldown_at - nowTs)}s | Reward: ${spotModel.attributes.reward_available} | TownID: ${townId}`);
|
||||||
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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (totalUnits > 0) {
|
if (spotModel.attributes.reward_available) {
|
||||||
log(`⚔️ Bandit Camp: Cooldown over! Preparing to attack with ${totalUnits} units...`);
|
log('⚔️ Bandit Camp: Reward available! Waiting before claiming...');
|
||||||
await sleep(randInt(8000, 24000));
|
await sleep(randInt(8000, 24000));
|
||||||
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
|
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
|
||||||
model_url: `PlayerAttackSpot/${spotId}`,
|
model_url: `PlayerAttackSpot/${spotId}`,
|
||||||
action_name: 'attack',
|
action_name: 'useReward',
|
||||||
captcha: null,
|
captcha: null,
|
||||||
arguments: sendUnits,
|
arguments: {},
|
||||||
town_id: townId,
|
town_id: townId,
|
||||||
nl_init: true
|
nl_init: true
|
||||||
});
|
});
|
||||||
log('⚔️ Bandit Camp: Attack sent!');
|
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) {
|
} catch (e) {
|
||||||
log(`Bandit camp error: ${e.message}`);
|
log(`⚔️ Bandit camp error: ${e.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (cmdData.sync_requested) {
|
if (cmdData.sync_requested) {
|
||||||
log('Sync requested by server — pushing state immediately');
|
log('Sync requested by server — pushing state immediately');
|
||||||
pushState();
|
pushState();
|
||||||
|
|||||||
@@ -104,10 +104,11 @@ def get_pending_command():
|
|||||||
|
|
||||||
# Also return current farm settings so TM knows loot_option
|
# Also return current farm settings so TM knows loot_option
|
||||||
farm_row = c.execute(
|
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()
|
).fetchone()
|
||||||
farm_settings = {
|
farm_settings = {
|
||||||
'enabled': bool(farm_row['enabled']) if farm_row else False,
|
'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
|
'loot_option': farm_row['loot_option'] if farm_row else 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user