-
Notifications
You must be signed in to change notification settings - Fork 27
/
train_Magery.py
108 lines (89 loc) · 4.14 KB
/
train_Magery.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
'''
Author: TheWarDoctor95
Other Contributors:
Last Contribution By: TheWarDoctor95 - March 23, 2019
Description: Uses the recommended spells from the UO Forever Wiki (https://www.uoforum.com/wiki/index.php/Magery)
to level Magery to GM. Will also increase Meditation if the skill is set to Up and not maxed out while running
'''
# Change this to False if you want to use all of the reagents in your backpack
saveReagentsForRecall = True
# Change this to the number of recall spells you want to be able to cast
numberOfRecallsToSaveFor = 3
# Change this to the number of extra milliseconds to delay between casts
# This will vary depending on which shard you are on
additionalShardCooldown = 900
from Scripts.glossary.spells import reagents, spells
from Scripts.utilities.items import FindNumberOfItems
from Scripts.glossary.colors import colors
mageryTimerMilliseconds = 6500
meditationTimerMilliseconds = 8200
def FindReagents():
'''
Uses FindNumberOfItems to find an the reagents in the player's backpack
Returns a dictionary of the reagents found
'''
global reagents
reagentItemIDs = []
for reagent in reagents:
reagentItemIDs.append( reagents[ reagent ].itemID )
numberOfReagentsFound = FindNumberOfItems( reagentItemIDs, Player.Backpack )
return numberOfReagentsFound
def CheckReagents( spellName, numberOfCasts = 1 ):
'''
Checks if the necessary reagents are available in the player's backpack to use a spell
'''
global spellInfo
reagentsInBackpack = FindReagents()
reagentsNeeded = spells[ spellName ].reagents
for reagent in reagentsNeeded:
if reagentsInBackpack[ reagent.itemID ] < numberOfCasts:
return False
return True
def TrainMagery():
'''
Trains Magery by casting spells on the player
Stops training if the player runs out of the necessary reagents
'''
global mageryTimerMilliseconds
global meditationTimerMilliseconds
Timer.Create( 'mageryTimer', 1 )
while not Player.IsGhost and Player.GetRealSkillValue( 'Magery' ) < Player.GetSkillCap( 'Magery' ):
if saveReagentsForRecall and not CheckReagents( 'Recall', numberOfRecallsToSaveFor + 1 ):
Misc.SendMessage( 'Need to save reagents for recall!', colors[ 'red' ] )
return
if not Timer.Check( 'mageryTimer' ):
if Player.GetSkillValue( 'Magery' ) < 62.8:
spell = spells[ 'Mana Drain' ]
elif Player.GetSkillValue( 'Magery' ) < 75.5:
spell = spells[ 'Invisibility' ]
else:
spell = spells[ 'Mana Vampire' ]
if not CheckReagents( spell.name ):
reagentsNeeded = spell.reagents
reagentsNeededAsString = ''
for reagent in reagentsNeeded:
reagentsNeededAsString += reagent.name + ','
# Remove the extra comma from the string
reagentsNeededAsString[ : -1 ]
Misc.SendMessage( 'Ran out of regs for %s! These regs are needed: %s' % ( spell.name, reagentsNeededAsString ), colors[ 'red' ] )
break
if Player.Mana > spell.manaCost:
Spells.CastMagery( spell.name )
# Wait an extra 100 ms in case of latency
Timer.Create( 'mageryTimer', spell.delayInMs + additionalShardCooldown )
# Target the cast spell on the player
Target.WaitForTarget( 2000, True )
Target.TargetExecute( Player.Serial )
else:
Player.UseSkill( 'Meditation' )
Timer.Create( 'meditationTimer', meditationTimerMilliseconds )
Misc.Pause( 200 )
while Player.Mana < spell.manaCost + 1:
if not Player.BuffsExist( 'Meditation' ) and not Timer.Check( 'meditationTimer' ):
Player.UseSkill( 'Meditation' )
Timer.Create( 'meditationTimer', meditationTimerMilliseconds )
Misc.Pause( 200 )
# Wait a little bit so that the while loop doesn't consume as much CPU
Misc.Pause( 50 )
# Start the training
TrainMagery()