#################################################################
#   )      (\_     # WOLFPACK 13.0.0 Scripts                    #
#  ((    _/{  "-;  # Created by: khpae                          #
#   )).-" {{ ;"`   # Revised by:                                #
#  ( (  ;._ \\ ctr # Last Modification: Created                 #
#################################################################

import wolfpack
from spells.consts import *
import whrandom

def onSpellSuccess( char, spell, type, target ):
	# target check is done at c++ code
	defender = target.char
	if not defender:
		return
	if defender.hastag( "protection" ):
		char.socket.sysmessage( "Already under the influence!" )
		return 1
	# effects
	defender.soundeffect( 0x1ee )
	defender.effect( 0x373a )
	# disturb medi
	defender.disturb()
	# unfreeze - needed to be implemented
	whrandom.seed()
	rand = whrandom.randint( 1, 11 )
	duration = rand * 10000 + char.skill[ MAGERY ] * 50
	modArmor = char.skill[ MAGERY ] / 100
	defender.settag( "protection", modArmor )
	defender.addtimer( "protection.restore", duration, ( defender.serial, ) )
	defender.update()
	# armor up - needed to be implemented
	return 1

def restore( serial ):
	char = findchar( serial )
	if not char:
		return 1
	if not char.hastag( "protection" ):
		return 1
	char.removetag( "protection" )
	char.update()
	return 1
