Skip to content

Commit

Permalink
Merge branch 'main' into CT-offhand-trainables
Browse files Browse the repository at this point in the history
  • Loading branch information
MahtraDR authored Jan 26, 2025
2 parents 9b09359 + ae152f0 commit 9dceaa5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
35 changes: 35 additions & 0 deletions combat-trainer.lic
Original file line number Diff line number Diff line change
Expand Up @@ -4369,6 +4369,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 @@ -4907,6 +4911,37 @@ 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)
if !@focus_threshold_active && weapon_training.reject { |skill, _| DRSkill.getxp(skill) > @focus_threshold }.empty?
# 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) }
# 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
else
return false
end
end
@action_count >= @target_action_count || current_exp >= @target_weapon_skill
end

Expand Down
4 changes: 4 additions & 0 deletions profiles/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ combat_trainer_action_count: 10
# Optional feature to preference using aiming_trainables on the offhand ONLY, to reduce competition from aiming_trainables using mainhand attacks
# It is contingent on combat_trainer_focus_threshold being active.
combat_trainer_offhand_trainables: false
# minimum mindstate threshold (for all weapons being trained) to begin focussing on single weapons to minimise weapon switching.
# default is 0 which means feature is not active. Change to 10 or higher to activate.
combat_trainer_focus_threshold: 0


dual_load: false
# use_stealth_attacks true will train stealth by hiding and attacking/backstabbing from stealth. Thieves also use backstab: below
Expand Down

0 comments on commit 9dceaa5

Please sign in to comment.