-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathspot_definitons.py
106 lines (77 loc) · 2.22 KB
/
spot_definitons.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
from pythonspot import *
NORTH = 0
EAST = 1
SOUTH = 2
WEST = 3
STAY = 5
ACTION_USE = 0
ACTION_SKILL = 1
ACTION_MAGIC = 3
ACTION_MOVE = 5
ACTION_TIMER = 6
ACTION_TRADE = 7
ACTION_ATTACK = 8
ACTION_GET = 9
ACTION_QUESTION = 0xb
ACTION_BUY = 0xc
ACTION_TALK = 0xd
EVERYBODY = 0xf0
LEADER = 0xf4
RINGBEARER = 0xf7
FRODO = 0xa0
SAM = 0xa1
HOBBIT = 0x88
WOMAN_HOBBIT = 0x89
ORC = 0x94
NAZGUL = 0x95
RING = 0x94
def default_action_func(spot):
pass
class Action:
type = None
param = None
npc = None
func = default_action_func
def __init__(self, type, param, npc, func):
self.type = type
self.param = param
self.npc = npc
self.func = func
if func == None:
self.func = default_action_func
def match(self, type = None, param = None, npc = None):
return (self.type == None or self.type == type or type == 0xff) and \
(self.param == None or self.param == param or param == 0xff) and \
(self.npc == None or self.npc == npc or npc == 0xff)
def default_start(self):
pass
def default_continue(self):
return 0
class PythonSpot:
def __init__(self, map, x, y, w, h):
self.map = map
self.x = x
self.y = y
self.w = w
self.h = h
self.start_func = default_start
self.cont_func = default_continue
def start(self):
self.actions = []
self.start_func(self)
def cont(self):
result = self.cont_func(self)
if result != None: return result
return 0
def add_action(self, type=None, param=None, npc=None, func=None):
self.actions.append(Action(type, param, npc, func))
def has_action(self, type=None, param=None, npc=None):
for i in range(len(self.actions)):
if self.actions[i].match(type, param, npc): return 1
return 0
def action(self, type=None, param=None, npc=None):
for i in range(len(self.actions)):
if self.actions[i].match(type, param, npc):
self.actions[i].func(self)
break
emptyspot = PythonSpot(0xffff, 0xffff, 0xffff, 0, 0)