Script Request: Bookmark Farming Report Generator

DeletedUser

Guest
Can someone tell me whats wrong with my script...I get variation when I click on my link so sometime 2 attacks following goes on the same vills and one gets no hauls......

Here my script javascript:function%20end(){c='183|638 182|634 182|633 185|634 185|635 187|635 187|634 188|635 188|637 188|633 189|634 190|634 190|635 191|634 181|640 191|640';var%20d=document;if(window.frames.length>0)d=window.main.document;url=d.URL;if(url.indexOf('screen=place')==-1)alert('This%20script%20needs%20to%20be%20run%20from%20the%20rally%20point');a=c.match(/(\d+\|\d+)/g);b=a[Math.round(Math.random()*(a.length-1))].split("|");d.forms[0].x.value=b[0];d.forms[0].y.value=b[1];d.forms[0].spear.value=0;d.forms[0].sword.value=0;d.forms[0].axe.value=0;d.forms[0].spy.value=2;d.forms[0].light.value=25;d.forms[0].heavy.value=0;d.forms[0].ram.value=0;d.forms[0].catapult.value=0;d.forms[0].snob.value=0;d.forms[0].archer.value=0;d.forms[0].marcher.value=0;d.forms[0].knight.value=0;}end();
 

dalesmckay

Guest
It's a random attack script.
Since you have 16 coordinates in the script, you have a 1 in 16 chance of sending to the same village the next time you run the script.

I have a much better version floating around.
Not at a computer at the moment, so can't currently dig it up.
 

Karmalot

Non-stop Poster
Reaction score
0
Probably because we've been fixing them up. :icon_rolleyes:


Here's your Bookmark Farming Evaluator Script:
[SPOIL]
Code:
javascript:

var worldSpeed=1;
var resend={
	unit:'light',
	spy:0,
	minutes:15
};
var defaultBuildingLevel=20;

var script={
	id:'6A6C55B4-D459-4341-B81D-BF448104D376',
	name:'Mangina Farmer Script',
	version:1.00,
	minGameVersion:7.00,
	author:{
		name:'dalesmckay',
		email:'dalesmckay@gmail.com',
		url:'http://crosstrigger.com'
	},
	credit:'(Dedicated to <span style="color:blue;">Karmalot</span>)',
	runOnce:false
};

function fnInt(value){return parseInt(value||'0',10);}
function fnPrint(msg){$('body').append('<span>'+msg+'</span><br/>');}

function fnPrintVersion(){
	var authorURL=script.author.url?('<a href="'+script.author.url+'" target="_blank">'+script.author.name+'</a>'):script.author.name;
	
	fnPrint('');
	fnPrint('<span style="color:red;font-weight:bold;">Provide the following info when asking for help:</span><hr>');
	fnPrint('=========================');
	fnPrint(authorURL + '\'s ' + script.name + ': v' + script.version.toFixed(2) + (script.credit?('<br/>'+script.credit):''));
	fnPrint('=========================');
	fnPrint($.trim($('td.server_info').text().match(/\|\s*(.+)/)[1]));
	fnPrint('Account: '+win.game_data.player.name);
	fnPrint('Sitter : '+((fnInt(win.game_data.player.sitter_id)>0)?('yes - '+win.game_data.player.sitter_id):'no'));
	fnPrint('=========================');
	fnPrint('Version: '+win.game_data.version);
	fnPrint('World  : '+win.game_data.world);
	fnPrint('Screen : '+win.game_data.screen);
	fnPrint('Mode   : '+win.game_data.mode);
	fnPrint('URL    : '+win.location.href);
	fnPrint('Browser: '+navigator.userAgent);
	fnPrint('=========================');
	fnPrint('worldSpeed: '+worldSpeed);
	fnPrint('resend: '+JSON.stringify(resend));
	fnPrint('defaultBuildingLevel: '+defaultBuildingLevel);
	fnPrint('=========================');
	fnPrint('');
}

var win=(window.main||self),$=win.$;
fnPrintVersion();

if((win.game_data.screen=='place')&&!win.game_data.mode&&win.location.search.match(/dsmScript\=true/i)){
	var config={spear:0,sword:0,archer:0,axe:0,spy:1,light:0,marcher:0,heavy:0,ram:0,catapult:0,knight:0,snob:0};
	config.spy=(win.location.search.match(/spy\=(\d+)/i)||[0,0])[1];
	var unit=(win.location.search.match(/unit\=(\w+)/i)||[0,0])[1];
	var qty=(win.location.search.match(/qty\=(\d+)/i)||[0,0])[1];
	config[unit]=qty;

	$.each(config,function(i,e){
		$('input[name="'+i+'"]').val(Math.min(e,fnInt($('input[name="'+i+'"]').closest('tr').text().match(/\d+/))));
	});
}
else if((win.game_data.screen!='report')||!win.location.search.match(/view\=\d+/i)){
	var msg='This script must be run from a Report Detail Screen!';
	fnPrint(msg);
	alert(msg);
}
else{
	var buildingInfo={
		wood:{name:'Timber camp',level:defaultBuildingLevel},
		stone:{name:'Clay pit',level:defaultBuildingLevel},
		iron:{name:'Iron mine',level:defaultBuildingLevel}
	};

	var unitInfo={
		spear:{name:'Spear fighter',carry:25},
		sword:{name:'Swordsman',carry:15},
		axe:{name:'Axeman',carry:10},
		archer:{name:'Archer',carry:10},
		light:{name:'Light cavalry',carry:80},
		marcher:{name:'Mounted archer',carry:50},
		heavy:{name:'Heavy cavalry',carry:50}
	};

	function fnResourceProduction(lvl){return ((lvl==0)?5:Math.round(30*Math.pow(80,(lvl-1)/29)))*worldSpeed;}

	function fnExtractBuildings(){
		var buildings=undefined;
		var buildingSrc=$('#attack_spy tr:eq(1) td:first').html();
		if(buildingSrc){
			buildingSrc=buildingSrc.match(/\w+\s\w*\s*<b>\(\w+\s\d+\)/ig);
			if(buildingSrc){
				buildings={};
				$.each(buildingSrc,function(i,e){
					buildings[$.trim(e.match(/\w+\s*\w*\s*/i))]=fnInt(e.match(/\d+/));
				});
			}
		}
	
		return buildings;
	}

	var buildings=fnExtractBuildings();
	if(buildings){
		$.each(buildingInfo,function(i,e){
			buildingInfo[i].level=buildings[e.name];
		});
	}

	var hourlyResources=0;
	$.each(buildingInfo,function(i,e){
		hourlyResources+=fnResourceProduction(e.level);
	});

	fnPrint('Resources: '+hourlyResources*(resend.minutes/60));
	fnPrint('');

	$.each(unitInfo,function(i,e){
		unitInfo[i].qty=Math.round((hourlyResources*(resend.minutes/60))/e.carry);
		fnPrint('%%UNITID - (%%UNITDESC): %%QTY'.replace(/\%\%QTY/ig,unitInfo[i].qty).replace(/\%\%UNITID/ig,i).replace(/\%\%UNITDESC/ig,unitInfo[i].name));
	});

	var villageID=$('#attack_info_def td a:eq(0)').attr('href').match(/id\=(\d+)/i)[1];

	win.open(win.game_data.link_base_pure.replace(/screen\=\w*/ig,'screen=place&target='+villageID+'&dsmScript=true&spy='+resend.spy+'&unit='+resend.unit+'&qty='+unitInfo[resend.unit].qty));
}

void(0);
[/SPOIL]

Usage:
[SPOIL]
worldSpeed=1
Change this to the speed of the world you are using the script in.

unit:'light'
The Unit you want to use for collecting the resources.
Valid values:
  • spear
  • sword
  • axe
  • archer
  • light
  • marcher
  • heavy

spy:0
The number of scouts you want to send.
(If you don't have enough scouts in your village, it will send all of them)

minutes:15
The number of minutes between future farm runs.

defaultBuildingLevel=20
If your initial scout report does not contain building levels then this value will be used.
[/SPOIL]

Run the Script from a Report Detail screen.
It will display the estimated number of troops at the bottom of the screen and Open a Rally point screen.

Run the Script again at the new Rally point screen and it will assign the troops.

Hey Dale, I'm wondering if you could edit this script such that when I click on the script from the scout report, and it brings me to the rally point, and then I click on it the first time at the rally point it does as it does now but if I click on it a second time while still at the rally point it will send how many LC's it needs to send to pick up all of the resources in the village PLUS the travel time production LESS the production it produces within the variably entered time frame. For example, let's say I currently have a village bookmarked and I'm sending constantly bookmarked troops there via this script, but then I notice that the village is continually having full hauls, so I can scout the village, and see the resources that are there and use the same script to send the troops to pick up the resources, but have it subtract the LC's I would have already going there via the bookmark script, ie - less one hour of production if I have the time frame entered as 1 hour, or less 15 minutes of production if I have the LC's traveling there every 15 minutes etc..

Does that bit make sense?
 
Last edited:
Top