[FUNCTION F_ANIMATEDEAD_CHECKER]
IF (<EVAL <MAXHITS>-1> == 0) || (!(<OWNER>))
HITS=0
ELSE
HITS --
MAXHITS --
TIMERF 1,F_ANIMATEDEAD_CHECKER
ENDIF

[EVENTS e_animated_dead]
ON=@PetDesert
RETURN 1

ON=@ContextMenuRequest
RETURN 1

ON=@Attack
REF1=<TAG0.ANIMATEDEAD.SUMMONER>
IF (<SRC.ISPLAYER>)
RETURN 1
ELIF (<SRC.FLAGS>&STATF_PET)
	IF ((<REF1> == <SRC.OWNER>) || (<SRC.OWNER.ISBENEFICIAL <REF1>>))
	RETURN 1
	ENDIF
ENDIF

ON=@HitTry
REF1=<TAG0.ANIMATEDEAD.SUMMONER>
IF (<SRC.ISPLAYER>)
RETURN 1
ELIF (<SRC.FLAGS>&STATF_PET)
	IF ((<REF1> == <SRC.OWNER>) || (<SRC.OWNER.ISBENEFICIAL <REF1>>))
	RETURN 1
	ENDIF
ENDIF

ON=@SpellEffect
IF (<ARGN1> == 4) || (<ARGN1> == 29) || (<ARGN1> == 11) || (<ARGN1> == 25)
RETURN 1
ENDIF

ON=@Destroy
IF (!(<TAG0.DESTROYED>))
TIMERF CLEAR
TAG.DESTROYED=1
LOCAL.LISTINDEX=<LIST.ANIMATEDEAD_<TAG.ANIMATEDEAD.SUMMONER>.FINDELEM <UID>>
LIST.ANIMATEDEAD_<TAG.ANIMATEDEAD.SUMMONER>.<dLOCAL.LISTINDEX>.REMOVE
	IF (0<LIST.ANIMATEDEAD_<TAG.ANIMATEDEAD.SUMMONER>.COUNT> <= 0)
	LIST.ANIMATEDEAD_<TAG.ANIMATEDEAD.SUMMONER>.CLEAR
	ENDIF
ENDIF

ON=@DeathCorpse
ARGO.TIMERF 1,EMPTY

[Spell 101]
DEFNAME=s_Animate_Dead
NAME=Animate Dead
SOUND=0
RUNES=
CAST_TIME=1.5
RESOURCES=1 i_reag_grave_dust,1 i_reag_daemon_blood
RUNE_ITEM=0
SCROLL_ITEM=0
FLAGS=spellflag_targ_item|spellflag_playeronly|spellflag_targ_noself
EFFECT_ID=
EFFECT=
DURATION=0.0
MANAUSE=23
SKILLREQ=SKILL_NECROMANCY 40.0
INTERRUPT=0.0,0.0

ON=@Start
IF (<ISPLAYER>)
SAY @,3,1 Uus Corp
ENDIF

ON=@Effect
IF (!(<ISITEM>))
SRC.SYSMESSAGELOC -1,1061084 // You cannot animate that.
ELIF (<BASEID> != i_corpse)
SRC.SYSMESSAGELOC -1,1061084 // You cannot animate that.
ELIF (<LINK.ISPLAYER>) || (<TAG0.OWNER.FAME> < 100)
SRC.SYSMESSAGELOC -1,1061085 // There's not enough life force there to animate.
ELIF (<TAG0.UNDEADREMAINS>)
SRC.SYSMESSAGELOC -1,1061086 // You cannot animate undead remains.
ELSE
SRC.SOUND=01FB
EFFECT=2,03789,16,30,0,03f,9907
LOCAL.CASTERABILITY=<EVAL <SRC.NECROMANCY>*30>
LOCAL.CASTERABILITY += <EVAL <SRC.SPIRITSPEAK>*70>
LOCAL.CASTERABILITY /= 10
	IF (<LOCAL.CASTERABILITY> > <TAG0.OWNER.FAME>)
	LOCAL.CASTERABILITY=<TAG0.OWNER.FAME>
	ENDIF
	IF (<LOCAL.CASTERABILITY> < 1500)
		DORAND 2
		LOCAL.SUMMON=C_PATCHWORK_SKELETON
		LOCAL.SUMMON=C_WAILING_BANSHEE
		ENDDO
	ELIF (<LOCAL.CASTERABILITY> < 1900)
	LOCAL.SUMMON=C_M_SKELETON_MAGE
	ELIF (<LOCAL.CASTERABILITY> < 2800)
	LOCAL.SUMMON=C_M_MUMMY
	ELIF (<LOCAL.CASTERABILITY> < 3700)
	LOCAL.SUMMON=C_M_SKELETON_KNIGHT
	ELIF (<LOCAL.CASTERABILITY> < 4200)
	LOCAL.SUMMON=C_FLESH_GOLEM
	ELIF (<LOCAL.CASTERABILITY> < 4800)
	LOCAL.SUMMON=C_LICHE
	ELIF (<LOCAL.CASTERABILITY> < 8900)
	LOCAL.SUMMON=C_M_LICHE_LORD
	ELIF (<LOCAL.CASTERABILITY> >= 8900)
	LOCAL.SUMMON=C_SKELETAL_DRAGON
	ENDIF
TAG0.OWNER.FAME=
COLOR=0349
	IF (0<LIST.ANIMATEDEAD_<SRC.UID>.COUNT> >= 3)
	REF1=<LIST.ANIMATEDEAD_<SRC.UID>.0>
	REF1.REMOVEFROMVIEW
	REF1.MOVETO <SRC.P>
	REF1.HITS=0
	ENDIF
SERV.NEWNPC=<LOCAL.SUMMON>
	IF (<LOCAL.SUMMON> == C_SKELETAL_DRAGON)
	NEW.MAXHITS /= 2
	NEW.HITS=<NEW.MAXHITS>
	ENDIF
LIST.ANIMATEDEAD_<SRC.UID>.ADD=<NEW.UID>
NEW.NPC=<DEF.brain_monster>
NEW.P=<P>
NEW.TAG.ANIMATEDEAD.SUMMONER=<SRC.UID>
SRC.TAME=<NEW.UID>
SRC.CURFOLLOWER --
NEW.EVENTS -E_HORSES
NEW.FINDID.i_bonded_check.REMOVE
NEW.EVENTS +e_animated_dead
NEW.TIMERF 2,F_BERSERKER_LOOKFORTARGET
NEW.TIMERF 1,F_ANIMATEDEAD_CHECKER
ENDIF

[EOF]