var state = "";
var pt_count=0;
var max_coumt=1
var ghost_count = 0;
var DisconnectFlag = 0.3;
var isMove = 0;
var isAutoRegenOK = 1;
var x;
var y;
var god_count = 0;
var die_count = 0;
var pet_die_count = 0;
var battle_count = 0;
var HealingFlag = 0.5;
var hpFraction = 0.8
var spFraction = 0.65
var MyMapID = ts.Character.mapid;
function Start(){
// no remove this function
ts.Walk(562,1615)
}
function Stop(){
// no remove this function
ts.Walk(302,1795)
}
function MyAttack(){
m = SelectF1Target()
sk = SkillID(attack);
ts.SendAttack(
ts.Character.Row
, ts.Character.Col
, m.Row
, m.Col
, sk =10000
)
}
function MyPartnerAttack(){
m = SelectF1Target()
sk = SkillID(attack);
ts.SendAttack(
ts.CurrentPartner.Row
, ts.CurrentPartner.Col
, m.Row
, m.Col
, sk =10000
)
}
function AcceptedParty(playerid)
{
if(playerid == getPlayerId("vn466847") )
{
ts.AcceptParty(playerid)
pt_count++;
}
if(playerid == getPlayerId("vn466847"))
{
ts.sena(playerid)
}
if (pt_count==max_count)
{
Start();
}
}
function PartyStop( playerid )
{
if(playerid == getPlayerId("vn466847") )
{
pt_count--;
debug("Dis by " + playerid + " dis",0xFF0000)
ts.Disconect();
}
}
function BattleStarted(){
battle_count++;
}
function BattleStoped(){
/* Just safty first. for Warrior not leave you call function SaveWarrior() every end battle. */
SaveWarrior();
CheckDisconnect();
AutoEatHPSP()
ViewState()
//ts.ClickOnNPC(1)
}
function ViewState(){
debug("************************************",0xFF0000)
debug(" Battle Count : " + battle_count ,0xFF0000)
debug(" Dead Count : " + die_count ,0xFF0000)
debug(" Pet KO Count : " + pet_die_count, 0xFF0000)
debug(" Lucky Count : " + god_count, 0xFF0000)
debug(" Ghost Count : " + ts.Character.Ghost ,0xFF0000)
debug(" Warrior's FAI : " + ts.CurrentPartner.CharName +" : " + ts.CurrentPartner.fai,0xFF0000)
debug("************************************",0xFF0000)
}
function SaveWarrior(){
if(ts.CurrentPartner.HP< ((0.20) * ts.CurrentPartner.MAXHP)){
//ts.Disconect();
debug(" SAVE THE FAI DISCONNECT NOW! : ",0x0000FF);
}
}
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) || (oSlot.itemid == 50001)) { 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 AutoEatHPSP() {
var bRet=true;
if (ts.Character.HP < (ts.Character.MAXHP * hpFraction)){
doEatHP(0,(ts.Character.MAXHP)-ts.Character.HP)
}
if (ts.Character.SP < (ts.Character.MAXSP * spFraction)){
doEatSP(0,(ts.Character.MAXSP)-ts.Character.SP)
}
if (ts.CurrentPartner.HP < (ts.CurrentPartner.MAXHP * hpFraction)){
doEatHP(ts.CurrentPartner.Order,(ts.CurrentPartner .MAXHP )-ts.CurrentPartner.HP)
}
if (ts.CurrentPartner.SP < (ts.CurrentPartner.MAXSP * spFraction)){
doEatSP(ts.CurrentPartner.Order,(ts.CurrentPartner .MAXSP )-ts.CurrentPartner.SP)
}
}
function onEvilGod(){
ghost_count++
debug("E V I L G O D."+"["+ghost_count+"]",0x0000FF)
msg = "Wrong.Add(\""+ts.LastQuestion+"\",\""+ts.LastResponseAnswer+"\")"
WriteLog("Wrong.js",msg)
}
function onLuckyGod(){
debug("LUCKY G O D.",0xFF0000)
if(!QA.Exists(ts.LastQuestion)){
AddQA(ts.LastQuestion,ts.LastResponseAnswer)
msg = "AddQA(\""+ts.LastQuestion+"\",\""+ts.LastResponseAnswer+"\")"
WriteLog("QA.js",msg)
}
}
function OnTimer(){
if(isAutoRegenOK==1) {
if (isAutoRegen){
if (ts.Character.HP >= CharFlagHighHP && ts.CurrentPartner.HP >= PartnerFlagHighHP){
debug("Going to Battle field...",0x00FF00);
isAutoRegen = 0;
status=1;
Timer.Enabled = false
MoveCircle( MyMapID )
}
}
}
if(isMove) {
if(x) {
Move(corX1,corY1)
x = 0
}else{
Move(corX2,corY2)
x = 1
}
}
}
function FinishAnswerFuckGod(){
if(ghost_count>=3){
debug("3 FuckGod detected bye!",0x00FF00);
//ts.Disconect();
}
}
function Start(){
// no remove this function
ts.Walk(562,795)
}
function Stop(){
// no remove this function
ts.Walk(242,715)
}
function CheckDisconnect(){
if(ts.Character.HP < 2
|| ts.CurrentPartner.HP < 2
){
//ts.Disconect();
}
}
function OnChat(PlayerName , Msg){
debug(PlayerName + " " + Msg , 0 )
}
function InitBot()
{
}
function onNPCAppear( npcmapid , x , y ){
//debug(npcmapid,0)
if(npcmapid == npcmapid){
ts.ClickOnNPC(npcmapid)
ts.ClickOnNPC(npcmapid)
}
}
InitBot()
ClearLog("Wrong.js")