|
function main()
{
print("loading " +charsetfile +" For " +me.name);
include(charsetfile);
load("bots\\PwnagePindle.d2j");
potionloop();
}
// Dont mess with anything below here or you will die
var waitForLeech=true;
function drinkpot(type)
{
var pot = null;
var potType;
switch (type.charAt(0).toLowerCase())
{
case "r":
{
if(me.hp < mymaxlife*.20 || me.mp < mymaxmana*.20)
potType = "rvl";
else
potType = "rvs";
pot = getItem(potType, 2);
if (!pot)
{
if(me.hp < mymaxlife*.20 || me.mp < mymaxmana*.20)
potType = "rvs";
else
potType = "rvl";
pot = getItem(potType, 2);
}
break;
}
case "h":
{
for (i = 5; i > 0; i--)
{
potType = "hp" + i.toString();
pot = getItem(potType, 2);
if (pot) break;
}
break;
}
case "m":
{
for (i = 5; i > 0; i--)
{
potType = "mp" + i.toString();
pot = getItem(potType, 2);
if (pot) break;
}
break;
}
default:
{
print("Invalid argument " + type + " passed to drinkpot()");
return -1;
}
}
if (pot && pot.getParent().name == me.name)
{
var potgid = pot.gid;
var tries=0;
var limit=5;
for (i = 1; i <= 2 && pot && pot.gid == potgid; i++)
{
if (me.classid == 4 && me.mode == 18)
{
print("Can't drink right now...");
return -1;
}
if (pot && pot.gid == potgid)
pot.interact(1);
while (pot && pot.gid == potgid && pot.getParent().name == me.name && tries++ < limit*i)
{
delay(100);
pot = getItem(potType, 2);
}
}
// did we drink it?
if (pot && pot.gid == potgid)
return -1; // drink failed
else
return 1;
}
return 0;
}
|