Changeset 704


Ignore:
Timestamp:
01/09/11 22:29:14 (9 years ago)
Author:
zenbitz
Message:

make NPCs wander slower

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/objects/actors.py

    r627 r704  
    125125        self.nextAction = None 
    126126         
    127         # hard code this for now 
     127        # hard code these for now 
    128128        self.distRange = (2, 4) 
     129        # these are parameters to lower the rate of wandering 
     130        # wander rate is the number of "IDLEs" before a wander step 
     131        # this could be set for individual NPCs at load time 
     132        # or thrown out altogether. 
     133        self.wanderCounter = 0 
     134        self.wanderRate = 9 
    129135         
    130136    def getTargetLocation(self): 
     
    172178            self.agent.act('stand', self.agent.getFacingLocation()) 
    173179        elif self.state == _AGENT_STATE_IDLE: 
     180            if self.wanderCounter > self.wanderRate: 
     181                self.wanderCounter = 0 
     182                self.state = _AGENT_STATE_WANDER 
     183            else: 
     184                self.wanderCounter += 1 
     185                self.state = _AGENT_STATE_NONE 
     186             
    174187            self.target_loc = self.getTargetLocation() 
    175             self.state = _AGENT_STATE_WANDER 
    176188            self.agent.act('stand', self.agent.getFacingLocation()) 
    177189        elif self.state == _AGENT_STATE_WANDER: 
Note: See TracChangeset for help on using the changeset viewer.