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

PyuDi

  • daily touhou~
  • danmakufu!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1020 on: February 17, 2018, 03:39:55 AM »
Is there a way to create a bullet polygons (square, pentagon, ?etc) and stars?

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1021 on: February 17, 2018, 04:13:42 AM »

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

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1022 on: February 17, 2018, 03:07:24 PM »
echo, echo, echo, echo, echo, echo

https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1375135.html#msg1375135

I swear this is the 5th? 6th? time I've seen it requested lol. Might as well just slap it on the Danmakufu Wiki under tutorials and hope people go there first?

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1023 on: February 18, 2018, 04:01:37 AM »
The thing is that one shape is pretty easy to make and can have multiple ways to go about it, but as soon as people want general purpose stuff and both being able to shoot shapes as a large object and also expand shapes outwards, you need a more appropriate solution. I can't really make it a "tutorial" per se because the math for the general case is complicated enough that it isn't very useful to even explain.

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 #1024 on: February 18, 2018, 08:15:59 AM »
Is there a collection of useful functions in one txt/dnh file?
There isn't. You will need to make your own or check out the code snippet thread where people post these. Some have been posted even in this thread.

I swear this is the 5th? 6th? time I've seen it requested lol. Might as well just slap it on the Danmakufu Wiki under tutorials and hope people go there first?
Sounds like a good idea. A separate wiki page posting code snippets + a screenshot of the result.

Gregory

  • I draw stuffs
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1025 on: February 19, 2018, 02:06:08 PM »
Is there a discord group specific in danmakufu ? since I saw python's video there's a secret santa's scripts so I'm really curious

Tom

  • *
  • Programmer
    • LunarCast Network
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1026 on: February 19, 2018, 07:49:42 PM »
Does anyone know the bullet cap in danmakufu?  Or other caps like sprite/object/enemy etc

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1027 on: February 20, 2018, 04:38:19 AM »
Is there a discord group specific in danmakufu ? since I saw python's video there's a secret santa's scripts so I'm really curious

There are a few Danmakufu-specific groups (such as the Land of Codes and Apertures) and a number of servers with danmaku channels (such as the main Len'en Discord Server)

Does anyone know the bullet cap in danmakufu?  Or other caps like sprite/object/enemy etc

There may be a hard bullet cap but if there is, you're probably lagging down to single digit FPS values anyways. There is no limit on graphical objects such as sprites. As for enemies, there can be only one boss enemy on screen at a given time, but you can have any number of standard enemies.

Gregory

  • I draw stuffs
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1028 on: February 20, 2018, 05:19:42 AM »
There are a few Danmakufu-specific groups (such as the Land of Codes and Apertures) and a number of servers with danmaku channels (such as the main Len'en Discord Server)

There may be a hard bullet cap but if there is, you're probably lagging down to single digit FPS values anyways. There is no limit on graphical objects such as sprites. As for enemies, there can be only one boss enemy on screen at a given time, but you can have any number of standard enemies.

Ah, I see. Then how can I apply/join the Discord group ?

Tom

  • *
  • Programmer
    • LunarCast Network
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1029 on: February 20, 2018, 12:06:58 PM »
There may be a hard bullet cap but if there is, you're probably lagging down to single digit FPS values anyways. There is no limit on graphical objects such as sprites. As for enemies, there can be only one boss enemy on screen at a given time, but you can have any number of standard enemies.
What is a generally accepted bullet limit that works well on low end PCs and is under what most scripts use? 1024?

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1030 on: February 20, 2018, 01:43:44 PM »
Please be aware that a lot of things can impact performance on low end PCs. Not just bullets. Effects, sounds, number of enemies, the number of tasks/loops running.

But it is a good thing to start with the bullets.

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1031 on: February 20, 2018, 10:02:15 PM »
Ah, I see. Then how can I apply/join the Discord group ?
I would like to join it too :D
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Trung0246

  • Gaming, coding, drawing, composing, ... for fun
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1032 on: February 21, 2018, 12:05:21 AM »
I would like to join it too :D
3 of us !
My workbench & codedump
Gallery & album (WIP)

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1033 on: March 03, 2018, 12:09:43 AM »
How can I make multi phased Nonspells and Spells?
and
Can I put two shotsheets in one plural script?
« Last Edit: March 03, 2018, 02:41:53 AM by jao »
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1034 on: March 03, 2018, 03:57:30 AM »
How can I make multi phased Nonspells and Spells?
and
Can I put two shotsheets in one plural script?

Multi-phased: Have multiple tasks. Not all tasks need to run while the boss is alive either. You can have a task that does one thing for x frames, then does another thing for y frames, etc.

Shotsheets: Yes. However, the numbers used for the constants must be different between the two. Otherwise the second one you load will override the numbers for the first shot sheet.

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1035 on: March 03, 2018, 11:58:18 PM »
Multi-phased: Have multiple tasks. Not all tasks need to run while the boss is alive either. You can have a task that does one thing for x frames, then does another thing for y frames, etc.
Can you give an example, because I can't understand clearly.
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1036 on: March 04, 2018, 12:43:04 AM »
Can you give an example, because I can't understand clearly.
Code: [Select]
task mainTask {
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
        //Phase 1
        loop(6) {
            ascent(i in 0..36) {
                ascent(j in 0..4) {
                    CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2 + j/4, GetAngleToPlayer(objBoss) + 360/36*i, 4, 5);
                }
            }
            wait(20);
        }
        wait(120);
        //Phase 2
        let randangle = rand(0, 360);
        ascent(i in 0..120) {
            loop(4) {
                CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 1 + i/30, randangle, 6, 5);
                randangle += 360/4;
            }
            randangle += 7.1 + i/30;
            wait(2);
        }
        wait(120);
    }
}

In this case, Phase 1 is designated under "//Phase 1" while Phase 2 is designated under "//Phase 2". You could alternatively use tasks.

With tasks the contents of each phase would be in a task, and you would wait the appropriate amount of time in the main task. Like so:

Code: [Select]
task mainTask {
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
        //Phase 1
        taskA;
        wait(120); //time for taskA to run
        wait(120);
        //Phase 2
        taskB;
        wait(240); //time for taskB to run
        wait(120);
    }
}

task taskA {
    loop(6) {
        ascent(i in 0..36) {
            ascent(j in 0..4) {
                CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2 + j/4, GetAngleToPlayer(objBoss) + 360/36*i, 4, 5);
            }
        }
        wait(20);
    }
}

task taskB {
    let randangle = rand(0, 360);
    ascent(i in 0..120) {
        loop(4) {
            CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 1 + i/30, randangle, 6, 5);
            randangle += 360/4;
        }
        randangle += 7.1 + i/30;
        wait(2);
    }
}
« Last Edit: March 04, 2018, 12:45:25 AM by Sparen »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1037 on: March 04, 2018, 01:46:34 AM »
If you want to make the phases of the attack move onwards when bosshp reaches a certain threshold, then just put each phase in a loop while the bosses' health is above a certain threshold.
 
Working from Sparen's earlier example:

Code: [Select]
task mainTask {
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
//Phase 1 last until the boss's life gets below 3000
        while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 3000) {
            loop(6) {
                ascent(i in 0..36) {
                    ascent(j in 0..4) {
                        CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2 + j/4, GetAngleToPlayer(objBoss) + 360/36*i, 4, 5);
                    }
                }
                wait(20);
            }
}
        wait(120);
        //Phase 2
       //If there were a third phase when the boss got to, say, 1500 health, you'd just put a similar while loop around Phase 2 as well
        let randangle = rand(0, 360);
        ascent(i in 0..120) {
            loop(4) {
                CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 1 + i/30, randangle, 6, 5);
                randangle += 360/4;
            }
            randangle += 7.1 + i/30;
            wait(2);
        }
        wait(120);
    }
}

Its also usually a good idea to have the pattern skip straight to the last phase if the player takes too long to clear it, like how Boundary of Life and Death works if you try to time it out. That can be accomplished by just adding a time condition to each phase's while loop.

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1038 on: March 04, 2018, 02:27:37 PM »
Thank you Sparen and Arcvasti, you really helped me! :D
I really like the tasking style (it's simple and looks organized):
Code: [Select]
task mainTask {
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
        //Phase 1
        taskA;
        wait(120); //time for taskA to run
        wait(120);
        //Phase 2
        taskB;
        wait(240); //time for taskB to run
        wait(120);
    }
}
Just to note, I already knew about the division by the boss health, I made "First and Nameless Danmaku" with my old Mamizou script (the first) --- but thanks anyways ;)
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1039 on: March 05, 2018, 07:06:32 AM »
Note that if you make taskA and taskB functions instead of tasks you don't have to repeat your code and manually wait, because then waiting in the function waits the parent task instead. This also works fine with the life method.
Here's also an addition you might want for checking boss life in the middle of patterns rather than just when the loop restarts.

Code: [Select]
task mainTask(){
    phaseA(3000);
    wait(120);
    phaseB(0);
    wait(120);
}

function phaseA(life_t){
    while(check_life(life_t)){
        loop(60){
            // shoot bullet
            if(!wait_check_life(3, life_t)){ return; }
        }
        if(!wait_check_life(120, life_t)){ return; }
    }
}

function phaseB(life_t){
    while(check_life(life_t)) {
        // do stuff
        if(!wait_check_life(120, life_t)){ return; }
        // do stuff
        if(!wait_check_life(120, life_t)){ return; }
    }
}

function check_life(life_t){
    return (ObjEnemy_GetInfo(objBoss, INFO_LIFE) > life_t);
}

function wait_check_life(n, life_t){
    loop(n){
        if(check_life(life_t)){ yield; }
        else{ return false; }
    }
    return true;
}
« Last Edit: March 05, 2018, 07:10:48 AM by Drake »

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 #1040 on: March 10, 2018, 12:42:02 AM »
What is wrong with this (its repeating but it isn't ending the task)?
https://pastebin.com/5n90wMCJ
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1041 on: March 10, 2018, 02:06:26 AM »
I can think of two reasons why, off the top of my head:

1: The balls task has what seems to be an infinite loop inside it. This is probably the immediate culprit.
2: The condition for ending the while loop in timeline won't trigger if the boss's health goes below zero. I can't remember if that's possible or not, but it seems plausible.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1042 on: March 10, 2018, 01:26:29 PM »
That's right. Each call of ball looks like it's meant to shoot a new pattern, not supposed to be a running loop, so get rid of the outer loop. I would also use life <= 0 instead of life != 0 for semantic purposes, even if it's effectively the same.

Also, I would recommend putting the if(ObjEnemy_GetInfo(objBoss, INFO_LIFE) <= 0){return;} in the timeline loop before each pattern call instead, that way timeline can end immediately instead of having to wait a couple seconds to be over.
« Last Edit: March 10, 2018, 01:33:48 PM 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 #1043 on: March 11, 2018, 04:38:50 AM »
How do item scripts work? I haven't been able to find a good resource. More specifically, how do I change the graphics used for items? The defaults are... ugly. ...Where are the default item graphics even stored, for that matter?

I'm currently digging around in TresserT's Reisen from RaNGE 14 (the first I tried that had non-default item graphics), but I can't find... I just found it, he skipped using items entirely and made his own out of primitives. Is changing the item graphics really so hard as to drive someone to do that?

Random question: Where do I change nicknames on here? I don't see it in forum profile with the rest.

Another question: How big is the potential performance difference between if statements and alternatives in Danmakufu? I'm finally getting around to reworking my UI, and I keep trying to optimize everything. And one of the things I've been trying to avoid is unnecessary branching, so I've been using alternatives instead of ifs, since they do fancy shit with tables to be faster. But now I have it stuck in my head that alternative==faster and I keep using it even when there's only one condition I want to check.
Worse, I keep doing stuff like
Code: [Select]
n = i-whole;
alternative( floor(n/((|n|)+1)) - floor(-n/((|-n|)+1)) ) //sign(n)
case(-1){ x = 5; }
case( 0){ x = pieces; }
case( 1){ x = 0; }
when I could very easily just go
Code: [Select]
if(i<whole){       x = 5; }
else if(i==whole){ x = pieces; }
else {             x = 0; }
and long story short I need someone to tell me to stop.
« Last Edit: March 11, 2018, 06:42:51 AM by Andi »
Literally everything in this script will crash and burn.
1CC tracker

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1044 on: March 11, 2018, 06:00:57 AM »
The default item graphics are stored in th_dnh_ph3/resource/img. Changing that would probably be a poor plan unless you're distributing your own package script[Maybe even then?], since it'd also affect the item graphics for every other script. There's probably a better way to make item scripts work, but I sure don't know what it is.

re: Changing nicknames:

I think that this might be one of those forums where you have to PM an admin and they'll change your username for you[Assuming it isn't an awful awful username, of course]? Not really sure.


EDIT: Disregard above, I misread nickname as username. And also got that wrong.
« Last Edit: March 11, 2018, 06:03:49 AM by Arcvasti »

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1045 on: March 11, 2018, 05:53:32 PM »
How do item scripts work? I haven't been able to find a good resource. More specifically, how do I change the graphics used for items? The defaults are... ugly. ...Where are the default item graphics even stored, for that matter?
You can't change the default item handling; they're probably just packaged right into the game. Rather, even if you could change the defaults it wouldn't be a good idea. Defining your own items instead is just the better course of action.

Here's a blurb (+linked blurb) that might be good enough:
https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1373257.html#msg1373257

Another question: How big is the potential performance difference between if statements and alternatives in Danmakufu?
If this were a compiled language there could be optimizations done with jump tables, depending on the context, the compiler, settings used, etc, but it also just as easily can compile to literally the same thing as if you used if statements. More than that though, this is an interpreted language running on an engine and such specific optimizations can't even be applied, it depends entirely on how the engine handles it. The difference between ifs and switches is extremely negligible, if it's even different at all here, and is greatly overwhelmed by like, everything else. There is no way that branching is going to impact performance in meaningful ways and I would recommend not focusing too hard on it because that is definitely not where your heaviest parts are going to be. I highly anticipate that the extra massaging you do to get the cases you want would end up outweighing any potential benefits, if they even exist.

Random question: Where do I change nicknames on here? I don't see it in forum profile with the rest.
Display names are changed in Account Settings. "Nicknames" are intentionally static and can only be changed by admins.
« Last Edit: March 11, 2018, 05:55:08 PM 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 #1046 on: March 11, 2018, 07:16:45 PM »
Here's a blurb (+linked blurb) that might be good enough:
https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1373257.html#msg1373257
Thanks! Is there anything on what to put in the item data file? Or just point me at a script that uses it to dig through?
Literally everything in this script will crash and burn.
1CC tracker

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1047 on: March 11, 2018, 08:13:54 PM »
It works pretty similarly to shot data files and stuff. Here's what the beginning of an item data file could look like if, say, you want item 1 to be a point item and item 2 to be a power item:

Code: [Select]
#UserItemData

item_image = "./img/item.png"

//Point item
ItemData{
id = 1
rect = (208, 0, 224, 16)
out = (208, 16, 224, 32)
render = ALPHA
alpha = 255
}

//Power item
ItemData{
id = 2
rect = (192, 0, 208, 16)
out = (192, 16, 208, 32)
render = ALPHA
alpha = 255
}

item_image is the image containing the item graphics. rect is the image coordinates for the item. out is the image coordinates for the arrow that's displayed at the top of the playing field when the item flies above bounds. render and alpha are self-explanatory; you probably don't even need to put them in there but you can if you want/need. You might even be able to use some of the other properties you can define in the shot data file, but I haven't played around much with that.

For more items, just keep adding more of these with different IDs.

R. P. Genocraft

  • Craftsman of absolute unpredictability
  • Boundary of productive and lazy
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1048 on: March 11, 2018, 08:38:54 PM »
Is there a way to check what kind of object an object is? Like, a task that checks if an object is a laser and does something different if it isn't.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1049 on: March 11, 2018, 09:21:25 PM »
Is there a way to check what kind of object an object is? Like, a task that checks if an object is a laser and does something different if it isn't.

Yes, there is Obj_GetType, which should be exactly what you're looking for.