Author Topic: [D2NT] Leechfighter COW script  (Read 756 times)

noob_patrol

  • Guest
[D2NT] Leechfighter COW script
« on: June 19, 2010, 11:55:29 PM »
hey this is a modified cow script from here, http://purekaoz.com/index.php/topic,91.0.html

if you put this in your bots as NTCowLeech.ntj

add NTConfig_Script.push("NTCowLeech.ntj"); NTConfig_KillRakanishuCows = true; NTConfig_TristExtension = true; to your char_config it should wait for the leader to make the cow, then follow him in and help. He is simply on a delay to check for cow portal so you may need to adjust the delay on:
NTC_PingDelay(55000);
if(!NTR_TakeCowPortal(1)
{
NTC_SendMsgToScript("NTBotGame.ntj", "Failed to take Cow Portal.");
return;
Depending on how long it takes your leader to make cow portal, I.E he does countess first and such


Code: [Select]
// D2NT Cow script
// Version 1.4.1
//--- CONFIG ---
const _NTR_FAIL_CHECKS = 25; // Number of failed teleports before script ends. Ex. Edge of map causes a fail teleport. DEFAULT: 25
const _NTR_PRE_EVERY = 40; // Number of seconds before precasting again. -1 for never. DEFAULT: 40
const _NTR_CHEST_AND_ROCKS = true; // Open chest and rocks. DEFAULT: true
//--- END ---

const _NTR_STRING_PORTAL = GetLocaleString(3226);

function NTMain()
{
   Include("libs/common/NTCommon.ntl");
   NTC_IncludeLibs();
   NTC_IncludeConfig("NTBot/char_configs");
   NT_LoadConfig();
   NTSI_LoadNIPFiles("NTBot/item_configs");
   NTA_Initialize();
   if(!NTTM_CheckAct())
   {
      NTC_SendMsgToScript("NTBotGame.ntj", "NTTM_CheckAct()");
      return;
}   
      if(!NTTM_TownMove("waypoint"))
      {
         NTC_SendMsgToScript("NTBotGame.ntj", "NTTM_TownMove()");
         return;
      }
      if(!NTM_TakeWaypoint(1))
      {
         NTC_SendMsgToScript("NTBotGame.ntj", "NTM_TakeWaypoint()");
         return;
      }

    NTTM_TownMove("stash");
    for(var i = 0 ; i < 10 ; i++)
    {
        _stash = NTC_FindUnit(NTC_UNIT_OBJECT, NTC_UNIT_STASH);
        if(_stash)
         break;
   }

    NTC_PingDelay(55000); // adjust this delay depending on how long it takes leader to make portal
    if(!NTR_TakeCowPortal(18))
    {
        NTC_SendMsgToScript("NTBotGame.ntj", "Failed to take Cow Portal.");
        return;
    }
    NTP_DoPrecast();
    NTR_ClearRooms();
   NTC_SendMsgToScript("NTBotGame.ntj", "SCRIPT_END");
      }


// Internal functions
function NTR_GetTP()
{
   var _portals = me.GetItems("tbk");
   
   if (_portals)
   {
      for (var i = 0; i < _portals.length; i++)
      {
         if (_portals[i].mode == 0 && (_portals[i].itemloc != 0 || NTConfig_Columns[_portals[i].y][_portals[i].x] > 0))
         {
            return _portals[i];
         }
      }
   }
   return false;
}
function abs(integer)
{
   if(integer < 0){
      integer = -integer;
   }
   return integer;
}
function NTR_TakeCowPortal(range)
{
   var _portal = NTC_FindUnit(NTC_UNIT_OBJECT, _NTR_STRING_PORTAL);
   
   if (_portal)
   {
      var _isClick;
      var _preAreaId = me.areaid;
      do
      {
         if (GetDistance(me, _portal) < range && _portal.mode == 2)
         {
            for (var i = 0; i < 40; i++)
            {
               if ((i % 10) == 0)
               {
                  if(NTM_GetCloserInt(_portal))
                     _isClick = NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _portal);
               }
               if (_isClick)
               {
                  NTC_Delay(200);
                  break;
               }
            }
            NTC_PingDelay(1000);
            var j = 0;
            var check = true;
            do
            {
               if (me.areaid != _preAreaId)
               {
                  NTC_PingDelay(500);
                  return true;
                  check = false;
               }
               j++;
            } while(j < 40 && check == true);
         }
      } while (_portal.GetNext());
   }
   return false;
}
function NTR_ClearPosition(range, pickitem, safelevel, failed)
{
   var _orgx, _orgy;
   var _spectype = [0x0A, 0x01, 0x01];
   var _skiplist;
   var _attackcount = 0;
   var _target;
   var _distance, _mingid, _mindistance;
   var _result;
   var _cowKing;
   var _test;

   if(NTConfig_AttackSkill[1] < 1 || NTConfig_AttackSkill[3] < 1)
      return false;

   switch(arguments.length)
   {
   case 0:
      range = 20;
   case 1:
      pickitem = false;
   case 2:
      safelevel = 0;
   default:
      if(NTConfig_CheckSelfSafe < 0x01 && NTConfig_CheckMercSafe < 0x01)
         safelevel = 0;
      break;
   }

   _orgx = me.x;
   _orgy = me.y;

   for(var i = 0 ; i < _spectype.length ; i++)
   {
      _skiplist = new Array();
      while(_attackcount < (i+1)*100)
      {
         _mindistance = 100000;
         _target = NTC_FindUnit(NTC_UNIT_MONSTER);
         if(_target)
         {
            do
            {
               if(_skiplist.indexOf(_target.gid) < 0)
               {
                  if(_target.IsAttackable() && (_target.spectype&_spectype[i]))
                  {
                     if(GetDistance(_orgx, _orgy, _target.x, _target.y) <= range && NTA_IsValidMonster(_target))
                     {
                        _distance = GetDistance(me, _target);

                        if(_distance < _mindistance)
                        {
                           _mingid = _target.gid;
                           _mindistance = _distance;
                        }
                     }
                  }
                  else
                     _skiplist.push(_target.gid);
               }
            } while(_target.GetNext());
         }
         if(_mindistance < 100000)
         {
            _target = NTC_FindUnit(NTC_UNIT_MONSTER, _mingid);

            if(_target)
            {
               _cowKing = GetUnit(NTC_UNIT_MONSTER, GetLocaleString(2850));
               if(_cowKing){
                  return true;
               }
               _result = NTA_Attack(_target, (_attackcount%30) == 0);

               switch(_result)
               {
               case 1:
                  _skiplist.push(_mingid);
                  break;
               case 2:
               case 3:
                  _attackcount++;
                  break;
               default:
                  return false;
               }
            }
         }
         else
            break;
      }
   }
   if(me.classid == NTC_CHAR_CLASS_PALADIN)
   {
      if(_attackcount > 2 && (parseInt(me.hp*100/me.hpmax) < NTConfig_UseRedemptionHP || parseInt(me.mp*100/me.mpmax) < NTConfig_UseRedemptionMP))
      {
         if(NTC_PutSkill(124, NTC_HAND_RIGHT))
            NTC_PingDelay(1000);
      }
   }
   _cowKing = GetUnit(NTC_UNIT_MONSTER, GetLocaleString(2850));
   if(_cowKing){
      return true;
   }
   if(_NTR_CHEST_AND_ROCKS && failed == false)
   {
      _target = NTR_GetChest();
      if(_target){
         do
         {
         if(_target && GetDistance(_orgx, _orgy, _target.x, _target.y) <= range)
         {   
               if(NTC_OpenChest(_target))
                  NTSI_PickItems();
           
         }
         }while(_target.GetNext());
      }
      _target = NTR_GetObj(174);
      if(_target){
         do
         {
            if(_target && GetDistance(_orgx, _orgy, _target.x, _target.y) <= range)
            {
               if(NTM_MoveTo(me.areaid, _target.x, _target.y))
               {
                  if(NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _target))
                  {
                     Delay(200);
                     NTSI_PickItems();
                  }
               }
            }
         }while(_target.GetNext());
      }
      _target = NTR_GetObj(175);
      if(_target){
         do
         {
            if(_target && GetDistance(_orgx, _orgy, _target.x, _target.y) <= range)
            {
               if(NTM_MoveTo(me.areaid, _target.x, _target.y))
               {
                  if(NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _target))
                  {
                     Delay(200);
                     NTSI_PickItems();
                  }
               }
            }
         }while(_target.GetNext());
      }
      _target = NTR_GetObj(159);
      if(_target){
         do
         {
            if(_target && GetDistance(_orgx, _orgy, _target.x, _target.y) <= range)
            {
               if(NTM_MoveTo(me.areaid, _target.x, _target.y))
               {
                  if(NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _target))
                  {
                     Delay(200);
                     NTSI_PickItems();
                  }
               }
            }
         }while(_target.GetNext());
      }
      _target = NTR_GetObj(155);
      if(_target){
         do
         {
            if(_target && GetDistance(_orgx, _orgy, _target.x, _target.y) <= range)
            {
               if(NTM_MoveTo(me.areaid, _target.x, _target.y))
               {
                  if(NTC_DoClick(NTC_CLICK_LDOWN, NTC_SHIFT_NONE, _target))
                  {
                     Delay(200);
                     NTSI_PickItems();
                  }
               }
            }
         }while(_target.GetNext());
      }
   }
   if(pickitem && _attackcount > 0)
      NTSI_PickItems();
   switch(safelevel)
   {
   case 1:
      return NTTMGR_CheckSafe(0x00, NTConfig_CheckMercSafe&0x01);
   case 2:
      return NTTMGR_CheckSafe(NTConfig_CheckSelfSafe, NTConfig_CheckMercSafe);
   }
   return true;
}
function NTR_ClearRooms()
{
   var failcount = 0, precount = 0, x, y, offx = 0, offy = 0, goalx = 0, goaly = 0, cowoffx = 0, cowoffy = 0;
   var toggle = true;
   var _cowKing;
   var _faillast;
   
   x = me.x;
   y = me.y;
   
   //NTC_PingDelay(5000);
   while (failcount <= _NTR_FAIL_CHECKS)
   {
      if(toggle == true && offx == goalx){
         if(goaly < 0){
            goaly=(0-(goaly-20));
         }else{
            goaly=(0-(goaly+20));
         }
         toggle = false;
      }
      if(toggle == false && offy == goaly){
         if(goaly < 0){
            goalx=(0-(goalx-20));
         }else{
            goalx=(0-(goalx+20));
         }
         toggle = true;
      }
      if(offy > goaly){
         offy-=20;
         y-=20;
      }
      if(offy < goaly){
         offy+=20;
         y+=20;
      }
      if(offx < goalx){
         offx+=20;
         x+=20;
      }
      if(offx > goalx){
         offx-=20;
         x-=20;
      }
      _cowKing = GetUnit(NTC_UNIT_MONSTER, GetLocaleString(2850));
      if(!_cowKing){
         NTR_ClearPosition(20, true, 0, _faillast);
         if(((GetTickCount()-precount)/1000) >= _NTR_PRE_EVERY && _NTR_PRE_EVERY >= 0){
            NTP_DoPrecast();
            precount = GetTickCount();
         }
      }
      if(!NTM_MoveTo(me.areaid, x, y)){
         failcount++;
         _faillast = true;
      }else{
         _faillast = false;
      }
   }
   return true;
}
function NTT_SecondTomeTP(npc, type, amount)
{
   var _items;
   var _counter = 0;

   if(arguments.length < 1)
      return false;

   if(arguments.length < 2)
      type = 0;

   if(arguments.length < 0)
      amount = 1;

   if(amount == 0)
      return false;

   if(type)
      _items = npc.GetItems("tbk");

   if(_items)
   {
      if(_items.length > 0)
      {
         for(var i = 0 ; i < amount ; i++)
         {
            if(NTT_ShopItem(_items[0], npc, 2))
               _counter++;
         }
      }
   }
   return (_counter > 0);
}
function NTR_GetChest()
{
   var _chest;

   _chest = NTC_FindUnit(NTC_UNIT_OBJECT, "chest");
    if(_chest)
    {
      return _chest;
    }

   return null;
}
function NTR_GetObj(num)
{
   var _chest;

   _chest = NTC_FindUnit(NTC_UNIT_OBJECT, num);
    if(_chest)
    {
      return _chest;
    }

   return null;


Credits
~Protonman1
~OhhWatALoser