Maidens of the Kaleidoscope

~Hakurei Shrine~ => Rika and Nitori's Garage Experiments => Topic started by: WishMakers on April 19, 2020, 08:05:10 PM

Title: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: WishMakers on April 19, 2020, 08:05:10 PM
Welcome to the Danmakufu Q/A thread!  This is a continuation of the V2 thread, finally back in action.
Ask your questions here should you have a problem with Danmakufu, be it an error that you can't find, problem with the program, etc.

Previous thread
Danmakufu Wiki (http://dmf.shrinemaiden.com)
DNH Function Docs (http://sparen.github.io/ph3tutorials/docs.html)
Major Info Thread
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Nickster206 on April 26, 2020, 02:18:17 AM
I'm having trouble animating a "gravitational aura" around a boss. The only Danmakufu scripts I've come across that have made use of these can be found here (https://www.youtube.com/watch?v=2hVmjJrUzmM (https://www.youtube.com/watch?v=2hVmjJrUzmM)) and here (https://www.youtube.com/watch?v=bxf9Hvkx5oE (https://www.youtube.com/watch?v=bxf9Hvkx5oE)). In case I'm not clear, I mean the circle around the boss that causes the background to pulsate and warp. I've examined both of these scripts' code and am still unsure how it was accomplished. Can someone help?

EDIT: Nevermind, I got it to work!
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Nickster206 on May 03, 2020, 03:13:29 AM
I have a new question! I'm struggling with understanding packages. When I launch th_dnh.exe, I want it to immediately run the package declared in th_dnh.def like package.script.main = x/y/z.dnh. Despite having declared the package as such in the .def file, the package does not launch automatically, and I am instead brought to the regular Danmakufu menu. I checked to make sure the path was correct, and the package works if I select it from the menu. What am I missing?
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Icemoon on May 08, 2020, 08:16:37 PM
Greetings! I am relatively new to Danmakufu, working my way through Sparen's tutorials, trying out my own stuff or to tinker with his provided code for learning's sake - long story short, for some reason the task TFinalize he provides only goes off in one of my scripts. I always call it in @Initialize, I have moved it into a function library outside of the pastebins below to ensure all my scripts make use of the same TFinalize task and, quite frankly, I am stumped. :( It does work in all my scripts when moved into @MainLoop, but then awards way too many points on spell capture for obvious reasons.

I've tried to search the old forum as well as Google for my issue before posting here, but have not found aught that could help me - doesn't mean it's not there, merely that I failed to find it.

https://pastebin.com/MucNFquT (https://pastebin.com/MucNFquT) One of my scripts where TFinalize does not work.

https://pastebin.com/urXMyXZN (https://pastebin.com/urXMyXZN) My script where TFinalize does work.

Apologies if I missed out on anything else you might need!

EDIT: Please do notify me if I did. I... generally try to avoid getting help since most of the time, it's just me being stupid or my search engine fu being weak, so I'm far from used to making these posts...

EDIT 2: I am a fool thrice over and I have figured it out - I needed to yield; in @MainLoop... still leaving the post here in case anyone else stumbles over the same issue - my utmost apologies ;_;
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: WishMakers on May 09, 2020, 11:26:03 PM
Quote
Despite having declared the package as such in the .def file, the package does not launch automatically, and I am instead brought to the regular Danmakufu menu. I checked to make sure the path was correct, and the package works if I select it from the menu. What am I missing?

Here's a good example of a def file, just in case you're still stuck.
Code: [Select]
window.title = <redacted>
package.script.main = Script/package.dnh
screen.width=640
screen.height=480
I'm sure you have everything like that, but make sure the name of the .def file is th_dnh.def and in the same folder as the exe.  Other than that, I'm not sure personally, but I don't work with .def files very often.
Do you have any more info about the issue?  What does your setup look like?
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Nickster206 on May 10, 2020, 04:58:54 PM
Thank you so much for your reply! I tried messing around with the .def file after seeing your sample, and I figured out the problem!

I had declared package.script.main before window.title, and my window title had a "~" character in it. Even though the window would work with the ~ and launch to the regular danmakufu window, after removing it, it launched the package!

For further context, I am using your Woo version of Danmakufu, if that makes any difference in how the .exe interprets the .def. Either way, thank you for your help! It is greatly appreciated.  :D
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Hyouiibara on May 19, 2020, 09:51:53 AM
I'm new to danmakufu, and each time I tried to run the engine, it crashes and leaves a file called "Gcprojectcrash", I already used locale emulator and I downloaded the Ph3 version

I already posted it in Moriya shrine, but no one replied

Thank you for your reply!

Pichuun!  :power: :power: :power: :bigpower: :power: :power: :power:
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: WishMakers on May 21, 2020, 05:17:09 PM
Quote
I'm new to danmakufu, and each time I tried to run the engine, it crashes and leaves a file called "Gcprojectcrash", I already used locale emulator and I downloaded the Ph3 version

Can you explain your problem in more detail?  What script were you trying to run, if any?  When and where does it crash?
For the record, for PH3 Locale Emulator shouldn't be necessary so if you turn that off I think you'll be fine.
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Lapis Lazuli on May 22, 2020, 10:42:32 PM
Hello friends!
So I've been following Sparen's Danmakufu ph3 tutorials for a while, but I've gotten stuck at the process of creating a plural. Whenever I create a plural and try to run it in Danmakufu, the game refuses to give me an error warning and simply crashes on the spot, even though I've created the simplest plural imaginable. But, still, here's the text file for it:

Code: [Select]
#TouhouDanmakufu[Plural]
#ScriptVersion[3]
#Title["Vs. Momiji"]
#Text["For Kiiro"]

@Event
{

}
@Initialize
{
TPlural;
}
@MainLoop
{
yield;
}

task TPlural
{
    let dir = GetCurrentScriptDirectory();
    let obj = ObjEnemyBossScene_Create();
// ObjEnemyBossScene_Add(obj, 0, dir ~ "momiji 1.txt");
ObjEnemyBossScene_Add(obj, 0, dir ~ "momiji spell 1.txt");
ObjEnemyBossScene_LoadInThread(obj);
    ObjEnemyBossScene_Regist(obj);
    while(!Obj_IsDeleted(obj)){
        yield;
    }
    CloseScript(GetOwnScriptID());
}

Again, I get no error message, so I have no idea what could be going wrong. Can anyone give me a hand, please? Thank you so much.

EDIT: Figured it out! Turns out it has to do with how notepad++ saves .txt files.
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Nickster206 on May 24, 2020, 03:56:16 PM
I've got some trouble working with Package scripts now. When I run all my singles, plurals, and the stage through the normal menu everything works as intended. However, when I launch the game through the package script, something strange happens.

Whenever I hit "Retry from Beginning" in my pause script which returns RESULT_RETRY, it keeps the game paused, and a new instance of the game opens up in the same window while the previous instance remains paused. At this point, there will be a paused instance of the stage and a running instance of the stage, and only the running instance detects key inputs. If I repeatedly select retry, more instances of the stage will open in the same way.

If I hit "Return to Title" for RESULT_END, the currently running instance of the stage will close because of TerminateStageScene(), and the most recent previous instance of the game will render and begin accepting key inputs. This will continue until all instances of the stage are closed, at which point, the package will close.

The code for my package script is below.

EDIT: I found out what the problem was. I was restarting the stage from the pause menu, meaning I couldn't finalize the stage scene. I moved the recursive TStageScene call to a point after calling FinalizeStageScene and now it works.

Code: [Select]
#TouhouDanmakufu[Package]
#Title["Touhou ~ Forlorn Souls of Wicked Past"]
#Text["-NL"]
#System["./system/Default_System.dnh"]
#Player["./player/player_reimu.dnh"]

@Initialize{
  TStageScene(GetCurrentScriptDirectory ~ "x1/stage1.dnh", GetCurrentScriptDirectory ~ "player/player_reimu.dnh", "");
}

@MainLoop{
  yield;
}

@Finalize{}

// STAGE SCENE                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
task TStageScene(let stagePath, let playerPath, let replayPath){
  ClearCommonData;

  // Prepare the Stage Scene                    ------------------------------
  InitializeStageScene();

  // If a replay was called                     ------------------------------
  if(length(replayPath) > 0){
    SetStageReplayFile(replayPath);
  }

  let indexStage = 1;
SetStageIndex(indexStage);
SetStageMainScript(stagePath);
SetStagePlayerScript(playerPath);
StartStageScene();

  loop{
    // Hitting the pause key
if(GetVirtualKeyState(VK_PAUSE) == KEY_PUSH){
let resPause = RunPauseScene();
alternative(resPause)
case(RESULT_RETRY){
if(!IsReplay()){
TerminateStageScene();
TStageScene(stagePath, playerPath, replayPath);
          ClearCommonData;
}
}
case(RESULT_END){
TerminateStageScene();
        // ClosePackage();
}
}

let stgSceneState = GetStageSceneState();
if(stgSceneState == STAGE_STATE_FINISHED){

let stageResult = GetStageSceneResult();
alternative(stageResult)
case(STAGE_RESULT_CLEARED){
        TEndScene();
        break;
}
case(STAGE_RESULT_PLAYER_DOWN){
TEndScene();
break;
}
case(STAGE_RESULT_BREAK_OFF){
// TTitleScene();
        TEndScene();
        // ClosePackage();
break;
}
}

    yield;
  }
}

// PAUSE SCENE                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function RunPauseScene{
RenderSceneToTransitionTexture();
PauseStageScene(true);

let pathScript = GetCurrentScriptDirectory ~ "system/New_Pause.dnh";

let idScript = LoadScript(pathScript);
StartScript(idScript);

while(!IsCloseScript(idScript)){
yield;
}

PauseStageScene(false);

let res = GetScriptResult(idScript);
return res;
}

// END SCENE                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
task TEndScene{
if(IsReplay){
// TTitleScene();
return;
}

FinalizeStageScene();

  while(GetVirtualKeyState(VK_OK) != KEY_FREE){yield;}

let dirModule = GetModuleDirectory();
let pathScript = GetCurrentScriptDirectory ~ "system/New_EndScene.dnh";
let idScript = LoadScript(pathScript);
StartScript(idScript);

while(!IsCloseScript(idScript)){
yield;
}

let result = GetScriptResult(idScript);
alternative(result)
case(RESULT_SAVE_REPLAY){
TReplaySaveScene();
}
case(RESULT_END){
// TTitleScene();
    ClosePackage();
}
case(RESULT_RETRY){
TStageScene("","","");
}
}

// REPLAY SAVE SCENE                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
task TReplaySaveScene{
let dirModule = GetModuleDirectory();
let pathScript = GetCurrentScriptDirectory ~ "system/New_ReplaySaveScene.dnh";

let idScript = LoadScript(pathScript);
StartScript(idScript);

while(!IsCloseScript(idScript)){
yield;
}

// TTitleScene();
  ClosePackage();
}

function RenderSceneToTransitionTexture{
let textureName = GetTransitionRenderTargetName();
RenderToTextureA1(textureName, 0, 100, true);
}
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Hyouiibara on May 26, 2020, 10:00:21 AM
Can you explain your problem in more detail?  What script were you trying to run, if any?  When and where does it crash?
For the record, for PH3 Locale Emulator shouldn't be necessary so if you turn that off I think you'll be fine.
I tried to run the EXRumia script, I'm on Windows 10, and every time I tried to run the Danmakufu it just crashes and left an error BMP. File. Had a Segurazo virus once, note that
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: MakiBlank on June 23, 2020, 09:00:02 AM
Hello, been working on a coding a player for a while, I'm trying to figure out how to animate my character, which the tutorial I was using (Helepolis) didn't cover much, here's my code for rendering the player

https://pastebin.com/364tY5rd

For some reason, it doesn't seem to be animating, just staying on one static sprite based on the key presses. any ideas on why/ a better way to do it?

Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Tsukasa on July 02, 2020, 11:34:45 PM
Hello, been working on a coding a player for a while, I'm trying to figure out how to animate my character, which the tutorial I was using (Helepolis) didn't cover much, here's my code for rendering the player

https://pastebin.com/364tY5rd

For some reason, it doesn't seem to be animating, just staying on one static sprite based on the key presses. any ideas on why/ a better way to do it?

The way you have it now, every single frame, you're defining a new variable under those two names initialised to the value 0 -- you don't want that.

Instead, you want to define animFrame and animFrame2 outside of the while loop, not inside.
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: MakiBlank on July 04, 2020, 05:26:43 AM
The way you have it now, every single frame, you're defining a new variable under those two names initialised to the value 0 -- you don't want that.

Instead, you want to define animFrame and animFrame2 outside of the while loop, not inside.
Ah, it seems that was what I have overlooked, thanks!
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Lefkada on July 24, 2020, 05:42:34 PM
Hi!
It's being a long time since I came here for the last time (I mean, it was still the old MotK forum...).

I have just a question... where is the danmakufu wiki with all the functions now? Last time I checked it it was here: http://dmf.shrinemaiden.org/wiki/Main_Page
But it's dead now. Please tell me all this usefull stuff is not lost for ever. Tell me that the danmakufu comunity is not dead.
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Sparen on July 25, 2020, 02:04:53 PM
Hi!
It's being a long time since I came here for the last time (I mean, it was still the old MotK forum...).

I have just a question... where is the danmakufu wiki with all the functions now? Last time I checked it it was here: http://dmf.shrinemaiden.org/wiki/Main_Page
But it's dead now. Please tell me all this usefull stuff is not lost for ever. Tell me that the danmakufu comunity is not dead.

Wiki is down permanently as noted in one of the forum transfer threads. If it is resurrected, it will be in a different form.

If you need the function reference, the wiki is saved on the Wayback Machine (https://web.archive.org/web/*/http://dmf.shrinemaiden.org/wiki/Main_Page) and many parts have already been saved and backed up to websites (e.g. https://sparen.github.io/ph3tutorials/docs.html) and into various plugins for IDEs.
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Lefkada on July 25, 2020, 07:04:59 PM
Thanks for the answer. That's not a good news for the wiki but I'm glad some people and The WaybackMachine saved the functions list.
I'm gonna work on a .doc to save this in one more place. This list is too precious to be lost.
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: tkon on August 04, 2020, 12:51:47 PM
Hello

Is there a way or a work around to add optional parameters with a default value in functions or tasks ?

Thanks
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Sparen on August 06, 2020, 02:53:06 AM
Hello

Is there a way or a work around to add optional parameters with a default value in functions or tasks ?

Thanks

In default Danmakufu ph3, there is no way to do this, unfortunately. There is also no reliable way to check the type of an input or check if a value has been assigned, so you also can't perform null checks.

The only real case where defaults exist is for built-in systems like object values and CommonData.
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: tkon on August 06, 2020, 02:52:45 PM
Found this active branch which does allow overcharging functions and type checking https://github.com/Natashi/Touhou-Danmakufu-ph3sx-2
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: MadGreenReimu on August 15, 2020, 02:30:43 PM
Hi, im starting with danmakufu and i have trouble with lasers that they dont show in the battle.

Here is all the code: https://pastebin.com/Cmc6gw5b


Thanks
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Sparen on August 16, 2020, 01:52:06 AM
Hi, im starting with danmakufu and i have trouble with lasers that they dont show in the battle.

Here is all the code: https://pastebin.com/Cmc6gw5b


Thanks

Are the graphic IDs you used defined in your shot sheet?
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: MadGreenReimu on August 17, 2020, 04:21:07 PM
How important / Useless  is the "Bullet Controll" Thing?

And what are the dhn archives?
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Sparen on August 19, 2020, 01:19:05 PM
How important / Useless  is the "Bullet Controll" Thing?

And what are the dhn archives?

I'm not sure what you're referring to by Bullet Controll

As for DNH Archives, they are a way of compressing a bunch of files (e.g. images, sound) into a single file. It makes it harder for people to access the contents inside.
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: MadGreenReimu on August 21, 2020, 11:34:19 AM
I was wondering why Rumia just shoots at her spawn position
For the "shoots when she spawned" use a wait(60); before the loop

task Fire{
   let angleT = GetAngleToPlayer(objBoss);

        wait(60);
   loop(12){
      CreateShotA1(bossX, bossY, 2, angleT, DS_BALL_S_RED, 5);
      angleT += 360/12;      
   }
   
}
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Sparen on August 21, 2020, 01:19:58 PM
I'm just wondering if there's a way to make Rumia shoot for the entire length of the script

You're going to want to make your Fire task have a loop.

For starters, you can use the following to repeat some code over and over again.

while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
  // Firing bullets + some wait time goes here
}


Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: xChumbo on August 24, 2020, 04:14:59 AM
Hi, I'm following Sparen's tutorial, but i noticed that it has no information about packages and the way they are handled; so I don't really know where to start to create one.

The question is: Should I use the ExRumia package as a reference? Is there some magical tutorial or something else that I can use to learn more about packages?

Thank you for your attention :cirnotan:
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Tsukasa on August 24, 2020, 08:39:38 AM
packages

What don't you understand about the ExRumia package? The most basic package lesson would simply cover something like it, since it contains mostly everything you need to run a game anyway.
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: xChumbo on August 24, 2020, 08:04:42 PM
There are some tasks that I can't understand well, like TStageScene() or RunPauseScene() for example; When are this kind of tasks executed in the package? I recently started to create stage scripts with bosses, so I know that maybe I need more experience but I'm just looking for some advice to start with packages because I'd like to do something bigger. I'll accept anything.

Thanks for the answer
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Sparen on August 26, 2020, 01:55:12 PM
There are some tasks that I can't understand well, like TStageScene() or RunPauseScene() for example; When are this kind of tasks executed in the package? I recently started to create stage scripts with bosses, so I know that maybe I need more experience but I'm just looking for some advice to start with packages because I'd like to do something bigger. I'll accept anything.

Thanks for the answer

Take a look at the package for how they are defined and used. I don't recommend working with packages until you have a firm understanding of how tasks and scripts work in Danmakufu.
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: MadGreenReimu on August 28, 2020, 10:08:10 AM
I really dont understand how does sprite sheets work. I mean, i have 2 questions

1: Where can i find them?

i tried the "The sprite recourses" web (https://www.spriters-resource.com/pc_computer/touhoufuujinrokumountainoffaith/sheet/51906/) but in the image appears all the bosses, but i only need 1

2: The coordinates

Is there a way to know the sprite's coordinates to dont make it glitch in battle? (Same problem with shot sheets)

thanks
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Sparen on August 28, 2020, 01:19:51 PM
I really dont understand how does sprite sheets work. I mean, i have 2 questions

1: Where can i find them?

i tried the "The sprite recourses" web (https://www.spriters-resource.com/pc_computer/touhoufuujinrokumountainoffaith/sheet/51906/) but in the image appears all the bosses, but i only need 1

2: The coordinates

Is there a way to know the sprite's coordinates to dont make it glitch in battle? (Same problem with shot sheets)

thanks

1. You already have what you need. Any image editor can crop the image down to the boss you want

2. Most image editors will tell you the coordinates of a given pixel. In addition, in a sprite sheet, most sprites are the same size, so knowing the height and width of the area with the boss sprites is usually enough to determine the dimensions of a single sprite (e.g. width/#sprites)
Title: Stage enemies
Post by: xChumbo on August 31, 2020, 01:34:17 AM
Hello, I'm having troubles creating stage enemies; the thing is, I can create the stage enemies well, but is there a way to make the boss wait until the other enemies are defeated? I've tried some solutions by myself but still all the enemies appear with the boss and I can't make it work.


Another doubt I got is: In the StageEnemy creation, there's the following line: "SetDamageRateAtFrameEnm(objEnemy, 80, 50, 30);". This is a function/task that I'm not really sure what it does; the enemies still work but It would be nice if you can tell me its purpose.

Here's some code if you want to see:

Stage code: [attachment=1]
STGEnemy code: [attachment=2]

Thank you for your attention.

Title: Re: Stage enemies
Post by: Sparen on September 01, 2020, 01:24:24 PM
Hello, I'm having troubles creating stage enemies; the thing is, I can create the stage enemies well, but is there a way to make the boss wait until the other enemies are defeated? I've tried some solutions by myself but still all the enemies appear with the boss and I can't make it work.

Personally, I use this function from Ultima:

Code: [Select]
/* *************************************************************************
*void WaitForZeroEnemy() -- Waits for there to be no enemies on screen
************************************************************************* */
function WaitForZeroEnemy(){ //ULTIMA
    while(length(GetAllEnemyID()) > 0){yield;}
}
Title: Extend function using item points
Post by: Skelly on November 06, 2020, 02:11:35 PM
Hello, I'm not so new to danmakufu but have stopped messing with it for a while and wanted to warm up again.

Recently I've been working on a simple function in PH3. Basically a function that extends the player whenever it gets a certain amount of points(Like PCB). The major problem I'm having is with the GetPoint function. It basically doesn't work, not returning the actual points collected.

I have tried checking if my function was written wrong. But I have noticed it works using GetGraze instead. I have also noticed that whenever I try to print the number of points collected(Using text functions), it basically doesn't update the actual count(Notice I am calling the function every frame). So I really wonder if the GetPoint function actually works on PH3...

Here is the function I am refering to(I have called it on the stage script btw): https://pastebin.com/cUxjiM2x

(Apologies if the post is messy, it's my first time posting here.)
Title: Re: Extend function using item points
Post by: Sparen on November 08, 2020, 02:21:30 PM
Recently I've been working on a simple function in PH3. Basically a function that extends the player whenever it gets a certain amount of points(Like PCB). The major problem I'm having is with the GetPoint function. It basically doesn't work, not returning the actual points collected.

I have tried checking if my function was written wrong. But I have noticed it works using GetGraze instead. I have also noticed that whenever I try to print the number of points collected(Using text functions), it basically doesn't update the actual count(Notice I am calling the function every frame). So I really wonder if the GetPoint function actually works on PH3...

Here is the function I am refering to(I have called it on the stage script btw): https://pastebin.com/cUxjiM2x

Danmakufu doesn't actually automatically add points - you need to do so manually via AddPoint.

Personally, I would have a task running in the system script that's checking a CommonData value in order to handle extends, and I'd use a CommonData value to track your custom points.
Title: Re: Extend function using item points
Post by: Skelly on November 11, 2020, 08:58:43 PM
Danmakufu doesn't actually automatically add points - you need to do so manually via AddPoint.

Personally, I would have a task running in the system script that's checking a CommonData value in order to handle extends, and I'd use a CommonData value to track your custom points.

I see, gonna check your common data tutorials, thanks for the help!
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: MadGreenReimu on December 19, 2020, 05:29:02 PM
Hi, i need help with some bullets. I want to make a hammer fall when the other one is deleted, however, i tried it and this is how it ended: https://gyazo.com/8fcff2a6ef204c393af1559907373f65

Here is the whole code for if i did something wrong with the speed or delay: https://pastebin.com/EEULKn2r

Thanks for the help
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: latiasred on February 05, 2021, 07:29:07 PM
Hi, i need help with some bullets. I want to make a hammer fall when the other one is deleted, however, i tried it and this is how it ended: https://gyazo.com/8fcff2a6ef204c393af1559907373f65

Here is the whole code for if i did something wrong with the speed or delay: https://pastebin.com/EEULKn2r

Thanks for the help

It's a bit embarrassing replying to such an old topic. Do you still need help?  :cirnotan:

Note that I can't see your gyazo video as the link is invalid. Well, first off, your "move", "fire", and "fire2" tasks don't seem to be used anywhere. I would recommend not keeping unused tasks like these around your code.

Second,
Code: [Select]
ascent(i in 30 .. 3300)
{
if(Obj_IsDeleted(GoldHam)){break;}
let shotSpeed = rand(0.5,1.5);
let sx = ObjMove_GetX(GoldHam);
let sy = ObjMove_GetY(GoldHam);
CreateShotA1(sx, sy - 10, rand(0.5,1.5), rand(0,360), 226, 30);
yield;
}

You don't need an ascent loop for this. You could handle this code with a normal loop. Only use an ascent or descent loop when you need to use the iteration variable that comes with it. (in this case, that would be "i")

Now, I'm a bit confused, but are you trying to fire bullets when GoldHam is deleted? If so, then you will never be able to do this because of the following line:
Code: [Select]
if(Obj_IsDeleted(GoldHam)){break;}
This line of code terminates the loop if GoldHam has been deleted. With this line of code, you'll never be able to spawn bullets because GoldHam is deleted, the loop terminates and shots from firing.

Instead, I would handle this with a "while" loop that runs as long as the GoldHam object has *not* been deleted. In this loop, I will save GoldHam's position to a variable and then "yield;". (if you dont put a yield in an infinite loop, DNH will freeze up as it tries to do infinite things all at once.) The yield also makes DNH stay parsing the loop until the condition becomes false (in this case, until GoldHam is deleted). Meanwhile, there's a reason GoldHam's position has to be saved and updated within this loop. By the time you fire shots, GoldHam has already been deleted. If you try to spawn another object at the X and Y position of an object that does not exist, it will instead spawn at the top left corner of the playing field. Because of this, you will have to save the hammer's last position in the "while" loop. I would do it like so:
Code: [Select]
let sx = 0;
let sy = 0;
while(!Obj_IsDeleted(GoldHam)){
         sx = ObjMove_GetX(GoldHam);
sy = ObjMove_GetY(GoldHam);
         yield;
}
CreateShotA1(sx, sy - 10, rand(0.5,1.5), rand(0,360), 226, 30);

Hopefully this is a clear example, but when GoldHam gets deleted, DNH will stop processing the while loop and will continue to what's directly below. At this point, it will spawn your new shot at the X and Y position GoldHam was at just before it got deleted.

Again, I hope I described this in a way that makes sense. If you still need help, I suggest you join the Bullet Hell Engines Discord server. (https://discord.gg/4wNvvPHxeU)

 
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Katach314 on April 21, 2021, 08:57:54 PM
I have a question pertaining to (what appears to be) a (relatively) popular script, ExPorygon's ZUN Expanded Shotsheet (https://www.bulletforge.org/u/ozzy/p/zun-expanded-shotsheet-for-ph3 (https://www.bulletforge.org/u/ozzy/p/zun-expanded-shotsheet-for-ph3)).

After installing this script, I attempted to use it by #include-ing a specific one of its .txt files (as the readme told me to). However, once I tried to play the script and selected my character, Danmakufu froze for a few seconds and then closed itself.

According to this site (https://sites.google.com/site/sparensdanmakufututorials/dnh-0-12m-tutorials-part-3/014-intro-to-danmakufu-part-4#TOC-ERR-A01:-Danmakufu-crashes (https://sites.google.com/site/sparensdanmakufututorials/dnh-0-12m-tutorials-part-3/014-intro-to-danmakufu-part-4#TOC-ERR-A01:-Danmakufu-crashes)), the problem seems to have to do with system locale. However, my locale has been set to Japanese for some time now, so I have no idea what could be causing the problem.

Does anyone know what is causing this problem? (I would prefer not to switch to a different bullet script, as this one seems to be of the highest quality, and... I've already spent an hour or so making a reference sheet for the bullets used by this script.)

EDIT: I tried reverting my script back to when it used the default shots, but it still crashes Danmakufu just before the spell begins for no apparent reason. The part that makes it crash is as follows:

Code: [Select]
task MainTask{
    wait(120);
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){
        let angleT = GetAngleToPlayer(objBoss);
        loop(13) {
CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2,
angleT, DS_BALL_S_RED, 5);
angleT += 360/13;
}
    }
}

EDIT 2: I found what was causing the crash... I forgot to add a yield in that task. My apologies.
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: PivotLever on May 07, 2021, 04:07:47 AM
Hi there! Just started coding in Danmakufu (basically a beginner), got a small Single script going, but I ran into a slight issue. While it may seem simple, I wasn't sure where to ask, so I'll ask here. How would I make a bullet that has gravity (as in, would fall down after a delay when initially shot upwards)? If it's a specific shot function, please direct me to the correct one, or if it requires extra steps, please provide some tips! Given I'm just starting out, I'm not familiar with all of the shot functions yet, so that's why I'm asking. Any help would be greatly appreciated!
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Katach314 on May 12, 2021, 09:38:41 PM
Try using this (https://sparen.github.io/ph3tutorials/docs_standard.html#fxn_CreateShotA2 (https://sparen.github.io/ph3tutorials/docs_standard.html#fxn_CreateShotA2)) function. Have the bullet's Y speed accelerate to create the illusion of falling. Have the X speed decelerate instead so it dips down the longer it's there.

I'm a newbie too! I guess the regulars don't check this thread too often.

EDIT: Wait, I had some questions, too!
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: PivotLever on May 28, 2021, 09:09:37 PM
Try using this (https://sparen.github.io/ph3tutorials/docs_standard.html#fxn_CreateShotA2 (https://sparen.github.io/ph3tutorials/docs_standard.html#fxn_CreateShotA2)) function. Have the bullet's Y speed accelerate to create the illusion of falling. Have the X speed decelerate instead so it dips down the longer it's there.

I'm a newbie too! I guess the regulars don't check this thread too often.

EDIT: Wait, I had some questions, too!
  • How does one modify what sprites are used by default system stuff (like the border or the numbers used for the score)? I think the default dnh sprites for the items are grody and wish to replace them with different ones.
  • Are there any scripts that replace the default lifebar system with the ring lifebar system?
  • Same as above, but for a symbol- rather than number-based lives/bullets system? BulletForge doesn't seem to have anything relevant related to either.

I never noticed this until now, for some reason  when I set my email notifications, this was set as spam? Thanks, email.

1. To modify the shotsheet, you would need to #include a different one, though you seem to have figured that out in your following message.
2. Not that I know of, you would have to do the coding for that yourself.
3. If you mean life/bomb fragments, that might be included in a HUD of some kind, though I don't know for sure, sorry.

I recommend joining this Discord server if you haven't already, you'll get answers to your questions a lot faster. https://discord.gg/4wNvvPHxeU
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Dire29 on June 16, 2021, 08:50:52 PM
Not really a question per se, I'm just curious about how menus are generally implemented? How are the animations done and how are things customized?
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: WishMakers on July 23, 2021, 06:24:51 PM
Not really a question per se, I'm just curious about how menus are generally implemented? How are the animations done and how are things customized?

Basically just a matter of generating render objects and moving them around manually with tasks and stuff.  Sadly in that regard you typically have to do the heavy lifting yourself, but outside of things like smoothing out paths and stuff with interpolation (which ph3sx now has functions for, handily) it's not too bad.  Menu flow is the thing I've found to be trickier and being able to maintain things like state so you can go back to a previous menu without things breaking.
Title: Replay save scene error on Danmakufu Ph3
Post by: TouhouLinuxFan on September 27, 2021, 05:42:14 PM
This is a silly error, but I don't know how to fix it. While reading Sparen's Danmakufu tutorials, I came across the replay save scene tutorial. The tutorial said to copy everything from the default replay save scene script to a custom replay save scene script, I did it so. Now, Everytime I go to the replay save scene, danmakufu throws me a weird brackets error, like this one at the picture.

https://imgur.com/MW4g0ln.png



If anyone needs the script, I'll be attaching it here at this topic(even though i'ts identical to the default replay save scene :meiling:)
(Also, don't mind these "squared" texts, it's a WINE error :cirnotan:)

Title: Re: Replay save scene error on Danmakufu Ph3
Post by: PassingStrike on October 03, 2021, 10:00:22 PM
Did you try to do exactly what the error says?

Although those "]" ";" or similar missing errors normally are not a thing and the real problem is another thing.
Title: Smooth "ObjRender_SetPosition()"
Post by: TouhouLinuxFan on October 11, 2021, 02:47:43 AM
Hello once again! I just wanted to ask if someone knows how to smooth out ObjRender_SetPosition(), like with ObjMove_SetDestWithFrame(), etc. Or anything equivalent to "ObjMove_SetDest" that works with ObjRender. Like with this:

(focus on reimu's orb movement)
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: xChumbo on October 18, 2021, 09:47:47 PM
Hello guys! I've been thinking a lot about danmakufu scripts, and my question is: Is it posible to render danmakufu scripts/stages/packages outside ph3?

I mean, I've recently seen applications like this one (https://play.google.com/store/apps/details?id=com.knead.TouhouTNA02&hl=es_AR&gl=US (https://play.google.com/store/apps/details?id=com.knead.TouhouTNA02&hl=es_AR&gl=US)), but I don't really know if it's using ph3 or something else to run.

Thank you for your attention.
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: deice on October 18, 2021, 10:15:52 PM
Hello guys! I've been thinking a lot about danmakufu scripts, and my question is: Is it posible to render danmakufu scripts/stages/packages outside ph3?

I mean, I've recently seen applications like this one (https://play.google.com/store/apps/details?id=com.knead.TouhouTNA02&hl=es_AR&gl=US (https://play.google.com/store/apps/details?id=com.knead.TouhouTNA02&hl=es_AR&gl=US)), but I don't really know if it's using ph3 or something else to run.

Thank you for your attention.

while i can't say this with 100% certainty (i don't have the source code) i'm fairly certain thousand night anamnesis is built on it's own engine. this is going by the assumption that building your own DNH interpreter that (presumably) perfectly mimics the original is not only far more difficult, but also far less practical than just writing your own game from scratch
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Gabe24 on October 23, 2021, 05:49:44 AM
Can render priority affect hitboxes? I don't think it should but well...

So, I was messing around with bullets that changed sizes, before realizing that my shrinking bullets completely hid the growing bullets until they were close to the player and led to some cheap deaths.

I used the Obj_SetRenderPriority function to give the growing bullets a priority of 1 and they started behaving... oddly. I'm not 100% sure what was going on, but I was definitely getting killed by invisible hitboxes. I set the priority to 0.6 instead and the problem went away. Any idea what could have possibly caused this?

Additionally, is there a list somewhere of the default render priority of each object?

Thanks!
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: Tsukasa on October 23, 2021, 06:39:55 AM
Can render priority affect hitboxes?

Bullets will start rendering with (0,0) being the top left of the window rather than the top left of the playing field.

Maybe that will explain why hitboxes become "wonky" -- they aren't where the bullets seem to be.
Title: Re: Smooth "ObjRender_SetPosition()"
Post by: WishMakers on October 26, 2021, 12:28:33 AM
You can interpolate it.  A good start would be to do this over multiple frames, like this:
Code: [Select]
task OrbMove(obj,orbx,orby,destx,desty) {
    let sx = orbx;
    let sy = orby;
    let frames = 10; //the amount of frames to move over
    let incr_x = (destx - orbx) / frames;
    let incr_y = (desty - orby) / frames;
    loop(frames) {
        sx += incr_x;
        sy += incr_y;
        ObjRender_SetPosition(obj,sx,sy);
        yield;
    }
}
You can do this in a more refined way, but this is a good starting point.
(Also I noticed you're using 0.12m... you should probably be using ph3.  It's far newer lol)

Also, I realize I'm often not as attentive in here as I should be sometimes, but please keep your questions in the help thread as opposed to making new threads for every question :sweatangry:
For the sake of cleanliness, I'll merge these with the main help thread.
Title: Re: Danmakufu Q&A Thread 4 - V3 Edition.
Post by: WishMakers on October 26, 2021, 12:36:56 AM
Hello guys! I've been thinking a lot about danmakufu scripts, and my question is: Is it posible to render danmakufu scripts/stages/packages outside ph3?

I mean, I've recently seen applications like this one (https://play.google.com/store/apps/details?id=com.knead.TouhouTNA02&hl=es_AR&gl=US (https://play.google.com/store/apps/details?id=com.knead.TouhouTNA02&hl=es_AR&gl=US)), but I don't really know if it's using ph3 or something else to run.

Thank you for your attention.

A bit delayed but...a couple things.
Firstly, ph3 and its variants only work on PCs for now.  They are designed for Windows and can be used on Mac and Linux using a tool like Wine.
Apps like these are made from scratch and either use their own engines, or use something pre-made like GameMaker:Studio, Unity, Godot, etc.
There are frameworks/sample projects for those if you're interested in making shmup stuff, if you're interested in mobile development.  I'll admit it's not been very explored since the shift in guidelines (which is due for a topic update on the FAQs, come to think of it...)