#-------------------------------------#
#                                     #
#                      #
#                                     #
#-------------------------------------#

#
#  
alias { $U::leader = "@_"; }                   "";
alias { $U::tank = "@_"; }                     "";

trig { $U::leader=$U::myname; } '^    [--\-]', "500s:CORE";

trig { undef(@group); enable("SETGR"); } '   :$', "1000s:SETGRINIT";
trig { 
  if ($1 ne $U::myname) {
    push(@group,"$1");
    $n=$#group+1;
    if (($2 eq '')||($2 eq '')) {
        $_="$1($n) $2 $3 $4 $5 $6 $7";       
    } elsif (($2 eq '.')||($2 eq '')||($2 eq '')) {
        $_=" _ $1 _(\003F$n\003H) $2 $3 $4 $5 $6 $7";       
    }
  } 
}  '^  ([--]+)\s+(|.||||.||)\s+(||)\s+(||||)\s+(|)\s+(|)\s+(1|0)', "500s-:SETGR";

alias { local($tmp)="@_"; $tmp=~s/\,/\r\n/g; $U::profHelpAction = "$tmp"; } "";
bindkey { sendl("");                           }  "M-";
bindkey { sendl("$U::profHelpAction $U::tank");  }  "M-";
bindkey { sendl("$U::profHelpAction ");      }  "M-";
bindkey { sendl("$U::profHelpAction $group[0]"); }  "M-1";
bindkey { sendl("$U::profHelpAction $group[1]"); }  "M-2";
bindkey { sendl("$U::profHelpAction $group[2]"); }  "M-3";
bindkey { sendl("$U::profHelpAction $group[3]"); }  "M-4";
bindkey { sendl("$U::profHelpAction $group[4]"); }  "M-5";
bindkey { sendl("$U::profHelpAction $group[5]"); }  "M-6";
bindkey { sendl("$U::profHelpAction $group[6]"); }  "M-7";
bindkey { sendl("$U::profHelpAction $group[7]"); }  "M-8";
bindkey { sendl("$U::profHelpAction $group[8]"); }  "M-9";

#
#  
alias { push(@autorescue,"@_"); }              "+";
alias { undef(@autorescue); }                  "!";
alias {
  echo "  :"; 
  foreach $ar(@autorescue) { echo "$ar"; } 
} "";

trig {
  if (defined(@group)) {
    for($i=1;(($i<=$#group+1)&&($i<10));$i++) {
      if (($_=~/$group[$i-1]/)&&(!($_=~//)||($_=//))&&
          (substr($_,0,length($group[$i-1])) ne "$group[$i-1]")) {
        if ($group[$i-1] eq $U::tank) {
          $_ =~ s/$group[$i-1]/($i)$group[$i-1]/g;
        } else {
          $_ =~ s/$group[$i-1]/ (\003F$i\003H) _$group[$i-1]_ /g;
        }
        $: = $_;
      }
    }
  }
  if (defined(@autorescue)) {
    foreach $rescue(@autorescue) {
      if ($4=~/$rescue/) {
        sendl(" $rescue$U::strAFK");
      }
    }
  }
} '^([-- ]+)(||| | ||| | )? (.*|.*|.*|.*|.*|.*|.*|.*|.*|.*|.*|.*|.*|.*|.*|.*) ([-- ]+)(!!|\.)$', "500fn:AUTORESC";

trig { $U::resc = "$4"; } '^(.*) \[(.*):(.*)\] \[(.*):(.*)\] \[(.*):(.*)\]', "500fn:AUTORESC";

bindkey { sendl("$U::profHelpAction $U::resc"); } "M-";

#
#   
trig {
  $tmp1=$1;
  $tmp2=$3;
  if ($tmp2 eq " ") {
    if ($infoAFK eq "") { sendl(" !$U::strAFK"); }
    else { sendl(" $msg_test!"); }
  }
  if ($tmp1 eq $U::leader) { 
    $_="\003O[] $tmp1 --  --: \"$tmp2\"";
    if (($tmp2 eq "")||($tmp2 eq "")||($tmp2 eq "")||($tmp2 eq "")) {sendl("$U::strAFK");}
  } else { $_ = "\003O[] $tmp1: \"$tmp2\""; }
  ($tmp3,@tmp4)=split (/ /,$tmp2);
  if ((($tmp3 eq "")||($tmp3 eq $U::myname))&&($tmp1 eq $U::leadtank)) {
     sendl("@tmp4");
  }
  $: = $_;
} '^([--\-]+) (|||) : "(.*)"$', "1500fn:HIGHLIGHT";

trig {
  $: = "\003I[] $1: \"$3\"";
} '^([--\-]+) (|||) : "(.*)"$', "1500fn:HIGHLIGHT";

#
#  .         
trig { $U::exp += $1; echo "   $U::exp ."; }  '^     -- (\d+).', "500n:EXP";
trig { $U::exp -= $1; echo "   $U::exp ."; }  '  (\d+)     !', "500n:EXP";

alias { echo "   $U::exp ."; }  "";
alias { echo " !"; $U::exp=0; }        "";

#
#      .

trig {
  if ($1 eq " ") { 
    sendl(" $msg_mem_light");
  } elsif ($1 eq " ") {
    sendl(" $msg_mem_serios");
  } elsif ($1 eq " ") {
    sendl(" $msg_mem_critical");
  } else {
    sendl(" $msg_mem_heal");
  } 
} '^     "( | | |)".',  "900s:MAGE";

trig { $: = "\003P$_"; } '^ ,   .',               "900s:MAGE";
trig { $: = "\003P$_"; } '^    .',                 "900s:MAGE";
trig { $: = "\003P$_"; } '^      .',  "900s:MAGE";
trig { $: = "\003P$_"; } '^    .',                   "900s:MAGE";
trig { $: = "\003P$_"; } '^   .',                       "900s:MAGE";


trig { $: = "\003J$_"; sendl(" !!!!!!!!  !!!!!!!! \r\n  ### -  -  -  - ###\r\n $U::strAFK") }
         '^    ,   - .',                                      "900s:MAGE";
trig { $: = "\003J$_"; sendl(" $msg_blind$U::strAFK") } '^ !',                                      "900s:MAGE";
trig { $: = "\003J$_"; sendl(" $msg_poison$U::strAFK") } '^   !',                  "900s:MAGE";
trig { $: = "\003P$_"; sendl(" $msg_fly$U::strAFK") } '^   .',                          "900s:MAGE";
trig { $: = "\003P$_"; sendl(" $msg_armor$U::strAFK") } '^     .',       "900s:MAGE";
trig { $: = "\003P$_"; sendl(" $msg_sanc$U::strAFK") } '^     .',            "900s:MAGE";
trig { $: = "\003P$_"; sendl(" $msg_bless$U::strAFK") } '^    .',            "900s:MAGE";
trig { $: = "\003P$_"; sendl(" $msg_milk$U::strAFK") } '^      .', "900s:MAGE";
trig { $: = "\003P$_"; sendl(" $msg_strength$U::strAFK") } '^   .',                 "900s:MAGE";

trig { $: = "\003B$_"; sendl("   $U::strAFK") }   '^   ',                            "900s:MAGE";
trig { $: = "\003B$_"; sendl("   $U::strAFK") }          '^   ',                                   "900s:MAGE";
trig { $: = "\003B$_"; sendl("   !!!!!!$U::strAFK") }  '^    ',                     "900s:MAGE";
trig { $: = "\003B$_"; sendl("    $U::strAFK")}'^    ',                        "900s:MAGE";
trig { $: = "\003B$_"; sendl("$U::strAFK") }  '^    ',                                   "900s:MAGE";
trig { $: = "\003B$_"; sendl("$U::strAFK") }  '^   ( | |)',       "900s:MAGE";
trig { $: = "\003B$_"; sendl("$U::strAFK") } '^   ',                                             "900s:MAGE";
trig { $: = "\003C$_"; } '^   !',  "900s:MAGE";
trig { $: = "\003C$_"; } '^    .',  "900s:MAGE";

trig {
  $: = "\003C$_";
  if ($1 eq "  !") {
    sendl(" $msg_dispellall$U::strAFK");
  } else {
    sendl(" $msg_dispell\r\n$U::strAFK");
  }
} '^   (  !|!)$', "900s:MAGE";


#
#   .
bindkey { sendl(" $U::tank ") }    "C-k1";
bindkey { sendl(" $U::tank ") }      "C-k2";
bindkey { sendl(" $U::tank ") }  "C-k4";
bindkey { sendl(" $U::tank ") }   "C-k6";
bindkey { sendl(" $U::tank ") }   "C-k7";
bindkey { sendl(" $U::tank ") }   "C-k8";
bindkey { sendl(" $msg_cmd_ready") }   "C-f1";
bindkey { sendl(" $msg_cmd_recall") }  "C-f2";
bindkey { sendl(" $msg_cmd_rest") }    "C-f3";
bindkey { sendl(" $msg_cmd_up") }      "C-f4";


#
# .
alias { sendl(" $msg_ready") }             "";    #  !
alias { sendl(" @_"); $U::leader="@_"; } "";     #  
