"""Makes the caster temporarily immune to slow, paralysis.

Copyright 2000 Cabochon Technologies, Inc.
author: Steve Yegge
"""

from wyvern.lib import Timed, Kernel
from wyvern.lib.classes.magic import Spell

class free_action(Spell, Timed):

    def start(self):

        # save target in instance var for timer expiration
        self.target = self.findTargetObject(1)
        if self.target is None:
            return

        self.target.adjustTransientIntProperty("resist-slow", 100)
        self.target.adjustTransientIntProperty("resist-paralysis", 100)
        self.target.message('You feel unstoppable.')

        lvl = self.getLevel(self.MIND) + self.getLevel(self.LIFE)
        duration = 30000 + lvl * 10000
        Kernel.setTimer(duration, self)


    def timerExpired(self):
        self.target.adjustTransientIntProperty("resist-slow", -100)
        self.target.adjustTransientIntProperty("resist-paralysis", -100)
        self.target.message('Your free-action spell expires.')