From f81d4276a4142df057d121923f221017d5497b84 Mon Sep 17 00:00:00 2001 From: Robert Herbig Date: Sun, 29 May 2016 07:07:08 -0400 Subject: [PATCH] "Namespace" debug var for combat-trainer --- combat-trainer.lic | 154 ++++++++++++++++++++++----------------------- 1 file changed, 75 insertions(+), 79 deletions(-) diff --git a/combat-trainer.lic b/combat-trainer.lic index 4153ab1c3b..ba3e89bd08 100644 --- a/combat-trainer.lic +++ b/combat-trainer.lic @@ -17,19 +17,19 @@ class SetupProcess include DRCT def initialize(settings) - echo('New SetupProcess') if $debug_mode + echo('New SetupProcess') if $debug_mode_ct @summoned_weapons_element = settings.summoned_weapons_element(nil) - echo(" @summoned_weapons_element: #{@summoned_weapons_element}") if $debug_mode + echo(" @summoned_weapons_element: #{@summoned_weapons_element}") if $debug_mode_ct @summoned_weapons_ingot = settings.summoned_weapons_ingot(nil) - echo(" @summoned_weapons_ingot: #{@summoned_weapons_ingot}") if $debug_mode + echo(" @summoned_weapons_ingot: #{@summoned_weapons_ingot}") if $debug_mode_ct end def execute(game_state) return true if game_state.done_cleaning_up? if game_state.stowing? - echo('SetupProcess::clean_up') if $debug_mode + echo('SetupProcess::clean_up') if $debug_mode_ct retreat if game_state.summoned_info(game_state.weapon_skill) if DRStats.moon_mage? @@ -72,12 +72,12 @@ class SetupProcess def determine_next_to_train(game_state, weapon_training, ending_ranged) return unless game_state.skill_done? || !weapon_training[game_state.weapon_skill] || ending_ranged - echo('new skill needed for training') if $debug_mode + echo('new skill needed for training') if $debug_mode_ct game_state.action_count = 0 if DRStats.moon_mage? && moon_used_to_summon_weapon.nil? - echo('skipping summoned weapons because no moonblade available') if $debug_mode + echo('skipping summoned weapons because no moonblade available') if $debug_mode_ct weapon_training = weapon_training.reject { |skill, _| game_state.summoned_info(skill) } end new_weapon_skill = weapon_training.min_by { |skill, _| [DRSkill.getxp(skill), DRSkill.getrank(skill)] }.first @@ -131,7 +131,7 @@ class SetupProcess def check_weapon(game_state) return unless game_state.weapon_skill_changed? - echo("checking weapons as #{game_state.last_weapon_skill.inspect}!=#{game_state.weapon_skill}") if $debug_mode + echo("checking weapons as #{game_state.last_weapon_skill.inspect}!=#{game_state.weapon_skill}") if $debug_mode_ct last_summoned = game_state.summoned_info(game_state.last_weapon_skill) next_summoned = game_state.summoned_info(game_state.weapon_skill) @@ -165,33 +165,33 @@ class LootProcess include DRC def initialize(settings) - echo('New LootProcess') if $debug_mode + echo('New LootProcess') if $debug_mode_ct skinning = settings.skinning({}) @skin = skinning['skin'] || false - echo(" @skin: #{@skin}") if $debug_mode + echo(" @skin: #{@skin}") if $debug_mode_ct @arrange_all = skinning['arrange_all'] || false - echo(" @arrange_all: #{@arrange_all}") if $debug_mode + echo(" @arrange_all: #{@arrange_all}") if $debug_mode_ct @arrange_count = skinning['arrange_count'] || 0 - echo(" @arrange_count: #{@arrange_count}") if $debug_mode + echo(" @arrange_count: #{@arrange_count}") if $debug_mode_ct @tie_bundle = skinning['tie_bundle'] || false - echo(" @tie_bundle: #{@tie_bundle}") if $debug_mode + echo(" @tie_bundle: #{@tie_bundle}") if $debug_mode_ct @arrange_types = skinning['arrange_types'] || {} - echo(" @arrange_types: #{@arrange_types}") if $debug_mode + echo(" @arrange_types: #{@arrange_types}") if $debug_mode_ct @lootables = settings.lootables([]) - echo(" @lootables: #{@lootables}") if $debug_mode + echo(" @lootables: #{@lootables}") if $debug_mode_ct thanatology = settings.thanatology({}) @ritual_type = thanatology['ritual_type'] || {} - echo(" @ritual_type: #{@ritual_type}") if $debug_mode + echo(" @ritual_type: #{@ritual_type}") if $debug_mode_ct @necro = thanatology['necro'] || false - echo(" @necro: #{@necro}") if $debug_mode + echo(" @necro: #{@necro}") if $debug_mode_ct end def execute(game_state) @@ -199,7 +199,7 @@ class LootProcess dispose_body(game_state) stow_lootables(game_state) if (game_state.mob_died || DRRoom.npcs.empty?) && game_state.finish_killing? - echo('LootProcess::clean_up') if $debug_mode + echo('LootProcess::clean_up') if $debug_mode_ct game_state.next_clean_up_step end return true if game_state.finish_spell_casting? || game_state.stowing? @@ -355,7 +355,7 @@ class SafetyProcess include DRCT def initialize - echo('New SafetyProcess') if $debug_mode + echo('New SafetyProcess') if $debug_mode_ct Flags.add('ct-engaged', 'closes to pole weapon range on you', 'closes to melee range on you') Flags.add('ct-lodged', 'You feel an agonizing pain from the .* lodged in your (.*)\.') end @@ -402,28 +402,28 @@ class SpellProcess include DRCS def initialize(settings) - echo('New SpellProcess') if $debug_mode + echo('New SpellProcess') if $debug_mode_ct @buff_spells = settings.buff_spells({}) - echo(" @buff_spells: #{@buff_spells}") if $debug_mode + echo(" @buff_spells: #{@buff_spells}") if $debug_mode_ct @offensive_spells = settings.offensive_spells([]) - echo(" @offensive_spells: #{@offensive_spells}") if $debug_mode + echo(" @offensive_spells: #{@offensive_spells}") if $debug_mode_ct @cambrinth = settings.cambrinth(nil) - echo(" @cambrinth: #{@cambrinth}") if $debug_mode + echo(" @cambrinth: #{@cambrinth}") if $debug_mode_ct @casts = settings.cast_messages([]) - echo(" @casts: #{@casts}") if $debug_mode + echo(" @casts: #{@casts}") if $debug_mode_ct @preps = settings.prep_messages([]) - echo(" @preps: #{@preps}") if $debug_mode + echo(" @preps: #{@preps}") if $debug_mode_ct @is_empath = settings.is_empath(false) - echo(" @is_empath: #{@is_empath}") if $debug_mode + echo(" @is_empath: #{@is_empath}") if $debug_mode_ct @empath_spells = settings.empath_healing({}) - echo(" @empath_spells: #{@empath_spells}") if $debug_mode + echo(" @empath_spells: #{@empath_spells}") if $debug_mode_ct if (!@buff_spells.empty? || !@offensive_spells.empty?) && (@casts.empty? || @preps.empty?) raise(ArgumentError, 'Must provide casting/prep messages to use spells') @@ -459,7 +459,7 @@ class SpellProcess check_offensive(game_state) check_current(game_state) if game_state.finish_spell_casting? && !game_state.casting - echo('SpellProcess::clean_up') if $debug_mode + echo('SpellProcess::clean_up') if $debug_mode_ct game_state.next_clean_up_step fput('release dalu') if DRSpells.active_spells['Damaris\' Lullaby'] return true @@ -502,7 +502,7 @@ class SpellProcess def charge_cambrinth?(game_state) return false unless game_state.charges - echo("charge_camb: #{game_state.charges}") if $debug_mode + echo("charge_camb: #{game_state.charges}") if $debug_mode_ct if game_state.charges.empty? bput("invoke my #{@cambrinth}", 'You reach for its center', 'Your link to the') @@ -560,7 +560,7 @@ class SpellProcess !DRSpells.active_spells[name] || DRSpells.active_spells[name].to_i <= data['recast'] end end - echo("found buff missing: #{name}") if $debug_mode && name + echo("found buff missing: #{name}") if $debug_mode_ct && name data['name'] = name prepare_spell(data, game_state) end @@ -570,7 +570,7 @@ class SpellProcess return unless @is_empath return if checkhealth > 91 - echo('Healing') if $debug_mode + echo('Healing') if $debug_mode_ct data = { 'abbrev' => 'vh', 'mana' => @empath_spells['VH'].first, 'cambrinth' => @empath_spells['VH'][1..-1] } prepare_spell(data, game_state) end @@ -591,7 +591,7 @@ class SpellProcess def prepare_spell(data, game_state) return unless data game_state.cast_timer = Time.now - echo("prepare spell: #{data}") if $debug_mode + echo("prepare spell: #{data}") if $debug_mode_ct if data['cyclic'] fput('release care') if DRSpells.active_spells['Caress of the Sun'] fput("release #{data['abbrev']}") # make bputs. better spells @@ -649,19 +649,19 @@ class AbilityProcess include DRCT def initialize(settings) - echo('New AbilityProcess') if $debug_mode + echo('New AbilityProcess') if $debug_mode_ct @buffs = settings.buff_nonspells({}) - echo(" @buffs: #{@buffs}") if $debug_mode + echo(" @buffs: #{@buffs}") if $debug_mode_ct @khri = @buffs.delete('khri') || [] - echo(" @khri: #{@khri}") if $debug_mode + echo(" @khri: #{@khri}") if $debug_mode_ct @kneel_khri = settings.kneel_khri(false) - echo(" @kneel_khri: #{@kneel_khri}") if $debug_mode + echo(" @kneel_khri: #{@kneel_khri}") if $debug_mode_ct @khri_preps = settings.khri_preps([]) - echo(" @khri_preps: #{@khri_preps}") if $debug_mode + echo(" @khri_preps: #{@khri_preps}") if $debug_mode_ct end def execute(game_state) @@ -697,10 +697,10 @@ class ManipulateProcess include DRCT def initialize(settings) - echo('New ManipulateProcess') if $debug_mode + echo('New ManipulateProcess') if $debug_mode_ct @threshold = settings.manipulate_threshold(nil) - echo(" @threshold: #{@threshold}") if $debug_mode + echo(" @threshold: #{@threshold}") if $debug_mode_ct @last_manip = Time.now - 200 end @@ -729,10 +729,10 @@ class TrainerProcess include DRCT def initialize(settings) - echo('New TrainerProcess') if $debug_mode + echo('New TrainerProcess') if $debug_mode_ct @training_abilities = settings.training_abilities({}) - echo(" @training_abilities: #{@training_abilities}") if $debug_mode + echo(" @training_abilities: #{@training_abilities}") if $debug_mode_ct @no_app = [] end @@ -802,7 +802,7 @@ class TrainerProcess def select_ability(game_state) ability = @training_abilities.find { |name, ability_info| check_ability(name, ability_info, game_state) }.first - echo("Selected: #{ability}") if ability && $debug_mode + echo("Selected: #{ability}") if ability && $debug_mode_ct game_state.cooldown_timers[ability] = Time.now ability end @@ -818,34 +818,34 @@ class AttackProcess include DRC def initialize(settings) - echo('New AttackProcess') if $debug_mode + echo('New AttackProcess') if $debug_mode_ct @aim_fillers = settings.aim_fillers([]) - echo(" @aim_fillers: #{@aim_fillers}") if $debug_mode + echo(" @aim_fillers: #{@aim_fillers}") if $debug_mode_ct @aim_fillers_stealth = settings.aim_fillers_stealth({}) - echo(" @aim_fillers_stealth: #{@aim_fillers_stealth}") if $debug_mode + echo(" @aim_fillers_stealth: #{@aim_fillers_stealth}") if $debug_mode_ct @charged_maneuvers = settings.charged_maneuvers({}) - echo(" @charged_maneuvers: #{@charged_maneuvers}") if $debug_mode + echo(" @charged_maneuvers: #{@charged_maneuvers}") if $debug_mode_ct @dance_actions = settings.dance_actions([]) - echo(" @dance_actions: #{@dance_actions}") if $debug_mode + echo(" @dance_actions: #{@dance_actions}") if $debug_mode_ct @dance_actions_stealth = settings.dance_actions_stealth([]) - echo(" @dance_actions_stealth: #{@dance_actions_stealth}") if $debug_mode + echo(" @dance_actions_stealth: #{@dance_actions_stealth}") if $debug_mode_ct @fatigue_regen_threshold = settings.fatigue_regen_threshold(90) - echo(" @fatigue_regen_threshold: #{@fatigue_regen_threshold}") if $debug_mode + echo(" @fatigue_regen_threshold: #{@fatigue_regen_threshold}") if $debug_mode_ct @fatigue_regen_action = settings.fatigue_regen_action('bob') - echo(" @fatigue_regen_action: #{@fatigue_regen_action}") if $debug_mode + echo(" @fatigue_regen_action: #{@fatigue_regen_action}") if $debug_mode_ct @dual_load = settings.dual_load(false) - echo(" @dual_load: #{@dual_load}") if $debug_mode + echo(" @dual_load: #{@dual_load}") if $debug_mode_ct @is_empath = settings.is_empath(false) && !settings.construct(false) - echo(" @is_empath: #{@is_empath}") if $debug_mode + echo(" @is_empath: #{@is_empath}") if $debug_mode_ct Flags.add('ct-ranged-ready', 'You think you have your best shot possible now') end @@ -858,7 +858,7 @@ class AttackProcess end if game_state.dancing? if game_state.finish_killing? - echo('AttackProcess::clean_up') if $debug_mode + echo('AttackProcess::clean_up') if $debug_mode_ct game_state.next_clean_up_step else dance(game_state) @@ -867,8 +867,8 @@ class AttackProcess end if fatigue_low? - echo("***Fatigue: #{DRStats.fatigue}***") if $debug_mode - echo("***Target: #{@fatigue_regen_threshold}***") if $debug_mode + echo("***Fatigue: #{DRStats.fatigue}***") if $debug_mode_ct + echo("***Target: #{@fatigue_regen_threshold}***") if $debug_mode_ct fput(@fatigue_regen_action) return false end @@ -1000,7 +1000,7 @@ class AttackProcess end def get_actions(actions, stealth_actions, weapon_skill) - echo("get_actions #{actions}:#{stealth_actions}") if $debug_mode + echo("get_actions #{actions}:#{stealth_actions}") if $debug_mode_ct (stealth_actions && stealth_actions[weapon_skill] && (DRSkill.getxp('Stealth') < 34)) ? stealth_actions[weapon_skill].dup : actions[weapon_skill].dup end @@ -1024,7 +1024,7 @@ class AttackProcess timer = game_state.cooldown_timers[charged_maneuver] return '' if timer && (Time.now - timer).to_i < 60 - echo "***Ready to use charged maneuver: #{charged_maneuver}***" if $debug_mode + echo "***Ready to use charged maneuver: #{charged_maneuver}***" if $debug_mode_ct charged_maneuver end @@ -1045,7 +1045,7 @@ class CombatTrainer attr_reader :running def stop - echo 'Received stop signal' if $debug_mode + echo 'Received stop signal' if $debug_mode_ct @stop = true end @@ -1062,7 +1062,7 @@ class CombatTrainer settings.construct = construct - debug if should_debug + settings.debug_mode = true if should_debug set_dance(darg, settings) if darg set_retreat(rarg, settings) if rarg app(settings) if should_app @@ -1095,10 +1095,6 @@ class CombatTrainer settings.retreat_threshold = Regexp.last_match(1).to_i end - def debug - $debug_mode = true - end - def setup(settings) Flags.add('ct-spellcast', '^Your formation of a targeting pattern around .+ has completed\.', '^You feel fully prepared to cast your spell\.') @@ -1110,7 +1106,7 @@ class CombatTrainer @stop = false @running = true @game_state = GameState.new(settings) - $debug_mode |= UserVars.combat_trainer_debug + $debug_mode_ct = UserVars.combat_trainer_debug || settings.debug_mode @combat_processes = make_processes(settings) end @@ -1135,7 +1131,7 @@ class CombatTrainer end pause 0.1 if @game_state.done_cleaning_up? - echo('CombatTrainer::clean_up') if $debug_mode + echo('CombatTrainer::clean_up') if $debug_mode_ct @running = false stop_script('tendme') if Script.running?('tendme') break @@ -1153,7 +1149,7 @@ class GameState attr_accessor :mob_died, :action_count, :last_weapon_skill, :danger, :parrying, :casting, :need_bundle, :cooldown_timers, :action_queue, :dance_queue, :no_stab_current_mob, :loaded, :selected_maneuver, :charges, :last_moonblade_cast, :cast_timer, :casting_moonblade, :stance_override def initialize(settings) - echo('New GameState') if $debug_mode + echo('New GameState') if $debug_mode_ct # public @mob_died = false @action_count = 0 @@ -1186,37 +1182,37 @@ class GameState @retreating = false @dance_skill = settings.dance_skill(nil) - echo(" @dance_skill: #{@dance_skill}") if $debug_mode + echo(" @dance_skill: #{@dance_skill}") if $debug_mode_ct @target_action_count = settings.combat_trainer_action_count(10) - echo(" @target_action_count: #{@target_action_count}") if $debug_mode + echo(" @target_action_count: #{@target_action_count}") if $debug_mode_ct @dance_threshold = settings.dance_threshold(0) - echo(" @dance_threshold: #{@dance_threshold}") if $debug_mode + echo(" @dance_threshold: #{@dance_threshold}") if $debug_mode_ct @retreat_threshold = settings.retreat_threshold(nil) - echo(" @retreat_threshold: #{@retreat_threshold}") if $debug_mode + echo(" @retreat_threshold: #{@retreat_threshold}") if $debug_mode_ct @summoned_weapons = settings.summoned_weapons([]) - echo(" @summoned_weapons: #{@summoned_weapons}") if $debug_mode + echo(" @summoned_weapons: #{@summoned_weapons}") if $debug_mode_ct @target_increment = settings.combat_trainer_target_increment(3) - echo(" @target_increment: #{@target_increment}") if $debug_mode + echo(" @target_increment: #{@target_increment}") if $debug_mode_ct @stances = settings.stances([]) - echo(" @stances: #{@stances}") if $debug_mode + echo(" @stances: #{@stances}") if $debug_mode_ct @weapons_to_train = settings.weapon_training({}) - echo(" @weapons_to_train: #{@weapons_to_train}") if $debug_mode + echo(" @weapons_to_train: #{@weapons_to_train}") if $debug_mode_ct @use_stealth_attacks = settings.use_stealth_attacks(false) - echo(" @use_stealth_attacks: #{@use_stealth_attacks}") if $debug_mode + echo(" @use_stealth_attacks: #{@use_stealth_attacks}") if $debug_mode_ct @ambush = settings.ambush(false) - echo(" @ambush: #{@ambush}") if $debug_mode + echo(" @ambush: #{@ambush}") if $debug_mode_ct @backstab = settings.backstab(nil) - echo(" @backstab: #{@backstab}") if $debug_mode + echo(" @backstab: #{@backstab}") if $debug_mode_ct end def next_clean_up_step @@ -1272,8 +1268,8 @@ class GameState def skill_done? current_exp = DRSkill.getxp(@current_weapon_skill) - echo("action count: #{@action_count} vs #{@target_action_count}") if $debug_mode - echo("skill exp: #{current_exp} vs #{@target_weapon_skill}") if $debug_mode + echo("action count: #{@action_count} vs #{@target_action_count}") if $debug_mode_ct + echo("skill exp: #{current_exp} vs #{@target_weapon_skill}") if $debug_mode_ct @action_count >= @target_action_count || current_exp >= @target_weapon_skill end @@ -1304,7 +1300,7 @@ class GameState end def unskinnable(mob_noun) - echo("adding #{mob_noun} to no skin list: #{@no_skins}") if $debug_mode + echo("adding #{mob_noun} to no skin list: #{@no_skins}") if $debug_mode_ct @no_skins.push(mob_noun) end