Skip to content

Commit

Permalink
Merge pull request #7079 from mdr55/CT-magic-switcheroo
Browse files Browse the repository at this point in the history
  • Loading branch information
MahtraDR authored Jan 29, 2025
2 parents 4b0dd06 + 2e4fa53 commit 9da73e5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
52 changes: 50 additions & 2 deletions combat-trainer.lic
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,9 @@ class SpellProcess
end
echo(" @buff_spells: #{@buff_spells}") if $debug_mode_ct

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

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

Expand All @@ -1307,6 +1310,17 @@ class SpellProcess
@offensive_spell_cycle = settings.offensive_spell_cycle
echo(" @offensive_spell_cycle: #{@offensive_spell_cycle}") if $debug_mode_ct

@magic_last_spell = nil
@magic_last_exp = -1
@magic_last_exp_sorc = -1

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

@magic_no_gain_list = Hash.new(0)
@offensive_spells.each { |spell| @magic_no_gain_list[spell['skill']] = 0 }
echo(" @magic_no_gain_list: #{@magic_no_gain_list}") if $debug_mode_ct

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

Expand Down Expand Up @@ -1517,8 +1531,13 @@ class SpellProcess
check_starlight(game_state)
check_avtalia(game_state)
check_buffs(game_state)
check_training(game_state)
check_offensive(game_state)
if @prioritize_offensive_spells
check_offensive(game_state)
check_training(game_state)
else
check_training(game_state)
check_offensive(game_state)
end
check_current(game_state)

false
Expand Down Expand Up @@ -1770,6 +1789,10 @@ class SpellProcess
game_state.casting_cfb = false
game_state.casting_cfw = false
game_state.casting_cyclic = false

# once spell is cast, check on its mindstate performance and make decision if it needs blacklisting
blacklist_spells(game_state)

if game_state.casting_sorcery
game_state.casting_sorcery = false
@equipment_manager.wield_weapon?(game_state.weapon_name, game_state.weapon_skill)
Expand Down Expand Up @@ -2068,6 +2091,26 @@ class SpellProcess
prepare_spell(data, game_state, true)
end

def blacklist_spells(game_state)
return if game_state.casting

echo "Blacklisting non-training spells:" if $debug_mode_ct

# if there has been no gain from last cast, and its been flagged with cast_only_to_train its a little black cross against the skill
if (DRSkill.getxp(@magic_last_spell['skill']) <= @magic_last_exp) && @magic_last_spell['cast_only_to_train'] && (DRSkill.getxp(@magic_last_spell['skill']) < 34)
@magic_no_gain_list[@magic_last_spell['skill']] += 1
else
@magic_no_gain_list[@magic_last_spell['skill']] = 0
end

# blacklist offensive spell's skill by removing from @offensive_spells if threshold is exceeded
# side effect is that any spells with cast_only_to_train not set will also get hit by blacklist (discord consensus 28/1/2025)
if (@magic_no_gain_list[@magic_last_spell['skill']] > @magic_gain_check)
DRC.message("WARNING: Suppressing #{@magic_last_spell['skill']} due to cast_only_to_train spells within that skill not gaining mindstates.")
@offensive_spells.reject! { |spell| spell['skill'] == @magic_last_spell['skill'] }
end
end

def check_offensive(game_state)
echo "Checking offensive spells:" if $debug_mode_ct
return if game_state.casting
Expand Down Expand Up @@ -2114,6 +2157,11 @@ class SpellProcess
return
end
else
# track last spell for magic_gain_check
@magic_last_spell = data
# if there is a spell to cast, snapshot the relevant skill's mindstate
@magic_last_exp = data.nil? ? -1 : DRSkill.getxp(data['skill'])

prepare_spell(data, game_state)
end

Expand Down
4 changes: 4 additions & 0 deletions profiles/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ summoned_weapons_ingot:
# See combat-trainer documentation above for some attributes.
buff_spells:
combat_buff_waggle:
# Default setting is combat_spell_training: will take priority over offensive_spells:
prioritize_offensive_spells: false
# offensive_spells are what combat-trainer will use offensively.
# See combat-trainer documentation above for some attributes.
offensive_spells:
Expand Down Expand Up @@ -393,6 +395,8 @@ 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
# roughly number of consecutive spell casts of a single skill (e.g. Targeted Magic)that need to not gain mindstate (mob too low) before it is blacklisted.
combat_trainer_magic_gain_check: 3

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 9da73e5

Please sign in to comment.