-
Notifications
You must be signed in to change notification settings - Fork 1
/
combat.py
107 lines (95 loc) · 3.72 KB
/
combat.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
from enum import IntEnum
import random
import time
from Action import Action
class HuntingGround(IntEnum):
Island = 0
Sewers = 1
class combat:
def __init__(self, tec):
self.tec = tec
self.rotation = [['zzh', 'zxh', 'zch', 'zvh', 'zbh', 'znh', 'zmh', 'za', 'zsh'],
['zz', 'zx', 'zc', 'zv', 'zb', 'zn', 'za', 'zm', 'zs', 'zd', 'zd', 'zm']]##'zf']]
self.retreat = False
self.hunting_ground = HuntingGround.Sewers
def recover(self):
self.tec.send_cmd("get tin dagg")
time.sleep(random.randrange(1234, 2512) / 1000)
self.tec.send_cmd("wie tin dagg")
def handle_recover(self, recoverNow):
self.tec.add_action(Action.recover)
if recoverNow:
self.perform_action()
def attack(self):
index = random.randrange(0, len(self.rotation[self.hunting_ground]))
cmd = self.rotation[self.hunting_ground][index]
self.tec.send_cmd(cmd)
self.tec.add_action(Action.attack)
def combat_release(self):
pass
def retreat(self, isRetreating):
retreat = isRetreating
pass
def perform_action(self):
if self.tec.free and len(self.tec.queue) > 0:
self.tec.action = self.tec.queue.pop()
print("CAction: "+ str(self.tec.action))
if self.tec.action == Action.recover:
self.recover()
elif self.tec.action == Action.retreat:
self.tec.free = False
elif self.tec.action == Action.kill:
self.tec.free = False
self.tec.add_action(Action.kill)
self.tec.send_cmd("kl")
elif self.tec.action == Action.attack:
self.tec.free = False
self.attack()
elif self.tec.action == Action.release:
self.tec.send_cmd("release")
else:
self.tec.perform_action()
# We are in combat
def handle_combat_line(self, line):
me = True
if "You are no longer busy." in line:
print("Not Busy")
self.tec.free = True
self.perform_action()
elif "expires." in line:
self.tec.remove_action(Action.kill)
#self.tec.add_action(Action.combat_skin)
print("Dead")
self.tec.in_combat = False
elif "falls unconscious" in line:
print("Unconscious")
self.tec.remove_action(Action.attack)
self.tec.add_action(Action.kill)
if self.tec.free:
self.perform_action()
elif "You fumble!" in line:
self.handle_recover(False)
elif "You must be wielding a weapon to attack." in line or "You can't do that right now." in line:
self.handle_recover(True)
elif "clamped onto you" in line:
self.tec.add_action(Action.release)
elif "You manage to break free!" in line:
self.tec.remove_action(Action.release)
elif "must be unconscious first" in line:
self.tec.remove_action(Action.kill)
self.tec.free = True
elif "[" in line:
if "] A" in line or "] An" in line:
self.tec.add_action(Action.attack)
me = False
if self.tec.free:
print("Free, attacking")
self.perform_action()
elif "You slit" in line:
print("Killed")
self.tec.remove_action(Action.kill)
#self.tec.add_action(Action.combat_skin)
self.tec.in_combat = False
roll = self.tec.rollPattern.search(line)
if me:
self.tec.action_status = int(roll.group(1)) < int(roll.group(2))