the code have some problems and i cant test it bcs network shits D: <
update 1
- Code: Select all
//#! uniq = killersheep_hk
//#! name = Sheep Killer
//#! icon = gfx/kritter/pig/cdv
var counter=0
while(true){
sheep=getNearestObj("pig/s");
postNear2Obj(sheep,1)
jDoClick(sheep.getID(), 3, 0);
jWaitMove(2000);
if (jWaitPopup()) {
jSelectContextMenu("Slaughter");
jSleep(750);
jWaitProgress(12000);
}
jSleep(4000)
jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0);
jWaitMove(2000)
jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0);
jWaitMove(2000)
}
function postNear2Obj(obj,pos){
jPFMoveOffset_LX(obj.position(), pos);
}
function getNearestObj(obj) {
var trees = jGetObjects(50, jCoord(0, 0), [obj]);
var min_len = 100500;
var objid = 0;
for (var i = 0; i < trees.length; i++) {
if (trees[i].position().dist(jMyCoords()) < min_len) {
objid = trees[i];
min_len = trees[i].position().dist(jMyCoords());
}
}
return objid;
}
function getNearestSign() {
var trees = jGetObjects(40, jCoord(0, 0), ["arch/sign"]);
var min_len = 100500;
var objid = 0;
for (var i = 0; i < trees.length; i++) {
if (trees[i].position().dist(jMyCoords()) < min_len) {
objid = trees[i];
min_len = trees[i].position().dist(jMyCoords());
}
}
return objid;
}
function jPFMoveOffset_LX(point, offset) {
offsMoveS=jCoord(0,offset);
offsMoveE=jCoord(offset,0);
offsMoveW=jCoord(-offset,0);
offsMoveN=jCoord(0,-offset);
while (1) {
if(jPFMove(point.add(offsMoveS.mul(11))) > 0) {
jPFMove_LX(point.add(offsMoveS.mul(11)));
return offsMoveS;
}
if(jPFMove(point.add(offsMoveE.mul(11))) > 0) {
jPFMove_LX(point.add(offsMoveE.mul(11)));
return offsMoveE;
}
if(jPFMove(point.add(offsMoveW.mul(11))) > 0) {
jPFMove_LX(point.add(offsMoveW.mul(11)));
return offsMoveW;
}
if(jPFMove(point.add(offsMoveN.mul(11))) > 0) {
jPFMove_LX(point.add(offsMoveN.mul(11)));
return offsMoveN;
}
jPrint("jPFMoveOffset_LX can't find path");
// break;
jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0);
jSleep(500);
}
}
function jPFMove_LX(point) {
point = jTilify(point);
var MyX = jMyCoords().x;
var MyY = jMyCoords().y;
jPFMove(point);
cycles = 0;
while (MyX != point.x || MyY != point.y)
{
jPrint("jPFMove_LX My =" + MyX + " " + MyY + " - " + point.x + " " + point.y);
jSleep(1000);
MyX = jMyCoords().x;
MyY = jMyCoords().y;
if(cycles == 3)
{
jPrint("jPFMove_LX trying to move again");
jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0);
jSleep(500);
jPFMove(point);
cycles = 0
}
cycles++;
}
jPrint("jPFMove ended");
}
function getRandomArbitary(min, max)
{
return Math.random() * (max - min) + min;
}