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

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1050 on: March 14, 2018, 01:07:53 AM »
So I'm trying to implement continues, and the main difficulty I'm having is the part where the game actually... you know... continues. I assume what I need to do is start a script manually, rather than using the end scene script... Something more like how the pause script works?

I tried manually loading (both regular and in thread) and starting the end scene script from the main loop of the stage script and waiting for it to finish before deciding whether to close the stage scene, which froze the game. Mucked about with that for a while before concluding that I wasn't going to accomplish much fumbling around with no idea what I'm doing.
Literally everything in this script will crash and burn.
1CC tracker

SusiKette

  • @MainLoop { yield; }
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1051 on: March 14, 2018, 06:49:40 PM »
My question is about shot sheet hitboxes. If I'm not mistaken, using collision = 2 creates a round hitbox with radius (not diameter) of 2. However, I once saw something like this collision = (3, 0, 0, 0). What are the rest of these optional(?) parameters? One other thing I've been wondering is how big is the default hitbox size if you don't use collision in shot data? One of Sparen's tutorials state " By default, the hitbox is a percentage of the bullet graphic (in a circle)", but doesn't state how much. Also, is there a way to get other hitbox shapes besides circles? Like rectangles and ellipses? If so, how does one define these? Best case scenario would be that I'd be able to create some sort of overlay that would visualize the hitbox for me when I'm actually making the bullet graphic.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1052 on: March 14, 2018, 10:59:58 PM »
collision = (r, x, y) creates a hitbox of radius r positioned (x, y) from the bullet center.

After some testing, the formula for default hitbox radius given a bullet of size m*n is
Code: [Select]
max(3, floor((min(m, n) - 12) / 3))So it takes the smaller dimension (say n), then for n<21 all hitboxes are radius 3, and n>=21 it increases by 1 every 3 pixels.


If you need a truly rectangular hitbox you would have to code that manually, but typically this is not necessary. You can specify multiple hitboxes for a bullet, so if you e.g. have a large square bullet you can use circles to approximate the square. You can do this in different ways; many people might opt for just evenly spacing the whole way (example 1), but a more efficient way would be finding space-filling circles (example 2):



As for the last bit about displaying hitboxes, I made a thing to do this a while back:
https://gist.github.com/drakeirving/c4c12533fd7814d405e1
If you save an image of a white circle (example) as eff_circle.png and run TDrawHitboxes() in your system script (or I guess anywhere works) you can toggle hitbox visibility by pressing the H key.
« Last Edit: March 15, 2018, 03:42:13 AM by Drake »

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

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1053 on: March 15, 2018, 10:10:37 AM »
So I'm trying to implement continues, and the main difficulty I'm having is the part where the game actually... you know... continues. I assume what I need to do is start a script manually, rather than using the end scene script... Something more like how the pause script works?

I tried manually loading (both regular and in thread) and starting the end scene script from the main loop of the stage script and waiting for it to finish before deciding whether to close the stage scene, which froze the game. Mucked about with that for a while before concluding that I wasn't going to accomplish much fumbling around with no idea what I'm doing.
Actually, implementing a continue system is way more complicated than this. First of all, you need to provide us more details about your current setup. What are you currently using? A regular set of scripts in a plural? Stage scripts? Package scripts?

Edit:
In the mean while I am trying to find the posts where we've discussed this topic before except cannot seem to find this yet.
« Last Edit: March 15, 2018, 10:13:08 AM by Helepolis »

SusiKette

  • @MainLoop { yield; }
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1054 on: March 15, 2018, 11:34:45 AM »
collision = (r, x, y) creates a hitbox of radius r positioned (x, y) from the bullet center.

After some testing, the formula for default hitbox radius given a bullet of size m*n is
Code: [Select]
max(3, floor((min(m, n) - 12) / 3))So it takes the smaller dimension (say n), then for n<21 all hitboxes are radius 3, and n>=21 it increases by 1 every 3 pixels.

As for the last bit about displaying hitboxes, I made a thing to do this a while back:
https://gist.github.com/drakeirving/c4c12533fd7814d405e1
If you save an image of a white circle (example) as eff_circle.png and run TDrawHitboxes() in your system script (or I guess anywhere works) you can toggle hitbox visibility by pressing the H key.

Thanks :)

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1055 on: March 17, 2018, 01:36:58 PM »
I need help for stopping time like Sakuya, is there a handy task/post here?
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1056 on: March 17, 2018, 07:22:28 PM »
Time stops need to set up by hand, there really isn't a way to do it with one simple task/function. Really, time stops are composed of three parts:
1: Stopping all the bullets
2: Stopping the player from moving
3: The boss does something interesting
4: Starting the bullets moving again

Stopping all the bullets is fairly easy: Get an array with all the bullets in it and then set their speeds/accelerations/angular velocities to zero. You also usually want to store the old values in the bullet using Obj_SetValue, so you can start them again afterwards.

Stopping the player is more difficult. You can stop them from moving by continously setting their location to where they were when the timestop started while the timestop lasts, but this doesn't look very pretty[The player can still jerk around]. The other way is by implementing an event in the player script that sets their focussed and unfocussed movement values to zero[Remember to restores them afterward!], which works best with a custom player script.

Step three is where you actually do interesting stuff. This depends on what you want to accomplish with your timestop. General advice: Make sure that any bullets fired in this stage also start out timestopped.

Starting the bullets again is just step one, but in reverse. Here's where storing their previous speed values becomes important.

None of this is very complex to implement, although you do have to account for some potentially hairy edge cases[What if a bullet is destroyed during the timestop, what if the timestop ends prematurely, what if the player dies during the timestop, etc]. Timestopping can be very messy if something does go wrong, so playtest it thoroughly.

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1057 on: March 17, 2018, 11:34:58 PM »
Actually, implementing a continue system is way more complicated than this. First of all, you need to provide us more details about your current setup. What are you currently using? A regular set of scripts in a plural? Stage scripts? Package scripts?
Oh, boy. Currently I'm up to stage scripts, but I intend to move to a package script at some point soon, since the intent is to make a full game (since I've found myself leading a group project this semester and nobody else had any ideas). If you need more detail, here's our github.

If the continue system will have to be reworked when I move to a package I'll probably try to do that first and then implement continues - though, I haven't had much luck finding examples for packages.

Oh, random question: Can you use SplitString to split on multiple delimiters? Like, "+" or "-"?
« Last Edit: March 18, 2018, 02:04:13 AM by Andi »
Literally everything in this script will crash and burn.
1CC tracker

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1058 on: March 18, 2018, 06:26:34 AM »
Originally I thought not (and you could code it by hand) but after testing it splits on every character in the delimiter string. Nice.

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

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1059 on: March 18, 2018, 09:26:51 PM »
Is there a tutorial or handy post about Custom players?
I'm having some ideas for spells and shots that would be cool to have... :wat:
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1060 on: March 18, 2018, 11:51:31 PM »
Is there a tutorial or handy post about Custom players?
I'm having some ideas for spells and shots that would be cool to have... :wat:
It's fairly straightforward for the most part. I recommend starting off by modifying an existing player script - maybe look at several made by different people and pick whichever one whose structure seems the most intuitive to you.
Each player script does have its own shotsheet, which works basically the same as the usual ones but generally only has a few shot types. You can modify it the usual way, by adding shot graphics to the image and defining a shot type using them in the shotsheet.
Literally everything in this script will crash and burn.
1CC tracker

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1061 on: March 19, 2018, 01:52:25 AM »
Is there a tutorial or handy post about Custom players?
I'm having some ideas for spells and shots that would be cool to have... :wat:

Helepolis did one here. Its not finished[Might never be finished?]. There's also this old tutorial. This second one is for 0.12m, but I still found it pretty helpful.


SusiKette

  • @MainLoop { yield; }
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1062 on: March 19, 2018, 08:52:50 AM »
Are there any tutorials for making shaders? Mainly I want to try to make one that creates the background distortion around the boss, but I don't want to steal someone else's code and trying to make any sense out of the shader scripts is almost impossible without any documentation, since they differ from all the other scripts.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1063 on: March 19, 2018, 01:31:10 PM »
Are there any tutorials for making shaders? Mainly I want to try to make one that creates the background distortion around the boss, but I don't want to steal someone else's code and trying to make any sense out of the shader scripts is almost impossible without any documentation, since they differ from all the other scripts.

https://msdn.microsoft.com/en-us/library/windows/desktop/bb509635(v=vs.85).aspx

I just googled this, so I can't be sure if Microsoft's official tutorial is worth anything. But just googling "HLSL tutorial" should probably bring up some decent guides.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1064 on: March 19, 2018, 11:11:30 PM »
Does anyone know the cause for the get_center_x not defined error when trying to recreate spell cards using Sparens guide?

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1065 on: March 20, 2018, 04:32:07 AM »
That being said,
but I don't want to steal someone else's code
This is typically something not many people will have issue with, especially since I'm sure most people just copied stuff straight from the sample script that does this (SamplePS03_HLSL). The only thing you might even need to change from the sample script is adding color.a = 1; before setting Out.color = color. The main reason you don't see much documentation about shaders in the context of DNH is that most people don't use it for much.
« Last Edit: March 20, 2018, 04:34:37 AM by Drake »

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

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1066 on: March 20, 2018, 03:57:35 PM »
So my stage scripts are still freezing up for a while when they start a plural, despite loading the plural earlier. I just had the idea to start the plural immediately, and in the plural script load all the singles and then wait for common data or an event before starting them.

Is this a good idea, or a terrible one?
Literally everything in this script will crash and burn.
1CC tracker

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1067 on: March 21, 2018, 11:22:01 PM »
Translate to danmakufu code plz:
Code: [Select]
while(TaskA_IsRunning and !TaskB_IsRunning){
shoot_that;
}
while(!TaskA_IsRunning and TaskB_IsRunning){
shoot_this;
}
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1068 on: March 22, 2018, 12:09:39 AM »
So my stage scripts are still freezing up for a while when they start a plural, despite loading the plural earlier. I just had the idea to start the plural immediately, and in the plural script load all the singles and then wait for common data or an event before starting them.

Is this a good idea, or a terrible one?
If this is about script compilation, you should wait both after compiling the plural and starting it from the stage, and waiting after setting up and compiling the boss scene before starting it.

Like you say, you could do this by waiting a bit before starting the plural, but waiting for a trigger to start the boss scene. This is what several games do (at least ido games and FFF), but I still don't think it's a super clean approach. Is there any discernible reason things don't load fast enough? If it's resources rather than script compilation doing this might not even fix the issue.

Translate to danmakufu code plz:
Why are you splitting it into tasks if you're only running one at a time?

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

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1069 on: March 22, 2018, 06:44:04 AM »
wait both after compiling the plural and starting it from the stage, and waiting after setting up and compiling the boss scene before starting it.
Run that by me again? Not 100% sure I'm parsing that right.
What I'm currently doing is:
Code: [Select]

Stage: Load plural; Start plural; other stuff; Notify plural; Wait for plural to close
Plural: Add singles to boss scene; Load boss scene in thread; Wait for event; Register boss scene; Wait for boss scene to end
Which seems to be working pretty well. It still hangs for a few moments, but not nearly as much as before.

I still don't think it's a super clean approach.
Is there a cleaner approach? How do you deal with it?

Is there any discernible reason things don't load fast enough? If it's resources rather than script compilation doing this might not even fix the issue.
I think the bulk of it is script compilation, and the remaining bit is resources. I would go through watching the log to make sure, but my computer just BSOD'd and I need to be getting to bed.

Translate to danmakufu code plz:
I'm not sure why you wouldn't just do it in the respective tasks, but:
Code: [Select]
let numA=0; let numB=0;
task TaskA{
    numA++;
    do_that;
    if(numB==0){ shoot_that; } //the sane way
    numA--;
}
task TaskB{
    numB++;
    do_this;
    if(numA==0){ shoot_this; } //the sane way
    numB--;
}
task TaskC{
    loop{
        if(numA>0 && numB==0){ shoot_that; }
        else if(numB>0){ shoot_this; }
        yield;
    }
}
You can't directly check if a task is running like that, so you'd need to keep track of it manually as above.
Literally everything in this script will crash and burn.
1CC tracker

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1070 on: March 22, 2018, 07:33:25 AM »
The point is that you need to wait a bit between loading a script (which compiles it along with any included scripts) and actually starting it. When you say Load plural -> Start plural, you should have a short time between those to wait for it to compile or it'll block execution (causing the stall) until it's done. Meanwhile if you're loading the boss scene in your plural and then waiting until a trigger that's more than enough time so script compilation shouldn't be an issue when starting the boss scene.
« Last Edit: March 22, 2018, 07:35:43 AM by Drake »

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

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1071 on: March 22, 2018, 02:41:41 PM »
When you say Load plural -> Start plural, you should have a short time between those to wait for it to compile or it'll block execution (causing the stall) until it's done.
Oh, I see. Tried putting it in a task with a wait(600) and it definitely started faster, yeah.

Another question: Is there any way to collect only a specific item? There's CollectItemsByType and CollectItemsInCircle, but I don't see a way to filter both at once.
« Last Edit: March 22, 2018, 06:09:39 PM by Andi »
Literally everything in this script will crash and burn.
1CC tracker

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1072 on: March 22, 2018, 09:17:45 PM »
You would probably deal with this in the item script, and you can use ObjItem_SetDefinedMovePatternA1(item, ITEM_MOVE_TOPLAYER) to autocollect an item.

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

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1073 on: March 24, 2018, 07:12:28 AM »
Does anyone know the cause for the get_center_x not defined error when trying to recreate spell cards using Sparens guide?
Insufficient information provided to help out. Wild question: Did you create such a function first?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1074 on: March 24, 2018, 01:28:28 PM »
Does anyone know the cause for the get_center_x not defined error when trying to recreate spell cards using Sparens guide?

Which guide was it in (i.e. #23, etc)? I may have forgotten to manually inline the function in an example, or I may have forgotten to provide an appropriate function definition.

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1075 on: March 25, 2018, 02:39:35 AM »
Is there a tutorial for Dialogue?(Cutin or textbox type)
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1076 on: March 25, 2018, 02:51:51 AM »
Not really. Dialogue isn't difficult, per se, but it can be tedious aligning all the images and text objects properly. The part that I remember having the most trouble with was having the dialogue pause until you pressed "Z". Here's my implementation of it:

Code: [Select]
        let count = 0;
loop{
                count += 1;
if(GetVirtualKeyState(VK_SHOT) == KEY_PUSH || count >= 60*15){
break;
}
yield;
}

This will halt the task it is placed in until either fifteen seconds pass or the player presses "Z". This should be used as a break in between displaying each segment of dialogue. Actually displaying the dialogue shouldn't be much different then messing with the HUD or the background.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1077 on: March 25, 2018, 03:11:26 AM »
similarly

Code: [Select]
function wait_for_ok(n){
  if(n > 0){
    loop(n){
      if(GetVirtualKeyState(VK_OK) == KEY_PUSH){ break; }
      yield;
    }
  }else{
    while(GetVirtualKeyState(VK_OK) != KEY_PUSH){ yield; }
  }
}

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

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1078 on: March 25, 2018, 03:29:38 AM »
The part that I remember having the most trouble with was having the dialogue pause until you pressed "Z".
Here's a slightly better implementation if some players are still shooting when you advance dialogue:
Code: [Select]
let count = 0;
while(GetVirtualKeyState(VK_OK)!=KEY_PUSH && count < 60*15){
SetVirtualKeyState(VK_SHOT, KEY_FREE);
yield; count++;
}
VK_OK and VK_SHOT are distinct despite sharing the same key, so you can not only wait for the player to press Z but forcibly prevent the player from shooting, even if the player script doesn't properly respect SetForbidPlayerShot. Might not be necessary, but it's a problem I've had in the past.

Is there a tutorial for Dialogue?(Cutin or textbox type)
I don't know about a tutorial, but there are various libraries floating around. I got mine from one of Python's scripts (like this one), though I'm not 100% sure whether they wrote it or got it from someone else. The one in the linked script uses a dialogue box, though I've also seen versions of the same library modified to use text bubbles.


And another question of my own: Various enemy textures are being repeatedly unloaded, even though I'm not removing them. Are they removed automatically? How do I prevent them from being unloaded?
« Last Edit: March 25, 2018, 04:26:27 AM by Andi »
Literally everything in this script will crash and burn.
1CC tracker

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1079 on: March 26, 2018, 01:56:55 AM »
Textures are unloaded when there aren't any more references to them. If you only load textures automatically by assigning them to objects, once the objects using them are deleted the texture is unloaded, so it'll have to be reloaded if you use it again. This is done so unused textures don't waste memory. If you load textures in a script using LoadTexture, then the reference to the texture lives until the script is finished.

This doesn't mean the best solution is to always preload every asset globally, of course, since that removes the whole point of unloading unused assets.
« Last Edit: March 26, 2018, 02:05:21 AM by Drake »

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