Author Topic: Escort Script Problems (FIXED)  (Read 3214 times)

0 Members and 1 Guest are viewing this topic.

Offline delchiTopic starter

  • Newbie
  • *
  • Posts: 4
  • Activity:
    0%
  • Reputation Power: 1
  • delchi has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Escort Script Problems (FIXED)
« on: April 08, 2014, 09:16:24 AM »
0
This should be a simple script but I am having issues with it. Basically it fails to find some of the NPCs that I am looking for via the event property #FINDID.

Another problem that I had, which I fixed with a workaround... After the sub to gate, the script would jump back up to sub search and sub search would not return to where it was called, instead it returned to sub main. To fix this I added goto sub search at the end of sub gate.

Thank you for any and all help!

(The runebook methodology is not my script and I gave the original author credit)

The part of the script that I think is broken:
Code: [Select]
sub search
rescan:
     onhotkey f2
          gosub destination
     FINDITEM %npc G_10
      IF #FINDCNT > 0
     {
          EVENT PROPERTY #FINDID
          IF Messenger in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 Messenger
               }
               wait 10
               ignoreitem #FINDID
               return
          }
          EVENT PROPERTY #FINDID
          IF Mage in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 Mage
               }
               wait 10
               ignoreitem #FINDID
               return
          }
          IF Peasant in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 Peasant
               }
               wait 10
               ignoreitem #FINDID
               return
          }

          IF Merchant in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 Merchant
               }
               wait 10
               ignoreitem #FINDID
               return
          }
          IF Noble in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 Noble
               }
               wait 10
               ignoreitem #FINDID
               return
          }
          IF Healer in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 Healer
               }
               wait 10
               ignoreitem #FINDID
               return
          }
          IF peasant in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 peasant
               }
               wait 10
               ignoreitem #FINDID
               return
          }

          
          IGNOREITEM #FINDID
     }
goto rescan
return


THE ENTIRE SCRIPT

Code: [Select]
; Escorting 2.0
;brit
set %b 1
;cove
set %c 2
;jhelom
set %j 3
;minoc
set %m 4
;glow
set %g 5
;serp
set %sh 6
;skara
set %s 7
;trin
set %t 8
;vesp
set %v 9
;yew
set %y 10
;ocllo
set %o 11
;nujelm
set %n 12
;bucs
set %buc 13
;magin
set %mag 14
;dungeon
set %d 15
SET %jewels HVF_UVF_FVF_EVF_OVF_VUF_GVF_RVF_BVF_VVF_NVF_ZVF_
set %loot_table HPF_RGH_CHH_RNH_IZF_ATG_NSG_NFF_KUF_JUF_RZF_JZF_MZF_WZF_KZF_SZF_HPE_FPE_CPE_IPE_POF_
set %loot_table %loot_table , %jewels
SET %npc HS_IS
set #lpc 10000
ignoreitem #CHARID
EVENT SYSMESSAGE Runebook
SET #TARGCURS 1
WHILE #TARGCURS = 1
      WAIT 5
Set %book #ltargetid

gosub main

sub main
loop:
onhotkey f1
gosub search
onhotkey f2
gosub destination
onhotkey f3
{
msg $
event macro 4 4 bank
}
onhotkey f4
gosub tele
onhotkey f5
gosub loot
goto loop
return

sub tele
set #targcurs 1
while #targcurs = 1
wait 20
set %box #ltargetid
event macro 15 22
target
set #ltargetkind 1
event macro 22 0
wait 1s
event macro 15 20
target
set #ltargetkind 1
event macro 22 0
return

sub loot
finditem %box G_1
set #lobjectid %box
event macro 17 0
wait 1s
finditem %loot_table C_ , %box
for %i 0 #FINDCNT
{
finditem %loot_table C_ , #ltargetid
    exevent drag #FINDid #findstack
wait 25
Exevent Dropc #backpackid
wait 25
}
return



sub search
rescan:
     onhotkey f2
          gosub destination
     FINDITEM %npc G_10
      IF #FINDCNT > 0
     {
          EVENT PROPERTY #FINDID
          IF Messenger in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 Messenger
               }
               wait 10
               ignoreitem #FINDID
               return
          }
          EVENT PROPERTY #FINDID
          IF Mage in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 Mage
               }
               wait 10
               ignoreitem #FINDID
               return
          }
          IF Peasant in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 Peasant
               }
               wait 10
               ignoreitem #FINDID
               return
          }

          IF Merchant in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 Merchant
               }
               wait 10
               ignoreitem #FINDID
               return
          }
          IF Noble in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 Noble
               }
               wait 10
               ignoreitem #FINDID
               return
          }
          IF Healer in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 Healer
               }
               wait 10
               ignoreitem #FINDID
               return
          }
          IF peasant in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 peasant
               }
               wait 10
               ignoreitem #FINDID
               return
          }

          
          IGNOREITEM #FINDID
     }
goto rescan
return

sub destination
msg $
msg I will take thee$
msg Destination$
wait 2s
Scanjournal 1
  if trinsic in #journal
  gosub runebookdo gate %t %book
  if jhelom in #journal
  gosub runebookdo gate %j %book
  if magincia in #journal
  gosub runebookdo gate %mag %book
  if vesper in #journal
  gosub runebookdo gate %v %book
  if moonglow in #journal
  gosub runebookdo gate %g %book
  if yew in #journal
  gosub runebookdo gate %y %book
  if hold in #journal
  gosub runebookdo gate %sh %book
  if ocllo in #journal
  gosub runebookdo gate %o %book
  if skara in #journal
  gosub runebookdo gate %s %book
  if britain in #journal
  gosub runebookdo gate %b %book
  if Nujel'm in #journal
  gosub runebookdo gate %n %book
  if Minoc in #journal
  gosub runebookdo gate %m %book
  if den in #journal
  gosub runebookdo gate %buc %book
  if cove in #journal
  gosub runebookdo gate %c %book
  if dungeon in #journal
  gosub runebookdo gate %d %book
  gosub search
return
  
    
    
    
    
;==================================
; Script Name: RuneBookDo
; Author: Vito
; Version: 1.0a
; Client Tested with: 6.0.13 (91)
; EUO version tested with: 1.5 (148)
; Shard OSI / FS: FS ( RunUO ) Should work on OSI
; Revision Date: 13/04/2009
; Public Release: 13/04/2009
; Purpose: Handles most runebook functions
;==================================
;|
;| Parameters:
;|            %1 - "Do" ( setdefault  - Set default rune
;|                        drop        - Drop rune
;|                        charge      - Use charge on rune
;|                        recall      - Recall to rune
;|                        gate        - Open a gate to rune
;|                        sacred      - Sacred J. to rune )
;|            %2 - "Rune" ( Rune number, 1 to 16 )
;|            %3 - "Book" ( Runebook ID )
;|            [%4] - "TimeOut" ( Optional, sets timeout for
;|                               event based actions, in seconds )
;|
;| Return: #True if ok, else #False
;+-----------------------------------------------------------

sub RuneBookDo
    set %RBD_Do %1
    set %RBD_Rune %2 - 1
    set %RBD_Book %3

    ; Some security checks
    if %0 = 4
      set %RBD_TimeOut %4
    else
      set %RBD_TimeOut 10
    set %RBD_End #SCnt + %RBD_TimeOut

    if %0 < 3
      return #False

    if %RBD_Rune < 0 || %RBD_Rune > 15
      return #False

    ; Open the book

    finditem %RBD_Book C_ , #BackPackID
    set #LObjectID #FindID
    event macro 17
    while #ContKind <> SHT && %RBD_End > #SCnt
      wait 1

    if %RBD_Do = charge
    {
      set %RBD_X #ContPosX + 135
      if %RBD_Rune > 7
        set %RBD_X #ContPosX + 295
      ; Rather complex, uh?
      set %RBD_Y #ContPosY + 70 + ( 15 * ( %RBD_Rune % 8 ) )
    }
    else
    {
      ; Open the right page
      set %RBD_Page ( %RBD_Rune / 2 ) + 1
      if %RBD_Page < 5
        set %RBD_Page %RBD_Page - 1
      set %RBD_X #ContPosX + 140 + ( 35 * %RBD_Page )
      set %RBD_Y #ContPosY + 200
      click %RBD_X %RBD_Y dmc
      ; Unable to do event-based without using #PixCol (Puah!)
      wait 10

      if %RBD_Do = setdefault
      {
        set %RBD_X #ContPosX + 165 + ( 140 * ( %RBD_Rune % 2 ) )
        set %RBD_Y #ContPosY + 25
      }
      if %RBD_Do = drop
      {
        set %RBD_X #ContPosX + 140 + ( 160 * ( %RBD_Rune % 2 ) )
        set %RBD_Y #ContPosY + 120
      }
      if %RBD_Do = recall
      {
        set %RBD_X #ContPosX + 140 + ( 160 * ( %RBD_Rune % 2 ) )
        set %RBD_Y #ContPosY + 145
      }
      if %RBD_Do = gate
{
set %RBD_X #ContPosX + 210 + ( 160 * ( %RBD_Rune % 2 ) )
set %RBD_Y #ContPosY + 145
      }
      if %RBD_Do = sacred
      {
        set %RBD_X #ContPosX + 140 + ( 160 * ( %RBD_Rune % 2 ) )
        set %RBD_Y #ContPosY + 181
      }
    }
    click %RBD_X %RBD_Y dmc
return ;#True

« Last Edit: April 12, 2014, 04:36:15 PM by delchi »

Offline Tidus

  • Lazy
  • Administrator
  • *
  • *
  • Posts: 1291
  • Activity:
    0%
  • Reputation Power: 15
  • Tidus is working their way up.Tidus is working their way up.Tidus is working their way up.
  • Gender: Male
  • Mind Blown
  • Respect: +151
  • Referrals: 2
    • View Profile
    • Ultimate Apparel
Re: Escort Script Problems
« Reply #1 on: April 08, 2014, 10:38:04 AM »
0
The main problem i am seeing is that you are not cycling through all of your NPCs correctly.
Code: [Select]
FINDITEM %npc G_10
      IF #FINDCNT > 0
     {
          EVENT PROPERTY #FINDID
          IF Messenger in #property
          {
               for %i 1 10
               {
               EVENT EXMSG #FINDID 3 33 Messenger
               }
               wait 10
               ignoreitem #FINDID
               return
          }

With this you are not cycling through each NPC that was found with the #findid So it is only checking one out of the whole count of NPCs to see if it found it.

Code: [Select]
sub search
     onhotkey f2
          gosub destination
FINDITEM %npc G_10
IF #FINDCNT > 0
{
for #findindex 1 #findcnt
{
event Property #findID
IF Messenger in #property
EVENT EXMSG #FINDID 3 33 Messenger
IF Mage in #property
EVENT EXMSG #FINDID 3 33 Mage
IF Noble in #property
EVENT EXMSG #FINDID 3 33 Noble
IF Peasant in #property
EVENT EXMSG #FINDID 3 33 Peasant
IF Healer in #property
EVENT EXMSG #FINDID 3 33 Healer
IF Merchant in #property
EVENT EXMSG #FINDID 3 33 Merchant
ignoreitem #FINDID
}
}
return
For those who have fought for it, freedom has a taste the protected will never know ~ Anonymous, Vietnam, 1968

Offline delchiTopic starter

  • Newbie
  • *
  • Posts: 4
  • Activity:
    0%
  • Reputation Power: 1
  • delchi has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Escort Script Problems
« Reply #2 on: April 12, 2014, 04:36:03 PM »
0
Worked wonderfully, thank you! Now I know what #Findindex does too !!

Tags: