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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1350 on: June 12, 2018, 07:00:34 PM »
If you could give the code, it would be much appreciated! I just want to experiment with it until I get a feel, then get it how I want it

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1351 on: June 12, 2018, 07:23:36 PM »
It's a little long, but here's the code example (abridged).

Code: [Select]
    task SpawnRings{
let randoffset = rand(0,360);
        let numshiki = [6, 6, 8, 9];
ascent(i in 0..numshiki[diff]){AnchorBullet(randoffset+i*360/numshiki[diff]);}
    }
This task runs numshiki instances of the AnchorBullet task.
Code: [Select]
    task AnchorBullet(ang){
let obj = CreateShotA2Alt(GetEnemyX(objBoss), GetEnemyY(objBoss), 3, ang, -0.05, 0, S_LAURAORB_DARKBLUE + S_AO, 0);
let objcount = 0;
ObjShot_SetSpellResist(obj, true);
while(ObjMove_GetSpeed(obj)>0){yield;}
let randoffset = rand(0,360);
        let numinring = [5, 6, 8, 9];
        let numinline = [2, 3, 5, 6];
ascent(i in 0..numinring[diff]){//greater om higher difficulties.
    if(ObjEnemy_GetInfo(objBoss, INFO_LIFE) <= 0){return;}//Default kill to prevent (0,0) spawning
    ascent(j in 0..numinline[diff]){
                let obj2 = CreateShotA1Alt(GetEnemyX(objBoss), GetEnemyY(objBoss), 0, 0, S_DKSUPP_DARKBLUE, 0);
        BulletCommandsA1(obj2, obj, i, numinring[diff], j, randoffset);
    }
    GS(SFX_WAVE);
    objcount++;
    yield;
}
loop(150){//wait for last suppository to fire
    objcount++;
    yield;
}
Obj_Delete(obj);
    }
This task creates 'parent' bullets. Each parent bullet runs the double ascent loop to create 'child' bullets.
Code: [Select]
    task BulletCommandsA1(obj, parent, ID, numinring, rowID, offset){
ObjMove_SetDestAtFrame(obj, ObjMove_GetX(parent)+30*cos(ID*360/numinring), ObjMove_GetY(parent)+30*sin(ID*360/numinring), 60);
let objcount = offset;
descent(i in 1..60){
    ObjMove_SetDestAtFrame(obj, ObjMove_GetX(parent)+30*cos(ID*360/numinring+objcount), ObjMove_GetY(parent)+30*sin(ID*360/numinring+objcount), i);
    objcount++;
    yield;
}
loop(90){
    ObjMove_SetAngle(obj, ID*360/numinring+objcount);
    ObjMove_SetPosition(obj, ObjMove_GetX(parent)+30*cos(ID*360/numinring+objcount), ObjMove_GetY(parent)+30*sin(ID*360/numinring+objcount));
    objcount++;
    yield;
}
if(ObjEnemy_GetInfo(objBoss, INFO_LIFE) <= 0){return;}//Default kill to prevent (0,0) spawning
ObjMove_SetSpeed(obj, 2+rowID/6);
    }
The 'child' bullets constantly set their destination via ObjMove_SetDestAtFrame to be relative to their parent object. This allows them to spawn from anywhere on the screen and move towards their specified parent object. These particular shots rotate around their parent object for a while before flying off.

For what you want to accomplish, you will likely need to specify a parent object (does not need to be visible and does not need to have a hitbox - just a position) and have children objects gravitate towards + move relative to those parent objects.

If you have any further questions, please ask, although it is best to experiment on your own first.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1352 on: June 13, 2018, 11:24:36 PM »
I'm having issues with having an object shot work.
I tried having it spawn, but nothing happens.
Here's part of the code.

Code: [Select]
    @MainLoop {
        SetCollisionA(GetX, GetY, 24);
        SetCollisionB(GetX, GetY, 24);

task Bullet(x, y, v, angle) {
     let obj = Obj_Create(OBJ_SHOT);
     Obj_SetPosition(obj, x, y);
     Obj_SetAngle(obj, angle);
     Obj_SetSpeed(obj, v);
     ObjShot_SetGraphic(obj, RED01);
     ObjShot_SetDelay(obj, 0);
     ObjShot_SetBombResist(obj, true);
}
if(count == -60){
CutIn(KOUMA, "Wood Sign: Syphlae Horn (Easy)", Rumia, 0, 0, 0, 0);
}
        count++;
        yield;
    }


    @DrawLoop {
        DrawGraphic(GetX, GetY);
    }

    @Finalize {
        DeleteGraphic("script\img\ExRumia.png");
    }
}

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1353 on: June 14, 2018, 12:52:36 AM »
You need to call ObjShot_Regist to activate a shot object.

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1354 on: June 14, 2018, 11:51:36 PM »
You need to call ObjShot_Regist to activate a shot object.

How?

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1355 on: June 15, 2018, 12:44:04 AM »
?

You just use ObjShot_Regist(obj) after you create the object. This "activates" the shot which basically means it's fired.

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

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1356 on: June 15, 2018, 01:03:00 AM »
How?
?

You just use ObjShot_Regist(obj) after you create the object. This "activates" the shot which basically means it's fired.

I'd like to point out that you're looking for Bullet(x, y, v, angle), where x, y, v, and angle are all variables that you want to replace with actual values. ObjShot_Create in v0.12m, to my knowledge, automatically creates the object in the fired, stationary state with no graphic at the top left.

EDIT
Allow me to explain that.
by writing task Bullet (parameters) { ... }, you're not actually creating anything. You're giving Danmakufu a prototype of a code that it needs to run. It's like giving someone a recipe for baking cookies, but you haven't actually told them to actually do the baking. Calling the task's name along with the list of parameters like you do with CutIn, CreateShot01, etc. is what actually causes Danmakufu to execute what's written in the brackets.

... I would like to further suggest that since you haven't made it excessively far into the world of v0.12m, it might be worth considering learning the ph3 language instead.
« Last Edit: June 15, 2018, 01:07:08 AM by Chronojet ⚙ Dragon »

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1357 on: June 15, 2018, 01:47:47 AM »
I missed that they were using 0.12m because they didn't mention it in this post, yeah. I was also assuming they were just calling it somewhere else. Yeah they need to check out some tutorials.

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

Enko

  • Spirit flying to anywhere
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1358 on: June 15, 2018, 03:02:32 AM »
Encoding problem occured again in 東方潮聖書 ~ Sapphire Panlogism Trail ver. Chinese localization.
UTF-16 LE BOM occurs compiling error.

But this time things different.I've write lot of Chinese charactors in script\title\lib\lib_MusicData.dnh in case(-1), case(0) and case(2) section,and nothing wrong spread out.But here:
Code: [Select]
case(1){
return [
"The Sky Wanders Closer",
"
The stage 1 theme.[r][r]

It's raaaaining. But it's not really a bleak kind of rain.[r]
It's weird to see fairies in Gensokyo with any half-decent intelligence.[r]
But it doesn't make a difference.
"
];
}

I translated it into Chinese and error spread out,however:
Code: [Select]
case(1){
return [
"天空越来越近",
"
The Sky Wanders Closer / 1面主题曲。[r][r]

天's raaaaining. But it's not really a bleak kind of rain.[r]
Nothing happend.

I'd like to translate It's raaaaining to 天上在下??雨, however if I type after the error shows.
but I try another word: (Though that's not destination translation),it should like:
Code: [Select]
天月 raaaaining. But it's not really a bleak kind of rain.Nothing happend again. Even:
Code: [Select]
天在下??雨 But it's not really a bleak kind of rain.Nothing happend,either.

So comes a question,does Danmakufu's "UTF16 support" limit the charactors? e.g.

Edited:These are the translation codes that can spread error:
Code: [Select]
case(1){
return [
"天空越来越近",
"The Sky Wanders Closer / 1面主题曲。[r][r]

天上在下----雨,但并不是那种阴冷的雨。[r]
见到幻想乡的那些还算有点智慧的妖精是不可思议的。[r]
但是这没什么区别。
"
];
}

These are codes work well:
Code: [Select]
case(1){
return [
"天空越来越近",
"The Sky Wanders Closer / 1面主题曲。[r][r]

天在下??雨,但并不是那种阴冷的雨。[r]
见到幻想乡的那些还算有点智慧的妖精是不可思议的。[r]
但是这没什么区别。
"
];
}

A can occur a error?Why??

2nd Edited:Without nothing happend to game.
So what happen to the charactor ?
« Last Edit: June 15, 2018, 03:26:00 AM by Enko »
Need help with C# DX developing.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1359 on: June 16, 2018, 04:01:54 PM »
What do i need to do to get a notification that stage script is closed? I've tried various methods with CommonData, but none of them worked. @Finalize doesn't seem to work in stage scripts at all, since nothing I write there is ever executed. So I've come to the problem of needing a notification upon the closure of the stage, but none of the methods I know work.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1360 on: June 16, 2018, 04:14:32 PM »
What do i need to do to get a notification that stage script is closed? I've tried various methods with CommonData, but none of them worked. @Finalize doesn't seem to work in stage scripts at all, since nothing I write there is ever executed. So I've come to the problem of needing a notification upon the closure of the stage, but none of the methods I know work.

Show us what you are currently doing with a MVCE. Without seeing your code, it will be difficult to diagnose your problem.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1361 on: June 16, 2018, 06:05:10 PM »
Show us what you are currently doing with a MVCE. Without seeing your code, it will be difficult to diagnose your problem.

So, the amount of code is gonna be quite big, since atleast 3 scripts are connected here. I guess I should explain what am I trying to do first. The main script here is a package (it's main menu to be exact). I've made a mask in that package for some VFX, no problems were detected here. Then there is a background script for a stage, which also uses the same type of mask for similar VFX, and when it comes to using it in the stage itself, it works perfectly fine. However, if I return to the main menu of the package after mask was used in the stage, some bugs are caused. After some testing, I managed to figure out that the cause of the bugs is infact the mask used in stage, and to get rid of them I just have to remove the mask and do some other stuff upon closing the stage. Heres where the main problem kicks in. If I finish the stage, everything works fine, but if I close the stage in the middle of the fight with a boss, the aforementioned bugs occur and I can't find a way to detect the closure of the script.
Here are the scripts I use:
Package, StageBackground and Stage
I didn't manage to shorten Package and StageBG a lot, since many things there are involved, I hope my coding won't be that confusing. Also, there is a lot of images involved in Package, but I don't think they are gonna be useful to post

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1362 on: June 16, 2018, 09:53:39 PM »
So, the amount of code is gonna be quite big, since atleast 3 scripts are connected here. I guess I should explain what am I trying to do first. The main script here is a package (it's main menu to be exact). I've made a mask in that package for some VFX, no problems were detected here. Then there is a background script for a stage, which also uses the same type of mask for similar VFX, and when it comes to using it in the stage itself, it works perfectly fine. However, if I return to the main menu of the package after mask was used in the stage, some bugs are caused. After some testing, I managed to figure out that the cause of the bugs is infact the mask used in stage, and to get rid of them I just have to remove the mask and do some other stuff upon closing the stage. Heres where the main problem kicks in. If I finish the stage, everything works fine, but if I close the stage in the middle of the fight with a boss, the aforementioned bugs occur and I can't find a way to detect the closure of the script.

I don't know what kind of shader you are using, but I have some notes from a quick look at your code:
Firstly, if you are starting a shader in the package and then start the *exact* same shader again in the background, you may be applying it twice - it may be beneficial to have a CommonData flag that notes if the shader has already been started.
Secondly, as long as you can get the Stage script's ID and pass it to the Background script, you may be able to use IsCloseScript().

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1363 on: June 17, 2018, 08:59:44 AM »
Firstly, if you are starting a shader in the package and then start the *exact* same shader again in the background, you may be applying it twice - it may be beneficial to have a CommonData flag that notes if the shader has already been started.
I don't quite understand what do you mean by that.
Secondly, as long as you can get the Stage script's ID and pass it to the Background script, you may be able to use IsCloseScript().
I did already try using IsCloseScript in the background, but for some reason it doesn't work. I have SetCommonData("StageID", GetOwnScriptID()); in the Initialize of stage script and something like this in StageBackground
Code: [Select]
while(!IsCloseScript(GetCommonData("StageID", 0))){
   yield;
}
ClearInvalidRenderPriority();
but the while loop never stops running, even if I close stage script. That ClearInvalidRenderPriority(); is pretty much essential for me, since it needs to be called whenever stage script is closed, but nothing I know works.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1364 on: June 17, 2018, 10:20:30 AM »
Can you 100% confirm whether that script ID remains correct and accessing it refers to the correct script once you've closed it? I have a suspicion about the general problem.

Do something like create an event handler in the stage where if triggered it will increment some debug common data you can check. Then in your stage background while-is-not-closed loop, notify that event every frame with NotifyEvent targeting that script ID, so you would expect that the debug value would keep incrementing until you close the script. Also pay attention to what the value of the stage script ID common data is.


Alternatively you could upload your script package and I could take a look at it.
« Last Edit: June 17, 2018, 10:22:04 AM by Drake »

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1365 on: June 17, 2018, 10:41:18 AM »
Yes, correct script gets notified, the counter works, but still nothing after the loop is executed

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1366 on: June 17, 2018, 11:22:55 AM »
Okay, but does the counter stop once you close the script? Because there are really only a couple outcomes:
1) The event is notified but nothing is handled, which means the script ID was wrong
2) The event is notified every frame and handled by the script, but when the script is closed it can't handle the event anymore and the counter stops increasing; the loop then ends
3) The event is notified every frame and handled by the script and keeps increasing even after it apparently closes, which means it didn't close
4) The event is notified every frame and handled by the script, and when the script closes the counter stops, but the loop continues, meaning either:
4a) the common data holding the script ID becomes wrong (e.g. if it returns the default of 0)
4b) the return value of IsCloseScript is wrong, which you should be able to manually verify (i.e. it returns true despite the argument definitely being the correct script ID)

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1367 on: June 17, 2018, 11:37:57 AM »
The counter does stop, but I don't know if the loop is closed or not (commands after the loop don't work, but the counter in this loop also stops, which isn't supposed to happen)

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1368 on: June 17, 2018, 09:09:38 PM »
Well I mean either the loop is finished or it isn't lol. If you don't know how to check for what you want to check, zip up your script and put it somewhere so we can look at it.

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1369 on: June 18, 2018, 11:38:30 AM »
That's what I mean, the loop stops, but commands after it do not get executed. If that didn't happen there would be no problem in the first place. As for scripts, I did already post them
Here are the scripts I use:
Package, StageBackground and Stage
I don't think posting them whole would do much, since there are a lot of interconnected scripts and they use a lot of images

Edit: I think I know what happens. The loop does get closed, but so does the background script, so the whole task in background script gets shut down not being completed. But that's just a guess, I don't actualy know how danmakufu behaves in such situations.
« Last Edit: June 18, 2018, 02:37:04 PM by IIe4eNiIIIe »

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1370 on: June 18, 2018, 05:01:05 PM »
Is the hitbox intersection width of a straight laser always the same as the render width?
What about when using a bullet graphic which has a much smaller hitbox than its sprite?

Thanks in advance

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1371 on: June 18, 2018, 10:25:16 PM »
I can't confirm that at the moment, but regardless if needed you can use ObjLaser_SetIntersectionWidth to set it manually.

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

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1372 on: June 19, 2018, 09:59:49 AM »
I can't confirm that at the moment, but regardless if needed you can use ObjLaser_SetIntersectionWidth to set it manually.

Thanks,

I'm trying to incrementally decrease the width of a straight laser over time, so as an alternative, is there a way to alter the existing intersection width relative to the current hitbox width?

(Or relative to the render width may also work?)

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1373 on: June 19, 2018, 01:04:47 PM »
Thanks,

I'm trying to incrementally decrease the width of a straight laser over time, so as an alternative, is there a way to alter the existing intersection width relative to the current hitbox width?

(Or relative to the render width may also work?)

As long as the player doesn't get cheapshotted, it's fine :)

You'll probably end up manually set both of the widths each frame in a while loop.
« Last Edit: June 19, 2018, 01:06:25 PM by Sparen »

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1374 on: June 20, 2018, 06:38:10 AM »
I'm having trouble with the following lines of code

Code: [Select]
let EatShots = GetShotIdInCircleA2(spawnX+length*cos(angle)/2,spawnY+length*sin(angle)/2,width/2,TARGET_ENEMY);
ascent(i in 0 .. length(EatShots)){
    if(ObjShot_GetImageID(EatShots[i]) == 44){
         Obj_Delete(EatShots[i]);
    }
}

It seems that the second line in that block returns the error:
")" is necessary

Why does this happen, and how can it be fixed?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1375 on: June 20, 2018, 01:04:31 PM »
I'm having trouble with the following lines of code

Code: [Select]
let EatShots = GetShotIdInCircleA2(spawnX+length*cos(angle)/2,spawnY+length*sin(angle)/2,width/2,TARGET_ENEMY);
ascent(i in 0 .. length(EatShots)){
    if(ObjShot_GetImageID(EatShots[i]) == 44){
         Obj_Delete(EatShots[i]);
    }
}

It seems that the second line in that block returns the error:
")" is necessary

Why does this happen, and how can it be fixed?

I don't know if this is the solution, but in an ascent loop avoid having spaces before and after the ..?

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1376 on: June 20, 2018, 01:34:08 PM »
I don't know if this is the solution, but in an ascent loop avoid having spaces before and after the ..?

Normally those spaces do not cause a problem, and removing them hasn't resolved issue here.  :(

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1377 on: June 20, 2018, 01:41:01 PM »
Normally those spaces do not cause a problem, and removing them hasn't resolved issue here.  :(

Provide the code before the code you just posted. There might be a missing semicolon, or you might be missing a comma somewhere.

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1378 on: June 20, 2018, 02:17:52 PM »
Provide the code before the code you just posted. There might be a missing semicolon, or you might be missing a comma somewhere.

Code: [Select]
task SnakeAnime(spawnX,spawnY,speed,angle){
let count = 0;
let delay = 50;
let startLength = speed*delay/2;
let startWidth = delay/2;
let length = startLength;
let width = startWidth;
let hitbox = startWidth-2;
let obj = CreateStraightLaserA1(spawnX,spawnY,angle,length,width,delay,72,0);
ObjStLaser_SetSource(obj,false);
while(!Obj_IsDeleted(obj)){
ObjLaser_SetLength(obj,length);
ObjLaser_SetRenderWidth(obj,width);
ObjLaser_SetIntersectionWidth(obj,hitbox);
length -= startLength/delay;
width -= startWidth/delay;
hitbox -= (startWidth-2)/delay;
if(count < 4 || width < startWidth/2){
ObjShot_SetIntersectionEnable(obj,false);
}
else{
ObjShot_SetIntersectionEnable(obj,true);
if(count > 4){
let EatShots = GetShotIdInCircleA2(spawnX+length*cos(angle)/2,spawnY+length*sin(angle)/2,width/2,TARGET_ENEMY);
ascent(i in 0..length(EatShots)){
if(ObjShot_GetImageID(EatShots[i]) == 44){
Obj_Delete(EatShots[i]);
}
}
}
}
if(count >= delay || width < 0){
Obj_Delete(obj);
}
count++;
yield;
}
}

This is the task that contains the section. Is this enough, or should I provide the entire script?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1379 on: June 20, 2018, 02:58:47 PM »
Code: [Select]

This is the task that contains the section. Is this enough, or should I provide the entire script?

I thought I was hallucinating at that error

The issue is that length is a reserved keyword in Danmakufu, and you are redefining it in the function. Replace all occurrences of your local variable length with something else.

Refer to https://sparen.github.io/ph3tutorials/ph3u1l5.html#sub9 for more info - I'll update the section as well
« Last Edit: June 20, 2018, 03:01:03 PM by Sparen »