Changeset 415:9d2a8dfba670


Ignore:
Timestamp:
Sep 7, 2013, 10:50:21 AM (7 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Children:
416:bea0ea5b98df, 419:3f15e071614f
rebase_source:
23acc254e1be6d35c2c8525782712208d1ff1aed
Message:

Sheep behaviour.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/enemies.py

    r410 r415  
    308308    impulse_factor = 50
    309309
    310     vision_range = 100
     310    human_vision_range = 100
     311    wolf_vision_range = 200
    311312
    312313    def make_physics(self, space, position):
     
    320321    def move(self, result):
    321322        vec = self.range_to_visible_protagonist()
    322         if vec is not None and vec.length < self.vision_range:
    323             # TODO: Run away! Wander towards!
    324             step = (0, 0)
    325         else:
     323        prot = self.world.protagonist
     324        step = None
     325        if vec is not None:
     326            if prot.in_human_form() and vec.length < self.human_vision_range:
     327                step = vec.int_tuple
     328            if prot.in_wolf_form() and vec.length < self.wolf_vision_range:
     329                step = (-vec).int_tuple
     330        if step is None:
    326331            step = self.random_move()
    327332        self.set_direction(*step)
Note: See TracChangeset for help on using the changeset viewer.