forked from ScriptB3ast/razor-enhanced
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pvm_pvp_healPets.py
149 lines (125 loc) · 5.36 KB
/
pvm_pvp_healPets.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
from Scripts.utilities.items import FindItem
from Scripts.glossary.colors import colors
from System.Collections.Generic import List
if Misc.ShardName() == 'UO Evolution':
petsToCheck = [
0x002A6E71, # Horse
0x0015D121, # Zazzy
]
else:
petsToCheck = [
0x00048E19, # Saphira
0x00102404, # Your Darkest Nightmare
0x00189E83, # an avian steed
0x00302246, # Bid'Daum
0x0001801E, # Metalicana
0x0009CA1B, # Toothless
0x000EAFDB, # The Darkness
0x0025E1FA, # Nocturnal llama
0x00064ECB, # Izzo
0x00088F42, # Give Me Relic
]
#for pet in petsToCheck:
# Timer.Create( 'distanceTimer%s' % pet, 1 )
def TestBandagesApplying():
# Fetch the Journal entries (oldest to newest)
regularText = Journal.GetTextByType( 'Regular' )
# Reverse the Journal entries so that we read from newest to oldest
regularText.Reverse()
# Read back until the bandages were started to see if they have finished applying
for line in regularText[ 0 : len( regularText ) ]:
if line == 'You begin applying the bandages.':
break
if ( line == 'You finish applying the bandages.' or
line == 'You heal what little damage your patient had.' or
line == 'You did not stay close enough to heal your patient!' or
line == 'You apply the bandages, but they barely help.' or
line == 'That being is not damaged!' or
line == 'You fail to resurrect the creature.' or
line == 'You are able to resurrect your patient.' or
line == 'You have cured the target of all poisons!' or
line == 'That is too far away.' ):
return False
return True
def WaitForBandagesToApply():
bandageDone = False
secondsCounter = 0
while TestBandagesApplying():
Misc.Pause( 1000 )
secondsCounter += 1
Misc.SendMessage( '%i seconds since bandage started' % ( secondsCounter ) )
return
def HealPets():
global petsToCheck
bandages = FindItem( 0x0E21, Player.Backpack )
if bandages == None:
Misc.SendMessage( 'Out of bandages!', colors[ 'red' ] )
return
#Misc.SendMessage( 'healing pets' )
petFilter = Mobiles.Filter()
petFilter.RangeMin = 0
petFilter.RangeMax = 1
petFilter.IsHuman = 0
petFilter.IsGhost = 0
petFilter.Friend = 1
pets = Mobiles.ApplyFilter( petFilter )
if len( pets ) == 0:
return
petToHeal = Mobiles.Select( pets, 'Weakest' )
if petToHeal.Hits == petToHeal.HitsMax:
petFilter.Poisoned = 1
pets = Mobiles.ApplyFilter( petFilter )
if len( pets ) == 0:
return
else:
petToHeal = Mobiles.Select( pets, 'Weakest' )
Items.UseItem( bandages )
Target.WaitForTarget( 10000, False )
Target.TargetExecute( petToHeal )
Player.HeadMessage( colors[ 'cyan' ], 'Applying bandage on %s (currently %i%% health)' % ( petToHeal.Name, ( float( petToHeal.Hits ) / float( petToHeal.HitsMax ) * 100 ) ) )
Misc.Pause( 200 )
WaitForBandagesToApply()
return
for petSerial in petsToCheck:
pet = Mobiles.FindBySerial( petSerial )
if pet == None:
continue
#Misc.SendMessage( 'Checking %s\'s health' % pet.Name )
if Misc.ShardName() == 'UO Evolution':
maxDistance = 2
else:
maxDistance = 1
if pet.Hits < pet.HitsMax or pet.Poisoned:
if Player.DistanceTo( pet ) > maxDistance:
if not Timer.Check( 'distanceTimer%s' % petSerial ):
Misc.SendMessage( 'Too far away from %s to apply bandages' % ( pet.Name ), colors[ 'red' ] )
Timer.Create( 'distanceTimer%s' % petSerial, 1000 )
continue
Items.UseItem( bandages )
Target.WaitForTarget( 10000, False )
Target.TargetExecute( pet )
Player.HeadMessage( colors[ 'cyan' ], 'Applying bandage on %s (currently %i%% health)' % ( pet.Name, ( float( pet.Hits ) / float( pet.HitsMax ) * 100 ) ) )
Misc.Pause( 200 )
bandageDone = False
while not bandageDone:
regularText = Journal.GetTextByType( 'Regular' )
regularText.Reverse()
for line in regularText[ 0 : len( regularText ) ]:
if line == 'You begin applying the bandages.':
break
if ( line == 'You finish applying the bandages.' or
line == 'You heal what little damage your patient had.' or
line == 'You did not stay close enough to heal your patient!' or
line == 'You apply the bandages, but they barely help.' or
line == 'That being is not damaged!' or
line == 'You fail to resurrect the creature.' or
line == 'You are able to resurrect your patient.' or
line == 'You have cured the target of all poisons!' ):
bandageDone = True
Misc.Pause( 100 )
break
Misc.Pause( 50 )
return
while not Player.IsGhost:
HealPets()
Misc.Pause( 150 )