Author Topic: Building a Sub: Find and tag all NPCs in the local area  (Read 9482 times)

0 Members and 1 Guest are viewing this topic.

Offline NObamaTopic starter

  • Everything I need to know, I learned from Miffy's Item Finder.
  • Elite
  • *
  • *
  • Posts: 3454
  • Activity:
    0%
  • Reputation Power: 43
  • NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.
  • Respect: +161
  • Referrals: 2
    • View Profile
Building a Sub: Find and tag all NPCs in the local area
« on: March 22, 2010, 05:43:45 PM »
0
Salutations -

I'm toying with the idea of a sub that will do the following:

1) Scan a given radius and find all NPCs
2) Determine, via context menu, if each NPC is a vendor
3) Assign each vendor's unique ID to a %npc_id[num] variable.  For example, if there were 3 vendors, the variables would be
   - %npc_id1 XXXXX
   - %npc_id2 YYYYY
   - %npc_id3 ZZZZZ

The point of this sub is, of course, to abuse TM's item buying routines.

Basic structure would be something like this, I think:

Code: [Select]
scan tile radius 15 for type IS
determine if IS is yellow
Open context menu for yellow IS
   If context includes 'buy'
     assign ID to %npc_ id[#]
     increment %npc_id[#]
   ignore vendor

Eventually, it should also identify types of npc vendor (tailor, provisioner, mage, scribe, etc, etc).  

Is my approach logical, or do I need a different angle?  

 :)

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #1 on: March 22, 2010, 06:04:00 PM »
0
Your approach looks fine to me .. what do you need to index all vendors in this manner if you dont mind me asking
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline NObamaTopic starter

  • Everything I need to know, I learned from Miffy's Item Finder.
  • Elite
  • *
  • *
  • Posts: 3454
  • Activity:
    0%
  • Reputation Power: 43
  • NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.
  • Respect: +161
  • Referrals: 2
    • View Profile
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #2 on: March 22, 2010, 06:09:45 PM »
0
I'm automating item buying.  Basically, I want to fill a runebook with runes and just recall into a shop and auto-buy everything on my list from every NPC in the joint.

I hit my first snag.  I'm trying to build a set of conditions that will increment variable names, but I can't figure out the logical structure.

My intent is to do something like this:

Code: [Select]
sub Find_NPCs
set !npc_counter 1

  finditem IS G_15
    if #findkind = 1 && #findrep = 7
      set %npc_id[!npc_counter value] #findid
      set !npc_counter !npc_counter + 1
    ...etc

...but I don't know how to tell EUO to do that...

 ???

Scrripty

  • Guest
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #3 on: March 22, 2010, 08:29:29 PM »
0
I'm automating item buying.  Basically, I want to fill a runebook with runes and just recall into a shop and auto-buy everything on my list from every NPC in the joint.

I hit my first snag.  I'm trying to build a set of conditions that will increment variable names, but I can't figure out the logical structure.

My intent is to do something like this:

Code: [Select]
sub Find_NPCs
set !npc_counter 1
  finditem IS G_15
    if #findkind = 1 && #findrep = 7
      set %npc_id[!npc_counter value] #findid
      set !npc_counter !npc_counter + 1
    ...etc
...but I don't know how to tell EUO to do that...
 ???

Use a for loop to iterate through all within range and any that meet your criteria would get set to a variable name with a number applied.  But I would think you might want to add their vendor TYPE on there too... but do you need to go all that way?  Why not just recall in to where there's a bunch of vendors, set your search range, and have it buy everything from them?  That's what gen200's script does basically...  It will find any vendor and then buy from every one within range.

Offline BadManiac

  • Jr. Member
  • **
  • Posts: 61
  • Activity:
    0%
  • Reputation Power: 4
  • BadManiac has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #4 on: March 22, 2010, 09:47:49 PM »
0
probably easier to do with some string magic, or at least it's an alternative to OCR'ing the popup menu. Make a list of all vendor professions. Blah the Tinker, Blah the Tailor and so on, make a long list, tailor_tinker_blacksmith_provisioner_mage_scribe_...
Then read each NPC name, and either use STR functions to find each separate word from the list in the vendor name via for loop, or extract the vendors title from it's name. Should be pretty simple, find 'the' in the title, delete anything from the start of the name to the space after 'the', find the next space, delete everything including and after that space. Then you're left with a #STRRES containing the vendors profession. Then simply check IF #STRRES IN %longassvendorlist. If it is, it's a vendor and you can go shopping.

Either way works, but I avoid using OCR unless absolutely necessary so that's how I'd solve your problem.

As for your second question what you want is the DOT concatenation operator.
Code: [Select]
finditem HS_IS_XU_AV_GARGOYLES G_15
    if #findkind = 1 && #findrep = 7
      set %npc_id . !npc_counter #findid
      set !npc_counter !npc_counter + 1

Then you can go through the list:
Code: [Select]
FOR %i 1 !npc_counter
{
  SET !current_npc_id %npc_id . %i
  ;do things with !current_npc_id
}

Scrripty

  • Guest
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #5 on: March 22, 2010, 10:22:34 PM »
0
Make sure to ignore anything you find that doesn't meet your criteria too so you don't search it again while buying regs. :)

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #6 on: March 23, 2010, 05:48:18 AM »
0
Do as BM said.   But i would use an array of profession names.  That way dont have to pase the vendor profession but rather do

For !x 1 %TotalProfessions
  if %profession . !x  in Vendorname
      set Whaterver to somesomething

and second question  as BM siad use DOT .  operator

Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Scrripty

  • Guest
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #7 on: March 23, 2010, 08:03:24 AM »
0
Well as Twinkle McNugget said, and BM elaborated anyways... heh

Offline BadManiac

  • Jr. Member
  • **
  • Posts: 61
  • Activity:
    0%
  • Reputation Power: 4
  • BadManiac has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #8 on: March 23, 2010, 01:06:42 PM »
0
Yes Twinkle McNugget did say it. But Twinkle McNugget was so incredibly non specific and vague that I felt some clarification to what Twinkle McNugget had said was in order :P

Offline NObamaTopic starter

  • Everything I need to know, I learned from Miffy's Item Finder.
  • Elite
  • *
  • *
  • Posts: 3454
  • Activity:
    0%
  • Reputation Power: 43
  • NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.
  • Respect: +161
  • Referrals: 2
    • View Profile
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #9 on: March 23, 2010, 02:52:59 PM »
0
Yes Twinkle McNugget did say it. But Twinkle McNugget was so incredibly non specific and vague that I felt some clarification to what Twinkle McNugget had said was in order :P

I second that.  Twinkle McNugget forgets that I are a scriptingz newb.

Thanks everyone.  I will go learn more about arrays after I master the dot concatenation doo hickey.

 :)

Scrripty

  • Guest
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #10 on: March 23, 2010, 03:47:48 PM »
0
Yes Twinkle McNugget did say it. But Twinkle McNugget was so incredibly non specific and vague that I felt some clarification to what Twinkle McNugget had said was in order :P

I second that.  Twinkle McNugget forgets that I are a scriptingz newb.

Thanks everyone.  I will go learn more about arrays after I master the dot concatenation doo hickey.

 :)

I'm a scripting noob too.  Seriously...  I'm still learning new stuff every day.

Offline NObamaTopic starter

  • Everything I need to know, I learned from Miffy's Item Finder.
  • Elite
  • *
  • *
  • Posts: 3454
  • Activity:
    0%
  • Reputation Power: 43
  • NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.
  • Respect: +161
  • Referrals: 2
    • View Profile
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #11 on: March 23, 2010, 06:31:09 PM »
0
Alright - thanks to the expert tutelage above, I believe I have mastered the concept of DOT and also correctly applied EN's earlier lessons on REPEAT/UNTIL.

It correctly assigned variable names and values.  Anyone have any critique of this piece before I continue?

Code: [Select]
ignoreitem #charid
gosub Find_NPCs

sub Find_NPCs
set !npc_counter 1
finditem IS G_15
  set !Exit 10
  Repeat
     set !Exit !exit - 1
     {
     finditem IS G_15
       if #findkind = 1 && #findrep = 7
         {
         set %npc_id . !npc_counter #findid
         set !npc_counter !npc_counter + 1
         }
       ignoreitem #findid
     }
  Until #findkind = -1
halt

Victory comes in small slices for newbs.

 ;)

Offline BadManiac

  • Jr. Member
  • **
  • Posts: 61
  • Activity:
    0%
  • Reputation Power: 4
  • BadManiac has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #12 on: March 23, 2010, 06:41:10 PM »
0
I'd put the IGNOREITEM #CHARID in it's own ignorelist, and place it at the top of the sub, and then IGNOREITEM RESET that list before returning from the sub. Globally ignoring yourself can be a bad idea ;)

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #13 on: March 23, 2010, 07:04:15 PM »
0
I hardly ever find a need to use ignore item
In this case i would use a for loop like below.

Code: [Select]
sub Find_NPCs
  set !npc_counter 1
  finditem IS G_15
  If #findcnt > 0
    {
    For #findindex 1 #findnct
      {
      if #findkind = 1 && #findrep = 7
         {
         set %npc_id . !npc_counter #findid
         set !npc_counter !npc_counter + 1
          }
      }
    }
Return
« Last Edit: March 23, 2010, 08:24:42 PM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline NObamaTopic starter

  • Everything I need to know, I learned from Miffy's Item Finder.
  • Elite
  • *
  • *
  • Posts: 3454
  • Activity:
    0%
  • Reputation Power: 43
  • NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.
  • Respect: +161
  • Referrals: 2
    • View Profile
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #14 on: March 23, 2010, 07:47:44 PM »
0
NObama's Emerging Rules of Coding:

1. Whatever you write, Endless Night can do it better and with at least 12.5% fewer lines.


 :P

Tags: