[FUNCTION F_REMOVEALLMINIONS]
LOCAL.IDOL=<UID>
FORCHARS 90
	IF ((<TAG0.CHAMPIONIDOL> == <LOCAL.IDOL>) && (<ISEVENT.e_champion_minion>))
	REMOVE
	ENDIF
ENDFOR

[FUNCTION QUANTOSMONSTROS]
LOCAL.LESSMONSTERS=<EVAL <TAG0.NOTYET>*2>
IF (<LOCAL.LESSMONSTERS> > 6)
LOCAL.LESSMONSTERS=6
ENDIF
IF (<MOREX> <= 4)
RETURN 64
ELIF (<MOREX> <= 9)
RETURN 32
ELIF (<MOREX> <= 13)
RETURN 16
ELSE
RETURN <EVAL 8-<LOCAL.LESSMONSTERS>>
ENDIF

[FUNCTION F_MONSTERLEVEL]
IF (<MOREX> <= 4)
RETURN 1
ELIF (<MOREX> <= 9)
RETURN 2
ELIF (<MOREX> <= 13)
RETURN 3
ELSE
RETURN 4
ENDIF

[FUNCTION F_CHAMPION_UPONELEVEL]
REF1=<UID>
FORCHARS 100
	IF (<TAG0.CHAMPIONIDOL> == <REF1.UID>) && (<UID> != <ARGN2>)
		IF ((!(<MEMORYFINDTYPE.memory_fight>)) && (<TAG0.CHAMPION.LEVEL> == <ARGN1>))
			IF (<FLOATVAL 0.6> > <RANDOMDOUBLE>)
			REMOVE
			LOCAL.MOREMONSTERS ++
			ENDIF
		ENDIF
	ENDIF
ENDFOR
IF (<LOCAL.MOREMONSTERS> == 0)
LOCAL.MOREMONSTERS=1
ENDIF
RETURN <LOCAL.MOREMONSTERS>

[EVENTS E_CHAMPION_MINION]
ON=@DeathCorpse
LOCAL.OLDNEW=<NEW>
ARGO.TIMER=60
REF1=<TAG0.CHAMPIONIDOL>
IF (<REF1.TAG0.ACTIVE>) && (!(<REF1.TAG0.CHAMPIONUP>))
	IF (<REF1.MORE1> == 0) && (<REF1.MOREX> == 1)
	REF1.TIMER=<DEF.CHAMPIONLEVELMINUTE>
	REF1.TIMERF <DEF.CHAMPIONCOMPLETETIME>,F_CHAMPION_TIMEOUT_RESET
	ENDIF
	IF (<TAG0.CHAMPION.LEVEL> >= <REF1.F_MONSTERLEVEL>)
	REF1.MORE1 ++
		IF ((<REF1.MORE1> >= <REF1.QUANTOSMONSTROS>)
		REF1.TIMER=<DEF.CHAMPIONLEVELMINUTE>
		ENDIF
		IF ((<REF1.MORE1> >= <REF1.QUANTOSMONSTROS>) && (<REF1.MOREX> != 16))
		REF1.MORE1=0
		REF1.MOREX ++
		REF1.REGION.LIGHT=<EVAL <REF1.MOREX>+1>
		REF1.REGION.FLAGS &= ~<DEF.region_flag_nodecay>
		REF1.REGION.FLAGS &= ~<DEF.region_antimagic_teleport>
		REF1.REGION.FLAGS |= <HVAL <DEF.region_flag_announce>|<DEF.region_antimagic_recall_in>|<DEF.region_antimagic_recall_out>|<DEF.region_antimagic_gate>>
		SERV.NEWITEM i_skull_candle
		NEW.TAG.ALWAYSSEND=1
		NEW.COLOR=33
		NEW.TIMER -1
		NEW.ATTR=ATTR_MOVE_NEVER
		REF1.TAG0.CANDLES ++
		REF1.TAG0.CANDLE.<dREF1.TAG0.CANDLES>=<NEW>
		NEW.P=<REF1.P>
		NEW.CANDLEP=<REF1.TAG0.CANDLES>
		REF1.REMOVEWHITECANDLES
			IF (<REF1.F_MONSTERLEVEL> > <TAG0.CHAMPION.LEVEL>)
			LOCAL.MONSTERS=<REF1.F_CHAMPION_UPONELEVEL <TAG0.CHAMPION.LEVEL> <UID>>
			LOCAL.LEVELUP=1
			ENDIF
		ELIF (<REF1.MORE1> == <REF1.QUANTOSMONSTROS>) && (<FLOATVAL 0.70> > <RANDOMDOUBLE>) && (<REF1.MOREX> == 16)
		SERV.LOG Summoning Champion!
		SERV.NEWNPC <DEF.champ_<REF1.TAG0.MONSTERGROUP>_champion>
		NEW.TAG.CHAMPIONIDOL=<REF1.UID>
		NEW.EVENTS +e_champion
		NEW.P=<REF1.P>
		NEW.HOME=<REF1.P>
		NEW.HOMEDIST=15
		NEW.UPDATE
		REF1.TIMERF CLEAR
		REF1.REGION.LIGHT=20
		REF1.F_SET_PENTAGRAM_COLOR 33
			FOR <REF1.TAG0.CANDLES>
			UID.<REF1.TAG0.CANDLE.<dLOCAL._FOR>>.REMOVE
			TRY REF1.TAG.CANDLE.<dLOCAL._FOR>
			REF1.TAG0.CANDLES --
			ENDFOR
		REF1.TAG.CANDLES
		REF1.TAG.NOTYET
		REF1.REMOVEWHITECANDLES
		REF1.TAG.CHAMPIONUP=1
		REF1.TIMER=-1
		ELIF (<REF1.MOREX> == 16) && (<REF1.MORE1> == <REF1.QUANTOSMONSTROS>)
		REF1.REMOVEWHITECANDLES
		REF1.TAG0.NOTYET ++
		REF1.MORE1=0
		ELSE
			IF (<REF1.MORE1> == <EVAL (<REF1.QUANTOSMONSTROS>*20)/100>) || (<REF1.MORE1> == <EVAL (<REF1.QUANTOSMONSTROS>*40)/100>) || (<REF1.MORE1> == <EVAL (<REF1.QUANTOSMONSTROS>*60)/100>) || (<REF1.MORE1> == <EVAL (<REF1.QUANTOSMONSTROS>*80)/100>)
			SERV.NEWITEM i_skull_candle
			NEW.TAG.ALWAYSSEND=1
			NEW.TIMER -1
			NEW.P=<REF1.P>
			NEW.ATTR=ATTR_MOVE_NEVER
			REF1.TAG0.WHITESKULLS ++
			TRY REF1.TAG.WHITESKULLS.<dREF1.TAG0.WHITESKULLS>=<NEW>
			NEW.WHITESKULLLOC <REF1.TAG0.WHITESKULLS>
			NEW.EFFECT 2,03728,3,20
			NEW.SOUND 029
			ENDIF
		ENDIF
	ENDIF
	IF (<ATTACKER>)
	REF25=<ATTACKER.MAX>
		IF (<FLOATVAL 0.001> > <RANDOMDOUBLE>) && (<MAP> == 0)
		LOCAL.OLDNEW=<NEW>
		SERV.NEWITEM I_POWER_SCROLL
		NEW.MORE2=50
		NEW.name=<NEW.POWERSCROLLNAME> Power Scroll of <SERV.SKILL.<NEW.MORE1>.NAME> (105 Skill)
		REF25.TRIGGER @ReceivePowerScroll
		REF25.BOUNCE <NEW>
		REF25.SYSMESSAGELOC -1,1049524
		NEW=<LOCAL.OLDNEW>
		ENDIF
		IF (<FLOATVAL 0.001> > <RANDOMDOUBLE>)
		LOCAL.OLDNEW=<NEW>
		SERV.NEWITEM I_SCROLL_TRANSCENDENCE
		REF25.TRIGGER @ReceiveTranscendenceScroll
		REF25.BOUNCE <NEW>
		NEW=<LOCAL.OLDNEW>
		ENDIF
		FOR z 0 <EVAL <ATTACKER>-1>
		REF26=<ATTACKER.<dLOCAL.Z>>
			IF ((<ATTACKER.<dLOCAL.Z>.DAM>) && (<REF26.ISPLAYER>))
				IF ((!(<REF26.TAG0.VIRTUDES>&<DEF.VALOR_L3>)) && (<REF26.TAG0.VIRTUDES.VALOR>) && ((<MAP> == 2) || (<MAP> == 3)))
				REF26.TAG0.VIRTUDES.VALOR += 150
				REF26.SYSMESSAGELOC -1,1054030
					IF (!(<REF26.TAG0.VIRTUDES>&<DEF.VALOR_L1>))
						IF (<REF26.TAG0.VIRTUDES.VALOR> >= 10000)
						REF26.TAG0.VIRTUDES.VALOR=1
						REF26.TAG0.VIRTUDES |= <DEF.VALOR_L1>
						REF26.SYSMESSAGELOC -1,1054032
						ENDIF
					ELIF (!(<REF26.TAG0.VIRTUDES>&<DEF.VALOR_L2>))
						IF (<REF26.TAG0.VIRTUDES.VALOR> >= 15000)
						REF26.TAG0.VIRTUDES.VALOR=1
						REF26.TAG0.VIRTUDES |= <DEF.VALOR_L2>
						REF26.SYSMESSAGELOC -1,1054032
						ENDIF
					ELIF (!(<REF26.TAG0.VIRTUDES>&<DEF.VALOR_L3>))
						IF (<REF26.TAG0.VIRTUDES.VALOR> >= 20000)
						REF26.TAG0.VIRTUDES.VALOR=
						REF26.TAG0.VIRTUDES |= <DEF.VALOR_L3>
						REF26.SYSMESSAGELOC -1,1054031
						ENDIF
					ENDIF
				ENDIF
			ENDIF
		ENDFOR
	ENDIF
	IF (<REF1.F_MONSTERLEVEL> == 2) && (<TAG0.CHAMPION.LEVEL> == 1)
	LOCAL.NOTFROMTHISLEVEL=1
	ELIF (<REF1.F_MONSTERLEVEL> == 3) && ((<TAG0.CHAMPION.LEVEL> == 1) || (<TAG0.CHAMPION.LEVEL> == 2))
	LOCAL.NOTFROMTHISLEVEL=1
	ELIF (<REF1.F_MONSTERLEVEL> == 4) && ((<TAG0.CHAMPION.LEVEL> == 1) || (<TAG0.CHAMPION.LEVEL> == 2) || (<TAG0.CHAMPION.LEVEL> == 3))
	LOCAL.NOTFROMTHISLEVEL=1
	ENDIF
	LOCAL.MONSTERS ++
	FOR <dLOCAL.MONSTERS>
		IF (<LOCAL.LEVELUP>) || (<LOCAL.NOTFROMTHISLEVEL>)
		SERV.NEWNPC <DEF.champ_<REF1.TAG0.MONSTERGROUP>_<REF1.F_MONSTERLEVEL>>
		ELSE
		SERV.NEWNPC <BASEID>
		ENDIF
	NEW.REMOVEFROMVIEW
	NEW.FLAGS |= <DEF.STATF_INVISIBLE>
	NEW.TAG.CHAMPION.LEVEL=<REF1.F_MONSTERLEVEL>
	NEW.P=<REF1.P>
	NEW.MOVE <HVAL {-<REF1.TAG0.RANGE> <REF1.TAG0.RANGE>}> <HVAL {-<REF1.TAG0.RANGE> <REF1.TAG0.RANGE>}>
		IF (<REF1.MAP> == 2)
		NEW.F_CREATE_PARAGON 1
		ENDIF
	NEW.FIX
		WHILE (<NEW.ISSTUCK>) || (<NEW.ISNEARTYPE T_WATER>) || (<NEW.P.TERRAIN> == 0244) || (<NEW.ISNEARTYPE T_WALL>)
		NEW.P=<REF1.P>
		NEW.MOVE <HVAL {-<REF1.TAG0.RANGE> <REF1.TAG0.RANGE>}> <HVAL {-<REF1.TAG0.RANGE> <REF1.TAG0.RANGE>}>
		NEW.FIX
		ENDWHILE
	NEW.HOME=<NEW.P>
	NEW.HOMEDIST=6
	NEW.FLAGS &= ~<DEF.STATF_INVISIBLE>
	NEW.UPDATE
	NEW.TAG.CHAMPIONIDOL=<REF1.UID>
	NEW.EVENTS +E_CHAMPION_MINION
	ENDFOR
ENDIF
NEW=<LOCAL.OLDNEW>

[EOF]