Author Topic: ※ Danmakufu Q&A/Problem thread 3 ※  (Read 489929 times)

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #840 on: October 15, 2017, 07:38:49 AM »
Hi from me again.
https://pastebin.com/qAzMJg27
The code up there summons two bosses.One of them acts fine, but the another one cannot shoot nor move, i tasked them quite correctly. What should I needed to do ?
Just keep it neutral :3

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #841 on: October 15, 2017, 03:16:05 PM »
Hi from me again.
https://pastebin.com/qAzMJg27
The code up there summons two bosses.One of them acts fine, but the another one cannot shoot nor move, i tasked them quite correctly. What should I needed to do ?

There are multiple problems in your script:

- Assuming they are sharing the same lifebar, you must place a boss collision hitbox on the second boss (objEnemy) or in the case that the second boss is an extra like Yoshika, you must provide the second boss with proper HP. This is most likely the reason why the second boss doesn't shoot - it defaults to 0 HP, and you never set it to something else. If you still have trouble, refer to https://dmf.shrinemaiden.org/wiki/Functions_(ph3)#Enemy_Object_Functions

- In your move task, the second boss never moves because you have an infinite loop running before the second boss's movement block. I suggest two tasks - one for each of the bosses. If you still have trouble, I recommend the following: https://en.wikipedia.org/wiki/Control_flow


R. P. Genocraft

  • Craftsman of absolute unpredictability
  • Boundary of productive and lazy
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #842 on: October 16, 2017, 09:42:48 PM »
If i spawn a straight laser from a random position and angle, how do I calculate the spot where it enters in contact with the walls or top of the screen?
« Last Edit: October 16, 2017, 09:45:09 PM by GenoCraft »

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #843 on: October 16, 2017, 09:49:12 PM »
If i spawn a straight laser from a random position and angle, how do I calculate the spot where it enters in contact with the walls or top of the screen?

https://en.wikipedia.org/wiki/Line?line_intersection

You know the two points that mark the start and end of your laser, and you have the four corners of the screen, so using the equations using the formulas of the two lines should be fine.

R. P. Genocraft

  • Craftsman of absolute unpredictability
  • Boundary of productive and lazy
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #844 on: October 17, 2017, 06:30:32 PM »
https://en.wikipedia.org/wiki/Line?line_intersection

You know the two points that mark the start and end of your laser, and you have the four corners of the screen, so using the equations using the formulas of the two lines should be fine.
After reading through that page, I realized I can't undertand anything... Probably because my main language isn't english so I don't understand many of the terms used there as I likely already learned them in another language...

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #845 on: October 17, 2017, 06:58:02 PM »
There's also this fun solution I worked out that is more specific than the line-line, taking note that you'll always make right triangles with the walls.

Code: [Select]
function GetSTGFrameIntersectPoint(x, y, t){
let wall = [[384,448], [0,448], [0,0], [384,0]][floor(t/90)];
let h = min( (|(wall[0]-x) / cos(t)|), (|(wall[1]-y) / sin(t)|) );
return [x + h*cos(t), y + h*sin(t)];
}

This probably works. Minimums with infinity should play nicely. I don't really want to explain the math and logic behind what exactly I'm doing here lol.
« Last Edit: October 17, 2017, 07:15:15 PM by Drake »

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

IIRawsomeII

  • Treat me as you will
    • Rawcode Studios
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #846 on: October 18, 2017, 02:49:05 AM »
I'm sorry if this is rude but it seems my question was skipped over. It's the last post in the previous page.
Let's start again

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #847 on: October 18, 2017, 04:24:31 AM »
Ah, you were just paged after a few hours and nobody noticed.

Immediate first question is, do you have a yield in your MainLoop. If not the task will yield once but never be yielded back to, so nothing will keep running.

If this isn't the problem then I'd ask you to post some more details, because it isn't super clear what you mean by "doesn't update", or whether anything else works, or what the rest of your script looks like.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

R. P. Genocraft

  • Craftsman of absolute unpredictability
  • Boundary of productive and lazy
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #848 on: October 18, 2017, 06:03:58 PM »
There's also this fun solution I worked out that is more specific than the line-line, taking note that you'll always make right triangles with the walls.

Code: [Select]
function GetSTGFrameIntersectPoint(x, y, t){
let wall = [[384,448], [0,448], [0,0], [384,0]][floor(t/90)];
let h = min( (|(wall[0]-x) / cos(t)|), (|(wall[1]-y) / sin(t)|) );
return [x + h*cos(t), y + h*sin(t)];
}

This probably works. Minimums with infinity should play nicely. I don't really want to explain the math and logic behind what exactly I'm doing here lol.
Thank you, that works just fine!

IIRawsomeII

  • Treat me as you will
    • Rawcode Studios
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #849 on: October 19, 2017, 12:12:43 AM »
Immediate first question is, do you have a yield in your MainLoop. If not the task will yield once but never be yielded back to, so nothing will keep running.
Ahh. It turns out I didn't even have the main loop at all, I didn't know It was so essential. Thanks!
Let's start again

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #850 on: October 19, 2017, 04:21:54 AM »
Task scheduling and yielding work by having the program execute a script until it hits a yield, at which point it stops where it is and "puts it aside" in a queue for later. In most cases, you'll start a bunch of tasks from @Initialize, which only runs once, so the tasks started there will run a bit, yield (or end), and eventually @Initialize finishes. After this the @MainLoop runs once per frame, even if it's empty or you didn't write anything. If you leave it like this without a yield in it, there's nothing to tell the script engine to go back to those other tasks. If you put a yield in, then the MainLoop will hit it, the script engine goes "ok I'll save the MainLoop for later" and puts it at the back of the task queue, picks up at the start of the queue, and goes through all the tasks until it reaches the MainLoop again, which might have some more code left, finishes, and the script waits for the next frame for it to run again.

To explore this, you can try putting two yields in the MainLoop, and all the tasks will run "twice as fast", because the task scheduler will go through the whole queue twice before the MainLoop ends.
« Last Edit: October 19, 2017, 04:24:35 AM by Drake »

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

IIRawsomeII

  • Treat me as you will
    • Rawcode Studios
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #851 on: October 19, 2017, 04:25:48 AM »
Task scheduling and yielding work by having the program execute a script until it hits a yield, at which point it stops where it is and "puts it aside" in a queue for later. In most cases, you'll start a bunch of tasks from @Initialize, which only runs once, so the tasks started there will run a bit, yield (or end), and eventually @Initialize finishes. After this the @MainLoop runs once per frame, even if it's empty or you didn't write anything. If you leave it like this without a yield in it, there's nothing to tell the script engine to go back to those other tasks. If you put a yield in, then the MainLoop will hit it, the script engine goes "ok I'll save the MainLoop for later" and puts it at the back of the task queue, picks up at the start of the queue, and goes through all the tasks until it reaches the MainLoop again, which might have some more code, finishes, and the script waits for the next frame for it to run again.

To explore this, you can try putting two yields in the MainLoop, and all the tasks will run "twice as fast", because the task scheduler will go through the whole queue twice before the MainLoop ends.
Interesting. But I don't want to clog the thread with our conversation. It's the garage, not the recovery centre. But thanks for sharing!
Let's start again

IIRawsomeII

  • Treat me as you will
    • Rawcode Studios
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #852 on: October 20, 2017, 03:29:00 AM »
I have two problems.

1) I get this error saying: EnemyBossSceneが作成されていません. I have no idea what it means but it probably due to my lack of knowledge on how to make a boss script. script: https://pastebin.com/4VP6srRa
2) It seems my player is displaced, more specifically the sprite is displaced from where the actual object is. I tried changing the boundaries and the sprite is in place but the actual object is not. script: https://pastebin.com/daXa4WsX

Don't feel the need to solve the two simultaneously. It's fine just to do one.
Let's start again

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #853 on: October 20, 2017, 04:12:56 AM »
I have two problems.

1) I get this error saying: EnemyBossSceneが作成されていません. I have no idea what it means but it probably due to my lack of knowledge on how to make a boss script. script: https://pastebin.com/4VP6srRa

You only need a scene object in single scripts. Your script is a plural. You are also creating a boss object, which makes no sense given that the plural is a container that creates the 'boss battle' itself.

Please refer to: https://sparen.github.io/ph3tutorials/ph3u2l12.html

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #854 on: October 20, 2017, 04:52:53 AM »
More specifically, you're using GetEnemyBossSceneObjectID to try and get the boss scene, which isn't created yet (you create it in TPlural). Then you try to StartSpell it when it isn't set up so it errors, but as Sparen says it isn't what you'd be doing in the plural anyways. Get rid of those calls, you don't need or want them. You also don't call TPlural anywhere so that never runs.

As for the second, I dunno why you set up an extra Sprite object to draw the player sprite when Player objects already are one. But your actual problem is just that you use Obj_SetRenderPriority which ranges from 0 to 1 instead of Obj_SetRenderPriorityI which ranges from 0 to 100, so 50 and 31 just max out to 1 and the sprites are drawn above the frame, which makes the origin the top-left of the screen instead of the play area.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

IIRawsomeII

  • Treat me as you will
    • Rawcode Studios
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #855 on: October 20, 2017, 03:39:34 PM »
You only need a scene object in single scripts. Your script is a plural. You are also creating a boss object, which makes no sense given that the plural is a container that creates the 'boss battle' itself.

Please refer to: https://sparen.github.io/ph3tutorials/ph3u2l12.html

More specifically, you're using GetEnemyBossSceneObjectID to try and get the boss scene, which isn't created yet (you create it in TPlural). Then you try to StartSpell it when it isn't set up so it errors, but as Sparen says it isn't what you'd be doing in the plural anyways. Get rid of those calls, you don't need or want them. You also don't call TPlural anywhere so that never runs.

As for the second, I dunno why you set up an extra Sprite object to draw the player sprite when Player objects already are one. But your actual problem is just that you use Obj_SetRenderPriority which ranges from 0 to 1 instead of Obj_SetRenderPriorityI which ranges from 0 to 100, so 50 and 31 just max out to 1 and the sprites are drawn above the frame, which makes the origin the top-left of the screen instead of the play area.

Drake) 2) Ah thanks so much. It worked.
Drake & Sparen) 1) Ah It does work... but what do I do for a boss to appear like making a boss in a single script. Do I just make a boss for all the single scripts?
Let's start again

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #856 on: October 20, 2017, 04:56:20 PM »
Drake) 2) Ah thanks so much. It worked.
Drake & Sparen) 1) Ah It does work... but what do I do for a boss to appear like making a boss in a single script. Do I just make a boss for all the single scripts?

In every single script that is part of a boss scene, create a new boss object. For more information, please read the tutorials.

IIRawsomeII

  • Treat me as you will
    • Rawcode Studios
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #857 on: October 20, 2017, 05:36:31 PM »
In every single script that is part of a boss scene, create a new boss object. For more information, please read the tutorials.
Thanks!
Let's start again

R. P. Genocraft

  • Craftsman of absolute unpredictability
  • Boundary of productive and lazy
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #858 on: October 21, 2017, 12:13:11 PM »
The fact that you're replaying music tracks at the start of every single worries me. I suggest loading and playing music tracks in either a Stage or Plural, whichever you use.

In general, if a task must run for the duration of a boss fight, don't run an abbreviated version at the start of every single if it's going to have a significant effect on the player's experience.
Still on this, how do I change the music mid-battle? I want a certain song to play for the first 3 singles and then change to another one.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #859 on: October 21, 2017, 01:52:30 PM »
Still on this, how do I change the music mid-battle? I want a certain song to play for the first 3 singles and then change to another one.

You can use NotifyEventAll to control the playing and stopping of music tracks (be sure to adjust your pause on and off events too so that they pause the correct music track). Assuming you have a plural/stage user event for playing bgm and stopping bgm, you can call the respective events to stop the old one and start the new one  at the start of the fourth single. You will probably need a CommonData so that the rest of the plural/stage knows that you are using the second bgm instead of the first.

IIRawsomeII

  • Treat me as you will
    • Rawcode Studios
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #860 on: October 21, 2017, 04:54:56 PM »
Code: [Select]
//So I have this problem with GetShotIdInCircleA1 where it's not getting anything!

//wait(60); Commented this out just to test quickly
let bullets = GetShotIdInCircleA1(x,y,99999); // This Should Get every Bullet. I Just set it to 99999 to test it.
ascent(i in 0..length(bullets)) // Foreach bullet in bullets...
{
ObjMove_SetAngle(bullets[i], GetAngleToPlayer(bullets[i])); // Set Bullet Angle to Player
        Obj_Delete(bullets[i]); // Here for debugging purposes
}
Obj_Delete(bullets[0]); // I tried this to try to find why the code dosen't work and It's apparently because the array index is out of range.
// Thanks!
Let's start again

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #861 on: October 21, 2017, 06:39:05 PM »
Code: [Select]
//So I have this problem with GetShotIdInCircleA1 where it's not getting anything!

//wait(60); Commented this out just to test quickly
let bullets = GetShotIdInCircleA1(x,y,99999); // This Should Get every Bullet. I Just set it to 99999 to test it.
ascent(i in 0..length(bullets)) // Foreach bullet in bullets...
{
ObjMove_SetAngle(bullets[i], GetAngleToPlayer(bullets[i])); // Set Bullet Angle to Player
        Obj_Delete(bullets[i]); // Here for debugging purposes
}
Obj_Delete(bullets[0]); // I tried this to try to find why the code dosen't work and It's apparently because the array index is out of range.
// Thanks!

1. What are you trying to do
2. If run before there are any bullets spawned, it will always fail because bullets[] will be empty - that is likely the cause of your problem

IIRawsomeII

  • Treat me as you will
    • Rawcode Studios
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #862 on: October 21, 2017, 06:51:44 PM »
1. What are you trying to do
2. If run before there are any bullets spawned, it will always fail because bullets[] will be empty - that is likely the cause of your problem
Sorry if the post wasn't clear, I was experimenting with my post.

So my spell spawn rings of bullets from the boss. She will also occasionally fire curved lasers aiming for the player.
When the laser reaches the target position they will make all the bullets around the area of landing, aim towards the player. The snippet is the function that gets the bullets and makes them aim.

I removed the offending lines of code but it still doesn't work. I'll include more of the script:

Code: [Select]
task fire02
{
while(true)
{
let objLaser = CreateCurveLaserA1(ObjMove_GetX(bossObj), ObjMove_GetY(bossObj), 4, GetAngleToPlayer(bossObj), 60, 18, DS_SCALE_WHITE, 10);
let playerX = GetPlayerX;
let playerY = GetPlayerY;
ObjMove_AddPatternA2(objLaser, 5, 1, NO_CHANGE, 0, 1, 50);
ObjMove_AddPatternA2(objLaser, 25, 1, NO_CHANGE, 0.1, -1, 2);
wait(60);
ObjMove_SetDestAtFrame(objLaser,playerX,playerY,20); // Aim to player
deleteIn(objLaser,120); // Delete in 2 seconds
changeBullets(playerX, playerY) // Affect the bullets
}
}

task changeBullets(x,y)
{
wait(60);
let bullets = GetShotIdInCircleA1(x,y,99999);
ascent(i in 0..length(bullets))
{
ObjMove_SetAngle(bullets[i], GetAngleToPlayer(bullets[i]));
Obj_Delete(bullets[i]);
}
}
Let's start again

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #863 on: October 21, 2017, 07:29:25 PM »
Sorry if the post wasn't clear, I was experimenting with my post.

So my spell spawn rings of bullets from the boss. She will also occasionally fire curved lasers aiming for the player.
When the laser reaches the target position they will make all the bullets around the area of landing, aim towards the player. The snippet is the function that gets the bullets and makes them aim.

I removed the offending lines of code but it still doesn't work. I'll include more of the script:

Code: [Select]
task fire02
{
while(true)
{
let objLaser = CreateCurveLaserA1(ObjMove_GetX(bossObj), ObjMove_GetY(bossObj), 4, GetAngleToPlayer(bossObj), 60, 18, DS_SCALE_WHITE, 10);
let playerX = GetPlayerX;
let playerY = GetPlayerY;
ObjMove_AddPatternA2(objLaser, 5, 1, NO_CHANGE, 0, 1, 50);
ObjMove_AddPatternA2(objLaser, 25, 1, NO_CHANGE, 0.1, -1, 2);
wait(60);
ObjMove_SetDestAtFrame(objLaser,playerX,playerY,20); // Aim to player
deleteIn(objLaser,120); // Delete in 2 seconds
changeBullets(playerX, playerY) // Affect the bullets
}
}

task changeBullets(x,y)
{
wait(60);
let bullets = GetShotIdInCircleA1(x,y,99999);
ascent(i in 0..length(bullets))
{
ObjMove_SetAngle(bullets[i], GetAngleToPlayer(bullets[i]));
Obj_Delete(bullets[i]);
}
}

Firstly, I recommend reading the description of GetShotIdInCircleA1: https://dmf.shrinemaiden.org/wiki/Shot_Functions#GetShotIdInCircleA1
You should probably use GetShotIdInCircleA2 with TARGET_ENEMY.

Secondly, changeBullets(playerX, playerY) is based on the player's location, not that of the laser. Keep that in mind.

IIRawsomeII

  • Treat me as you will
    • Rawcode Studios
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #864 on: October 21, 2017, 07:48:22 PM »
Firstly, I recommend reading the description of GetShotIdInCircleA1: https://dmf.shrinemaiden.org/wiki/Shot_Functions#GetShotIdInCircleA1
You should probably use GetShotIdInCircleA2 with TARGET_ENEMY.

Secondly, changeBullets(playerX, playerY) is based on the player's location, not that of the laser. Keep that in mind.
It works! Thanks.
Let's start again

IIRawsomeII

  • Treat me as you will
    • Rawcode Studios
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #865 on: October 22, 2017, 04:40:19 PM »
Rawcode Here:

Is there a way to detect what graphic is a bullet. Or better yet some way to "Tag" a bullet and read that tag?
Thanks.
Let's start again

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #866 on: October 22, 2017, 05:18:52 PM »
Rawcode Here:

Is there a way to detect what graphic is a bullet. Or better yet some way to "Tag" a bullet and read that tag?
Thanks.

What exactly are you trying to do? Both you as the scripter and the players who are playing your game should always be able to know what graphic is a bullet. In your case, you know on a code level because any graphic that's not boss/player/effect/etc. is going to be a bullet (and you as the scripter decide where the bullet are and where they go), while for the player, if they can't distinguish what is and is not a bullet, they're not going to have a fun time playing your script.

In short, you are creating the bullets. Therefore, you always know which graphic is a bullet and which one is not. If you are trying to get the graphic corresponding to a bullet, use https://dmf.shrinemaiden.org/wiki/Shot_Object_Functions#ObjShot_GetImageID

In the future, please refer to the tutorials and wiki function list to see if your question can be answered with an existing function. Also, it is important to state what you are trying to achieve, so that we can assist you more effectively.

IIRawsomeII

  • Treat me as you will
    • Rawcode Studios
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #867 on: October 22, 2017, 05:56:35 PM »
What exactly are you trying to do? Both you as the scripter and the players who are playing your game should always be able to know what graphic is a bullet. In your case, you know on a code level because any graphic that's not boss/player/effect/etc. is going to be a bullet (and you as the scripter decide where the bullet are and where they go), while for the player, if they can't distinguish what is and is not a bullet, they're not going to have a fun time playing your script.

In short, you are creating the bullets. Therefore, you always know which graphic is a bullet and which one is not. If you are trying to get the graphic corresponding to a bullet, use https://dmf.shrinemaiden.org/wiki/Shot_Object_Functions#ObjShot_GetImageID

In the future, please refer to the tutorials and wiki function list to see if your question can be answered with an existing function. Also, it is important to state what you are trying to achieve, so that we can assist you more effectively.
Ah Thanks. And I'm sorry if the lack of information is impairing your ability to help me effectively, Next time I'll state my goal.
Also sorry about not finding the function, I swear I searched the list but I didn't find what I needed.
Let's start again

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #868 on: October 23, 2017, 06:39:48 PM »
As an aside, if you do for whatever reason need to "tag" individual shot objects with specific information that you couldn't otherwise get already, you can use the Obj_SetValue/GetValue functions to do so.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

IIRawsomeII

  • Treat me as you will
    • Rawcode Studios
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #869 on: October 29, 2017, 07:19:30 PM »
It's me Again!
So I'm trying to load the next scene in a Boss Scene object, but my attempts have come up futile. I have no Idea on how to do it. Can you help me?
Code: [Select]
#TouhouDanmakufu[Plural]
#ScriptVersion[3]
#Title["Koishi Komeji"]
#Text["Koishi is acting up again"]

let dir = GetCurrentScriptDirectory();
let obj = ObjEnemyBossScene_Create(); // Make the boss scene object

@Initialize
{
SetCommonData("ScriptID", GetOwnScriptID());
TPlural;
}
@Event
{
alternative(GetEventType)
case(EV_USER)
{
ObjEnemyBossScene_StartSpell(obj);
ObjEnemyBossScene_LoadInThread(obj); // Load
}
}
@MainLoop
{
    yield;
}
task TPlural
{
// Define Scripts
ObjEnemyBossScene_Add(obj, 0, dir ~ "non01.txt");
ObjEnemyBossScene_Add(obj, 0, dir ~ "spell01.txt");

    ObjEnemyBossScene_LoadInThread(obj); // Load
    ObjEnemyBossScene_Regist(obj); // And register

while(!Obj_IsDeleted(obj)){yield}; // yield while the Boss is not deleted
    CloseScript(GetOwnScriptID()); // Close if it the boss died
}

function GetCenterX(){
     return GetStgFrameWidth() / 2;
}
function GetCenterY(){
     return GetStgFrameHeight() / 2;
}

Thanks.
Let's start again