# HG changeset patch # User Jeremy Thurgood # Date 1251919046 0 # Node ID 4c2fbab20abeb4ac3d915a64e9fb288209b5afff # Parent 55105d3bdab1a1837cc266e2111d30e9af38b2eb Foxes are stealthy now. diff -r 55105d3bdab1 -r 4c2fbab20abe gamelib/animal.py --- a/gamelib/animal.py Wed Sep 02 19:13:54 2009 +0000 +++ b/gamelib/animal.py Wed Sep 02 19:17:26 2009 +0000 @@ -14,6 +14,8 @@ class Animal(Sprite): """Base class for animals""" + STEALTH = 0 + def __init__(self, image_left, image_right, tile_pos): # Create the animal somewhere far off screen Sprite.__init__(self, image_left, (-1000, -1000)) @@ -72,6 +74,8 @@ """Choose a random fox within range of this weapon.""" killable_foxes = [] for fox in gameboard.foxes: + if not visible(self, fox): + continue if weapon.in_range(gameboard, self, fox): killable_foxes.append(fox) if not killable_foxes: @@ -104,6 +108,8 @@ class Fox(Animal): """A fox""" + STEALTH = 20 + costs = { # weighting for movement calculation 'grassland' : 2, @@ -290,6 +296,8 @@ class NinjaFox(Fox): """Ninja foxes are hard to see""" + STEALTH = 60 + class DemoFox(Fox): """Demolition Foxes destroy fences easily""" @@ -305,3 +313,8 @@ self.chickens_eaten += 1 if self.chickens_eaten > 2: self.hunting = False + +def visible(watcher, watchee): + roll = random.randint(1, 100) + distance = watcher.pos.dist(watchee.pos) - 1 + return roll > watchee.STEALTH + 10*distance diff -r 55105d3bdab1 -r 4c2fbab20abe gamelib/equipment.py --- a/gamelib/equipment.py Wed Sep 02 19:13:54 2009 +0000 +++ b/gamelib/equipment.py Wed Sep 02 19:17:26 2009 +0000 @@ -47,7 +47,7 @@ RANGE = 3 BASE_HIT = 50 - RANGE_MODIFIER = 10 + RANGE_MODIFIER = 15 HIT_SOUND = "fire-rifle.ogg" def is_equipment(obj):