Page 1 of 2

shopper.iss

Posted: Mon Apr 25, 2005 7:59 pm
by onetimehero
Script for checking vendors for items.
Needs INI support, etc,bla,bla,bla.

Nice thing about IS, you can leave it running while running other scripts =)

Code: Select all


function main()
{
  declare shouldcheck int global 0
  declare MerchantOpened bool script false
  declare vmItemCount int script 9
  declare vmItemArray[9] string script

  varset vmItemArray[1] Incorporeal
  varset vmItemArray[2] Acquisition
  varset vmItemArray[3] Purification
  varset vmItemArray[4] Dark Path
  varset vmItemArray[5] Haunting
  varset vmItemArray[6] Annihil
  varset vmItemArray[7] Eventide
  varset vmItemArray[8] Black Sapphire

  AddTrigger MerchantOffer "@merch@ says 'Welcome to my shop, %${Me.Name}%. You would probably find a @item@ handy.'"
  AddTrigger MerchantOffer "@merch@ says 'Hello there, %${Me.Name}%. How about a nice @item@?'"
  AddTrigger MerchantOffer "@merch@ says 'Welcome to my shop, %${Me.Name}%.'"
  AddTrigger MerchantOffer "@merch@ says 'Greetings, %${Me.Name}%. You look like you could use a @item@.'"
  AddTrigger MerchantOffer "@merch@ says 'Hi there %${Me.Name}%, just browsing?  Have you seen the @item@ I just got in?'"

  do 
  {
    if ${Merchant.Open}
    {
      if ${shouldcheck}
      {
        varset shouldcheck 0
        do
        {
          if "${QueuedCommands}"
          {
            echo executing queued commands
            ExecuteQueued
          }
          WaitFrame
        }
        while "!${MerchantOpened}"
        FlushQueued
        call shopper
        varset MerchantOpened false
      }
      WaitFrame
    }
    else
    {
      if "!${shouldcheck}"
      {
        echo resetting shouldCheck variable
        varset shouldcheck 1
      }
;     echo Waiting 10 seconds for Merchant open
      wait 100 ${Merchant.Open}
    }
  }
  while "1"
}

function shopper()
{
  declare merchTotal int local 0
  declare slot int local
  declare vmCur int local
  varcalc merchTotal ${Merchant.Items}+1
  
  varset slot 1
  do
  {
    varset vmCur 1
    do
    {
      if (${Merchant.Item[${slot}].Name.Find[${vmItemArray[${vmCur}]}]}) 
        echo Found ${Merchant.Item[${slot}].Name} in slot ${slot} on ${Merchant.DisplayName}
      varcalc vmCur ${vmCur}+1
    }
    while "${vmCur}<${vmItemCount}"
    varcalc slot ${slot}+1
  } 
  while "${slot}<${merchTotal}"
;  echo Finished checking ${Merchant.DisplayName}
}  

function MerchantOffer(string all, string who, string item)
{
;  echo MerchantOffer called for ${who}
  varset MerchantOpened true 
}

Posted: Sat Jul 29, 2006 1:59 am
by Kroak
Tinkered with this just for the heck of it. Got it working. Was a ways off how it was.
Make sure to set the names in the vmItemArray variables to what you're looking for.

Code: Select all

function main() 
{ 
  declare shouldcheck int global 1
  declare MerchantOpened bool script FALSE 
  declare vmItemCount int script 9 
  declare vmItemArray[9] string script 

  vmItemArray[1]:Set[Incorporeal] 
  vmItemArray[2]:Set[Acquisition] 
  vmItemArray[3]:Set[Purification] 
  vmItemArray[4]:Set[Dark Path] 
  vmItemArray[5]:Set[Haunting] 
  vmItemArray[6]:Set[Annihil] 
  vmItemArray[7]:Set[Eventide] 
  vmItemArray[8]:Set[Words of]
  vmItemArray[9]:Set[Alteration]

  AddTrigger MerchantOffer "@merch@ says 'Welcome to my shop, %${Me.Name}%. You would probably find a @item@ handy.'" 
  AddTrigger MerchantOffer "@merch@ says 'Hello there, %${Me.Name}%. How about a nice @item@?'" 
  AddTrigger MerchantOffer "@merch@ says 'Welcome to my shop, %${Me.Name}%.'" 
  AddTrigger MerchantOffer "@merch@ says 'Greetings, %${Me.Name}%. You look like you could use a @item@.'" 
  AddTrigger MerchantOffer "@merch@ says 'Hi there %${Me.Name}%, just browsing?  Have you seen the @item@ I just got in?'" 

  do 
  { 
;    echo Shopper engaged.
		if !${Window[MerchantWnd].Open}
			MerchantOpened:Set[FALSE]
    if ${Window[MerchantWnd].Open}
    { 
;    	echo Merchant Window opened.
      if ${shouldcheck}
      { 
        shouldcheck:Set[0] 
        if !${MerchantOpened}
	        {
	        if ${QueuedCommands}
	 	        { 
		          echo executing queued commands 
	  	        ExecuteQueued 
		        } 
	 	       echo Small delay
	 	       Wait 35
	 	       call shopper
	 	       MerchantOpened:Set[TRUE] 
 		       FlushQueued 
 		      }
      } 
      Wait 1
    } 
    else
    { 
      if !${shouldcheck} 
      { 
        echo resetting shouldCheck variable 
        shouldcheck:Set[1] 
      } 
;      echo Waiting 10 seconds for Merchant open 
      wait 100 ${Window[MerchantWnd].Open} 
    } 
  } 
  while 1
} 

function shopper() 
{ 
  declare merchTotal int local 0 
  declare slot int local 
  declare vmCur int local 
  merchTotal:Set[${Math.Calc["${Merchant.Items}+1"]}] 
;  echo Checking Items.
  slot:Set[1] 
  while "${slot}<${merchTotal}"
  { 
    vmCur:Set[1] 
    while "${vmCur}<${vmItemCount}"
    { 
      if (${Merchant.Item[${slot}].Name.Find[${vmItemArray[${vmCur}]}]}) 
        echo Found ${Merchant.Item[${slot}].Name} in slot ${slot} on ${Spawn[Merchant].CleanName} 
      vmCur:Inc
    } 
   slot:Inc 
  } 
   
echo Finished checking ${Spawn[Merchant].CleanName} 
MerchantOpened:Set[TRUE]
}  

function MerchantOffer(string all, string who, string item) 
{ 
  echo MerchantOffer called for ${who} 
  MerchantOpened:Set[TRUE] 
} 

Posted: Wed Sep 06, 2006 1:42 am
by mekaniak
Just found this today and I am wondering if it still work right and I just messsed something up.

Code: Select all

function main()
{
  declare shouldcheck int global 1
  declare MerchantOpened bool script FALSE
  declare vmItemCount int script 9
  declare vmItemArray[4] string script

  vmItemArray[1]:Set[Large Groove Knocks]
  vmItemArray[2]:Set[Field Point Arrowheads]
  vmItemArray[3]:Set[Bundled Wooden Arrow Shafts]
  vmItemArray[4]:Set[Several Round Cut Fletchings]

  AddTrigger MerchantOffer "@merch@ says 'Welcome to my shop, %${Me.Name}%. You would probably find a @item@ handy.'"
  AddTrigger MerchantOffer "@merch@ says 'Hello there, %${Me.Name}%. How about a nice @item@?'"
  AddTrigger MerchantOffer "@merch@ says 'Welcome to my shop, %${Me.Name}%.'"
  AddTrigger MerchantOffer "@merch@ says 'Greetings, %${Me.Name}%. You look like you could use a @item@.'"
  AddTrigger MerchantOffer "@merch@ says 'Hi there %${Me.Name}%, just browsing?  Have you seen the @item@ I just got in?'"

  do
  {
;    echo Shopper engaged.
      if !${Window[MerchantWnd].Open}
         MerchantOpened:Set[FALSE]
    if ${Window[MerchantWnd].Open}
    {
;       echo Merchant Window opened.
      if ${shouldcheck}
      {
        shouldcheck:Set[0]
        if !${MerchantOpened}
           {
           if ${QueuedCommands}
               {
                echo executing queued commands
                ExecuteQueued
              }
              echo Small delay
              Wait 35
              call shopper
              MerchantOpened:Set[TRUE]
              FlushQueued
             }
      }
      Wait 1
    }
    else
    {
      if !${shouldcheck}
      {
        echo resetting shouldCheck variable
        shouldcheck:Set[1]
      }
;      echo Waiting 10 seconds for Merchant open
      wait 100 ${Window[MerchantWnd].Open}
    }
  }
  while 1
}

function shopper()
{
  declare merchTotal int local 0
  declare slot int local
  declare vmCur int local
  merchTotal:Set[${Math.Calc["${Merchant.Items}+1"]}]
;  echo Checking Items.
  slot:Set[1]
  while "${slot}<${merchTotal}"
  {
    vmCur:Set[1]
    while "${vmCur}<${vmItemCount}"
    {
      if (${Merchant.Item[${slot}].Name.Find[${vmItemArray[${vmCur}]}]})
        echo Found ${Merchant.Item[${slot}].Name} in slot ${slot} on ${Spawn[Merchant].CleanName}
      vmCur:Inc
    }
   slot:Inc
  }
   
echo Finished checking ${Spawn[Merchant].CleanName}
MerchantOpened:Set[TRUE]
} 

function MerchantOffer(string all, string who, string item)
{
  echo MerchantOffer called for ${who}
  MerchantOpened:Set[TRUE]
} 
Thats what I have and on load I get this "error", which the script still runs.

Code: Select all

Unparsable in calculation at : "'
EDIT: Thought I fixed it when I changed the "declare vmItemCount int script 9" from 9 to 4, but then I ran it again and it only searched for 2 items :-( Oh well I try more tomorrow.

Re: shopper.iss

Posted: Sun May 11, 2025 9:07 pm
by xyilla

Re: shopper.iss

Posted: Sun May 11, 2025 9:08 pm
by xyilla

Re: shopper.iss

Posted: Sun May 11, 2025 9:45 pm
by xyilla

Re: shopper.iss

Posted: Sun May 11, 2025 9:46 pm
by xyilla

Re: shopper.iss

Posted: Sun May 11, 2025 10:23 pm
by xyilla

Re: shopper.iss

Posted: Sun May 11, 2025 10:24 pm
by xyilla

Re: shopper.iss

Posted: Sun May 11, 2025 10:25 pm
by xyilla

Re: shopper.iss

Posted: Mon May 12, 2025 12:15 am
by xyilla

Re: shopper.iss

Posted: Mon May 12, 2025 12:16 am
by xyilla

Re: shopper.iss

Posted: Mon May 12, 2025 12:17 am
by xyilla

Re: shopper.iss

Posted: Mon May 12, 2025 12:18 am
by xyilla

Re: shopper.iss

Posted: Mon May 12, 2025 12:55 am
by xyilla