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

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre17)
« Reply #810 on: September 27, 2013, 06:37:20 AM »
your code makes me want to cry

The problem is likely due to you only pairing two vertices together when trying to change the graphic.



You're probably aware that things render in triangles, that is, groups of three vertices. When you change only the last two vertices to a different UV set, two things happen:
-You get the one 2-3-4 triangle sticking out where really you want that part greyed as well to make the "ring" look evenly cut.
-I didn't put it in the image, but the 3-4-5 triangle also screws up, because it still uses the UVs from 3. You'd get a warped result in that triangle.

This is essentially caused by you trying to use the same object to display two different images. Unless you want to get clever with the original graphic and UV sets, even if you modify the vertices in groups of four (as you normally would) for say 2-3-4-5, the 0-1-2-3 block will also be using the UVs from 2 and 3 and the graphic will still screw up at that intersection.

The lifebar circles we already see don't use another graphic for "lost" health, they simply delete two vertices at a time. By actually deleting the two vertices, all the triangles that used those vertices just stop existing, so deleting the two vertices will give you the intended straight cut.
« Last Edit: September 27, 2013, 06:42:24 AM by Drake »

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

Darkness1

  • Nothing to see here.
  • Enigmatic, isn't it?
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre17)
« Reply #811 on: September 27, 2013, 06:45:53 PM »
Well, changing it to 4 vertices at a time instead of 2 fixed the main problem, so I'm pleased.

But how do I delete vertices?
« Last Edit: October 04, 2013, 03:51:04 AM by Darkness1 »

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre17)
« Reply #812 on: September 28, 2013, 04:53:00 PM »
Code: [Select]
WriteLog(cos(90));
WriteLog(cos(90) == 0);
WriteLog(cos(90) > 0);

Code: [Select]
2013/09/28 19:50:27.002 0.000000
2013/09/28 19:50:27.026 false
2013/09/28 19:50:27.047 true

 :wat:

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre17)
« Reply #813 on: September 28, 2013, 04:57:29 PM »
What will happen if you try 0.0 instead of just 0? It's likely the matter of integer vs real values.
Would be glad to get help with Touhou Doumeiju ~ Mystical Power Plant Translation Project spellcard comments' translation.

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre17)
« Reply #814 on: September 28, 2013, 06:19:13 PM »
I tried it, still the same. (Also I'm pretty sure there's no int in danmakufu, only float)
You only get this result with the zero that cos() returns. Every other zero is fine

???

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre17)
« Reply #815 on: September 28, 2013, 06:28:53 PM »
Probably a bug. Maybe you should report about it to the author. I don't know if he knows English but it seems Helepolis was able to send bug reports somehow.
Would be glad to get help with Touhou Doumeiju ~ Mystical Power Plant Translation Project spellcard comments' translation.

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre17)
« Reply #816 on: September 29, 2013, 02:42:59 AM »
It's very likely just floating point shenanigans; it's an extremely common quirk of floating-point representations that you just have to deal with and it's present in many different languages, libraries, etc (seriously just google it). It has a lot to do with approximations of pi with FP and what the cosine of that representation is.

More importantly, why is it necessary that you compare the cosine, anyway? If it's truly necessary, which I doubt it is, just check the absolute range within 0.000001 or round it or something.

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

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre17)
« Reply #817 on: September 29, 2013, 05:37:34 AM »
I've just googled it. Well, I was never aware of this problem. Weird.
Anyway, of course I don't HAVE to compare cosine, it's just something I like to use when I want to know if the angle is to the right or to the left (since I don't want to rely on the fact that the angle is always between -180 and 180 degrees)

If anyone is interested, my solution is to compare cos(angle) to cos(90) instead of zero. This way it works fine.

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre17)
« Reply #818 on: September 29, 2013, 07:24:44 AM »
if((angle-90) % 360 < 180){ left }
if((angle-90) % 360 > 180){ right }
Or if you just wanted to check the exact angles I don't see why you can't just do
if(angle%360 == 180){ left }
if(angle%360 == 0){ right } 
« Last Edit: September 29, 2013, 07:27:25 AM by Drake »

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

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #819 on: September 30, 2013, 06:33:05 AM »
Does anyone know any trick to force text drawing function not to trim empty characters like normal whitespaces (whitespaces at the beginning of the line are trimmed) and line-breaks? I'm getting rid of Japanese text, and there ' ' was used instead of normal whitespaces and it was put between line-breaks to avoid being trimmed, but what can be done for English encoding?
« Last Edit: September 30, 2013, 06:37:54 AM by Vectorfish »
Would be glad to get help with Touhou Doumeiju ~ Mystical Power Plant Translation Project spellcard comments' translation.

KuroArashi100

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #820 on: October 03, 2013, 07:41:29 PM »
Does anybody know the system requirements for ph3?
The Touhou wiki says something about it, but I don't know anything about video cards and the like.

My laptop keep running it at 60.04 or 59.96 FPS, because it keeps freezing a few frames every few seconds.
And while I know my system specs are pretty bad, does ph3 really use that much more resources than 0.12?
I can run 0.12 on my computer, and it won't lag unless I spawn something like 1000 bullets at once, but ph3 won't even let me create a boss and move it left and right every few seconds without lagging.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #821 on: October 03, 2013, 08:10:04 PM »
Does anybody know the system requirements for ph3?
The Touhou wiki says something about it, but I don't know anything about video cards and the like.

My laptop keep running it at 60.04 or 59.96 FPS, because it keeps freezing a few frames every few seconds.
And while I know my system specs are pretty bad, does ph3 really use that much more resources than 0.12?
I can run 0.12 on my computer, and it won't lag unless I spawn something like 1000 bullets at once, but ph3 won't even let me create a boss and move it left and right every few seconds without lagging.
This seems to be odd. Have you breaking it down into parts for trial & error. As in 1) Disable the boss appearance nor any other graphics / tasks for movement -> Does it lag?  2) Add the graphic for the boss only (no movement) -> Does it lag?  etc.

There should be something going on in your script. Maybe show us also your code? (Why don't people show their code and assume that we should use our crystal balls to guess what is happening)

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #822 on: October 03, 2013, 10:19:06 PM »
Can someone tell me why this effect object for the pause menu won't load?

I call this inside of the pause script but nothing shows up. I've tried everything I could think of.
Code: [Select]
task Pause{
let csd = GetCurrentScriptDirectory;

let Target = csd~"/default_system/img/pause.png";
let objp = ObjPrim_Create(OBJ_SPRITE_2D);

        LoadTexture(Target);
Obj_SetRenderPriorityI(objp, 100);
ObjPrim_SetTexture(objp, Target);
ObjRender_SetBlendType(objp, BLEND_ALPHA);
ObjSprite2D_SetSourceRect(objp, 0, 0, 47, 211);
ObjSprite2D_SetDestRect(objp,0,0,47,211);
ObjRender_SetPosition(objp,120,120,125);
ObjSprite2D_SetDestCenter(objp);
ObjRender_SetScaleXYZ(objp, 1, 1, 1);

         }
Also, what are the steps to creating a bullet dissolve effect?
« Last Edit: October 03, 2013, 10:27:50 PM by Infinite Ultima Wave »

Ozzy

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #823 on: October 04, 2013, 02:21:15 AM »
Can someone tell me why this effect object for the pause menu won't load?

I call this inside of the pause script but nothing shows up. I've tried everything I could think of.
Code: [Select]
task Pause{
let csd = GetCurrentScriptDirectory;

let Target = csd~"/default_system/img/pause.png";
let objp = ObjPrim_Create(OBJ_SPRITE_2D);

        LoadTexture(Target);
Obj_SetRenderPriorityI(objp, 100);
ObjPrim_SetTexture(objp, Target);
ObjRender_SetBlendType(objp, BLEND_ALPHA);
ObjSprite2D_SetSourceRect(objp, 0, 0, 47, 211);
ObjSprite2D_SetDestRect(objp,0,0,47,211);
ObjRender_SetPosition(objp,120,120,125);
ObjSprite2D_SetDestCenter(objp);
ObjRender_SetScaleXYZ(objp, 1, 1, 1);

         }
Also, what are the steps to creating a bullet dissolve effect?

Your ObjSprite2D_SetDestRect and ObjSprite2D_SetDestCenter are redundant as both have the same function. ObjSprite2D_SetDestCenter automatically centers the image on the object's coordinates while ObjSprite2D_SetDestRect allow you to customize the location of it, so to speak. However, since the ObjSprite2D_SetDestCenter comes after, that may not be what's causing your issue. Have you checked your file paths? Also, it is not necessary to LoadTexture the image. Only v0.12m requires that.

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #824 on: October 04, 2013, 03:42:13 AM »
You misunderstand render priority. It's understandable that you'd be like "well the larger value means it's drawn overtop!" but that isn't the case.
The higher the render priority of an image, the earlier it is drawn. An object with 50 priority will be drawn before an object with 30 priority. However, this means that if the object with 30 priority is drawn at the same position as the other, the one drawn later will be drawn overtop. So, what's really happening is that objects with high priority end up drawn on the bottom, and objects with low priority end up drawn on the top.

The problem is that anything drawn above 80 priority goes before any of the STG frame and you'll essentially never see it.

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

Darkness1

  • Nothing to see here.
  • Enigmatic, isn't it?
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #825 on: October 04, 2013, 03:46:42 AM »
Also, what are the steps to creating a bullet dissolve effect?
The version I use for this:
1. Create an "item" script.
2. Make the dissolve effect appear on a bullet getting itemized. You should use white graphics, so you can change the dissolve color with getshotdatainfo (delaycolor).
3. Load and start the script in the system script.

Well, ofcourse you can't have it in the "main" item script which is defining the item types. You have to create a script connected to the system script which checks if bullets are being itemized, handling the effect and so on.
(I realize this got confusing as I really don't know what to call the item script part.)
The official japanese ph3 documentation shows an example of these scripts, if you find the itemdata part.
http://www.geocities.co.jp/SiliconValley-Oakland/9951/products/th_dnh_help_v3.html

This works well for making a generic bullet deletion effect, but requires an item to be created
« Last Edit: October 04, 2013, 04:19:09 AM by Darkness1 »

KuroArashi100

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #826 on: October 04, 2013, 06:36:07 AM »
There should be something going on in your script. Maybe show us also your code? (Why don't people show their code and assume that we should use our crystal balls to guess what is happening)
Because it's not something that happens only in that script; it happens in every script, which currently means the ExRumia script, TalosMistake's and Shadow's entry for contest #10, and Darkness1's Yuuka script. It lags on all of them, except for Shadow's entry, where it drops to 30 FPS in the later spellcards.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #827 on: October 04, 2013, 07:12:08 AM »
Because it's not something that happens only in that script; it happens in every script, which currently means the ExRumia script, TalosMistake's and Shadow's entry for contest #10, and Darkness1's Yuuka script. It lags on all of them, except for Shadow's entry, where it drops to 30 FPS in the later spellcards.
Well, you haven't given us this info in your initial post. How are we suppose to know? I have no idea at this moment except for your configuration inside config.exe. ph3 isn't necessary heavier than 0.12m. In fact I think it should run smoother.


KuroArashi100

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #828 on: October 04, 2013, 07:58:04 AM »
Well, if it happened in one script only, I would have posted said script and asked if anybody knew why it was lagging.
But I'll try to be more clear next time.

I don't think I changed any options; it currently is set windowed, the resolution is 640*480 and the third option (frameskip?) is set at the first option.
I don't think key configuration has something to do with it, and I don't know what the option tab does.


trancehime

  • 不聖女
  • *
  • 2017年~ 茨心R (希望)
    • himegimi
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #829 on: October 04, 2013, 01:29:16 PM »
I don't think I changed any options; it currently is set windowed, the resolution is 640*480 and the third option (frameskip?) is set at the first option.
I don't think key configuration has something to do with it, and I don't know what the option tab does.

the option tab just has checkboxes if you want log windows to be open, log files to be saved, and for the cursor to be visible when the program is open

元素召唤 || pad & msl news translator robit
twitter xx motk resident whale

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #830 on: October 04, 2013, 09:05:07 PM »
Your ObjSprite2D_SetDestRect and ObjSprite2D_SetDestCenter are redundant as both have the same function. ObjSprite2D_SetDestCenter automatically centers the image on the object's coordinates while ObjSprite2D_SetDestRect allow you to customize the location of it, so to speak. However, since the ObjSprite2D_SetDestCenter comes after, that may not be what's causing your issue. Have you checked your file paths? Also, it is not necessary to LoadTexture the image. Only v0.12m requires that.
It's always something. I forgot to put the "." when I wrote the file path. csd~"./ is what I should've put.


You misunderstand render priority. It's understandable that you'd be like "well the larger value means it's drawn overtop!" but that isn't the case.
The higher the render priority of an image, the earlier it is drawn. An object with 50 priority will be drawn before an object with 30 priority. However, this means that if the object with 30 priority is drawn at the same position as the other, the one drawn later will be drawn overtop. So, what's really happening is that objects with high priority end up drawn on the bottom, and objects with low priority end up drawn on the top.

The problem is that anything drawn above 80 priority goes before any of the STG frame and you'll essentially never see it.
Damn, that's exactly what I thought. I'll keep that mind when I work on drawing objects.


The version I use for this:
1. Create an "item" script.
2. Make the dissolve effect appear on a bullet getting itemized. You should use white graphics, so you can change the dissolve color with getshotdatainfo (delaycolor).
3. Load and start the script in the system script.

Well, ofcourse you can't have it in the "main" item script which is defining the item types. You have to create a script connected to the system script which checks if bullets are being itemized, handling the effect and so on.
(I realize this got confusing as I really don't know what to call the item script part.)
The official japanese ph3 documentation shows an example of these scripts, if you find the itemdata part.
http://www.geocities.co.jp/SiliconValley-Oakland/9951/products/th_dnh_help_v3.html

This works well for making a generic bullet deletion effect, but requires an item to be created

Hmm, I'll try it this way, but on arby's miko boss I see that he used effect objects to make the dissolve effect though I tried it myself and I was instantly confused on what to do.

Darkness1

  • Nothing to see here.
  • Enigmatic, isn't it?
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #831 on: October 04, 2013, 09:50:38 PM »
Hmm, I'll try it this way, but on arby's miko boss I see that he used effect objects to make the dissolve effect though I tried it myself and I was instantly confused on what to do.
I don't really understand what you mean, since effects are pretty much always effect objects. The method I said uses effect objects too, it just activates them from the event "EV_DELETE_SHOT_TO_ITEM" and uses GetEventArgument(1)[0] and GetEventArgument(1)[1] to get the bullets X and Y positions.     

Here's my entire script files used (except for the main system file): http://pastebin.com/CsS6G2YM
Use with caution, I'm no genius when it comes to these things, but I think it looks good atleast.
I have to look up what method Talos and Arby uses to compare.

Gotta fix those load function placements sometimes, since I'm pretty sure the way I'm spamming LoadSomething; spawns alot of lag. Aswell as spawning two effects per bullet..
« Last Edit: October 04, 2013, 10:01:32 PM by Darkness1 »

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #832 on: October 04, 2013, 11:45:16 PM »
Well arby's doesn't use items, he calls this from the player scripts, I know I would need GetShotIdInCircleA2 but I'm a bit confused on how that function even works.

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #833 on: October 05, 2013, 12:49:27 AM »
Give it x, y, radius and type of bullets to grab. Returns an array of matched object ids.
Finding all the ids that match something (while being deleted) and then doing something based on that seems really awkward.

The way Darkness runs his item script looks a bit weird but in essence it's probably simpler and easier to expand on. By making an item script you can just call CreateItemA1 whenever you need a single case, DeleteShot to TYPE_ITEM for large cases like on pattern completion, etc, and just perform all of the nice item functions now available.

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

Darkness1

  • Nothing to see here.
  • Enigmatic, isn't it?
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #834 on: October 05, 2013, 01:26:12 AM »
Another thing I forgot to mention, you don't actually have to spawn items in the item script. By deleting any item creation function from the event delete_shot_to_item, you could just have the effect activate instead.

GetShotIdInCircleA2 works for some cases, but is also good at doing other things than just deletion effects. The startup code to check for all bullets on the screen and then use their ID-values would be something like this:
Code: [Select]
let shotarray = [];

shotarray = GetShotIdInCircleA2( "X", "Y", "Radius", TARGET_ENEMY);

ascent( i in 0..length(shotarray) ){

//dostuff;

Obj_Delete( shotarray[i] ); //delete the bullet, where shotarray[i] would get the id of each stored bullet.
}

This is similair to the code Talos used and should work. I don't see the reason to use it in the player scripts when system scripts and events should be able to do the same thing.
The function itself should be able to be used in alot of different ways if you're clever with it.

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #835 on: October 05, 2013, 03:30:55 AM »
Actually, thanks for your help guys, I did it using only effect objects.

Anyway, I guess I'll post it so that others can use it too. It doesn't look as smooth as ZUN but close enough I guess.
http://pastebin.com/JjKXgRj9

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #836 on: October 05, 2013, 04:04:25 AM »
Could definitely shorten that last bit:
Code: [Select]
if(timer%4==0){
    ObjSprite2D_SetSourceRect(objde, s*(timer/4), 0, s*(timer/4 + 1), 32);
}
As long as you either moved the 4th and 5th graphics over so they fit, or if you actually used the one between 128 and 160 rather than skipping over it.

You could also just redo your entire loop as
Code: [Select]
DeleteShotAll(TYPE_ALL,TYPE_IMMEDIATE);
ascent(i in 0..8){
    ObjSprite2D_SetSourceRect(objde, s*i, 0, s*(i+1), 32);
    loop(4){ yield; }
}
Obj_Delete(objde);
which would also avoid only using the last rect for one frame before deletion, and would actually delete the bullets the same frame as you start the effect (rather than four frames later).

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

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre18)
« Reply #837 on: October 05, 2013, 05:02:28 AM »
Ah, that works much better. Thanks again Drake.

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre1x)
« Reply #838 on: October 06, 2013, 05:21:29 PM »
nvm, the problem seems to come from the shotsheet not having a shot defined for id = 0. So sometimes the dissolve code breaks the game.
« Last Edit: October 06, 2013, 05:44:47 PM by Infinite Ultima Wave »

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre1x)
« Reply #839 on: October 08, 2013, 03:50:04 AM »
So I noticed that PlayBGM doesn't deleted the old sound anymore, or rather using RemoveSound ---> LoadSound ----> PlayBGM only works if the script that played the song is the same as the one that's playing the new one.

I've also tried various other methods such as using sound objects and playing the music inside of the plural but when you return back to the menu the music continues to play.

I'm building somewhat of a base engine(I call it MOF engine because I use stuff from MOF), the menus and everything else all work fine but it's the playing music part that doesn't work correctly.