Skip to content

Commit

Permalink
Update combat-trainer.lic
Browse files Browse the repository at this point in the history
  • Loading branch information
mdr55 authored Jan 24, 2025
1 parent c18f30a commit 97af569
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions combat-trainer.lic
Original file line number Diff line number Diff line change
Expand Up @@ -4324,6 +4324,10 @@ class GameState
@weapons_to_train.each { |skill_name, _weapon_name| @no_gain_list[skill_name] = 0 }
echo(" @no_gain_list: #{@no_gain_list}") if $debug_mode_ct

@focus_threshold_active = false
@focus_threshold = settings.combat_trainer_focus_threshold
echo(" @focus_threshold: #{@focus_threshold}") if $debug_mode_ct

@use_stealth_attacks = settings.use_stealth_attacks
echo(" @use_stealth_attacks: #{@use_stealth_attacks}") if $debug_mode_ct

Expand Down Expand Up @@ -4862,6 +4866,36 @@ class GameState
end
end

# focus_threshold code: if all the weapons being trained are above focus_threshold,
# @target_increment is set to 34 and @target_action_count to 1000.
# If at any time any weapon is at or below focus_threshold/2, parameters
# are restored to yaml values. The divide by 2 is hysterisis to prevent this
# code from bouncing between the two states. Focus_threshold has a min value of 10 to ensure
# a decent minimum hysterisis band.
# @focus_threshold is mapped to yaml value combat_trainer_focus_threshold
# Setting the yaml value turns this code on, it will remain dormant otherwise.
#
# The code will allow CT to focus on a single weapon once we know all weapons are draining;
# the focus means there is no weapon switching costs being incurred.

if (@focus_threshold > 10) then
if !@focus_threshold_active && weapon_training.reject { |skill, _| DRSkill.getxp(skill) > @focus_threshold }.empty? then
# all weapons above threshold
DRC.message("Focussing on single weapon")
@target_action_count = 1000
@target_increment = 34
@focus_threshold_active = true
return true
elsif @focus_threshold_active && weapon_training.any? { |skill, _| DRSkill.getxp(skill) < (@focus_threshold/2) } then
# any weapon below threshold/2
DRC.message("Spreading attention to all weapons")
@target_action_count = settings.combat_trainer_action_count
@target_increment = settings.combat_trainer_target_increment
@focus_threshold_active = false
return true
end
end

@action_count >= @target_action_count || current_exp >= @target_weapon_skill
end

Expand Down

0 comments on commit 97af569

Please sign in to comment.