mirror of
https://github.com/evennia/evennia.git
synced 2026-03-23 08:16:30 +01:00
Moved distance_inc back to being its own function
I almost forgot - distance_inc is actually used by both 'approach' and 'withdraw', since approaching an object might put you farther away from others. So, I moved it back to its own function.
This commit is contained in:
parent
95f840ac7a
commit
1fe9bf3dce
1 changed files with 15 additions and 14 deletions
|
|
@ -310,6 +310,21 @@ def get_range(obj1, obj2):
|
|||
return None
|
||||
# Return the range between the two objects.
|
||||
return obj1.db.combat_range[obj2]
|
||||
|
||||
def distance_inc(mover, target):
|
||||
"""
|
||||
Function that increases distance in range field between mover and target.
|
||||
|
||||
Args:
|
||||
mover (obj): The object moving
|
||||
target (obj): The object to be moved away from
|
||||
"""
|
||||
mover.db.combat_range[target] += 1
|
||||
target.db.combat_range[mover] = mover.db.combat_range[target]
|
||||
# Set a cap of 2:
|
||||
if get_range(mover, target) > 2:
|
||||
target.db.combat_range[mover] = 2
|
||||
mover.db.combat_range[target] = 2
|
||||
|
||||
def approach(mover, target):
|
||||
"""
|
||||
|
|
@ -370,20 +385,6 @@ def withdraw(mover, target):
|
|||
of their withdrawl. The mover will never inadvertently move toward anything else while
|
||||
withdrawing - they can be considered to be moving to open space.
|
||||
"""
|
||||
def distance_inc(mover, target):
|
||||
"""
|
||||
Helper function that increases distance in range field between mover and target.
|
||||
|
||||
Args:
|
||||
mover (obj): The object moving
|
||||
target (obj): The object to be moved away from
|
||||
"""
|
||||
mover.db.combat_range[target] += 1
|
||||
target.db.combat_range[mover] = mover.db.combat_range[target]
|
||||
# Set a cap of 2:
|
||||
if get_range(mover, target) > 2:
|
||||
target.db.combat_range[mover] = 2
|
||||
mover.db.combat_range[target] = 2
|
||||
|
||||
contents = mover.location.contents
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue