#TouhouDanmakufu[Player]
#ScriptVersion[2]
#Menu[Lymia]
#Text[Lymia's unfocused shot is angled, which gives her a wide range, but it won't hit directly in front of her. The focused shot is aimed straight forward, however, which makes it more useful during boss fights. Overall, she's a very balanced and fluffy character.]
#Image[.\selectimg\0.png]
#ReplayName[Lymia]

script_player_main{

  #include_function ".\playerfunctions.txt"
  #include_function ".\effects.txt"
  #include_function ".\lymia.txt"
  #include_function ".\lymia_functions.txt"
  #include_function ".\lymia_functions_main.txt"
  #include_function ".\raibys.txt"
  #include_function ".\raibys_functions.txt"
  #include_function ".\nhimor.txt"
  #include_function ".\nhimor_functions.txt"

  defaulthitbox=0;  // 0 = burst (Castle Shikigami-type), 1 = normal (standard Touhou), 2 = none
                    // usually is changed in-game, but for use in other scripts, just change this


  let playernum=-1;


  let count=-1;
  let i=0;
  let angleshot=0;
  let color=0;
  let shottype=0;

  let Pose=0;
  let Dir=0;
  let Frame=0;
  let Rot=0;
  let Focus=0;
  let playershot=-1;
  let deadframes=0;
  let locky=-1;

  let XOffset=[0,-2,2];
  let YOffset=[-1,-2,-2];
  let Left=[0,42,42];
  let Right=[42,76,76];
  let Flip=[1,-1,1];

  @Initialize{
    InitDelay;
    SetAutoEffect(false);
    PlayerForbidShotOff;
    DeleteCommonData("FakeDeath");
    SetRebirthFrame(9);
    SetRebirthFrameReduction(3);
  }

  let initialbombs=[3,3,4,0,0,0,0];

  task InitDelay{
	yield;
	playernum=0;
	SetCommonData("explayer",GetKeyState(VK_SKIP)!=KEY_FREE);
	if(playernum==0){LymiaInit(0);}
	else if(playernum==1){RaibysInit(0);}
	else if(playernum==2){NhimorInit(0);}
	if(playernum>=0){
		SetInitialBombCount(initialbombs[playernum]);
	}
	LoadGraphic(img_effects);
	EffectTask;
  }

let angle1=[30,35,30,20,15,20];
let angle2=[20,15,20,30,35,30];

  @MainLoop{
    if(GetCommonDataDefault("FakeDeath",0)==1){
	PlaySE("se\sePlayerCollision.wav");
	let k=1;
	loop(3){
		RainbowExplosion(GetPlayerX,GetPlayerY,k*10,k+2,1);
		k++;
	}
	RainbowExplosion(GetPlayerX,GetPlayerY,30,5,0);
	RainbowExplosion(GetPlayerX,GetPlayerY,60,50,0);
	SetY(800);
	ResetPositions(1);
	ResetPositions(0);
	DeleteCommonData("FakeDeath");
    }
    if(GetCommonDataDefault("ResetAWCBombs",false)==true){
	if(playernum>=0&&playernum!=6){
		if(initialbombs[playernum]>GetPlayerBomb){
			AddBomb(initialbombs[playernum]-GetPlayerBomb);
		}
	}
	DeleteCommonData("ResetAWCBombs");

    }

    if(playernum==0){LymiaMainLoop;}
    else if(playernum==1){RaibysMainLoop;}
    else if(playernum==2){NhimorMainLoop;}

    dead=0;
    deadframes=0;

    if(GetCommonDataDefault("Dialogue",0)==0){
	SetIntersectionCircle(GetPlayerX, GetPlayerY, 0);
    }

    if(locky!=-1){
	SetY(locky);
    }
    if(GetCommonDataDefault("DialogueChoice",0)==1){
	locky=GetPlayerY;
    }else{
	locky=-1;
    }

    yield;
  }
  let nodrawfocus=0;
  @Missed{
	frame++;
	if(playernum!=6){
		HandleDeath;
	}else{
		HandleDeath2;
	}
	deadframes++;
	yield;
  }
  @SpellCard{
	if(playernum==0){LymiaSpell;}
	else if(playernum==1){RaibysSpell;}
	else if(playernum==2){NhimorSpell;}
  }

  @DrawLoop{
	if(playernum==0){LymiaDrawLoop;}
	else if(playernum==1){RaibysDrawLoop;}
	else if(playernum==2){NhimorDrawLoop;}
	if(playernum>=0){
		DrawFocus;
	}
  }

  @Finalize{
	if(playernum==0){LymiaFinalize;}
	else if(playernum==1){RaibysFinalize;}
	else if(playernum==2){NhimorFinalize;}
	DeleteGraphic(img_effects);
  }
}

script_spell LymiaU{
	#include_function ".\lymia_spell1.txt"
}
script_spell LymiaF{
	#include_function ".\lymia_spell2.txt"
}
script_spell RaibysU{
	#include_function ".\raibys_spell1.txt"
}
script_spell RaibysF{
	#include_function ".\raibys_spell2.txt"
}
script_spell NhimorU{
	#include_function ".\nhimor_spell1.txt"
}
script_spell NhimorF{
	#include_function ".\nhimor_spell2.txt"
}