#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Nonspell1"]
#Text["Woop"]


let objBoss;

let BossX;
let BossY;

let AttackX;
let AttackY;

#include "./Functions/Index.txt"
#include "./Functions/Dialogue.txt"


@Initialize {
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	RenderClause(objBoss);
	BossShotSound(objBoss, 50, 600);
	DrawName("Wilhelm von Clausewitz Halcyon HISUIMARUUUU", [255, 0, 255], 12.7);
	BottomEnemyMarker(objBoss, objBoss);
	MagicRing(objBoss, true);
	ObjMove_SetPosition(objBoss, -50,-50);
	DialogueStart;
	end;

} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(4500);
     	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(80000000);
	}
	case(EV_REQUEST_SPELL_SCORE){
		SetScriptResult(1000000);
	}
} 

@MainLoop {
	BossX = ObjMove_GetX(objBoss);
	BossY = ObjMove_GetY(objBoss);
	
	ObjEnemy_SetIntersectionCircleToShot(objBoss,BossX,BossY,21);
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,BossX,BossY,16);
	yield;
} 

@Finalize {

} 

task DialogueStart{
wait(50);
	SetForbidPlayerShot(true);
	SetForbidPlayerSpell(true);
SetCommonData("PlayerCutin",Characters[0][0]);
SetCommonData("PlayerTalk",0);
DialogueCutinPlayer;
DialogueBox;
Dialogue(0, "...Why does everything look so colorful?", 0, 0,  0,0,0);

	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);
	
Dialogue(0, "What's going on here.", 0, 4,  0,0,0);

	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);
	
ObjMove_SetDestAtWeight(objBoss,GetStgFrameWidth/2,GetStgFrameHeight/4, 5, 2);
Intro;
Dialogue(1, "Oh, Nothing at &quot;all!&quot;, Nothing at aaall.", 0, 0,  0,0,0);

	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);
	
DialogueCutinBoss;
Dialogue(1, "We've been &quot;Busy&quot; trying out these new[r]&quot;Looks&quot;", 0, 0,  0,0,0);

	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);
	
Dialogue(1, "I &quot;feel&quot; like they &quot;Make&quot; us &quot;Pretty&quot;[r] and &quot;Colorful&quot;.", 0, 1,  0,0,0);

	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);

Dialogue(1, "Not to &quot;Mention&quot; how almost everybody[r] doesn't really &quot;Like&quot; it.", 0, 0,  0,0,0);

	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);
	
Dialogue(0, "What... are we talking about here...?", 0, 3,  0,0,0);

	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);

Dialogue(1, "It's a little &quot;Something&quot; I and some other[r] &quot;People&quot; like to call...", 0, 1,  0,0,0);

	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);
	
	SATURATION;
	
	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);

Dialogue(0, "R-right...", 0, 3,  0,0,0);

	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);
	
Dialogue(0, "I still don't believe you..", 0, 0,  0,0,0);

	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);
	
Dialogue(1, "Oh, Is that &quot;So&quot;?", 0, 10,  0,0,0);

	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);
	
Dialogue(1, "Bring in the &quot;Test&quot; &quot;Subject&quot; number 1!", 0, 5,  0,0,0);
ObjMove_SetDestAtWeight(objBoss,GetStgFrameWidth/2+75,GetStgFrameHeight/4, 5, 2);

	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);
SetCommonData("PlayerTalk",2);

let obj = OhHellNo;
ObjMove_SetPosition(obj, -100, -100);
ObjMove_SetDestAtWeight(obj,GetStgFrameWidth/2-75,GetStgFrameHeight/4-20, 5, 4);

wait(120);

Dialogue(1, "Hai!", 1, 0,  0,0,0);

	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);
	
TimedDialogue(1, "OH HELL NOOOOOAAAAWHHH", 0, 11,  10,10,22.5, 60*5);
ObjMove_SetDestAtWeight(objBoss,GetStgFrameWidth/2+100,GetStgFrameHeight/4, 5, 2);
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/ohhellno.mp3", 70);
wait(60*5);
SetCommonData("PlayerTalk",2);

ObjMove_SetDestAtWeight(objBoss,GetStgFrameWidth/2-100,GetStgFrameHeight/4-20, 5, 15);
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/punch.wav", 70);
wait(10);

Smoking(obj);
ObjMove_SetDestAtFrame(obj, -100, -100, 40);
wait(30);
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/smashdeath.wav", 70);
wait(10);
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/smashgame.wav", 70);

wait(180);

Dialogue(1, "With that out of the way...", 0, 2,  0,0,0);
ObjMove_SetDestAtWeight(objBoss,GetStgFrameWidth/2,GetStgFrameHeight/4, 5, 2);

	wait(5);
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(5);

wait(40);
SetForbidPlayerShot(false);
SetForbidPlayerSpell(false);
TimedDialogue(1, "I will &quot;Teach&quot; you how it's &quot;Done&quot;", 0, 1,  0,0,0, 60*3);
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
SetCommonData("Play",1);
wait(60*3);
mainTask;
TimedDialogue(1, "First, A special &quot;Kind&quot; of light Magic[r]is used.", 0, 0,  0,0,0, 60*3);
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
wait(60*3);
TimedDialogue(1, "It's main &quot;Purpose&quot; is to amplify Light[r] entering the Retina.", 0, 0,  0,0,0, 60*4);
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
wait(60*4);
TimedDialogue(1, "The more Light entering the Retina, [r]the more colors there are.", 0, 0,  0,0,0, 60*3);
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
wait(60*3);
TimedDialogue(1, "And thus, everything becomes a lot more [r]prettier!", 0, 1,  0,0,0, 60*3);
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
wait(60*3);
TimedDialogue(1, "But of course, You still need to be able to SEE.", 0, 1,  0,0,0, 60*3);
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
wait(60*3);
TimedDialogue(1, "Blahblahblahblahblahblahblahblahblahblahblah", 0, 1,  0,0,0, 60*3);
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
wait(60*3);
TimedDialogue(1, "Blahblahblahblahblahblahblahblahblahblahblah", 0, 1,  0,0,0, 60*3);
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
wait(60*3);
TimedDialogue(1, "(you can fire btw)", 0, 1,  0,0,0, 60*3);
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
wait(60*3);
	loop{
	TimedDialogue(1, "Blahblahblahblahblahblahblahblahblahblahblah", 0, 1,  0,0,0, 60*3);
	SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/talk_00.wav", 200);
	wait(60*3);
	}
}

task Smoking(obj){
	while(!Obj_IsDeleted(obj)){
	Smoke(obj);
	wait(15);
	}
}

task Intro{
let seobj = ObjSound_Create;
ObjSound_Load(seobj, GetCurrentScriptDirectory ~ "/Functions/sfx/bossintro.ogg");
ObjSound_Play(seobj);
ObjSound_SetVolumeRate(seobj,90);
loop(1850){yield;}
RemoveSound(path);
}

let Gravity;

task mainTask { 
ObjMove_SetDestAtWeight(objBoss,GetStgFrameWidth/2,GetStgFrameHeight/4, 5, 4);
wait(70);
GravityLoop;
	loop{
	ascent(j in 0..6){
		ascent(i in 0..20){
		let obj = CreateShotA1(BossX, BossY, rand(1,2), rand(0,360),CG_BULLET_PURPLE, 0);
		Boop(obj, ObjMove_GetSpeed(obj));
		let obj2 = CreateShotA1(BossX, BossY, rand(1,2), rand(0,360),PELLET_PURPLE, 0);
		Boop(obj2, ObjMove_GetSpeed(obj2));
		}
		SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/e_shot_00.wav", 60);
		wait(15);
		}
	wait(60);
	}
	task GravityLoop{
		loop{
		Gravity = GravityPush(GetStgFrameWidth/2,25, 0);
		MoveGrav(Gravity);
		wait(120);
		}
	}
	task MoveGrav(obj){
	let mult = 1;
		while(!Obj_IsDeleted(obj)){
		ObjMove_SetPosition(obj, GetStgFrameWidth/2, ObjMove_GetY(obj)+(5*mult));
		mult+=0.2;
		yield;
		}
	}
	task Boop(obj, spd){
	let count = 0;
		while(!Obj_IsDeleted(obj)){
			if(ObjMove_GetY(Gravity)+25>ObjMove_GetY(obj)&&count==0){
			ObjMove_AddPatternA1(obj, 0, spd+rand(1,2), NO_CHANGE);
			count++;
			}
		yield;
		}
	}
}

task end{
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
	SetCommonData("EndDialogue",1);
    Obj_Delete(objBoss);
	wait(1);
	SetCommonData("deathsound",1);
    DeleteShotAll(TYPE_ALL, TYPE_ITEM);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
} 
