Author Topic: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (locked)  (Read 268523 times)

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #450 on: October 13, 2012, 03:21:15 PM »
Here. It's just a crude template, but it should give you the general direction.
http://pastebin.com/8nfVgLeG
You use tasks for parallel processes, such as MotionTask() and ShootBulletPattern(patternid);

Mind the yield; at @MainLoop.
Since MainLoop runs every frame, you must tell Danmakufu to suspend the MainLoop routine to look for other tasks. In this case, the BulletTask and MotionTask, since they'll never stop running. Once they have their timeslice and yield back to MainLoop, execution for that frame will be finished, and it'll happen all over again next frame.

Multiple yields suspend the tasks multiple frames, etc etc.
« Last Edit: October 13, 2012, 03:23:15 PM by Fujiwara no Mokou »

Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #451 on: October 13, 2012, 05:15:07 PM »
It seem to work...
But I can't force PatternX and PatternY to start at chooseable frame... if(frame==x) doesn't work...

http://pastebin.com/0QpHEA6S

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #452 on: October 13, 2012, 09:16:21 PM »
You seem to have missed the part where I did this:
task patternX{
   wait(60);
   loop{
      dosomething;
      wait(5);
   }
}

If the loop(30){yield;} during your patternX task makes the task wait for 30 frames each time it loops, then you should be able to see that putting loop(60){yield;} before the task's core loop, when the task begins, will make the task wait for 60 frames before really starting up.

The @Initialize routine only runs once, when the script begins. After that it is never run again. This is why you can't put if(frame==60){patternX;} in @Initialize, because that code will only run once, be false since frame is still 0, and the task won't run.
« Last Edit: October 13, 2012, 09:20:51 PM by Drake »

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

Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #453 on: October 13, 2012, 09:36:30 PM »
I'm still having trouble...
This doesn't seem to run:

task PatternX(){
   wait(60); //here is problem
   loop(){
      let ex = ObjMove_GetX(objEnemy);
      let ey = ObjMove_GetY(objEnemy);
      let moving = rand(-5, +5);
      let angle=0+moving;
      while(angle<=360+moving){
         let obj1 = CreateShotA1(ex, ey, 3, angle, DS_BALL_SS_WHITE, 15);
         angle+=10;
      }
      wait(10);
      yield;
   }
}

There is something wrong with the first wait command... Oh, I would appreciate any good ph3 tutorials (it's not so fresh software)...

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #454 on: October 13, 2012, 10:45:43 PM »
It has nothing to do with ph3, it's the exact same in 0.12.

wait() is not a hardcoded function, it's user-defined:
function wait(n){
   loop(n){ yield; }
}


You're getting an error because you don't have the wait() function in your script. You have to add it to your script in order to use it, otherwise you use loop(n){yield;}. They're the same thing, wait() just saves some typing. I'm sorry, I assumed you understood what wait(n) meant so I used wait(n) and loop(n){yield;} interchangeably.

I'm not exactly sure how I can explain this better. When you use a yield, it stops the code there and moves onto the next thing to do, until the next frame. This is how you get danmakufu to seemingly run multiple tasks at the same time. On the next frame, the task/whatever will start from that yield and continue until it yields again or finishes. So if you have a loop(20){ yield; }, danmakufu will yield, wait for the next frame, then yield again, and yield again, 20 times. In this way, it's "waiting" 20 frames. We use the wait() function defined above to save a bit of typing and make it clearer what we're doing.

I really want you to understand this. This is a fundamental part of danmakufu scripting. Just giving you code to copypaste for all of your problems might be nice, but if you get to understand how the scripts actually works then you can do so much more without having to ask for anyone's help. I have no problems helping you, but understanding what's you're actually doing is obviously important!

Also, most things you're currently doing in ph3 are the same or very similar to how you'd do it in 0.12. Most of the early differences in ph3 come with the increased focus on objects, and the new drawing rules. Most of the real heavy differences only show up when you're doing more advanced scripting. Because the people working on advanced scripting are going to be more knowledgeable, we don't really have a need to make tutorials for ph3 right away, especially when the program is still being updated. If people really want a tutorial on ph3 and we have some actual interest in a subject to cover in a tutorial, then tell me and I'll do it.

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

ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #455 on: October 14, 2012, 02:52:40 AM »
If people really want a tutorial on ph3 and we have some actual interest in a subject to cover in a tutorial, then tell me and I'll do it.
Most of the parts of Ph3 I think I can (probably) figure out on my own based on my experience with 0.12m. However, there is one aspect of it that sort of mystifies me. I know it's not really necessary to know for basic scripting, but I've always been curious as to what @Loading is and what it does.

Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #456 on: October 14, 2012, 12:20:57 PM »
Thanks Drake, it's now working well.

EDIT: Now, the "script" is completed!
here

I want to add one more thing to it before trying to make something more - I want enemy's hitbox to be inactive before the sixtieth frame, because the first bullets are shoot at this particular frame, and the enemy is just moving before. I can't do this in Initailize, MainLoop, and making the task just seem to not work (it's bypassed by script). What should I do?
« Last Edit: October 14, 2012, 12:45:56 PM by Danmakuer »

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #457 on: October 14, 2012, 10:53:00 PM »
You can do this in a few different ways, but the one with the least amount of editing is by starting a new task from @Initialize (just like the others) that uses ObjEnemy_SetDamageRate so that no damage to the boss is done, waits 60 frames, then resets SetDamageRate back to normal.
http://dmf.shrinemaiden.org/wiki/index.php?title=Enemy_Object_Functions#ObjEnemy_SetDamageRate
This is the description for ObjEnemy_SetDamageRate(). You should be able to implement this yourself, now.

Ozzy: From the description on the documentation, @Loading is for loading graphics and sounds in a separate thread. This might be useful when you start, perhaps say, stages inside a full game and you don't want massive chugging or a loading screen while you load necessary files. However, you can't create objects or generate random numbers, and probably not anything that calls the game engine's functions, but this shouldn't matter because those aren't its purpose anyways. Functions that the main program uses like loading files and simple math and the like should be fine, though? You probably also have to make sure that you aren't referencing the loaded files immediately because that can cause possible errors and replay desyncs for whatever reason. This is just my take on it, though.
« Last Edit: October 14, 2012, 11:05:14 PM by Drake »

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

Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #458 on: October 15, 2012, 04:05:11 PM »
Thanks for all these things, Drake. You should really complete the lack of tutorials on the wiki.

(...)You probably also have to make sure that you aren't referencing the loaded files immediately(...)
-> let imgExRumia = GetCurrentScriptDirectory ~ "ExRumia.png";?
Do you mean using the let command after the load? Because I don't know how to refer after.

And more one thing, becuase i can't see anything wrong in this code:
http://pastebin.com/YJ47bkeG
It runs without error, but the black bullets doesn't seem to appear.

Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #459 on: October 20, 2012, 06:22:55 PM »
Sorry for doublepost, but I want the another advice.
http://pastebin.com/UC2se2Ee
I just wanted to make the in-code difficulty switches for testing purposes, but something gone wrong. How it should be built?

EDIT:Nonetheless, i get script working. Here:
http://pastebin.com/NQy7FKxQ
« Last Edit: October 20, 2012, 06:33:43 PM by Danmakuer »

PJ

  • jesus christ it's all over the walls
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #460 on: October 23, 2012, 12:36:32 AM »
Sorry for doublepost, but I want the another advice.
http://pastebin.com/UC2se2Ee
I just wanted to make the in-code difficulty switches for testing purposes, but something gone wrong. How it should be built?

EDIT:Nonetheless, i get script working. Here:
http://pastebin.com/NQy7FKxQ

Do you know what "local scope" is? Imagine something like this.

Imagine you have three boxes. Box A, Box B, and Box C.
B and C are inside of Box A.

You put a music box inside of box B, and then a microphone in box C. Because they're in different boxes, they cannot interact. Therefore, the microphone ignores the music box.
Now, what if you removed the music box from Box B, and just put it inside Box A? It should then be able to interact with the microphone.

Your issue is that you define the variable "difficult" in @Initialize, and then try to refer to it inside @Mainloop. What you want to do is move "let difficult" below the header, in the space where objPlayer, frame, and objEnemy are defined.

So, if you wanted it to work correctly, it should be like this.

Code: [Select]
#?Ś?ű?e????[Single]
#ScriptVersion[3]
#Title["10"]
#Text["10"]
#Background["script/default_system/Default_Background_IceMountain.txt"]
 
#include"script/default_system/Default_ShotConst.txt"
 
let objEnemy;
let objPlayer;
let frame = 0;
let difficult = 2;

Then, you remove "let difficult = 2;" from @Initialize, because you already defined it on a higher "level".

fondue

  • excuse me
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #461 on: October 23, 2012, 07:58:47 PM »
How can I use polar coordinates in Danmakufu? Like the θ thingy? I'm using it to generate curves.

PJ

  • jesus christ it's all over the walls
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #462 on: October 23, 2012, 08:28:07 PM »
How can I use polar coordinates in Danmakufu? Like the θ thingy? I'm using it to generate curves.
Just convert the polar coordinates to cartesian coordiates. Danmakufu does not have native support for polar coordinates.

fondue

  • excuse me
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #463 on: October 24, 2012, 06:51:04 AM »
Well if that's the case, how can eye do that?

PJ

  • jesus christ it's all over the walls
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #464 on: October 24, 2012, 11:55:33 AM »
Well if that's the case, how can eye do that?
sine and cosine, of course.
Polar coordinates are direction and magnitude. Cartesian coordinates are X and Y.
For polar coordinates, it's just as simple as making a circle.

For example, to calculate the position of the end of a vector at (0,0) that has a direction of 53 degrees, and its magnitude is 96 pixels, to convert it to cartesian, you would use cos(53)*96 for the X coordinate, and sin(53)*96 for the Y coordinates.

Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #465 on: October 24, 2012, 05:40:50 PM »
@Anthropohpobia - thanks, but I used that way already before you posted.

I had another question - how to get a definied track placed between two ends of the laser, regardless any properties (in my cause, angle is changing in every loop)?

PJ

  • jesus christ it's all over the walls
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #466 on: October 24, 2012, 08:11:02 PM »
I had another question - how to get a definied track placed between two ends of the laser, regardless any properties (in my cause, angle is changing in every loop)?
A defined track?  ???
I have no idea what that means. There's a function that checks if a circle intersects with a line, though, if that's what you want.
« Last Edit: October 25, 2012, 08:10:44 PM by Anthropophobia »

fondue

  • excuse me
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #467 on: October 26, 2012, 06:55:18 PM »
Okay, in the file DrawFunctions.txt in the folder Functions, the task TEnd in Cutin won't work. Ideas why?
« Last Edit: October 26, 2012, 07:07:59 PM by masterfondue »

Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #468 on: October 26, 2012, 09:30:38 PM »
Hello there. I'm a beginner to Danmakufu ph3 and I'm trying to remake some of my patterns from the 0.12m version with the ph3.
But while testing, I had a problem with this task that is launched in the @Initialize loop : http://pastebin.com/DMQe2Sqm

Nothing fires. In 0.12m I obtain this result : http://puu.sh/1j2Yk


Sorry, actually I forget to add yield; in the mainloop. Shame on me ><
« Last Edit: October 27, 2012, 12:11:26 PM by Jonath »

toyosataomimiMasquerade

  • Probated until the evning of 10/31
  • For admitting to game downloads
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #469 on: October 27, 2012, 08:35:02 AM »
umm excuse me but where can i make scripts of characters and bullets and etc.... well my computer is japanese applocale but the danmakufu isn't japanese it is kind of strange marks(noticing that it is the latest version and my danmakufu is working properly)can anyone give me an guide?
 ???

gtbot

  • Master of ScreenSplit
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #470 on: October 27, 2012, 02:29:16 PM »
Okay, in the file DrawFunctions.txt in the folder Functions, the task TEnd in Cutin won't work. Ideas why?

Your scripts are ended immediately after the boss health reaches 0, giving no time for any other processes to do anything.  Do a wait(128) (or more than 128, depending on how long you want your script to remain active) right before CloseScript in all your scripts. Additionally, if you add bullet shooting sounds, they won't be abruptly stopped either.  However, a problem surfaces when you do this: your script's attack will likely continue to go on.  To solve this, you can either break your loops by checking if the boss hp is 0, or have the loops in a while statement for boss hp > 0, and when the hp reaches 0 the while statement will end.  Also, I suggest adding your piece of code that closes the script below a single while/loop (whichever you choose to do) statement; this will simplify a lot of things.

umm excuse me but where can i make scripts of characters and bullets and etc.... well my computer is japanese applocale but the danmakufu isn't japanese it is kind of strange marks(noticing that it is the latest version and my danmakufu is working properly)can anyone give me an guide?

What exactly do you mean by scripts of characters and bullets? Boss scripts or player scripts or bullet shot data? You can find information in the wiki, located at http://dmf.shrinemaiden.org/wiki/Main_Page. Also I'm not sure about the applocale part, I've never used it before.

fondue

  • excuse me
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #471 on: October 27, 2012, 02:49:59 PM »
Your scripts are ended immediately after the boss health reaches 0, giving no time for any other processes to do anything.  Do a wait(128) (or more than 128, depending on how long you want your script to remain active) right before CloseScript in all your scripts. Additionally, if you add bullet shooting sounds, they won't be abruptly stopped either.  However, a problem surfaces when you do this: your script's attack will likely continue to go on.  To solve this, you can either break your loops by checking if the boss hp is 0, or have the loops in a while statement for boss hp > 0, and when the hp reaches 0 the while statement will end.  Also, I suggest adding your piece of code that closes the script below a single while/loop (whichever you choose to do) statement; this will simplify a lot of things.
Okay I've done all that (except for the while(){} thing for the code that closes the script) but for some reason stray bullets are being left behind in the top-left corner of the stage. They're there when the script closes. Ideas why?
fixed yaaaaaaaaaaaaay ilu
no its not :<

fixed :derp:

e: How do I make a replica of the first part of Shikigami's Shot "Unilateral Contract"? The part where a massive amount of bullets were being shot out from Ran all at the same time?
And in this piece of code why is it that Rumia (the boss) sometimes goes off the stage?
Code: [Select]
task TMovement{
let result=rand(-1,1);
if((GetEnemyX-50)<=32||(GetEnemyX+50)>=(GetStgFrameWidth()-32)){
result=-result;
}
if(result>=0){
ObjMove_SetDestAtWeight(objBoss,GetEnemyX-50,GetStgFrameHeight()/4,10,5);
}else{
ObjMove_SetDestAtWeight(objBoss,GetEnemyX+50,GetStgFrameHeight()/4,10,5);
}
yield;
}
« Last Edit: October 27, 2012, 05:02:23 PM by masterfondue »

gtbot

  • Master of ScreenSplit
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #472 on: October 27, 2012, 04:49:43 PM »
Okay I've done all that (except for the while(){} thing for the code that closes the script) but for some reason stray bullets are being left behind in the top-left corner of the stage. They're there when the script closes. Ideas why?
If you went with the break; route, put one yield before the DeleteShotAll.
e: How do I make a replica of the first part of Shikigami's Shot "Unilateral Contract"? The part where a massive amount of bullets were being shot out from Ran all at the same time?
Code: [Select]
loop(128){
let ranspd = rand(2.5, 8);
let obshot = CreateShotA2(ex, ey, ranspd, rand(0,360), -ranspd/90, 0, DS_RICE_S_BLUE, 10);
ObjMove_AddPatternA2(obshot, 105, NO_CHANGE, NO_CHANGE, 0.05, 2.85, 3);
ObjMove_AddPatternA2(obshot, 155, NO_CHANGE, NO_CHANGE, 0.1, 0, 3);
}
change as needed

fondue

  • excuse me
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #473 on: October 27, 2012, 05:16:33 PM »
If you went with the break; route, put one yield before the DeleteShotAll.
I went with the other one, I called DeleteShotAll twice, before the wait(); and after the wait(); just to make sure all bullets are deleted.
Code: [Select]
loop(128){
   let ranspd = rand(2.5, 8) ;
   let obshot = CreateShotA2(ex, ey, ranspd, rand(0,360), -ranspd/90, 0, DS_RICE_S_BLUE, 10);
   ObjMove_AddPatternA2(obshot, 105, NO_CHANGE, NO_CHANGE, 0.05, 2.85, 3);
   ObjMove_AddPatternA2(obshot, 155, NO_CHANGE, NO_CHANGE, 0.1, 0, 3);
}
change as needed
Thankyou~
now
And in this piece of code why is it that Rumia (the boss) sometimes goes off the stage?
Code: [Select]
task TMovement{
      let result=rand(-1,1);
      if((GetEnemyX-50)<=32||(GetEnemyX+50)>=(GetStgFrameWidth()-32)){
         result=-result;
      }
      if(result>=0){
         ObjMove_SetDestAtWeight(objBoss,GetEnemyX-50,GetStgFrameHeight()/4,10,5);
      }else{
         ObjMove_SetDestAtWeight(objBoss,GetEnemyX+50,GetStgFrameHeight()/4,10,5);
      }
      yield;
}
« Last Edit: October 27, 2012, 05:22:36 PM by fondoomahsterr »

gtbot

  • Master of ScreenSplit
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #474 on: October 27, 2012, 05:41:00 PM »
And in this piece of code why is it that Rumia (the boss) sometimes goes off the stage?
The result variable is not accounted for at all when checking if Rumia is going to fly off screen, it's merely made into the opposite of + or - without regard to your current if statements.
Code: [Select]
if(GetEnemyX-50<=32){
result=-1
}
if(GetEnemyX+50>=GetStgFrameWidth-32){
result=1
}

Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #475 on: October 27, 2012, 09:55:06 PM »
I'm coming with another trouble:

task PatternX(){
   loop(60){yield;}
   
   loop{
      let ex = ObjMove_GetX(objEnemy);
      let ey = ObjMove_GetY(objEnemy);
      let angle=0;
      while(angle<=360){
         tangensbullet(ex, ey, 2, angle, DS_ICE_RED, 15);
         angle+=5;
      }
      loop(60){yield;}
   }
}

task tangensbullet(x, y, spd, ang, graph, delay){
   let shot = CreateShotA1(x, y, spd, ang, graph, delay);
   let sx = ObjRender_GetX(shot);
   let sy = ObjRender_GetY(shot);
   let wallhit = false;
   while(!Obj_IsDeleted(shot)){
      sx = ObjRender_GetX(shot);
      sy = ObjRender_GetY(shot);
      if(sx<=1){Obj_Delete(shot); wallhit = true;}
      if(sx>=GetStgFrameWidth-1){Obj_Delete(shot); wallhit = true;}
      if(sy<=1){Obj_Delete(shot); wallhit = true;}
      yield;
   }
   if(wallhit == true){
      CreateShotA1(sx, sy, spd, tan(ang), graph, 0);
      yield;
   }
}


I just wanted bullets to act like in Flandre's final spell, but I can't figure how to implement tangens here.

gtbot

  • Master of ScreenSplit
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #476 on: October 27, 2012, 11:03:02 PM »
I just wanted bullets to act like in Flandre's final spell, but I can't figure how to implement tangens here.
You don't have to use tangent, http://pastebin.com/8ZLLGRjt
« Last Edit: October 27, 2012, 11:04:49 PM by gtbot »

toyosataomimiMasquerade

  • Probated until the evning of 10/31
  • For admitting to game downloads
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #477 on: October 27, 2012, 11:53:05 PM »
....well i need all (it is my first time....and i don't know anything at all or even how to put these files or where)i just downloaded it because i wanted to get CtC

Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #478 on: October 28, 2012, 08:01:24 PM »

PJ

  • jesus christ it's all over the walls
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #479 on: October 29, 2012, 11:53:36 PM »
never mind, fixed it.
« Last Edit: October 31, 2012, 10:43:17 PM by Anthropophobia »