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

import wolfpack
from wolfpack.consts import *
from wolfpack.utilities import *
from math import floor

def onSpellSuccess( char, spell, type, target ):
	# target check is done at c++ code
	defender = target.char
	if not defender:
		return

	agression( char, defender, spell )
	attacker = char
	reflected = magicReflection( char, defender )
	if( reflected == 1 ):
		attacker = defender
		defender = char
	# effects
	defender.soundeffect( 0x1e5 )
	defender.effect( 0x374a )

	# not a resistable spell : just check the damage : 1 ~ 11
	# skill 1.0 = 100 point
	damage = - floor( 1 + attacker.skill[ MAGERY ] / 100 ) # 100(.)0 Magery = 10 Bonus Points

	# disturb medi
	defender.disturb()
	# unfreeze - needed to be implemented

	# FIXME: Duration more or less unknown
	statmodifier( defender, 60000, 0, 0, damage )
	return 1
