ScriptUO

Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: razeial on September 12, 2014, 08:14:08 AM

Title: New issue. Need help
Post by: razeial on September 12, 2014, 08:14:08 AM
So im writing a pot chugging script. The issue im having is when my character is holding a two handed weapon, the script will not disarm. However, when i step through the script line-by-line, the disarm works. I dont know where the error is.

Code: [Select]
  sub ConsumeItem
    while h in #charstatus || #LLIFTEDKIND = 1
    {
      wait 0
    }
    Finditem %1 C_ , #backpackid
    retry:
    if %1 = ZLF
    {
      event macro 58 0
      goto skip
    }
    gosub TM_AdvJournalSync Apple
    set #lobjectid #findid
    event macro 17 0
    if %1 = CBS
    {
      gosub TM_AdvJournalScan Apple VALID not_strong_enough
      wait 10
      if #result = #TRUE
      {
        goto retry
      }
    }
    if %1 = NUF
    {
     gosub TM_AdvJournalScan Apple VALID free_hand
     wait 10
     if #result = #TRUE && %Disarm = #true
     {
      gosub Disarm
      goto retry
     }
     if %disarm = #false
     {
      event ExMsg #charid 0 2498 Can't use cure pot with two handed weapon!
     }
    if %Disarmed = #true
    {
     set %Disarmed #false
     event macro 37 0
     wait 10
    }
skip:
    wait 10
  return
Code: [Select]
  sub Disarm
  finditem %weapon C_ , #charid
  set %CurWep #findid
  exevent drag %CurWep
  wait 10
  exevent dropc #backpackid
  wait 10
  return
Title: Re: New issue. Need help
Post by: Tidus on September 12, 2014, 11:04:50 AM
If it is doing it when stepped through but not normally, usually means you are having to wait time issues.
Title: Re: New issue. Need help
Post by: razeial on September 12, 2014, 03:49:08 PM
That was the first thing I though, but even if i set a 5 second wait time before executing the disarm, it still doesn't do it  :-[
Title: Re: New issue. Need help
Post by: TaskForce on September 17, 2014, 12:34:44 AM
gosub TM_AdvJournalScan Apple VALID free_hand could be the culprit, since trying to find something in the journal is sometimes flaky, as I experienced while putting the assumed #journal entry into a msg. It may already behind and cluttered by subsequent entries.
Title: Re: New issue. Need help
Post by: TrailMyx on September 17, 2014, 08:09:54 AM
You can keep the journal scan up to date by adding a sync after you do the scan.  You can sync up right after a journal check by adding this to your calls:

Code: [Select]
gosub TM_AdvJournalScan Apple VALID_ADVANCE not_strong_enough ; note the ADVANCE added

But this is problematic if you are relying on the journal information for another call. It's always best to synchronize only if you find an entry (so everywhere you find your journal item successfully)

Code: [Select]
 sub ConsumeItem
    while h in #charstatus || #LLIFTEDKIND = 1
    {
      wait 0
    }
    Finditem %1 C_ , #backpackid
    retry:
    if %1 = ZLF
    {
      event macro 58 0
      goto skip
    }
    gosub TM_AdvJournalSync Apple
    set #lobjectid #findid
    event macro 17 0
    if %1 = CBS
    {
      gosub TM_AdvJournalScan Apple VALID not_strong_enough
      wait 10
      if #result = #TRUE
      {
        gosub TM_AdvJournalSync Apple
        goto retry
      }
    }
    if %1 = NUF
    {
     gosub TM_AdvJournalScan Apple VALID free_hand
     wait 10
     if #result = #TRUE && %Disarm = #true
     {
      gosub TM_AdvJournalSync Apple
      gosub Disarm
      goto retry
     }
     if %disarm = #false
     {
      event ExMsg #charid 0 2498 Can't use cure pot with two handed weapon!
     }
    if %Disarmed = #true
    {
     set %Disarmed #false
     event macro 37 0
     wait 10
    }
skip:
    wait 10
  return

so there's a couple things to try.  Make sure you have TM_AdvJournalSync somewhere in your code.