from evennia.utils import inherits_from, logger from typeclasses.characters import Character from typeclasses.scripts import Script from typeclasses.rooms import IndoorRoom from utils.utils import has_tag, toggle_effect, has_effect class EffectMagicalLight(Script): """ """ def at_script_creation(self): self.key = "effect_magic_light_script" self.desc = "not now" self.start_delay = True self.interval = 20 self.persistent = True # will survive reload self.repeats = 1 def at_start(self): if self.obj: if not has_effect(self.obj, "emit_magic_light"): toggle_effect(self.obj, "emit_magic_light") if self.obj.location: if inherits_from(self.obj.location, IndoorRoom): self.obj.location.msg_contents("{} starts emitting a soft and steady light.".format(self.obj.name)) self.obj.location.check_light_state() # check if effect target is in actor contents if self.obj.location.location and inherits_from(self.obj.location.location, IndoorRoom): if inherits_from(self.obj.location, Character): self.obj.location.msg("{} starts emitting a soft and steady light.".format(self.obj.name)) self.obj.location.location.check_light_state() def at_stop(self): if self.obj: if has_effect(self.obj, "emit_magic_light"): toggle_effect(self.obj, "emit_magic_light") if self.obj.location: if inherits_from(self.obj.location, IndoorRoom): self.obj.location.msg_contents("{} stops emitting light.".format(self.obj.name)) self.obj.location.check_light_state() # check if effect target is in actor contents if self.obj.location.location and inherits_from(self.obj.location.location, IndoorRoom): if inherits_from(self.obj.location, Character): self.obj.location.msg("{} stops emitting light.".format(self.obj.name)) self.obj.location.location.check_light_state() def at_repeat(self): self.at_stop() class EffectCharm(Script): """ """ def at_script_creation(self): self.key = "effect_charm_script" self.desc = "not now" self.start_delay = True self.interval = 20 self.persistent = True # will survive reload self.repeats = 1 def at_start(self): if self.obj: if not has_effect(self.obj, "charm"): toggle_effect(self.obj, "charm") self.obj.db.real_owner = self.obj.db.owner self.obj.db.owner = self.db.source def at_stop(self): if self.obj: if has_effect(self.obj, "charm"): toggle_effect(self.obj, "charm") self.obj.db.owner = self.obj.db.real_owner del self.obj.db.real_owner def at_repeat(self): self.at_stop()