Blizzhackers

Return of the Jedi

* Login   * Register    * FAQ    * Search

Join us on IRC: #bh@irc.synirc.net (or Mibbit Web IRC)


MuleFactory


It is currently Sun May 19, 2013 12:51 am


All times are UTC [ DST ]





Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: [Dev] Do Boss by Key Count
PostPosted: Sat Jan 07, 2012 6:35 pm 
 
User
User

Joined: Sat Jan 07, 2012 2:24 am
I have searched through many scripts and posts and cannot seem to find a method to obtain the Count of an item. If anyone could help me with this please.

Top
 Profile  
 Post subject: Re: [Dev] Do Boss by Key Count
PostPosted: Sat Jan 07, 2012 9:52 pm 
 
User
User

Joined: Fri Jun 17, 2011 8:40 pm
can you be more specific? there are ofc ways of checking what items you have and how many but
i'm not exactly sure what you're trying to do

Top
 Profile  
 Post subject: Re: [Dev] Do Boss by Key Count
PostPosted: Sat Jan 07, 2012 9:52 pm 
 
User
User
User avatar

Joined: Sun Jul 12, 2009 6:00 pm
key of destruction: a little search tells us its classid is 649

Method 1: me.getItem(id) returns a reference to an item, much like getUnit

var item = me.getItem(649), count = 0;

if (item) {
  do {
    count += 1;
  } while (item.getNext());
}

print(count);


Method 2: me.getItems() returns an array of all our items

var i, items = me.getItems(), count = 0;

if (items && items.length > 0) {
  for (i = 0; i < items.length; i += 1) {
    if (items[i].classid === 649) {
      count += 1;
    }
  }
}

print(count);

_________________
Image


Top
 Profile  
 Post subject: Re: [Dev] Do Boss by Key Count
PostPosted: Sun Jan 08, 2012 1:10 am 
 
User
User

Joined: Sat Jan 07, 2012 2:24 am
Thank you very much, I am modifying the SuperUnique bot to disable each Key Boss based on the count of keys. Will post back when i'm done :-D.

I have completed it, testing it now:

function CheckKeys()
{
    var tKeys = 0;
   var dKeys = 0;
   var hKeys = 0;
   var i, items = me.getItems();
   
   if (items && items.length > 0)
   {
      for (i = 0; i < items.length; i += 1)
      {
         -- 647      Key Of Terror // Countress
         -- 648      Key Of Hate // Summoner
         -- 649      Key Of Destruction // Nith
         if (items[i].classid === 649)
         {
            dKeys += 1;
         }
         if (items[i].classid === 647)
         {
            tKeys += 1;
         }
         if (items[i].classid === 648)
         {
            hKeys += 1;
         }
      }
   }
   
   if (tKeys > 3)
   {
      NTConfig_SuperCountess = false;   
   }
   else
   {
      NTConfig_SuperCountess = true;   
   }
   
   if (dKeys > 3)
   {
      NTConfig_SuperNihlathak = false;
   }
   else
   {
      NTConfig_SuperNihlathak = true;
   }
   
   if (hKeys > 3)
   {
      NTConfig_SuperSummoner = false;
   }
   else
   {
      NTConfig_SuperSummoner = true;
   }
}

Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron