tömeges seregkiképző script

Státusz
Nem lehet hozzászólni.

Gabriel

Well-Known Member
A reakció pontszáma
1.024
Nem működik ez se nálam.

[spoil]javascript:
/* jame removed - fnGetconfig var archers=true; */
/* var configuration=[0,0,6000,0,0,2500,500,0,400,0]; */
var configuration=[0,0,6000,0,0,2500,500,0,400,0];

var units;
var unitsNET;
var costs;
var doc=document;
var win=(window.frames.length>0)?window.main:window;

if (doc.URL.indexOf('mode=mass') != -1)
{
/* jame this function was added from sorter script */
function fnGetConfig(){
var oRequest=new XMLHttpRequest();
var sURL="http://"+window.location.hostname+"/interface.php?func=get_config";
oRequest.open("GET",sURL,0);
oRequest.send(null);
if(oRequest.status==200)return oRequest.responseXML;
alert("Error executing XMLHttpRequest call to get Config!");
}

function arrayMin(array)
{
var value=array[0];
for(var t=1; t<array.length;t++) {
if(array[t]<value) {value=array[t];} }
return value;
}
function linearDivideArray(array1,array2)
{
var value=[];
if(array1.length==array2.length)
{
for(var t=0;t<array1.length;t++)
{
if(array2[t]!=0) {value[t]=array1[t]*1.0/array2[t];}
else{value[t]=0;}
}
}
return value;
}
function linearAddArray(array1,array2)
{
var value=[];
if(array1.length==array2.length) {
for(var t=0;t<array1.length;t++) { value[t]=array1[t]+array2[t]; } }
return value;}
function getUnitId(unit)
{
for(var t=0;t<units.length;t++) {
if(unit==unitsNET[t]) { return t; }
}
return-1;
}
function getQueue(record)
{
var value=[0,0,0,0,0,0,0,0,0,0];
for(var u=3;u<record.cells.length;u++)
{
try { value[u-3]=parseInt(record.cells.childNodes[1].childNodes[1].firstChild.title,10); }
catch(e){}
if(isNaN(value[u-3])) { value[u-3]=0; }
}
return value;
}
function getResources(record)
{
var value=[0,0,0,0];
var res=record.cells[1].textContent.split("\n");
var farm=record.cells[2].innerHTML.split('/');
value[0]=parseInt(res[1].replace(".",""),10);
value[1]=parseInt(res[2].replace(".",""),10);
value[2]=parseInt(res[3].replace(".",""),10);
value[3]=farm[1]-farm[0];
return value;
}
function getProduced(record)
{
var value=[0,0,0,0,0,0,0,0,0,0];
for(var u=3;u<record.cells.length;u++)
{
/* jame: modified try{ value[u-3]=parseInt(record.cells.childNodes[1].textContent.split("\n")[2],10); } */
try{ value[u-3]=parseInt(record.cells.childNodes[1].textContent,10); }
catch(e){}
if(isNaN(value[u-3])) {value[u-3]=0;}
}
return value;
}
if(document.URL.match('screen=train')&&document.URL.match('mode=mass'))
{
var records=document.getElementById('mass_train_table').rows;
var XMLdoc=fnGetConfig();
var archers=(XMLdoc.getElementsByTagName("archer")[0].childNodes[0].nodeValue!=0);
if(archers) {
units=['spear','sword','axe','archer','spy','light','marcher','heavy','ram','catapult'];
unitsNET=['Spear Fighter','Swordsman','Axeman','Archer','Scout','Light Cavalry','Mounted Archer','Heavy Cavalry','Ram','Catapult'];
costs=[[50,30,10,1],[30,30,70,1],[60,30,40,1],[100,30,60,1],[50,50,20,2],[125,100,250,4],[250,100,150,5],[200,150,600,6],[300,200,200,5],[320,400,100,8]];
}
else {
units=['spear','sword','axe','spy','light','heavy','ram','catapult'];
unitsNET=['Spear Fighter','Swordsman','Axeman','Scout','Light Cavalry','Heavy Cavalry','Ram','Catapult'];
costs=[[50,30,10,1],[30,30,70,1],[60,30,40,1],[50,50,20,2],[125,100,250,4],[200,150,600,6],[300,200,200,5],[320,400,100,8]];
}
for(r=1;r<records.length;r++)
{
var subconf=[];
var total_costs=[0,0,0,0];
var i;
/* 0: fa, 1: agyag, 2: vas, 3: üres a tanyán */
var resources=getResources(records[r]);
/* ennyi készül */
var queue=getQueue(records[r]);
/* ennyi van meg */
var produced=getProduced(records[r]);
for(i=0;i<units.length;i++){
/* ennyi kell */
subconf=configuration-(queue+produced);
if(subconf[ i]<0) {subconf=0; }
/* fa, agyag, vas, ember menni kell */
for(var j=0;j<4;j++) {total_costs[j]+=costs[j]*subconf;}
};
var factor=arrayMin(linearDivideArray(resources,total_costs));
if(factor>1.0) { factor=1.0; }
for(i=0;i<units.length;i++) {
var number=subconf*factor;
if(number<0) {number=0;}
if(number!=0){
if(records[r].cells[3+i].childNodes[3]&&records[r].cells[3+i].childNodes[3].disabled==false) {
var ibox=records[r].cells[3+i].childNodes[3];
try{ibox.value=parseInt(number,10);}
catch(e){alert(e);}
}
}
}
}
stop();
}}
else{alert("A script csak a tömeges kiképzésnél működik.\nUgrás...");
self.location=win.game_data.link_base_pure.replace(/screen\=\w*/i,"screen=train&mode=mass")};
end(0);[/spoil]

átugrik a kiképzésre, de nem illeszt be egységeket.
 

DeletedUser

Vendég
javítva, a script eredeti helyén megtalálható a javított
 
Státusz
Nem lehet hozzászólni.
Fent