Author Topic: Dealing with NCP vendors...  (Read 3452 times)

0 Members and 1 Guest are viewing this topic.

Offline OMGBurgersTopic starter

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Dealing with NCP vendors...
« on: January 15, 2009, 04:36:51 PM »
0
I'm working on my shopper vendor and I'm having problems scrolling through the shop list to find the items I want to buy.  Randomly usually every other click on the down arrow than highlighting an item and using the getshopinfo or whatever command sometimes adds the item to my buy list.  Then I have to make it click the minus to get rid of it.

Anyone have any stable sample code I can compare mine to?  this is what I got atm.

Code: [Select]
set #RESULT
repeat
   {
   gosub TM_HandleContextMenu %currentnpc %CONTEXT_Buy #TRUE
   gosub contwait bill_gump 283_248 30
   }
until #RESULT = CONTINUE
getshopinfo
set %vendorstatus EMPTY
for %a 1 #SHOPCNT
   {
   gosub clickmod -42 -137
   click %x %y f ;click top item in list
   wait 2
   getshopinfo
   if #shopitemtype = DPF
      {
      click %x %y d
      wait 10
      set %amount 1600 - %beetleweight
      if #shopitemmax > %amount
         {
         setShopItem #shopItemID %amount
         set %vendorstatus STOCKED
         }
      else
         {
         setShopItem #shopItemID #shopItemMax
         set %vendorstatus EMPTY
         }
      wait 10
      gosub clickmod 47 208
      click %x %y f ;click the accept button
      wait 2s
      break
      }
   gosub clickmod 73 -17
   click %x %y f ;click down arrow
   wait 2
   gosub clickmod 228 86
   click %x %y f ;click minus arrow
   wait 2
   }
return %vendorstatus

Offline Cerveza

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Dealing with NCP vendors...
« Reply #1 on: January 15, 2009, 04:58:53 PM »
0
Maybe play with this?

Code: [Select]
sub buy ; <vendorid/s> <itemtype> <maxprice> <popup option#> <# of items>
{
   set %vendor_empty #false
   NAMESPACE PUSH
   NAMESPACE LOCAL buy
   set !_vendors %1
   set !_itemtype %2
   set !_maxprice %3
   set !_popup_option %4
   set !_amount %5
   set !_popup_y !_popup_option * 20
   set ! !_lastitemtype
   finditem !_itemtype C_ , #backpackid
   set !_item_bp_stack #findstack
   set !_item_bp_cnt #findcnt

   sub_buy_again:
   finditem !_vendors G_8
   if #findkind <> -1
   {
      open_context:
      set !_vendor #findid
      exevent popup !_vendor
      wait 10
      click 20 !_popup_y
      set %maxwait #scnt + 60
      while #contname <> bill_gump || #contsize <> 283_248
      {
         wait 5
         if #scnt >= %maxwait
            goto open_context
      }
      wait 20
      scroll_one_down:
      gosub pause
      getshopinfo
      if #shopitemtype <> !_itemtype
      {
         if !_lastitemtype <> #shopitemtype
            set !_lastitemtype #shopitemtype
         else
         {
            set !_x #contposx + 73
            set !_y #contposy - 16
            click !_x !_y r
            NAMESPACE POP
            NAMESPACE CLEAR
            return #false
         }
         sleep 0
         set !_x #contposx + 73
         set !_y #contposy - 16
         click !_x !_y
         sleep 0
         goto scroll_one_down
      }
      if #shopitemprice <= !_maxprice
      {
         wait 20
         set !_x #contposx - 33
         set !_y #contposy - 128
         click !_x !_y
         wait 10
         click !_x !_y x 3
         wait 10
         click !_x !_y x 3
         wait 5
         if !_amount > #shopitemmax
         {
            set !_amount #shopitemmax
            set %vendor_empty #true
         }
         setshopitem #shopitemid !_amount
         wait 5
         set !_x !_x + 75
         set !_y !_y + 335
         click !_x !_y
         wait 2s
         finditem !_itemtype C_ , #backpackid
         if #findstack = !_item_bp_stack && #findcnt = !_item_bp_cnt
            goto sub_buy_again

         NAMESPACE POP
         NAMESPACE CLEAR
         return #true
      }
      else
   }
click !_x !_y r
NAMESPACE POP
NAMESPACE CLEAR
return #false
}
Maybe give you ideas about stepping down the list.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline OMGBurgersTopic starter

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: Dealing with NCP vendors...
« Reply #2 on: January 15, 2009, 05:11:03 PM »
0
Well I fixed it.  I haven't messed with NPC buy/sell gumps in a long time and i thought I had to highlight the top item for getshopinfo to work, but you don't.  So I took 2 unneeded clicks out and it works like a charm.  I should have tried more with it before I got too confused haha.

Offline Khameleon

  • Script Tester - Team Leader
  • Elite
  • *
  • *
  • Posts: 2574
  • Activity:
    0%
  • Reputation Power: 30
  • Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!
  • Gender: Male
  • Respect: +238
  • Referrals: 0
    • View Profile
Re: Dealing with NCP vendors...
« Reply #3 on: January 16, 2009, 01:28:53 AM »
0
awesome, I can't wait for this to hit Beta phase.

Offline OMGBurgersTopic starter

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: Dealing with NCP vendors...
« Reply #4 on: January 16, 2009, 11:19:28 AM »
0
I collected about 200k blank scrolls last night with it.  Right now it's just hard coded for blank scrolls.  Now I'm going to train inscribe enough to make spellbooks then run a script to make me slayers.  While that's running I'm going to try to become unconfused and start modifying it to work with the main shopper script lol.

Right now it works pretty damn good.  I'm very satisified with it.  I've been brainstorming how to deal with the stone issue but I think it's pretty easy.  I'll just have one stone equal a value of 10 or something.  That way a reagent that is like a tenth of a stone lets say, will equal a 1 value.  Should be simple enough.

I added a few lines to TM's recall subs that checks if the rune was able to be defaulted.  If it tried to default an empty position it returns an error and then considers that runebook empty.  Working pretty well and it allows me to keep my trammel/felucca runes in seperate books.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • 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: Dealing with NCP vendors...
« Reply #5 on: January 16, 2009, 11:25:55 AM »
0
If your changes are relatively generic, I can include them into the next release of the runebook subs with your OK.  Lemme know if that'll work.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Khameleon

  • Script Tester - Team Leader
  • Elite
  • *
  • *
  • Posts: 2574
  • Activity:
    0%
  • Reputation Power: 30
  • Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!
  • Gender: Male
  • Respect: +238
  • Referrals: 0
    • View Profile
Re: Dealing with NCP vendors...
« Reply #6 on: January 17, 2009, 06:24:21 PM »
0
well, blank scrolls are an item on my list to start buying up.

I need to start working on my whammy so I can start collecting dread manes.  I finally got my scrappers scroll and I just completed my 120 magery.

Tags: