var state = ""
var ghost_count = 0;
var god_count = 0;
var hpFraction = 0.9;
var spFraction = 0.9;
var warp_back = 0;
var flag_stop = 0;
var check = 0;
var turn1 = 0;
var turn2 = 0;
var counter = 0;
var time1 = 0;
var time2 = 0;
var delay1 = 1000;
var delay2 = 500;
//my vars
//Chinh sua o duoi !!!
var mapid1 = 12013;
var mapid2 = 12521;
var warpid1 = 1;
var warpid2 = 5;
var id_chupt = 1111111; // Điền Id của chủ Pt vào đây
var id_ptmem1 = 222222;// Id của các thành viên trong Pt
var id_ptmem2 = 333333;
var id_ptmem3 = 444444;
var id_ptmem4 = 555555;
var id_quansu = *******;// Điền lại Id của Quân sư
function MyAttack(){
turn1++;
if (turn1 == 1) {
sk = SkillID("Attack"); // Đặt skill của tướng, thông tin về Id của skill tham khảo thêm
ts.SendAttack(
ts.Character.Row
, ts.Character.Col
, 0
, 2
, sk // vị trí đánh của tướng 0 tưong ứng với hàng sau, 2 tương ứng với vị trí đánh, 0,2 tức là hàng sau, vị trí thứ 2 tính từ trái qua phải
)
}
if (turn1 >= 2) {
sk = SkillID("Attack");
ts.SendAttack(
ts.Character.Row
, ts.Character.Col
, 0
, 4
, 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 = SkillID("Defend");
ts.SendAttack(
ts.CurrentPartner.Row
, ts.CurrentPartner.Col
, ts.CurrentPartner.Row
, ts.CurrentPartner.Col
, sk
)
}
}
function BattleStarted(){
check = 0;
turn1 = 0;
turn2 = 0;
warp_back = 0;
flag_stop = 0;
time1 = 0;
time2 = 0;
}
function BattleStoped(){
check = 1;
SaveWarrior();
EatHP();
EatSP();
//DoSendItem()
DoDropItem()
time1 = 0;
time2 = 0;
}
function EatHP(){
if (ts.Character.HP < (ts.Character.MAXHP * hpFraction)){
doEatHP(0,(ts.Character.MAXHP * hpFraction)-ts.Character.HP)
}
if (ts.CurrentPartner.HP < (ts.CurrentPartner.MAXHP * hpFraction)){
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< 10){
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 NpcDialogMenu(DialogId){
debug("Menu "+DialogId,0x0000FF)
ts.SelectChoice(1);
ts.SendEnd();
}
function NpcDialog(DialogId) {
debug("Dialog "+DialogId,0x0000FF)
ts.SendEnd()
}
function FinishAnswerFuckGod(){
if (check = 1) { if (ts.Character.mapid==mapid1) {ts.Walk(1522,175);ts.delay(delay1);ts.delay(500);ts.warp(warpid1);};
if ((ts.Character.mapid==mapid2) && (flag_stop == 0)) {ts.Walk(60,1630);ts.delay(delay2);ts.delay(500);ts.warp(warpid2);}
}
if(ghost_count>=2){
debug("2 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 DoDropItem() {
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 == "Saltedshoots"
|| itemname == "ZhuoScroll"
|| itemname == "HasteScroll")){
ts.DropItem(oSlot.slot,oSlot.num);
}
}
}
/*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 == "Saltedshoots"
|| itemname == "ZhuoScroll"
|| itemname == "HasteScroll") && oSlot.num ==50){
ts.SendItemTo(75909,oSlot.slot,oSlot.num);
} else { if ((itemname == "Blood tonic"
|| itemname == "6HerbPotion"
|| oSlot.itemid == 27035
|| itemname == "ZhongYuanDew"
|| itemname == "RefreshPill") && oSlot.num ==50)
{ts.SendItemTo(75909,oSlot.slot,oSlot.num);}
}
}
}*/
function Start(){
flag_stop = 0;
time1 = 0;
time2 = 0;
if (ts.Character.mapid==mapid1) {ts.Walk(1522,175);ts.delay(delay1);ts.warp(warpid1);}
if (ts.Character.mapid==mapid2) {ts.Walk(60,1630);ts.delay(delay2);ts.warp(warpid2);}
}
function Stop(){
flag_stop = 1;
}
function InitBot(){
debug("login okie", 0x00FF00)
ts.Horse();
EatHP();
EatSP();
if (ts.Character.mapid==12012) {flag_stop = 1;ts.warp(2);}
if (ts.Character.mapid==mapid2) {flag_stop = 1;ts.warp(warpid2);}
frm.mnuAutoEat.Checked = false;
frm.mnuEnableReconnect.Checked = true;
Timer.Enabled = true;
}
function OnTimer(){
counter++;
if (counter == 30) {
ts.AcceptParty(id_ptmem4);
ts.AcceptParty(id_ptmem3);
ts.AcceptParty(id_ptmem2);
ts.AcceptParty(id_ptmem1);
ts.sena(id_quansu);
ts.Warp(warpid1);
}
if (counter==1000) {counter=counter-900};
if (ts.Character.mapid==mapid2) {time1++; if (time1 == 10) {time1 = 0;flag_stop = 0;check = 1;ts.warp(warpid2);}}
if (ts.Character.mapid==mapid1) {time2++; if (time2 == 120) {time2 = 0;flag_stop = 0;check = 1;ts.warp(warpid1);}}
}
function PartyStop( playerid ){
if(playerid == id_chupt || playerid == id_ptmem1 || playerid == id_ptmem2 || playerid == id_ptmem3 || playerid == id_ptmem4){
ts.Disconect();
}
}
function warpFinish(){
if ((check == 1) && flag_stop==0) { if (ts.Character.mapid==mapid1) {ts.Walk(1522,175);ts.delay(delay1);ts.warp(warpid1);};}
if (ts.Character.mapid==mapid2) {ts.Walk(60,1630);ts.delay(delay2);ts.warp(warpid2);}
if (ts.Character.mapid==10952) {ts.Walk(902,875);ts.delay(1000);ts.delay(1000);ts.warp(1);}
}
InitBot()
debug("Ti`nh trang hien nay: " + ts.Character.Ghost + " con ma!",0xFF9933)