Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #TouhouDanmakufu[Single]
- #ScriptVersion[3]
- #Title["SampleA55"]
- #Text["SampleA55"]
- //load the default shotsheet
- #include"script/default_system/FondueShotDefine.txt"
- //----------------------------------------------------
- //Declaring Global Variables
- //The variables declared here can be used throughout the entire script.
- //However, the variables declared here are static. (They can be changed, but not by themselves as they are not in the main loop)
- //(As execution order cannot be guaranteed, random numbers cannot be used(?))
- //----------------------------------------------------
- let objEnemy;
- let objPlayer;
- let frame=0;
- let frame2=0;
- let addangle=0;
- let spinangle=0;
- let radius=150;
- //----------------------------------------------------
- //Enemy movement
- //----------------------------------------------------
- @Event
- {
- alternative(GetEventType())
- case(EV_REQUEST_LIFE)
- {
- //script requests for the enemy's life
- SetScriptResult(500);//setting enemy life to 500
- }
- }
- @Initialize
- {
- //Sets variable "objPlayer" to the Player ID
- objPlayer = GetPlayerObjectID();
- //creates and registers enemy object
- objEnemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
- ObjEnemy_Regist(objEnemy);
- //Setting the enemy's image
- let imgExRumia = GetCurrentScriptDirectory ~ "ExRumia.png"; //file path to enemy image
- ObjPrim_SetTexture(objEnemy, imgExRumia); //Setting the above image file as a texture to the enemy object(objEnemy)
- ObjSprite2D_SetSourceRect(objEnemy, 64, 1, 127, 64); //Setting the rectangle coordinates in the enemy image to use(Left, Top, Right, Bottom).
- ObjSprite2D_SetDestCenter(objEnemy); //Positioning the center of the rectangle(w/texture) at (0, 0) on the stage(top left corner).
- //Moving to the coordinate (cx, 120) in 60 frames
- let sx = GetStgFrameHeight() / 2;
- let cx = GetStgFrameWidth() / 2;//defines the variable cx as the horizontal middle of the stage. (Stage width / 2)
- ObjMove_SetDestAtFrame(objEnemy, cx, sx, 60);
- mainTask;
- }
- @MainLoop
- {
- let ex = ObjMove_GetX(objEnemy);
- let ey = ObjMove_GetY(objEnemy);
- yield;
- //Setting the enemy hit box
- ObjEnemy_SetIntersectionCircleToShot(objEnemy, ex, ey, 32);//hitbox against player bullets. 32 is the radius.
- ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ex, ey, 24);//hitbox against the player. 24 is the radius.
- //adding +1 to frame. "frame++" is equivalent to "frame = frame + 1;" or "frame += 1;"
- frame++;
- frame2++;
- if(radius>=150){
- radius--;
- }
- if(radius<=-150){
- radius++;
- }
- if(frame>=90){
- spinangle++;
- addangle+=0.5;
- }
- //if enemy life is 0
- if(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) <= 0)
- {
- //The enemy is killed immediately when life is 0
- //As this is a beginner sample script,
- //the script is ended immediately without waiting for an explosion effect.
- Obj_Delete(objEnemy);
- CloseScript(GetOwnScriptID());
- return;
- }
- }
- task mainTask{
- yield;
- fire;
- firefollowshot;
- }
- task firefollowshot{
- wait(90);
- let shot1;
- shot1 = CreateShotA1(ex,ey-150,0,0,BALL_T_RED,60);
- while(!Obj_IsDeleted(shot1)){
- ObjMove_SetAngle(shot1,ObjAngleToObj(shot1,objPlayer));
- ObjMove_SetDestAtFrame(shot1,px,py,120);
- yield;
- }
- }
- task fire{
- wait(90);
- loop{
- let angle=0;
- while(angle<359){
- shot(ex+50*cos(angle+(addangle*spinangle/25)),ey+50*sin(angle+(addangle*spinangle/25)),1,(addangle*spinangle/25)+angle,OVAL_T_CYAN,5);
- angle+=(360/2);
- }
- wait(1);
- }
- }
- task shot(x,y,speed,angle,graphic,delay){
- let obj = ObjShot_Create(OBJ_SHOT);
- ObjMove_SetPosition(obj,x,y);
- ObjMove_SetSpeed(obj,speed);
- ObjMove_SetAngle(obj,angle);
- ObjMove_SetAngularVelocity(obj,0);
- ObjShot_SetGraphic(obj,graphic);
- ObjShot_SetDelay(obj,delay);
- ObjShot_Regist(obj);
- while(Obj_IsDeleted(obj)){
- yield;
- }
- }
- function followshot(x,y,speed,angle,graphic,delay){
- let obj = ObjShot_Create(OBJ_SHOT);
- ObjMove_SetPosition(obj,x,y);
- ObjMove_SetSpeed(obj,speed);
- ObjMove_SetAngle(obj,angle);
- ObjShot_SetGraphic(obj,graphic);
- ObjShot_SetDelay(obj,delay);
- ObjShot_Regist(obj);
- return obj;
- }
- function wait(n){loop(n){yield;}}
- function ex{
- return ObjMove_GetX(objEnemy);
- }
- function ey{
- return ObjMove_GetY(objEnemy);
- }
- function px{
- return ObjMove_GetX(objPlayer);
- }
- function py{
- return ObjMove_GetY(objPlayer);
- }
- function ObjAngleToObj(obj2,obj1){
- let obj1x=ObjMove_GetX(obj1);
- let obj1y=ObjMove_GetY(obj1);
- let obj2x=ObjMove_GetX(obj2);
- let obj2y=ObjMove_GetY(obj2);
- let angleresult=atan2(obj1y-obj2y,obj1x-obj2x);
- return angleresult;
- }
- function NormalizeAngle(angle){
- angle %= 360;
- if(angle<0){ angle += 360; }
- return angle;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement