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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1110 on: March 31, 2018, 12:19:53 AM »
length(array) returns how many items there are in an array.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1111 on: March 31, 2018, 07:42:40 AM »
Given that I've only been experiencing this issue (not just with this script btw) with Ultima's DDC ReimuB I'll pin the blame on that, and just use another player then. Thanks for the help.
maybe you should not try throwing 8000 bullets on the screen regardless

Here are some concerns I found:

- In spell4.dnh, CheckHitWall will return null if the bullet is deleted somehow, leading to angle being unset when you use it, throwing an error. You might not have seen this error but it happened on my first run.
- In functions.txt, for PlaySound you do something like if(str == "Shot1"){ObjSound_Load(s,MainSTG~"sound/Shot1.wav");} but like 30 times, which means:
  - You aren't using else-ifs so as to not compare against every string
  - You aren't using alternative-case which is what you should be doing instead, given you want to choose between all these string comparisons
  - Note that you can replace all this boilerplate with ObjSound_Load(s,MainSTG~"sound/"~str~".wav"); given that all the strings being called are also the filenames
- You don't delete the sound objects after you create them, but you create a new object for every call, so you'll have a gazillion of them quickly.

This last one will cause your issue, as the number of objects will grow endlessly and start causing memory leaks or whatever else. If you're using sounds in your original script, which is what I suspect, this is almost surely the cause.

If this is the case, I would guess that the reason you see it with that particular player script could be that with other player scripts you end the fight sooner and don't have enough time for the problem to build to critical levels.

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

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1112 on: March 31, 2018, 09:35:20 AM »
maybe you should not try throwing 8000 bullets on the screen regardless

Here are some concerns I found:

- In spell4.dnh, CheckHitWall will return null if the bullet is deleted somehow, leading to angle being unset when you use it, throwing an error. You might not have seen this error but it happened on my first run.
- In functions.txt, for PlaySound you do something like if(str == "Shot1"){ObjSound_Load(s,MainSTG~"sound/Shot1.wav");} but like 30 times, which means:
  - You aren't using else-ifs so as to not compare against every string
  - You aren't using alternative-case which is what you should be doing instead, given you want to choose between all these string comparisons
  - Note that you can replace all this boilerplate with ObjSound_Load(s,MainSTG~"sound/"~str~".wav"); given that all the strings being called are also the filenames
- You don't delete the sound objects after you create them, but you create a new object for every call, so you'll have a gazillion of them quickly.

This last one will cause your issue, as the number of objects will grow endlessly and start causing memory leaks or whatever else. If you're using sounds in your original script, which is what I suspect, this is almost surely the cause.

If this is the case, I would guess that the reason you see it with that particular player script could be that with other player scripts you end the fight sooner and don't have enough time for the problem to build to critical levels.

Thanks for the analysis. I don't actually have any sound effects in my scripts, so I'll just remove those from the functions.txt; I've also fixed spell4.dnh now.
The final script'll just use another Reimu shot that doesn't have the issues but kills everything at roughly the same time.
Lunatic 1cc: EoSD, PCB, IN, MoF, TD, DDC, LoLK, HSiFS, WBaWC

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1113 on: March 31, 2018, 10:50:13 AM »
Unrelated to CrestedPeak9's problem but general advise to all Danmakufu programmers: Keep the Log window open when analysing problems with performance and other weird behaviour. There is lots of information given in the log window and trivial things such as potential slowdowns can be easily detected. The Log windows is easily enabled from config.exe -> option -> show log file.

Edit
@ CrestedPeak9, I've downloaded your junko script and checked. Tested using default Rumia with god mode then tested with Ultimate's DDC ReimuB. All bullets were appearing fine, but there was 15 FPS slow down on the 9th Spell Card because over 8000 bullets on the screen.

Aside from your problems, this is very bad design and you should avoid this at all costs.

Now about your problem:
You're not reading into what people are answering. Even now in your last post you keep mentioning the player script. There is nothing wrong with it in combination with your script. When three people conclude this by testing then obviously your problem is something else which you aren't clearly communicating or showing us.

I highly suggest you stop assuming things and upload your entire Dnh folder without stripping anything.
« Last Edit: March 31, 2018, 12:05:11 PM by Helepolis »

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1114 on: March 31, 2018, 11:05:27 AM »
The final script'll just use another Reimu shot that doesn't have the issues but kills everything at roughly the same time.
That... doesn't solve the issue though. You're claiming that it's the player script, but even if Ultima's script has some minor problems with resource usage it shouldn't be as significant as throwing so many bullets on screen. If it is a problem with Ultima's script, then it would be good to find out what the problem is and get it fixed, not just ignore it. I've also spent a good deal of time going through both of your scripts, so I would like some closure here. Can you replicate the problem while giving more information? If you replicate the bug but have the log window open (as Hele just posted how to do) and post screenshots that could help tremendously in pinpointing the issue.

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

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1115 on: April 01, 2018, 03:12:39 AM »
Sorry to everyone; I didn't mean to be presumptuous, but I was rushing to get the script out for a contest outside of this community, and one of my playtesters also encountered the same issues that I did. When I switched to another Reimu script I just wanted to get the boss fight ready.

In the meantime however, I'll look into changing spell6 to use white lasers for the obscuring effect, and I'll post logs when I get the time to.
This is the dnh folder I was using with all other scripts cleaned out: http://bit.ly/2pT8ZXJ

Edit: It just occured to me that I did modify Ultima's player script slightly in changing the grazebox, so I've uploaded my modified player script and a replay with the issue (at least on my PC).
https://www.dropbox.com/s/kq824xvw9f6pvfm/package2.zip?dl=0
« Last Edit: April 01, 2018, 03:40:01 AM by CrestedPeak9 »
Lunatic 1cc: EoSD, PCB, IN, MoF, TD, DDC, LoLK, HSiFS, WBaWC

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1116 on: April 01, 2018, 04:09:08 AM »
Edit: It just occured to me that I did modify Ultima's player script slightly in changing the grazebox, so I've uploaded my modified player script and a replay with the issue (at least on my PC).
https://www.dropbox.com/s/kq824xvw9f6pvfm/package2.zip?dl=0

From what I can see, on death Ultima's player starts approx. 60 nonterminating tasks. When I tested with my own player, the extra tasks did not appear. Currently looking into it; might not find an answer due to the terrible formatting on the player script.

Update: Yeah I have no idea where the problem is. Sorry about that. I will recommend using another player.
« Last Edit: April 01, 2018, 04:22:43 AM by Sparen »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1117 on: April 01, 2018, 06:02:32 AM »
...This is the dnh folder I was using...
...Edit: It just occured to me that I did modify Ultima's player script slightly in changing the grazebox,..
This makes absolutely no sense. Why did you upload your entire dnh folder but then removed the player script and now are separately uploading it because you thought you modified the player script? You were suppose to upload your entire Dnh folder without cleaning up anything. I explicitly requested this.

Edit:
There are four difficulty levels. Which one of these are causing the issue?

Edit2
Your replay is not functioning because it throws me the error "自機スクリプトが見つかりません:[ReimuH.dnh]" which basically means the replay was unable to find the player script.

We seriously cannot help you if you keep doing things you were not told to do.
« Last Edit: April 01, 2018, 06:15:37 AM by Helepolis »

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1118 on: April 01, 2018, 06:15:13 AM »
This makes absolutely no sense. Why did you uploaded your entire dnh folder but then removed the player script and now are separately uploading it because you thought you modified the player script? You were suppose to upload your entire Dnh folder without cleaning up anything. I explicitly requested this.

That folder I uploaded was the one I released for the external contest. Sorry about that, I was trying to minimize the download size since I had a lot of other scripts.
https://www.dropbox.com/s/d3phs0k07ut79py/danmakufu%20ph3%20pre6a.zip?dl=0


Lunatic 1cc: EoSD, PCB, IN, MoF, TD, DDC, LoLK, HSiFS, WBaWC

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1119 on: April 01, 2018, 07:04:58 AM »
That folder I uploaded was the one I released for the external contest. Sorry about that, I was trying to minimize the download size since I had a lot of other scripts.
https://www.dropbox.com/s/d3phs0k07ut79py/danmakufu%20ph3%20pre6a.zip?dl=0
This dnh folder does not function. Booting it spits out this massive 1.45mb log. Here is a snip:  https://pastebin.com/6584Dk5u

Once loaded, I am missing all player scripts except Reimu MoF.

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1120 on: April 01, 2018, 10:17:26 AM »
This dnh folder does not function. Booting it spits out this massive 1.45mb log. Here is a snip:  https://pastebin.com/6584Dk5u

Once loaded, I am missing all player scripts except Reimu MoF.

I'm not sure what happened. I've uploaded it again.
Lunatic 1cc: EoSD, PCB, IN, MoF, TD, DDC, LoLK, HSiFS, WBaWC

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1121 on: April 01, 2018, 10:42:03 AM »
Found it. In Ultima's player script, on EV_HIT it calls DestructionA1 which calls Cherry a bunch of times, which does not end once the expected conditions are met. This by itself is not so much of a problem, but first I have to explain parallel universes object IDs.

Object IDs are just integers that index into a table of all objects. When you create an object with a function like ObjPrim_Create or CreateShotA1, it returns the object ID, which is just an integer that the engine will use to look up where the actual object is stored in memory. The table of object IDs range from 0 to 65535 (a range of 2^16). As you create objects the next ID number available just goes up one by one, so you create object 0, 1, 2, etc. However once the next ID passes 65535 it wraps back around to 0. This is generally fine, because even though the next ID resets to 0, any IDs with existing objects are skipped over until the next available one.

Here in the Cherry task, the ora variable decreases per frame and once it hits 0 the cherry object is deleted. Once the cherry objects are deleted, their IDs are free to be assigned new objects again. The tasks keep going and continue to keep calling Obj_Delete(obj). Meanwhile, the boss script is constantly spewing out tons of bullets, and motors through the available object IDs quickly. It hits 65535, wraps back around, and eventually reaches the object IDs that are still stored by the cherry object variables, which have long since been deleted but are still just integers so whatever. Then it deletes the new objects with Obj_Delete(obj). This happens for 60 object IDs, so that's 60 objects later being spontaneously deleted, but this is for every time that function is triggered, which is when you get hit. So the more you get hit, the more often this happens and the more object IDs get set up to be deleted, which also wouldn't be obvious if not for the infinite lives given allowing you to die a kajillion times.

So it's a big combination of crap. Only with both of your combined crap could you get so much crap it would cause this issue.


Despite that explanation, literally the only thing needed to "fix" this really is to replace the raw infinite loop with a while-not-deleted loop or anything else that lets the task end properly. But this also really only shows up (and in a noticeable way) because of the unreasonable quantity of bullets being put out by the boss script (which is not exactly a good thing itself) and the infinite lives.
« Last Edit: April 01, 2018, 10:50:34 AM by Drake »

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

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1122 on: April 01, 2018, 12:58:11 PM »
Thanks a lot, Drake. I'll get to fixing two of those three things, but I can't really change the dying a lot part.

I do have another issue though. In all variants of spell5, occasionally, the second phase with the green bullets won't trigger and nothing spawns except for the red wall. I tried cleaning up the script and make the health a global variable, then have mainloop update it every frame, but it still fails to trigger sometimes. Is there someone wrong I'm doing with the conditionals?
Lunatic 1cc: EoSD, PCB, IN, MoF, TD, DDC, LoLK, HSiFS, WBaWC

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1123 on: April 01, 2018, 01:00:02 PM »
I know that 0.12m is a old version, but I really want to try to make something...
The problem is: Danmakufu keeps crashing without the menu(with AppLocale and LocaleEmulator),
when I open naturally it opens the menu, but when I select ExRumia (directory) *crash*
Plz Help mee
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1124 on: April 01, 2018, 01:57:42 PM »
I know that 0.12m is a old version, but I really want to try to make something...
The problem is: Danmakufu keeps crashing without the menu(with AppLocale and LocaleEmulator),
when I open naturally it opens the menu, but when I select ExRumia (directory) *crash*
Plz Help mee
As moderator I need to alert you of the following: It is not encouraged to make anything in 0.12m. I've written in the FAQ about this. The only things that should be supported is getting old scripts to work for research/playing purposes. Seeing that you aren't trying to get someone else's script to work but actually attempting a creation I suggest to do it in ph3.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1125 on: April 02, 2018, 05:03:29 AM »
I do have another issue though. In all variants of spell5, occasionally, the second phase with the green bullets won't trigger and nothing spawns except for the red wall. I tried cleaning up the script and make the health a global variable, then have mainloop update it every frame, but it still fails to trigger sometimes. Is there someone wrong I'm doing with the conditionals?
Can't replicate after like 10 attempts. Have a replay? Preferably of just the spell?

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

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1126 on: April 02, 2018, 06:06:23 AM »
Can't replicate after like 10 attempts. Have a replay? Preferably of just the spell?

https://cdn.discordapp.com/attachments/428716490653696000/430102399646957574/Junko3_replay03.dat
Unfortunately I couldn't replicate it either, but here's a replay with the issue occuring during a Lunatic plural run that one of my testers submitted.
Lunatic 1cc: EoSD, PCB, IN, MoF, TD, DDC, LoLK, HSiFS, WBaWC

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1127 on: April 02, 2018, 07:13:59 AM »
The break statement is used to exit loops, not functions. If you use break in a function or task, it will end it immediately and cascade down the function call chain until it does find something to break out of.
Code: [Select]
function a{
  b;
}

task b{
  loop(10){
    c;
    yield;
  }
  break;
}

function c{
  break;
}
In the above example: a calls b; b starts a loop and calls c; c breaks, cascades back to b, and breaks the loop; b then breaks after the loop, cascades back to a, breaks a, then keeps cascading break to whatever a's context was.

In your case, the big blue bullet is deleted by hitting 5000 life before it hits the wall, triggering if(Obj_IsDeleted(blue)){break;} which ends the BlueHelix task, cascades back through the Main task and then breaks out of the while (life > 0) loop, ending the rest of the pattern.

Always use return to end a function or task. I suggest fixing anywhere in your code that breaks instead of returning.

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

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1128 on: April 02, 2018, 09:11:22 AM »
Always use return to end a function or task. I suggest fixing anywhere in your code that breaks instead of returning.
I suddenly have a sense of deja vu...
Thanks for the help. I'll need to, uh, break this bad habit of mine.
Lunatic 1cc: EoSD, PCB, IN, MoF, TD, DDC, LoLK, HSiFS, WBaWC

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1129 on: April 08, 2018, 10:05:00 PM »
(Whoops, double-checked and I wasn't deleting my ObjSounds when I was done with them either. No wonder I was having some fps issues.)

So, I know Danmakufu is kinda bad about arrays. What I'm not sure of is the relative speed of common data and object dictionaries. My guess is it's at least somewhat slower than just using a variable, but I'm unsure how it compares to arrays.

Specifically, how stupid of an idea would it be to forgo arrays entirely and use SetCommonData("arrname"~itoa(i),v);, Obj_SetValue(arrobj,itoa(i),v);, or SetAreaCommonData("arrname",itoa(i),v); instead?

Testing with a single that does nothing but increment members of an "array" 10000 times per frame - that is:
Code: [Select]
let size=10; arr=Arr_Init(size,0);
let ops_per_frame = 10000;
loop{
loop(ops_per_frame){
let v = Arr_Get(arr,i);
Arr_Set(arr,i,v+1);
i=(i+1)%size;
}
yield;
}
With the methods using an alternative on a global to determine which type of "array" to use. (Here's the code for the methods.)
Here are the FPS values I recorded for each test:
Code: [Select]
V:    | 27 |    | 33    single variable (ignoring index)
v: 13 |    | 13 | 12    10 variables w/alternative
n: 09 | 24 | 21 | 19    normal array
o: 14 | 16 | 16 | 15    object dictionary
c: 09 | 11 | 10 | 10    common data
a: 09 | 11 | 11 | 10    area common data
It seems like none of them are faster than normal arrays, aside from in the first set of tests. It also seems that the alternatives for working with the individual variables are actually slower than just using an arrays.

Thoughts? Second opinions?
Literally everything in this script will crash and burn.
1CC tracker

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1130 on: April 10, 2018, 12:46:16 PM »
So I was wondering how people get the boss's health bar to be a red circle around the boss instead of on the top of the screen. To add to this, could anyone help me with spellcard pictures? Like whenever a spellcard is declared, usually a picture of the boss hovers over the screen for a second. How do I do this?

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1131 on: April 10, 2018, 12:51:06 PM »
So I was wondering how people get the boss's health bar to be a red circle around the boss instead of on the top of the screen. To add to this, could anyone help me with spellcard pictures? Like whenever a spellcard is declared, usually a picture of the boss hovers over the screen for a second. How do I do this?
The hovering of the boss and such is called often a ' cutin '. It is nothing else than drawing a texture on the screen and then moving it around in a sequence. You can code it yourself or download ready made scripts. Have you checked the sticky Information thread?

The circular life bar I am unsure whether it was mentioned here or not. Need some extra reply on this one.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1132 on: April 10, 2018, 12:56:54 PM »
The hovering of the boss and such is called often a ' cutin '. It is nothing else than drawing a texture on the screen and then moving it around in a sequence. You can code it yourself or download ready made scripts. Have you checked the sticky Information thread?

The circular life bar I am unsure whether it was mentioned here or not. Need some extra reply on this one.
Thank you, this will help a lot! While I'm here could I ask if there are any ready made scripts to make dialogue? If not, what is an easy way to create a dialogue function/system?

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1133 on: April 10, 2018, 02:09:13 PM »
Thank you, this will help a lot! While I'm here could I ask if there are any ready made scripts to make dialogue? If not, what is an easy way to create a dialogue function/system?
There are various libraries floating around. Here's one of Python's scripts using one.
Literally everything in this script will crash and burn.
1CC tracker

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1134 on: April 10, 2018, 02:50:26 PM »
There are various libraries floating around. Here's one of Python's scripts using one.
Sorry I'm not that experienced, but I found the Dialogue file but I can't seem to find him using it anywhere in the game. How would I use this file with it's functions?

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1135 on: April 10, 2018, 03:32:37 PM »
Sorry I'm not that experienced, but I found the Dialogue file but I can't seem to find him using it anywhere in the game. How would I use this file with it's functions?
Something like this, usually in a separate single. (Ignore SetBGM and ShowEnemyTitle, those aren't part of the library.)

how people get the boss's health bar to be a red circle around the boss instead of on the top of the screen
Here's a task I grabbed from somewhere to do it. (You'll probably need to change the filepaths.)
« Last Edit: April 10, 2018, 09:35:27 PM by Andi »
Literally everything in this script will crash and burn.
1CC tracker

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1136 on: April 11, 2018, 12:38:47 PM »
Something like this, usually in a separate single. (Ignore SetBGM and ShowEnemyTitle, those aren't part of the library.)
Here's a task I grabbed from somewhere to do it. (You'll probably need to change the filepaths.)
Thank you so much!

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1137 on: April 11, 2018, 01:05:40 PM »
Something like this, usually in a separate single. (Ignore SetBGM and ShowEnemyTitle, those aren't part of the library.)
Here's a task I grabbed from somewhere to do it. (You'll probably need to change the filepaths.)
Sorry, just one more question. Every time I try to use the Dialogue pastebin you gave me, the entire program crashes. (yes I changed the images to my own)

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1138 on: April 11, 2018, 03:15:42 PM »
Sorry, just one more question. Every time I try to use the Dialogue pastebin you gave me, the entire program crashes. (yes I changed the images to my own)
Could you copy-paste the error messages you get, or does your program freeze and not respond?
Lunatic 1cc: EoSD, PCB, IN, MoF, TD, DDC, LoLK, HSiFS, WBaWC

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1139 on: April 11, 2018, 03:22:19 PM »
Could you copy-paste the error messages you get, or does your program freeze and not respond?
It freezes and doesn't respond