actor ArchvileClass : PlayerPawn
{
  health 700
  gibhealth 99999 //added - actor can not be gibbed
  height 56
  mass 500
  Radius 20
  Speed 0.95 //0.7
  PainChance 0
  MaxStepHeight 36
  Player.MorphWeapon "VileHands"
  Player.WeaponSlot 1, VileHands
  Player.DisplayName "Archvile"
  Player.MaxHealth 700   
  Player.ViewHeight 50
  Player.SoundClass "Mvile"
  Player.JumpZ 10
  
  DamageFactor "Suicide", 0 // puppetmaster can not suicide a monster
  DamageFactor "MarineDamage", 0.6
  DamageFactor "MarineRLDamage", 0.6
  DamageFactor "BFGSplash", 0.6
  DamageFactor "MarineRail", 0.6
  
  DamageFactor "CybRLDamage", 0 //0.25
	DamageFactor "CybYamato", 0.02 //added
  DamageFactor "ImpBallDamage", 0
  DamageFactor "CacoDamage", 0
  DamageFactor "SkelDamage", 0
  DamageFactor "FatsoDamage", 0
  DamageFactor "KnightDamage", 0
  DamageFactor "ArachDamage", 0
  DamageFactor "viledamage", 0
  DamageFactor "Control", 0
  DamageFactor "ZombiesDamage", 0
  DamageFactor "Slime", 0
  
  -PICKUP  
  +NOSKIN
  +NOPAIN
  -FRIENDLY
  +NOTARGET
  +NOTRIGGER //added - avoid issues in level design

  states
  {
  Spawn:
    VILE AB 10
    loop
  See:
    VILE A 1 A_Jump (240,2) //0
	VILE A 0 A_PlaySoundEx ("vile/active","body")
    VILE ABCDEF 4
    Goto Spawn
  Missile:
    VILE G 0 A_JumpIf(pitch>=30 && pitch<90,"Heal") //pitch>=20 && pitch<60
    VILE G 0 BRIGHT 
    VILE G 10 BRIGHT 
    VILE H 8 BRIGHT 
    VILE IJKLMN 8 BRIGHT 
    VILE O 8 BRIGHT
    VILE P 21 BRIGHT
    Goto Spawn
  Missile2:
    VILE G 0 BRIGHT 
    VILE G 10 BRIGHT 
    VILE H 8 BRIGHT 
    VILE IJKLMN 8 BRIGHT 
    VILE O 8 BRIGHT
    VILE P 21 BRIGHT 
    Goto Spawn	
  Heal:
  	VILE G 0 HealThing(100) //added 4.1
    VILE "[\]" 15
    goto Spawn
  Death:
    VILE Q 7 A_GiveToTarget ("MarineExp",7)
    VILE R 7 A_PlaySoundEx("vile/death","body")
    VILE S 7 A_NoBlocking
    VILE T 7 Thing_changeTid(144,0)
    VILE UVW 7 
    VILE XY 5
    VILE Z 1 A_SpawnItemEx ("MDeathGhost",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0) //0
	VILE Z -1
    stop
  Raise: // added
    VILE Y 20 //added
    VILE X 20 //added
    VILE W 20 //added
	VILE V 20 //added
	VILE U 20 //added
	VILE T 20 //added
    Goto See //added
  }
}

// weapon


ACTOR VileHands : Weapon
{
  obituary "%o was incinerated by %k."
  weapon.kickback 0
  +WEAPON.NOALERT
  +Ammo_Optional
  +Alt_Ammo_Optional
  +WEAPON.DONTBOB
  +WEAPON.CHEATNOTWEAPON
  //+WEAPON.NOAUTOFIRE
  //+INVENTORY.UNDROPPABLE //added

  states
  {
  Spawn:
    TNT1 A 0 Thing_Remove (0)
    Stop
  Select:
    TNT1 A 1 A_Raise
    Goto Ready
  Ready:
    TNT1 A 0 ACS_ExecuteAlways(426,0,10)
    TNT1 A 2 A_WeaponReady
    TNT1 A 2 //ACS_ExecuteAlways (571,0,1,0,0)
    TNT1 A 2 //ACS_ExecuteAlways (571,0,5,0,0)
    TNT1 A 2 //ACS_ExecuteAlways (571,0,6,0,0)
    TNT1 A 1
    TNT1 A 0 A_JumpIfInventory ("nothere",1,"nouse")
    TNT1 A 0 A_JumpIfInventory ("goraise",1,"raisethem") //"gpraise"
    TNT1 A 0 A_JumpIfInventory ("Mskull",0,12)
    TNT1 A 5 A_WeaponReady
    TNT1 A 0 A_JumpIfInventory ("Mskull",5,10)
    TNT1 A 5 A_WeaponReady
    TNT1 A 0 A_JumpIfInventory ("Mskull",4,8)
    TNT1 A 5 A_WeaponReady
    TNT1 A 0 A_JumpIfInventory ("Mskull",3,6)
    TNT1 A 5 A_WeaponReady
    TNT1 A 0 A_JumpIfInventory ("Mskull",2,4)
    TNT1 A 5 A_WeaponReady
    TNT1 A 0 A_JumpIfInventory ("Mskull",1,2)
    TNT1 A 5 A_WeaponReady
    TNT1 A 0 HealThing(10) //1
    Loop
  DeSelect:
    TNT1 A 1 A_Lower
    Loop
 Fire:
    TNT1 A 0 A_JumpIfInventory ("PM_AltFireX",1,"AltFireX")
	TNT1 A 0 A_JumpIfInventory ("PM_AltFireY",1,"AltFireY")
	TNT1 A 0 A_JumpIfInventory ("PM_AltFireZ",1,"AltFireZ")
 	TNT1 A 0 ACS_ExecuteAlways(426,0,3) //added
	TNT1 A 0
    TNT1 A 0 A_JumpIfInventory ("goraise",1,"raisethem")
    TNT1 A 0 A_JumpIf(pitch>=30 && pitch<90,"Heal") //pitch>=20 && pitch<60
    //TNT1 A 0 SetPlayerProperty (0, 1, 4)
	TNT1 A 10
	TNT1 A 0 A_ClearTarget
	TNT1 A 0 A_Look
	TNT1 A 0 A_VileStart
	TNT1 A 0 A_SetBlend ("YELLOW",0.4,56)	
    TNT1 A 0 A_FaceTarget

	TNT1 A 0 A_FireCustomMissile ("MVileFireP",0,1,5,10)

    ARCG IJKLMN 8 A_FaceTarget
    TNT1 A 0 A_SetBlend ("YELLOW",0.7,20)
    TNT1 A 0 A_JumpIfInventory ("vattack2",1,6)
    TNT1 A 8 A_VileAttack
    TNT1 A 0 A_ClearTarget
	TNT1 A 0 A_ReFire //added
    //TNT1 A 0 SetPlayerProperty (0, 0, 4)
	TNT1 A 0 ACS_ExecuteAlways(426,0,3) //added
    GOTO Ready
    TNT1 AAA 1
    TNT1 A 0 A_TakeInventory("vattack2",1)
    TNT1 A 8 A_VileAttack
    TNT1 A 0 A_ClearTarget
    //TNT1 A 0 SetPlayerProperty (0, 0, 4)
	TNT1 A 0 ACS_ExecuteAlways(426,0,10) //added
    GOTO Ready

AltFireX:
	TNT1 A 0 ACS_ExecuteAlways(426,0,3) //added
	TNT1 A 0
	TNT1 A 10
	TNT1 A 0 A_VileStart
	TNT1 A 0 A_SetBlend ("YELLOW",0.4,56)	
		TNT1 A 0 A_FireCustomMissile ("MVileFireAltX",0,1,5,10)
    ARCG IJKLMN 8
    TNT1 A 0 A_SetBlend ("YELLOW",0.7,20)
	TNT1 A 0 ACS_ExecuteAlways(426,0,10) //added
	TNT1 A 20
    GOTO Ready
	
AltFireY:
	TNT1 A 0 ACS_ExecuteAlways(426,0,6) //added
	TNT1 A 0
	TNT1 A 5 //10
	TNT1 A 0 A_VileStart
	TNT1 A 0 A_SetBlend ("YELLOW",0.4,56)	
		TNT1 A 0 A_FireCustomMissile ("MVileFireAltY",0,0,-30,0)
    ARCG IJKLMN 8
    TNT1 A 0 A_SetBlend ("YELLOW",0.7,20)
	TNT1 A 0 ACS_ExecuteAlways(426,0,10) //added
	TNT1 A 10 //20
    GOTO Ready

AltFireZ:
	TNT1 A 0 ACS_ExecuteAlways(426,0,6) //added
	TNT1 A 5 //15
	TNT1 A 0 A_ClearTarget
	TNT1 A 0 A_Look
	TNT1 A 0 A_VileStart
		TNT1 A 0 A_FireCustomMissile ("MVileFireP",0,1,5,10)
	TNT1 A 0 A_SetBlend ("YELLOW",0.4,56)	
    ARCG I 12 A_FaceTarget
		TNT1 A 0 A_FireCustomMissile ("MVileFireP",0,1,5,10)
	ARCG J 12 
		TNT1 A 0 A_FireCustomMissile ("MVileFireP",0,1,5,10)
	ARCG K 12 
		TNT1 A 0 A_FireCustomMissile ("MVileFireP",0,1,5,10)
	ARCG L 12 
		TNT1 A 0 A_FireCustomMissile ("MVileFireP",0,1,5,10)
	ARCG M 12 
		TNT1 A 0 A_FireCustomMissile ("MVileFireP",0,1,5,10)
	ARCG N 12 A_FaceTarget
    TNT1 A 0 A_SetBlend ("YELLOW",0.7,20)
    TNT1 A 8 A_FireCustomMissile ("PuppetVileZNapalm")
    TNT1 A 0 A_ClearTarget
	TNT1 A 0 A_ReFire
	TNT1 A 0 ACS_ExecuteAlways(426,0,10) //added
    GOTO Ready
    TNT1 AAA 1
    TNT1 A 8
    TNT1 A 0 A_ClearTarget
	TNT1 A 0 ACS_ExecuteAlways(426,0,10) //added
    GOTO Ready

   nouse:
    TNT1 A 0
    TNT1 A 4 A_Print("cant use this")
    GOTO Altfire
    
   AltFire:
    TNT1 A 0 A_ClearTarget
    TNT1 A 5 ACS_ExecuteAlways (419,0,15)
    GOTO ready
  Raisethem:
   TNT1 A 0 A_JumpIfInventory ("seenit",1,"Heal")
   TNT1 A 1 A_print("raise dead monsters")
   GOTO Heal

  Heal:
   TNT1 A 0
   TNT1 A 0 A_TakeInventory("goraise",1)
   TNT1 A 0 SetPlayerProperty (0, 1, 4)
   TNT1 A 6 A_SetBlend ("RED",0.7,17)
   TNT1 A 0 A_JumpIfInventory ("Mskull",0,12)
   TNT1 A 0 A_Explode(1,0,false,false)
   TNT1 A 0 A_JumpIfInventory ("Mskull",5,10)
   TNT1 A 0 A_Explode(2,0,false,false)
   TNT1 A 0 A_JumpIfInventory ("Mskull",4,8)
   TNT1 A 0 A_Explode(2,0,false,false)
   TNT1 A 0 A_JumpIfInventory ("Mskull",3,6)
   TNT1 A 0 A_Explode(2,0,false,false)
   TNT1 A 0 A_JumpIfInventory ("Mskull",2,4)
   TNT1 A 0 A_Explode(2,0,false,false)
   TNT1 A 0 A_JumpIfInventory ("Mskull",1,2)
   TNT1 A 0 A_Explode(2,0,false,false)
   TNT1 A 0 A_Explode(15,0,false,false)
   TNT1 A 7 bright A_FireCustomMissile ("MVileRevive",0,0,0,0,0,0)
   TNT1 AA 15
   TNT1 A 2
   TNT1 A 0 SetPlayerProperty (0, 0, 4)
   TNT1 A 0 ACS_ExecuteAlways(426,0,10) //added 
   goto Ready	
  }
}

actor myfriend : inventory
{
inventory.maxamount 1
}

actor goraise : myfriend
{}

actor vattack2 : myfriend
{}
actor seenit : myfriend
{}

//Primary weapon
actor MVileFireP
{
  radius 4
  height 1
  speed 999
  alpha 1
  damage 1
  DamageType "viledamage"
  renderstyle add
  PROJECTILE
  +NOBLOCKMAP
  +NOGRAVITY
  PROJECTILE
  +SEEKERMISSILE
  -BLOODLESSIMPACT
  +RIPPER
  states
  {
  Spawn:
    TNT1 A 1 A_Fire 
	loop
  Death:
    FIRE A 2 bright A_StartFire
    FIRE BAB 2 bright A_Fire
    FIRE C 2 bright A_FireCrackle
    FIRE BCBCDCDCDEDED 2 bright A_Fire
    FIRE E 2 bright A_FireCrackle
    FIRE FEFEFGHGHGH 2 bright A_Fire
    stop
  }
}

//AltFire X
actor MVileFireAltX
{
  radius 4
  height 1
  speed 12
  alpha 1
  DamageType "viledamage"
  renderstyle add
  PROJECTILE
  +NOBLOCKMAP
  +NOGRAVITY
  PROJECTILE
  -BLOODLESSIMPACT
  states
  {
  Spawn:
    PAV3 AB 2
    PAV3 A 0 A_SpawnItemEx ("PuppetVileFire",random(-8,8),random(-8,8))
	loop
  Death:
    PAV3 ABCD 2
	PAV3 A 0 A_PlaySound("weapon/grenadeexplode", CHAN_WEAPON, 1, 0, ATTN_NONE)
	PAV3 A 0 A_Blast (BF_DONTWARN, 10000, 100, 20) //255 168 15
	PAV3 A 0 A_Explode(90,16,0,1)
	PAV3 A 0 A_Explode(60,32,0,1)
	PAV3 A 0 A_Explode(30,64,0,1)
    PAV3 A 0 A_Explode(25,128,0,1)
    PAV3 A 0 A_Explode(20,256,0,1)
	PAV3 A 0 A_Explode(15,512,0,1)
	PAV3 A 0 A_Explode(10,1024,0,1)
	PAV3 A 0 A_Explode(5,2048,0,1)
    stop
  }
}


//AltFire Y
actor MVileFireAltY
{
  radius 10
  height 1
  speed 24 //12
  alpha 1
  damage 1
  DamageType "viledamage"
  renderstyle add
  PROJECTILE
  +NOBLOCKMAP
  +NOGRAVITY
  +FLOORCLIP //added 4.3
  PROJECTILE
  -BLOODLESSIMPACT
  +RIPPER
		BounceCount 4
		+CANBOUNCEWATER
		+DOOMBOUNCE
		+NOBOUNCESOUND
		+NOWALLBOUNCESND
  states
  {
  Spawn:
    TNT1 A 4 A_SpawnItemEx ("PuppetVileFireRipper")
	loop
  Death:
    TNT1 A 1
    stop
  }
}




//FireTrail visual
actor PuppetVileFire
{
  radius 4
  height 1
  speed 0
  damage 0
  alpha 1
  DamageType "viledamage"
  renderstyle add
  PROJECTILE
  +NOBLOCKMAP
  +NOGRAVITY
  -BLOODLESSIMPACT
  states
  {
  Spawn:
    TNT1 A 1 A_Fire 
	GoTo Death
  Death:
    FIRE A 2 bright A_StartFire
    FIRE BAB 2 bright A_Fire
    FIRE C 2 bright A_FireCrackle
    FIRE BCBCDCDCDEDED 2 bright A_Fire
    FIRE E 2 bright A_FireCrackle
    FIRE FEFEFGHGHGH 2 bright A_Fire
    stop
  }
}


//FireTrail visual
actor PuppetVileFireRipper
{
  radius 4
  height 1
  speed 0
  damage 2
  alpha 1
  DamageType "viledamage"
  renderstyle add
  PROJECTILE
  +NOBLOCKMAP
  +NOGRAVITY
  +FLOORCLIP //added 4.3
  -BLOODLESSIMPACT
  +RIPPER
  states
  {
  Spawn:
    TNT1 A 1 A_Fire 
	GoTo Death
  Death:
    FIRE A 2 bright A_StartFire
    FIRE BAB 2 bright A_Fire
    FIRE C 2 bright A_FireCrackle
    FIRE BCBCDCDCDEDED 2 bright A_Fire
    FIRE E 2 bright A_FireCrackle
    FIRE FEFEFGHGHGH 2 bright A_Fire
    stop
  }
}








//Revive monsters
ACTOR MVileRevive
{
   Radius 30
   Height 1
   Speed 5
   PROJECTILE
   +NOCLIP
   +FLOORHUGGER
   States
   {
   Spawn:
	  TNT1 AAAA 4 A_VileChase  
	  TNT1 A 0 
      stop
   See:	
      TNT1 A 4 A_VileChase
	  stop
   Heal:
      TNT1 A 1 
      stop	  
   }
}



actor fastRaise : MVileRevive
{
speed 20
}

actor Raisefriend : MVileRevive
{

   Radius 30
   Height 1
   Speed 5
   PROJECTILE
   +NOCLIP
   +FLOORHUGGER
   DamageType getup
   Damage 1
   States
   {
spawn:
	TNT1 A 0
	TNT1 A 1 
	TNT1 A 1 A_spawnItem("fastraise",11,0)
	LOOP
DEATH:
	TNT1 A 0
	STOP
}}



//AltFire Z - homing missile invisible
ACTOR PuppetVileZNapalm
{
   Radius 8
   Height 11
   Speed 999
   Damage 15
   PROJECTILE
   DeathSound "weapons/hrlexp"
   ExplosionDamage 50
   ExplosionRadius 50
   //+SeekerMissile
   //+SCREENSEEKER
   //+Rockettrail
   +RANDOMIZE
   +DEHEXPLOSION
   Damagetype "viledamage"
      
   States
   {
   Spawn:
      TNT1 A 4 Bright
      TNT1 A 4 Bright
      goto Spawn
   Death:
      TNT1 A 1 A_SpawnItemEx("BFGGravityWaveShieldIluminate",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
	  TNT1 A 1 bright A_Explode(1,1)
	  TNT1 A 1 A_SpawnItemEx ("PuppetVileZCrackerRipper",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
			TNT1 A 1 A_SpawnItemEx ("PuppetVileZCrackerRipper",0,48,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
			TNT1 A 1 A_SpawnItemEx ("PuppetVileZCrackerRipper",48,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
			TNT1 A 1 A_SpawnItemEx ("PuppetVileZCrackerRipper",-48,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
			TNT1 A 1 A_SpawnItemEx ("PuppetVileZCrackerRipper",0,-48,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
			TNT1 A 1 A_SpawnItemEx ("PuppetVileZCrackerRipper",-48,-48,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
			TNT1 A 1 A_SpawnItemEx ("PuppetVileZCrackerRipper",48,48,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
				TNT1 A 1 A_SpawnItemEx ("PuppetVileZCrackerRipper",0,96,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
				TNT1 A 1 A_SpawnItemEx ("PuppetVileZCrackerRipper",96,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
				TNT1 A 1 A_SpawnItemEx ("PuppetVileZCrackerRipper",-96,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
				TNT1 A 1 A_SpawnItemEx ("PuppetVileZCrackerRipper",0,-96,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
				TNT1 A 1 A_SpawnItemEx ("PuppetVileZCrackerRipper",96,96,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
				TNT1 A 1 A_SpawnItemEx ("PuppetVileZCrackerRipper",-96,-96,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
      stop
   }
}

//AltFire Z - fire cracker ripper
actor PuppetVileZCrackerRipper
{
  radius 4
  height 1
  speed 0
  damage 1
  alpha 1
  DamageType "viledamage"
  renderstyle add
  PROJECTILE
  +NOBLOCKMAP
  +NOGRAVITY
  +FLOORCLIP //added 4.3
  -BLOODLESSIMPACT
  +RIPPER
  states
  {
  Spawn:
    TNT1 A 1 A_Fire 
	GoTo Death
  Death:
    FIRE A 1 bright A_StartFire
    FIRE BAB 1 bright A_Fire
    FIRE C 1 bright A_FireCrackle
    FIRE BCBCDCDCDEDED 1 bright A_Fire
  
	FIRE A 1 bright A_StartFire
    FIRE BAB 1 bright A_Fire
    FIRE C 1 bright A_FireCrackle
    FIRE BCBCDCDCDEDED 1 bright A_Fire

	FIRE A 1 bright A_StartFire
    FIRE BAB 1 bright A_Fire
    FIRE C 1 bright A_FireCrackle
    FIRE BCBCDCDCDEDED 1 bright A_Fire
   
	FIRE A 1 bright A_StartFire
    FIRE BAB 1 bright A_Fire
    FIRE C 1 bright A_FireCrackle
    FIRE BCBCDCDCDEDED 1 bright A_Fire
    FIRE E 1 bright A_FireCrackle
    FIRE FEFEFGHGHGH 1 bright A_Fire
    stop
  }
}





