// [Blue Shadow] A_SpawnItemEx combo flag used by the spawners below
// [Blue Shadow] Note that with SXF_TRANSFERAMBUSHFLAG flag, you do not need the "Deaf" variants.
const int SD_VARIANTSPAWNFLAGS = SXF_TRANSFERAMBUSHFLAG | SXF_NOCHECKPOSITION | SXF_TRANSFERSPECIAL;

// Base spawner class -----------------------------------------------------------------------------

ACTOR SmoothDoom_VariantsSpawner
{
  +ISMONSTER // [Blue Shadow] So the below monsters don't spawn when "no monsters" DMFlag is enabled
  +NOBLOCKMAP
  +NOSECTOR
  +NOGRAVITY
  +THRUACTORS
}

// ------------------------------------------------------------------------------------------------

ACTOR ZombieDice : SmoothDoom_VariantsSpawner replaces Zombieman
{
  States
  {
  Spawn:
    // [Blue Shadow] Check to see the if the "Extra Monster Sprites" option is enabled or not and
    // act accordingly.
    TNT1 A 0 NoDelay A_JumpIf(CallACS("RifleDropToggle") == 1, "RifleSpawn")
    TNT1 A 0 A_SpawnItemEx("SmoothZombieman", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
    Stop

  VariantSpawn:
    // [Blue Shadow] The above option is enabled, so either spawn a standard or one of the
    // variants.

    // [Blue Shadow] RandomSpawner would have been "cleaner" to use, but the ambush flag cannot be
    // transferred to the things it spawns if it itself is spawned by a spawner. So we have to do
    // it this way.
    TNT1 A 0 A_Jump(256, "Standard", "Variant1")

    Standard:
      TNT1 A 0 A_SpawnItemEx("SmoothZombieman", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
      Stop
    Variant1:
      TNT1 A 0 A_SpawnItemEx("ZombieV1", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
      Stop
    Variant3:
      TNT1 A 0 A_SpawnItemEx("ZombieV3", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
      Stop
     
   RifleSpawn:
     TNT1 A 0 A_JumpIf(CallACS("SpawnVariants") == 1, "RifleVariants")
   RifleNormal:
     TNT1 A 0 A_SpawnItemEx("RifleZombie0", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
      Stop
   RifleVariants:
     TNT1 A 0 A_Jump(256, "RifleStandard", "RifleVariant1")
     
   RifleStandard:
      TNT1 A 0 A_SpawnItemEx("RifleZombie0", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
      Stop
    RIfleVariant1:
      TNT1 A 0 A_SpawnItemEx("RifleZombie1", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
      Stop
    RifleVariant3:
      TNT1 A 0 A_SpawnItemEx("RifleZombie3", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
      Stop
  }
}

ACTOR SguyDice : SmoothDoom_VariantsSpawner //replaces Shotgunguy
{
  States
  {
  Spawn:
    //TNT1 A 0 NoDelay A_JumpIf(CallACS("SpawnVariants") == 1, "VariantSpawn")
    TNT1 A 0 A_SpawnItemEx("SmoothShotgunguy", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
    Stop

  VariantSpawn:
    TNT1 A 0 A_Jump(256, "Standard", "Variant1")

    Standard:
      TNT1 A 0 A_SpawnItemEx("SmoothShotgunguy", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
      Stop
    Variant1:
      TNT1 A 0 A_SpawnItemEx("SguyV1", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
      Stop
    Variant2:
      TNT1 A 0 A_SpawnItemEx("SguyV2", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
      Stop
  }
}


ACTOR ImpDice : SmoothDoom_VariantsSpawner //replaces DoomImp
{
  States
  {
  Spawn:
    //TNT1 A 0 NoDelay A_JumpIf(CallACS("SpawnVariants") == 1, "VariantSpawn")
    TNT1 A 0 A_SpawnItemEx("SmoothDoomImp", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
	stop 
	
  VariantSpawn:
    TNT1 A 0 A_Jump(256, "Standard")

    Standard:
      TNT1 A 0 A_SpawnItemEx("SmoothDoomImp", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
      Stop
    Variant2:
      TNT1 A 0 A_SpawnItemEx("ImpV2", 0, 0, 0, 0, 0, 0, 0, SD_VARIANTSPAWNFLAGS, 0, tid)
      Stop
  }
}