Et siis Alusta Skript Edge Ville Mani majas.
- Kood:
import java.awt.Color;
import java.awt.Graphics;
import java.util.Map;
import java.util.List;
import java.awt.*;
import java.util.*;
import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.event.listeners.PaintListener;
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.script.wrappers.*;
import com.speljohan.rsbot.accessors.*;
public class EdgevilleManKiller extends Script implements PaintListener
{
private RSTile[] validTiles = {
new RSTile(3092,3507), new RSTile(3092,3509), new RSTile(3092,3510), new RSTile(3091,3509), new RSTile(3091,3512), new RSTile(3092,3512),
new RSTile(3093,3509), new RSTile(3093,3510), new RSTile(3093,3511), new RSTile(3093,3512),
new RSTile(3094,3508), new RSTile(3094,3509), new RSTile(3094,3511), new RSTile(3094,3512), new RSTile(3094,3513),
new RSTile(3095,3508), new RSTile(3095,3509), new RSTile(3095,3511), new RSTile(3095,3512), new RSTile(3095,3513),
new RSTile(3096,3508), new RSTile(3096,3509), new RSTile(3096,3510), new RSTile(3094,3512),
new RSTile(3097,3508), new RSTile(3097,3509), new RSTile(3097,3510), new RSTile(3097, 3511), new RSTile(3097,3512),
new RSTile(3098,3508), new RSTile(3098,3509), new RSTile(3098,3510), new RSTile(3098, 3511), new RSTile(3098,3512),
new RSTile(3099,3508), new RSTile(3099,3509), new RSTile(3099,3510), new RSTile(3099, 3511),
new RSTile(3100,3509), new RSTile(3100,3510), new RSTile(3100,3511)
};
private int[] fish = {315,351,333,329,361,379,373}; // shrimp, pike, trout, salmon, tuna, lobster, swordfish
private int[] enemies = {1,2,3};
private int skill;
private int tries;
private long startTimer;
private String stringSkill;
private int startExp = 0;
long lastAction;
long timeSinceLastAction;
public String getName ()
{
return "Edgeville Man Killer";
}
public String getAuthor ()
{
return "Admin";
}
public double getVersion ()
{
return 1;
}
public String getScriptCategory ()
{
return "Combat";
}
public String getNotes ()
{
return "Vali Endale Stiil. Alusta Edge ville Man majas";
}
public String getScriptDescription ()
{
String html = "";
html += "<html>\n";
html += "<body>\n";
html += "<font size='6'>";
html += "<center><h2>" + getName() + "</h2></center>";
html += "</font>";
html += "<b>Version: </b>" + getVersion() + "<br/><br>";
html += "<b>Author: </b>" + getAuthor() + "<br/>";
html += "<b>Notes: </b>" + getNotes() + "<br/><br>";
html += "<form><input type=\"radio\" name=\"style\" value=\"attack\">Attack<br>";
html += "<form><input type=\"radio\" name=\"style\" value=\"strength\">Strength<br>";
html += "<form><input type=\"radio\" name=\"style\" value=\"defence\">Defence<br>";
html += "<form><input type=\"radio\" name=\"style\" value=\"shared\">Shared<br></form>";
html += "</body>\n";
html += "</html>";
return html;
}
public boolean onStart (Map<String, String> args)
{
if(getCurrentTab() != TAB_ATTACK)
{
openTab(TAB_ATTACK);
}
if(args.get("style").equals("attack"))
{
skill = STAT_ATTACK;
stringSkill = "Attack";
setFightMode(0);
}
else if(args.get("style").equals("strength"))
{
skill = STAT_STRENGTH;
stringSkill = "Strength";
setFightMode(1);
}
else if(args.get("style").equals("shared"))
{
skill = STAT_ATTACK;
stringSkill = "Attack";
setFightMode(2);
}
else if(args.get("style").equals("defence"))
{
skill = STAT_DEFENSE;
stringSkill = "Defence";
setFightMode(3);
}
else
{
log("Invalid selection of style.");
stopAllScripts();
}
startExp = skills.getCurrentSkillExp(skill);
Bot.getEventManager().addListener(PaintListener.class, this);
return true;
}
public void onFinish()
{
Bot.getEventManager().removeListener(PaintListener.class, this);
}
public int loop()
{
if(tries > 25)
{
log("Couldn't find an enemy 25 times, stopping script.");
stopAllScripts();
}
// check if hunger, only works if fighting
if(getMyPlayer().isInCombat())
{
if(!autoEat())
{
log("Ran out of food, stopping script.");
stopAllScripts();
}
}
if(getMyPlayer().getInteracting() != null)
{
timeSinceLastAction = System.currentTimeMillis()-lastAction;
if(timeSinceLastAction >= 20000) // we may have got trapped or levelled up etc
{
log("Got stuck, moving away.");
walkTileMM(validTiles[random(10,33)]); // walk to center-ish so it doesn't stick around edges
return random(1000, 2000);
}
else
{
//log("Anti-Banning");
return antiBan();
}
}
if(doorCheck())
return random(1000, 2000);
lastAction = System.currentTimeMillis();
//log("Not anti-banning");
if(getEnergy() >= 50 && !isRunning())
{
setRun(true);
return random(500, 1000);
}
//log("Finding enemy.");
RSNPC enemy = getNearestFreeValidNPCByID(enemies);
if(enemy == null)
{
//log("No enemies found.");
tries++;
return antiBan();
}
if(!isValidTile(enemy.getLocation()))
{
log("Enemy found but on invalid tile, this shouldn't happen!");
walkTileMM(validTiles[random(10,33)]); // walk to center-ish so it doesn't stick around edges
return random(1000, 2000);
}
//log("Found enemy.");
if(!tileOnScreen(enemy.getLocation()))
{
//log("Enemy not on screen, moving to enemy.");
walkTileMM(randomizeTile(enemy.getLocation(), 2, 2));
tries++;
return random(1000, 2000);
}
if(enemy.isInCombat()) // we shouldn't need this but apparently it thinks enemies are free even if they're not :/
{
return antiBan();
}
//log("Enemy free, Attemping to attack...");
if(!clickNPC(enemy, "Attack"))
{
tries++;
return antiBan();
}
//while(!getMyPlayer().isInCombat())
// wait(random(400, 600));
//log("Attack successfull.");
if(tries > 0)
tries = 0;
return random(250, 500);
}
public boolean autoEat ()
{
if(skills.getCurrentSkillLevel(STAT_HITPOINTS) <= 10)
{
for(int item : fish)
{
if(getInventoryItemByID(item) != null)
{
log("Eating item with id: "+item+".");
atInventoryItem(item, "Eat");
return true;
}
}
return false;
}
return true;
}
public boolean isValidTile (RSTile tileA)
{
for(RSTile tileB : validTiles)
{
if(tileA.equals(tileB))
return true;
}
return false;
}
public boolean doorCheck ()
{
if(!isValidTile(getMyPlayer().getLocation())) // we're outside of the room
{
log("Wandered away from room, returning.");
RSObject door = findObject(26913);
if(door != null)
{
walkTileMM(randomizeTile(new RSTile(3101, 3510), 2, 2));
wait(random(2500,5000));
if(atObject(door, "Open Large Door"))
{
log("Opening door.");
wait(random(500,1000));
}
}
walkTileMM(validTiles[random(10,33)]); // walk to center-ish
return true;
}
return false;
}
public int antiBan()
{
switch (random(0, 300))
{
case 1:
moveMouse(random(0, 745), random(0, 495), 5, 5);
wait(random(1000, 2000));
return random(500, 1000);
case 2:
if(random(1,8) == 2)
{
int angle = getCameraAngle() + random(-90, 90);
if (angle < 0 || angle > 359)
angle = 0;
setCameraRotation(angle);
}
return random(500, 1000);
case 3:
int temp = random(0, 14);
if(getCurrentTab() != temp)
openTab(temp);
return random(1000, 2000);
case 4:
if(getCurrentTab() != TAB_STATS)
openTab(TAB_STATS);
moveMouse(554, 226, 50, 84);
return random(1000, 2000);
default:
return random(250, 500);
}
}
public RSNPC getNearestFreeValidNPCByID (int... ids)
{
int Dist = 20;
RSNPC closest = null;
int[] validNPCs = Bot.getClient().getNPCIndexArray();
NPC[] npcs = Bot.getClient().getNPCArray();
for (int element : validNPCs)
{
if (npcs[element] == null)
continue;
RSNPC Monster = new RSNPC(npcs[element]);
try
{
for (int id : ids)
{
if (id != Monster.getID() || Monster.isInCombat() || Monster.getInteracting() != null || !isValidTile(Monster.getLocation()))
continue;
int distance = distanceTo(Monster);
if (distance < Dist)
{
Dist = distance;
closest = Monster;
}
}
}
catch (Exception e) {}
}
return closest;
}
private boolean clickNPC(RSNPC npc, String action)
{
if (npc == null)
return false;
RSTile tile = npc.getLocation();
if (!tile.isValid())
return false;
try
{
Point screenLoc = npc.getScreenLocation();
if (distanceTo(tile) > 6 || !pointOnScreen(screenLoc))
turnToTile(tile);
if (distanceTo(tile) > 20)
{
walkTileMM(tile);
return false;
}
for (int i = 0; i < 12; i++)
{
screenLoc = npc.getScreenLocation();
if (!npc.isValid() || !pointOnScreen(screenLoc))
return false;
moveMouse(screenLoc, 5, 5);
if (getMenuItems().get(0).toLowerCase().contains(npc.getName().toLowerCase()))
break;
if (getMouseLocation().equals(screenLoc))
break;
}
List<String> menuItems = getMenuItems();
if (menuItems.isEmpty())
return false;
for (int a = 0; a < menuItems.size(); a++)
{
if (menuItems.get(a).toLowerCase().contains(npc.getName().toLowerCase()))
{
if (menuItems.get(0).toLowerCase().contains(action.toLowerCase()))
{
clickMouse(true);
return true;
}
else
{
clickMouse(false);
return atMenu(action);
}
}
}
}
catch (Exception e)
{
System.out.print("clickNPC(RSNPC, String) error: " + e);
return false;
}
return false;
}
public void onRepaint(Graphics render)
{
long timer;
long hours = 0, minutes = 0, seconds = 0;
if(startTimer == 0)
startTimer = System.currentTimeMillis();
timer = System.currentTimeMillis() - startTimer;
seconds = timer / 1000;
if (seconds > 59)
{
minutes = seconds / 60;
seconds -= minutes * 60;
}
if (minutes > 59)
{
hours = minutes / 60;
minutes -= hours * 60;
}
render.setColor(Color.WHITE);
render.drawString("Script: "+getName(), 9, 32);
render.drawString("Author: "+getAuthor(), 9, 48);
render.drawString(stringSkill + " level: " + skills.getCurrentSkillLevel(skill), 9, 80);
render.drawString("XP Levlini: " + skills.getXPToNextLevel(skill), 9, 96);
render.drawString("XP Tulnud Töötamise ajal: "+ (skills.getCurrentSkillExp(skill)-startExp), 9, 110);
render.drawString("Töötanud aeg: " + hours + ":" + minutes + ":" + seconds, 9, 126);
}
}
Viimati muutis seda Admin (Reede Veeb 20, 2009 2:33 pm). Kokku muudetud 1 kord