ScriptUO

Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: Ketchup on July 09, 2015, 10:10:03 AM

Title: GM Alerter Sub
Post by: Ketchup on July 09, 2015, 10:10:03 AM
So It seems a GM loves me and bothers me almost twice a day so I'd like some help please, I'm needing it to journal scan for a GM talking, let me know if I've got it all wrong!
Code: [Select]
Main: My mainy body script would go here along with
gosub GM_ALERT


sub GM_ALERT
gosub TM_AdvJournalScan GM ALERT [GM][
if #RESULT = #TRUE
{
sound warning2.wav


;-------------------------------------------------------------------------------
; %1 - Journal Name
; %2 - #LPC setting (optional)
; Brings !_jindex up to the most recent #journal entry
sub TM_AdvJournalSync
  namespace push
  namespace local TM_AdvJS_ , %1
  set !_jindex #jindex + 1
  if %0 > 1
    set !lpc_set %2
  namespace pop
  set !TM_FunctionCalled #TRUE
return
;-------------------------------------------------------------------------------
; %1 - Journal Name
; %2 - NONE, ADVANCE , ( _VALID ) - advances jindex pointer, anything else
; %3, %4, %5, etc strings to match
; returns #TRUE for match, #FALSE for no match
;  Will not advance !_jindex pointer to allow for scanning journal history for more than one search.
;  Also searches for : , #SPC in journal entry to be sure someone isn't spamming the text
;  About %2 arguments:
;    NONE: defaults to basic journal scan (no SPAM checking, no #jindex pointer copy advancing)
;    ADVANCE: no spam checking, advances #jindex copy
;    VALID: invokes SPAM filtering, no advance of #jindex copy
;    VALID_ADVANCE, VALIDADVANCE, ADVANCE_VALID, etc.: invokes SPAM filtering, advances of #jindex copy
sub TM_AdvJournalScan
  namespace push
  namespace local TM_AdvJS_ , %1
  set !args %2
  set !temp_lpc #LPC
  if !lpc_set = N/A
    set #LPC 1000
  else
    set #LPC !lpc_set
  set !num_args %0
  set !first_arg 3
  set !sampled_jindex #JINDEX
  if !_jindex = N/A
    set !_jindex !sampled_jindex
  if !charname = N/A
  {
    set !charname #CHARNAME
AdvJournalScan_loop1:
    str pos !charname #SPC
    if #STRRES <> 0
    {
      set !val #STRRES - 1
      str left !charname !val
      set !left #STRRES
      set !val !val + 1
      str del !charname 1 !val
      set !charname !left , _ , #STRRES
      goto AdvJournalScan_loop1
    }
  }
  set !index !first_arg
  repeat
    set !temp_jindex !_jindex
    set !text % . !index
    while !temp_jindex <= !sampled_jindex
    {
      scanjournal !temp_jindex
      str pos #JOURNAL !charname 1
      set !namepos #STRRES
      str count #JOURNAL !charname
      set !namecnt #STRRES
      str pos #JOURNAL :_ 1
      set !smcpos #STRRES
      str pos #JOURNAL !text 1
      set !textpos #STRRES
      if !textpos < !smcpos && !smcpos <> 0 || !smcpos = 1 || :_ notin #JOURNAL || VALID notin !args
        set !pass #TRUE
      else
        set !pass #FALSE
      if ( !text in #journal && ( ( !namepos = 1 && !namecnt <= 1 ) || !pass ) )
      {
        set !temp_jindex !temp_jindex + 1
        if ADVANCE in !args
          set !_jindex !temp_jindex
        set !trigger !text
        set #LPC !temp_lpc
        namespace pop
        set !TM_FunctionCalled #TRUE
        return #TRUE
      }
      set !temp_jindex !temp_jindex + 1
    }
    set !index !index + 1
  until !index - !first_arg > !num_args - !first_arg
  set %10 !sampled_jindex - !_jindex
  set %10 %1 , _ , %10 ; for debugging purposes
  set #LPC !temp_lpc
  set TM_AdvJournalGetTrigger #FALSE
  namespace pop
  set !TM_FunctionCalled #TRUE
return #FALSE
;-------------------------------------------------------------------------------

Title: Re: GM Alerter Sub
Post by: Ketchup on July 09, 2015, 03:11:03 PM
I'm thinking it would be eaier to just edit this however, it only seems to pick up general chat %alerts I would of set, anyone any idea why?
;================================================
;-----------------Main loop----------------------
;================================================
;--------DO NOT EDIT BELOW THIS LINE-------------
;================================================
gosub showEUOMenu1
gosub s7TTS G M Alert is now scanning
loop:
if #MENUBUTTON = CLOSED
  halt
if #MENUBUTTON = pause
  gosub pause
if %line <= #jindex
{
  for %number 1 %alerts
  {
    scanjournal %line
    if %alert . %number in #journal
    {
      gosub failsafe
      if #result
      {
        if %debug
          set !debug_result #journal
        gosub updJournalLines #journal
        set %alert Talking
        set %journal %journalline1
        set %pause #true
        gosub alert %journalline1
      }
    }
  }
}
menu get playerdetect
if ! #MENURES
  goto trade
if %contact_wait < #SCNT
  ignoreitem reset name
finditem HS_IS_NAB_OAB_QAB_PAB_MAB_RAB_SAB_LAB_XU_AV_OCB_NCB_DF_CD_ME G_12
if #findkind <> -1
{
  if #FINDREP <> 7
  {
    gosub GetName #findid
    if #result
    {
      set %cname %Propname
      set %sound #false
      gosub alert %cname , #spc , has , #spc , arrived
      set %contact %cname
      menu set contact %contact
    }
  }
  ignoreitem #findid name
  set %contact_wait #SCNT + 30
}
trade:
menu get tradewindow
if #MENURES
{
  if #CONTSIZE = 348_203 && #CONTNAME = trade_gump
  {
    set %alert Trade Window
    set %pause #true
    gosub alert Trade , #spc , Winndow
  }
}
menu get jail
if #MENURES
{
  if #CHARPOSY < 1192 && #CHARPOSY > 1158 && #CHARPOSX < 5312 && #CHARPOSX > 5270
  {
    set %alert Jail!
    set %pause #true
    gosub alert You , #spc , are , #spc , in , #spc , jail
  }
}
if #CHARNAME = N/A
{
  event macro 8 2
  wait 10
}
menu get dead
if #MENURES
{
  if #CHARGHOST = yes
  {
    set %alert Your Dead
    set %pause #true
    gosub alert you , #spc , are , #spc , dead
  }
}
menu get lostcon
if #MENURES
{
  if #CONTNAME = waiting_gump && #CONTSIZE = 203_121
  {
    set %alert LostConn
    set %pause #true
    gosub alert Lost , #spc , Connection
  }
}
menu get charmove
if #MENURES
{
  if ! %set
    gosub setcharpos
  if %x <> #CHARPOSX || %y <> #CHARPOSY
  {
    set %set #false
    set %alert Moved
    set %pause #true
    gosub alert your , #spc ,  character , #spc ,  has , #spc , been , #spc , mooved
  }
}
if #CLILOGGED <> 1
{
  menu set status Halted
  menu set Alert Logged
  halt
}
goto loop
Title: Re: GM Alerter Sub
Post by: The Ghost on July 09, 2015, 03:28:35 PM
Instead of dealing with the journal  have you try to scan for people
Not sure what type is the GM

;1-Innocent (Blue), 2-Friend (Green), 3-Grey (Grey - Animal), 4-Criminal (Grey)
;5-Enemy (Orange), 6-Murderer (Red), 7-Invulnerable (Yellow)


Code: [Select]
set %AllPeople IS_HS_OCB_NCB  ;  <-------  Find the rest

SubGM_ALERT
Finditem %AllPeople G_25
event property #findid
 If #FindCnt > 0
  {
      if #findid = #charid
         {
          ignoreitem #findid
          return
          }

          if guard in #property || healer in #property  ; <---  Add what you see that are safe here
         {
          ignoreitem #findid
          return
         }

  if ( #findtype in %AllPeople ) && ( #findrep = 2)   ; <   this will look for all and guildmate
           {
            IgnoreItem #Findid
            return
           }

 Else
        Gosub playsound
       }
Return



Title: Re: GM Alerter Sub
Post by: Ketchup on July 10, 2015, 02:44:46 AM
I'm pretty sure that's what the script I posted above does, but it seems that it doesn't work, hence why I need it to journal scan
Title: Re: GM Alerter Sub
Post by: The Ghost on July 10, 2015, 04:39:38 AM
Since you are having issue that way, maybe it time to go a different route. Manwinc seen to think like me.  You can have a look at Spewy, rune book mining (https://www.easyuo.com/forum/viewtopic.php?t=200) for Enemy Detection and Evasion.  See how it scan and react.     If you still want to use Journal.  look at TM Advance journal, S7 or Ormgrimm