Author Topic: Building a Sub: Find and tag all NPCs in the local area  (Read 9481 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
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #15 on: March 23, 2010, 07:48:25 PM »
0
Globally ignoring yourself can be a bad idea ;)

Tell me about it.  Chicks did it to me for years.

 ;)

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 #16 on: March 23, 2010, 08:52:51 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

LOL ...  your projects are defaintly getting more ambitious
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 #17 on: March 24, 2010, 01:26:47 PM »
0
Can someone point me to a tutorial on arrays or a good example of a script that effectively uses an array?  There is no discussion of them on EUO's wiki as far as I've been able to find.

I really need the array to help me ignore the NPCs that are yellow that don't actually sell anything...


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 #18 on: March 24, 2010, 01:44:02 PM »
0
Tm i belive has some array subs on these boards some place

Arrays and how to make them in EUO

1 dimensional array  Var[x= 1.....]
set %MYArray . !CountX  !Value
 
2 dimensional array  var[x,y]
set %MYArrayVarNAme %MyArray , !CountX , _ , !CountY
set % . %MyArrayVarName !Value
(eg %Myarray1_1 )

3 dimensional array  var[x,y,z]
set %MYArrayVarNAme %MyArray , !CountX , _ , !CountY , _ , !CountZ
set % . %MyArrayVarName !Value
(eg %Myarray1_1_1 )

4 dimensional array  var[A,b,c,d]etc
set %MYArrayVarNAme %MyArray , !CountA , _ , !CountB , _ , !CountC , _ , !CountD
set % . %MyArrayVarName !Value
(eg %Myarray1_1_1_1 )


In your case you probably just need a One Dimensional Array  (you have already used them with my MiniRail system you just might not have realised - Every time you add a way point you add a record to 3 one dimensional arrarys  x[], y[], z[])




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 #19 on: March 24, 2010, 01:48:48 PM »
0
Ahhhh...that helps put them in perspective.

I really only need a one dimensional array.  I'm looking to do:

if X in #property
ignore id


Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #20 on: March 24, 2010, 01:50:52 PM »
0
Please read the ScriptUO site RULES
Come play RIFT with me!

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 #21 on: March 24, 2010, 02:08:45 PM »
0
Heh - that thread is only somewhat less arcane to me as when I first commented on it...=P

Codingz is hard

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 #22 on: March 24, 2010, 02:58:26 PM »
0
Okay - I'm stripping this down to components to try and solve it one piece at a time.

This definitely works to establish the bad NPC names:

Code: [Select]
goSub Setup_Ignore_NPC_Type_Values
halt
;--------------------------------------------------------------
Sub Setup_Ignore_NPC_Type_Values
  gosub Add_Ignore_NPC_Type guildmaster
  gosub Add_Ignore_NPC_Type banker
  gosub Add_Ignore_NPC_Type minter
Return
;--------------------------------------------------------------
Sub Add_Ignore_NPC_Type
  if %Ignore_NPC_Type_Max = N/A
     set %Ignore_NPC_Type_Max 0
  set %Ignore_NPC_Type_Max %Ignore_NPC_Type_Max + 1
  set %Ignore_NPC_Type_Max . %Ignore_NPC_Type_Max %1
Return
;--------------------------------------------------------------

Var Dump yields:
%IGNORE_NPC_TYPE_MAX: 3
%IGNORE_NPC_TYPE_MAX1: guildmaster
%IGNORE_NPC_TYPE_MAX2: banker
%IGNORE_NPC_TYPE_MAX3: minter

I still don't get why I have to have "MAX" in there, so if someone could educate me...

Now, I just need to apply the array values in a loop...

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 #23 on: March 24, 2010, 03:20:39 PM »
0
Ok - someone check my logic and tell me if I'm using #result correctly:

Given the following sub:

Code: [Select]
;--------------------------------------------------------------
sub Ignore_NPC_Types

set !loopvalue 1
  If %Ignore_NPC_TYPE_Max = N/A
    gosub Setup_Ignore_NPC_Type_Values
Repeat
  set #result true
  if %Ignore_NPC_TYPE_Max . !loopvalue notin #property
    {
    set #result false
    }
  set !loopvalue !loopvalue + 1
Until !loopvalue >= %Ignore_NPC_Type_Max
return #result
;--------------------------------------------------------------

Would this code execute the way I intend?

Code: [Select]
        if #result = false
           {
           set %npc_id . !npc_counter #findid
           set !npc_counter !npc_counter + 1
           set %npc_max !npc_counter
           }

I actually think I'm close to cracking this...

Scrripty

  • Guest
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #24 on: March 24, 2010, 03:25:21 PM »
0
Why does this need to be so difficult?  There's not that many npcs that need to be ignored...

Code: [Select]
     if hairstylist in #property || sculptor in #property || Noble in #property || mage in #property || bride in #property || miner in #property || fighter in #property || peasant in #property || messenger in #property || guard in #property || adventure in #property || artist in #property || bard in #property || thief in #property || actor in #property || impresario in #property || beggar in #property || gypsy in #property || mondain in #property || breeder in #property
        ignoreitem #findid

Done.

Yes there's more, but they are easy to find.  Make a list menu script that adds any #findrep invulnerable npcs to the list and you can just run around a big town like brit and get them all.  Then add them to the list.  It's fast to read the line and if it gets too long, you can use the + thingy to add to it on another line...
« Last Edit: March 24, 2010, 03:27:27 PM by Scripty »

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 #25 on: March 24, 2010, 03:32:46 PM »
0
I could take the moral high ground here and claim that I was trying to better my coding skills...but the truth is that I just didn't think of doing it that way.

The good news is, I think I learned how to do this with an array.

I think this is a working version...

Code: [Select]
goSub Setup_Ignore_NPC_Type_Values
gosub Find_NPCs
;--------------------------------------------------------------
sub Find_NPCs
set !npc_counter 1
finditem IS G_30
  set !Exit 10
  Repeat
     set !Exit !exit - 1
     {
     finditem IS G_15
       if #findkind = 1 && #findrep = 7
         {
         event Property #findid
         gosub Ignore_NPC_Types
         if #result = false
           {
           set %npc_id . !npc_counter #findid
           set !npc_counter !npc_counter + 1
           set %npc_max !npc_counter
           }
         }
         ignoreitem #findid
  Until #findkind = -1
return
;--------------------------------------------------------------
sub Ignore_NPC_Types

set !loopvalue 1
  If %Ignore_NPC_TYPE_Max = N/A
    gosub Setup_Ignore_NPC_Type_Values
Repeat
  set #result true
  if %Ignore_NPC_TYPE_Max . !loopvalue notin #property
    {
    set #result false
    }
  set !loopvalue !loopvalue + 1
Until !loopvalue >= %Ignore_NPC_Type_Max
return #result
;--------------------------------------------------------------
Sub Setup_Ignore_NPC_Type_Values
  gosub Add_Ignore_NPC_Type guildmaster
  gosub Add_Ignore_NPC_Type banker
  gosub Add_Ignore_NPC_Type minter
Return
;--------------------------------------------------------------
Sub Add_Ignore_NPC_Type
  if %Ignore_NPC_Type_Max = N/A
     set %Ignore_NPC_Type_Max 0
  set %Ignore_NPC_Type_Max %Ignore_NPC_Type_Max + 1
  set %Ignore_NPC_Type_Max . %Ignore_NPC_Type_Max %1
Return
;--------------------------------------------------------------

Var Dump:
%NPC_ID1: BVKLCC
%NPC_ID10: SWSMM
%NPC_ID2: JQNXXB
%NPC_ID3: QNLOM
%NPC_ID4: HAIOM
%NPC_ID5: BCPNM
%NPC_ID6: ZEPNM
%NPC_ID7: XMHNM
%NPC_ID8: KJHNM
%NPC_ID9: HYUMM

Booyah. 

 8)
« Last Edit: March 24, 2010, 03:41:08 PM by NObama »

Scrripty

  • Guest
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #26 on: March 24, 2010, 04:08:21 PM »
0
You still need a type LIST correct?  So you're still doing what I just did there... just in a more complex way.  As EN would say about now:  KISS.  Keep it simple stupid. :)

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 #27 on: March 24, 2010, 04:52:48 PM »
0
Ok - the six-letter NPC IDs above are guildmasters and guildmistresses.  Any idea why this code is excluded everything on the list properly except those two words?

;--------------------------------------------------------------
Sub Setup_Ignore_NPC_Type_Values
  gosub Add_Ignore_NPC_Type guildmaster
  gosub Add_Ignore_NPC_Type guildmistress
  gosub Add_Ignore_NPC_Type banker
  gosub Add_Ignore_NPC_Type minter
  gosub Add_Ignore_NPC_Type trainer

Return
;--------------------------------------------------------------

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 #28 on: March 24, 2010, 05:14:33 PM »
0
Whoops.  Found my problem.  A wee tiny logical error.  Working sub below:

Code: [Select]
ignoreitem #charid
goSub Setup_Ignore_NPC_Type_Values
gosub Find_NPCs
event exmsg #charid 3 0 done$
halt
;--------------------------------------------------------------
sub Find_NPCs
set !npc_counter 1
finditem HS_IS G_15
  set !Exit 10
  Repeat
     set !Exit !exit - 1
     {
     finditem HS_IS G_15
       if #findkind = 1 && #findrep = 7
         {
         event Property #findid
         gosub Ignore_NPC_Types
         if #result = false
           {
           set %npc_id . !npc_counter #findid
           set !npc_counter !npc_counter + 1
           set %npc_max !npc_counter
           event exmsg #charid 3 0 adding #property $
           }
         }
         ignoreitem #findid
  Until #findkind = -1
return
;--------------------------------------------------------------
sub Ignore_NPC_Types

set !loopvalue 1
  If %Ignore_NPC_TYPE_Max = N/A
    gosub Setup_Ignore_NPC_Type_Values
Repeat
  set #result true
  if %Ignore_NPC_TYPE_Max . !loopvalue notin #property
    {
    event exmsg #charid 3 0 not %Ignore_NPC_TYPE_Max . !loopvalue
    set #result false
    }
  if %Ignore_NPC_TYPE_Max . !loopvalue in #property
    event exmsg #charid 3 0 matches %Ignore_NPC_TYPE_Max . !loopvalue
  set !loopvalue !loopvalue + 1
  if #result = true
    {
    event exmsg #charid 3 0 IGNORING NPC!
    return
    }
Until !loopvalue >= %Ignore_NPC_Type_Max
return #result
;--------------------------------------------------------------
Sub Setup_Ignore_NPC_Type_Values
  gosub Add_Ignore_NPC_Type guildmaster
  gosub Add_Ignore_NPC_Type guildmistress
  gosub Add_Ignore_NPC_Type banker
  gosub Add_Ignore_NPC_Type minter
  gosub Add_Ignore_NPC_Type trainer
  gosub Add_Ignore_NPC_Type vet
Return
;--------------------------------------------------------------
Sub Add_Ignore_NPC_Type
  if %Ignore_NPC_Type_Max = N/A
     set %Ignore_NPC_Type_Max 0
  set %Ignore_NPC_Type_Max %Ignore_NPC_Type_Max + 1
  set %Ignore_NPC_Type_Max . %Ignore_NPC_Type_Max %1
Return
;--------------------------------------------------------------

Gosh, this is a rush.

 :)

Offline rana70

  • Elite
  • *
  • *
  • Posts: 294
  • Activity:
    0%
  • Reputation Power: 5
  • rana70 has no influence.
  • Gender: Male
  • Respect: +37
  • Referrals: 2
    • View Profile
    • MyScripts
Re: Building a Sub: Find and tag all NPCs in the local area
« Reply #29 on: March 26, 2010, 10:39:40 AM »
0
Hi,

just in case you are too lazy to search :-)

Code: [Select]
     if #FindType in HS_IS
      Set %RACE HUMAN
     if #FindType in XU_AV
      Set %RACE ELF
     if  #FindType in OCB_NCB
      Set %RACE GARGOYLE


 :D

Tags: