var state = ""
var ghost_count = 0;
var god_count = 0;
var hpFraction = 1;
var spFraction = 0.95;
var warp_back = 0;
var flag_stop = 0;
var turn1 = 0;
var turn2 = 0;
var time = 0;
//my vars
//Chinh sua o duoi !!!
var mapid1 = 12013;
var mapid2 = 12521;
var warpid1 = 1;
var warpid2 = 5;
var id_chupt = 123456;
var id_ptmem1 = 123456;
var id_ptmem2 = 123456;
var id_ptmem3 = 123456;
var id_ptmem4 = 123456;
var id_quansu = 123456;
function MyAttack(){
turn1++;
if (turn1 == 1) {
sk = SkillID("Attack");
ts.SendAttack(
ts.Character.Row
, ts.Character.Col
, 0
, 2
, sk
)
}
if (turn1 >= 2) {
sk =18001;
ts.SendAttack(
ts.Character.Row
, ts.Character.Col
, ts.Character.Row
, ts.Character.Col
, sk
)
}
}
function MyPartnerAttack(){
turn2++;
if (turn2 == 1) {
sk = SkillID("Fire Arrow");
ts.SendAttack(
ts.CurrentPartner.Row
, ts.CurrentPartner.Col
, 0
, 2
, sk
)
}
if (turn2 >= 2) {
sk = 18001;
ts.SendAttack(
ts.CurrentPartner.Row
, ts.CurrentPartner.Col
, ts.CurrentPartner.Row
, ts.CurrentPartner.Col
, sk
)
}
}
function BattleStarted(){
turn1 = 0;
turn2 = 0;
warp_back = 0;
flag_stop = 0;
time = 0;
}
function BattleStoped(){
SaveWarrior();
EatHP();
EatSP();
DoSendItem()
}
function EatHP(){
if (ts.Character.HP < (){
doEatHP(0,(ts.Character.MAXHP * hpFraction)-ts.Character.HP)
}
if (ts.CurrentPartner.HP < (){
doEatHP(ts.CurrentPartner.Order,(ts.CurrentPartner.MAXHP * hpFraction)-ts.CurrentPartner.HP)
}
}
function EatSP(){
if (ts.Character.SP < (ts.Character.MAXSP * spFraction)){
doEatSP(0,(ts.Character.MAXSP * spFraction)-ts.Character.SP)
}
if (ts.CurrentPartner.SP < (ts.CurrentPartner.MAXSP * spFraction)){
doEatSP(ts.CurrentPartner.Order,(ts.CurrentPartner.MAXSP * spFraction)-ts.CurrentPartner.SP)
}
}
function SaveWarrior(){
if(ts.CurrentPartner.HP< 0){
frm.mnuEnableReconnect.Checked = false;
ts.Disconect();
debug(" Cuu nguoi tren het! Disconnect nha! : ",0x0000FF)
}
}
function onEvilGod(){
ghost_count++
debug("E V I L G O D."+"["+ghost_count+"]",0x0000FF)
}
function onLuckyGod(){
god_count++;
debug("LUCKY G O D.",0xFF0000)
if(!QA.Exists(ts.LastQuestion)){
QA.Add(ts.LastQuestion,ts.LastResponseAnswer)
msg = "QA.Add(\""+ts.LastQuestion+"\",\""+ts.LastResponseAnswer+"\")"
WriteLog("QA.js",msg)
}
}
function FinishAnswerFuckGod(){
if(ghost_count>=2){
debug("3 con ma rui! Disconnect thoi!",0x00aaaa)
ts.Disconect();
}
}
function doEatHP(order,difHp){
for(var i = 1;i<= 25 ;i++){
var oSlot = ts.MyItems.Item(i)
var oItem = ITEMS.Item(oSlot.itemid)
if (oSlot.itemid == 0){ continue; }
if(oItem.isHPItem()){
if (oItem.itemvalue > difHp){ continue; }
var eatHpAmt = (difHp - (difHp % oItem.itemvalue)) / oItem.itemvalue
if (eatHpAmt> 0){
if (eatHpAmt > oSlot.num){eatHpAmt = oSlot.num; }
ts.EatItem(i,eatHpAmt,order)
debug( "?"+oItem.itemname+" HP "+oItem.itemvalue+"at slot "+i+" decrease "+eatHpAmt+"?" ,0xC08008 )
difHp = difHp - eatHpAmt * oItem.itemvalue
}
}
}
}
function doEatSP(order,difSp){
for(var i = 1;i<= 25 ;i++){
var oSlot = ts.MyItems.Item(i)
var oItem = ITEMS.Item(oSlot.itemid)
if (oSlot.itemid == 0){ continue; }
if(oItem.isSPItem()){
if (oItem.itemvalue > difSp){ continue; }
var eatSpAmt = (difSp - (difSp % oItem.itemvalue)) / oItem.itemvalue
if (eatSpAmt> 0){
if (eatSpAmt > oSlot.num){eatSpAmt = oSlot.num; }
ts.EatItem(i,eatSpAmt,order)
debug( "?"+oItem.itemname+" SP "+oItem.itemvalue+"at slot "+i+" decrease "+eatSpAmt+"?" ,0xC08008 )
difSp = difSp - eatSpAmt * oItem.itemvalue
}
}
}
}
function DoSendItem() {
for(var i=1;i<=25;i++){
var oSlot = ts.MyItems(i);
if( oSlot.itemid == 0){ continue; }
var oItem = ITEMS.Item(oSlot.itemid);
var itemname = oItem.getName();
if( (itemname == "AutoAttackPill"
|| itemname == "Honey pill"
|| itemname == "AutoTonicPill"
|| itemname == "Yellow wine"
|| itemname == "ZhuoScroll"
|| itemname == "HasteScroll") && oSlot.num ==50){
ts.SendItemTo(606712,oSlot.slot,oSlot.num);
} else { if ((itemname == "Blood tonic"
|| itemname == "6HerbPotion"
|| oSlot.itemid == 27035
|| itemname == "ZhongYuanDew"
|| itemname == "RefreshPill") && oSlot.num ==50)
{ts.SendItemTo(606712,oSlot.slot,oSlot.num);}
}
}
}
function PlayerOnline( playerid ){
if (playerid == id_chupt) {
if (ts.Character.mapid==12012) {ts.Warp(2);}
if (ts.Character.mapid==mapid2) {ts.warp(warpid2);}
}
}
function Start(){
}
function Stop(){
}
function InitBot(){
debug("login okie", 0x00FF00)
EatHP();
EatSP();
if (ts.Character.mapid==12012) {ts.Warp(2);}
if (ts.Character.mapid==mapid2) {ts.warp(warpid2);}
frm.mnuAutoEat.Checked = false;
frm.mnuEnableReconnect.Checked = true;
Timer.Enabled = true;
}
function OnTimer(){
if (ts.Character.mapid==12012) {time++; if (time ==5) {time = 0; ts.Warp(2);}}
if (ts.Character.mapid==mapid2) {time++; if (time ==5) {time = 0; ts.Warp(warpid2);}}
ts.RequestParty(id_chupt);
}
function RequestPartyAcceptedFrom(uid) {
if (uid==id_chupt) Timer.Enabled=false;
}
function PartyStop( playerid ){
if(playerid == id_chupt || playerid == id_ptmem1 || playerid == id_ptmem2 || playerid == id_ptmem3 || playerid == id_ptmem4){
if (ts.Character.mapid==12012) {ts.Warp(2);}
if (ts.Character.mapid==mapid2) {ts.warp(warpid2);}
}
}
function warpFinish(){
if (ts.Character.mapid==10952) {ts.Walk(902,875);ts.delay(50);ts.delay(50);ts.warp(1);}
}
InitBot()