def ApplyAnimation(character, animation, keep=False, **kwargs):
cam = bge.logic.getCurrentScene().active_camera
if character in Reuse.reuse.get(character.name, [])\
or cam.getDistanceTo(character) > 150:
return
rig = getRig(character)
action = rig.get("Action")
startframe = animation[0]
endframe = animation[1]
if not action:
return
if type(animation) == str and animation in animations.get(character.name, {}):
data = animations[character.name][animation]
action = data.get("Action", action)
keep = data.get("Keep", keep)
startframe = data["Frames"][0]
endframe = data["Frames"][1]
kwargs = data.get("kwargs", kwargs)
elif type(animation) == str:
startframe = 0
endframe = 0
if keep and rig.getActionFrame(kwargs.get("layer", 0)) == endframe:
startframe = endframe
rig.playAction(action, startframe, endframe, **kwargs)
if kwargs.get("layer", 0) == 0:
rig["animation"] = animation
Character.ApplyAnimation(dani, "AnswerPhone")
if dani.getDistanceTo(house) < 600 and not dani.get("race"):
if bge.logic.getRealTime() > Story.get("lastring", 20):
Story["ringing"] = RingPhone()
Story["lastring"] = bge.logic.getRealTime() + 400