enum {
	DND_PET_ZOMBIEID
};

Actor MovePetCooldown : PowerDamage {
	damagefactor "normal", 1.0
	powerup.duration -3
}

Actor PetTargetClear : DnD_Activator {
	States {
		Pickup:
			TNT1 A 0 A_ClearTarget
		Stop
	}
}

Actor PetMonsterBase {
	Monster
	Species "Player"
	+USEKILLSCRIPTS
	+FLOORCLIP
	+DONTBLAST
	-COUNTKILL
	+CANPUSHWALLS
	+CANUSEWALLS
	+CANPASS
	+USEDAMAGEEVENTSCRIPT
	+THRUSPECIES
	+DONTHURTSPECIES
	-ACTIVATEMCROSS
	-NOTELEPORT
	+NOBLOCKMONST
	+NEVERRESPAWN
	+NEVERFAST
	+DONTHARMSPECIES
	
	States {
		Death:
			"####" "#" 0 ACS_NamedExecuteAlways("DnD On Summon Death Check", 0, DND_PET_ZOMBIEID)
			"####" "#" 0 A_Jump(256, "DeathAnim")
		Wait
		XDeath:
			"####" "#" 0 ACS_NamedExecuteAlways("DnD On Summon Death Check", 0, DND_PET_ZOMBIEID)
			"####" "#" 0 A_Jump(256, "XDeathAnim")
		Wait
	}
}

ACTOR ZombiePet : PetMonsterBase {
	Health 125
	GibHealth 20
	Radius 20
	Height 56
	Speed 10
	PainChance 192
	Stamina 1
	SeeSound "ZombieFodder/sight"
	PainSound "ZombieFodder/pain"
	DeathSound "ZombieFodder/death"
	ActiveSound "ZombieFodder/active"
	Obituary "%o joins the zombies."
	Tag "Summoned Zombie"
	MeleeRange 78
	States {
		Spawn:
			TNT1 A 0 NoDelay ACS_NamedExecuteAlways("DnD Pet Monster Scale", 0, DND_PET_ZOMBIEID, DND_SILVER_WEAKNESS, -1)
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Timed Monster", ACS_NamedExecuteWithResult("DnD Master Skill Info", SKILLINFO_ZOMBIEPETTIMER), 1)
			TNT1 A 0 ACS_NamedExecuteAlways("DnD Pet Distance Move", 0)
			ZFOD S 6
			ZFOD RQPON 3
		SpawnLoop:
			ZFOD AB 8 A_Look
		Goto See
		See:
			ZFOD AABBCCDD 2 A_Chase
		Loop
		Melee:
			TNT1 A 0 A_AlertMonsters(0, AMF_TARGETNONPLAYER)
			ZFOD E 6 A_FaceTarget
			TNT1 A 0 A_PlaySound("ZombieFodder/MeleeBegin", 5)
			ZFOD F 5 A_FaceTarget
			ZFOD G 2 A_CustomMeleeAttack(ACS_NamedExecuteWithResult("DND Pet Monster Damage Scale", 8, 1 | (2 << 16), 0), "ZombieFodder/MeleeHit")
			ZFOD G 3
		Goto See
		Pain:
			ZFOD H 4
			ZFOD H 4 A_Pain
		Goto See
		DeathAnim:
			ZFOD I 7
			ZFOD J 7 A_Scream
			ZFOD K 5 A_NoBlocking
			ZFOD L 5 A_SpawnItemEx("FodderSoul",0,0,10,0,0,1)
			ZFOD M -1
		Stop
		XDeathAnim:
			ZFOD N 5
			ZFOD O 5 A_XScream
			ZFOD P 5 A_NoBlocking
			ZFOD Q 5 A_SpawnItemEx("FodderSoul",0,0,10,0,0,1)
			ZFOD R 5
			ZFOD S -1
		Stop
	}
}

ACTOR FodderSoul {
	+NOBLOCKMAP
	+NOGRAVITY
	+CLIENTSIDEONLY
	States {
		Spawn:
			TNT1 A 0 NoDelay A_Playsound("ZombieFodder/Soul")
			ZFSL ABC 5
			ZFSL DEFG 9
		Stop
	}
}