1 import packets
, nil
.thread
, time
, random
, utility
, configuration
, craw
3 raise_skeleton_skill
= 0x46
4 raise_skeletal_mage_skill
= 0x50
8 ('Raising a skeleton', raise_skeleton_skill
),
9 ('Raising a skeletal mage', raise_skeletal_mage_skill
),
10 ('Reviving a monster', revive_skill
)
13 class summoner_handler_class
:
19 self
.skeleton_mages
= 0
22 nil
.thread
.create_thread(self
.summoner_thread
)
24 def process_bytes(self
, bytes
):
25 if packets
.entering_game(bytes
):
28 add_unit
= packets
.parse_add_unit(bytes
)
30 unit_type
, unit_id
= add_unit
31 #print 'Added unit of type %d: %08x' % (unit_type, unit_id)
33 self
.monsters
.append(unit_id
)
35 object_removal
= packets
.object_removal(bytes
)
36 if object_removal
!= None:
37 type, id = object_removal
39 self
.monsters
.remove(id)
43 def get_targets(self
):
45 for unit_id
in self
.monsters
:
46 monster
= craw
.get_unit(unit_id
, 1)
48 print 'Failed to retrieve the unit of monster %08x' % unit_id
50 if monster
.mode
in [0, 12]:
51 targets
.append(unit_id
)
55 def summoner_thread(self
):
57 player
= utility
.get_my_player()
59 #print 'No summoner unit'
60 time
.sleep(configuration
.summoner_check_delay
)
64 if player
.name
not in configuration
.summoners
:
65 #print 'This is not a summoner'
69 my_unit
= utility
.get_my_unit()
71 print 'Unable to retrieve summoner unit'
74 standing_still
= my_unit
.mode
== 1
75 if standing_still
and not utility
.town_check():
76 targets
= self
.get_targets()
78 craw
.print_text('There are no nearby corpses')
80 target
= random
.choice(targets
)
81 description
, skill
= random
.choice(skills
)
82 craw
.print_text('%s: %08x' % (description
, target
))
83 packets
.set_right_skill(skill
)
84 time
.sleep(configuration
.summoner_switch_delay
)
85 packets
.cast_right_skill_at_target(1, target
)
86 time
.sleep(configuration
.summoner_cast_delay
)
89 time
.sleep(configuration
.summoner_check_delay
)