Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[script][combat-trainer] Stop training untrainable weapon skills in CT - optional feature #7068

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
29 changes: 29 additions & 0 deletions combat-trainer.lic
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class SetupProcess
echo('new skill needed for training') if $debug_mode_ct

game_state.reset_action_count
@last_exp = -1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this assignment for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've just switched weapons so the old @last_exp is no longer valid. The new weapon's @last_exp = -1 guarantees it will pass the mindstate portion of the check. Its not strictly necessary, worst case is new weapon gets a mark against it, only to be reset to 0 at the cycle after. But its nice to reset properly on weapon change, seeing as line 176 does something similar.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, you can add an attr reader for it in GameState, then just reference game_state.last_exp here instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaah right, scoping, i'll fix that. it mustn't have been working before?


# If you're training with summoned moon weapons but you haven't cast the moonblade spell yet
# then skip those weapon skills and train something else while we wait for moonblade spell to be cast.
Expand Down Expand Up @@ -4312,6 +4313,11 @@ class GameState
$ranged_skills << 'Brawling'
end

@last_exp = -1
@no_gain_list = Hash.new(0)
@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

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

Expand Down Expand Up @@ -4821,6 +4827,29 @@ class GameState
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

# gain_check code: logic to account for a skill that is not gaining any MS at all
if @gain_check && (weapon_skill != nil) then
if (current_exp <= @last_exp) && (current_exp != 34) && (@weapons_to_train.size > 1) then
@no_gain_list[weapon_skill] += 1
else
@no_gain_list[weapon_skill] = 0
end
@last_exp = current_exp
echo("updated @no_gain_list: #{@no_gain_list}") if $debug_mode_ct

# blacklist skill if it hasn't been gaining for a while
if (@no_gain_list[weapon_skill] > @gain_check) then
DRC.message("WARNING: Supppressing #{weapon_skill} due to skill not training")
@weapons_to_train.delete(weapon_skill)
return true
end

# if weapon is at 34, don't black list but do (try to) switch weapons.
if current_exp == 34 then
return true
end
end

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

Expand Down
Loading