Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- Version:
- Chuno, v1.0 - 6/23/19
- Dragonrealms Magic Training Script
- This is mainly useful for befores and afters. It doesn't use combat_spell_training:
- Reason: Sometimes you want different spells apart from those and it supports straight sorcery
- Requirements:
- Dependency: https://elanthipedia.play.net/Dependency
- You can remove or add any of the magics listed below and it will adjust.
- YAML Setup with a "magic_training" section:
- Example:
- magic_training
- Augmentation:
- abbrev: sap
- symbiosis: true
- cast: cast debil
- mana: 25
- cambrinth:
- - 25
- Warding:
- abbrev: maf
- symbiosis: true
- mana: 25
- cambrinth:
- - 25
- Utility:
- abbrev: bless
- symbiosis: true
- mana: 25
- cambrinth:
- - 25
- Sorcery:
- abbrev: pg
- symbiosis: false
- mana: 15
- cambrinth:
- - 15
- Note:
- You can change and save settings on the fly, and the trainer
- will get the new mana levels/spell on the next time through.
- * This is very useful for finding max training limits for spells
- =end
- custom_require.call(%w[common common-arcana])
- class MagicTraining
- include DRC
- include DRCA
- def initialize
- settings = get_settings
- #Change these values to whatever you want in your yaml, or use these defaults
- #stops training if mana falls below threshold and waits for more mana
- mana_threshold = settings.training_spell_mana_threshold || 40 #percentage
- #stops training specfic skill after threshold, and quits program when all are above
- exp_threshold = settings.combat_spell_training_max_threshold || 20
- loop do
- if mana > mana_threshold
- return unless train_magics(mana_threshold, exp_threshold)
- else
- echo "Waiting for mana..."
- pause 10
- end
- end
- end
- def train_magics(mana_threshold, exp_threshold)
- settings = get_settings # This is redone purposely so you can adjust this on the fly, it's great for finding mana values
- magics = settings.magic_training
- skills_to_train = magics.keys
- .select { |skill| %w[Utility Warding Augmentation Sorcery].include? skill }
- .reject { |skill| DRSkill.getxp(skill) > exp_threshold }
- return false if skills_to_train.empty?
- skills_to_train.sort_by { |skill| DRSkill.getxp(skill) }
- .each { |skill|
- # Get settings here so I can update on the fly
- echo "Training: #{skill}"
- spell_data = magics[skill]
- before_xp = DRSkill.getxp(skill)
- if mana < mana_threshold
- echo "Waiting on mana..."
- pause 2 until mana > mana_threshold
- end
- cast_spell(spell_data, settings, true)
- echo "#{skill} gains: #{DRSkill.getxp(skill) - before_xp}"
- }
- true
- end
- end
- before_dying do
- fput('release spell')
- fput('release sym')
- end
- MagicTraining.new
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement