Changeset 199:696936621a93


Ignore:
Timestamp:
Sep 4, 2009, 7:49:30 PM (11 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68@200
Message:

Buildings can affect visual acuity.

Location:
gamelib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gamelib/animal.py

    r196 r199  
    1616
    1717    STEALTH = 0
     18    VISION_BONUS = 0
     19    VISION_RANGE_PENALTY = 10
    1820
    1921    def __init__(self, image_left, image_right, tile_pos):
     
    416418        self.last_steps = []
    417419
     420def _get_vision_param(parameter, watcher):
     421    param = getattr(watcher, parameter)
     422    if watcher.abode:
     423        modifier = getattr(watcher.abode.building, 'MODIFY_'+parameter, lambda r: r)
     424        param = modifier(param)
     425    return param
     426
    418427def visible(watcher, watchee):
     428    vision_bonus = _get_vision_param('VISION_BONUS', watcher)
     429    range_penalty = _get_vision_param('VISION_RANGE_PENALTY', watcher)
     430    distance = watcher.pos.dist(watchee.pos) - 1
    419431    roll = random.randint(1, 100)
    420     distance = watcher.pos.dist(watchee.pos) - 1
    421     return roll > watchee.STEALTH + 10*distance
     432    return roll > watchee.STEALTH - vision_bonus + range_penalty*distance
  • gamelib/buildings.py

    r198 r199  
    215215    MODIFY_GUN_BASE_HIT = lambda s, x: x-5
    216216    MODIFY_GUN_RANGE_PENALTY = lambda s, x: x-1
     217    MODIFY_VISION_BONUS = lambda s, x: x+10
     218    MODIFY_VISION_RANGE_PENALTY = lambda s, x: x-2
    217219
    218220def is_building(obj):
Note: See TracChangeset for help on using the changeset viewer.