[EVENTS e_bloodoath_caster]
ON=@GetHit
SERV.Log <NAME> (<UID>) Got hit with blood oath.
IF (<SRC.ISCHAR>)
	IF (!(<ARGN2>&<DEF.DAM_GOD>)) && (!(<ARGN2>&<DEF.dam_drain>)) && (<SRC> != <UID>) && (!(<TAG0.GOTHIT>)) && ((<ARGN2>&<DEF.DAM_PHYSICAL>) || (<TAG0.GOTHITBYSPELL>))
		IF (<SRC.UID> == <TAG0.BLOODOATH.TARGET>)
		ARGN1 += <EVAL (<ARGN1>*20)/100>
		SRC.DAMAGE <ARGN1> <HVAL <DEF.dam_drain>|<DEF.DAM_MAGIC>> <UID>
		ENDIF
	ENDIF
ENDIF

ON=@Death
SERV.Log <NAME> (<UID>) Died with blood oath. (caster)
F_REMOVE_BLOODOATH <UID>,<TAG0.BLOODOATH.TARGET>

[EVENTS e_bloodoath_affected]
ON=@Death
SERV.Log <NAME> (<UID>) Died with blood oath. (affected)
F_REMOVE_BLOODOATH <TAG0.BLOODOATH.CASTER>,<UID>

[FUNCTION F_REMOVE_BLOODOATH]
//ARGV[0]=caster
//ARGV[1]=affected
REF1=<ARGV[0]> //caster
REF2=<ARGV[1]> //affected
//caster part
REF1.TAG.BLOODOATH.TARGET=
REF1.EVENTS -e_bloodoath_caster
IF (<REF1.ISPLAYER>)
REF1.REMOVEBUFF 1014
REF1.SYSMESSAGELOC -1,1061620 // Your Blood Oath has been broken.
ENDIF

//affected part
IF (<REF2>)
REF2.TAG.BLOODOATH.CASTER=
REF2.EVENTS -e_bloodoath_affected
	IF (<REF2.ISPLAYER>)
	REF2.REMOVEBUFF 1015
	REF2.SYSMESSAGELOC -1,1061620 // Your Blood Oath has been broken.
	ENDIF
ENDIF
REF1.FINDID.i_bloodoath_timer.REMOVE

[ITEMDEF i_bloodoath_timer]
ID=i_memory
NAME=Blood Oath
TYPE=T_EQ_SCRIPT

ON=@Timer
//CONT=Caster
CONT.F_REMOVE_BLOODOATH <CONT.UID>,<CONT.TAG0.BLOODOATH.TARGET>
RETURN 1

[Spell 102]
DEFNAME=s_Blood_Oath
NAME=Blood Oath
SOUND=0
RUNES=
CAST_TIME=1.5
RESOURCES=1 i_reag_daemon_blood
RUNE_ITEM=0
SCROLL_ITEM=0
FLAGS=spellflag_targ_char|spellflag_targ_noself|spellflag_playeronly|spellflag_harm
EFFECT_ID=
EFFECT=
DURATION=0.0
MANAUSE=13
SKILLREQ=SKILL_NECROMANCY 20.0
INTERRUPT=0.0,0.0

ON=@Start
IF (<ISPLAYER>)
SAY @,3,1 In Jux Mani Xen
	IF (<ISEVENT.e_bloodoath_caster>) || (<ISEVENT.e_bloodoath_affected>)
	SYSMESSAGELOC -1,1061607
	RETURN 1
	ENDIF
ENDIF

ON=@Effect
//IF (!(<ISPLAYER>))
//SRC.SYSMESSAGE @,3,1 Bloodoath can't be cast on NPCs (temporarily).
//RETURN 1
//ENDIF
IF (<SRC.ISEVENT.e_bloodoath_affected>) || (<SRC.ISEVENT.e_bloodoath_caster>)
SRC.SYSMESSAGELOC -1,1061607
ELIF (<ISEVENT.e_bloodoath_caster>) || (<ISEVENT.e_bloodoath_affected>)
	IF (<ISPLAYER>)
	SRC.SYSMESSAGELOC -1,1061608
	ELSE
	SRC.SYSMESSAGELOC -1,1061609
	ENDIF
ELIF (<SRC> == <UID>)
SRC.SYSMESSAGELOC -1,1060508
ELSE
SRC.SOUND=0175
src.effect 3,0375A,1,18,0,33,3
src.effect 3,03728,1,18,0,33,3
effect 3,0375A,1,18,0,33,3
effect 3,03728,1,18,0,33,3
LOCAL.DELAY=<EVAL ((((<SRC.NECROMANCY>*3)+(<SRC.SPIRITSPEAK>*7))-(<MAGICRESISTANCE>))/80)+8>
SKILLGAIN MagicResistance <EVAL (<SRC.NECROMANCY>+<SRC.SPIRITSPEAK>)/2>
	IF (<LOCAL.DELAY> < 1)
	LOCAL.DELAY=1
	ENDIF
EVENTS +e_bloodoath_affected
SERV.NEWITEM=i_bloodoath_timer,1,<SRC.UID>
NEW.TIMER=<LOCAL.DELAY>
SRC.TAG.BLOODOATH.TARGET=<UID>
SRC.EVENTS +e_bloodoath_caster
	IF (<SRC.ISPLAYER>)
	SRC.ADDBUFF 1014 1075659 1075660 <dLOCAL.DELAY> grr
	ENDIF
TAG.BLOODOATH.CASTER=<SRC.UID>
	IF (<ISPLAYER>)
	ADDBUFF 1015 1075661 1075662 <dLOCAL.DELAY> grr
	ENDIF
ENDIF

[EOF]