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

0 Members and 2 Guests are viewing this topic.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1620 on: January 07, 2019, 03:19:07 pm »
I see that some scripts use .txt files and some use .dnh files.
Is there a difference, other than personal preference?

There is no difference functionally. .dnh may be helpful if you use a text editor and want syntax highlighting.

Kinedyme

  • Dream Magic - Duplex Spark!
  • Nickname: Kine
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1621 on: January 11, 2019, 07:42:39 am »
Is it possible to vary the alpha value of a laser along its length?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1622 on: January 11, 2019, 02:22:56 pm »
Is it possible to vary the alpha value of a laser along its length?

You can utilize multiple lasers or apply a shader to achieve this effect.

HumanReploidJP

  • The Scripter with Something of Common Sense
  • "Start the life of an idol! Let's get STAR~ted!"
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1623 on: January 13, 2019, 12:07:39 am »
Hmm... I have a question.

What's the purpose of a loading system (when you open a pre-packaged danmakufu script)?
Can you describe the loading system? I wanted to know for sure, thank you.
MiraikeiBudoukan (Futuristic Vineyard) Game Concepts (WIP)
(Non-Touhou, yet bullet-hell-Inspirable (Like JynX). Don't get serious.)
  • HumanReploidJP's Youtube Channel

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1624 on: January 13, 2019, 03:22:04 am »
Hmm... I have a question.

What's the purpose of a loading system (when you open a pre-packaged danmakufu script)?
Can you describe the loading system? I wanted to know for sure, thank you.

What do you mean by 'loading system'?

HumanReploidJP

  • The Scripter with Something of Common Sense
  • "Start the life of an idol! Let's get STAR~ted!"
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1625 on: January 13, 2019, 11:10:17 pm »
What do you mean by 'loading system'?

This loading system (see picture below i.e.)
[ Guests cannot view attachments ]
MiraikeiBudoukan (Futuristic Vineyard) Game Concepts (WIP)
(Non-Touhou, yet bullet-hell-Inspirable (Like JynX). Don't get serious.)
  • HumanReploidJP's Youtube Channel

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1626 on: January 14, 2019, 02:08:01 am »

Splash Screens are done typically for graphical effect before the Main Menu. Many games have them in some form.

In Danmakufu, they don't have any specific purpose since they're just a few images rendered before loading the menu. Some scripters may choose to load assets for the menu, etc, but it's not necessarily required.

Mr.Ownage

  • Neophyte
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1627 on: January 16, 2019, 04:16:50 pm »
Hi, everyone.

I recently got into Danmakufu scripting, and I feel like I've understood the basics for the most part (including rendering, moving, and giving the boss a hitbox, some nonspells and spells), but I've run into an issue as I was working on an idea for a spell card.

The idea would be : firing 6 curvy lasers from the boss's location at intervals, which leave trails of "soul" bullets (Yuyuko-type butterfly bullets) behind as they travel, which then will randomly begin moving shortly after.

The problem is : I'm unable to find a solution to fire all six lasers and have the trails appear at the same time. I have tried using different variations of loops, ascents, different positioning of curly braces, yields, to no avail. In the recent versions of the code idea, either the lasers appear one after the other, and the rest don't appear until the prior one finishes trailing, or I get a "variable is not defined" error.

Here is the most recent version of the code I've been experimenting with. No other shooting tasks run alongside this one, this task is included in Initialize. I didn't include movement commands for the soul-bullets in this one yet. I'm using the AllStar shotsheet in this example.

Code: [Select]
task lazertime{
let i = 1;
loop{
loop(6){
let obj = CreateCurveLaserA1(ObjMove_GetX(Zataihou), ObjMove_GetY(Zataihou), 5, 120+i*10, 50, 20, 1019, 10); //shoots lasers. "Zataihou" would equal "objBoss" in this code, it itself being a name for an original character of mine. Yes, I'm weird.
i++;
} //if this brace is taken out, the lasers fire sequentially instead of at the same time. If it's in, Danmakufu shows "obj is not defined" error due to the "let souls" line.

loop(20){
wait(1);
let souls = CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,0,294,10);} //would handle spawning of soul bullets along the lasers. No angle and speed set yet for testing. 294 is a Yuyuko-type, blue "butterfly" bullet graphic.
ObjCrLaser_SetTipDecrement(obj,0); //makes laser hitbox fair by removing their invisible parts
ObjMove_SetAngularVelocity(obj,-1); //curves the lasers
yield;}

I've been thinking of making the trailing be handled by a seperate task, but it would likely also bring up a "variable is not defined" error. I've also seen people use arguments in task names, but I don't exactly get what is that used for, or how to make use of it. Any advice regarding these matters is greatly appreciated.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1628 on: January 16, 2019, 05:52:59 pm »
The problem is : I'm unable to find a solution to fire all six lasers and have the trails appear at the same time. I have tried using different variations of loops, ascents, different positioning of curly braces, yields, to no avail. In the recent versions of the code idea, either the lasers appear one after the other, and the rest don't appear until the prior one finishes trailing, or I get a "variable is not defined" error.

Here is the most recent version of the code I've been experimenting with. No other shooting tasks run alongside this one, this task is included in Initialize. I didn't include movement commands for the soul-bullets in this one yet. I'm using the AllStar shotsheet in this example.

Code: [Select]
task lazertime{
let i = 1;
loop{
loop(6){
let obj = CreateCurveLaserA1(ObjMove_GetX(Zataihou), ObjMove_GetY(Zataihou), 5, 120+i*10, 50, 20, 1019, 10); //shoots lasers. "Zataihou" would equal "objBoss" in this code, it itself being a name for an original character of mine. Yes, I'm weird.
i++;
} //if this brace is taken out, the lasers fire sequentially instead of at the same time. If it's in, Danmakufu shows "obj is not defined" error due to the "let souls" line.

loop(20){
wait(1);
let souls = CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,0,294,10);} //would handle spawning of soul bullets along the lasers. No angle and speed set yet for testing. 294 is a Yuyuko-type, blue "butterfly" bullet graphic.
ObjCrLaser_SetTipDecrement(obj,0); //makes laser hitbox fair by removing their invisible parts
ObjMove_SetAngularVelocity(obj,-1); //curves the lasers
yield;}

I've been thinking of making the trailing be handled by a seperate task, but it would likely also bring up a "variable is not defined" error. I've also seen people use arguments in task names, but I don't exactly get what is that used for, or how to make use of it. Any advice regarding these matters is greatly appreciated.

Tasks are the perfect solution to your problem, since you want each laser to perform the same task. In this case, you get the ID of each laser, and pass it to a task. In the task, the trails are made.

In other words, your code structure would be as follows:

In lazertime:
- In a loop without waiting (unless you want a delay between lasers), create your lasers, and call a new task, passing the laser ID as a parameter.
- In the new task, handle the trail.

Tasks run parallel to the main routine as long as you are using yield; in your Main Loop.

Mr.Ownage

  • Neophyte
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1629 on: January 16, 2019, 07:06:09 pm »
Tasks are the perfect solution to your problem, since you want each laser to perform the same task. In this case, you get the ID of each laser, and pass it to a task. In the task, the trails are made.

In other words, your code structure would be as follows:

In lazertime:
- In a loop without waiting (unless you want a delay between lasers), create your lasers, and call a new task, passing the laser ID as a parameter.
- In the new task, handle the trail.

Tasks run parallel to the main routine as long as you are using yield; in your Main Loop.

Hey, Sparen. It's been a great honor to be helped out by one of the grandfathers of Danmakufu, so to say.
I created a new task to handle the trail as you've advised to do, and sure enough, now each laser leaves a trail correctly, like it was meant to be. And using an if Obj_IsDeleted statement in the trail task also successfully prevented 0,0 spawning (in case a laser went offscreen).
Many thanks for the advice!

A few more questions that came up while experimenting/thinking about spell ideas and how to code them :

-Judging from the example indicated, giving a task an argument (like : trail(obj)) serves to pass the ID of created objects so the "no variable defined" error doesn't come up? Likewise, for shots, its ID is acquired by declaring it as something?

-For more complicated shapes (in my case, a spiderweb comes to mind) it's best to use multiple tasks to handle their creation, right?

-If I want to modify the lasers by modifying their angular velocity at various intervals and values (for example, setting it to 1 after 90 frames, then 2 after 30 frames, then 0 shortly after) via tasking, would that affect even the newly spawned lasers, or would newly spawned ones also only have their velocity modified when they are intended to?

-Danmakufu seems to be faster whenever the player (Reimu) is in a "shotdown" state (before respawning) for some reason, which leads to quite big desyncs at times, mainly in more complicated patters or regarding sound effects. What could be causing this?
« Last Edit: January 16, 2019, 07:27:09 pm by Mr.Ownage »

Arcvasti

  • Nickname: Unmoving Puppet
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1630 on: January 16, 2019, 09:13:25 pm »
You shouldn't add angular velocity to non-curvy lasers. I've never been able to figure out how danmakufu's curvy lasers are supposed to work, so I just made my own out of a bunch of small straight lasers.

Mr.Ownage

  • Neophyte
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1631 on: January 16, 2019, 10:07:28 pm »
You shouldn't add angular velocity to non-curvy lasers. I've never been able to figure out how danmakufu's curvy lasers are supposed to work, so I just made my own out of a bunch of small straight lasers.

Don't worry, I've made sure that they are indeed curvy lasers. I've managed to get them working since.

Now, however, the only problem I have is that I've accidentally overwritten the script with an old version, thus losing a lot of work, and I had to remake it. Something went wrong, though, as bullets from the trail keep spawning at 0,0, even if if/while statements checking for if the parent lasers are deleted are included (and if they are deleted, remove said shots, but some still manage to spawn in 0,0 anyway). Perhaps due to them being spawned via an ascent?

Due to this, I'm using a weird workaround of DeleteShotInCircle aimed at 0,0 with a small radius. It looks wonky, but it works, at least.

And to help you in the curvy laser regard : you need to use ObjMove_SetAngularVelocity on your lasers to have them curve. Though first, declare them as something so you'll be able to refer them via that variable through the command.

For example, if you name your laser obj, it would look like this :
let obj = CreateCurveLaserA1(xcoord, ycoord, speed, angle, length, width, graphic, delay);
ObjMove_SetAngularVelocity(obj,number)

Hope this helps!

Kinedyme

  • Dream Magic - Duplex Spark!
  • Nickname: Kine
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1632 on: January 16, 2019, 10:58:20 pm »
This is the code I'm currently using:

Code: [Select]
let angle = 0;
CreateShotA1(GetCenterX(),GetCenterY(),1,angle,5,5);
{
let angle = 90;
CreateShotA1(GetCenterX(),GetCenterY(),1,angle,5,5);
}

I wrote this as a test in the process of debugging a larger problem. The expected behaviour of this code here is that two bullets will be fired at angle 0 and 90 degrees respectively.

For me, this code does not compile at all, requesting a "}" on the same line as the opening bracket. Removing the curly braces leads to a conflicting declaration of 'angle'.

I'm aware that if I were to represent the latter two lines as a nested task or function I would be able to make use of a local scope for the variable, but since this code only appears once in this location and has no yields, I was wondering if there was a way to define a section of limited, local scope without using a task, function, or something queer-looking like "loop(1){...}" ?

Drake

  • *
  • LOOK AT ME
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1633 on: January 16, 2019, 11:51:25 pm »
local{}

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by あかがし -

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1634 on: January 17, 2019, 01:39:21 am »
Hey, Sparen. It's been a great honor to be helped out by one of the grandfathers of Danmakufu, so to say.
:V :V :V :V :V

Something went wrong, though, as bullets from the trail keep spawning at 0,0, even if if/while statements checking for if the parent lasers are deleted are included (and if they are deleted, remove said shots, but some still manage to spawn in 0,0 anyway). Perhaps due to them being spawned via an ascent?

You'll need to post code for us to locate a specific problem. In general, you need to prevent bullets from spawning if their position is based on the position of a deleted object. IE if the player bombs and a bullet that spawns other bullets is deleted, no more bullets should be spawned from that bullet (IE the task should be terminated via return;)

Mr.Ownage

  • Neophyte
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1635 on: January 17, 2019, 07:46:27 am »
Here is the current version of the code I'm using for the card, which, other than the 0,0 spawning post-death, seems to work great by now :

Code: [Select]
task lazertime{
let angle = 100;
wait(60); //One time wait so the cutin can disappear by this time, and the boss can move into position
loop{
while(GetShotCount(Zataihou) > 160){yield;} //If there's many souls on screen, stop creating new lasers and trails. Once again, Zataihou = objBoss in this example.
wait(10);
ascent(i in 1..6){
let obj = CreateCurveLaserA1(ObjMove_GetX(Zataihou), ObjMove_GetY(Zataihou), 12, angle+i*12, 30, 20, 1019, 10); //Handles the lasers
ObjCrLaser_SetTipDecrement(obj,0); //Makes laser hitbox fair
ObjMove_SetAngularVelocity(obj,-7); //Handles the initial curving of the lasers
trail(obj); //Task to spawn trails
straighten(obj); //Task to have the lasers go straight after a short while (so they leave the screen)
angle+=30; //Increment angle to give different laser angles
}
}}

task trail(obj){
while(Obj_IsDeleted(obj)){return;} //Supposed to handle preventing 0,0 spawning, which works until player death, but some souls spawn at 0,0 anyway on respawn.
loop(5){
wait(8);
let souls = CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,0,rand(291,298),10); //Creates the souls
fly(souls);} //Task to wait until there's a certain amount of souls, then let them begin moving
}

task straighten(obj){
ObjMove_AddPatternA2(obj,60,NO_CHANGE,NO_CHANGE,NO_CHANGE,0,11); //Task to straighten the lasers by setting their angular velocity to 0, leaving everything else intact.
}

task fly(souls){
while(GetShotCount(Zataihou) < 150){yield;} //Wait until there's enough souls, then...
ObjMove_AddPatternA2(souls,60,NO_CHANGE,rand(40,150),0.01,0,12); //... let them move around.

I'm assuming that since the lasers are in an ascent loop (which I need to have an incrementing angle, imo this is the easiest way to do so) they get spawned just a tiny bit one after the other, and because of that, since there's at least one obj (laser) on screen by that time, the ones that can spawn at the lasers' x, while the rest spawn in at 0,0?
Then again, this does not happen when the card starts out, only after player respawn. It's... weird.

For me, personally, it's not a big deal to use DeleteShotInCircle aimed at 0,0 as a workaround, but for keen eyes, it really does look wonky regardless.

« Last Edit: January 17, 2019, 07:51:18 am by Mr.Ownage »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
  • Staff
  • LOOK AT ME
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1636 on: January 17, 2019, 08:19:25 am »
Your while(Obj_IsDeleted(obj)){return;} is the culprit I think. Cannot test it as I am at work but you need to enclose this statement around the execution of your trail code.

As in:
Code: [Select]
// As long as the obj IS NOT deleted, executed the code in between. Otherwise, jump over it (thus not executed)
while (!Obj_IsDeleted(obj)) {
// Spawn fancy trail stuff here.
}
You can translate the above code into human language but reading it out loud: "While the object is not deleted, execute the code in between which is CreateShotA etc.

Because, there could be a scenario where the creation of souls could be already running while the original object is perhaps just 1 frame ago deleted. Which results in spawning at 0,0 because the original Obj is gone. And this can be confirmed because you're looping it 5 times. So if indeed the obj got deleted and the program was executing the loop, then it would simply run it 5x.

Edit: However, even if you do it like this there is still a trap in your code. It is the loop(5) and the way you're spreading out the tasks. You should approach it differently imo.

So if I understood your code. Your use case is this, right?
- Boss keeps firing number of shots on screen
- It also spawns these lasers (shots) on screen
- If the shotcount exceeds a certain number, stop spawning lasers
- Respawn lasers/shots if the number drops under this said threshold

So for this case, you will need something like this:
Code: [Select]
task fireCurvyLaser() {
  // While the boss IS alive AND the number of shots IS BELOW 160, execute the code.
  while (!Obj_IsDeleted(Zataihou) && GetShotCount(Zataihou) < 160) {
    let obj = CreateCurveLaserA1(...);
    // ... laser related stuff etc
    spawnLaserTrail(obj);
    wait(10);
  }
}

task spawnLaserTrail(obj) {
  // Loop 5x, but keep checking each loop whether the obj (laser) is NOT deleted. If the laser is "alive", spawn a soul (createShotA1)
  loop(5) {
    if (!Obj_IsDeleted(obj)) {
      let soul = CreateShotA1(...);
    }
    wait(8);
  }
}

Above code will do the following:
- Add extra lasers up to your given threshold (160 in this case)
- Prevent the laser from spawning more souls if it is "dead"
- A more compact and maintainable code

Imagine if the curvy was deleted exactly the moment when spawnLaserTrail was executing loop #3. This code will immediately prevent the spawn of future souls. This is exactly the type of control you want. Always verify the existence of the obj. When working with objects, the only reason something spawns at 0,0 is the fact that the original reference object is gone.

So why might wonder now why your code spawning things at 0,0 when the player went pichuun? (post death as you mentioned)
In your original code, your script is executing loops without verifying whether its reference object is still alive. So once the loop started running, it would just do what you told it to do: Spawn souls. But the souls used the obj as its reference for its x/y position. As the player dies, it clears the entire screen of bullets (by default). Clearing the screen means all objects (bullets) are deleted. With the objects gone, its x/y is destroyed. But your loop was probably running at that moment and thus the 0,0 spawning occurs for that specific task.

Conclusion is that you didn't check/verify or control your code. A common mistake made by many beginner and intermediate danmakufu scripters.

Hope this helps out.


Edits, spelling/grammar correction
« Last Edit: January 17, 2019, 09:17:46 am by Helepolis »
  • Helepolis' Siege Workshop

Mr.Ownage

  • Neophyte
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1637 on: January 17, 2019, 09:20:23 am »
Not sure if this is exactly how you meant it, but I did this (enclosing the trail task in a while statement) :

Code: [Select]
task trail(obj){
while(!Obj_IsDeleted(obj)){ //Supposed to handle preventing 0,0 spawning
loop(5){
wait(8);
let souls = CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,0,rand(291,298),10); //Creates the souls
fly(souls);} //Task to wait until there's a certain amount of souls, then let them begin moving
}}

But it only made it worse : as soon as a laser leaves the screen, "souls" begin spawning at 0,0 in greater amounts.
One thing to note is that I'm using this code in @MainLoop to delete bullets on player death, could it be a potential culprit?

Code: [Select]
if(GetPlayerState == STATE_DOWN){
DeleteShotAll(TYPE_ALL, TYPE_FADE);

Setting the down state time to 30 frames via SetPlayerDownStateFrame (from the default 2-3 seconds) also helped alleviate the problem a LOT, but there are still rare cases of 0,0 spawning even with it.  This is all assuming the original version of the code is being used (instead of enclosing the task in a while(!Obj_IsDeleted) statement, while(Obj_IsDeleted(obj)){return;} is used) and does not occur when a bomb is used.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
  • Staff
  • LOOK AT ME
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1638 on: January 17, 2019, 09:28:12 am »
I edited my post while you were probably trying it out. See my edited post, I am pretty sure it will work out.

Edit:
I have no idea why you're calling a DeleteShotAll because it is default being done when the player dies. All bullets, which aren't resistant to deletion, will be deleted. Pure objects (sprites, effects, etc) obviously won't.
« Last Edit: January 17, 2019, 09:54:57 am by Helepolis »
  • Helepolis' Siege Workshop

Mr.Ownage

  • Neophyte
  • Gender: Male
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1639 on: January 17, 2019, 10:10:50 am »
Alright, the issue was found and fixed at last!

The problem was, for one, that the check for the parent laser existing was, as you've mentioned, incorrect. Rewriting it using an if(!Obj_IsDeleted(obj)) statement as you've mentioned helped do the trick.

But for the most part, I assume the problem was that I included the wait( 8 ); function inside the check statement, which would make it wait 8 frames before running the check to see if the lasers are still existing (in other words, the check wouldn't be running every frame, but rather every 8 frames). Enough time for souls to try spawning, and end up spawning at 0,0.

With these modifications done, and by putting the wait before the if statement (the wait is there to make sure the souls are nicely spread, and so they don't spawn right on the first frame, as in, on the boss), now no souls spawn at 0,0 whatsoever, nor when bombing, nor when the lasers leave the screen, nor after going pichuun.

Thanks a lot for the help so far!

About the DeleteShotAll statement, I included it because the lasers/souls don't seem to delete by default without it. Both the souls and the lasers remain if it's not included (normally, they disappear via bombing).
« Last Edit: January 17, 2019, 10:15:49 am by Mr.Ownage »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
  • Staff
  • LOOK AT ME
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1640 on: January 17, 2019, 11:11:50 am »
Ah yes. This was also a thing in 0.12m. Bullets/danmaku created through Objects (including lasers) were default immune to bombing or player death or even leaving the screen. You indeed have to tell it to be not-immune. I forgot the exact code but it is there on the wifi.

Glad to be of any help and good to see you figured it out.
  • Helepolis' Siege Workshop
 

SMF 2.0.15 | SMF © 2017, Simple Machines
Theme based on ModernDark64 design by BlocWeb
Page created in 0.061 seconds with 26 queries.