Kingdoms of Camelot Attack helper

By niknah Last update Apr 1, 2011 — Installed 573,040 times.

Knights

in
Subscribe to Knights 6 posts, 3 voices



bighooters User
FirefoxWindows

I remember reading something about how the script picks knights randomly to avoid picking an unavailable knight. Would it be possible to edit the script so that it won't pick knights below a certain attack skill? Or just not pick knights with 55 attack?

 
niknah Script's Author
FirefoxWindows

Change the line in the script from...

knightSelect.selectedIndex=1+Math.floor(Math.random()*(knightSelect.options.length-1));

To(pick last knight in the list)...

knightSelect.selectedIndex=knightSelect.options.length-1;

 
bjries User
FirefoxWindows

Try this:

function knightMinAtkIndex(knightSelect, minAtk)
{
for(k=0;k<knightselect>
{
var opt=knightSelect.options[k];
var kAtk=opt.text;
kAtk=kAtk.substr(kAtk.indexOf("(Atk: ")+6,3);
if(kAtk[kAtk.length-1]==')'){kAtk=kAtk.substring(0,kAtk.length-1);}
if(parseInt(kAtk)>=minAtk)return k;
}
return -1;
}
knightSelect.selectedIndex=knightMinAtkIndex(knightSelect,75); //select the 1st knight with Atk >= 75

 
bjries User
FirefoxWindows

That for-loop didn't paste right:

for(k=0;k<knightselect>

 
bjries User
FirefoxWindows

Try again:

for(k=0;k<knightselect>

 
bjries User
FirefoxWindows

For-loop still pastes bad, but this function is a little better:

function knightMinAtkIndex(knightSelect, minAtk)
{
var opt=knightSelect.options;
for(k=0;k<opt>
{
var kAtk=opt[k].text;
kAtk=kAtk.substr(kAtk.indexOf("(Atk: ")+6,3);
if(kAtk[kAtk.length-1]==')'){kAtk=kAtk.substring(0,kAtk.length-1);}
if(parseInt(kAtk)>=minAtk)return k;
}
return opt.length-1;
}

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel