

//Trap Archvile
class TrapVile : Actor
{
    int VileLife;
    property VileLife : VileLife;
	Default
	{
       //$Category Monsters
		//$Sprite VILEI1
		Tag "Self-Resurrecting Archvile";
		SeeSound "vile/sight";
		PainSound "vile/pain";
		DeathSound "vile/death";
		ActiveSound "vile/active";
		MeleeSound "vile/stop";
		Obituary "$OB_VILE";
        TrapVile.VileLife 1;
		Health 600;
		Radius 20;
		Height 56;
		Mass 500;
		Speed 15;
		PainChance 15;
		Monster;
		MaxTargetRange 640;
		+QUICKTORETALIATE 
		+FLOORCLIP 
		+NOTARGET
	}

    state VileRaiseSelf(int ChancetoRaise = 0, statelabel endstate = "See")
    {
        if(VileLife == 1)
        {
            return  ResolveState("RaiseSelf");
        }
        else if(ChancetoRaise > random(0,100))
        {
            return ResolveState(endstate);
        }
        return null;
    }
	States
	{
	Spawn:
		VILE Z 1;
        VILE Z 0
        {
            A_Look();
            A_UnsetSolid();
        }
		Loop;
	Idle:
		VILE AB 10 A_Look;
		VILE AB 0
		{
			VileLife=1;
		}
		VILE Q 7;
		VILE R 7 A_Scream;
		VILE S 7 A_UnsetSolid;
		VILE TUVWXY 7;
        VILE Z 1;
		Goto Spawn;
    RaiseSelf:
        VILE Z 1;
		VILE YXWVUT 4;
		VILE S 4;
		VILE R 4;
		VILE Q 4;
		VILE Q 0
        {
            A_SetSolid();
            VileLife = 0;
        }
        Goto See;
	See:
        VILE Z 0 VileRaiseSelf(0, "RaiseSelf");
		VILE AABBCCDDEEFF 2 A_Chase;
		Loop;
	Missile:
		VILE G 0 BRIGHT A_VileStart;
		VILE G 10 BRIGHT A_FaceTarget;
		VILE H 8 BRIGHT A_VileTarget;
		VILE IJKLMN 8 BRIGHT A_FaceTarget;
		VILE O 8 BRIGHT A_VileAttack;
		VILE P 20 BRIGHT;
		Goto See;
	Pain:
		VILE Q 5;
		VILE Q 5 A_Pain;
		VILE Q 0
        {
            A_SetSolid();
            VileLife = 0;
        }
		Goto See;
	Death:
		VILE Q 7;
		VILE R 7 A_Scream;
		VILE S 7 A_NoBlocking;
		VILE TUVWXY 7;
        VILE Z -1;
		Stop;
	}
}