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

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #900 on: December 21, 2017, 11:24:59 AM »
Here's my repost of a repost on shooting regular polygons, read all the links for more info

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

And the obligatory code tweaking

Code: [Select]
function CreateShotShapeA1(x, y, shape_sides, shape_gap, shape_radius, shape_angle, speed, angle, graphic, delay){
let shots = [];
let t = 0;
while(t < 360){
let r = cos(180/shape_sides) / cos(((t - shape_angle) % (360/shape_sides)) - (180/shape_sides));
if(shape_radius == 0 && angle == 0){
// expand shape from center
shots = shots ~ [CreateShotA1(x, y, r * speed, t, graphic, delay)];
}else{
// fire shape in direction
shots = shots ~ [CreateShotA1(x + shape_radius*r*cos(t), y + shape_radius*r*sin(t), speed, angle, graphic, delay)];
}
t += shape_gap;
}
return shots;
}

Try

Code: [Select]
// expand
CreateShotShapeA1(192, 150, 5, 4, 0, 90, 2, 0, SHOT_RING_RED, 10);
// shoot
CreateShotShapeA1(192, 150, 4, 4, 80, 115, 2, 70, SHOT_RING_RED, 10);
« Last Edit: December 21, 2017, 11:27:11 AM by Drake »

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

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #901 on: December 22, 2017, 12:24:59 AM »
Both of them work perfectly, and I'll both of them(in case I want to mix the codes)
Code: [Select]
function BulletCircle(X, Y, angle, radius, speed, numBullets, graph, del) {
    let increment = 360/numBullets;
    ascent(i in 0..numBullets){
if(Obj_IsDeleted(objBoss)){return;} //Prevents bullets from spawning after the script finishes
        let obj = CreateShotA1(X+radius*cos(i*increment),Y+radius*sin(i*increment),speed,angle,graph,del);
    }
}
I actually changed a bit of Arc's code so I can mess with the speed, delay and graphic.

Thanks for the support :D
"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 #902 on: December 24, 2017, 01:51:43 AM »
I have another request, I want to LEARN (NOT JUST PASTE THE CODE) how to make Non-Directional Lasers like Alice in SWR/Soku
Crimson Sign "Holland Doll"


I know that Sparenoflria alrady did a tutorial of how to make Non-Directional Lasers, but it almays ended doing 4-way lasers
Plz help
« Last Edit: December 25, 2017, 10:59:23 AM by jao »
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #903 on: December 24, 2017, 06:37:49 AM »
I have another request, I want to LEARN (NOT JUST PASTE THE CODE) how to make Non-Directional Lasers like Alice in SWR/Soku
Crimson Sign "Holland Doll"


I know that Sparenoflria alrady did a tutorial of how to make Non-Directional Lasers, but it almays ended doing 4-way lasers
Plz help

I'm not too familiar with Soku as it's been a while since I've last played it, but have you tried pointing all of the lasers in the same direction? If you already have non-directional lasers Marisa/Patchouli-style, all you need to do is change one variable to the same value for each iteration of the code (i.e each laser).

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #904 on: December 24, 2017, 09:30:05 AM »
Is this the tutorial you mean?
http://sparen.github.io/ph3tutorials/ph3u1l9.html#sub7

This goes further than what you say, with 12 lasers and spawning in a circle around the boss position. This should be plenty to get you started.

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 #905 on: December 25, 2017, 11:04:12 AM »
It's ok, when I saw my idea it was actually pretty basic... And I kinda gave up on it  It's not anyone's fault OK

How do I use multiple BGM in a Plural Script like AJS did on the Satori script (Recollection of  a Scripter's Past) ? :V
Plz help
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #906 on: December 25, 2017, 05:35:47 PM »
Basically, you define multiple sound objects in the plural script itself and then run a task in that script that detects which phase the boss fight is on and changes which sound object is playing accordingly. You probably want to fade out the old music instead of just having it end abruptly.

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #907 on: December 26, 2017, 12:06:11 AM »
Basically, you define multiple sound objects in the plural script itself and then run a task in that script that detects which phase the boss fight is on and changes which sound object is playing accordingly. You probably want to fade out the old music instead of just having it end abruptly.

Could you explain it with codes, beacuse it's confusing for me to understand.
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #908 on: December 26, 2017, 06:10:30 AM »
Could you explain it with codes, beacuse it's confusing for me to understand.

Think of Danmakufu as a low-level, dumb language where you'd have to spell it out on how to adjust even the simplest things, like sound.
You are given a set of tools to manupulate sound, outline here: https://dmf.shrinemaiden.org/wiki/Sound_Object_Functions

If you want to, say, make the sound fade, you'd have to lower the volume over some period of time. You can do it like this:
Code: [Select]
let cur_music = "";  // globally (or high-level) scoped
objSound_Music = ObjSound_Create();
ObjSound_SetSoundDivision( objSound_Music, SOUND_BGM );

// Play the music, fading the previous in fade_time seconds
task PlayMusic( let path_to_music, let fade_time )
{
if( cur_music != path_to_music ) // applies only when changing music
{
let cur_volume = ObjSound_GetVolumeRate( objSound_Music );
let fade = -cur_volume / fade_time;
ObjSound_SetFade( objSound_Music, fade );
while( ObjSound_GetVolumeRate( objSound_Music ) > 0 ){ yield; } // wait until fade is done before proceeding
cur_music = path_to_music;
ObjSound_Load( objSound_Music, path_to_music );
ObjSound_SetVolumeRate( objSound_Music, 100 );
ObjSound_Play( objSound_Music );
}
}

This is just a high-level briefing. The code above may not actually work, but it should help get into the mindset of how things should get done.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #909 on: December 30, 2017, 01:05:06 AM »
Talking about sounds, is there a way to restart a sound object that's normally supposed to continue after ObjSound_Stop? For example, boss music when you restart a fight should restart as well, while after pausing/unpausing it should just continue playing normally.
Problem is, when you use ObjSound_SetRestartEnable(obj, true) after ObjSound_SetRestartEnable(obj, false), playback starts from the previous stop point and not from the beginning. (adding Plays and Stops between those didn't seem to help either)

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #910 on: December 30, 2017, 02:43:49 AM »
You can set a BGM sound object restarting to true by default and play it normally, and then when you need to start from the beginning you can set restarting to false, Play, and set it back to true again. You could make it a function like

Code: [Select]
function ObjSound_PlayForceRestart(obj){
  ObjSound_SetRestartEnable(obj, false);
  ObjSound_Play(obj);
  ObjSound_SetRestartEnable(obj, true);
}

Unfortunately you can't get what the setting was to begin with so you would have to assume it was initially set to true.

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 #911 on: January 01, 2018, 04:14:08 AM »
Two simple questions that doesn't need any code:
(1) How do I pack my script, in .dat?
(2) How do I undo that?
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #912 on: January 01, 2018, 06:01:44 PM »
Danmakufu comes with a built-in tool for doing that. Sparen has a tutorial for it here.

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #913 on: January 02, 2018, 12:00:33 PM »
Please be patient
http://www.bulletforge.org/u/darkwalker247/p/stellar-effects-library - Stellar FX
http://www.bulletforge.org/u/darkwalker247/p/bloom-effects-library-now-events-based - BFX
----------------------------------------------------------------------------------------------------------------------------------------------------
Both of them are/have functions to make your script more serious (I would say), putting effects and Magic Circles around the boss...

I only have three questions:
(1) Which one is the easiest?
(2) Is there any tutorial about this on any site?
(3) If there isn't or it's not updated anyone could someone explain how to do this?
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #914 on: January 02, 2018, 02:28:47 PM »
You can set a BGM sound object restarting to true by default and play it normally, and then when you need to start from the beginning you can set restarting to false, Play, and set it back to true again. You could make it a function like

Code: [Select]
function ObjSound_PlayForceRestart(obj){
  ObjSound_SetRestartEnable(obj, false);
  ObjSound_Play(obj);
  ObjSound_SetRestartEnable(obj, true);
}

Unfortunately you can't get what the setting was to begin with so you would have to assume it was initially set to true.
This has worked indeed. And that's what I've been doing, but my problem was that I tried to use something similar while stopping music (so that I could simply use ObjSound_Play the next time).

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #915 on: January 02, 2018, 02:42:05 PM »
Please be patient
http://www.bulletforge.org/u/darkwalker247/p/stellar-effects-library - Stellar FX
http://www.bulletforge.org/u/darkwalker247/p/bloom-effects-library-now-events-based - BFX
----------------------------------------------------------------------------------------------------------------------------------------------------
Both of them are/have functions to make your script more serious (I would say), putting effects and Magic Circles around the boss...

I only have three questions:
(1) Which one is the easiest?
(2) Is there any tutorial about this on any site?
(3) If there isn't or it's not updated anyone could someone explain how to do this?

They are function libraries - include what you need to and use what you want to. There are no tutorials since the instructions on Bulletforge explain what you need to do to use the library - #include what you need to, call the functions you want to call.

For example, if I wanted to use the former, I'd #include Stellar.dnh at the top of my Single script, and in @Initialize I would call Stellar_Init(). Afterwards, I would call whatever function I wanted to.

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #916 on: January 02, 2018, 11:32:16 PM »
They are function libraries - include what you need to and use what you want to. There are no tutorials since the instructions on Bulletforge explain what you need to do to use the library - #include what you need to, call the functions you want to call.

For example, if I wanted to use the former, I'd #include Stellar.dnh at the top of my Single script, and in @Initialize I would call Stellar_Init(). Afterwards, I would call whatever function I wanted to.
My question was how to use it the library, beacuse I couldn't know what was I doing(what value should I use, what this variable do, the range I should put, etc.)
Help plz
Code: [Select]
Stellar_Init() --Call this once before all other functions.

Stellar_ParticleTexture(path) --Set the texture to use for particles; this can be changed at any point without affecting particles already out so it's okay to change texture a lot.
Stellar_AuraTexture(path) --Set the texture to use for the "aura" effect; this can be changed at any point as well.
Stellar_MagicCircleTexture(path) --Set the texture to use for magic circles; this can be changed at any point as well.

Stellar_AuraPriority(priority) --Set the render priority for the "aura" effect; an integer between 0 and 100.
Stellar_MagicCirclePriority(priority) --Set the render priority for the magic circle effect; an integer between 0 and 100.

Stellar_Explosion(object,time,particlescale,blending,hue) --Create a 3D explosion effect with particles.
Stellar_Charge(object,time,particlescale,blending,hue) --Create a 3D charge effect with particles.
Stellar_Aura(object,radius,wavelength,rotspeed,fadetime,blending,hue,saturation) --Create an "aura" effect that is a warping rotating textured circle around the object.
Stellar_Emitter(object,time,scale,speed,firepitch,fireyaw,spread,life,numperframe,blending,hue,saturation,alpha) --Create a 3D particle emitter on an object.
Stellar_MagicCircle(object,scale,fadetime,pulseamount,pulsespeed,angvel,blending,hue,saturation,alpha) --Create a magic circle on an object.
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #917 on: January 03, 2018, 05:00:23 AM »
If you really can't understand what you should be doing even when you're given a library to use, you should probably not bother with fancy effects for the time being. You would really just be better off working on things that you can actually learn with.

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 #918 on: January 03, 2018, 10:37:50 AM »
How do I upload my scripts?

I can't register to the BulletForge, so I want to know if that problem is my fault, or if is the site's fault.
(And how to solve this)

If it's my fault = What's the problem? My country? My net? My browser?
If it's the site's fault  = What should I do then? Contact the author?Poste it in another site?
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #919 on: January 03, 2018, 01:20:27 PM »
How do I upload my scripts?

I can't register to the BulletForge, so I want to know if that problem is my fault, or if is the site's fault.
(And how to solve this)

If it's my fault = What's the problem? My country? My net? My browser?
If it's the site's fault  = What should I do then? Contact the author?Poste it in another site?

From what I've heard Bulletforge has closed signups so you'd need to contact the owner to get an account.
In the meantime just upload to any file sharing site (preferably one that isn't a scam) and share the link.
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 #920 on: January 03, 2018, 09:13:07 PM »
From what I've heard Bulletforge has closed signups so you'd need to contact the owner to get an account.
In the meantime just upload to any file sharing site (preferably one that isn't a scam) and share the link.

Good examples: Mediafire, Mega.co.nz (AKA MEGA)
Other examples: DropBox, GitHub (for advanced users), etc.

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #921 on: January 06, 2018, 09:25:29 AM »
Two questions:

How can I make the bullets transforms to score(that gray squares that add to your score)?

What are the AnimationData arguments? (I couldn't find it on dmf wiki)
« Last Edit: January 06, 2018, 10:24:42 AM by jao »
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #922 on: January 06, 2018, 02:10:44 PM »
So, I want to reveal parts of background only in certain places and shapes, kinda like Doremy's occult attack in AoCF (http://tinypic.com/r/33m9b2d/9), how do I do it? I tried using render targets, but it's too complicated and difficult to use without a tutorial.

Btw, how do I attach images to my posts?
« Last Edit: January 06, 2018, 02:13:30 PM by IIe4eNiIIIe »

R. P. Genocraft

  • Craftsman of absolute unpredictability
  • Boundary of productive and lazy
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #923 on: January 06, 2018, 02:35:51 PM »
How can I make the bullets transforms to score(that gray squares that add to your score)?
use DeleteShotAll( ,TYPE_ITEM)

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #924 on: January 07, 2018, 08:24:36 AM »
So, I want to reveal parts of background only in certain places and shapes, kinda like Doremy's occult attack in AoCF (http://tinypic.com/r/33m9b2d/9), how do I do it? I tried using render targets, but it's too complicated and difficult to use without a tutorial.

Btw, how do I attach images to my posts?

While it's actually pretty easy (or not, depending on how much setup you're comfortable with doing from scratch) to grab simple shapes from a texture and draw them in Danmakufu, the same may not hold true if you want to take the transparency of the edges of the shapes into account, in order to preserve a more natural-looking portal effect as is done in the example from Antinomy of Common Flowers that you had provided.

You're better off creating an alpha mask and using HLSL to display part of an image with the transparency dictated by the alpha mask. If you want to display an animated image, you may also try passing the name of a render target to the shader, since a render target may be updated without having to reset the texture taken by the objects that use said render target each frame.

There is an example in the script/sample folder that demonstrates just that. I think it's shader example #2, but my memory could be failing me. Please consult them -- the simple act of (methodical) experimentation and learning through trial and error will prove to be very useful.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #925 on: January 07, 2018, 09:50:32 AM »
While it's actually pretty easy (or not, depending on how much setup you're comfortable with doing from scratch) to grab simple shapes from a texture and draw them in Danmakufu, the same may not hold true if you want to take the transparency of the edges of the shapes into account, in order to preserve a more natural-looking portal effect as is done in the example from Antinomy of Common Flowers that you had provided.

You're better off creating an alpha mask and using HLSL to display part of an image with the transparency dictated by the alpha mask. If you want to display an animated image, you may also try passing the name of a render target to the shader, since a render target may be updated without having to reset the texture taken by the objects that use said render target each frame.

There is an example in the script/sample folder that demonstrates just that. I think it's shader example #2, but my memory could be failing me. Please consult them -- the simple act of (methodical) experimentation and learning through trial and error will prove to be very useful.

I followed your advise and used 2nd sample, but now I have even more problems. Using different images as masks and applying them to different render priorities is ok, but I don't know how to manipulate the masks (change their scale, etc.), and I don't know neither how shaders work in danmakufu nor HSLS programing, and that makes it really hard for me. Is there any tutorials on danmakufu shaders and maybe HLSL that doesn't require deep C++ knowledge?

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #926 on: January 07, 2018, 10:03:06 AM »
Is there a function for making the screen shake like Master Spark?
...
If there isn't, how could I do it?
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #927 on: January 07, 2018, 11:28:52 AM »
How can I make the bullets transforms to score(that gray squares that add to your score)?
use DeleteShotAll( ,TYPE_ITEM)
Or DeleteShotInCircle.

Additionally you can use the ObjShot_ToItem function which is more useful for fine control if you have the object IDs, and also ObjShot_SetItemChange to set whether bullets are deleted to items or not.

What are the AnimationData arguments? (I couldn't find it on dmf wiki)
(num_frames, left, top, right, bottom)

Is there a function for making the screen shake like Master Spark?
You can use Set2DCameraFocusX and Set2DCameraFocusY to shift the 2D camera around. Then you would write something that uses those to move the camera rapidly.

I followed your advise and used 2nd sample, but now I have even more problems. Using different images as masks and applying them to different render priorities is ok, but I don't know how to manipulate the masks (change their scale, etc.), and I don't know neither how shaders work in danmakufu nor HSLS programing, and that makes it really hard for me. Is there any tutorials on danmakufu shaders and maybe HLSL that doesn't require deep C++ knowledge?
Shader objects are Render objects and so you can use things like ObjRender_SetScaleXYZ as you would anything else.
« Last Edit: January 07, 2018, 11:36:11 AM by Drake »

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #928 on: January 07, 2018, 12:02:38 PM »
Shader objects are Render objects and so you can use things like ObjRender_SetScaleXYZ as you would anything else.

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?

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #929 on: January 09, 2018, 11:44:57 PM »
I'm playing around with making gaps that warp bullets from one to another, and I've got them working for the most part, though they still need improvement. However, now I'm encountering a strange issue where Danmakufu freezes after warping shots through the gaps - but not until the single ends.

My guess would be that it has something to do with cleaning up the gaps at the end, but it still happens when then there aren't any gaps left at the end, and it doesn't happen if no shots have been warped through gaps.

Gap functions: https://pastebin.com/YuBEVpnQ
Test single: https://pastebin.com/x3ZiGAgQ
Finalize task: https://pastebin.com/M1jBXNzf

Any ideas?

Edit: It didn't happen when I stopped creating gaps well before the end of the script, so I'm guessing it's to do with them being deleted at the end after all. It's not just something being null unexpectedly, though, since that would throw an exception rather than "th_dnh.exe has stopped working".
Edit2: It only happens when the spell times out, not when the boss is shot down.

Edit3: It still froze when I replaced the "in" gap with an "out" gap, which do nothing on their own, thus preventing any bullets from being warped. (It didn't freeze earlier when I stopped the shots being fired at all, leading me to think it only happened when shots had been warped.)

So now I think it's something to do with the task I was using to fire a "wedge" of shots (like Seiran). I wrote it the other day but hadn't yet actually used it in anything aside from testing (used it here because it's an easy way to check how deformed the pattern gets), so I'm not too surprised I hadn't noticed it yet.

Wedge shot task: https://pastebin.com/yGUZDFrc

Edit4: Found the problem. Turns out it was completely unrelated to the gaps. To make it easier to get a reference to all the shots in a wedge, the wedge task adds each new shot to an array stored in the dictionary of an invisible dummy bullet, which the function returns. The dummy bullet was deleted when the single ended, but the task had just enough time before the script closed to try to add one more row. Since the dummy bullet had been deleted, the script crashed when it tried to use it.

Still not sure why that caused Danmakufu to freeze instead of just throwing an exception, though. Something to do with the script being in the process of ending, maybe?
« Last Edit: January 10, 2018, 12:33:00 AM by gameboy17 »
Literally everything in this script will crash and burn.
1CC tracker