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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #120 on: April 13, 2016, 07:49:25 PM »
My Stage script starts to lag gradually about a minute after initiating the plural script. After 2 minutes, there's already only about 15FPS.
I checked and debugged my script many times, I came to realize it's definitely not an undeleted object, or a missing "yield;", and I still don't know what it is.
Is there a reason as to why my script might lag so much?
Lunatic 1CCs: PCB, IN, PoFV, HSiFS
Extra: All except PC-98.

Oh hey look I can do DNH scrips.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #121 on: April 13, 2016, 08:00:59 PM »
My Stage script starts to lag gradually about a minute after initiating the plural script. After 2 minutes, there's already only about 15FPS.
I checked and debugged my script many times, I came to realize it's definitely not an undeleted object, or a missing "yield;", and I still don't know what it is.
Is there a reason as to why my script might lag so much?
Doesn't needs to be undeleted objects. Could be something that spawns endless number of threads being started doing things endlessly. Btw, missing yields cannot cause lag (directly). A missing yield in a loop would insta-freeze your game. A missing yield in a regular task with no loop would instant finish the the task and then become 'dead'.

You'll need to do some checking:
- What is happening in your Log Window when you look at threads, values and such after the plural has been started?
- What happens if you don't activate the plural script in your stage? (Not summoning the boss)
- What happens if you run the plural script alone from the dnh menu?



Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #122 on: April 13, 2016, 08:27:34 PM »
I came to realize it's definitely not an undeleted object, or a missing "yield;", and I still don't know what it is.

Two things come to mind.
First, can you ensure that all of your task blocks are able to terminate? If you're calling tasks left and right, and they get caught up in an infinite loop somewhere, they can bottleneck your fps.
Please take a look below:
Code: [Select]
task foo( let bar )
{
    // ex1:
    loop
    {
        ...
        // no break
    }

    // ex2:
    let baz = true;
    while( baz )
    {
         ...
        // baz not accessed, no break
    }
}

if foo is called, as an example, it may never return.
There's also a second thing. You want to ensure that scripts themselves terminate and don't just hang in limbo when they finish their job.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #123 on: April 14, 2016, 06:41:19 PM »
So, by good ol' trial and error, I managed to find the problem.
It's the system file. :o

I still can't find the issue with it. I'm 100% sure there are no problems with the pause and replay scripts, because when I excluded them from the system file, the lag still persisted.
I've been looking at it for hours now, and I'm still struggling. (I swear if it's going to be something glaringly obvious--)

Here's my system script.
Lunatic 1CCs: PCB, IN, PoFV, HSiFS
Extra: All except PC-98.

Oh hey look I can do DNH scrips.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #124 on: April 14, 2016, 08:24:14 PM »
So, by good ol' trial and error, I managed to find the problem.
It's the system file. :o

I still can't find the issue with it. I'm 100% sure there are no problems with the pause and replay scripts, because when I excluded them from the system file, the lag still persisted.
I've been looking at it for hours now, and I'm still struggling. (I swear if it's going to be something glaringly obvious--)

Here's my system script.
You'll need more trial and error. The fun just started.

Start commenting out everything in @Initialize. Everything.

- Now start from the top by removing the comment from InitFrame(); first.
- Run your game > observe Log Window for threads, tasks, objects, shots, etc.
- If lag / fps drop > you found your problematic thread/task.
- If no lag, uncomment the next line > repeat from run game.

In the mean while I'll use this system file on my own end to observe and repeat same steps when there is lag.

Edit
Well, it is as I suspected. There is a reason why I told you to observe your Log Window. It is your best friend with detecting lag and such. Always use it when debugging/testing these things. If you haven't activated your log window. Shame on you!  :flamingv:

So quickly activate it here.
[attach=1]


Now your problem is that there are objects being created endlessly.
[attach=2]

See how first there were ~500 and few moments later there are over 5000? Apply the above trial & error to find which task is responsible for this.

Edit 2
- Upon enabling TBossLife(); I started seeing object_count going up.

Edit 3
At Line #290 you're creating an object inside function RenderLife(); which is called when ObjScene statement is no longer invalid (the loop calls the function thus you're continuously making objects). You might want to deal with that, so the object is created once and then mutated/modified instead of recreated. No idea what you're trying to achieve here. But that might be source of your problems.

Make sure you check the rest of your script. Don't just stop here. Comment out the obj2 creation and continue checking other tasks for similar behaviour.

Hope you learned some effective trial & error. Will save you struggling in future  :D
« Last Edit: April 14, 2016, 08:51:35 PM by Helepolis »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #125 on: April 15, 2016, 04:05:42 PM »
ouch.
ouch.

Well, it is as I suspected. There is a reason why I told you to observe your Log Window. It is your best friend with detecting lag and such. Always use it when debugging/testing these things. If you haven't activated your log window. Shame on you!  :flamingv:

i didn't actually know it was a thing that exists, and when you told me in the last post, i couldn't find the option to activate it, so i... guess there's that. and i could've just asked but i'm a stubborn idiot :getdown:
i've never learned a single thing, have i.
also this log window is a godsend why haven't i heard of it before.

No idea what you're trying to achieve here.

To be honest, neither do I.
I should have put "ObjPrim_Create(OBJ_SPRITE_2D);" at the start of the task, not in the RenderLife function. (By the way, it's supposed to be a lifebar container thingy.)

So, yeah... I fixed the issue.
I sincerely apologize for wasting your time on this mess. And thank you.
Lunatic 1CCs: PCB, IN, PoFV, HSiFS
Extra: All except PC-98.

Oh hey look I can do DNH scrips.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #126 on: April 16, 2016, 07:16:56 AM »
If you were wasting my time I wouldn't posting you know :V

To be honest, neither do I.
I should have put "ObjPrim_Create(OBJ_SPRITE_2D);" at the start of the task, not in the RenderLife function. (By the way, it's supposed to be a lifebar container thingy.)
Ooh, now I remember. Yea the little bars under the lifebar, counting the number of spell cards.


Good to hear you managed to fix it. Just keep in mind that any object or task you've made, and shouldn't be alive, should be killed/finished. I always test effects and such separately in a blanc script and monitor the object / task count to see if they are removed correctly.


Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #127 on: April 18, 2016, 05:57:51 PM »
So, I really didn't want to clog up this thread with myself again, but...
WHAT THE ACTUAL HELL IS WRONG WITH THIS SCRIPT. (<- link) It seems to be stable, yet Danmakufu keeps yelling at me!

The error says:

CreateOrbsS is not defined.
(CreateOrbsSは未定義の識別子です)
line(行)=102

That task is already defined!

Changing any of the parameters in the function results in the same error.

Now, this is where it gets interesting.
When I move the "CreateOrbsS(type, pos)" task above "Pattern", it results in THIS error:

BulletCommandsA1 is not defined.
(BulletCommandsA1は未定義の識別子です)
line(行)=134

Which is even weirder, considering it completely avoided the first half of the task, and decided to give me an error of the second half, which again, seems completely stable!
Oddly, when I remove "BulletCommandsA1(yinyang);" from the task, it then shows me the same error, but replaces "BulletCommandsA1 is not defined." with "MoveCommandsA1 is not defined.", and I have no clue why. All of these are properly defined.

Before anyone asks, yes, I did check if all the parentheses are matched. Yes, if I remove all mentions taks from the script, it runs perfectly (but it doesn't really do anything without them).
Lunatic 1CCs: PCB, IN, PoFV, HSiFS
Extra: All except PC-98.

Oh hey look I can do DNH scrips.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #128 on: April 18, 2016, 06:17:57 PM »
So, I really didn't want to clog up this thread with myself again, but...
WHAT THE ACTUAL HELL IS WRONG WITH THIS SCRIPT. (<- link) It seems to be stable, yet Danmakufu keeps yelling at me!

Check for missing semicolons, }, and ) in all of your #include files.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #129 on: April 18, 2016, 06:51:56 PM »
Check for missing semicolons, }, and ) in all of your #include files.

The script worked perfectly before I added the two tasks I talked about in my post, so I don't think there's a problem with my #include files.
Lunatic 1CCs: PCB, IN, PoFV, HSiFS
Extra: All except PC-98.

Oh hey look I can do DNH scrips.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #130 on: April 18, 2016, 07:56:44 PM »
The script worked perfectly before I added the two tasks I talked about in my post, so I don't think there's a problem with my #include files.

Oh wow I'm stupid. You have : instead of ; in various places in your script.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #131 on: April 18, 2016, 10:20:31 PM »
You have : instead of ; in various places in your script.

oh
let objAwalys = Obj_Create(OBJ_IDIOT);
ObjPrim_SetTexture(objAwalys, GetCurrentScriptDirectory ~ "./well.png");
RaiseError("i'm done");
Lunatic 1CCs: PCB, IN, PoFV, HSiFS
Extra: All except PC-98.

Oh hey look I can do DNH scrips.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #132 on: April 19, 2016, 08:57:14 AM »
I just added functionality to sublime-danmakufu to highlight colons as invalid characters for this reason (whether you're using it or not). They really don't have any meaning in the language, so hey whatever.

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #133 on: April 19, 2016, 09:31:29 AM »
I just added functionality to sublime-danmakufu to highlight colons as invalid characters for this reason (whether you're using it or not). They really don't have any meaning in the language, so hey whatever.

I'm currently using Notepad++, but I think I might just switch to Sublime Text for the upgrade. Hopefully someone makes a version for NP++ (though it could be much harder).
Thank you.

EDIT: This syntax is beautiful. It was definitely worth switching from Notepad++ to this.
« Last Edit: April 19, 2016, 09:42:11 AM by iVAwalys »
Lunatic 1CCs: PCB, IN, PoFV, HSiFS
Extra: All except PC-98.

Oh hey look I can do DNH scrips.

ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #134 on: April 19, 2016, 05:39:58 PM »
Hopefully someone makes a version for NP++ (though it could be much harder).
I actually have such a version. I cannot remember where I found it, but I'm pretty sure it was not from here. It's semi outdated but adequate for me. I could try to get it up to date and send it to you if you haven't become too attached to Sublime already.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #135 on: April 19, 2016, 07:07:21 PM »
I actually have such a version. I cannot remember where I found it, but I'm pretty sure it was not from here. It's semi outdated but adequate for me. I could try to get it up to date and send it to you if you haven't become too attached to Sublime already.

No need to, actually found one on these forums.
It's for ph3, and it also supports the Bespin theme, which is nice. Not quite sure if it's up to date or not.
Lunatic 1CCs: PCB, IN, PoFV, HSiFS
Extra: All except PC-98.

Oh hey look I can do DNH scrips.

ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #136 on: April 19, 2016, 08:07:09 PM »
No need to, actually found one on these forums.
It's for ph3, and it also supports the Bespin theme, which is nice. Not quite sure if it's up to date or not.
The last update Danmakufu Ph3 received was in January 2015, two months before that post was made. So assuming the person who made it was thorough, it should be complete and up to date. Might have to try that one myself.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #137 on: April 26, 2016, 06:22:12 PM »
Mod notice:
0.12m questions, if any, are welcome in this thread from now on. The main focus remains ph3, but we no longer wish to keep two separate threads. We don't expect people (or encourage them) to develop in the old engine as there is in our opinion no reason to do so any more.

Don't cry people. 0.12m served us well until this point on. But we know ph3 does it better. We will never forget you.

* Helepolis salutes.  ( ̄^ ̄)ゞ

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #138 on: April 27, 2016, 10:49:04 PM »
I need help figuring out how to implement this gameplay feature in my danmakufu project.

Basically what I want is a character that only gets shot down only if 2 or more bullets are touching the players hitbox.

At first I thought making this work would be easy. My initial idea was to have the hitbox disabled unless a bullet was touching a phantom hitbox, but I realized that the bullet that activated the phantom hitbox would immediately trigger the real one unless I could identify the exact bullet touching the phantom hitbox and making sure it wouldn't trigger a death.

Does anyone have an idea if making a hitbox that can ignore a particular object ID can be done?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #139 on: April 28, 2016, 02:21:35 AM »
I need help figuring out how to implement this gameplay feature in my danmakufu project.

Basically what I want is a character that only gets shot down only if 2 or more bullets are touching the players hitbox.

At first I thought making this work would be easy. My initial idea was to have the hitbox disabled unless a bullet was touching a phantom hitbox, but I realized that the bullet that activated the phantom hitbox would immediately trigger the real one unless I could identify the exact bullet touching the phantom hitbox and making sure it wouldn't trigger a death.

Does anyone have an idea if making a hitbox that can ignore a particular object ID can be done?

Ignoring a particular object is very hard if you don't know precisely what object that is. However, if you want the player to only die if multiple bullets are colliding, then that's not too bad.

You'll want to use GetShotIdInCircleA1(GetPlayerX, GetPlayerY, reasonable value) and from there iterate over the array of shots returned. In each case, use GetShotDataInfoA1 to obtain the radius of the bullet hitbox (this value is defined in the shot sheet or defaults based off of the dimensions of the shots). If the distance between the player and the bullet is less than or equal to the sum of the bullet's hitbox radius and the player hitbox radius, that's a collision.

From there, just make sure that at least two shots are colliding, and you're all good to go (you will need to disable the player's hitbox or disable the bullet's hitbox if only one is touching so that the player does not die unintentionally)

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #140 on: April 28, 2016, 03:35:20 PM »
Thank you Sparen, GetShotIdInCircleA1 was just what I needed!  :]

In case anyone is curious, here's how I've implemented it ATM. I still need to add proper detection of bullet size.

Code: [Select]
task tHitBox
{
loop{
while (length(GetShotIdInCircleA1(GetPlayerX,GetPlayerY,8))>1){
ObjPlayer_AddIntersectionCircleA1(objPlayer, 0, 0, 100, 20);
yield;
}//while
ObjPlayer_ClearIntersection(objPlayer);
yield;
}//loop
}

I do still have a small problem, since I'm using a non standard resolution and playing field size my character doesn't spawn in the lower center of the screen anymore, I can't seem to find where the default spawn coordinates are defined.
« Last Edit: April 28, 2016, 05:10:45 PM by arch »

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #141 on: April 29, 2016, 09:17:19 AM »
Player starting position is (GetStgFrameWidth() / 2, GetStgFrameHeight() - 32).

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

Random Sphere

  • It's been 3 years...
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #142 on: April 29, 2016, 04:39:27 PM »
How do I make star shaped danmaku (like Sanae)?
Normal 1CCs : PCB, IN, PoFV, MoF, UFO, TD, DDC, HSiFS, WBaWC.
Extra Clears: IN, MoF, HSiFS, WBaWC.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #143 on: April 29, 2016, 06:36:38 PM »
How do I make star shaped danmaku (like Sanae)?

Depends. You can create a shot and have it move and turn to make a star shape, spawning bullets at those locations, for example. Or you could spawn bullets using a parametric equation with appropriate offsets. Personally, I'd identify the five points you would like to use as the points, calculate the angle of each line, and spawn bullets along those lines to create the star.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #144 on: April 29, 2016, 07:57:42 PM »
Like Sparen said, the best method is probably to find the points you want to draw between and then make lines of bullets between them. It's the easiest way to draw shapes in general.

Here is a good method on how to do this (more details are in a post immediately below):
https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1226299.html#msg1226299

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

Random Sphere

  • It's been 3 years...
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #145 on: April 29, 2016, 08:40:01 PM »
I forgot about that. Thanks!
Normal 1CCs : PCB, IN, PoFV, MoF, UFO, TD, DDC, HSiFS, WBaWC.
Extra Clears: IN, MoF, HSiFS, WBaWC.

Nefer007

  • Nefer007, Shinto God of Insects, Doctorate in Referralology
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #146 on: April 30, 2016, 11:20:11 PM »
I'm having a problem.

I'm trying to make a plural stage, but now it's crashing Danmakufu whenever I run it.

Code: [Select]
#TouhouDanmakufu[Plural]
#ScriptVersion[3]
#Title["EX Rumia Plural Script"]
#Text["EX Rumia Spell Cards"]
#Image[".\img\ExRumia(?????u?~?b?h?i?C?g?????@???G?v).png"]
#Background["script/default_system/Default_Background_IceMountain.txt"]

@Initialize
{
TPlural();
}

@MainLoop
{
yield;
}

@Finalize
{
}


task TPlural
{
let dir = GetCurrentScriptDirectory();

//Creates the boss scene
let obj = ObjEnemyBossScene_Create();
ObjEnemyBossScene_Add(obj, 0, dir ~ "boss1attack1.txt");
ObjEnemyBossScene_Add(obj, 0, dir ~ "boss1attack2hard.txt");
ObjEnemyBossScene_LoadInThread(obj);
ObjEnemyBossScene_Regist(obj);

//Stands by until the boss scene is finished
while(!Obj_IsDeleted(obj))
{
yield;
}

//The end of the script
CloseScript(GetOwnScriptID());
}

The nonspells are boss1attack1 and boss1attack2hard. Why isn't it going to load?
Looking for Desunoya music! Help me obtain these ill-gotten goods!

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #147 on: May 01, 2016, 02:59:12 AM »
I'm having a problem.

I'm trying to make a plural stage, but now it's crashing Danmakufu whenever I run it.

The nonspells are boss1attack1 and boss1attack2hard. Why isn't it going to load?

What is #Image[".\img\ExRumia(?????u?~?b?h?i?C?g?????@???G?v).png"] supposed to be? Danmakufu can't parse the stuff you put there.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #148 on: May 01, 2016, 10:13:03 AM »
Hi!
Is there a way to manually open the pause script? Like a function when it called it open the pause menu without pressing any pause key?
I want to create a pseudo-continue system that occur before the actual danmakufu gameover by oppening a pause script but I don't know how to freeze the game during the pause menu and unfreeze it when the player leave the menu.



Random Sphere

  • It's been 3 years...
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #149 on: May 01, 2016, 05:32:56 PM »
I`m trying to make a circle :

Code: [Select]

let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
ObjPrim_SetPrimitiveType(obj,PRIMITIVE_TRIANGLESTRIP);
ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "MG1.png");
Obj_SetRenderPriority(obj, 0.69);

ObjPrim_SetVertexCount(obj,64);

ascent(a in 0..64){
ObjSpriteList2D_AddVertex(obj);
ObjSprite2D_SetSourceRect(obj, 1024/64*(a), 0, 1024/64*(a+1), 64);
ObjSprite2D_SetDestCenter(obj);
ObjPrim_SetVertexPosition(obj,a,bossX+64*cos(a*360/64),bossY+64*sin(a*360/64),0);
}

ObjSpriteList2D_CloseVertex(obj);

ObjRender_SetBlendType(obj,BLEND_ADD_RGB);

Aaand it doesn`t work. The circle does not appear. Why?
Normal 1CCs : PCB, IN, PoFV, MoF, UFO, TD, DDC, HSiFS, WBaWC.
Extra Clears: IN, MoF, HSiFS, WBaWC.