// Written by Marco, TEMP fix mod for KF.
class a_CharFix extends Info;

// #exec obj load file="MeshMod.u" Package="KFCharFix"
#exec obj load file="KF_Freaks_Trip.ukx"
#exec obj load file="KF_Freaks2_Trip.ukx"


simulated function PreBeginPlay()
{
  local State S;
  local Class<KFMonster> KCM;
  local KFMonster M;

  // Fix defaults.
  foreach AllObjects(Class'State',S)
  {
    KCM = Class<KFMonster>(S);
    if( KCM==None || KCM.Default.Mesh!=None )
      continue;
    if( Class<ZombieBloatBase>(KCM)!=None )
      FixMonsterMesh(KCM,Mesh'Bloat_Freak');
    else if( Class<ZombieBossBase>(KCM)!=None )
      FixMonsterMesh(KCM,Mesh'Patriarch_Freak');
    else if( Class<ZombieClotBase>(KCM)!=None )
      FixMonsterMesh(KCM,Mesh'CLOT_Freak');
    else if( Class<ZombieCrawlerBase>(KCM)!=None )
      FixMonsterMesh(KCM,Mesh'Crawler_Freak');
    else if( Class<ZombieFleshPoundBase>(KCM)!=None )
      FixMonsterMesh(KCM,Mesh'FleshPound_Freak');
    else if( Class<ZombieGorefastBase>(KCM)!=None )
      FixMonsterMesh(KCM,Mesh'GoreFast_Freak');
    else if( Class<ZombieHuskBase>(KCM)!=None )
      FixMonsterMesh(KCM,Mesh'Burns_Freak');
    else if( Class<ZombieScrakeBase>(KCM)!=None )
      FixMonsterMesh(KCM,Mesh'Scrake_Freak');
    else if( Class<ZombieSirenBase>(KCM)!=None )
      FixMonsterMesh(KCM,Mesh'Siren_Freak');
    else if( Class<ZombieStalkerBase>(KCM)!=None )
      FixMonsterMesh(KCM,Mesh'Stalker_Freak');
  }

  // Fix existing actors.
  foreach AllActors(Class'KFMonster',M)
  {
    if( M.Mesh==None && M.Default.Mesh!=None && (ZombieBloatBase(M)!=None || ZombieBossBase(M)!=None
         || ZombieClotBase(M)!=None || ZombieCrawlerBase(M)!=None || ZombieFleshPoundBase(M)!=None || ZombieGorefastBase(M)!=None
         || ZombieHuskBase(M)!=None || ZombieScrakeBase(M)!=None || ZombieSirenBase(M)!=None || ZombieStalkerBase(M)!=None) )
    {
      M.Skins = M.Default.Skins;
      M.LinkMesh(M.Default.Mesh);
    }
  }
}

simulated final function FixMonsterMesh( Class<Actor> AC, Mesh Mdl )
{
  local int i;

  // Using hack method, alter default.
  class'u_MeshMod'.Static.SetMeshDefault(AC,Mdl);

  // If invalid skins, empty the array.
  for( i=0; i<AC.Default.Skins.Length; ++i )
  {
    if( AC.Default.Skins[i]==None )
    {
      AC.Default.Skins.Length = 0;
      break;
    }
  }
}