Mercurial > parpg-core
comparison src/parpg/behaviours/npc.py @ 133:ecac92680bef
Added animation queue and method the base behaviour class.
author | KarstenBock@gmx.net |
---|---|
date | Fri, 30 Sep 2011 14:04:29 +0200 |
parents | 9f8faf6e974d |
children | 704145b96171 |
comparison
equal
deleted
inserted
replaced
132:ccf4d6cffcf1 | 133:ecac92680bef |
---|---|
27 | 27 |
28 self.parent = parent | 28 self.parent = parent |
29 self.state = base._AGENT_STATE_NONE | 29 self.state = base._AGENT_STATE_NONE |
30 self.pc = None | 30 self.pc = None |
31 self.target_loc = None | 31 self.target_loc = None |
32 self.nextAction = None | |
33 | 32 |
34 # hard code these for now | 33 # hard code these for now |
35 self.distRange = (2, 4) | 34 self.distRange = (2, 4) |
36 # these are parameters to lower the rate of wandering | 35 # these are parameters to lower the rate of wandering |
37 # wander rate is the number of "IDLEs" before a wander step | 36 # wander rate is the number of "IDLEs" before a wander step |
79 """Controls the NPC when it is idling. Different actions | 78 """Controls the NPC when it is idling. Different actions |
80 based on the NPC's state. | 79 based on the NPC's state. |
81 @return: None""" | 80 @return: None""" |
82 if self.state == base._AGENT_STATE_NONE: | 81 if self.state == base._AGENT_STATE_NONE: |
83 self.state = base._AGENT_STATE_IDLE | 82 self.state = base._AGENT_STATE_IDLE |
84 self.agent.act('stand', self.agent.getFacingLocation()) | 83 self.animate('stand') |
85 elif self.state == base._AGENT_STATE_IDLE: | 84 elif self.state == base._AGENT_STATE_IDLE: |
86 if self.wanderCounter > self.wanderRate: | 85 if self.wanderCounter > self.wanderRate: |
87 self.wanderCounter = 0 | 86 self.wanderCounter = 0 |
88 self.state = base._AGENT_STATE_WANDER | 87 self.state = base._AGENT_STATE_WANDER |
89 else: | 88 else: |
90 self.wanderCounter += 1 | 89 self.wanderCounter += 1 |
91 self.state = base._AGENT_STATE_NONE | 90 self.state = base._AGENT_STATE_NONE |
92 | 91 |
93 self.target_loc = self.getTargetLocation() | 92 self.target_loc = self.getTargetLocation() |
94 self.agent.act('stand', self.agent.getFacingLocation()) | 93 self.animate('stand') |
95 elif self.state == base._AGENT_STATE_WANDER: | 94 elif self.state == base._AGENT_STATE_WANDER: |
96 self.wander(self.target_loc) | 95 self.wander(self.target_loc) |
97 self.state = base._AGENT_STATE_NONE | 96 self.state = base._AGENT_STATE_NONE |
98 elif self.state == base._AGENT_STATE_TALK: | 97 elif self.state == base._AGENT_STATE_TALK: |
99 self.agent.act('stand', self.pc.getLocation()) | 98 self.animate('stand', self.pc.getLocation()) |
100 | 99 |
101 def wander(self, location): | 100 def wander(self, location): |
102 """Nice slow movement for random walking. | 101 """Nice slow movement for random walking. |
103 @type location: fife.Location | 102 @type location: fife.Location |
104 @param location: Where the NPC will walk to. | 103 @param location: Where the NPC will walk to. |