[FUNCTION F_EXPLODECORPSE]
REF1=<UID>
FORCLIENTS 5
DAMAGE 70 <DEF.DAM_PHYSICAL> <ARGN1>
SPELLEFFECT S_POISON,100.0,<ARGN1>
ENDFOR

[FUNCTION F_EXPLODECORPSE_DROPALL]
LOCAL.OLDNEW=<NEW>
SERV.NEWITEM i_flesh_head
NEW.P=<P>
NEW.ATTR=ATTR_DECAY
NEW.UPDATE
NEW.TIMER=60*2
SERV.NEWITEM i_flesh_torso
NEW.P=<P>
NEW.ATTR=ATTR_DECAY
NEW.MOVE S
NEW.UPDATE
NEW.TIMER=60*2
SERV.NEWITEM i_flesh_leg
NEW.P=<P>
NEW.ATTR=ATTR_DECAY
NEW.MOVE E
NEW.UPDATE
NEW.TIMER=60*2
SERV.NEWITEM i_flesh_leg
NEW.P=<P>
NEW.ATTR=ATTR_DECAY
NEW.MOVE N
NEW.UPDATE
NEW.TIMER=60*2
REMOVE
FORCONT <UID> 0
	IF (<TYPE> != T_BEARD) && (<TYPE> != T_HAIR)
	DROP
	ENDIF
ENDFOR
NEW=<LOCAL.OLDNEW>

///////////////////////////

[CHARDEF 146]
DEFNAME=c_Harrower
NAME=Harrower
CAN=MT_WALK|MT_USEHANDS
DAM=35,41
SOUND=1150
ARMOR=70
MOVERATE=60
CATEGORY=Addon
SUBSECTION=Champs
DESCRIPTION=Harrower
TAG.IAMACHAMPION=1

ON=@Create
TAG.LIFETIER=2
NPC=brain_monster
KARMA=-10000
FAME=10000
STR={901 1000}
DEX={126 140}
INT={1001 1200}
MAXHITS=20000
MAXMANA=6000
WRESTLING={115.0 120.0}
TACTICS={115.0 120.0}
MAGICRESISTANCE={115.0 160.0}
MAGERY=120.0
EVALUATINGINTEL=140.0

ON=@Death
TAG0.LIFETIER --
IF (<TAG0.LIFETIER>)
HITS=<MAXHITS>
ACTION -1
RETURN 1
ENDIF

ON=@NPCLookAtChar
IF (<FLOATVAL 0.01> > <RANDOMDOUBLE>) && (!(<SRC.FLAGS>&STATF_DEAD)) && (<SRC.ISPLAYER>)
SRC.GO <P>
ATTACK <SRC>
SAY @,,2 1049503
ENDIF
IF (<ISNEARTYPE T_CORPSE 10>)
	IF (<FLOATVAL 0.02> > <RANDOMDOUBLE>)
	REF1=<UID>
		FORITEMS 10
			IF (<BASEID> == i_corpse) && (!(<LOCAL.JAEXPLODIU>))
			F_EXPLODECORPSE <REF1.UID>
			F_EXPLODECORPSE_DROPALL
			LOCAL.JAEXPLODIU=1
			ENDIF
		ENDFOR
	ENDIF
ENDIF

ON=@DeathCorpse
LOCAL.NEW=<NEW>
SERV.NEWNPC C_TRUE_Harrower
NEW.GO <P>
NEW.SAY @,,2 1049499
REF1=<NEW>
FOR 12
SERV.NEWNPC C_TENTACLES_Harrower
NEW.FLAGS |= <DEF.statf_invisible>
NEW.P <P>
NEW.REMOVEFROMVIEW
NEW.FACE <REF1.UID>
NEW.MOVE <HVAL {-6 6}> <HVAL {-6 6}>
NEW.FIX
	WHILE (<NEW.ISNEARTYPE T_WATER>) || (<NEW.P.TERRAIN> == 0244) || (<NEW.ISNEARTYPE T_WALL>)
	NEW.P <P>
	NEW.FACE <REF1.UID>
	NEW.MOVE <HVAL {-6 6}> <HVAL {-6 6}>
	NEW.FIX
	ENDWHILE
NEW.FLAGS &= ~<DEF.statf_invisible>
NEW.UPDATEX
ENDFOR
NEW=<LOCAL.NEW>
ARGO.REMOVE

ON=@Hit
IF (!(<R8>))
	DORAND 4
	SAY @,,2 1049500
	SAY @,,2 1049501
	SAY @,,2 1049505
	SAY @,,2 1049507
	ENDDO
ENDIF

ON=@SpellEffect
SAY @,,2 1049502

ON=@GetHit
IF (!(<R8>))
	DORAND 2
	SAY @,,2 1049508
	SAY @,,2 1049504
	ENDDO
ENDIF
IF (<SRC.ISPLAYER>) && (!(<SRC.FLAGS>&STATF_DEAD))
	IF (<FLOATVAL 0.03> > <RANDOMDOUBLE>)
	SRC.GO <P>
	ATTACK <SRC>
	SAY @,,2 1049503
	ENDIF
ENDIF

[CHARDEF C_TENTACLES_Harrower]
ID=C_CORPSER
NAME=Tentacles of Harrower
CAN=MT_NONMOVER|MT_USEHANDS
RANGE=9
DAM=13,20
ARMOR=45
CATEGORY=Addon
SUBSECTION=Champs
DESCRIPTION=Tentacles of the Harrower
TAG.LIFELEECH=50

ON=@Create
COLOR=COLORS_BLACK
NPC=brain_monster
NAME=Tentacles of the Harrower
KARMA=-9000
FAME=5000
STR={300 400}
DEX={110 130}
INT={1000 1200}
MAXHITS=860
MAXMANA=1000
WRESTLING=90.0
TACTICS=90.0
MAGICRESISTANCE={120.0 140.0}
ANATOMY=100.0

ON=@NPCREstock
ITEM=i_gold,{900 1300}

[CHARDEF C_TRUE_Harrower]
ID=c_bog_thing
DEFNAME=C_TRUE_Harrower
CAN=MT_NONMOVER|MT_USEHANDS
NAME=True Harrower
DAM=36,42
SOUND=1150
ARMOR=70
CATEGORY=Addon
SUBSECTION=Champs
DESCRIPTION=True Harrower
TAG.IAMACHAMPION=1
TAG.LIFELEECH=50

ON=@Create
TAG.LIFETIER=2
NPC=brain_monster
KARMA=-10000
FAME=10000
STR={901 1000}
DEX={126 140}
INT={1001 1200}
MAXHITS=20000
MAXMANA=6000
WRESTLING={115.0 120.0}
TACTICS={115.0 120.0}
MAGICRESISTANCE={115.0 160.0}
MAGERY=120.0
EVALUATINGINTEL=140.0
TIMERF 2,SAY @,,2 1049499

ON=@NPCLookAtChar
IF (<FLOATVAL 0.01> > <RANDOMDOUBLE>) && (!(<SRC.FLAGS>&STATF_DEAD)) && (<SRC.ISPLAYER>)
SRC.GO <P>
ATTACK <SRC>
SAY @,,2 1049503
ENDIF
IF (<ISNEARTYPE T_CORPSE 10>)
	IF (<FLOATVAL 0.02> > <RANDOMDOUBLE>)
	REF1=<UID>
		FORITEMS 10
			IF (<BASEID> == i_corpse) && (!(<LOCAL.JAEXPLODIU>))
			F_EXPLODECORPSE <REF1.UID>
			F_EXPLODECORPSE_DROPALL
			LOCAL.JAEXPLODIU=1
			ENDIF
		ENDFOR
	ENDIF
ENDIF

ON=@GetHit
IF (<SRC.ISPLAYER>) && (!(<SRC.FLAGS>&STATF_DEAD))
	IF (<FLOATVAL 0.03> > <RANDOMDOUBLE>)
	SRC.GO <P>
	ATTACK <SRC>
	ENDIF
ENDIF

ON=@Hit
IF (<FLOATVAL 0.1> > <RANDOMDOUBLE>)
SRC.SPELLEFFECT S_POISON,1600,<UID>
ENDIF

ON=@Death
TAG0.LIFETIER --
IF (<TAG0.LIFETIER>)
HITS=<MAXHITS>
ACTION -1
RETURN 1
ENDIF

LOCAL.NEW=<NEW>
FOR 4
serv.newitem=i_gold_champion
new.p=<p>
new.timer=1
ENDFOR
LOCAL.NEW=<NEW>
VAR.HARROWER=
FOR 0 5
	DOSWITCH <dLOCAL._FOR>
	REF1=<VAR0.HARROWER.SKULL.Greed>
	REF1=<VAR0.HARROWER.SKULL.Pain>
	REF1=<VAR0.HARROWER.SKULL.Venom>
	REF1=<VAR0.HARROWER.SKULL.Power>
	REF1=<VAR0.HARROWER.SKULL.Death>
	REF1=<VAR0.HARROWER.SKULL.Enlightenment>
	ENDDO
	IF (0<REF1>)
	REF1.REMOVE
	ENDIF
ENDFOR
VAR.HARROWER.SKULL.Greed=
VAR.HARROWER.SKULL.Pain=
VAR.HARROWER.SKULL.Venom=
VAR.HARROWER.SKULL.Power=
VAR.HARROWER.SKULL.Death=
VAR.HARROWER.SKULL.Enlightenment=
VAR.HARROWER.TOTALSKULLS=
SERV.B @0ad The Harrower has been slain! Congratulations!
LIST.ChampionPowerScroll.ADD 0
LIST.ReceivedPowerScroll.ADD 0
IF (<ATTACKER>)
	FOR 0 <EVAL <ATTACKER>-1>
		IF (<ATTACKER.<dLOCAL._FOR>.DAM>)
		REF2=<ATTACKER.<dLOCAL._FOR>>
			IF (<REF2.FLAGS>&STATF_PET)
			REF2=<REF2.OWNER>
			ENDIF
			IF (<LIST.ChampionPowerScroll.FINDELEM <REF2>> == -1) && (<REF2.ISPLAYER>)
			LIST.ChampionPowerScroll.ADD=<REF2>
			ENDIF
		ENDIF
	ENDFOR
	IF (<LIST.ChampionPowerScroll.COUNT> > 1)
	LIST.ChampionPowerScroll.0.REMOVE
	LOCAL.TOTALPOWERSCROLLSTOBEGIVEN=<LIST.ChampionPowerScroll.COUNT>
		IF (<LOCAL.TOTALPOWERSCROLLSTOBEGIVEN> > 16)
		LOCAL.TOTALPOWERSCROLLSTOBEGIVEN=16
		ENDIF
		WHILE (<EVAL <LIST.ReceivedPowerScroll.COUNT>-1> < <LOCAL.TOTALPOWERSCROLLSTOBEGIVEN>)
		REF2=<LIST.ChampionPowerScroll.<R<LIST.ChampionPowerScroll.COUNT>>>
			IF (<LIST.ReceivedPowerScroll.FINDELEM <REF2>> == -1)
			LOCAL.OLDNEW=<NEW>
			SERV.NEWITEM=i_stat_power_scroll
				IF (!(<REF2.FLAGS>&STATF_DEAD))
				REF2.BOUNCE <NEW>
				ELSE
				NEW.P=<REF2.P>
				NEW.UPDATE
				ENDIF
			NEW=<LOCAL.OLDNEW>
			REF2.TRIGGER @ReceiveStatPowerScroll
			REF2.SYSMESSAGELOC -1,1049524
			REF2.RANDMAGICITEMGREAT
				IF ((<FLOATVAL 0.35> > <RANDOMDOUBLE>) && (!(<LOCAL.GAVEREWARD>)))
				LOCAL.OLDNEW=<NEW>
				SERV.NEWITEM <DEF.champ_Harrower_REWARD>
				REF2.BOUNCE <NEW>
				LOCAL.GAVEREWARD=1
				NEW=<LOCAL.OLDNEW>
				ENDIF
				IF (<FLOATVAL 0.50> > <RANDOMDOUBLE>)
				LOCAL.OLDNEW=<NEW>
				SERV.NEWITEM <HVAL <DEF.MINORARTIS>>
				REF2.BOUNCE <NEW>
				NEW=<LOCAL.OLDNEW>
				ENDIF
				IF (<FLOATVAL 0.10> > <RANDOMDOUBLE>)
				LOCAL.OLDNEW=<NEW>
				SERV.NEWITEM <HVAL <DEF.RANDOM_ML_SETS_DROP_LIST>>
				REF2.BOUNCE <NEW>
				NEW=<LOCAL.OLDNEW>
				ENDIF
			REF2.HARROWERPOINTS ++
			LIST.ReceivedPowerScroll.ADD <REF2.UID>
			ENDIF
		ENDWHILE
	ENDIF	
ENDIF
LIST.ChampionPowerScroll.CLEAR
LIST.ReceivedPowerScroll.CLEAR
FOR 15
SERV.NEWITEM i_osi_treasure_map
NEW.TAG.LEVEL=5
	IF (<FLOATVAL 0.2> > <RANDOMDOUBLE>)
	NEW.TAG.LEVEL=6
	ENDIF
ENDFOR
IF (<FLOATVAL 0.15> > <RANDOMDOUBLE>)
NEWLOOT=i_crimson_cinture
ENDIF
NEW=<LOCAL.NEW>

[TYPEDEF T_Harrower_OFFER]
ON=@DClick
IF (<DISTANCE> > 3)
SRC.MESSAGE @,,2 500446
ELIF (<VAR0.HARROWER>)
SRC.MESSAGE @,3,1 The harrower has already been spawned.
ELIF (<VAR0.HARROWER.SKULL.<TAG0.SKULLNAME>>)
MESSAGE @,,2 1049487
ELSE
TARGET @,,2 1049485
ENDIF
RETURN 1

ON=@Targon_Item
IF (<ARGO.BASEID> != i_champion_skull)
MESSAGE @,,2 1049488
ELIF (<VAR0.HARROWER>)
SRC.MESSAGE @,3,1 The harrower has already been spawned.
ELIF (<VAR0.HARROWER.SKULL.<TAG0.SKULLNAME>>)
MESSAGE @,,2 1049487
ELIF (<ARGO.CONT> != <SRC.FINDLAYER.<DEF.layer_pack>.UID>)
SRC.SYSMESSAGE @,,2 1049486
ELIF (!(STRMATCH(*<TAG0.SKULLNAME>*,<ARGO.NAME>)))
MESSAGE @,,2 1049488
ELSE
TRY VAR.HARROWER.SKULL.<TAG0.SKULLNAME>=<ARGO.UID>
VAR0.HARROWER.TOTALSKULLS ++
EFFECT 2,i_fx_sparkle,16,20
ARGO.P=<P>
ARGO.Z ++
ARGO.ATTR=<DEF.ATTR_MOVE_NEVER>|<DEF.ATTR_CURSED>
ARGO.UPDATE
	IF (<VAR0.HARROWER.TOTALSKULLS> == 6)
	SERV.NEWNPC C_Harrower
		DORAND 15
		NEW.P=5242,945,-40 //Destard
		NEW.P=5225, 798, 0 //Destard
		NEW.P=5556, 886, 30 //Despise
		NEW.P=5187, 615, 0 //Deceit
		NEW.P=5319, 583, 0 //Deceit
		NEW.P=5713, 1334, -1 //Fire Dungeon
		NEW.P=5860, 1460, -2 //Fire Dungeon
		NEW.P=5328, 1620, 0 //Terathan Keep
		NEW.P=5690, 538, 0 //Wrong
		NEW.P=5609, 195, 0 //Shame
		NEW.P=5475, 187, 0 //Shame
		NEW.P=6085, 179, 0 //Hythloth
		NEW.P=6084, 66, 0 //Hythloth
		NEW.P=5499, 2003, 0 //Covetous
		NEW.P=5579, 1858, 0 //Covetous
		ENDDO
	NEW.FIX
	REF1=<NEW>
	SERV.NEWITEM i_moongate_blue
	NEW.P=5138,1767
	NEW.TYPE=T_Harrower_GATE
	NEW.TAG.LOCAL=<STRARG <REF1.REGION.NAME>>
	NEW.COLOR=038b
	NEW.TIMER <EVAL 60*10>
	NEW.ATTR=ATTR_MOVE_NEVER|ATTR_DECAY|ATTR_CAN_DECAY
	ENDIF
ENDIF
RETURN 1

ON=@Targon_Char
MESSAGE @,,2 1049488
RETURN 1

[TYPEDEF T_Harrower_GATE]
ON=@Step
SRC.GO <TAG0.LOCAL>

[EOF]