Mercurial > fife-parpg
comparison clients/rio_de_hola/scripts/hero.py @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 import random | |
2 from agent import Agent | |
3 import settings as TDS | |
4 | |
5 _STATE_NONE, _STATE_IDLE, _STATE_RUN, _STATE_KICK, _STATE_TALK = xrange(5) | |
6 | |
7 class Hero(Agent): | |
8 def __init__(self, model, agentName, layer, uniqInMap=True): | |
9 super(Hero, self).__init__(model, agentName, layer, uniqInMap) | |
10 self.state = _STATE_NONE | |
11 self.idlecounter = 1 | |
12 | |
13 def onInstanceActionFinished(self, instance, action): | |
14 self.idle() | |
15 if action.getId() != 'stand': | |
16 self.idlecounter = 1 | |
17 else: | |
18 self.idlecounter += 1 | |
19 if self.idlecounter % 7 == 0: | |
20 txtindex = random.randint(0, len(TDS.heroTexts) - 1) | |
21 instance.say(TDS.heroTexts[txtindex], 2500) | |
22 | |
23 def start(self): | |
24 self.idle() | |
25 | |
26 def idle(self): | |
27 self.state = _STATE_IDLE | |
28 self.agent.act('stand', self.agent.getFacingLocation()) | |
29 | |
30 def run(self, location): | |
31 self.state = _STATE_RUN | |
32 self.agent.move('run', location, 4 * TDS.TestAgentSpeed) | |
33 | |
34 def kick(self, target): | |
35 self.state = _STATE_KICK | |
36 self.agent.act('kick', target) | |
37 | |
38 def talk(self, target): | |
39 self.state = _STATE_TALK | |
40 self.agent.act('talk', target) |