name		MissClear
type		none
lifespan	1


anim idle
@script
    void self = getlocalvar("self");

    if(frame==1){
      char Name = getentityproperty(self,"name");
      int State = getglobalvar(Name);
      if( State==NULL() ){
        setglobalvar(Name, 1);
      } else {
        setglobalvar(Name, State+1);
      }
    }
    if(frame==2){
      int Compl1 = getglobalvar("Cobra");
      int Compl2 = getglobalvar("Silent");
      int Compl3 = getglobalvar("Spring");
      int Compl4 = getglobalvar("FLAGG");
      int Compl5 = getglobalvar("Defiant");
      int Compl6 = getglobalvar("Wings");
      int ComplA = getglobalvar("AllClear");
      void file = createfilestream();

      if( Compl1==NULL() ){
        Compl1 = 0;
      }
      if( Compl2==NULL() ){
        Compl2 = 0;
      }
      if( Compl3==NULL() ){
        Compl3 = 0;
      }
      if( Compl4==NULL() ){
        Compl4 = 0;
      }
      if( Compl5==NULL() ){
        Compl5 = 0;
      }
      if( Compl6==NULL() ){
        Compl6 = 0;
      }
      if( ComplA==NULL() ){
        ComplA = 0;
      }

      //Main Mission Complete
      filestreamappend(file, Compl1, 1); //the 1 at the end is nb to make sure it starts on the first line
      //Silent Castle Complete
      filestreamappend(file, Compl2, 0);
      //Springfield Battle Complete
      filestreamappend(file, Compl3, 0);
      //Defend USS FLAGG Complete
      filestreamappend(file, Compl4, 0);
      //Defiant Space Complete
      filestreamappend(file, Compl5, 0);
      //Wings of Fury Complete
      filestreamappend(file, Compl6, 0);
      //All missions Complete
      filestreamappend(file, ComplA, 0);
      savefilestream(file, "save.txt");
    }

    if(frame==3){
      killentity(self); //Suicide!
    }
@end_script
	delay	5
	offset	1 1
	frame	data/chars/misc/empty.gif
	frame	data/chars/misc/empty.gif
	frame	data/chars/misc/empty.gif
	frame	data/chars/misc/empty.gif
