Good to be back. I updated the script on the ;repo tonight. It now incorporates the ability to add mstrike as well.

;smartmonk setup

Enjoy.

Code:
=begin
Script           SmartMonk
Author           Yasutoshi
Date             September 8th, 2020
Version          6.0.2
Description      Provides stancing and smart combat through unarmed vulnerabilities (punch, kick, grapple, jab)
                 Locks onto specific targets and continues fighting those targets, regardless of other monsters
                 entering into the rooms.  Once the monster is killed, it loots using ;sloot.
                 Use:  ;smartmonk punch OR ;smartmonk kick chest
                 Note: You can specify location to attack as well
                 Automatically finds and attacks monsters if they are in the same room.  No need to specify
                 Only push button once and the script will handle the rest.  No button mashing!


SETUP            ;smartmonk setup
.................| Equipment Name (hands) refers to gloves/handwraps - use adjective + noun (ex. leather handwraps)
.................| Equipment Name (feet) refers to boots/footwraps - use adjective + noun (ex. leather footwraps)
.................| Member of Voln?  (yes or no)  If yes, when blesses run out auto blesses of feet/hands occurs automatically.
.................| Aimed Strikes (yes or no)  If yes, then on the first up-tiered attack, your preferred attack will aim for a leg.  On consecutive attacks, will aim for head.
.................| MStrike (yes or no)  If yes, then on the very first attack, regardless of ambush settings, you'll perform one mstrike attack to try to hopefully uptier in combat.
.................| Default Brawling Attack can take (punch, kick, grapple, or jab)
.................| Default Attack Stance can take (offensive, advance, forward, guarded, defensive)
.................| Default Loot Script take (none, sloot, sloot2, sloot3, etc.)
.................
.................  Note that blessable equipment needs to be specified based on the message received.
.................  Example:  some black leather footwraps show "Your leather footwraps returns to normal."
.................  You need to specify leather footwraps in the box for the auto blessings to work then.
=end


# You feel recovered from your whirlwind flurry of strikes.


VERSION = '6.0.2'
$TITLE = "SmartMonk: v. (#{VERSION})"


class SmartMonk


  attr_accessor :variable, :debug


  def initialize(variable, debug=0)
    @debug_messages = 0
    @msg = nil
    @target = nil
    @my_status = nil
    @currently_tiered = false
    @num_of_uptiered = 0
    @debug = debug
    @variable = variable
    silence_me if @debug == 0
    @variable[1] == 'setup' ? setup : start
  end


  def setup
    gui
    echo "..........| Settings Saved!"
    echo "..........| Member of Voln?  #{UserVars.smartmonk['sm_voln']}"
    echo "..........| - If a voln member, when blesses run out, the following items will be blessed automatically -"
    echo "..........| - You can turn this off by typing the word NO in the voln member box -"
    echo "..........| Edging Weapons? (input spell number)  #{UserVars.smartmonk['sm_edge']}"
    echo "..........| - If a wizard, when edging charges run out, the items below will be spelled up automatically -"
    echo "..........| - You can turn this off by typing the word NO in the edging weapons box -"
    echo "..........| Hand Equipment:  #{UserVars.smartmonk['sm_hands']}"
    echo "..........| Foot Equipment:  #{UserVars.smartmonk['sm_feet']}"
    echo "..........| - Default attack stance and martial arts move-"
    echo "..........| Use Aimed Strikes?:  #{UserVars.smartmonk['sm_ambush']}"
    echo "..........| Use MSTRIKE on 1st attack for uptier chance?:  #{UserVars.smartmonk['sm_mstrike']}"
    echo "..........| Preferred Defense Stance:  #{UserVars.smartmonk['sm_default_defensive_stance']}"
    echo "..........| Preferred Attack Stance:  #{UserVars.smartmonk['sm_default_stance']}"
    echo "..........| Preferred Attack Type:  #{UserVars.smartmonk['sm_default_attack']}"
    echo "..........| - If you don't want to use a loot script, specify the word none -"
    echo "..........| Default Loot Script:  #{UserVars.smartmonk['sm_loot_script']}"
  end


  def get_custom_settings
    if (UserVars.smartmonk['sm_default_stance']) && (UserVars.smartmonk['sm_default_attack'])
      @voln = UserVars.smartmonk['sm_voln']
      @edge = UserVars.smartmonk['sm_edge']
      @ambush = UserVars.smartmonk['sm_ambush']
      @mstrike = UserVars.smartmonk['sm_mstrike']
      @hand_equipment = UserVars.smartmonk['sm_hands']
      @foot_equipment = UserVars.smartmonk['sm_feet']
      @preferred_stance = UserVars.smartmonk['sm_default_stance']
      @preferred_defensive_stance = "Stance #{UserVars.smartmonk['sm_default_defensive_stance']}"
      @preferred_attack = UserVars.smartmonk['sm_default_attack']
      @default_loot_script = UserVars.smartmonk['sm_loot_script']
      @num_of_mstrikes = 0
    else
      @variable = nil
      setup
    end
  end


  def start
    get_custom_settings
    @target = GameObj.npcs.find { |npc| npc.status.nil? }
    # Examples Below for different situations
    # @target = GameObj.npcs.find { |npc| npc.status.nil? }
    # @target = GameObj.npcs.find_all { |x| x.name == 'lesser mummy' };
    # ;exec echo GameObj.npcs.find { |npc| npc.status; echo "#{npc} #{npc.status}" }
    if @target
      echo "Monster = ##{@target.id}" if @debug == 1
      open_attack                                                                                                       # If a target is found, we'll start our open_attack sequence
      rebless_items if (@voln == 'yes')
      @msg = check_match_conditions
      echo "start method and msg = #{@msg}" if @debug == 1
      fight_on
    else
      echo "From Start Method - exiting." if @debug_messages == 1
      exit
    end
  end


  def check_match_conditions
    return matchwait('returns to normal', 'It looks like somebody already','What were you referring to?', 'followup jab', 'followup punch', 'followup grapple', 'followup kick', 'Roundtime')
  end


  def attack_with(move)
    if @variable[2]
      multifput "stance offensive", "#{move} ##{@target.id} #{@variable[2]}"
    elsif @variable[1]
      multifput "stance offensive", "#{move} ##{@target.id}"
    elsif @preferred_stance
      multifput "stance #{@preferred_stance}", "#{move} ##{@target.id}"
    else
      multifput "stance offensive", "#{move} ##{@target.id}"
    end
  end


  def ambush_or_attack_with(move)
    @stamina_total = XMLData.max_stamina.to_f
    @stamina_current = XMLData.stamina.to_f
    @stamina_threshold = @stamina_total / 2.0
    echo "Stamina Total = #{@stamina_total}, Stamina Current = #{@stamina_current}, Stamina Threshold = #{@stamina_threshold}" if @debug == 1
    if (@mstrike == 'yes') && (@num_of_mstrikes == 0) && (@stamina_current >= @stamina_threshold)
      multifput "stance #{@preferred_stance}", "mstrike punch"
      @num_of_mstrikes = 1
      @mstrike == 'no'
    else
      if @ambush == 'yes'
        if (@currently_tiered == true) && (@num_of_uptiered == 0)
          @num_of_uptiered += 1
          multifput "stance #{@preferred_stance}", "#{move} ##{@target.id} right leg"
          # You fail to find an opening for your strike.
        elsif (@currently_tiered == true) && (@num_of_uptiered > 0)
          multifput "stance #{@preferred_stance}", "#{move} ##{@target.id} head"
        else
          attack_with(move)
        end
      else
        attack_with(move)
      end
    end
  end


  def check_my_status
    if checkprone == true
      fput @preferred_defensive_stance
      fput "stand"
    end
  end


  def open_attack
    check_my_status
    if @variable[1]
      ambush_or_attack_with(@variable[1])
    elsif @preferred_attack
      ambush_or_attack_with(@preferred_attack)
    else
      ambush_or_attack_with("punch")
    end
    @msg = check_match_conditions
    waitrt?
    fput @preferred_defensive_stance
    fight_on
  end


  def loot_em
    unless @default_loot_script == 'none'
      #start_scripts "#{@default_loot_script}"
      start_script "#{@default_loot_script}"; wait_while { running?("#{@default_loot_script}") }
    end
  end


  def fight_on
    check_my_status
    # Bless items when they run out
    if ( @msg =~ /Your #{@hand_equipment} returns to normal./ )
      echo "Blessing ran out so refreshing if in voln." if @debug == 1
      if @voln == 'yes'
        waitrt?
        fput @preferred_defensive_stance
        fput "sym of bless my #{@hand_equipment}"
        attack_with("#{@preferred_attack}")
        @msg = check_match_conditions
        waitrt?
        fput @preferred_defensive_stance
        fight_on
      else
        attack_with("#{@preferred_attack}")
        @msg = check_match_conditions
        waitrt?
        fput @preferred_defensive_stance
        fight_on
      end
    elsif ( @msg =~ /Your #{@foot_equipment} returns to normal./ )
      echo "Blessing ran out so refreshing if in voln." if @debug == 1
      if @voln == 'yes'
        waitrt?
        fput @preferred_defensive_stance
        fput "sym of bless my #{@foot_equipment}"
        attack_with("#{@preferred_attack}")
        @msg = check_match_conditions
        waitrt?
        fput @preferred_defensive_stance
        fight_on
      else
        attack_with("#{@preferred_attack}")
        @msg = check_match_conditions
        waitrt?
        fput @preferred_defensive_stance
        fight_on
    end
    # Check for Edging
    elsif ( @msg =~ /Your #{@hand_equipment} stops glowing./)
      if @edge.to_i > 0
        waitrt?
        fput @preferred_defensive_stance
        fput "prep #{@edge}"
        fput "cast my #{@hand_equipment}"
        attack_with("#{@preferred_attack}")
        @msg = check_match_conditions
        waitrt?
        fput @preferred_defensive_stance
        fight_on
      else
        attack_with("#{@preferred_attack}")
        @msg = check_match_conditions
        waitrt?
        fput @preferred_defensive_stance
        fight_on
      end
    elsif ( @msg =~ /Your #{@foot_equipment} stops glowing./ )
      if @edge.to_i > 0
        waitrt?
        fput @preferred_defensive_stance
        fput "prep #{@edge}"
        fput "cast my #{@foot_equipment}"
        attack_with("#{@preferred_attack}")
        @msg = check_match_conditions
        waitrt?
        fput @preferred_defensive_stance
        fight_on
      else
        attack_with("#{@preferred_attack}")
        @msg = check_match_conditions
        waitrt?
        fput @preferred_defensive_stance
        fight_on
      end
    # Check if target is dead
    elsif @target.status == 'dead'
      echo "Target Status = #{@target.status}" if @debug == 1
      echo "Begin Search" if @debug == 1
      fput @preferred_defensive_stance
      loot_em
      echo "Just looted the monster. - exiting." if @debug_messages == 1
      exit
    # Jab Vulnerability was found
    elsif ( @msg =~ /followup jab/ )
      @currently_tiered = true
      echo "Fight On - Jab and msg = #{@msg}" if @debug == 1
      echo "Jab Vulnerability Found" if @debug == 1
      ambush_or_attack_with("jab")
      #attack_with("jab")
      @msg = check_match_conditions
      waitrt?
      fput @preferred_defensive_stance
      fight_on
    # Punch Vulnerability was found
    elsif ( @msg =~ /followup punch/ )
      @currently_tiered = true
      echo "Fight On - Punch and msg = #{@msg}" if @debug == 1
      echo "Punch Vulnerability Found" if @debug == 1
      ambush_or_attack_with("punch")
      #attack_with("punch")
      @msg = check_match_conditions
      waitrt?
      fput @preferred_defensive_stance
      fight_on
    # Grapple Vulnerability was found
    elsif ( @msg =~ /followup grapple/ )
      @currently_tiered = true
      echo "Fight On - Grapple and msg = #{@msg}" if @debug == 1
      echo "Grapple Vulnerability Found" if @debug == 1
      ambush_or_attack_with("grapple")
      #attack_with("grapple")
      @msg = check_match_conditions
      waitrt?
      fput @preferred_defensive_stance
      fight_on
    # Kick Vulnerability was found
    elsif ( @msg =~ /followup kick/ )
      @currently_tiered = true
      echo "Fight On - Kick and msg = #{@msg}" if @debug == 1
      echo "Kick Vulnerability Found" if @debug == 1
      ambush_or_attack_with("kick")
      #attack_with("kick")
      @msg = check_match_conditions
      waitrt?
      fput @preferred_defensive_stance
      fight_on
    # Monster already dead so search
    elsif ( @msg =~ /It looks like somebody already did the job for you./ )
      echo "Monster dead so search" if @debug == 1
      fput @preferred_defensive_stance # do a stance check
      loot_em
      echo "Monster already dead so searching" if @debug_messages == 1
      exit
    # Monster ran or I got feared
    elsif ( @msg =~ /What were you referring to?/ )
      echo "Monster ran or perhaps I got feared so exiting"
      fput @preferred_defensive_stance # do a stance check
      echo "Exiting because I got feared or monster ran." if @debug_messages == 1
      exit
    elsif ( @msg =~ /You don\'t seem able to move to do that./ )
      echo "You must be immobilized" if @debug == 1
      fput @preferred_defensive_stance # do a stance check
      stand
      echo "You dont seem able to move to do that so exiting." if @debug_messages == 1
      exit
    elsif ( @msg =~ /You are immobilized with sheer terror!/ )
      echo "You must be immobilized" if @debug == 1
      fput @preferred_defensive_stance # do a stance check
      stand
      echo "You are immobilized with sheer terror." if @debug_messages == 1
      exit
    elsif ( @msg =~ /You mentally give a sigh of relief as you remember that the Goddess Lorminstra owes you a favor./ )
      echo "You just died - Combat Script should now end." if @debug == 1
      echo "You died." if @debug_messages == 1
      exit
    else
      echo "nothing found attempting to continue" if @debug == 1
      open_attack
    end
  end


  def check_blessings
    return matchwait("A faint aura of holy light radiates", "You also notice a small enchanter's glyph")
  end


  def rebless_items
    @msg = nil
    # check hands
    fput "look at my #{@hand_equipment}"
    @msg = check_blessings
    if ( @msg =~ /A faint aura of holy light radiates/ )
      echo "Hand Items are still blessed so do nothing" if @debug == 1
    else
      echo "Blessing #{@hand_equipment}."
      fput "sym of bless my #{@hand_equipment}"
    end
    @msg = nil
    # check hands
    fput "look at my #{@foot_equipment}"
    @msg = check_blessings
    if ( @msg =~ /A faint aura of holy light radiates/ )
      echo "Foot Items are still blessed so do nothing" if @debug == 1
    else
      echo "Blessing #{@foot_equipment}."
      fput "sym of bless my #{@foot_equipment}"
    end
  end


  def gui
        Gtk.queue {
            $MONK_WINDOW = Gtk::Window.new
            $MONK_WINDOW.title = $TITLE
            $MONK_WINDOW.set_border_width(10)
            $MONK_BOX = Gtk::VBox.new(false)
            $MONK_BOX.set_border_width(5)


            $MONK_VERTICAL_BOX1 = Gtk::VBox.new(false, 0)


            $MONK_WINDOW.add($MONK_BOX)
            $MONK_NOTEBOOK = Gtk::Notebook.new
            $MONK_NOTEBOOK.set_show_border(true)
            $MONK_BOX.add($MONK_NOTEBOOK)
            $MONK_NOTEBOOK.append_page($MONK_VERTICAL_BOX1, Gtk::Label.new(' Configuration Settings  '))


            $MONK_ENTRY = Hash.new
            $MONK_TABLE_SIZE = Hash.new
        }


        Gtk.queue {
            $MONK_TABLE1 = Gtk::Table.new(4, 1, false)
            $MONK_TABLE1.row_spacings=2
            $MONK_TABLE1.column_spacings=2
            $MONK_VERTICAL_BOX1.pack_start($MONK_TABLE1, false, false, 0)
        }


        def self.add_label_entry(table, label, variable)
            size = $MONK_TABLE_SIZE[table] || 0


            label = Gtk::Label.new(label)
            align = Gtk::Alignment.new 1, 0, 0, 0
            align.set_padding(4, 0, 3, 4)
            align.add(label)
            table.attach(align, 0, 1, size, size + 1)


            entry = Gtk::Entry.new
            entry.text = UserVars.smartmonk[variable].to_s
            entry.set_width_request(157)
            table.attach(entry, 1, 2, size, size + 1)


            $MONK_ENTRY[variable] = entry
            $MONK_TABLE_SIZE[table] += 1
        end


        Gtk.queue {
            $MONK_ENTRY = Hash.new
            add_label_entry($MONK_TABLE1, "   Equipment Name (hands)......| ", 'sm_hands')
            add_label_entry($MONK_TABLE1, "    Equipment Name (feet)......| ", 'sm_feet')
            add_label_entry($MONK_TABLE1, "          Member of Voln?......| ", 'sm_voln')
            add_label_entry($MONK_TABLE1, "          Edging Weapons?......| ", 'sm_edge')
            add_label_entry($MONK_TABLE1, "       Use Aimed Strikes?:.....| ", 'sm_ambush')
            add_label_entry($MONK_TABLE1, "             Use MSTRIKE?:.....| ", 'sm_mstrike')
            add_label_entry($MONK_TABLE1, "  Default Brawling Attack......| ", 'sm_default_attack')
            add_label_entry($MONK_TABLE1, "    Default Attack Stance......| ", 'sm_default_stance')
            add_label_entry($MONK_TABLE1, "   Default Defense Stance......| ", 'sm_default_defensive_stance')
            add_label_entry($MONK_TABLE1, "      Default Loot Script......| ", 'sm_loot_script')
        }


        Gtk.queue {
            $MONK_WINDOW.signal_connect("delete_event") {
                $MONK_SETUP_COMPLETED = true
            }
        }


        Gtk.queue {
            $MONK_WINDOW.show_all
        }


        $MONK_SETUP_COMPLETED = false
        until($MONK_SETUP_COMPLETED)
            sleep 1
        end


        UserVars.smartmonk ||= Hash.new
        $MONK_ENTRY.keys.each { |key|
            UserVars.smartmonk[key] = $MONK_ENTRY[key].text.strip.downcase
        }
        UserVars.save()


        Gtk.queue {
            $MONK_WINDOW.destroy
        }
  end


end


combat = SmartMonk.new(variable)