Author Topic: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m [Closed, read last post!]  (Read 172298 times)

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #270 on: August 26, 2013, 02:08:44 AM »
How do I make background effects like the falling cherry petals/maple leaves/snowflakes?
...Basically do what I said in my above post. Don't put them in the actual background routine, though.
Call startConfetti() -> startConfetti() is a task that calls spawnConfetti() every so often -> spawnConfetti creates an effect object on a low layer and has it do some stuff before being deleted

That's the gist of it.

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

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #271 on: August 26, 2013, 06:37:01 AM »
How do I make background effects like the falling cherry petals/maple leaves/snowflakes?

You mean just like the Touhou Games, right? There are several ways to do this.
I recommend using effect objects. Even with that, there are several ways to do it.
Too many effect objects can slow Danmakufu down, however.
But if you just use one object and draw it as a TriangleList primitive, and play with the vertices to make it look as if though there are many objects, that would do you much good.

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #272 on: August 26, 2013, 06:35:34 PM »
I dunno if this is allowed, but does anybody know which sound in ZUN's SE files is the one used for shooting? (The first sound used in Youmu's first nonspell.)
« Last Edit: August 27, 2013, 05:47:29 AM by KuroArashi »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #273 on: August 26, 2013, 09:10:16 PM »
Enemy shots are usually tan00, 01 and 02. plst00 is player shot.

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #274 on: August 27, 2013, 05:47:12 AM »
Okay, thank you!

I kept using plst00 for the really small bullets *facepalm*.

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #275 on: August 27, 2013, 03:54:48 PM »
How exactly does Collision_Obj_Obj work?
The wiki says to use "object 1" and "object 2" when using it, but are these the task names?
Or are they the object IDs and can it only be called when using 2 objects inside 1 task?
Or is it something else and am I missing something?

Edit: I'm sorry for double posting, I didn't see it until I pressed the post button.
« Last Edit: August 27, 2013, 04:43:21 PM by KuroArashi »

Darkness1

  • Nothing to see here.
  • Enigmatic, isn't it?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #276 on: August 27, 2013, 04:37:54 PM »
Yes, they are two object ID's. I'm not entirely sure how to use them correctly, but here is a link to a mini-tutorial I made on making simple 2-way object collision objects: http://www.shrinemaiden.org/forum/index.php/topic,14911.msg1001257.html#msg1001257

Please correct me or come with a simpler/better version as I would too like to know this. This is just the way I managed to get it working.

If you use the user defined value together with some values in the master/slave script, it should work. Other than that, I guess you have to use common data in some way if you want alot of script-global values.

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #277 on: August 29, 2013, 05:54:08 AM »
Okay, that seems logical. I cannot say I fully understand, but the problem I had has been resolved anyway, so that's okay to me.
I'll just look over it again once I understand what exactly is happening.

To ask another question:
I am trying to replicate the effect of Youmu's background whenever she slows down time.(A lot of flowers spinning in the background)
However, it doesn't work.
 
Code: [Select]
@BackGround{
SetTexture(bg);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicRect(0,0,256,256);
SetGraphicScale(1.9,1.9);
SetGraphicAngle(0,0,0);
DrawGraphic(GetCenterX,GetCenterY);

SetTexture(lay);
SetRenderState(ALPHA);
SetAlpha(timeslow);
SetGraphicRect(0,0,256,256);
SetGraphicScale(1.9,1.9);
SetGraphicAngle(0,0,spin);
DrawGraphic(GetCenterX,GetCenterY);
spin++;
}
timeslow is a variable that is set to 255 whenever time slows down.
Is there a way to fix this? Or do I have to use effect objects?

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #278 on: August 29, 2013, 09:33:06 AM »
See:
Quote from: Drake
Next time, when you say something is wrong, please also describe what is going wrong, not just what you want and "it isn't working". It helps.

Does it just not show up or what? The code looks fine besides still having to do the processing for the overlay every frame.
Main things:
- wrap the drawing in an if(timeslow>0) clause so you aren't drawing an invisible image all the time
- check if you actually loaded the graphic
- just set the alpha value to 255 to check if it draws at all
« Last Edit: August 29, 2013, 09:34:50 AM by Drake »

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

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #279 on: August 29, 2013, 02:24:01 PM »
Can you explain why it's looking for the file in the root DNH directory? Where is the script you're running and what do your directories look like? Also, does including sanGayaFramework.dnh before variables.dnh but after the other random variable declarations do anything different?

Sorry about the delay. Got really busy. Anyway, back on topic.

I have absolutely no idea why the script is looking at the DNH root. the directories look something like this:

Touhou Danmakufu
>bgm
>img
>lib
>player
>replay
>se
>snapshot
>script
 |
 >all the other scripts
 >testSign (where all my stuff are.)
     |
     >>>bgm
     >>>devDocs (just to track progress)
     >>>img
     >>>libs (ultimately didn't use this. it's empty. Will probably remove)
     >>>SFX
     >>>system (where libs went to)

The script is running within testSign.
I was doing some code cleanup before the project got too big and decided to take off a number of comments that don't do anything useful in understanding what the code does. If I delete that particular comment however, the code breaks.
I tried moving sanGayaFramework.dnh before variables.dnh. Nothing special happens until I delete that comment which breaks the code. I tried playing around with the comment and it won't accept any other text.

Edit: ran a couple more tests: apparently, the comment must be placed within script_enemy_main before #include_function ".\sanGayaFramework.dnh". I have absolutely no idea why a comment can make or break the code.
Edit2: ran even more experiments. changing ".\variables.dnh" to GetCurrentScriptDirectory~"variables.dnh" still has danmakufu looking at the root.
« Last Edit: August 29, 2013, 02:45:56 PM by pogisanpolo »

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #280 on: August 29, 2013, 04:29:37 PM »
Sorry about the delay. Got really busy. Anyway, back on topic.

I have absolutely no idea why the script is looking at the DNH root. the directories look something like this:
//Stuff

The script is running within testSign.
I was doing some code cleanup before the project got too big and decided to take off a number of comments that don't do anything useful in understanding what the code does. If I delete that particular comment however, the code breaks.
I tried moving sanGayaFramework.dnh before variables.dnh. Nothing special happens until I delete that comment which breaks the code. I tried playing around with the comment and it won't accept any other text.

Edit: ran a couple more tests: apparently, the comment must be placed within script_enemy_main before #include_function ".\sanGayaFramework.dnh". I have absolutely no idea why a comment can make or break the code.
Edit2: ran even more experiments. changing ".\variables.dnh" to GetCurrentScriptDirectory~"variables.dnh" still has danmakufu looking at the root.

Can you pastebin the included scripts?

Also, this is probably stupid, but you have the correct number of { and }, right?

And also, you don't do any directory changing or anything, right? And you don't have a #TouhouDanmakufu inside the included files, right? (that will automatically bring up an error).

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #281 on: August 29, 2013, 06:43:06 PM »
Quote from: Drake
Next time, when you say something is wrong, please also describe what is going wrong, not just what you want and "it isn't working". It helps.

See:
Does it just not show up or what? The code looks fine besides still having to do the processing for the overlay every frame.
Main things:
- wrap the drawing in an if(timeslow>0) clause so you aren't drawing an invisible image all the time
- check if you actually loaded the graphic
- just set the alpha value to 255 to check if it draws at all

I'm sorry, I was kind of hasty when I typed that question. Which is why I didn't elaborate on the problem.
The problem was that it wouldn't appear. However, while pentuple-checking the code, I found out that I forgot to type the extension behind the variable name.  :colonveeplusalpha:

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #282 on: August 29, 2013, 11:05:15 PM »
pogisanpolo: Ah, I remember the problem now.

When you have a header in your script, such as #Title, #Player, and so on, these aren't read at runtime the same way as the rest of the script, they're preprocessed for that header information. The problem occurs from two steps:

1. The file is searched for headers matching valid patterns, and accepts the first instance matching the pattern. If you write #Title[X] then #Title[Y], the script's title will be X. For #include headers, it just finds all of the unique script paths, and will ignore duplicates. This is useful in a way, since if you accidentally include a script twice you won't have duplicates of whatever was in it. This preprocessing is not affected by comments, since it isn't run by the interpreter. You can try commenting out #TouhouDanmakufu all you want but it'll still work.

2. Then when the script is loaded, it grabs the #include headers, loads the associated scripts and basically pastes them directly where the header was found. However, because this is done when the script is actually running (i.e. it's in script_enemy_main), the interpreter is affected by comments, and the #include line is commented out. Since the other instance of the #include was tossed out before, you are no longer loading the script at all.
« Last Edit: August 29, 2013, 11:07:02 PM by Drake »

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

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #283 on: August 30, 2013, 03:43:33 AM »
Can you pastebin the included scripts?

Also, this is probably stupid, but you have the correct number of { and }, right?

And also, you don't do any directory changing or anything, right? And you don't have a #TouhouDanmakufu inside the included files, right? (that will automatically bring up an error).

I've included the main script as well. I've used Victini's and Johnny Walker's stuff as a boilerplate so for those familiar with their work, much of the code may look familiar with a couple of tweaks here and there to serve my purposes. The lack of a dedicated IDE means it's entirely possible I missed something as simple as one or two curly braces. On that note, I prefer tasks.

http://pastebin.com/ejrLdmq9 //main script
http://pastebin.com/E0F48WTM //variables.dnh
http://pastebin.com/pNhdjtsw //moveFunctions.dnh
http://pastebin.com/a8LTSQAk //shotVariables.dnh
http://pastebin.com/MtqDzmFa //sanGayaFramework.dnh

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #284 on: August 31, 2013, 01:50:27 AM »
I've included the main script as well. I've used Victini's and Johnny Walker's stuff as a boilerplate so for those familiar with their work, much of the code may look familiar with a couple of tweaks here and there to serve my purposes. The lack of a dedicated IDE means it's entirely possible I missed something as simple as one or two curly braces. On that note, I prefer tasks.

http://pastebin.com/ejrLdmq9 //main script
http://pastebin.com/E0F48WTM //variables.dnh
http://pastebin.com/pNhdjtsw //moveFunctions.dnh
http://pastebin.com/a8LTSQAk //shotVariables.dnh
http://pastebin.com/MtqDzmFa //sanGayaFramework.dnh

Yup. This is a unique case for me.

Anyways, I've never seen anyone ever include their @Initialize and everything. The tasks should be in the included script, and the @Initialize, etc. should all be in the main script. What you just did may actually be the problem (others will need to confirm).

Also, regarding Victini, I'm going to let you know now that Victini does not use #DNH[Single] or #DNH[Plural] at all. I highly advise against using his coding style for attacks because he doesn't use more traditional means of scripting.

This is what I would do: move the tasks into sanGayaFramework.dnh and move the all of the contents of sanGayaFramework.dnh after all of the @include_functions in the script_enemy_main.

It may or may not fix your problem, but it will definitely make it easier to debug.

There doesn't seem to be a problem with the other include_functions.

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #285 on: September 01, 2013, 06:35:51 AM »
Yup. This is a unique case for me.

Anyways, I've never seen anyone ever include their @Initialize and everything. The tasks should be in the included script, and the @Initialize, etc. should all be in the main script. What you just did may actually be the problem (others will need to confirm).

Also, regarding Victini, I'm going to let you know now that Victini does not use #DNH[Single] or #DNH[Plural] at all. I highly advise against using his coding style for attacks because he doesn't use more traditional means of scripting.

This is what I would do: move the tasks into sanGayaFramework.dnh and move the all of the contents of sanGayaFramework.dnh after all of the @include_functions in the script_enemy_main.

It may or may not fix your problem, but it will definitely make it easier to debug.

There doesn't seem to be a problem with the other include_functions.

I put the initialize and other things within the include after a while since I found most of the code in there to be repetitive with a couple of minor tweaks which can be done by passing variables, in this case it would be the boss sprites to use, spell card timers and spell card names. That way, I can get the repetitive stuff out of the way and work on the patterns themselves. The entire set of scripts are all spell cards. Anyways, I'll try out your suggestion and I'll take note of what you said about Victini's coding style. I might consider moving @Initialize out of sanGayaFramework.dnh for starters and work from there.

And thanks to your comment, now I'm sure I'm probably the only one here who put the in

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #286 on: September 01, 2013, 05:55:49 PM »
Can someone help me with this effect object? "while(Obj_BeDeleted(obje)==false){" doesn't seem to be working.
Code: [Select]
function CreateSprite(texture, width, height){
let obje=Obj_Create(OBJ_EFFECT);
let srate = 0;
Obj_SetPosition(obje,GetX,GetY);
ObjEffect_SetTexture(obje,texture);
ObjEffect_SetRenderState(obje,ALPHA);

ObjEffect_SetPrimitiveType(obje,PRIMITIVE_TRIANGLESTRIP);
ObjEffect_CreateVertex(obje, 4);

ObjEffect_SetVertexXY(obje,0,-width/2,-height/2);
ObjEffect_SetVertexXY(obje,1,width/2,-height/2);
ObjEffect_SetVertexXY(obje,2,-width/2,height/2);
ObjEffect_SetVertexXY(obje,3,width/2,height/2);
        ObjEffect_SetLayer(obje,5);
ObjEffect_SetVertexUV(obje,0,0,0);
ObjEffect_SetVertexUV(obje,1,width,0);
ObjEffect_SetVertexUV(obje,2,0,height);
ObjEffect_SetVertexUV(obje,3,width,height);

return obje;

while(Obj_BeDeleted(obje)==false) {
srate++;
ObjEffect_SetAngle(obje,0,0,srate);



yield;
}
}

For some reason it won't spin around like want it to. Normally "while(Obj_BeDeleted(obje)==false) {" is supposed to act like a mainloop right?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #287 on: September 01, 2013, 06:06:32 PM »
Can someone help me with this effect object? "while(Obj_BeDeleted(obje)==false){" doesn't seem to be working.
Code: [Select]
function CreateSprite(texture, width, height){
let obje=Obj_Create(OBJ_EFFECT);
let srate = 0;

//Lots of code

return obje;

while(Obj_BeDeleted(obje)==false) {
srate++;
ObjEffect_SetAngle(obje,0,0,srate);



yield;
}
}

For some reason it won't spin around like want it to. Normally "while(Obj_BeDeleted(obje)==false) {" is supposed to act like a mainloop right?

Firstly...

use
while(!Obj_BeDeleted(oboe){}

Secondly, it does act like a @MainLoop, but only after executing everything before it.

Change the code and see if it works.

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #288 on: September 01, 2013, 06:18:28 PM »
Nope. Still does nothing.

Shadow

  • Forever waiting for tomorrow
  • ...
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #289 on: September 01, 2013, 06:18:37 PM »
The while loop never gets to be evaluated because you are returning the Effect Object's ID--and effectively ceasing to execute the rest of the code from that point. The solution is simple if you still want to return the ID: define a separate task containing the while loop inside your CreateSprite function, and call the task before your return call.

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #290 on: September 01, 2013, 06:26:27 PM »
Thanks it worked.

ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #291 on: September 01, 2013, 06:44:07 PM »
use
while(!Obj_BeDeleted(oboe){}
Um, that line is exactly equivalent to while(Obj_BeDeleted(obje)==false) {}. There's functionally no reason to use one over the other.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #292 on: September 01, 2013, 06:50:25 PM »
Um, that line is exactly equivalent to while(Obj_BeDeleted(obje)==false) {}. There's functionally no reason to use one over the other.

Oh, OK. I've never seen it before though.

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #293 on: September 01, 2013, 11:38:52 PM »
Obj_BeDeleted() returns either true or false. With equality, if it returns true, you evaluate (true == false) which is false and the loop ends, and if it returns false, you evaluate (false == false) which is true and the loop continues. Using negation, returning true you would evaluate (! true) meaning "NOT true", which is still false and the loop ends, and if it returns false you evaluate (! false) which is true, loop continues.

That's really odd though. It's like saying you've never seen x = x + 5 and have only seen x += 5.
« Last Edit: September 01, 2013, 11:41:31 PM by Drake »

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

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #294 on: September 02, 2013, 12:23:13 AM »
Obj_BeDeleted() returns either true or false. With equality, if it returns true, you evaluate (true == false) which is false and the loop ends, and if it returns false, you evaluate (false == false) which is true and the loop continues. Using negation, returning true you would evaluate (! true) meaning "NOT true", which is still false and the loop ends, and if it returns false you evaluate (! false) which is true, loop continues.

That's really odd though. It's like saying you've never seen x = x + 5 and have only seen x += 5.

Most scripts I remember use !Obj_BeDeleted, and I do too. Maybe that's why it threw me off. I guess I'm just too used to it.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #295 on: September 02, 2013, 08:09:07 AM »
Just to note.

It is has nothing to do with not being used to, however more like knowledge and style. A beginner scripter would not use the exclamation mark like that and only recognize it in statements such as == and !=. I used that style in the old days as well. Later on if someone understands the exclamation mark, he/she will reduce redundancy and apply "proper" style.

It is a non-issue to be pointed out or even commented, unless you're teaching the person code-clean up. Which is in this thread usually not priority. Obviously that change wasn't going to fix his initial problem.

Also another note in general for everybody:
Please refrain from noise posts if you don't test out the script/code yourself. I am noticing too many posts in this thread where people post help but actually never test it out themselves. Don't post because you just want to post. Post because you have tested and/or fixed the issue for the user. There is a secondary reason why we ask people to post their code in pastebin. Not just to see it, but also to quick copy/paste into our own dnh engines and test out what is going on.

Thanks.
« Last Edit: September 02, 2013, 08:15:06 AM by Helepolis »

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #296 on: September 02, 2013, 05:02:11 PM »
Then I'm going to jump in with another question:
The sprite of my player character won't appear.
The options appear just fine, the life image (which is the same image) appears too.
The sprite however, won't appear.
Does anybody know what causes this?
This is the script if anybody wants to see.

Thanks in advance!

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #297 on: September 02, 2013, 05:16:18 PM »
Then I'm going to jump in with another question:
The sprite of my player character won't appear.
The options appear just fine, the life image (which is the same image) appears too.
The sprite however, won't appear.
Does anybody know what causes this?
This is the script if anybody wants to see.

Thanks in advance!

You don't DrawGraphic (GetPlayerX,GetPlayerY);

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #298 on: September 03, 2013, 03:02:22 PM »
You don't DrawGraphic (GetPlayerX,GetPlayerY);
*Facepalm*
I keep forgetting the most basic things. I'm sorry for asking such a stupid question.

But, to ask even more questions:
-Is it possible to set a hitbox on effect objects outside spellcards?
I need to make something like that both as an enemy bullet, and as a player bullet (object).
The enemy bullet is just a normal kind of bullet (object), and the player bullet is slightly similar to DDC ReimuA's Gohei.

-And how is the hitbox for user defined bullets calculated? I can't find any text that indicates that.
« Last Edit: September 03, 2013, 03:06:08 PM by KuroArashi »

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #299 on: September 03, 2013, 11:28:51 PM »
It's about a third of the defined rect's smaller dimension.

You can make your own collision checking for the object and use AddLife(-x) to damage the enemy. Use SetCollisionB() on the same object to have it hit the player.
If you're doing this then obviously you don't need to define it as a bullet and so the calculated hitbox won't matter.
« Last Edit: September 03, 2013, 11:30:22 PM by Drake »

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