Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 10th, 2010  |  syntax: None  |  size: 8.28 KB  |  hits: 131  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function findLead(leader)
  2. {
  3.    var _lead= getUnit(0, leader)
  4.       if(_lead)
  5.       return _lead.area;
  6.    // leader not found look in party
  7.    var area =0;
  8.     var a = getParty();
  9.    if(!a)
  10.       return false;
  11.        
  12.       do {
  13.         if (a.name==leader){
  14.          area=a.area;    
  15.          }
  16.       } while(a.getNext());
  17.       if (area==0) {
  18.          //sendCopyData(null, "OOG", 0,"Quit:Quit()" );
  19.          return false;
  20.  
  21.       }
  22.    return area;
  23. }
  24.  
  25. var _NTLW_timerLastDrink = new Array(5);
  26.    var myself;
  27.    var pause = false;
  28.    var _LifeMax
  29.    var _ManaMax
  30.    var _count = 0;
  31.    var _mercHP;
  32.    var _party, _mypartyid;
  33.    var Result =" ";
  34.    var Reason =" ";
  35. var _NTLW_timerLastDrink = new Array(5);
  36. var debugStr;
  37. function main()
  38. {
  39.  Result =" ";
  40. Reason =" ";
  41.    delay(500);
  42.    //text "text",x,y,color,font,alingment
  43.    //var LWHook = new Text("LWHook", 400, 550, 2, 6, 2);
  44.    //var LWHook2 =  new Text("", 400, 540, 2, 6, 2);
  45.    include("common/NTCommon.dbl");
  46.    NTC_IncludeConfig();
  47.    var DrinkHP;
  48.    var DrinkMP;
  49.    var DrinkRV;
  50.    var MercHP;
  51.    var meHP;
  52.    var meMP;
  53.    var DrinkRVm;
  54.    var LastAction =" " ;
  55.    
  56.    var _count = 0;
  57.    var _LifeMax, _ManaMax;
  58.    var _mercHP;
  59.    var _party, _mypartyid;
  60.  
  61.    print("ÿc3Start ToolsThread script");
  62.  
  63.    NT_LoadConfig();
  64.  
  65.    _LifeMax = me.hpmax;
  66.    _ManaMax = me.mpmax;
  67.  
  68.    if(NTConfig_LifeChicken > 0)
  69.    
  70.       me.chickenhp = parseInt((_LifeMax*NTConfig_LifeChicken)/100,10);
  71.  
  72.    if(NTConfig_ManaChicken > 0)
  73.       me.chickenmp = parseInt((_ManaMax*NTConfig_ManaChicken)/100,10);
  74.  
  75.    for(var i = 0 ; i < 5 ; i++)
  76.       _NTLW_timerLastDrink[i] = ((getTickCount())-5000);
  77.        
  78.    //print( _NTLW_timerLastDrink[2] );
  79. myself = copyUnit(me);
  80.    while(me.ingame)
  81.    {
  82.    
  83.       if(!LW_InTown())
  84.       {
  85.          if(_LifeMax != me.hpmax)
  86.          {
  87.             _LifeMax = me.hpmax;
  88.  
  89.             if(NTConfig_LifeChicken > 0)
  90.                me.chickenhp = parseInt((_LifeMax*NTConfig_LifeChicken)/100,10);
  91.          }
  92.  
  93.          if(_ManaMax != me.mpmax)
  94.          {
  95.             _ManaMax = me.mpmax;
  96.  
  97.             if(NTConfig_ManaChicken > 0)
  98.                me.chickenmp = parseInt((_ManaMax*NTConfig_ManaChicken)/100);
  99.          }
  100.    /*
  101.    DrinkHP = parseInt((_LifeMax*NTConfig_LifeThresh)/100);
  102.    DrinkMP = parseInt((_ManaMax*NTConfig_ManaThresh)/100,10);
  103.    DrinkRV =parseInt((_LifeMax*NTConfig_LifeRejuvThresh)/100,10);
  104.    DrinkRVm = parseInt((_ManaMax*NTConfig_ManaRejuvThresh)/100,10)
  105.    meHP =me.hp;
  106.    meMP = me.mp;
  107.    debugStr ="Drinking HP at:"+DrinkHP+" Drinking MP at:"+DrinkMP+" Drinking RVhp at:"+DrinkRV +" ManaJuv at:"+DrinkRVm;
  108.    LWHook.text = debugStr;
  109.    LWHook2.text = LastAction + " " + Reason;
  110.    */
  111.    //me.overhead( LastAction + " " + Reason);
  112.          if(me.hp < parseInt((_LifeMax*NTConfig_LifeRejuvThresh)/100,10) || me.mp < parseInt((_ManaMax*NTConfig_ManaRejuvThresh)/100,10)){
  113.             LastAction="Drink Rejuve";
  114.             if (!NTLW_DrinkPotInt(2)){ //failed to find juvie drink hp/mp
  115.                if(me.hp < parseInt((_LifeMax*NTConfig_LifeThresh)/100,10)){
  116.                   NTLW_DrinkPotInt(0);
  117.                   LastAction="Drinking HP";
  118.                }
  119.                if(me.mp < parseInt((_ManaMax*NTConfig_ManaThresh)/100,10)){
  120.                   NTLW_DrinkPotInt(1);
  121.                   LastAction="Drinking MP";
  122.                }            
  123.             }            
  124.          }else
  125.          {
  126.             if(me.hp < parseInt((_LifeMax*NTConfig_LifeThresh)/100,10)){
  127.                NTLW_DrinkPotInt(0);
  128.                   LastAction="Drinking HP";
  129.             }
  130.             if(me.mp < parseInt((_ManaMax*NTConfig_ManaThresh)/100,10)){
  131.                NTLW_DrinkPotInt(1);
  132.                LastAction="Drinking MP";
  133.             }
  134.          }
  135.  
  136.          _mercHP = getMercHP();
  137.  
  138.          if(_mercHP > 0)
  139.          {
  140.             if(_mercHP < NTConfig_MercChicken)
  141.             {                
  142.                quit();
  143.                break;
  144.             }
  145.  
  146.             if(_mercHP < NTConfig_MercRejuvThresh){
  147.                NTLW_DrinkPotInt(4);
  148.                LastAction="Merc Rejuve";
  149.             }
  150.             else if(_mercHP < NTConfig_MercLifeThresh){
  151.                LastAction="Merc HP";
  152.                NTLW_DrinkPotInt(3);
  153.             }
  154.          }
  155.       }
  156.  
  157.       if(_count++ > 10)
  158.       {
  159.          if(NTConfig_PublicMode)
  160.          {
  161.             var leader;
  162.             _party = getParty();
  163.  
  164.             if(_party)
  165.             {
  166.                _mypartyid = _party.partyid;
  167.                for (var z = 0 ; z < NT_Leader.length ; z++) {
  168.                   if  (findLead(NT_Leader[z])) {
  169.                      leader = NT_Leader[z];
  170.                      break;
  171.                   }
  172.                   else sendCopyData(null,"OOG",0,"Leader Not Found -->" +NT_Leader[z]);
  173.                }
  174.                while(_party.getNext())
  175.                {
  176.                   if((leader && _party.name == leader) || !leader || me.charname == leader)
  177.                      if(_party.partyid == 65535 || _party.partyid != _mypartyid)
  178.                      {
  179.                         if(_party.partyflag == 2)
  180.                         {
  181.                            clickParty(_party, 2);
  182.                            continue;
  183.                         }
  184.  
  185.                         if(_party.partyid == 65535 && me.charname == leader)
  186.                         {
  187.                            if(_party.partyflag == 4)
  188.                               continue;
  189.  
  190.                            clickParty(_party, 2);
  191.                            delay(40);
  192.  
  193.                            if(_party.partyflag == 4 || (_party.partyid != 65535 && _party.partyid == _mypartyid))
  194.                               continue;
  195.                         }
  196.                      }
  197.                }
  198.             }
  199.          }
  200.  
  201.          _count = 0;
  202.       }
  203.  
  204.       delay(500);
  205.    }
  206. }
  207.  
  208. // Internal function
  209. function NTLW_DrinkPotInt(type)
  210. {
  211. Reason ="Attempting to drink" +type;
  212.    var _pottype;
  213.    var _potion;
  214.    var _tNow = getTickCount();
  215.  
  216.    if(type == 2 || type == 4)
  217.    {
  218.    Reason ="timer check"+_NTLW_timerLastDrink[type] ;
  219.       if(_tNow-_NTLW_timerLastDrink[type] < 1000){
  220.          Reason ="Failed Drink Timer";
  221.          //print("last drink "+ _NTLW_timerLastDrink[type] + " Diff "+ (_tNow-_NTLW_timerLastDrink[type]) +" type " +type);
  222.          return false;
  223.       }
  224.    }
  225.    else
  226.    {
  227.       Reason ="timer check"+_NTLW_timerLastDrink[type] ;
  228.       if(_tNow-_NTLW_timerLastDrink[type] < 3000){
  229.          Reason ="Failed Drink Timer";
  230.          //print("last drink "+ _NTLW_timerLastDrink[type] + " Diff "+ (_tNow-_NTLW_timerLastDrink[type]) +" type " +type);
  231.          return false;
  232.       }
  233.    }
  234.    Reason ="after timer check";
  235.    switch(type)
  236.    {
  237.    case 0:
  238.    case 3:
  239.       _pottype = 76;      
  240.       break;
  241.    case 1:
  242.       _pottype = 77;
  243.       break;
  244.    default:
  245.       _pottype = 78;
  246.       break;
  247.    }
  248.    Reason ="Getting Pot type" +_pottype;
  249.    _potion = NTLW_GetPotionInt(_pottype);
  250.  
  251.    if(_potion)
  252.    {
  253.    Reason ="Found Pot";
  254.       if(me.mode == 0 || me.mode == 17 || me.mode == 18){
  255.          Reason ="bad Mode Failed";
  256.          return false;
  257.       }
  258.       if(type < 3)
  259.          _potion.interact();
  260.       else
  261.          clickItem(2, _potion);
  262.    
  263.       _NTLW_timerLastDrink[type] = getTickCount();
  264.       Reason ="Success";
  265.       return true;
  266.    }
  267.    Reason ="Failed to find pot";
  268.    return false;
  269. }
  270.  
  271. function NTLW_GetPotionInt(pottype)
  272. {
  273.    var _items = me.getItems();
  274.  
  275.    if(!_items)
  276.       return false;
  277.  
  278.    for(var i = 0 ; i < _items.length ; i++)
  279.    {
  280.       if(_items[i].mode == 2 && _items[i].itemType == pottype){
  281.          //print("pot Found");
  282.          return copyUnit(_items[i]);
  283.          }
  284.    }
  285.  
  286.    return false;
  287. }
  288. function LW_InTown(who)
  289. {
  290.    
  291.    var _area;
  292.  
  293.    if(arguments.length < 1)
  294.       who = myself;
  295.    _area = who.area;
  296.  
  297.    return (_area == NTC_AREA_ID_ACT_1 || _area == NTC_AREA_ID_ACT_2 || _area == NTC_AREA_ID_ACT_3 || _area == NTC_AREA_ID_ACT_4 || _area == NTC_AREA_ID_ACT_5);
  298. }