63 lines
No EOL
2 KiB
Python
63 lines
No EOL
2 KiB
Python
from evennia import create_script
|
|
from typeclasses import effects
|
|
from utils.utils import has_effect
|
|
|
|
from utils.spells import Spell
|
|
|
|
|
|
class LightSpell(Spell):
|
|
"""Make the target emit magical light"""
|
|
name = "light" # name to refer to this recipe as
|
|
casting_time = 1
|
|
duration = 60
|
|
target_type = "SINGLE"
|
|
success_message = "You cast |wlight|n on {}."
|
|
|
|
def do_cast(self, **kwargs):
|
|
target_obj = self.target_obj
|
|
if has_effect(target_obj, "emit_magic_light"):
|
|
self.msg("{} already has a magical light on itself.".format(target_obj.name))
|
|
return False
|
|
|
|
create_script(effects.EffectMagicalLight, obj=target_obj, interval=self.duration)
|
|
self.success_message = self.success_message.format(target_obj.name)
|
|
|
|
return True
|
|
|
|
# def spell_light(caller, target, **kwargs):
|
|
# if not target:
|
|
# target_obj = caller
|
|
# else:
|
|
# target_obj = caller.search(target, location=[caller, caller.location])
|
|
#
|
|
# if not target_obj:
|
|
# return
|
|
#
|
|
# if has_effect(target_obj, "emit_magic_light"):
|
|
# caller.msg("{} already has a magical light on itself.".format(target_obj.name))
|
|
# return
|
|
#
|
|
# light_script = create_script(effects.EffectMagicalLight, obj=target_obj)
|
|
# caller.msg("You cast |wlight|n on {}.".format(target_obj.name))
|
|
|
|
|
|
# def spell_charm(caller, target, **kwargs):
|
|
# if not target:
|
|
# caller.msg("You need someone to place your charm on.")
|
|
# return
|
|
#
|
|
# target_obj = caller.search(target, location=[caller.location])
|
|
#
|
|
# if not target_obj:
|
|
# return
|
|
#
|
|
# if not inherits_from(target_obj, Mob):
|
|
# caller.msg("You cannot charm {}".format(target_obj.name))
|
|
# return
|
|
#
|
|
# if has_effect(target_obj, "charm"):
|
|
# caller.msg("{} is already charmed.".format(target_obj.name))
|
|
# return
|
|
#
|
|
# charm_script = create_script(effects.EffectCharm, obj=target_obj, attributes=[("source", caller.dbref)])
|
|
# caller.msg("You cast |wcharm|n on {}.".format(target_obj.name)) |