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

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #930 on: January 10, 2018, 02:34:26 AM »
Relevantly, the fact that you're deleting the dummy shot from its own task should clue you in that you don't really need the dummy at all. The main benefit that returning a dummy shot object carrying the shot array has over just returning the shot array is that, if you want to change the array over time from an internal task, you can't just pass the array reference (because arrays are not mutable), so you use the mutable object instead. But in your case you aren't using the returned object at all, nor is the object being used in the task because it's just a dummy anyways. So really "Shots" and "IsNewShots" should just be variables.

Also it crashes because trying to access a nonexistent object value will crash. You typically use GetValueD everywhere which is safe but you can't get around SetValue without first checking if the object exists.


Here's all the code that I use (https://pastebin.com/YzMNJQ1j - danmakufu code; https://pastebin.com/wuCby6mg - HLSL code), but none of the ObjRender functions work on objShader. Maybe I'm missing something?
Haven't forgotten about this, but yes in order to do what you want you need some extra stuff. I have a test background I did this with, but there's a lot of unrelated code so it's a bit tricky to extract just the parts needed to explain what to do, so hang on.
« Last Edit: January 10, 2018, 02:39:13 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 #931 on: January 10, 2018, 03:35:06 AM »
Relevantly, the fact that you're deleting the dummy shot from its own task should clue you in that you don't really need the dummy at all. The main benefit that returning a dummy shot object carrying the shot array has over just returning the shot array is that, if you want to change the array over time from an internal task, you can't just pass the array reference (because arrays are not mutable), so you use the mutable object instead. But in your case you aren't using the returned object at all, nor is the object being used in the task because it's just a dummy anyways. So really "Shots" and "IsNewShots" should just be variables.
Normally I would just return the shot array, yes, but in this case not all the bullets are created immediately, so I'd only get an array containing the first bullet and not be able to get a reference to the others. By doing it like this I can come back and grab the references once all the shots have been created, or handle the new ones as they're created. I'm not using it for anything at the moment, but I almost certainly will at some point, so it's there when I need it.
Deleting it from the task is just to make sure it gets deleted, since it's not autodelete and isn't moving anyway - the idea is I'd copy the final array before it's deleted - but now that I look at it again there are better ways of ensuring that.

Haven't forgotten about this, but yes in order to do what you want you need some extra stuff. I have a test background I did this with, but there's a lot of unrelated code so it's a bit tricky to extract just the parts needed to explain what to do, so hang on.
You mean the gaps? They're shaping up pretty nicely, actually. Here's the current code: https://pastebin.com/VgTfDrTz
I still need to do some stuff like warping shots when they hit the back and making sure the edge detection works at all angles (currently it's near-perfect at 90/270 and a bit weird otherwise), but the main part is looking pretty solid.
Edit: Greatly improved after swapping around a few things so it checks where the edge actually is and not where the edge would be if the whole thing was mirrored: https://pastebin.com/p7qycsBU
« Last Edit: January 10, 2018, 04:20:08 AM by gameboy17 »
Literally everything in this script will crash and burn.
1CC tracker

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #932 on: January 10, 2018, 04:51:28 AM »
Normally I would just return the shot array, yes, but in this case not all the bullets are created immediately, so I'd only get an array containing the first bullet and not be able to get a reference to the others. By doing it like this I can come back and grab the references once all the shots have been created, or handle the new ones as they're created. Deleting it from the task is just to make sure it gets deleted, since it's not autodelete and isn't moving anyway - the idea is I'd copy the final array before it's deleted - but now that I look at it again there are better ways of ensuring that.
Well like I said, you don't actually seem to be using the return value for anything. Even if you did want to use the returned dummy object, you delete it, making it useless.

If you plan to actually use the array outside of the task, what you can do instead is to not use CreateShotA1, but create and set up the shots manually, all at once, but have each row of bullets call ObjShot_Regist (i.e. fire them) after a different number of frames. This way all the objects are created and can fill the array which you can then return.

Here's my implementation: https://gist.github.com/drakeirving/36aac5ad8ddcc504525a983d56a3e2ea

You mean the gaps?
I quoted somebody else, if you missed that ;P

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 #933 on: January 10, 2018, 10:00:34 PM »
Well like I said, you don't actually seem to be using the return value for anything. Even if you did want to use the returned dummy object, you delete it, making it useless.
It waits a few seconds after creating all the bullets to delete it, so I can grab a new reference before then. It is a bit silly, though, I'll probably rework it before actually using it.

If you plan to actually use the array outside of the task, what you can do instead is to not use CreateShotA1, but create and set up the shots manually, all at once, but have each row of bullets call ObjShot_Regist (i.e. fire them) after a different number of frames. This way all the objects are created and can fill the array which you can then return.
Ah, so that's what that's for! I kept seeing those and not quite getting why I would use them instead of the CreateShot functions. I'll have to mess around a bit with that, then.

Here's my implementation: https://gist.github.com/drakeirving/36aac5ad8ddcc504525a983d56a3e2ea
Random question, is there any particular reason you're allocating space for the reference to the shot in the loop itself? I usually put let shot, etc before the loop, so I can reuse the same variable and in theory save time on memory allocation.
On the other hand, I hadn't realized that you can avoid passing things in as arguments to those internal tasks like that, at least inside a loop. I always passed in i manually. Does the task need to be defined inside the loop to do that?

I quoted somebody else, if you missed that ;P
Ah, whoops. I hit quote and was looking at that when typing out my response.
Literally everything in this script will crash and burn.
1CC tracker

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #934 on: January 11, 2018, 03:39:24 AM »
Random question, is there any particular reason you're allocating space for the reference to the shot in the loop itself? I usually put let shot, etc before the loop, so I can reuse the same variable and in theory save time on memory allocation.
On the other hand, I hadn't realized that you can avoid passing things in as arguments to those internal tasks like that, at least inside a loop. I always passed in i manually. Does the task need to be defined inside the loop to do that?
Nah, no particular reason. Garbage collection works fine; it isn't as though the actual objects are allocated differently either; the ID is just a number. When it has a coding advantage I'll typically opt for it.

The task thing works precisely because the task is defined inside that scope. It acts like any other scope; it has access to the outer scope variables, any variables defined within do not exist outside the task (of course), and the task name only exists inside the scope it was defined in.

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 #935 on: January 12, 2018, 12:36:38 PM »
How am I supossed to do this in real code:
Code: [Select]
task TPlural{
        if(first_bosslife == 0) {
             create(second_boss);
             change(bgm1 to bgm2);
         }
}
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #936 on: January 12, 2018, 01:05:36 PM »
If you wanted to fight two bosses back-to-back you would make a stage with two plural scripts. A plural script generally (but doesn't have to) contains one boss.
Also see http://sparen.github.io/ph3tutorials/ph3u3l23.html
« Last Edit: January 12, 2018, 01:09:46 PM by Drake »

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 #937 on: January 12, 2018, 05:00:33 PM »
If you wanted to fight two bosses back-to-back you would make a stage with two plural scripts. A plural script generally (but doesn't have to) contains one boss.
Also see http://sparen.github.io/ph3tutorials/ph3u3l23.html

Threw together an example of two plural scripts in the same stage at the end of the guide.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #938 on: January 13, 2018, 06:33:59 AM »
After recent drivers update, all Danmakufu ph3 based games, includind ido games from MPP to BSM, became crash on start. Debugging shows that the problem is in the amd64 driver. Does anyone except me has such problem?
Easy: PoDD, FW, LoLK
Normal: SoEW, UFO, HSiFS
Hard: LLS, MS, EoSD, PoFW, MoF, SA, TD, DDC
Lunatic: PCB, IN
Extra: EoSD, PCB, IN, MoF, TD, DDC, HSiFS; Phantasm

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #939 on: January 13, 2018, 12:07:01 PM »
Threw together an example of two plural scripts in the same stage at the end of the guide.
Thank you for this adding this.

If you wanted to fight two bosses back-to-back you would make a stage with two plural scripts. A plural script generally (but doesn't have to) contains one boss.
Also see http://sparen.github.io/ph3tutorials/ph3u3l23.html
It worked perfectly and I thank you very much, but I'm having problem with the background and exiting (before reaching the boss - "you are using a variable that has not been set yet")

https://pastebin.com/Fsc1YgLy


Large code pastes go into pastebin links --Helepolis
« Last Edit: January 13, 2018, 01:12:28 PM by Helepolis »
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #940 on: January 13, 2018, 09:58:08 PM »
The problem seems to be that stagepart isn't set to a value when its created, but can be checked by @Event before it gets a value assigned to it. If you changed  line 7 from "let stagepart" to "let stagepart = 0", then it should probably work fine.

Trickysticks

  • What am I? TRICKYSTEAKS I AM!
  • A stick of the tricky variety.
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #941 on: January 13, 2018, 10:16:35 PM »
After recent drivers update, all Danmakufu ph3 based games, includind ido games from MPP to BSM, became crash on start. Debugging shows that the problem is in the amd64 driver. Does anyone except me has such problem?

When I updated the drivers for my AMD card that happened to me too. I tried restarting and other things but could only fix it by reverting my driver to the previous version.
Interested in playing some boss fights I made? Have Danmakufu? Then check out my Danmakufu creations!

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #942 on: January 14, 2018, 04:17:21 AM »
How you revert driver to older version?
Easy: PoDD, FW, LoLK
Normal: SoEW, UFO, HSiFS
Hard: LLS, MS, EoSD, PoFW, MoF, SA, TD, DDC
Lunatic: PCB, IN
Extra: EoSD, PCB, IN, MoF, TD, DDC, HSiFS; Phantasm

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #943 on: January 14, 2018, 09:49:32 AM »
The problem seems to be that stagepart isn't set to a value when its created, but can be checked by @Event before it gets a value assigned to it. If you changed  line 7 from "let stagepart" to "let stagepart = 0", then it should probably work fine.
The error is gone, thanks for the help :D
But... the background is still black...and I don't know why
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #944 on: January 14, 2018, 05:33:53 PM »
The error is gone, thanks for the help :D
But... the background is still black...and I don't know why

There's nothing in the code you pasted about a background, so I'm not sure about exactly what's wrong. Based on my own experiences with backgrounds though, the most likely thing that's wrong is filepaths. Its possible that either your stage script is referring to the wrong file with its #Background or your background script is referring to the wrong image.

PyuDi

  • daily touhou~
  • danmakufu!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #945 on: January 15, 2018, 07:22:11 AM »
I was wondering how to add the ?note? bullets from DDC. If there are, please tell me it.
However, I think there is none, so I will make it.
But the question is: how do I make the collision only in the head of the note bullet? +Is there any note bullet script?

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #946 on: January 15, 2018, 10:00:14 AM »
You can use the collision parameter in the shot definition to move the hitbox to the head. It should look like collision = (r, x, y) where r is the radius and x,y is the relative position of the hitbox from the center.

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 #947 on: January 15, 2018, 12:51:18 PM »
Here is my Background script and my Stage script (For anyone to see this and try to see the problem)
For me it's ok, but the background is black still...soooooo there is a problem! :blush:
  • The file's name and file's path is correct
  • It's included in the Stage, the Plurals and for nice practices in every Single
  • Perfectly works in the Plurals and the Singles
« Last Edit: January 15, 2018, 12:58:53 PM by jao »
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #948 on: January 15, 2018, 01:57:35 PM »
Almost definitely the problem is that you start it immediately with TCallBg which checks while(!Obj_IsDeleted(GetEnemyBossSceneObjectID())). In a Single or Plural, the boss scene object will exist before your script even starts (because it's created in the "default" stage script), but in a Stage script it won't exist until you start a plural script where you make the scene object. So the while loop condition fails immediately and your background is never created.

You can fix this by changing TCallBg to something else that makes sense for the stage. How it's set up right now (draw a normal bg until a spell starts, then draw the spell bg until it stops, and loop as long as the boss exists) is clearly meant for a boss fight, but if you actually had stuff before or after the boss, this doesn't make sense anymore.

Because your MainLoop already does the checking for an existing boss scene and spell (and puts the result in bSpell), you can actually make it simpler:
Code: [Select]
task TCallBg{
    loop{
        TNormalBackground;
        while(bSpell==false){ yield; }
        TSpellBackground;
        while(bSpell==true){ yield; }
    }
}


(For anyone else reading, there are reasons why you shouldn't quite do it this way, and there are better ways to set this up, but for the sake of this answer and simplicity it's better off ignoring all that)

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 #949 on: January 16, 2018, 01:59:14 AM »
I'm trying to write a function to safely check if a variable is null, deleted, or otherwise shouldn't be dereferenced. It can check both of those fine, but doing so 100% safely is out of reach unless I can find a way to check if it's been set.

Code: [Select]
function isnull(obj){                        //is this safe to use?
//do something              //if it hasn't been set
if(!obj){return true;}               //if it's null
if(Obj_IsDeleted(obj)){return true;} //if it's been deleted
return false;                        //we're good
}

Is there any possible way to check if a variable has been set without crashing the script? Exception handling, awful hacks, anything?
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 #950 on: January 16, 2018, 02:12:10 AM »
Almost definitely the problem is that you start it immediately with TCallBg which checks while(!Obj_IsDeleted(GetEnemyBossSceneObjectID())). In a Single or Plural, the boss scene object will exist before your script even starts (because it's created in the "default" stage script), but in a Stage script it won't exist until you start a plural script where you make the scene object. So the while loop condition fails immediately and your background is never created.

You can fix this by changing TCallBg to something else that makes sense for the stage. How it's set up right now (draw a normal bg until a spell starts, then draw the spell bg until it stops, and loop as long as the boss exists) is clearly meant for a boss fight, but if you actually had stuff before or after the boss, this doesn't make sense anymore.

Because your MainLoop already does the checking for an existing boss scene and spell (and puts the result in bSpell), you can actually make it simpler:
Code: [Select]
task TCallBg{
    loop{
        TNormalBackground;
        while(bSpell==false){ yield; }
        TSpellBackground;
        while(bSpell==true){ yield; }
    }
}

Thank you so much! It works perfectly :3 :3
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #951 on: January 16, 2018, 03:21:33 AM »
I'm trying to write a function to safely check if a variable is null, deleted, or otherwise shouldn't be dereferenced. It can check both of those fine, but doing so 100% safely is out of reach unless I can find a way to check if it's been set.

Is there any possible way to check if a variable has been set without crashing the script? Exception handling, awful hacks, anything?
I don't think this is ever possible. If your intended use is to set up variables meant to store object IDs but have them potentially empty, or want to empty them, and still have all processing work consistently, you should be setting the values to ID_INVALID, which is just -1.

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 #952 on: January 16, 2018, 09:24:08 AM »
I know it's really simple to do these desires, but I can't figure it out how to do them:
  • Write the name of the boss below the lifebar
  • Have an difficulty written (not with CommonData)
  • Have pretty effects(like charge, death, explode)
"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 #953 on: January 16, 2018, 03:24:46 PM »
I know it's really simple to do these desires, but I can't figure it out how to do them:
  • Write the name of the boss below the lifebar
  • Have an difficulty written (not with CommonData)
  • Have pretty effects(like charge, death, explode)

https://dmf.shrinemaiden.org/wiki/Text_Object_Functions
https://dmf.shrinemaiden.org/wiki/Primitive_Object_Functions
https://dmf.shrinemaiden.org/wiki/Render_Object_Functions

Everything you are trying to do can be done using Text objects and Render objects.
I suggest having a blank single script where you experiment with these and try to get them working the way you want.
For moving render objects, simply calculate their positions using trigonometry: current position = original position + time elapsed*speed, so currx = origx + time*speed*cos(angle), curry = origy + time*speed*sin(angle)

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #954 on: January 16, 2018, 05:24:57 PM »
Its also worth noting that the 0.12m tutorials are mostly still applicable to drawing stuff. The only big difference I noticed was that effect objects are now primitive objects in ph3.

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #955 on: January 17, 2018, 01:26:54 AM »
About fonts
I have a file named "reve.ttf" which font is Revue...but...
Which example should I use?
Code: [Select]
ObjText_SetFontType(text, "./reve.ttf");
//or
ObjText_SetFontType(text, Revue);
"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 #956 on: January 17, 2018, 01:35:36 AM »
About fonts
I have a file named "reve.ttf" which font is Revue...but...
Which example should I use?
Code: [Select]
ObjText_SetFontType(text, "./reve.ttf");
//or
ObjText_SetFontType(text, Revue);

The font name is Revue. Use Revue.

...I guess I should directly spell this out in my tutorial, huh.

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #957 on: January 17, 2018, 01:43:12 AM »
The font name is Revue. Use Revue.

...I guess I should directly spell this out in my tutorial, huh.
oops forgot InstallFont
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #958 on: January 17, 2018, 10:51:20 PM »
Is there a way to extract archives from .dat files?
"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 #959 on: January 17, 2018, 11:11:53 PM »
Is there a way to extract archives from .dat files?

If a creator decides to package their files so that they cannot be accessed by other people, please respect their decision to protect their assets.

If you want to rip their resources with complete disregard to their wishes, feel free to use Google search or the forum's search feature.