Maidens of the Kaleidoscope

~Hakurei Shrine~ => Rika and Nitori's Garage Experiments => Topic started by: Helepolis on March 13, 2014, 09:51:13 PM

Title: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 13, 2014, 09:51:13 PM
Welcome to the Question and Answer (or any problem/help me) thread for ph3.
Great lord of Danmakufu, we hit thread number two.


Please post large code in pastebin.com please. Thanks  :)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 13, 2014, 09:56:44 PM
Last 2 posts from previous thread where Kimidori asked a question. Requested by Sparen for additional information in order to assist proper.

It seem like making a nice flight path and shaped danmaku is hard without much knowledge of Geometry and/or Trigonometry. ._.

I still haven't been able to make a flower shaped danmaku without manually placing bullet to draw them out....

Would anyone be so kind to give me a sample code of drawing a flower with math?
Please elaborate on which kind of flower you are looking for. Talos has used flowers before, and polar/parametric equations can easily generate a flower pattern.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Kimidori on March 15, 2014, 03:09:24 PM
Sorry for the late reply, the flower I want to make is like yuuka 2nd and 3rd spell card in PoFV, without the circle surrounding it, only the petal.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 15, 2014, 03:43:09 PM
Sorry for the late reply, the flower I want to make is like yuuka 2nd and 3rd spell card in PoFV, without the circle surrounding it, only the petal.

Use two angle variables, an ascent loop, and a normal loop

ex:

Code: [Select]
task CreateFlowerA1{
    let angle = GetAngleToPlayer(objBoss);
    let angle2 = GetAngleToPlayer(objBoss);
    ascent(i in 0..24){
        loop(6){
            CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 1.5+i/12, angle, <graphic here>, 5);
            CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 1.5+i/12, angle2, <graphic here>, 5);
            angle+=360/6; angle2+=360/6;
        }
        angle+=7;
        angle2-=7;
        wait(3);
    }
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 23, 2014, 01:08:57 PM
The 'erase' function for arrays is non-existant in ph3, though what is the alternative? The ph3/0.12m list points at 'length' though I am probably missing a vital thinking logic. Current documentation isn't providing insight on this.

I have a set of laser obj ID inside an array upon creation. laserTrackID = laserTrackID ~ [obj]; Basically when the laser disappears, I want the corresponding obj ID to be deleted. However, dumping the entire array is not an option i.e: laserTrackID = [];

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on March 23, 2014, 08:30:07 PM
The 'erase' function for arrays is non-existant in ph3, though what is the alternative? The ph3/0.12m list points at 'length' though I am probably missing a vital thinking logic. Current documentation isn't providing insight on this.

I have a set of laser obj ID inside an array upon creation. laserTrackID = laserTrackID ~ [obj]; Basically when the laser disappears, I want the corresponding obj ID to be deleted. However, dumping the entire array is not an option i.e: laserTrackID = [];
But the erase function still exists.

If you want to define it yourself, it's just a[0..i] ~ a[i+1..length(a)].
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: CK Crash on March 24, 2014, 09:08:57 PM
Just to clarify, even though erase isn't listed on the wiki, it's still in ph3. I guess it went unlisted because it's considered to be in the same class as loop, while, length, etc.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 24, 2014, 09:31:03 PM
You're both right, 'erase' function is still there and managed to get it working as intended, thanks. I'll try to add it tomorrow after some sleep (unless someone goes before me, feel free to)

Edit Done.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Mege on March 27, 2014, 11:05:43 AM
Hello there, first message and first question.

I'm a week new to Danmakufu (and programming in general) so please bear with any "obvious errors" I might type!
Anyway, I was wondering what does the function "ascent" actually do (somebody posted it before regarding flower pattern bullets and I can't find it on the ph3 functions list on the wiki).
Also, I've been practicing my very first codings with knives bullets and I was wondering:
- does the knives bullets hitbox match the one from the official games? They do feel a little off but it might just be the default Rumia sprite!
- when playing full screen the knives seem to be quite grainy (does this make sense? I mean they seem to be low quality). Is it just me, or maybe it's the lack of a background, or are the bullets sprite actually of lower quality?

I apologize for any spelling and grammatical error I might've made as English isn't my native language.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 27, 2014, 03:21:04 PM
Hello Mege, welcome!

Ascent and descent are light weight loops which can hold a variable (for example here, i) to be performed several times (0..<numberoftimes>).
Code: [Select]
// useful function to 'yield' for given number of frames.
function wait(w) { loop(w) { yield; }

// loop four times using the variable i as the counter. This variable can be called within ascent
ascent(i in 0..4) {
CreateShotA1(bossX,bossY,3,90,i,0);
wait(60);
}
The above would fire a bullet every 60 frames (if we remove wait, it would fire them all at once) for total of four times. The bullet's graphic will be the ID of variable i, which changes every time the ascent loop walks through. Descent will count backwards.

About the knives and grainy looks. I know exactly what you're talking about and I wish I could give you a solid response. I'll await the response from someone who was into the graphical things of 0.12m and ph3. It almost seems Danmakufu stretches the screen and doesn't proper apply image resizing. (Makes me feel as if you're using old mspaint). I do remember that someone told us to try to stick to images being power of 2 --> 32x32  64x64  128x128 etc.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Mege on March 27, 2014, 05:58:40 PM
Thanks for your response Helepolis, I do tend to get lost in way too many loops so this function might come in handy.
And bummer about the knives, I usually like to play Touhou full screen, I hope somebody has got some tip for it! A side from that, what about the hitbox, does it match the games one by default?

On a (quite) related note, I hope I'm not going to flood this topic too much and I'll try to merge as many questions as possible in single posts, but still, while coding a lot of doubts arise and tutorials can only go as far, compared to somebody actually helping you out. And by the way, I found your videos about ph3 extremely useful, congratulations on that.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on March 27, 2014, 08:09:44 PM
Could you post a screenshot of the bullets (and if possible a screenshot where you have a background, even if it's the default)? There are a few different things this could be.

In any case, the knife hitboxes will not be the same as they are in the Touhou games. The knife hitboxes in the official games can be wonky anyways, so that might be a good thing lol
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Mege on March 27, 2014, 11:29:52 PM
Could you post a screenshot of the bullets (and if possible a screenshot where you have a background, even if it's the default)? There are a few different things this could be.

In any case, the knife hitboxes will not be the same as they are in the Touhou games. The knife hitboxes in the official games can be wonky anyways, so that might be a good thing lol

Sure thing, here is a screenshot: http://oi58.tinypic.com/r70z9g.jpg
I'm sorry there is no background, I don't know yet how to even add the basic one.
And it's a shame about the hitboxes, the wonkiness was something I actually liked about them, is there any way to make them match the games one? (or at least the sprite size? I feel like the blades are cutting trough me sometimes but the tip doesn't register as a collision. I guess I should find a way to show the player hitbox first to be sure though...).

Thanks in advance.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on March 28, 2014, 05:35:01 PM
I'll be direct: I'm trying to make a bullet spawn other bullets as it flies. Pretty simple. I have the code attached, but it only makes a single little bullet appear at when the large one is spawned. What did I do wrong? Here's the code: http://pastebin.com/E1v4TWjj
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 28, 2014, 07:24:42 PM
I'll be direct: I'm trying to make a bullet spawn other bullets as it flies. Pretty simple. I have the code attached, but it only makes a single little bullet appear at when the large one is spawned. What did I do wrong? Here's the code: http://pastebin.com/E1v4TWjj

You're drastically overthinking this. Use CreateShotOA1 or CreateShotOA2.

Code: [Select]
    task EruptRing{
          //Deleted code here
  let obj = CreateShotA1(GetEnemyX(objBoss), GetEnemyY(objBoss), 3, angleT, 823, 10);
  ObjShot_SetSpellResist(obj, true);
          //More deleted code
    let objangle = ObjMove_GetAngle(obj);
    loop(8){
      let obj2 = CreateShotOA1(obj, 15, objangle, 226, 5);
      BulletCommands(obj2, dir);
      objangle+=360/8;
    }
          //More deleted code
  wait(20);
        }
    }

This code spawns a bullet that spawns bullets on its position every 20 frames using CreateShotOA1. The loop(8) is because I am spawning 8 bullets on top of the parent bullet.

 let obj2 = CreateShotOA1(obj, 15, objangle, 226, 5);

This creates a new bullet on the location of the bullet whose ID is saved at memory address obj, at speed 15 (it changes later), angle objangle, graphic 226, and delay 5.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on March 28, 2014, 07:34:38 PM
Oh, that looks a lot cleaner. Thanks for the help! Just one thing; what's the deal with the bulletcommands thing?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 28, 2014, 08:27:31 PM
Oh, that looks a lot cleaner. Thanks for the help! Just one thing; what's the deal with the bulletcommands thing?

Oh, that's just residual code I forgot to remove. I used that to set speed and angular velocity, then wait and change it again. The speed of 15 was to move it a certain distance from the boss.

If you were wondering:

Code: [Select]
    task BulletCommands(obj, dir){
if(ObjEnemy_GetInfo(objBoss, INFO_LIFE) <= 0){return;}//Default kill to prevent (0,0) spawning
ObjMove_SetMaxSpeed(obj, 0);
ObjMove_SetAcceleration(obj, -5); //Will give 3 frames till 0, which is apx. 45 frames away from start location
wait(30);
ObjMove_SetAngularVelocity(obj, 5*dir);
ObjMove_SetSpeed(obj, 1);
wait(60); //Makes 300 degree turn
ObjMove_SetAngularVelocity(obj, 0);
ObjMove_SetMaxSpeed(obj, 2);
ObjMove_SetAcceleration(obj, 0.05);
    }

And yeah, you don't need to create an OBJ_SHOT and do all of that; CreateShotA1 and the like return the object ID for you. This code affects the bullets created on top of the parent bullet only, and is used to control their activity over a number of frames. Dir is spin direction.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on March 29, 2014, 08:23:09 PM
Sure thing, here is a screenshot: http://oi58.tinypic.com/r70z9g.jpg
I'm sorry there is no background, I don't know yet how to even add the basic one.
Ok so, this isn't unique to your bullets. If you didn't notice, the rest of the screen is also pixelated/aliased. The antialiasing in ph3 just isn't the greatest, and because you're in fullscreen 1440x1080 it looks really pixelated. If your sprites are small and meant for a 640x480 resolution (which is standard), then you're blowing them up to 2.25 times their usual size. You won't be able to fix this really, but if you play windowed at 640x480 you'll see that they look fine.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Mege on March 30, 2014, 09:28:10 AM
Ok so, this isn't unique to your bullets. If you didn't notice, the rest of the screen is also pixelated/aliased. The antialiasing in ph3 just isn't the greatest, and because you're in fullscreen 1440x1080 it looks really pixelated. If your sprites are small and meant for a 640x480 resolution (which is standard), then you're blowing them up to 2.25 times their usual size. You won't be able to fix this really, but if you play windowed at 640x480 you'll see that they look fine.

Yes I noticed everything gets quite pixelated, definitley a shame but if it can't be helped I guess I'll stick with it, thank you Drake!

I now have another problem. A poster above shared this script for spawning bullets from another flying bullet. After seeing it I tought I'd try to use it to re-create the Sakuya's spellcard from the fighting games (http://img2.wikia.nocookie.net/__cb20100927055435/touhou/images/d/d6/UNL_Sakuyaspell1screenshot.png this one).
So, I managed to have the blue knives fly and leave behind them some grey knives, but I can't get these knives to move at all! I'm probably doing something extremely wrong, and my script will look horrendous to you guys, but after being stuck on this matter for 2 days I'm at a loss!  ???

So here it is: http://pastebin.com/VZNpYYW7

The task I'm talking about is the "eruptingKnives" one.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on March 30, 2014, 02:15:34 PM
Yes I noticed everything gets quite pixelated, definitley a shame but if it can't be helped I guess I'll stick with it, thank you Drake!

I now have another problem. A poster above shared this script for spawning bullets from another flying bullet. After seeing it I tought I'd try to use it to re-create the Sakuya's spellcard from the fighting games (http://img2.wikia.nocookie.net/__cb20100927055435/touhou/images/d/d6/UNL_Sakuyaspell1screenshot.png this one).
So, I managed to have the blue knives fly and leave behind them some grey knives, but I can't get these knives to move at all! I'm probably doing something extremely wrong, and my script will look horrendous to you guys, but after being stuck on this matter for 2 days I'm at a loss!  ???

So here it is: http://pastebin.com/VZNpYYW7

The task I'm talking about is the "eruptingKnives" one.


If you want better knife collision then add another "collision = (X,Y,Radius)" to the bullet's ID in the shotsheet. However, if you plan on sharing your scripts, you will need to include the shotsheet with your scripts as well.

Here, I made this which should get you the results you want. You can change the positions and stuff for the main bullet (CreateBulletSpecial)  if you want a different take on the attack.

http://pastebin.com/PU4F8kGN

Also, you don't need to make a angleToPlayer function. Danmakufu has one built in that works. --> GetAngleToPlayer(object);

You also didn't close your script when boss has been deleted (in your end task).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Mege on March 30, 2014, 05:34:14 PM
Thank you Infinite, works perfectly!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TheScriptwriter on April 01, 2014, 09:06:50 PM
Is it possible to smoothStep the boss or bullets? How would I go about writing that code?

I did try to do this myself. I made a basic linear movement but that can be done easier using SetAtWeight/SetAtSpeed/SetAccel/etc. When I tried to make a smoothStep, it just jumps to the end destination (or Worse).
Code: [Select]
task smoothStep(obj, x1, y1, t1){
let t0 = 0; // Start Time
while(t0 != t1) {
let x0 = ObjMove_GetX(obj);
let y0 = ObjMove_GetY(obj);
let dT = t0 ^ 2 * (3 - 2 * t0);
let smoothX = x0 + dT * (x1 - x0);
let smoothY = y0 + dT * (y1 - y0);
ObjMove_SetPosition(obj,smoothX,smoothY);
t0 ++;
yield;
}
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: CK Crash on April 06, 2014, 04:55:49 PM
I've avoided doing this in the past, but I'm redoing my system files and I want to make sure I get everything right...


I know that's a lot of stuff to ask, but I don't want to put months into my script before discovering weird replay desynchs and other bugs. I'm aware that the wiki has the functions, but I'm confused about where they actually apply. Ideally, I'd want to have this stuff handled by the End Scene and Replay Scene scripts...
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on April 06, 2014, 07:26:14 PM
I've avoided doing this in the past, but I'm redoing my system files and I want to make sure I get everything right...

  • In a package script, how should I deal with CommonData for stuff that carries over between runs? (settings, Spell History, unlockables)
  • How should I deal with stuff that doesn't carry over? (choosing a certain route unlocks a secret boss later in the run)
  • How do I make stuff from 1) and 2) interact correctly with replays? (Watching a replay with a non-default number of lives works but doesn't change the user's setting, spell history doesn't change when you watch a replay of that spell, etc)

I know that's a lot of stuff to ask, but I don't want to put months into my script before discovering weird replay desynchs and other bugs. I'm aware that the wiki has the functions, but I'm confused about where they actually apply. Ideally, I'd want to have this stuff handled by the End Scene and Replay Scene scripts...

1: AreaCommonData. Create an AreaCommonData and save it to a file. GT's cut in does this, and both Ozzy's Artifact 1 (I think?) and my DEC demo have examples of the code. (See the config code; it is the clearest)
2: Initialize CommonData in the package and then alter it in the stage. I learned the hard way that if you load one stage and set CommonData in-stage, some of it will be reset when the next stage starts, producing unwanted consequences. I highly recommend initializing all CommonData that is game-specific in the main menu of your package.
3: Replay Comments. Never save CommonData to a replay. After saving it to the replay comment, make sure to initialize the CommonData in your replay save scene, and unload and set CommonData when running a replay in your replay select scene. If you are saving Hi Score, I recommend saving it to an AreaCommonData in the End Scene.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 08, 2014, 03:02:18 AM
Is it possible to smoothStep the boss or bullets? How would I go about writing that code?

I did try to do this myself. I made a basic linear movement but that can be done easier using SetAtWeight/SetAtSpeed/SetAccel/etc. When I tried to make a smoothStep, it just jumps to the end destination (or Worse).
Forgot about this, sorry. You mostly had it right, but you forgot or missed that smoothstep is supposed to bound the interpolated values between 0 and 1. When you increment t0 in your code, it's already 1. To get the smoothstepped value, -2(1)3+3(1)2 = 1, so your delta is 1, then you move to x0 + 1 * (x1 - x0) = x1 and oops you're done already. Notably, if you give smoothstep a value above 1, the squares and cubes will return a larger value than 1. With the input bounded from 0 to 1, you'll return a value between 0 and 1, as intended.
All you need to do instead is have your t0 value go from 0 to 1, so if you want it to last t1 frames, you increase t0 by 1/t1 per frame.

The other problem is just that you were setting a new x0 and y0 every frame. The dT * (x1 - x0) part is your change in x from x0 (origin coordinate), so changing x0 all the time accelerates it and it doesn't work properly (Add back in the x0 = ObjMove_GetX(obj) every frame to see what I mean).

Code: [Select]
task smoothStep(obj, x1, y1, t1){
let t0 = 0; // Start Time
let x0 = ObjMove_GetX(obj); // X-origin
let y0 = ObjMove_GetY(obj); // Y-origin
while(t0 < 1) {
let dT = t0 ^ 2 * (3 - 2 * t0); // Time-delta
let smoothX = x0 + dT * (x1 - x0); // X-origin + X-delta
let smoothY = y0 + dT * (y1 - y0); // Y-origin + Y-delta
ObjMove_SetPosition(obj,smoothX,smoothY);
t0+=1/t1; // Ranges from 0 to 1 over t1 frames
yield;
}
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: bronxterror on April 10, 2014, 11:27:43 PM
I'm sorry if this is a stupid question, but I was wondering how to program collisions.
Well, in specific, I'm trying to make it so that if one type of object collides with another type of object, the latter will be deleted.
Does anyone have any advice?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on April 11, 2014, 08:47:27 PM
This isn't specific to a code or problem, but I've seen codes where tasks are defined with parameters before the brackets, like this:

task thing (param1,param2,param3,etc) {
       blah
}

What do they mean, usually?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on April 11, 2014, 09:13:41 PM
Those are arguments/variables that can be passed through when the task is called.

task Bullet(x,y,s,a){
let angle = a;
CreateShotA1(x,y,s,angle........
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 11, 2014, 09:35:23 PM
Edit: GetObjectDistance works for any object, correct by Drake.

I'm sorry if this is a stupid question, but I was wondering how to program collisions.
Well, in specific, I'm trying to make it so that if one type of object collides with another type of object, the latter will be deleted.
Does anyone have any advice?
You can apply if(GetObjectDistance(EffObj1,anyotherObj) < 32) { <deleteDesiredObj> } which will determine whether the obj is within 32 distance from each other.

You can also use, If I am not mistaking: (x2-x1)^2 + (y2-y1)^2 <= (r1+r2)^2   where r = radius. Example: (mind the parentheses, they can be annoying around the ObjMove code.)
Code: [Select]
if( (ObjMove_GetX(obj1) - ObjMove_GetX(obj2))^2 + (ObjMove_GetY(obj1) - ObjMove_GetY(obj2))^2 <= (radius1 + radius2)^2 ) { <deleteDesiredObj> }
Those are arguments/variables that can be passed through when the task is called.

task Bullet(x,y,s,a){
let angle = a;
CreateShotA1(x,y,s,angle........
}
The same can be achieved without declaring angle and just instantly parsing 'a' into the task. I think in this case your example is redundant.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on April 12, 2014, 12:14:16 AM
The same can be achieved without declaring angle and just instantly parsing 'a' into the task. I think in this case your example is redundant.

That is to demostrate how you can use it. It isn't a question of redundancy; it also gives you an idea of how to somewhat control the information passed through the variable since task/function arguments can't be changed you would insert it into another variable.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 12, 2014, 05:18:35 AM
If you're using bullets/lasers, this function cannot be used.
Wut. GetObjectDistance() works with any objects.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 12, 2014, 07:04:41 AM
Wut. GetObjectDistance() works with any objects.
Why is the wiki confusing us then  :ohdear:
/me reads mkm documentation
I see, it mentions none of this so we'll need to fix the wiki.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TheScriptwriter on April 13, 2014, 01:13:22 AM
Forgot about this, sorry. You mostly had it right, but you forgot or missed that smoothstep is supposed to bound the interpolated values between 0 and 1...
...All you need to do instead is have your t0 value go from 0 to 1, so if you want it to last t1 frames, you increase t0 by 1/t1 per frame.
Thanks for this, as this was the only part I was messing up because I didn't fully understand. Because I was too busy overthinking it (ex. "How Do I make sure it moves to X location at X amount of frames..."). This was kind of important for me so thank you again.

Now, If I wanted to do a mirrored version of the smoothstep (from Origin to Target and back), I would have to divide Time(t1) by half, then have it smoothstep the first half and then the other half, so that it moves within the full time specified before I divided t1?
Also, do I have to break the smoothstep if I call another movement?

Also, how do I make sure any movement that I do (with the ObjMove functions) move to the location that I want at the time that I want?

Oh, and Length is listed under Other Functions but is Not listed in the Functions Main page.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 13, 2014, 09:07:48 AM
Now, If I wanted to do a mirrored version of the smoothstep (from Origin to Target and back), I would have to divide Time(t1) by half, then have it smoothstep the first half and then the other half, so that it moves within the full time specified before I divided t1?
I'm not entirely sure what you're looking to do here. This sounds like you would smooth start, smooth into the destination, smooth start back, and smooth back into the origin. If this is what you want, then yeah it would just be two smoothstep moves at half the time each.
Quote
Also, do I have to break the smoothstep if I call another movement?
Mostly depends on whether the movement method either:
1) Changes movement speed and/or angle
2) Changes movement position based on current position
3) Changes movement position based on precalculated position
Your current smoothstep does #3, and so would override any other movement you'd try to apply until it's done.

Quote
Also, how do I make sure any movement that I do (with the ObjMove functions) move to the location that I want at the time that I want?
Well, ObjMove_SetDestAtTime() is pretty much exactly that. If you want more complicated movement to work within a number of frames you'd have to write it up yourself or precalculate how much time you need.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: rikako_asakura on April 13, 2014, 02:13:03 PM
How do I use custom fonts? I'm trying to change the font on the DefaultSystem, but all I get is Arial instead of the font I want.

Here is my code.
Code: [Select]
@Initialize
{
InitFrame();
TScore();
TGraze();
TPlayerLife();
TPlayerSpell();
TBossLife();
TBossTimer();
TCurrentFps();
TReplayFps();
InstallFont(dirCurrent~"ImpressBT.ttf"); //this is a line I added for the font
}
[...]
task TScore()
{
let objScore = ObjText_Create();
ObjText_SetFontType(objScore, "ImpressBT.ttf"); //this is another line I added to change the font
ObjText_SetText(objScore, "Score");
[...]
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TheScriptwriter on April 13, 2014, 02:14:56 PM
This sounds like you would smooth start, smooth into the destination, smooth start back, and smooth back into the origin. If this is what you want, then yeah it would just be two smoothstep moves at half the time each.
Yep. That's what I want, so that's what I'll do.
Well, ObjMove_SetDestAtTime() is pretty much exactly that. If you want more complicated movement to work within a number of frames you'd have to write it up yourself or pre-calculate how much time you need.
Well, it's like I want to combine ObjMove_SetDestAtFrame and ObjMove_SetDestAtWeight/Acceleration together, where the obj speeds up or slows down to the desired position, but within the time I choose.
But from what you say, I would have to make something like that on my own.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: ExPorygon on April 13, 2014, 08:38:15 PM
How do I use custom fonts? I'm trying to change the font on the DefaultSystem, but all I get is Arial instead of the font I want.
For ObjText_SetFontType you have to specify the name of the font, not its file name. Double click on the font file to display information about it, including its name.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on April 14, 2014, 12:15:10 AM
How do I use custom fonts? I'm trying to change the font on the DefaultSystem, but all I get is Arial instead of the font I want.

I threw together a section on fonts.

http://dmf.shrinemaiden.org/wiki/Sparen%27s_0.12m_to_ph3_Transition_Guide#Fonts (http://dmf.shrinemaiden.org/wiki/Sparen%27s_0.12m_to_ph3_Transition_Guide#Fonts)

I hope it is helpful.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: rikako_asakura on April 14, 2014, 09:29:07 AM
For ObjText_SetFontType you have to specify the name of the font, not its file name. Double click on the font file to display information about it, including its name.

I threw together a section on fonts.

http://dmf.shrinemaiden.org/wiki/Sparen%27s_0.12m_to_ph3_Transition_Guide#Fonts (http://dmf.shrinemaiden.org/wiki/Sparen%27s_0.12m_to_ph3_Transition_Guide#Fonts)

I hope it is helpful.

Thank you to both of you! I managed to get it to work.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Gusano Wornis on April 14, 2014, 08:50:01 PM
how to replay comments?

just asking because page 1 :v
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on April 14, 2014, 09:24:30 PM
A replay comment is just a string. We can use this to transfer commondata back and forth between replays by storing them all as strings and then splitting them up again before the replay starts.

RPS = IntToStrin(GetCommonData("Something",0)) ~"/"~IntToStrin(GetCommonData("Something",0))~"";

Use SplitString to break them apart by a certain character like "/". SplitString(RPS,"/"); split the string into an array every time it reads a "/" symbol

of course, RPS would be SplitString(GetReplayInfo(indexreplay,REPLAY_COMMENT),"/");

Alternatively we can use SaveCommonDataToReplay which would be easier to manage but replays are almost certain to break if you save too much (anything more than 1 piece of commondata and it will always save off synced replays). So replay comments are a nice workaround to ensure that you won't have any problems.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chuckolator on April 17, 2014, 02:24:48 PM
oh wait, wrong thread. my bad, delete this <_<
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lunarethic on April 21, 2014, 09:46:33 AM
why is does this code keep spawning bullets on the topleft corner of myscreen? o.O even though theres nothing that i said to make it like that
http://pastebin.com/pK3ty7xD
like this
(http://i57.tinypic.com/2vbkgol.png)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 21, 2014, 10:46:37 AM
ObjMove_GetX() defaults to 0 when the object referenced is deleted, or if the id doesn't correspond to any object. The parent bullets are being deleted somehow (going off-screen?) but the task keeps running, so when the child bullets are fired they spawn at (0, 0).

While we have that code posted, I should mention that rather than having those two bullet tasks, you can easily merge them into one just by having another parameter like dir_inc or something so where you have that dir += 10; or dir -= 10; you just say dir += dir_inc; . Similarly you can squash the two testfire tasks into one by giving it one parameter that changes dir+= 15; and dir-=30; into dir+= whatever; and another parameter that goes directly into the objectbullet call like objectbullet(bossX,bossY,5,8,dir,0.50,65,10,dir_inc); .

If you can see what I mean it might make it a bit easier to modify later on and it cuts down on repeated code.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on May 01, 2014, 10:12:10 PM
I'm trying to make an object spawn other objects when it hits a side, but I'm not sure how to use ObjShot_AddShotA1 within it. I've messed around with locations of functions, but nothing works correctly. Here's my code:

task bulletProp(obj) {   
   while(!Obj_IsDeleted(obj)) {
      if(ObjMove_GetX(obj) < 0||ObjMove_GetX(obj) > 376) {   
         let bullet2 = ObjShot_Create(OBJ_SHOT);
         ObjShot_Regist(bullet2);
         ObjMove_SetSpeed(bullet2,2);
         ObjShot_SetGraphic(bullet2,144);
         ObjShot_SetDelay(bullet2,5);
         ObjMove_SetAngle(bullet2,180-ObjMove_GetAngle(obj));
         
         loop(4) {
            
            ObjMove_SetPosition(bullet2,ObjMove_GetX(obj),ObjMove_GetY(obj));
            ObjShot_AddShotA1(obj,bullet2,1);
            wait(2);
         }         
      }
      
      if(ObjMove_GetY(obj) < 0) {
         ObjMove_SetAngle(obj,-ObjMove_GetAngle(obj));
      }
      yield;
   }
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on May 02, 2014, 02:27:41 AM
What this currently does is check if obj is outside the x-boundaries, and if so, create new shot object bullet2 and fire it. Then set bullet2's position to be the same as obj, wait two frames; repeat this four times with the same bullet2 object. That is, if you removed the AddShotA1() call. If you removed the SetPosition(), you might get a flicker of a bullet before it vanishes. Before anything else I'd like you to comment out the AddShotA1(), then change the wait(2) to wait(20) and see what happens. Once you do that, comment out the SetPosition() instead (keep the wait(20)) and see what happens then. It might help you realize what's actually going on with your current code.

That being said, you were close in the sense that if you rearranged and removed some things it would have worked, but functionally it was pretty far off.
Code: [Select]
while(!Obj_IsDeleted(obj)) {
   if(ObjMove_GetX(obj) < 0||ObjMove_GetX(obj) > 386) {   
      loop(4) {
         let bullet2 = ObjShot_Create(OBJ_SHOT);
         // set up bullet2
         ObjShot_AddShotA1(obj,bullet2,0);
      }
   }
   if(ObjMove_GetY(obj) < 0) {
      ObjMove_SetAngle(obj,-ObjMove_GetAngle(obj));
   }
   yield;
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on May 02, 2014, 03:03:54 AM
This works, but it spawns all of the bullets on top of each other. How could I configure it so that they spawn with a noticeable delay between each fire?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on May 02, 2014, 04:09:50 AM
That was intentional, I was hoping you'd modify it from there. Well, the last parameter of AddShotA1() is the number of frames afterward to fire the bullet, so if you want to fire each bullet from wherever obj is at the time, you can change that depending on when you want the other bullets to fire (the way it is, it might go offscreen first, though). Or, you could just shoot the new bullet from obj's position in the first place, and wait() a bit after you fire each bullet to do effectively the same thing.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on May 02, 2014, 04:24:13 AM
I guess I should've been more specific; when I add a value for the wait(), only one bullet spawns at a time, but when I change the last parameter, it spawns 4x+4 bullets on top of each other where x is the parameter.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on May 02, 2014, 05:04:44 AM
So, you loop through that bullet code four times and say for each new bullet you tell them to fire from the parent after n frames. What do you think is going to happen after n frames? All four bullets will fire. You have to give each one a different number of frames to fire after.

As for the increasing number of bullets, say you finish your loop of four bullets. The script then does the top-boundary check, then yields. What happens on the next frame? It does the x-boundary check again. And the parent bullet will still be over the boundary, and the whole thing will run again. So each frame it's going to add four more bullets to fire at time n, up until you actually get to time n.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on May 16, 2014, 03:10:25 AM
I've been trying to figure out how to make a decent background for scripts, but I have no idea what any of the effect/image/whatever functions do or how to use them. Is there any sort of guide for drawing BGs in ph3?

EDIT: I'm asking because the wiki's ph3 tutorial is missing the background functions section and it'd be really inefficient to learn 0.12m's functions and translate them.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on May 17, 2014, 08:16:06 AM
I've been trying to figure out how to make a decent background for scripts, but I have no idea what any of the effect/image/whatever functions do or how to use them. Is there any sort of guide for drawing BGs in ph3?

EDIT: I'm asking because the wiki's ph3 tutorial is missing the background functions section and it'd be really inefficient to learn 0.12m's functions and translate them.
Aye, it is completely gone the @BackGround. In ph3, create a regular 2D sprite and set the drawing priority type to the background value.
http://dmf.shrinemaiden.org/wiki/Object_Functions#Obj_SetRenderPriorityI

For example:
Code: [Select]
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
<etcetc for the scale,rect,etc>
Obj_SetRenderPriorityI(obj,20); // code to decide render priority which is basically a value between 0-100 afaik.

An object having priority 80 will be drawn on top of a one with a lower value. You can for example layer things on top of each other more precisely like this. So less worrying about code order some what.  The somewhat traditional drawing order from 0.12m are in effect. For example drawing stuff on values 80+ will be drawing it on top of the player/bullet/etc. Example 2:
Code: [Select]
Obj_SetRenderPriorityI(obj,20);  ( Background layer )
Obj_SetRenderPriorityI(obj,30);  ( Player layer)
Obj_SetRenderPriorityI(obj,31);  <--- will be drawn on top of the 30 value because 31 is > 30.
Obj_SetRenderPriorityI(obj,80);  ( HUD layer )
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Fumi on May 20, 2014, 10:54:02 PM
Hello!

I don't know if this is the correct place to ask but I have a few questions and a possible request
Sorry for possible bad English :<

-Is there any equivalent for pH3 for the function SetMovePositionHermite? If there isn't, I'd love if someone could reply with an equivalent :<

-Recently I tried to make a library for effects, I tried to make the new DDC styled pentagram (the one with slow 3D rotation) but with no success, as I don't actually know how 3D graphics work in pH3

Here is my function

Code: [Select]
task MagicCircleV3() {
/*placed on the main loop
Creates a Magic Circle that follows the boss around
DDC styled circle, rotates in XYZ slowly
*/
let angle = 0;




let circle = ObjPrim_Create(OBJ_SPRITE_3D);
ObjPrim_SetTexture(circle, imgEffect);

let enmx = ObjMove_GetX(objEnemy);
let enmy = ObjMove_GetY(objEnemy);
let x1 = -128;
let y1 = -126;


//ObjRender_SetAlpha(circle, 150);

while(!Obj_IsDeleted(objEnemy)) {
ObjSprite3D_SetSourceDestRect(circle, 127, 81, 255, 206);
ObjSprite3D_SetDestRect (circle, x1-128, y1-125, x1, y1);


ObjRender_SetX(circle, ObjMove_GetX(objEnemy));
ObjRender_SetY(circle, ObjMove_GetY(objEnemy));

//ObjRender_SetAngleX(circle, angle);
//ObjRender_SetAngleY(circle, angle);
//ObjRender_SetAngleZ(circle, angle);


angle++;
yield;
}


}

-I'm also trying to make the charge animation that features petals/snowflakes/leaves but besides from the problems shown above, each time I try to draw something outside from the screen, it gets stuck on the edges. Also any idea how to actually move primitive objects? idk if graphics type objects should be threaten as such, because the ObjMove functions seem to not work on them....

Here is the code
Code: [Select]
//ObjRender_SetAlpha(petal, 150);


ObjSprite2D_SetSourceRect(petal, 194, 230, 221, 249);

ObjSprite2D_SetDestCenter(petal);

ObjRender_SetAngleX(petal, angle);
ObjRender_SetAngleY(petal, angle);
ObjRender_SetAngleZ(petal, angle);


ObjMove_SetDestAtSpeed(petal, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 5);
angle=angle+round(rand(0,5));

}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on May 21, 2014, 04:52:28 AM
Note sure why you're using ObjSprite3D_SetSourceDestRect() and then ObjSprite3D_SetDestRect(). More than that, for your purposes I don't think you need a 3D Sprite object, just a 2D Sprite object. They're both Render objects and so can use the functions you want. First just make a 2D Sprite object that follows the boss. Then use SetAngleZ() to spin it, then use SetAngleX() and Y() to spin the rest.

As for your second problem, Sprite objects aren't Move objects, so you can't use Move functions on them.

(http://nazr.in/6qe)

In order to move around Render objects you'd have to define your own movement functions for them. For SetDestAtSpeed() this is just some pythagoras:
Code: [Select]
task ObjRender_SetDestAtSpeed(obj, x, y, s){
    let ox = ObjRender_GetX(obj);
    let oy = ObjRender_GetY(obj);
    let dist = ((x-ox)^2 + (y-oy)^2)^0.5;
    let dx = (x-ox)/dist*s;
    let dy = (y-oy)/dist*s;
    loop(floor(dist/s)){
        ox += dx;
        oy += dy;
        ObjRender_SetX(obj, ox);
        ObjRender_SetY(obj, oy);
        yield;
    }
    ObjRender_SetX(obj, x);
    ObjRender_SetY(obj, y);
}

This won't have exactly the same behaviour as the Move version simply because Render objects don't have any movement speed or angle properties. If you call it multiple times on the same object, the one called last takes priority but if it finishes before the other calls would, the object will jump to the position it would be at with the other calls. It isn't a big deal since if you wanted to stack movements you would do something different anyways.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on May 21, 2014, 02:41:56 PM
I tried to make that simple 2D background, but it won't work. I made sure to call the background script, so what did I do wrong with it?

let img = ObjPrim_Create(OBJ_SPRITE_2D);
let imgBg = GetCurrentScriptDirectory ~ "resource_img/background.png";

ObjPrim_SetTexture(img,imgBg);
ObjSprite2D_SetSourceRect(img,0,0,256,256);
ObjSprite2D_SetDestCenter(img);
Obj_SetRenderPriorityI(img,20);
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on May 21, 2014, 08:46:49 PM
You have the source rectangle and destination mapped but no object position. It's going to default to (0, 0). Aside from that it should work; really right now it should look like the bottom-right quarter of the image is sitting in the top-left corner of the screen.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on May 21, 2014, 09:18:19 PM
I defined the position, but the image doesn't even appear. Do I have to set a blend type or something?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on May 21, 2014, 10:24:33 PM
No, it means you did something else wrong. Are you sure the background script is run? Put something easily verifiable in it like a CreateShot or something to make sure it's called. Make sure the image is actually being loaded; you can do this by checking the first option under Option in the config.exe, and checking the Texture tab when the game runs.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on May 21, 2014, 11:10:33 PM
I'm sure that the script is being called because Danmakufu recognized errors in it when I tried to make the sprite appear. And it turns out that the texture wasn't being loaded, but I have no idea why this should be the case.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on May 22, 2014, 05:37:34 AM
You're not being enough sure. Errors popping doesn't necessary mean anything aside then you made mistakes with the code.

When in doubt, debugging out. As Drake suggested, put noticeable things in the script that will assure you the function/script is called. I usually either use sound effects or text drawing on screen. If the script/function is in fact active, try to replace your image with something else that worked in the past as well and see how that turns out.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on May 22, 2014, 12:43:34 PM
Generally what I do is use the log window, as well as WriteLog to make sure something is being ran or checking the returned result of a function (like if true or false).

Also, danmakufu will display an error if the graphic was not found in the Log tab and you won't see it in the Texture tab either. Pathing is usually the case with images not showing up other than render priorities.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on May 22, 2014, 02:59:06 PM
I figured out what my mistake was; I tried to call the script with #Background, but I guess that only works for 3D sprites or something, since this only worked with #include. Thanks for the help!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on May 22, 2014, 08:55:32 PM
The problem is that you were loading a file that wasn't a script in #Background. It works with #include because its a task/function.

A script file must contain atleast @Initialize{} to be considered a script.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: MCXD on May 23, 2014, 03:50:51 AM
Oh boy, so after a few years away from danmakufu I come back to find a new version. I've been playing around with it for a few days, but I have a couple of basic questions:

a) Here is the 'boss defeated' task in the example ExRumiaSpell01 that comes with ph3:
Code: [Select]
task TEnd
{
while(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) > 0)
{
yield;
}

let ex = ObjMove_GetX(objEnemy);
let ey = ObjMove_GetY(objEnemy);
TExplosionA(ex, ey, 10, 0.6);
DeleteShotAll(TYPE_ALL, TYPE_ITEM);//敵弾を全て削除
Obj_Delete(objEnemy);

loop(30){yield;}

CloseScript(GetOwnScriptID());
}
The problem with it is, during the 30 frames of waiting before the script is closed, any loops that are running will continue running... which is an issue for some cards I've been playing around with to relearn the ropes, because it means that bullets will continue spawning for 30 frames after the boss dies (at 0,0 as it happens, because after the boss object is deleted I guess it defaults a GetX/Y for a non-existant object to 0). I can fix that by removing the 30 frames of waiting and closing the script immediately, but then the cool little explosion animation won't play, because that requires the script to be open. In general, how can you script it so that bullets cease being fired when the boss dies, but there is still time for death animations to occur, without adding an "If (ObjEnemy_GetInfo(objEnemy, INFO_LIFE) > 0)" to every single CreateShot?

If you want a specific example of what I'm talking about; consider the following scenario:
Code: [Select]
...

@Initialize {
int;
main;
close;
ObjMove_SetDestAtFrame(objBoss, cx, cy, 30);
}

...

task int {
//Boss drawing stuff
}

task main {
  loop{
    loop(30){yield;}
    CreateShotA1(ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),3,90,1,10);
    }
}

task close {
 //What should I put here so that bullets cease being fired and an explosion animation plays in full when the boss is reduced to 0 life?
}


b) Is there any default/built-in functionality for spell card names and cutins in Ph3, or do you have to code it all yourself now? If you have to do it yourself, does anyone have any cool templates/snipets I can use for it?

c) Is there a good, balanced, generic player script available for ph3? The default one is a bit buggy (deals damage while not firing when holding down shift, for example).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on May 23, 2014, 04:12:10 AM
To answer your first question, no however you can use while(){} instead of loop{}. Generally what I do is add if(ObjEnemyblahblhalblah){return;}  to any yielding loops which is easier than adding that line everytime you create a bullet.

As for your second, you have to create cutins and stuff on your own. Shouldn't be that hard to do. There are plenty of good player scripts out there, balanced is dependent on how the person who made them manages health for the bosses. Mr.Blue's players worked for me just fine until I created my own players.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: MCXD on May 23, 2014, 04:31:03 AM
To answer your first question, no however you can use while(){} instead of loop{}.

Like this?

Code: [Select]
task main {
  while(Obj_IsDeleted(objBoss)!=true){
    CreateShotA1(bx,by,3,45,1,10); wait(10);
    CreateShotA1(bx,by,3,45,2,10); wait(10);
    CreateShotA1(bx,by,3,45,3,10); wait(10);
    CreateShotA1(bx,by,3,45,4,10); wait(10);
    CreateShotA1(bx,by,3,45,5,10); wait(10);
  }
}

Because that didn't work. It only checks the while condition at the start of the loop, so if it's in-progress it keeps spawning bullets after the boss died until its conclusion.

Generally what I do is add if(ObjEnemyblahblhalblah){return;}  to any yielding loops which is easier than adding that line everytime you create a bullet.

Like this?

Code: [Select]
task main {
  loop{
    fire(1); wait(10);
    fire(2); wait(10);
    fire(3); wait(10);
    fire(4); wait(10);
    fire(5); wait(10);
  }
}

function fire(graphic) {
if (Obj_IsDeleted(objBoss)==true){return;}
CreateShotA1(bx,by,3,45,graphic,10);
}

Because that DID work, though I'm not sure it's what you meant.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on May 23, 2014, 05:42:55 AM
The above works because it checks first if the boss is deleted before it continues to fire the bullet. You can shorten that up to just  if(Obj_IsDeleted(objBoss)) {}. The function Obj_IsDeleted() throws back a boolean in the first place, so comparing it with a == operator and boolean is redundant for writing out. The Obj_ and !Obj_ will save you some typing.

Additionally you can replace loop {}  with while(!Obj_IsDeleted(objBoss)) {} which also does the trick (and looks more tidy). Basically this roughly translates into:  As long as the boss object IS NOT deleted, perform this loop. When Obj_Delete(objBoss); is called somewhere, the loop will logically be executed if it was already running so potential bullets might be spawned at 0,0 if they had been delayed in some way. Only any other task which was about to start will be prevented from running. 0.12m used to kill all loops/threads/tasks itself but ph3 doesn't understand any of that, hence even if you deleted the boss the script remains alive until closed. You need to plan this careful.

For custom cutins and ideas or usable templates: http://www.shrinemaiden.org/forum/index.php/topic,2146.0.html



Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on May 23, 2014, 12:32:50 PM
Like this?

Code: [Select]
task main {
  loop{
    fire(1); wait(10);
    fire(2); wait(10);
    fire(3); wait(10);
    fire(4); wait(10);
    fire(5); wait(10);
  }
}

function fire(graphic) {
if (Obj_IsDeleted(objBoss)==true){return;}
CreateShotA1(bx,by,3,45,graphic,10);
}

Because that DID work, though I'm not sure it's what you meant.

No I meant, whenever you yield in script. In your case you use a wait function like a lot of other people do (I don't). So you may have trouble doing this. because return will only end the task/function it was used in.

I don't use a wait function for this exact reason.

What I do: loop(num){if(ObjEnemy_GetInfo(objEnemy,INFO_LIFE)<0){return;}yield;}.

loop(num){if(!Obj_IsDeleted(objEnemy)){return;}yield;} this also works too.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on May 24, 2014, 07:32:26 PM
Why not have the return condition after the yields only once rather than checking every frame.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on May 25, 2014, 12:21:44 PM
I guess that could work too, its just me wanting to be perfect in terms of when to end the task.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: CK Crash on May 26, 2014, 01:18:42 PM
IMHO it's easier to:

1) Make the yield in @MainLoop conditional based on boss life, closing the script as soon as the boss dies.
2) Use external scripts to handle death effects to compensate for the inability to use a "TEnd task", using LoadScript and StartScript in @Finalize.

There are pros and cons to both methods, but I find that this is less intrusive to your pattern code than putting break points for every possible time your boss could run out of life.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on May 31, 2014, 11:17:15 AM
I had this interesting pattern/style for my noncard but as usual my Math-weakness kicks in hard to project my thoughts onto code. I have tried various things so please take the time to read into this.

I have 2 objects, a rectangle "floor" and a bullet Obj (presenting the balloon).  The floor is a simple 2D sprite with a while loop for behaviour purpose. The balloon obj bullet is just a simple bubble bullet for now. It has also a while loop in case required. The balloon object is defined globally, and thus can be mutated from any task/function. What I wanted as a gravity effect for the balloon that it keeps falling to the floor (Maximum Y of the field). However, if it interacts with the "floor" object, it will stop. The floor can move up/down.

Well the stopping part is easy to realise as I used the Intersected Line circle code (see below). I also did a test by simply making the bullet fall with direction 90 and speed 1. I had put ObjMove_Setspeed(balloonObj,0); next to the "yes" debug checking (used to check whether the obj is colliding). So far so good. Although what if I actually want to bounce the balloon back into the air? And preferable with an increased speed?

Not sure if anybody remembers Aniki script (yes, it is horrible one but the same mechanics were used there). See here www.youtube.com/watch?v=jLqmwnIW0ac#t=4m54s (nsfw possibility) Basically I'm seeking for the similar effect. The floor bounces the bullet back with a certain speed. The balloon will take a natural flight back into the air.

This is the part I cannot manage. I am to be honest clueless on how to get the direction and speed reversal in place. Or perhaps keep the speed but change the dir? Trying things like reversing the direction or speed didn't obviously help. Man I really wish my math was better orz

http://pastebin.com/UDjsPFsj
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Blargel on June 01, 2014, 08:12:30 AM
IT'S OKAY I GOT THIS.
ON IRC.
WITH 0.12M EXAMPLES.

http://pastebin.com/TJK5xTp1
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on June 01, 2014, 09:18:21 AM
Works like a charm. Thanks Blargel. I added the bounce code statements result in the intersection line circle part and now my rectangle "floor" pushes the balloon back. It is not changing angles so that saves us the trouble I assume.


Some different problem I bumped in and it felt really odd.

During the sprite adjusting of my floor I noticed something weird. My sprite is 256 wide and 128. So logically I set this code:
Code: [Select]
ObjRender_SetScaleXYZ(obj,1.0,1.0,0);
ObjSprite2D_SetSourceRect(obj,0,1,256,128);
ObjSprite2D_SetDestCenter(obj);
Now comes the odd part. The floor logically doesn't covers the entire width of my field, so I simply increased the value to 512 for example, so the texture gets repeated, right? Wrong.

The texture is actually stretched instead of repeated as in 0.12m. I started fiddling with various of functions and parameters such as using ObjSprite2D_SetDestRect as well but none of them had effect. This is quite weird as 3D sprites do repeat themselves if I set them (at least, as far as I can remember when I building my 3D stages. So what is the deal with 2D sprites?

Edit
This is embarrassing that I never had encountered this issue. Using SpriteList2D instead of regular Sprite2D will fix this problem. Thanks Drake for pointing it out.

Edit 2:
Apparently SpriteList2D does not listen to any of the SetAngle functions. Not the render, not the Move and also not the XYZ one. The hell is wrong right now.

Edit3:
Posted on bbs of dnh to see what Mkm has to say about it.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Mahou Shoujo Nel! on June 05, 2014, 04:43:23 PM
Well... She just does nothing....
http://pastebin.com/zWEGJgUd
I'm new to ph3 , switched from 12.m .... its a pain ;-;
I hope anyone can tell me what I'm doing wrong

Edit: About this one: Its my first attempt, I'm using helepolis tut. and  im not futher yet.
         I'm despairing...
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on June 05, 2014, 09:48:44 PM
You have no shot script included. Please check the tutorials carefully. Exame scripts are also available to compare. :)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on June 05, 2014, 10:00:23 PM
I think more important is the misspelling of @MainLoop.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Mahou Shoujo Nel! on June 05, 2014, 10:21:19 PM
I think more important is the misspelling of @MainLoop.
... :colonveeplusalpha:
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: PhantomSong on June 09, 2014, 12:48:00 AM
I think more important is the misspelling of @MainLoop.
That wouldn't be a spelling...  It's just a capitalization error...
Mainloop vs MianLoop the former is not a spelling error, the latter, is. (Just thought so you can know the difference).

But, yeah, just make sure you capitalize properly, Danmakufu is picky like that.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on June 09, 2014, 02:24:13 AM
I want to make a simple stage script with a few enemies, and I wanted to know if the CreateEnemyFromScript function exists in ph3 or has an equivalent.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on June 09, 2014, 03:49:37 AM
No, ph3 does not have that function. While you can make it yourself, I've found it easier to task enemies.

task Fairy{
let obj = ObjEnemy_Create(OBJ_ENEMY);
ObjEnemy_Regist(obj);
ObjEnemy_SetLife(obj,100);
ObjPrim_SetTexture(obj,);
ObjSprite2D functions go here
separate task to handle the enemy's hitbox would be called here or you can handle the enemy's hitbox directly in the task.
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on June 09, 2014, 03:57:38 AM
You can use StartScript() to start a new Single script or Plural script or whatever else. If you want a wrapper around your enemy so it has its own @Initialize, @Event and so on, then you could use StartScript(). However, in ph3 an enemy isn't defined by a script it's in, so you don't really have to call a script in particular. For generic enemies you can simply create an Enemy object and do things with it just as you otherwise would from inside a Single script.

That wouldn't be a spelling...  It's just a capitalization error...
Mainloop vs MianLoop the former is not a spelling error, the latter, is. (Just thought so you can know the difference).
:|
It is a programming language. Any sort of syntactical error involving words could be called a spelling error; the interpreter doesn't care that it's lowercase, it's still an entirely different character. Why would you even need to point this out.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: PhantomSong on June 09, 2014, 05:36:43 AM

:|
It is a programming language. Any sort of syntactical error involving words could be called a spelling error; the interpreter doesn't care that it's lowercase, it's still an entirely different character. Why would you even need to point this out.
But you're talking to humans, not a computer. A spelling error to a human means missing word, extra word, or misplaced words. Not capitalization.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on June 09, 2014, 07:20:43 AM
The dude clearly knew what I was talking about, and I'm pretty sure they're human. It should be immediately obvious to anyone looking at his code and my post that the problem was that he had typed @Mainloop instead of @MainLoop. Unless you intend to suggest that somebody would have read my post stating @MainLoop was misspelled, figured to themselves "but they are spelled the same" and didn't understand the problem despite the difference, then there really isn't an issue worth correcting here. It was a simple error, he got it. Again, why is this a big deal.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on June 09, 2014, 11:49:29 AM
No, ph3 does not have that function. While you can make it yourself, I've found it easier to task enemies.

task Fairy{
let obj = ObjEnemy_Create(OBJ_ENEMY);
ObjEnemy_Regist(obj);
ObjEnemy_SetLife(obj,100);
ObjPrim_SetTexture(obj,);
ObjSprite2D functions go here
separate task to handle the enemy's hitbox would be called here or you can handle the enemy's hitbox directly in the task.
}
No matter where I declare the hitbox functions, the enemy is untouchable and unshootable. Here's my script for reference: http://pastebin.com/DKjU9Hdd
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on June 09, 2014, 12:08:23 PM
ObjEnemy_SetIntersectionCircleToShot(enemyObj,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),16);
ObjEnemy_SetIntersectionCircleToPlayer(enemyObj,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),10);

You have these outside of the while loop in that task. Therefore the enemy only had a hitbox for one frame, in order to keep the hitbox running place the two functions inside of the loop.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on June 09, 2014, 07:10:53 PM
This is really weird. My second enemy task doesn't spawn the hitboxes for the enemies, no matter which animation task I use. Here's the code: http://pastebin.com/H2ewGFPs
And here's how I'm using this task in case that makes a difference:
loop {
      spamFairy(+5,30);
      spamFairy(2*cx-5,150);
      wait(100);
}

(cx is the center x-value)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on June 13, 2014, 07:23:01 AM
Not sure about it, but you are using wait(8); functions inside the animation script where also the hitbox is handled. A hitbox needs to be updated every frame. If you delay such important threads then your hitbox will be poorly updated or not at all perhaps.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on June 13, 2014, 09:22:50 AM
Yeah that seems to be the case, but it's actually worse than that since those are performed inside an infinite loop. If the fairy ever gets to the sixth animation frame of moving left or right, it will just loop those three animation frames forever. The hitbox, zero life, and out-of-range handling never gets called after that point.

1) You should probably be putting the hitbox code and whatnot inside a separate task that loops every frame anyways, just as habit.
2) Restructure your drawing code on those (f2 >= 25) parts so it doesn't loop forever.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on June 13, 2014, 08:33:05 PM
That would certainly do it.  :V
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on June 13, 2014, 09:18:52 PM
If a loop or tasks contains multiple events which are sensitive to yielding/waiting, you should try to break it into a separate task. You could for example create a hitbox task and pass on the obj id to perform collision updates while the fairy is alive. Since you did one for the animation, you could do it for collisions.

Code: [Select]
task fairy {
let obj = Enemy(ry

hitboxHandle(obj);
}

task hitboxHandle(obj) {
while(!Obj_IsDeleted(obj)) {
// perform collision check
}
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Icewave21 on June 24, 2014, 12:14:36 AM
Probably just an issue that I just can't find due to not looking at it clearly. I tried looking around for the solution and got nothing. The problem is that I can't use EV_GET_ITEM to check for player defined items.
In the Player Script:
Code: [Select]
case(EV_GET_ITEM)
{
ObjSound_Play(item);
let itemType = GetEventArgument(0);
alternative(itemType)
case(1){
  //Code that runs when collect the item
}

I was looking at the wiki for EV_GET_ITEM, but it doesn't say anything on how to call for UserItemData. The wiki being http://dmf.shrinemaiden.org/wiki/How_to_Write_Scripts#Events_.28.40Event.29 (http://dmf.shrinemaiden.org/wiki/How_to_Write_Scripts#Events_.28.40Event.29).
More code could be added if needed, but everything works except for this part.

Also, rather than making multiple topics, how do you make a player lasers... I looked at other scripts (and tried stealing them as a last resort) and got nothing. This isn't that important because I could just make a line with vertices and add a collision within the points. But it would be a lot simpler if someone could help me with this, or point me to a page on this topic. I'm not very smart when it comes to this, but I got it
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on June 25, 2014, 08:59:32 AM
What you're trying to do is use CreateItemU1() to make some item from its itemsheet id, then use the GET_ITEM event to grab that ID. This is half right and half wrong.
Basically the issue is that it doesn't make sense to define a user-defined item's behaviour entirely from a player script, so you can't. EV_GET_ITEM in player scripts is only triggered from the predefined items.
We have item scripts for that -- item scripts are just a slightly-specialized script used to generate various items. An item script looks like pretty much all other scripts:

Code: [Select]
@Initialize{
let dir = GetCurrentScriptDirectory();
LoadItemData(dir~"item_data.dnh");
}

@Event{
alternative(GetEventType())
case(EV_GET_ITEM){
let itemType = GetEventArgument(0);
let objItem = GetEventArgument(1);
}
case(EV_USER+100000){
CreateItem(200, 200);
}
}

task CreateItem(x, y){
let obj = CreateItemU1(1, itemX, itemY, 0);
// maybe do other things?
}

Now this is pretty much all you need, on a really basic level. Load the item data, have a GET_ITEM event, and some user event to call in order to create your item.
You should already have the item data stuff understood. The GET_ITEM event when inside an item script does what you already assume it should: grab the item type (as defined in the item data) from the event arguments and then do other stuff, probably by checking which item type it is and performing some action accordingly. The CreateItem() task should also be pretty clear, especially since as written it just spawns the actual item. I only put it in a task to illustrate that you can (and should, generally).

The special part is the script interaction. To run this script as an item script, you call StartItemScript(path_to_script). Once that's done, the item script initializes and is ready for work. So now the only part left is the user-defined event. It works like any other event, you just have to trigger the event yourself from some other script. This could be from the player script or your enemy script or whatever, but all you do is call NotifyEventAll(EV_USER+100000, *value*) when you want to spawn the item. The item script's event is triggered, it calls CreateItem() which in turn calls CreateItemU1() and makes the item. When the player collects it, the GET_ITEM event is triggered. Hooray, it works.


If you really want to have an item where you can define behaviour from the player script, you can define a barebones item script like above, notify a different user event on collection and then have the player read that event, that's all.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on June 25, 2014, 05:42:38 PM
Some different problem I bumped in and it felt really odd.

During the sprite adjusting of my floor I noticed something weird. My sprite is 256 wide and 128. So logically I set this code:
Code: [Select]
ObjRender_SetScaleXYZ(obj,1.0,1.0,0);
ObjSprite2D_SetSourceRect(obj,0,1,256,128);
ObjSprite2D_SetDestCenter(obj);
Now comes the odd part. The floor logically doesn't covers the entire width of my field, so I simply increased the value to 512 for example, so the texture gets repeated, right? Wrong.

The texture is actually stretched instead of repeated as in 0.12m. I started fiddling with various of functions and parameters such as using ObjSprite2D_SetDestRect as well but none of them had effect. This is quite weird as 3D sprites do repeat themselves if I set them (at least, as far as I can remember when I building my 3D stages. So what is the deal with 2D sprites?

Edit
This is embarrassing that I never had encountered this issue. Using SpriteList2D instead of regular Sprite2D will fix this problem. Thanks Drake for pointing it out.

Edit 2:
Apparently SpriteList2D does not listen to any of the SetAngle functions. Not the render, not the Move and also not the XYZ one. The hell is wrong right now.

Edit3:
Posted on bbs of dnh to see what Mkm has to say about it.

Mkm has posted a reply:
>>74 Helepolis氏
>This is a bit strange. With ObjPrim_Create(OBJ_SPRITE_2D);
>I can use ObjRender_SetAngleZ. But with ObjPrim_Create(OBJ_SPRITE_LIST_2D); nothing happens. See image please.
Before ObjSpriteList2D_CloseVertex is called,
ObjRender_SetAngleZ affects the angle of vertices that added by next ObjSpriteList2D_AddVertex.

After ObjSpriteList2D_CloseVertex is called,
ObjRender_SetAngleZ affects the all of OBJ_SPRITE_LIST_2D object vertices.


I assume he means you need to use the CloseVertex function in order to 'transform' the List2D into a "solid" sprite in order to apply the ObjRender functions. Anything called before the close is only applied to the next added vertex? Wiki roughly explains it the same way as well but cryptic. Perhaps some important note needs to be put on the SpriteList2D page / function?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Icewave21 on June 28, 2014, 09:13:00 PM
Damn I didn't use use StartItemScript... I was thinking LoadItemData/ReloadItemData did the same thing... maybe they can add a patch to where they start item scripts if it hasn't already been called.  But I think that could be troublesome in ways I can't see.. Thanks for the help, and next time I'll use the code function
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Shadow on July 01, 2014, 01:12:35 AM
I've run into a bit of a problem. I'm using an Item Script to handle bullet "breaking" effects, but since this method relies on using EV_DELETE_SHOT_TO_ITEM to retrieve the bullet's ID as it's itemized, it obviously only works when I use ObjShot_ToItem or a player's bomb. Is there a more generalized way of making it so it works whenever a bullet is deleted, i.e. via standard Obj_Delete? Or am I missing something obvious? ^^;
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on July 02, 2014, 09:00:19 PM
If all you want is the effect, you don't need items to pull that off. Basically what you need is two tasks. I personally handle this within the system script. Task 1 is what you will mainly call. Use task 1 to store all of the bullet ids on the screen using GetShotIdInCircleA2(x,y,radius,TARGET_ENEMY); save that to an array. Then ascent through the array calling task 2 which is where the break effect will play. You can use GetShotDataInfoA1(bullet id,TARGET_ENEMY,INFO_DELAY_COLOR); to set the color, this will return an array. Once you have all of the information you need from the bullet, make sure to delete it. Usually after setting the position of the effect is where I delete the bullet. You would use task 1 in @Event case(EV_END_BOSS_STEP){} will run everytime the boss has finished pattern so call it there.

You can also use events for manual bullet deletion by calling task 2 directly.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Shadow on July 02, 2014, 10:39:04 PM
If all you want is the effect, you don't need items to pull that off. Basically what you need is two tasks. I personally handle this within the system script. Task 1 is what you will mainly call. Use task 1 to store all of the bullet ids on the screen using GetShotIdInCircleA2(x,y,radius,TARGET_ENEMY); save that to an array. Then ascent through the array calling task 2 which is where the break effect will play. You can use GetShotDataInfoA1(bullet id,TARGET_ENEMY,INFO_DELAY_COLOR); to set the color, this will return an array. Once you have all of the information you need from the bullet, make sure to delete it. Usually after setting the position of the effect is where I delete the bullet. You would use task 1 in @Event case(EV_END_BOSS_STEP){} will run everytime the boss has finished pattern so call it there.

You can also use events for manual bullet deletion by calling task 2 directly.

Sorry, that's... not quite what I meant there. I already have a way of parsing all of this information into the effect task itself; the issue in this case is having the effect appear whenever a bullet is deleted in general, as opposed to solely an end-of-boss-step task that manually spawns the effect through GetShotIdInCircle and arrays. To achieve this, I used to run a background task that updated variables for an individual bullet's position on a frame-by-frame basis (and other miscellaneous information such as color and scale) that ran the bullet-breaking task after a while(!Obj_IsDeleted) loop, but this was... a bit on the "insane and inefficient" side of things, so I resorted to using an "Item Script" (which is more of an "effects script", really) to handle that remotely through events.

My problem right now is that this only works when the bullets themselves are itemized, as this allows EV_DELETE_SHOT_TO_ITEM to be notified and call my bullet-breaking task, but not when the bullets are deleted normally. This poses a problem because some player scripts have deathwaves that solely use Obj_Delete, and I would have to use ObjShot_ToItem everywhere instead of Obj_Delete for the effect to appear, so I was wondering if there was a more universal way of achieving this.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on July 03, 2014, 04:42:50 AM
From what you're describing it seems like an incompatibility with player scripts. This is one of the reasons I created my own players, because I could not be bothered with such things as you're describing. I suggest building a player script that can support this. There is no way to really get around that. Not unless mkm added an EV_OBJ_DELETE that would call everytime an object is deleted. From there you could just run the same info as you normally would. I would advise you to make a request out to mkm to add such feature in the next version of ph3. To be honest who knows when it will come out, its been 3 months and alot of requests have been sent out to him. Probably has his plate full on that, I'm hoping he can find time to get it out soon for us.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Shadow on July 03, 2014, 05:02:11 AM
From what you're describing it seems like an incompatibility with player scripts. This is one of the reasons I created my own players, because I could not be bothered with such things as you're describing. I suggest building a player script that can support this. There is no way to really get around that. Not unless mkm added an EV_OBJ_DELETE that would call everytime an object is deleted. From there you could just run the same info as you normally would. I would advise you to make a request out to mkm to add such feature in the next version of ph3. To be honest who knows when it will come out, its been 3 months and alot of requests have been sent out to him. Probably has his plate full on that, I'm hoping he can find time to get it out soon for us.

Hmm... I see. Well, that's certainly troublesome, as I can't find an easy way to circumvent this without falling back to my previous method. I'll try to contact mkm with that feature in mind then. Thanks for the help~

EDIT: A quick glance at ph3's "unimplemented features" changelog on the official site reveals that an "EV_DELETE_SHOT" has already been requested somewhat recently. Time to wait warmly, then...!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on July 03, 2014, 06:34:30 AM
It isn't just you that would like this, Riverbed Soul Saver (which was released just last week) also only has bullet delete effects on itemization, which they only do at the end of boss attacks and during the player bombs.
I was looking for a method to do this but we're pretty limited at the moment to either wrap around Obj_Delete(), or wrap around shot object creation using essentially your previous method on a bullet-by-bullet basis rather than dealing with the drudgery of a huge list of bullet info. You simply can't know when a bullet will be deleted, so you can't trigger extra events or run tasks at those points. It's just going to feel like you're back to 0.12m until we get an engine event for object deletion.

Ultima: Why would you go through that when you could just call DeleteShotAll() or DeleteShotInCircle() using TYPE_ITEM?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on July 03, 2014, 05:44:21 PM
Ultima: Why would you go through that when you could just call DeleteShotAll() or DeleteShotInCircle() using TYPE_ITEM?

I'm talking about a way he could've gotten around player scripts that, as he said, deletes shots using Obj_Delete instead of ObjShot_ToItem by having an event that is triggered whenever an object is deleted, or atleast whenever a bullet is deleted.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on July 03, 2014, 10:56:54 PM
No I mean your way of finding bullet objects in some radius then looping through them to start tasks and getting the shot data info and whatnot. It wouldn't get around the problem they're talking about regardless (you seem to have been mistaken about the problem when you suggested it), and it seems rather roundabout and excessive when itemization already pumps the bullet object and its final position directly to the event. This would also be the proper course of action if and when an EV_DELETE_SHOT event is implemented.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on July 04, 2014, 03:31:21 AM
Oh I gave him that advice based on what I do for my scripts. I don't use item scripts for such things. I grab object ids gradually in a circle (similar to how DDC does it) and just pass them through a task that sets the effect object in it's place and with the proper parameters.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: PhantomSong on July 13, 2014, 12:18:34 AM
With the new release of PH3, we got a little neat thing called High-level shader language (https://en.wikipedia.org/wiki/High-level_shader_language). Through the given examples by mkm, you can do the following:
Easily turn everything monochromatic  (http://i.imgur.com/p56JiFo.png)
Vanish things at certain points (http://i.imgur.com/Rt9wsNR.png)
Most notably making a burn/aura effect that is very processor friendly.  (http://i.imgur.com/ImGCRA8.png)
Of course there's more you can do with these, but these are the examples given by mkm.

High level shader language, however, is a different coding language that is compatible with Danmakufu, so it may be in your best interest to learn it (http://nazr.in/viu), however it is not required, and you can just easily go through the example scripts and mess with them, like I have done.

I can't wait to see what everyone makes with these new capabilities.
(note- I posted this so people know what it is that came with the update, and how to possibly pick it up, so this may answer some questions.)
(Note- If you'd like to, Infinite Ultima Wave has created a Skype chat to help others learn it and you can join by pming Ultima, GTbot, or myself. )
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on July 17, 2014, 12:08:24 AM
Another question regarding language discrepancies: is there a way to replicate the SetDamageRateEx function from 0.12m in ph3? I'm making an IN phantasm stage, and there are those two kinds of fairies which have orbiting familiars, which have this function applied to them. Thanks!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on July 17, 2014, 12:41:03 AM
Familiars aren't implicitly defined anywhere, so it's just a matter of setting extra hitboxes with ObjEnemy_SetIntersectionCircleToShot() at the familiars' positions. You can't set the damage rate this way but you can always just increase the parent enemy health accordingly.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on July 17, 2014, 08:28:29 PM
I tried that, but it spawned a new problem: when the fairy dies from familiar damage, the core's texture remains forever, even though I specified it to delete and it normally does. Here's the code I'm using for the animation (from TH8's image rips): http://pastebin.com/L5tQHaUE
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on July 18, 2014, 11:26:31 AM
I don't quite understand what you're doing. Is red supposed to be a parent enemy and core is a familiar "enemy"? Why is core being set to red's position? Why is the death condition for red when this looks like the familiar handling task?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on July 18, 2014, 02:16:54 PM
I am also to be honest quite confused with that code. judging from the parameter you're passing , red is an obj made outside the task (global enemy obj?). The nested task is confusing me.

You might want to post your entire code if possible and explain us what exactly you're trying to achieve.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on July 18, 2014, 10:40:27 PM
Here (http://pastebin.com/bM7dd1VE) is the code for the enemy itself. Red in the animation code is the familiar body (like the hexagram part) and I'm using the red wispy animation as its core, which is animated separately. Probably should have mentioned that with my weird naming scheme.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on July 21, 2014, 09:56:48 AM
You're only showing us a snippet of your code. redAnim(enemy); is being called but I cannot trace it anywhere.

I am extremely confused by your bracket placements.

At Line 24 you are deleting the enemy. Then you're calling at Line 28 ten times a function which has to pass the enemy object to the next task? This is impossible because you deleted your object.


Edit: Discussion on irc with Drake made me see what I missread/seen. Ignore the above.


Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on July 21, 2014, 11:38:42 AM
Okay so dying from "familiar damage" shouldn't really do anything different. All you've done is made several hitboxes for the parent enemy so they should all work the same.

What happens (I think) is that you kill the parent enemy, then in orbit(), ObjEnemy_GetInfo(enemy,INFO_LIFE) <= 0 so the fam object is deleted. Then in redFam() it sees the red (fam) object is deleted and stops, so the ObjEnemy_GetInfo(red,INFO_LIFE) <= 0 trigger isn't hit and so the core object isn't deleted. The coreAnim() task doesn't care either and keeps animating it.

What's more is that since the familiars have significantly more health than the parent, the parent will die before the familiars do (which also leads to the above).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on July 22, 2014, 11:30:20 AM
Thanks so much! I never thought of it like that.  :V
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Mahou Shoujo Nel! on August 04, 2014, 11:22:02 AM
Hey, its me again ,Nel.
I wanted to ask if anyone can help me with the coed of this animation:
http://imagizer.imageshack.us/v2/150x100q90/536/B3yqlS.png ?

I tried to Use the AnmLib of GTbot, but due to the lack of english-skills ,i didn't get it...
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on August 08, 2014, 08:58:57 PM
This is by far the weirdest problem I've come across. I've been trying to make a Seija battle. One problem: I can't access the spritesheet or sound effects. I attached the folder containing everything related to the script I've written. I've no clue what's wrong.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: gtbot on August 08, 2014, 10:40:02 PM
It seems like you've modified the files inside the default_system folder that's included with Danmakufu- I highly advise against ever doing that. The default system is there for when scripts don't include their own system or shotsheet, so Danmakufu defaults to using the default_system scripts.

If you wanted to add your own shotsheet or system, you must include the files with your script. If you modify or add the files to default_system, no one else would have the modified files, and packaging default_system with your script is silly.

(Unless you're making a whole game or packaging your script with Danmakufu, you shouldn't mess with default_system)

Code: [Select]
let bulletwave = csd ~ "../SE/BulletWave.wav"; LoadSound(bulletwave);"../" gets the previous directory, as opposed to the current one, which you want in this case (which is "./", or "GetCurrenScriptDirectory", in this case you'd want to use GetCurrentScriptDirectory~"path"). By the way, to use "../" properly, you'd want to do something like "./../", so that it gets the previous directory of the current directory.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on August 08, 2014, 11:53:06 PM
Oh my god. I copied the function_lib out of a different script folder and forgot to edit my pathing. I didn't touch the default stuff, I'm just an idiot. :V
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Fumi on August 13, 2014, 12:53:54 AM
Quick question:

How do I remove Danmakufu's default stuff like the game frame, the player and score numbers, the default enemy lifebar, etc?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 13, 2014, 02:08:30 AM
You make a System script. If you make one apply through #System, the one from default_system won't apply. It's really just another generic script that runs the "system" functions you want. There isn't anything particularly special about it besides being automatically run alongside whatever uses it. You can look at default_system/Default_System.txt (and Default_System_MagicCircle.txt) for the default system script. If you only want to change specific things, copy the contents to a new file and edit that. It isn't a good idea to modify the existing scripts without at least making backup copies.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Dan The Jerk on August 13, 2014, 02:40:36 AM
Out of boredom, I try creating a background that will be shown during spell cards.
However, it didn't show properly as I expected.

Expectation (note that the circle in the center is a separate image, and should rotate clockwise):
(http://i.imgur.com/gOcK8Vv.png)

Reality (ignore everything except the background):
(http://i.imgur.com/5LseB1k.png)

The code:
http://pastebin.com/h366CABC

The files linked in the code are in the right directory, as shown:
(http://i.imgur.com/m9iU001.png)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 13, 2014, 04:22:59 AM
For one, you don't need to do the things involving id[0] id[1] id[2] id[3] inside the first loop; these would be executed four times for no reason.
You can also use ObjSprite2D_SetSourceRect() and ObjSprite2D_SetDestCenter() instead of manipulating individual vertices (2D sprite objects also automatically have 4 vertices) to make things cleaner and easier.
You can rewrite your first loop as
Code: [Select]
ObjPrim_SetTexture(id[0],csd~"./stg6img/enm6a.png");
ObjPrim_SetTexture(id[1],csd~"./stg6img/enm6a.png");
ObjPrim_SetTexture(id[2],csd~"./stg6img/enm6b.png");
ObjPrim_SetTexture(id[3],csd~"./stg6img/enm6c.png");
ascent(i in 0..4){
                ObjRender_SetPosition(id[i],CenX,CenY,0);
                Obj_SetRenderPriorityI(id[i],22);
                ObjRender_SetBlendType(id[i],BLEND_ALPHA);
                ObjRender_SetScaleXYZ(id[i],1,1,0);
                ObjSprite2D_SetSourceRect(id[i],0,0,384,448);
                ObjSprite2D_SetDestCenter(id[i]);
}
ObjRender_SetScaleXYZ(id[3],1.1,1.1,0);

And really just in general it seems to be a bit disorganized and you have repeating code in a few places. You should look into cleaning it up.

Anyways as for your main problem, I take note that
1) alpha1 and alpha2 are set to 0 and never change, so it's invisible.
2) emn6b is drawn on the same layer as enm6c, but is drawn before it, so regardless it would be drawn underneath everything.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Dan The Jerk on August 13, 2014, 05:35:14 AM
For one, you don't need to do the things involving id[0] id[1] id[2] id[3] inside the first loop; these would be executed four times for no reason.
You can also use ObjSprite2D_SetSourceRect() and ObjSprite2D_SetDestCenter() instead of manipulating individual vertices (2D sprite objects also automatically have 4 vertices) to make things cleaner and easier.
You can rewrite your first loop as
Code: [Select]
ObjPrim_SetTexture(id[0],csd~"./stg6img/enm6a.png");
ObjPrim_SetTexture(id[1],csd~"./stg6img/enm6a.png");
ObjPrim_SetTexture(id[2],csd~"./stg6img/enm6b.png");
ObjPrim_SetTexture(id[3],csd~"./stg6img/enm6c.png");
ascent(i in 0..4){
                ObjRender_SetPosition(id[i],CenX,CenY,0);
                Obj_SetRenderPriorityI(id[i],22);
                ObjRender_SetBlendType(id[i],BLEND_ALPHA);
                ObjRender_SetScaleXYZ(id[i],1,1,0);
                ObjSprite2D_SetSourceRect(id[i],0,0,384,448);
                ObjSprite2D_SetDestCenter(id[i]);
}
ObjRender_SetScaleXYZ(id[3],1.1,1.1,0);

And really just in general it seems to be a bit disorganized and you have repeating code in a few places. You should look into cleaning it up.

Anyways as for your main problem, I take note that
1) alpha1 and alpha2 are set to 0 and never change, so it's invisible.
2) emn6b is drawn on the same layer as enm6c, but is drawn before it, so regardless it would be drawn underneath everything.

I redid the first loop, switched the order of the RenderPriority part, and fixed the zero-alpha part, but nothing has changed.

Pastebin:
http://pastebin.com/ZwD3Lutk
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 13, 2014, 06:23:08 AM
It looks like you put the draw layer change after the enemy object is deleted and the flag is hit, whatever it is. Put it before, since I assume that while loop is what runs for most of the time.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Fumi on August 16, 2014, 03:13:35 AM
I got a problem with ascent loops, for what I saw, anything created in an ascent loop can only be referenced inside the same loop which brings a problem when I try to make for example a ring of bullets that will create bullets at the border of the screen.

Code: [Select]
task ay()
{
let bulletX = ObjMove_GetX(objEnemy);
let bulletY = ObjMove_GetY(objEnemy);

let density = 16;
let a = 0;

ascent(i in 0..density)
{

let bulletObj=CreateShotA1(bulletX, bulletY, 2,a,375, 10);

a += 360/density;
ObjMove_AddPatternA1(bulletObj,20,2,a-30-ang);
ObjMove_AddPatternA3(bulletObj,40,2,a+30-ang,NO_CHANGE,0,2,379);
ObjMove_AddPatternA1(bulletObj,60,2,a-30-ang);
ObjMove_AddPatternA3(bulletObj,80,2,a+30-ang,NO_CHANGE,0,2,376);
ObjMove_AddPatternA1(bulletObj,100,2,a-30-ang);
ObjMove_AddPatternA3(bulletObj,120,2,a+30-ang,NO_CHANGE,0,2,376);
ObjMove_AddPatternA1(bulletObj,140,2,a-30-ang);
ObjMove_AddPatternA3(bulletObj,160,2,a+30-ang,NO_CHANGE,0,2,378);
ObjMove_AddPatternA1(bulletObj,180,2,a-30-ang);
ObjMove_AddPatternA3(bulletObj,200,2,a+30-ang,NO_CHANGE,0,2,380);
while(!Obj_IsDeleted(bulletObj)){
if (ObjMove_GetX(bulletObj)<=GetStgFrameLeft+2 && ObjMove_GetX(bulletObj)>=GetStgFrameLeft-2){
CreateShotA1(ObjMove_GetX(bulletObj), ObjMove_GetY(bulletObj), 2,rand(-45,45),375, 10);
}
if (ObjMove_GetX(bulletObj)>=GetStgFrameWidth-2 && ObjMove_GetX(bulletObj)<=GetStgFrameWidth+2){
CreateShotA1(ObjMove_GetX(bulletObj), ObjMove_GetY(bulletObj), 2,rand(135,225),375, 10);
}
if (ObjMove_GetY(bulletObj)<=GetStgFrameTop+2 && ObjMove_GetY(bulletObj)>=GetStgFrameTop-2){
CreateShotA1(ObjMove_GetX(bulletObj), ObjMove_GetY(bulletObj), 2,rand(135,45),375, 10);
}
yield;
}

}



}

This is part of what I'm using the loop, but as you see I need to check every frame if the bullet is touching the border of the screen. However adding a while makes the whole ascent loop to just execute once. How can I make it loop the required number of times? Or how can I make the task check every frame if the bullet is touching the border?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 16, 2014, 03:37:37 AM
Just move the whole while loop into a task, and instead call the task with bulletObj as the argument. This way the task will be run for each bullet, and yielding there will yield the new task instead of ay(), allowing ay() to continue.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: MoonRabbit on August 16, 2014, 02:21:55 PM
I want to make a spell have a random behavior, but be the same every time you play it.
For example:
Code: [Select]
while (!Obj_IsDeleted(bossId))
{
    SetSeed(4); // No such function :c
    let angle = rand(0, 360);
    CreateShotA1(ObjMove_GetX(bossId), ObjMove_GetY(bossId),
   5, // Speed
   angle,
   DS_BALL_L_WHITE,
   10); // Delay
    WaitSeconds(0.1);
}

I couldn't find any function for setting the seed manually.
So, what is the easiest way to achieve this?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: PhantomSong on August 16, 2014, 06:14:00 PM
I want to make a spell have a random behavior, but be the same every time you play it.
For example:
Code: [Select]
while (!Obj_IsDeleted(bossId))
{
    SetSeed(4); // No such function :c
    let angle = rand(0, 360);
    CreateShotA1(ObjMove_GetX(bossId), ObjMove_GetY(bossId),
   5, // Speed
   angle,
   DS_BALL_L_WHITE,
   10); // Delay
    WaitSeconds(0.1);
}

OK, first please dont space out your shot code like that.
Keep is simple like //CreateShotA1(x,y,speed,angle,graphic,delay); before or in the task, or write it down on notepad.

Next you arent resetting angle, so it is picking a random direction and it'll keep that value until you reset it.
Put
angle=rand(0,360); after WaitSeconds

You could also alternatively put rand(0,360) where angle would go.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: MoonRabbit on August 16, 2014, 07:20:33 PM
You are wrong about the angle not being reset, and you didn't even refer to my problem  :wat:
(btw, this is an example I'd just made up, not an actual code from my game. So don't nitpick)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: PhantomSong on August 16, 2014, 07:31:22 PM
You are wrong about the angle not being reset, and you didn't even refer to my problem  :wat:
(btw, this is an example I'd just made up, not an actual code from my game. So don't nitpick)
Oh, I see. SetSeed is what you're referring to. Apologies, i had just got up,
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 16, 2014, 11:31:35 PM
You cannot set the seed manually, no. If you're expecting random-like behaviour, you could use a sine wave with high frequency or something else to generate patterns that "seem" random, although this doesn't necessarily cluster values like you might expect from a good random number generator, so it depends what you're really going for. You could also implement your own hash function, as a "random number generator" sufficient for bullet patterns doesn't have to be cryptographically strong whatsoever.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on August 17, 2014, 07:41:39 AM
Not sure whether this question belongs in this thread, but does anyone know if there's a non-video tutorial for ph3?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 17, 2014, 11:12:38 AM
I'm currently writing a rather extensive beginner tutorial. Stay tuned, hopefully I'll be done within the week.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: MoonRabbit on August 20, 2014, 09:17:10 PM
I've just found out that I can change the resolution in the def file, and then set the game frame with with SetStgFrame.
I thought that maybe I should change everything in my game to relative locations, so I could support multiple resolutions. But it's too much work because of the shot data...

I'm just wondering, do you program to 640*480 or other resolutions?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: CK Crash on August 21, 2014, 02:16:46 AM
There's not really a way that you can scale a game to multiple resolutions while maintaining replay compatibility. Even if you perfectly scale your game to twice the size, there would probably be small difference in collision detection that make it a bad idea. If you use the default 640x480 size, Danmakufu's config allows the user to scale the game up (albeit rather jaggedly). If you want to use a higher resolution, bear in mind that you can't scale it down for users with old monitors.

Scaled render targets of the entire screen might work? I wouldn't worry about it though.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on September 15, 2014, 09:36:56 PM
I'm currently writing a rather extensive beginner tutorial. Stay tuned, hopefully I'll be done within the week.

Any progress on that?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on September 16, 2014, 12:14:39 AM
Any progress on that?

Don't press it too much. Tutorials take a lot of time to write, and require a lot of revision to be helpful.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on September 16, 2014, 12:37:05 AM
Yeah it's coming along, but obviously it's taking longer than anticipated. This is mostly because of how rigorous I'm being with my writing and phrasing. Sorry for the wait.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on September 16, 2014, 02:05:55 AM
P.S. Earlier today I went to my transition guide and briefly stated that I will not be filling in sections on players and backgrounds. Just a note. I don't fully understand either to the level that I'd need to write it.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Conarnar on September 27, 2014, 05:33:00 PM
I don't understand what 敵ライフを適切に返していません。 means.
Edit: nvm, I found out.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BlazervaniaX on October 04, 2014, 07:55:40 PM
so... i'm not sure if i should ask this on this thread or what but i guess this belongs here:
regarding ph3 player scripting, is there some place that describes how to make a Player Script or someone who knows how to do so? for the thing i've seen there's nothing on these forums tutorials (regarding the player scripting matter of course), nor did my research on the threads come to a reliable result (or at least for the thing i could see)...
do tell me if this question is out of place please  :V
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on October 04, 2014, 08:01:43 PM
so... i'm not sure if i should ask this on this thread or what but i guess this belongs here:
regarding ph3 player scripting, is there some place that describes how to make a Player Script or someone who knows how to do so? for the thing i've seen there's nothing on these forums tutorials (regarding the player scripting matter of course), nor did my research on the threads come to a reliable result (or at least for the thing i could see)...
do tell me if this question is out of place please  :V

There is currently no ph3 player script tutorial. Most people made their scripts by editing one of GTbot's or the Random Player Generator, the former of which was likewise based off of the latter.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BlazervaniaX on October 04, 2014, 08:04:32 PM
oh well, i guess i'll just have to do the exact same thing :v thanks
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on October 04, 2014, 11:33:52 PM
oh well, i guess i'll just have to do the exact same thing :v thanks

If you're going to release the player, make sure you cite who made it. Also, you are REQUIRED to have some of the @Event cases or danmakufu may crash when the events are triggered.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BlazervaniaX on October 04, 2014, 11:40:15 PM
i just looked up one and it's a complete freaking mess of coding which i cannot understand... yet, so i'm not going to do anything... yet  :V
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on October 06, 2014, 07:07:00 PM
I've been trying to get back into making my IN phantasm stage, and I'm trying to eliminate lag. So, could anyone suggest a less resource-intensive way to make the familiars? I only ever get lag when they're present, and I know that I suck at making them. The attached folder contains everything pertaining to the stage this time, so I won't have to make 3 posts for one problem.  :V
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on October 06, 2014, 07:25:46 PM
Why are you loading and trying to replay the music every frame.

Code: [Select]
@MainLoop {
LUNATIC_BLUE;
yield;
}

Code: [Select]
task LUNATIC_BLUE(){
let BGMobj = ObjSound_Create;
let BGMmp3 = GetCurrentScriptDirectory ~ "BGM.ogg";

ObjSound_Load(BGMobj,BGMmp3);
ObjSound_SetSoundDivision(BGMobj,SOUND_BGM);
ObjSound_SetVolumeRate(BGMobj,100);
ObjSound_SetLoopEnable(BGMobj,true);
ObjSound_SetLoopTime(BGMobj,0,284);
ObjSound_SetFade(BGMobj,60);

ObjSound_Play(BGMobj);
}

Use the debug window. If there are 600 instances of a music file, then you know what to fix.

ADDITIONAL NOTES:
Code: [Select]
wait(60);//Assuming that compiling with finish in about a second.Why are you doing this? This does not help you because the stage itself pauses until the thing is loaded.

fairy_fn.txt
Code: [Select]
let shot = ObjShot_Create(OBJ_SHOT);
ObjShot_Regist(shot);
ObjMove_SetPosition(shot,getX(fam)+rand(-30,30),getY(fam)+rand(-30,30));
ObjMove_SetSpeed(shot,0);
ObjMove_SetAngle(shot,angle);
ObjShot_SetGraphic(shot,76);
ObjShot_SetDelay(shot,3);
Please just use
Code: [Select]
let shot = CreateShotA2(getX(fam)+rand(-30,30),getY(fam)+rand(-30,30), 0, angle, 0, 0, 76, 3); and then do your other edits.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on October 06, 2014, 08:14:53 PM
 :V :V :V Thanks! I kinda made a lot of this while tired off my ass, so I made tons of unnecessary objects that I never fixed because of experimentation.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Neodymium on October 06, 2014, 09:36:50 PM
I am having some problem with shot data (nothing happens..... literally, nothing). Is there a trick to loading or editing them?

I find that if I open and save the included Default_Player_RumiaShotData.txt (no changes, just open & save to disk) it stops working (ie can't shoot anymore, like if the file was being ignored completely). I figure maybe there is some kind of quirk with encoding? But then, what's weird is, if I open and save Default_Player_Rumia.txt in my text editor it works just fine so I really don't know what is happening. Is the encoding of shotdata different than player/stage/etc. scripts? (I am saving as ANSI, tried UTF-8 and a few others too.... pretty sure this shouldn't be an issue though). Even if I create a new file from scratch it still won't load.

Example...
Code: [Select]
#UserShotData

shot_image = "./Player_Shots.png"

ShotData{ id=1 rect=(1, 1,31,31) render=ADD alpha=64 collision=16 }
ShotData{ id=2 rect=(1,32,48,80) render=ADD alpha=64 collision=24 }
(And I load it in my player script's @Initialize via LoadPlayerShotData(current ~ "Player_ShotData.txt");)

This does not work. And Player_shots.png is present, I triple-checked. =) Anyway it is the default "Default_Player_RumiaShot.png" file. This is very frustrating because it looks like it should be working, but it isn't and danmakufu is not giving any information I can post here or use to understand the problem..... It just "doesn't do anything"..... =/
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BlazervaniaX on October 06, 2014, 10:11:18 PM
you didn't forget the ";" at the end of "LoadPlayerShotData(current ~ "Player_ShotData.txt"" right?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Neodymium on October 06, 2014, 10:33:04 PM
you didn't forget the ";" at the end of "LoadPlayerShotData(current ~ "Player_ShotData.txt"" right?
It's in my post, the forum just made a smiley out of it. ( ;) <- ; ) ) Anyway, the problem only requires opening & saving the file, not modifying the player script any. So it has nothing to do with LoadPlayerShotData AFAIK.....

- If I take the default install, open the example Rumia shot data, save it back to disk without modifying it, and attempt to use the default Rumia player the problem manifests (shooting does nothing but moving, bombing, etc. is fine).
- If I make my own shot data from scratch (like in the above post) instead of modifying the one that's already there, the problem also manifests.
- If I edit the example Rumia player script (and do not touch the example Rumia shot data in any way), the problem does not manifest, so I doubt it's an encoding issue....? Otherwise, I'd have problems with the player script too?

Once I save the shot data, modified or not, it just stops working. So, what I'm asking is, is there some trick to this? Special file encoding? Use of applocal with my text editor/danmakufu/something else? I tried a few things and so far nothing.... I couldn't find any mention of this sort of thing on the wiki and tried redownloading from a different site but no luck......
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BlazervaniaX on October 06, 2014, 10:38:57 PM
oh, that's because the smiley was so out of place  :V
i have no idea... although i'm not an expert :V but i thought that your problem was similar to one i had the past days (the character won't shoot)...
but, your hypothesis suggests that's got something to do with the main player script, NOT the shot data, right?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BlazervaniaX on October 06, 2014, 10:44:39 PM
wait... isn't the "#UserShotData" misplaced? i never used it, nor knew of its existence, yet my tries on making player scripts worked fine without it :V
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Neodymium on October 06, 2014, 10:53:32 PM
wait... isn't the "#UserShotData" misplaced? i never used it, nor knew of its existence, yet my tries on making player scripts worked fine without it :V
From this post and the one before, I think you are getting confused. =) This problem is with "Default_Player_RumiaShotData.txt", not "Default_Player_Rumia.txt". The problem has nothing to do with player scripts as far as I can tell.

Please read the three example cases I provided. You will see that the player script causes no problems whatsoever: the problem comes up in a clean install without having touched the player script. It's modifying or even just saving the shot data that causes it to take place. Modifying the player script itself in any way is just fine and whatever changes I make to it come out as expected.

Edit: Ok got it working. The shot data worked after I made it UTF-8 and manually added a BOM to the start of the file (my text editor by default omits the BOM). But the player script does not require this at all (in fact the one I use is in plain ANSI). I still don't get it. So player scripts support any (?) encoding but shot data only supports UTF-8 with a BOM and won't load if it's not in that specific format? Something doesn't feel right. What is going on? =/
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BlazervaniaX on October 06, 2014, 11:34:37 PM
okay... what's all this UTF or ANSI stuff about? why not just saving them as plain normal txt files? i never heard of saving scripts like that...
also, the "#UsedShotData" i tried to mean was the one found inside the shotdata, right at the beginning... i fint it a bit... odd

EDIT: if it's working already then nevermind this :V
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on October 07, 2014, 12:08:24 AM
okay... what's all this UTF or ANSI stuff about? why not just saving them as plain normal txt files? i never heard of saving scripts like that...
also, the "#UsedShotData" i tried to mean was the one found inside the shotdata, right at the beginning... i fint it a bit... odd
"Plain normal text" doesn't exist. A computer has to go from individual bits to readable text in one way or another.

Neodymium, you can also replicate this problem in other scripts by using the #東方弾幕風 header instead of #TouhouDanmakufu, and then saving it as anything but Shift-JIS.

That being considered, it might be that the way the headers are being read is the main issue. I can't replicate your problem in shot definitions with any encoding, but see if it works in other encodings after removing the header. I've never actually had to put it there.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: AchySolrock on November 02, 2014, 06:31:38 AM
Hello, I'm new to the forums, and new to Danmakfu as well. I'm not quite sure if my first post should be a question, but I'll go for it!

Anyway, I want to make a gravity bullet have a trail following it, similar to Koishi's Rekindled "Embers of love" card, but with single bullets rather than clusters of them.
I did discover how to make gravity bullets, but the trail part is being a pain. Here's what I have so far.

-----
task Glow {
   //Current task for the "leader" Bullet
   loop(4){
      let randir = rand(-0.5,0.5);
      Light = CreateShotB2(BossX,BossY-45,randir,-3,0,0.05,0,2,308,15);
      wait(53);
   }
}

task Glowtrail {
   //Current task for the disappearing bullet trail following the leading bullet
   loop{
      let LgtX = ObjMove_GetX(Light);
      let LgtY = ObjMove_GetY(Light);
      MiniLgt = CreateShotA2(LgtX,LgtY,0,rand(0,360),0.001,0.1,74,11);
      wait(10);
      ObjShot_FadeDelete(MiniLgt);
   }
}
-----
(Sorry if the code is way too big, I felt like it isn't, but let me know if it is.)

I think I understand why the trail stops once a new "Light" bullet appears and instead follows the newer one, but I can't think of a way to get around it so I can have multiple gravity bullets with multiple trails on screen at once. I suppose I could just make a ton more variables, but it seems like there would be a better way to do this thing.
Also, the wait in the Glowtrail task isn't working how I'd like. The trails are too short, and adding more time to the wait makes the gaps in the trail bigger, which I don't want.

Thanks for the help!  :)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TalosMistake on November 02, 2014, 01:30:24 PM
I'm not good at English and I'm not that great about explanation, but I think can help you a little bit. xD

For the first problem, I assume your "Light" Variable is a global variable and it's created outside the task Glow, then you use it to store the bullet data from CreateShotB2, right?

Obviously, it's impossible that 1 variable can store more than 1 bullet data, so every time you call a new CreateShotB2 function,

"Light" variable will store new bullet data instead of the old one.

The silly way to solve this problem is create variables as many as possible to store every bullet data, but how many will you create it? 100? 1000? you don't really know how many

bullets will you create in that spell/nonpell card, and it also wastes your memory A LOT.

The good solution for me is create a new variable each time you call a CreateShotB2 function , and let another task handles it separately. Something like this.

http://pastebin.com/cgwxdk9D

The second problem is pretty easy, instead of using bullets as a trail, you use lasers, then you can adjust the laser length to make the trails longer or shorter.

It may be hard to understand at first (probably my english :V). Feel free to ask if you don't understand. Everyone here is willing to help you. xD
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: AchySolrock on November 03, 2014, 03:45:24 AM
Thanks, Talos!  :)
A trail follows all of the bullets now!

I've had no experience making tasks that have arguments at the end of them before, so I'm not sure I understand how "Glowtrail(Light)" makes a new bullet-containing variable each time it's called...Or, maybe it's "Glowtrail(obj)" that does it? (Maybe even both of those together?)

As for the length of the trails, that still needs to be fixed, and I'd rather not use lasers because I'm going for a certain look. The look I want is already achieved, but the time before the bullets disappear is too short. The rate they appear at is just right though.

Why do I need to create a new variable in the "Glowtrail" task though? (talking about your last comment after MiniLgt)
What would it be for?

Thanks again!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on November 03, 2014, 07:11:09 AM
One thing is that making a variable to put the Light bullet in isn't actually necessary in this case; you could just as well omit the task's obj parameter and instead put the randdir and a let obj = CreateShotB2(etc); at the start of the task, since it's always running the same thing anyways. Maybe that would look more familiar:

Code: [Select]
task Glow {
   loop(4){
      Glowtrail();
      wait(53);
   }
}
task Glowtrail(){
   let randir = rand(-0.5,0.5);
   let obj = CreateShotB2(BossX,BossY-45,randir,-3,0,0.05,0,2,308,15);
   while(!Obj_IsDeleted(obj)){
     //stuff
   }
}

CreateShotB2() is a function that returns the created object's ID. By saying Light = CreateShotB2(bla) you're storing the object's ID inside that variable. Then when you call Glowtrail(Light), you're giving the Glowtrail() task that object ID. Inside the task, having that obj parameter defines obj as a new variable that stores whatever is passed to it, so then inside the task obj will now contain the created object's ID. Now when you use obj throughout the task you're referring to that particular object.


If the time before the bullets disappear is too short, just change the wait(10) to longer.

Lastly, you just need the MiniLgt variable so you can reference the object later when you go to delete it with ObjShot_FadeDelete(MiniLgt).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: AchySolrock on November 03, 2014, 07:58:52 AM
Ah, ok! Thanks, Drake!

Yeah, that looks easier for me to understand.
One of my flaws with coding for this so far seems to be not knowing where to place lines of code...

If I increase the "wait(10)" though, the gaps in between the trail of bullets gets bigger. The wait in the while loop is affecting both
"let MiniLgt = CreateShotA2(LgtX,LgtY,0,rand(0,360),0.01,0.1,74,11);" the speed that the bullets spawn,
and "ObjShot_FadeDelete(MiniLgt);" the speed that they disappear.

"wait(10)" is the correct amount of time I need for the bullets to appear, but it's too quick for them to disappear. I'm thinking I need to move "ObjShot_FadeDelete(MiniLgt);" somewhere else? Like in a loop inside the while loop, or maybe a different task entirely?

...Actually thinking about it, putting it in a different task sounds like it could work... I might mess around with that in the meantime and see if I can come up with something.

Thanks for all the help!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on November 03, 2014, 10:06:26 AM
Oops, missed that. Well, you could stack another task on top of it, or you could use ObjShot_SetDeleteFrame() to specify when to delete the child bullets instead. Only thing is that you won't get the fade out, if that matters.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on November 03, 2014, 11:14:56 AM
Quote
or you could use ObjShot_SetDeleteFrame() to specify when to delete the child bullets instead. Only thing is that you won't get the fade out, if that matters.
You also could decrease the alpha of the bullet by what you want per frame with ObjRender_SetAlpha (and delete the object when alpha <= 0) and use ObjShot_SetIntersectionCircleA1 with 0 as radius to make fadeout bullet without hitbox.
It's not the easiest way but it work. I think.

(sorry if I'm not clear. My english is really bad ><)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TalosMistake on November 03, 2014, 11:30:02 AM
"wait(10)" is the correct amount of time I need for the bullets to appear, but it's too quick for them to disappear. I'm thinking I need to move "ObjShot_FadeDelete(MiniLgt);" somewhere else? Like in a loop inside the while loop, or maybe a different task entirely?
...Actually thinking about it, putting it in a different task sounds like it could work... I might mess around with that in the meantime and see if I can come up with something.

Yeah, you can create another task inside task Glowtrail, like this

http://pastebin.com/t3kPRvR7

with this you're able to create a trail bullet every 10 frames and determine how many frames do you want to wait before it's deleted.

(I think this technique is called "Nested task", but I'm not quite sure. xD)

You also could decrease the alpha of the bullet by what you want per frame with ObjRender_SetAlpha (and delete the object when alpha <= 0) and use ObjShot_SetIntersectionCircleA1 with 0 as radius to make fadeout bullet without hitbox.
It's not the easiest way but it work. I think.

Yeah, instead of using ObjShot_FadeDelete function, you can manually create a "fade delete" function by yourself

Code: [Select]
task ManualFadeDelete(obj,time) // time is a time before it's completely deleted.
{
    let alpha = 255;
    let ratio = 255/time;
    ObjShot_SetIntersectionEnable(obj,false); // remove the hitbox from a bullet.
    while(alpha>0)
    {
          alpha -= ratio;
          ObjRender_SetAlpha(obj,alpha); // the alpha of a bullet need to be updated every frame.
          yield;
    }
   Obj_Delete(obj);
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: AchySolrock on November 04, 2014, 12:10:36 AM
Yes, I got it to work by moving the ObjShot_FadeDelete into another task like this.

Code: [Select]
task deletetrail(obj2) {

wait(45);
ObjShot_FadeDelete(obj2);

}

The wait(45) doesn't add on to the other wait in the trail making task, so I can change either wait without it affecting the other now!

Wow, there seems to be lots of ways to do this. Thanks for your help everyone!

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Justin on November 08, 2014, 05:39:13 AM
Hi,
I'm fairly new around here. So I'm trying to make a small game with a friend, and I've run into a few.. issues with this stage script here...
http://pastebin.com/UckTStUz

The issues are as follows:
If you need the plural and single for the boss as well, here they are:
Plural: http://pastebin.com/arxQdcww
Single: http://pastebin.com/dMY3k83B
Oh, I  just wanted to add that that I looked under functions, and I found no way to get the hp of the enemy so I could delete the object.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on November 08, 2014, 04:20:00 PM
Oh, I  just wanted to add that that I looked under functions, and I found no way to get the hp of the enemy so I could delete the object.

Code: [Select]
        while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){yield;}
I think this is in the sample scripts that come with danmakufu? Use the samples as a base to start on if you are a beginner - it makes things like these slightly less cumbersome.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: ExPorygon on November 08, 2014, 04:57:21 PM
The one enemy that spawns does not die
You never tell the enemy to be deleted. Usually, people will have a while(ObjEnemy_GetInfo(objEnemy,INFO_LIFE)>0) rather than a simple loop and have Obj_Delete(objEnemy); after it. That way it will run the attack routines and/or collision detection while it has life and delete itself when it runs out.

Boss does not show up
You have to load every script before you can start it. You would want something like this:
Code: [Select]
let Script = LoadScript(dir ~ "Stage 1 Boss.txt");
StartScript(Script);
Alternatively you could just have the boss be created by the stage script itself instead of allowing another one to handle it but that's up to you.

Script just ends randomly (assuming because the boss script is never opened)
That is correct, the boss script is never started because it was never loaded.
 
To clarify Sparen, the fuction to get the life of any enemy object is ObjEnemy_GetInfo(object enemy id, INFO_LIFE); Most people tend to put it in a while statement, like what I had stated before.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Justin on November 09, 2014, 02:08:02 AM
Both of you, thank you so much!!


Code: [Select]
let Script = LoadScript(dir ~ "Stage 1 Boss.txt");
StartScript(Script);

I see my issue now, I had forgotten the LoadScript( blahblah ) in the "let Script=" thing. Thanks again!!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on November 10, 2014, 11:12:12 PM
It's certainly a stupid question but what is the exact meaning of the "../" used on pathing? It's seems to be a sort of "back to the previous folder" but... I'm not sure.

And also the "~" is used to concatenate string. But is there an operator or a function to do the opposite? For example if I have a string like "text1text2" and I want to remove "text2" and keep only "text1" how I can do? It's possible?


Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on November 11, 2014, 04:39:41 AM
It's certainly a stupid question but what is the exact meaning of the "../" used on pathing? It's seems to be a sort of "back to the previous folder" but... I'm not sure.

".." means the folder above the current one.

Quote
And also the "~" is used to concatenate string. But is there an operator or a function to do the opposite? For example if I have a string like "text1text2" and I want to remove "text2" and keep only "text1" how I can do? It's possible?

No.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: ExPorygon on November 11, 2014, 02:33:18 PM
And also the "~" is used to concatenate string. But is there an operator or a function to do the opposite? For example if I have a string like "text1text2" and I want to remove "text2" and keep only "text1" how I can do? It's possible?
Actually there sort of is a way. Look up the function SplitString on the wiki.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: AchySolrock on November 17, 2014, 11:34:38 AM
So I attempted to create a custom bullet for a script using ObjShot_Create and other commands that I figured went with it. I had a picture ready, and I set the code up similar to how I rendered the boss (via Helipolis's tutorial). But it didn't work when I tried to shoot it from the boss.

Code: [Select]
function RedRocket {
let RedMsl = ObjShot_Create(OBJ_SHOT);
ObjShot_Regist(RedMsl);
ObjPrim_SetTexture(RedMsl,RedMissleBullet);
ObjSprite2D_SetSourceRect(RedMsl,0,0,32,40);

while(!Obj_IsDeleted(RedMsl)){
ObjShot_SetIntersectionLine(RedMsl,16,4,16,36,4);
yield;
}
}

Other than probably not getting the coding right, I placed "RedRocket" as the bullet to shoot... But now thinking about it, putting a function or task inside the bullet ID seems a bit silly.
So how would I actually go about creating a custom bullet? I'm under the impression though that I'd need to paste the code for the custom bullet in every script I want it in, which may be unadvised.

From this happening though, I started making my own shot sheet, which I think I understand how to do, but I'd like some advice, like on mistakes to avoid and such. I can ask for that in this thread, right? For some reason, I feel like this might not be the right place to ask for advice on that.

Thanks for the help!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: PhantomSong on November 19, 2014, 11:24:51 PM
So I attempted to create a custom bullet for a script using ObjShot_Create and other commands that I figured went with it. I had a picture ready, and I set the code up similar to how I rendered the boss (via Helipolis's tutorial). But it didn't work when I tried to shoot it from the boss.

Code: [Select]
function RedRocket {
let RedMsl = ObjShot_Create(OBJ_SHOT);
ObjShot_Regist(RedMsl);
ObjPrim_SetTexture(RedMsl,RedMissleBullet);
ObjSprite2D_SetSourceRect(RedMsl,0,0,32,40);

while(!Obj_IsDeleted(RedMsl)){
ObjShot_SetIntersectionLine(RedMsl,16,4,16,36,4);
yield;
}
}

Other than probably not getting the coding right, I placed "RedRocket" as the bullet to shoot... But now thinking about it, putting a function or task inside the bullet ID seems a bit silly.
So how would I actually go about creating a custom bullet? I'm under the impression though that I'd need to paste the code for the custom bullet in every script I want it in, which may be unadvised.

From this happening though, I started making my own shot sheet, which I think I understand how to do, but I'd like some advice, like on mistakes to avoid and such. I can ask for that in this thread, right? For some reason, I feel like this might not be the right place to ask for advice on that.

Thanks for the help!

Can you please specify your problem? Does it not show up or does it not intersect with the player...?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: AchySolrock on November 20, 2014, 04:20:05 AM
Oh, sorry. The bullet does show up.  In fact, it actually stops the code after it from working as well.

I have this little bit of code for a slash like attack, it works just fine...until I changed it for a test.

Code: [Select]
ascent (i in 0..25) {
count+=360/8;
CreateShotA2(BossX-90+i*8,BossY-90+i*8,1.3,count+variance,0.01,2.7,202,20);
CreateShotA2(BossX-90+i*8,BossY-90+i*8,1,count+variance,0.01,2.5,202,20);
CreateShotA2(BossX-90+i*8,BossY-90+i*8,0.7,count+variance,0.01,2.3,RedRocket,20);
wait(1);
}

To see if the bullet would work, I've placed the function inside the 3rd CreatShotA2's bullet ID argument.
After I put the function in, the code stops after it hits the third CreateShotA2, spawning only 2 bullets.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on November 20, 2014, 04:53:59 AM
EDIT: was writing when you posted

By the lack of a position to shoot and saying "putting a function or task inside the bullet ID" I can only assume you did something like CreateShotA1(x, y, s, a, RedRocket, d). That's totally not how it works. Shot IDs are just numbers that correspond to the IDs in a shot definition file that you've loaded. If you include the default shots with #include"script/default_system/Default_ShotConst.txt", then you can use numbers from 1 to 255 as shot IDs, or use the constants defined in that file like DS_BALL_S_RED (which is 9, incidentally). When making a custom shot sheet this is also what you're doing.

RedRocket(), though, is just a function (like CreateShotA1). If it worked, you would just call it on its own. It won't work for a few reasons:
- A Shot object is not a Primitive object, nor a Sprite2D object, so those two functions won't work on RedMsl.
- The graphic would instead need to be set with ObjShot_SetGraphic(), which needs to be a shot ID as described above.
- You'd need to specify a position for the object to spawn at. You could do this with ObjMove_SetPosition() or something similar, since Shot objects are Move objects.
- ObjShot_SetIntersectionLine()'s four position parameters need you to give an absolute position on screen, rather than a position relative to the object. It doesn't change depending on angle.
- By using a function and not spawning a task, Danmakufu would probably freeze since it would be infinitely checking if the bullet was deleted.

How you would get this to work is that you make a shot sheet with your custom bullet so you have a shot ID for it, load it by using LoadEnemyShotData(path_to_file), then you could use that ID in your CreateShotA2().
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: AchySolrock on November 20, 2014, 05:54:19 AM
Ok, so I can't just plop a picture in and turn it into a bullet then. It would have to be an image from a ShotSheet.
I was just assuming it would be similar to give a bullet a graphic like it was to give one to the Boss Object. I don't know what actually counts as primitive objects or Sprite2D objects, other than that the Boss Object is one.

Thanks!
Now hopefully I can figure out how to make my own shot definition file and ShotConst file. Up till now, all I've been doing is drawing bullets. I'll use the defaults as a guide will show me how to make them properly. Though, setting the rect for things has been a little difficult for me to figure out.  :ohdear:

Oh, well, I'll figure out how rect works the more I mess with it it.
Thanks again!

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jimmy on November 23, 2014, 04:29:13 PM
I've got a problem with implementing sound effects into my script in ph3.

Although I've followed Helepolis' tutorial for doing so, using the functions LoadSound(...) and PlaySE(...) and putting them in @Initialize right below the ObjEnemy-functions
and other desired locations,
for some reason Danmakufu keeps spawning an error message saying that the line where @Initialize starts is "Unable to be interpreted", however,
the script runs flawlessly if I take these functions away or disable them.

I honestly don't have any idea why this is happening.
Have these functions been changed or updated in some way?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on November 23, 2014, 05:05:17 PM
Hello Jimmy,

Can you show us your script in pastebin and the error message as screenshot or text message exactly?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jimmy on November 23, 2014, 05:46:48 PM
That persistent error message reads as follows:

--------------------------------------------------------------------------
解釈できないものがあります(「;」を忘れていませんか)
C:/Users/KingJimmy/Saved Games/Touhou Danmakufu/script/Tutorial/test2.txt
test2.txt 17行目


@Initialize {
   bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
   ObjEnemy_Regist(bossObj);
   
   ObjMove_SetPosition(bossObj,190,-10
~~~
--------------------------------------------------------------------------

and refers to this part of the affected script:

http://pastebin.com/bPcCueqH (http://pastebin.com/bPcCueqH)


Every time I remove/disable the LoadSound and PlaySE functions, the script plays normally.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on November 23, 2014, 07:16:05 PM
The error message exactly reports what seems wrong. Before I'm going to spoil you the solution, I'm going to ask you to read and check very very carefully up to line #10.

You'll probably face palm when you see it.  :V

Edit: I can understand your confusion for this error message but I'll explain that once you detected your mistake.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jimmy on November 24, 2014, 12:56:16 PM
You'll probably face palm when you see it.  :V

Facepalm indeed :V

It's all about precision, that error was actually quite, if not too obvious.
Now the script runs perfectly. With the sound effects.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on November 24, 2014, 06:13:56 PM
Glad you discovered it.  ;)

You see, I am not sure if you have the latest ph3 version, but it reports English Error message as well.

Code: [Select]
Unable to be interpreted (Don't forget ";"s).
(解釈できないものがあります(「;」を忘れていませんか))
F:/Touhou project/th_dcs_ph3/script/thdcs/test.txt
test.txt line(行)=15

The only confusion here might be the line nummer. Basically the script runs up to that line and crashes. Thus you have to backtrack a little. Not often seen because usually the error msg line # points at correct lines. Lucky for you, your script was small so easier to find.

Always look out for syntax errors (forgetting or misplaced () [] {} ; etc etc.)

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jimmy on November 24, 2014, 07:50:58 PM
Yeah, overseeing tiny but important errors is quite a hardship for me as a novice in programming, but I'm confident that I'll get used to it and find out typing/syntax errors more easily. :)
By the way, I would like to ask how to implement objects into the script other than the boss and the bullets, for example the red spell circle, and make them rotate. I already took several attempts with using various Object-functions which don't seem to work, as Danmakufu either freezes or spawns an(other) syntax or (abc)-is-not-defined error.  :fail:

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on December 03, 2014, 08:52:06 PM
Hi!

Is someone know what is the "check" at the stg intertion_count line in the LogWindow?
(http://img110.xooimage.com/files/3/c/b/sans-titre-48dfa42.png)

I have some heavy frame drop even doing nothing and it's the only value that increase constantly. If I kill enemies or if I move the player this value decrease or return to zero.
And there is no lag when it's at zero.
It's seems there is not problem with this when I comment the ObjEnemy_SetIntersectionCircleToPlayer.

I really don't know how it is and how it work  ???
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on December 03, 2014, 09:53:52 PM
It's seems there is not problem with this when I comment the ObjEnemy_SetIntersectionCircleToPlayer.

Then there's the issue. How many times do you call ObjEnemy_SetIntersectionCircleToPlayer per frame? How many hitboxes are there?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on December 03, 2014, 10:10:52 PM
One ObjEnemy_SetIntersectionCircleToPlayer per enemy with 36 enemy.
I kown that's the source of the lag but... why? and why it's drop to zero even if I don't kill all the enemies? And if it's called 36 time per frame why it cause lag after a while and not at the start?

It's not really the issue that I don't understand but how this thing works.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on December 03, 2014, 10:56:26 PM
The check count is just the number of new collision checks being performed. These don't have to be collision to player either (although in this case the player collisions are the problematic ones).

The problem is that your enemies are doing something that starts the collision checks and they aren't being stopped/removed. Just pastebin your script; you should be doing that from the start.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on December 04, 2014, 08:28:43 AM
Unrelated to the user's problem: That new check is going to help me fix a few performance for my scripts. I should update my dnh version asap.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on December 04, 2014, 10:42:47 PM
The enemy task included and called in the stage script :
http://pastebin.com/raw.php?i=ihiQd8gj

And the stage function (called in the stage script):
http://pastebin.com/raw.php?i=wmZHph9v

And the task for spawning shot:
http://pastebin.com/raw.php?i=zMaLC7Jv

For some reason I separate all this things and play with include so I can't past the entire script (or I will past many little part of scripts).
If that can help, I explain:
In the same script I make several sub-stages with a task and a specific pattern (with it's own task) for each stage. So I separate sub-stage task, pattern task and enemy spawning function. I don't think it's come from this separation...


Now I've got the same problem with the enemy shots. A simple circle of 20 bullets make the frame drop ? 15 fps...
Is there a collision between enemy and enemy shot? And I have this problem with shots even if I comment the ObjEnemy_SetIntersectionCircleToShot and the
ObjEnemy_SetIntersectionCircleToPlayer line.
It's seem collisions are not deleted but... why?

edit: okay. It come form the player and not form the enemy/stage/otherrandomscript.
I try to see it by myself and... I come again if I don't find  :(
edit2: I found it. Player's hitbox was created every frame like enemy hitbox. I don't know haw I could make a such thing but I found it.
Thanks for the help. And Thank you Drake. Your explanation help me a lot.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on December 04, 2014, 11:33:58 PM
Cool. Just to mention, ObjEnemy_SetIntersectionCircleToShot(tile,x,y,0) doesn't remove the hitbox; the hitbox size will just be a single pixel. The SetIntersection functions are actually only valid for one frame, hence why you have to call it every frame in order to keep a hitbox. So really if you don't want a hitbox, don't call anything. Meanwhile, the ObjPlayer_AddIntersection functions only need to be called once and then are constantly active, which is why you had this problem.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on December 04, 2014, 11:56:19 PM
Thanks.
Indeed, the ADDIntersection is clear. But I remember why I do this. I move the hitbox graphic by a few pixel when the player move left or right and I want to let the hitbox centered on the hitbox graphic.But I forget that player hitbox are called one time and not every frame...
Also thanks for the advice about ObjEnemy_SetIntersectionCircleToShot (even if it seem it work with the 1 pixel hitbox but is better without).

Oh and not related but it's possible to don't turn enemy shot into star-item when it cleared by a player shot or bomb? (obviously it possible but how? A miracle function?).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on December 05, 2014, 12:45:41 AM
ObjShot_SetItemChange(obj, false);
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on December 05, 2014, 09:58:12 AM
It's perfect <3
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Justin on December 17, 2014, 02:52:35 AM
I'm back again.
So, I'm attempting to create my own dialogue script ( http://pastebin.com/8WTfSqJ6 )
The interests are lines 57 and 64. I want text to appear akin to IN, with the little transparent box and text appearing above it. However, the text always appears to be below the box, and I've tried two cases
 (one where box z = 99 and text z = 1, and vice versa) An example of what's going on:

(http://i40.photobucket.com/albums/e250/Justinwa0309/FadedText_zpsd7b3905f.png) (http://s40.photobucket.com/user/Justinwa0309/media/FadedText_zpsd7b3905f.png.html)

as opposed to the one without the box:
(http://i40.photobucket.com/albums/e250/Justinwa0309/Notsofadedtext_zps119a9f67.png) (http://s40.photobucket.com/user/Justinwa0309/media/Notsofadedtext_zps119a9f67.png.html)
 Any help would be appreciated.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on December 17, 2014, 03:14:00 AM
So, I'm attempting to create my own dialogue script ( http://pastebin.com/8WTfSqJ6 )
Use render priorities. http://dmf.shrinemaiden.org/wiki/Object_Functions#Obj_SetRenderPriority (http://dmf.shrinemaiden.org/wiki/Object_Functions#Obj_SetRenderPriority)

Changing Z changes the position of the object, not on which layer it is rendered.

EDIT: Also, I suggest using a border for that text or making the colors brighter - it's not particularly easy to read the bluer part on the blue background.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Justin on December 17, 2014, 03:44:40 AM
Use render priorities. http://dmf.shrinemaiden.org/wiki/Object_Functions#Obj_SetRenderPriority (http://dmf.shrinemaiden.org/wiki/Object_Functions#Obj_SetRenderPriority)

Changing Z changes the position of the object, not on which layer it is rendered.

EDIT: Also, I suggest using a border for that text or making the colors brighter - it's not particularly easy to read the bluer part on the blue background.
Is there a function for the border for text, or is that a custom font thing?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: gtbot on December 17, 2014, 04:31:21 AM
Have a look at the text functions (http://dmf.shrinemaiden.org/wiki/Text_Object_Functions) on the wiki., there are several border functions.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on December 17, 2014, 10:00:47 AM
Did anybody ever encountered textures/sprites being loaded but not properly visible in game? See below.

[attach=1]

This often happens when you simply boot the stage script for the first time (Note: this is not a package script, just plain stage for now). If I reload it with backspace then everything is fine. Sometimes the lanterns (red cubicles) won't proper show and sometimes the entire stage (as seen here). I want to avoid people playing this the ugly way when they "boot" my game.

The loading of textures is handled first when the stage is run (for now, later on when the full game is completed they will be pre-loaded).

Code: [Select]
// initialize stuff
@Initialize {
loadGraphics;
renderStage;
renderCamera;
}

// Function for loading all graphics into separate thread.
function loadGraphics {
// Stage 1
LoadTextureInLoadThread(balbg);
LoadTextureInLoadThread(balvloer);
LoadTextureInLoadThread(balmuur);
LoadTextureInLoadThread(balmat);
LoadTextureInLoadThread(balplafon);
LoadTextureInLoadThread(balplafon2);
LoadTextureInLoadThread(balslinger);
LoadTextureInLoadThread(balvspot);
LoadTextureInLoadThread(ballampion);
}
task renderStage {
Reset2DCamera; // Reset any possible 2D camera settings.
scrollStage; // Grand stage scrolling handler.

// Enable fog for the game. Fog minimum, maximum and colours are handled in threads.
SetFogEnable(true);

//------------------------------------------------------------------------------------------------------------------------------------------
// Stage 1 render
SetCameraPerspectiveClip(10,4096);
etc.................

renderStage defines fog, camera and contains stageenemy patterns etc. renderCamera is a listener thread for camera mutations and stuff.

Edit:

[12:50:21] <Drake> Helepolis: it's probably because you're loading resources in separate threads, so the rest of the script keeps running even though they aren't yet loaded
[12:50:53] <Drake> switch all the LoadTextureInLoadThread to just LoadTexture and see what that does
[12:52:00] <Drake> i expect it might pause a bit if it's loading lots of stuff, but then draw everything fine the first time
[12:53:42] <Drake> or maybe just yield for a second to let them load before you do start anything
[12:59:42] <Helepolis> Drake it happens on first load though. I'll try the loadtex and yield method now
[13:01:26] <Helepolis> delaying for 1 frame or 120 doesn't change result. Gonna try the load tex now
[13:02:38] <Helepolis> loadtex succeeds any time
[13:02:47] <Helepolis> so it is indeed an issue with loadinthread and loadtex standard

Now that made me curious, what is the exact technical reason for this?


Edit2:
[13:09:39] <Helepolis> in initialize i added wait(120)  after loadGraphics
[13:09:44] <Helepolis> so the stage isnt even booted before textures are loaded
[13:10:07] <Helepolis> loadgraphics is just a function, has no dependancy
[13:10:08] <Drake> ok so that wouldn't work, @init doesn't start @mainloop so no yielding is being done
[13:10:16] <Drake> you just didn't wait properly
[13:10:35] <Helepolis> then i'll move loadgraphics to first line in renderstage
[13:10:38] <Helepolis> and then put a yield there
[13:11:11] <Drake> just putting the wait()s at the beginning of the two tasks should be fine i think
[13:11:40] <Helepolis> ye that seems to have solved the problem
[13:11:48] <Helepolis> you're then right about the loading time.
[13:12:11] <Helepolis> though how come Loadtexture is faster than loadtextureinthread? Is it because loadtexture takes priority while loadinthread is spawned as a side thread?
[13:12:21] <Helepolis> so technically my stage is loaded before the textures are in memory ?
[13:12:37] <Drake> there's probably some overhead in making the other threads or something
[13:12:43] <Drake> i dunno
[13:12:54] <Drake> I imagine it's worth it if you have tons of resources
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Justin on December 17, 2014, 09:37:06 PM
Have a look at the text functions (http://dmf.shrinemaiden.org/wiki/Text_Object_Functions) on the wiki., there are several border functions.
Aaaand I'm an idiot who can't find anything. Thank you so much!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on December 18, 2014, 04:14:46 AM
Did anybody ever encountered textures/sprites being loaded but not properly visible in game? See below.

[attach=1]

This often happens when you simply boot the stage script for the first time (Note: this is not a package script, just plain stage for now). If I reload it with backspace then everything is fine. Sometimes the lanterns (red cubicles) won't proper show and sometimes the entire stage (as seen here). I want to avoid people playing this the ugly way when they "boot" my game.

I remember reading in the documentation that using LoadTextureInLoadThread can cause half/incomplete loaded textures though mkm specifically states that to only be the case for using that function in@Loading{}. @Loading should be where you're loading stuff anyway. It is called before Initialize and MainLoop, and you should only use LoadTexture(), LoadSound, and LoadScriptInLoadThread(I'm not too sure if the same applies to scripts that LoadScript is preferred).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on December 18, 2014, 09:06:02 AM
Aye, that is indeed what Drake also told me.

What technically went wrong was that LoadTextureInLoadThread is just like tasks a separate thread. Cannot confirm it but what I noticed is that LoadTexture takes supreme priority in Danmakufu. Notice my code that my @Initialize kicks off with three tasks which are parallel. renderStage spawns the entire 3D stage drawing and if there is no texture loaded in Danmakufu or partially, it will just draw a 'blanc' sprite in the respective colour of the sprite or nothing. (The lantern suppose to be suspended by fancy banners).

When you hit backspace it seems Dnh just reboots the script and doesn't clear the memory of loaded sprites/tex so that explains also why it looks fine because it takes aprox 60 frames to load my textures (Did some few delaying tests).

As soon as I put regular LoadTexture, my stage would always proper show, while I never changed the @Initialize or delayed the renderStage. I can only conclude that that LoadTexture is taking priority regardless of code running.

Basically it was a logic error I made with the order of handling but that was unintended as eventually everything will be moved to @Loading thread once the game is finished.

I wonder though what the advantages could be of LoadInThread, allow textures to be loaded simultaneously while loading sounds? For example @Loading thread taking the textures + sounds but don't need to be sequentially performed. Or perhaps flexible loading without pre-loading everything without interrupted/lagging your script. (Like before stages end, during the boss fight you could unload/garbage collect while preload next stage. I guess depends on how you manage your resources.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on December 19, 2014, 02:07:48 AM
I think the InLoadThread functions act as a personal @Loading{} on the spot and doesn't hold up the engine until the texture is completely loaded as you said. I don't use it for textures though. I use it to preload boss battles and scripts mainly. But to comment on the simultaneous loading of texture and sounds, @Loading will preform that already. For example, in MMS, I ascent through every texture in the game using LoadTexture while having an if statement to do the same for sound effects and music if possible(before the array ends).

I'm not 100% sure on the advantages for textures though. ido seemed to have skipped using @Loading + LoadTexture in RSS, and just jam everything into a function that calls LoadTextureInLoadThread a bunch of times from @Initialize. This could possibly explain the questionable loading times and occasional crashing when loading up the game.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Vampi on January 01, 2015, 03:48:25 PM
Have a  problem with player image.
The img is displayed incorect (more left from origin).

(http://savepic.ru/6519079.png)

let objPlayer = GetPlayerObjectID();
let current = GetCurrentScriptDirectory();

task TImage{
let path = GetCurrentScriptDirectory() ~ "51905.png";
ObjPrim_SetTexture(objPlayer, path);
Obj_SetRenderPriority(objPlayer, 0.95);
loop{
ObjSprite2D_SetSourceRect(objPlayer, 284, 117, 307, 157);
ObjSprite2D_SetDestCenter(objPlayer);
yield;}
}

"SourceRect" is correct.

Sorry for my ENG, and thx for help  :)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 01, 2015, 09:16:23 PM
Hmmm that is odd. You did use ObjSprite2D_SetDestCenter proper.

Have you set ObjRender_SetPosition anywhere? Because that will draw the sprite in the correct location.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 01, 2015, 09:53:26 PM
If your render priority is less than 20 or greater than 80, it will render above the STG Frame with the origin located at the top left corner of the window rather than the playing field.

Change this:

Code: [Select]
Obj_SetRenderPriority(objPlayer, 0.95);
to something between 0.20 and 0.80. I suggest 0.45.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 01, 2015, 10:56:42 PM
That is indeed good mention. Also could be because no SetPlayerClip; has been used or modified to decide boundaries how far the player can move. Then again, the hitbox should be outside the field too then no? Hmmm.

Vampi, please post entire code in pastebin.com if you're unable to solve it.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Vampi on January 02, 2015, 05:26:06 AM
Stil cant resolve.

Player script (Sorry for tons of "comment" - i'm repasting original rumia)
http://pastebin.com/SnYrG54e

boss script (if needed)
http://pastebin.com/dzakCbNv
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on January 02, 2015, 10:43:20 AM
You still have the line Obj_SetRenderPriorityI(GetPlayerObjectID,99) inside the enemy script.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Vampi on January 02, 2015, 11:32:59 AM
Oh  :ohdear:
Thx all for helping and usefull information )
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 02, 2015, 08:29:17 PM
I am creating a player script and want to set different shots for unfocused and focused movement. Is there a way to check whether the player is focused or is there something else for player scripts?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 02, 2015, 08:45:15 PM
I am creating a player script and want to set different shots for unfocused and focused movement. Is there a way to check whether the player is focused or is there something else for player scripts?

I suggest that you look at a player script for yourself and see how it is done.

Hint: Virtual Keys
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 02, 2015, 09:11:26 PM
I suggest that you look at a player script for yourself and see how it is done.

Hint: Virtual Keys
I found out, but thanks anyway.

Edit: I can't figure out why this definition for TShot doesn't cause the player to fire bullets:

Edit Mk.II: Giving an absolute path to the image file in the shot data sheets fixes the problem, but I'd like to avoid absolute paths.

Edit Mk.III:
Code: [Select]
./../resource/playershots.png. That was so obvious.

Code: [Select]
task TShot {
loop {
let x = GetPlayerX;
let y = GetPlayerY - 4;
let shot = GetVirtualKeyState(VK_SHOT);
let focus = GetVirtualKeyState(VK_SLOWMOVE);
if (shot == KEY_PUSH || shot == KEY_HOLD) {
if (focus == KEY_PUSH || focus == KEY_HOLD) {
CreatePlayerShotA1(x - 2, y, 10, 270, 2, 1, SPIKED_SEED);
CreatePlayerShotA1(x + 2, y, 10, 270, 2, 1, SPIKED_SEED);
CreatePlayerShotA1(x - 2, y, 10, 235, 1, 1, SPIKED_SEED);
CreatePlayerShotA1(x + 2, y, 10, 315, 1, 1, SPIKED_SEED);
CreatePlayerShotA1(x - 2, y + 8, 10, 90, 1, 1, SPIKED_SEED);
CreatePlayerShotA1(x + 2, y + 8, 10, 90, 1, 1, SPIKED_SEED);
}
else {
CreatePlayerShotA1(x, y, 10, 270, 5, 1, SILVER_ARROW);
}
}
yield;
}
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Maple on January 03, 2015, 01:35:06 PM
This may sound kind of dumb, but is there a way to save screenshots in the ph3 version? In the wiki i search for "screenshot" but there's only pressing "Home" for the 0.12m version. Googling* also didn't help much.

*I'm the paranoid who uses duckduckgo instead of google.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 03, 2015, 02:16:16 PM
This may sound kind of dumb, but is there a way to save screenshots in the ph3 version? In the wiki i search for "screenshot" but there's only pressing "Home" for the 0.12m version. Googling* also didn't help much.

*I'm the paranoid who uses duckduckgo instead of google.

http://dmf.shrinemaiden.org/wiki/Render_Functions#SaveSnapShotA1

Is this what you mean? Or are you referring to a generic screenshot, which puu.sh and a number of other things support?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Vampi on January 03, 2015, 02:30:43 PM
Hello again)
Now problem with Player directory script.

Package script

let ds = GetCurrentScriptDirectory();
let Module = GetModuleDirectory();
InitializeStageScene();
let pathMainScript = ds ~ "/Test.dnh";
//let pathPlayer = Module  ~ "script/SilentNight/Player/Arisa.txt";
let pathPlayer = Module ~ "script/player/default_player/Arisa.txt";
let indexStage = 1;
SetStageIndex(indexStage);
SetStageMainScript(pathMainScript);
SetStagePlayerScript(pathPlayer);
StartStageScene();


if use "Module  ~ "script/SilentNight/Player/Arisa.txt";" - player not found. But if copy to default folder - all ok.
"Arisa.txt" located in  "D:Danma   h_dnh_ph3scriptSilentNightPlayer"

If i run "Test.dnh" - all ok
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 03, 2015, 02:56:08 PM
As my math is horrible at such moments, I have 2 questions on creating pattern/shots

First one is a "crawling" or continuous curving shot, like the ones from SA I think.
[attach=1]

I have this already but apparently I seem to fail (feel free to laugh). The problem is that my shot doesn't even behave like this and doesn't even aim at the player initially.
Code: [Select]
task fireAfroCrawlShot00(obj) {

let sf = 0;
let dir = 0;

let crawlShot00 = CreateShotA(ObjMove_GetX(obj),ObjMove_GetY(obj),10);
let crawlShot01 = CreateShotA(ObjMove_GetX(obj),ObjMove_GetY(obj),10);

dir = GetAngleToPlayer(obj);

SetShotDataA(crawlShot00,0,3,dir,0,0,3,87);
SetShotDataA(crawlShot01,0,3,dir,0,0,3,87);

while(!Obj_IsDeleted(obj)) {
ObjMove_SetAngle(crawlShot00,dir);
ObjMove_SetAngle(crawlShot01,-dir);
dir = 12*sin(sf);
sf+=8;

yield;
}
}

Second one: How do I produce shapes using the correct math? Like a square, triangle, star. I've been staring at graphs and other gifs on the internet but I simply don't get how to transform the correct code. If someone can show me a simple example I can perhaps try to understand what is going on.




Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 03, 2015, 03:09:18 PM
Second one: How do I produce shapes using the correct math? Like a square, triangle, star. I've been staring at graphs and other gifs on the internet but I simply don't get how to transform the correct code. If someone can show me a simple example I can perhaps try to understand what is going on.
I assume you are not referring to ShootShape.

There are ways to use polar and parametric equations in Danmakufu, and then you can use a rotation matrix to alter the angle of given shape. You can also define a 2D array with the shape you would like or read from a binary text file, and then apply the rotation matrix there as well.

I used a star formed from a polar equation in my ICM contest entry - note that the code was meant for Miransu's custom 3D danmaku system and that it will require tweaking in order to be altered to standard polar/parametric:

Code: [Select]
    task SpawnStarA1(n){
if(ObjEnemy_GetInfo(objBoss, INFO_LIFE) <= 0){return;}//Default kill to prevent (0,0) spawning
let randx = rand(-75,75);
let randy = rand(-75,75);
let angleT = 0;//0 needed for nice star
loop(90){
  let modulus = 12/cos((2/n)*acos(cos(n*angleT/2)));//where n is number of sides. Flip across y = x to get pentagram
  CreateBullet(randx+modulus*sin(angleT),randy+modulus*cos(angleT), 0);
  angleT+=9;//Cycle 810 degrees.
}
    }
The
Code: [Select]
let modulus is the radius portion of the polar coordinate of each given spawn point, while angleT is the angle portion.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 03, 2015, 03:20:27 PM
I assume you are not referring to ShootShape.
ShootShape?

There are ways to use polar and parametric equations in Danmakufu, and then you can use a rotation matrix to alter the angle of given shape. You can also define a 2D array with the shape you would like or read from a binary text file, and then apply the rotation matrix there as well.
I'll be honest to say that none of this actually makes sense to me. It feels like magic, honestly. Even if I am allowed to use your code as example, just blatantly copy/pasting it and adjusting here and there still won't make me understand it though.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Maple on January 03, 2015, 03:33:29 PM
Is this what you mean? Or are you referring to a generic screenshot, which puu.sh and a number of other things support?

I was referring to generic ones. 0.12m allows for entire screen, playfield, playfield 1/4. I'm interested playfield simple, specifically. Does ph3 have a (combination of) key(s) to take these without other programs?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: gtbot on January 03, 2015, 06:01:36 PM
First one is a "crawling" or continuous curving shot, like the ones from SA I think.
In your code, you are replacing dir (which is GetAngleToPlayer) with 12*sin(sf),, causing it to oscillate around the angle 0. Adding another variable, like let shift = 0, then putting shift = 12*sin(sf) in the loop, and putting dir+shift and dir-shift as the angles should do the trick.

Second one: How do I produce shapes using the correct math? Like a square, triangle, star. I've been staring at graphs and other gifs on the internet but I simply don't get how to transform the correct code. If someone can show me a simple example I can perhaps try to understand what is going on.

Wish I could help more, but this is rather complicated for me as well. An alternative to drawing shapes like triangles/squares/etc, would be to ascent through the number of sides, and draw a line of bullets in the angle (360/sides*i). Here's an example,

(http://puu.sh/e1l7R/2f01c827b2.jpg)

Code: [Select]
let sides = 8; //number of edges
let bullets = 24; //number of bullets in each edge
let size = 48; //how large each edge is
let x = EnemyX;
let y = EnemyY;
ascent(i in 0..sides){
let sangle = 360/sides*i; // angle of the edge
let xinc = (size/bullets)*cos(sangle);
let yinc = (size/bullets)*sin(sangle);
ascent(b in 0..bullets){
CreateShotA1(x, y, 0, sangle, 30, 10);
x+=xinc;
y+=yinc;
}
}


For more complicated shapes, you would need to account for the angle in a different manner, as this example only works for simple polygons. This example is also not centered.

I can't answer your original question fully (which I assume you mean you want to use equations, not loops), as I don't understand it either. It's one of my questions, as well.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 04, 2015, 07:24:25 AM
Another bug is stumping me. For some reason, the yield statement in this code doesn't seem to function.

Code: [Select]
task renderScore(x, y, amt, color) {
let pathDigit = GetCurrentScriptDirectory ~ "../resource/digits_small.png";
let obj = ObjPrim_Create(OBJ_SPRITE_LIST_2D);
ObjPrim_SetTexture(obj, pathDigit);
ObjRender_SetBlendType(obj, BLEND_ALPHA);
ObjRender_SetAlpha(obj, 127);
ObjRender_SetColor(obj, color[0], color[1], color[2]);
let listNum = DigitToArrayBaseWC(amt, 16);
let digits = length(listNum);
ascent (j in 0 .. 30) {
ObjRender_SetY(obj, y - 8 - j);
ObjSpriteList2D_ClearVertexCount(obj);
ascent (iObj in 0 .. digits) {
let num = listNum[iObj];
ObjRender_SetX(obj, x + 2 * digits - 4 * iObj);
ObjSpriteList2D_SetSourceRect(obj, num * 16, 0, (num + 1) * 16, 16);
ObjSpriteList2D_SetDestRect(obj, 0, 0, 8, 8);
ObjSpriteList2D_AddVertex(obj);
}
// This one.
yield;
}
ObjSpriteList2D_ClearVertexCount(obj);
ObjRender_SetY(obj, y - 22);
Obj_Delete(obj);
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on January 04, 2015, 07:41:37 AM
Are you sure it's the yield? If that were the case, then all you would notice is that the object doesn't show up, which doesn't indicate a whole lot. What tests have you done? Have you tried commenting out the inner loop and doing something else more noticeable to confirm it is the yield?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 04, 2015, 08:05:53 AM
Are you sure it's the yield? If that were the case, then all you would notice is that the object doesn't show up, which doesn't indicate a whole lot. What tests have you done? Have you tried commenting out the inner loop and doing something else more noticeable to confirm it is the yield?
I put an error message right after the loop, and it didn't show; in other words, the loop doesn't break. In case you're curious, here's the whole file (it's an item script):

Code: [Select]
#include "../item/itemConsts.dnh"
#include "../prologue.dnh"

@Initialize {
LoadItemData(GetCurrentScriptDirectory ~ "../item/items.dnh");
SetDefaultBonusItemEnable(false);
}

task getItem(type, objItem) {
let x = ObjMove_GetX(objItem);
let y = ObjMove_GetY(objItem);
alternative (type)
case (POINT_ITEM) {
let piv = getPIV;
let y = GetPlayerY;
let multiplier = min(1.0, 1.25 - y / 600);
addScore(multiplier * piv);
addElemPoints(FIRE, multiplier * multiplier * 16);
renderScore(x, y, roundScore(multiplier * piv), [[255, 255, 255], [255, 255, 64]][multiplier == 1]);
}
case (GREEN_ITEM) {
addPIV(32);
renderScore(x, y, 32, [64, 192, 64]);
}
case (LIFE_FRAGMENT) {
setLifeFrag(getLifeFrag + 1);
if (getLifeFrag >= getLifeFragR) {
setLifeFrag(getLifeFrag - getLifeFragR);
SetPlayerLife(GetPlayerLife + 1);
setLifeFragR(getLifeFragRR + 1);
}
renderScore(x, y, 1, [255, 64, 255]);
}
case (BOMB_FRAGMENT) {
setBombFrag(getBombFrag + 1);
if (getBombFrag >= getBombFragR) {
setBombFrag(getBombFrag - getBombFragR);
SetPlayerSpell(GetPlayerSpell + 1);
}
renderScore(x, y, 1, [202, 255, 192]);
}
}

task renderScore(x, y, amt, color) {
let pathDigit = GetCurrentScriptDirectory ~ "../resource/digits_small.png";
let obj = ObjPrim_Create(OBJ_SPRITE_LIST_2D);
ObjPrim_SetTexture(obj, pathDigit);
ObjRender_SetBlendType(obj, BLEND_ALPHA);
ObjRender_SetAlpha(obj, 127);
ObjRender_SetColor(obj, color[0], color[1], color[2]);
let listNum = DigitToArrayBaseWC(amt, 16);
let digits = length(listNum);
ascent (j in 0 .. 30) {
ObjRender_SetY(obj, y - 8 - j);
ObjSpriteList2D_ClearVertexCount(obj);
ascent (iObj in 0 .. digits) {
let num = listNum[iObj];
ObjRender_SetX(obj, x + 2 * digits - 4 * iObj);
ObjSpriteList2D_SetSourceRect(obj, num * 16, 0, (num + 1) * 16, 16);
ObjSpriteList2D_SetDestRect(obj, 0, 0, 8, 8);
ObjSpriteList2D_AddVertex(obj);
}
yield;
}
ObjSpriteList2D_ClearVertexCount(obj);
ObjRender_SetY(obj, y - 22);
Obj_Delete(obj);
}

@Event {
alternative (GetEventType)
case (EV_DELETE_SHOT_TO_ITEM) {
let shot = GetEventArgument(0);
let position = GetEventArgument(1);
if (length(position) > 0) {
createItemU1(GREEN_ITEM, position[0], position[1], 0);
}
CollectAllItems;
}
case (EV_GET_ITEM) {
getItem(GetEventArgument(0), GetEventArgument(1));
}
}

Replacing task with function gets rid of the infinite loop, but the digits don't appear at all.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on January 04, 2015, 11:32:13 AM
The problem isn't that the yield isn't working, but that the loop doesn't end. That's a big difference; if the yield wasn't working, you'd expect the loop to end, just instantly.

Keeping that difference in mind, the yield works fine, but the problem is that it yields to nothing. An item script is basically the same as any other, structurally. You probably know you need a yield in the @MainLoop for boss scripts, and this (along with plural, stage, and player scripts) is no different.

To explain: where does this yield statement lead to? Nowhere, right? The script hits the yield statement, it goes "ok I'll stop here and resume later". Maybe some other events are triggered, maybe some other functions or tasks are run. If any of them yield, "ok I'll stop here and resume later". But right now, there's nothing that ever resumes the threads. If you stick a yield in @MainLoop, which runs every frame, then @MainLoop will yield over to whatever is next in the thread queue and everything will work as intended.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 04, 2015, 01:34:16 PM
In your code, you are replacing dir (which is GetAngleToPlayer) with 12*sin(sf),, causing it to oscillate around the angle 0. Adding another variable, like let shift = 0, then putting shift = 12*sin(sf) in the loop, and putting dir+shift and dir-shift as the angles should do the trick.
Gaaaah it was that easy I see. Now I understand my error as well. Working like a charm now, thank you for the help all.

The whole shape thing is a pain in the butt huh. I did manage to take a look at the example of Sparen. It draws a nice pentagram but seems the bullets are more spaced out towards the points of the star. I'm not trying to create anything extremely complicated. A simple square / triangle for example and maybe star at max. I'll study Sparen and your examples and get cracking on the shapes and such tonight after dinner and after some work on Stage 2 of my game (it is near completion). Will inform about the success of the shapes.



Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 04, 2015, 01:37:13 PM
Gaaaah it was that easy I see. Now I understand my error as well. Working like a charm now, thank you for the help all.

The whole shape thing is a pain in the butt huh. I did manage to take a look at the example of Sparen. It draws a nice pentagram but seems the bullets are more spaced out towards the points of the star. I'm not trying to create anything extremely complicated. A simple square / triangle for example and maybe star at max. I'll study Sparen and your examples and get cracking on the shapes and such tonight after dinner and after some work on Stage 2 of my game (it is near completion). Will inform about the success of the shapes.

Yeah, that's the main problem with polar and parametric equations. The bullets will never be spaced out the way you want them to be. It'd require a lot of work to force the distance between bullets to be equal (you would have to use trig in your angle incrementation, most likely). It has its uses though.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 04, 2015, 04:32:47 PM
The problem isn't that the yield isn't working, but that the loop doesn't end. That's a big difference; if the yield wasn't working, you'd expect the loop to end, just instantly.

Keeping that difference in mind, the yield works fine, but the problem is that it yields to nothing. An item script is basically the same as any other, structurally. You probably know you need a yield in the @MainLoop for boss scripts, and this (along with plural, stage, and player scripts) is no different.

To explain: where does this yield statement lead to? Nowhere, right? The script hits the yield statement, it goes "ok I'll stop here and resume later". Maybe some other events are triggered, maybe some other functions or tasks are run. If any of them yield, "ok I'll stop here and resume later". But right now, there's nothing that ever resumes the threads. If you stick a yield in @MainLoop, which runs every frame, then @MainLoop will yield over to whatever is next in the thread queue and everything will work as intended.

Well that fixed the problem, thank you. I meant to say that the yield wasn't working properly.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 04, 2015, 09:30:44 PM
A reminder that a new version of Danmakufu has been released.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 04, 2015, 09:42:40 PM
A reminder that a new version of Danmakufu has been released.

Finally, custom bullet scripts! (Though what are the advantages over using tasks?)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: gtbot on January 04, 2015, 10:27:27 PM
No idea just yet, the documentation has not yet been updated, nor are there any samples yet. I'm assuming it might be like Item Scripts, though.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 04, 2015, 10:39:12 PM
Nice to see Miransu and others from western community committing testing feedback for bugs and such. Mkm is doing a good job with the engine development.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 04, 2015, 11:01:54 PM
By the way, is it possible to change the background at runtime?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 04, 2015, 11:49:19 PM
By the way, is it possible to change the background at runtime?

What do you mean? By using CommonData, you can change the background at will.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 04, 2015, 11:51:54 PM
What do you mean? By using CommonData, you can change the background at will.

Could you please elaborate or show an example?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 05, 2015, 12:19:21 AM
Could you please elaborate or show an example?

Have a CommonData in your stage that changes once a certain thing has happened. Have a counter in your Background file, and have an if statement in the main loop of your background that, if the CommonData has been triggered and the counter is within a certain value, something changes and the counter is incremented.

I would show an example but my DEC Stage 6 background code is probably overkill for an example.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 05, 2015, 12:30:13 AM
Have a CommonData in your stage that changes once a certain thing has happened. Have a counter in your Background file, and have an if statement in the main loop of your background that, if the CommonData has been triggered and the counter is within a certain value, something changes and the counter is incremented.

I would show an example but my DEC Stage 6 background code is probably overkill for an example.

One question: why would I need a counter?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 05, 2015, 01:33:09 AM
One question: why would I need a counter?

For smooth transitioning from one background to another. If you just set completely different stuff within one frame, it is extremely disorienting
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 05, 2015, 02:26:16 AM
For smooth transitioning from one background to another. If you just set completely different stuff within one frame, it is extremely disorienting

I happened to do this without a counter:

Code: [Select]
// background

#include "./../prologue.dnh"

let bSpell = false;
let current = GetCurrentScriptDirectory();
let w = GetStgFrameWidth;
let h = GetStgFrameHeight;
let obj;

@Initialize {
let path = current ~ backgroundImage[getBGIndex];
obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj, path);
ObjRender_SetBlendType(obj, BLEND_ALPHA);
ObjSprite2D_SetSourceRect(obj, 0, 0, w, h);
ObjSprite2D_SetDestRect(obj, 0, 0, w, h);
Obj_SetRenderPriority(obj, 0.21);
changeBackground;
}

@MainLoop {
let objScene = GetEnemyBossSceneObjectID();
bSpell = objScene != ID_INVALID && ObjEnemyBossScene_GetInfo(objScene, INFO_IS_SPELL);
yield;
}

task changeBackground {
let prev = getBGIndex;
loop {
if (getBGIndex != prev) {
let path = current ~ backgroundImage[getBGIndex];
let newObj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(newObj, path);
ObjRender_SetBlendType(newObj, BLEND_ALPHA);
ObjSprite2D_SetSourceRect(newObj, 0, 0, w, h);
ObjSprite2D_SetDestRect(newObj, 0, 0, w, h);
Obj_SetRenderPriority(newObj, 0.21);
ascent (i in 0 .. 120) {
ObjRender_SetAlpha(obj, 255 - (i / 120 * 255));
ObjRender_SetAlpha(newObj, i / 120 * 255);
yield;
}
obj = newObj;
}
prev = getBGIndex;
yield;
}
}

@Finalize {
Obj_Delete(obj);
}

I think I beat you this time.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 05, 2015, 03:19:12 AM
I happened to do this without a counter:

I think I beat you this time.

There's more than one way to do it.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TresserT on January 08, 2015, 06:36:17 AM
Is it possible to temporarily/permanently disable the backspace key? And by that, I mean the "start script from beginning" thing it does.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on January 08, 2015, 07:56:28 AM
It seems like that's something enforced by Danmakufu. If you were testing your own scripts, you could design a quick package script to run the singles/plurals/stages you are making, since the "retry script" hotkey is disabled in packages. It's a bit tedious, though, and I'm not sure whether it's worth the time and effort.

Unfortunately, backspace is not bound to a virtual key, so you can't force the key to a certain press state.

... This leads me to believe that Danmakufu has a "default package" that runs singles and plurals, which you can't edit. It seems that the resource folder only contains the stage codes for running plurals and singles, which are used by this hypothetical "hidden default package".

Of course, this is just my speculation, and may not actually be the case. However, what I can do is suggest to mkm a function that can change the key for retrying scripts, just like I had requested SetSkipModeKey.

Are you, perhaps, making a kind of typing game in Danmakufu?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TresserT on January 08, 2015, 08:14:44 AM
It seems like that's something enforced by Danmakufu. If you were testing your own scripts, you could design a quick package script to run the singles/plurals/stages you are making, since the "retry script" hotkey is disabled in packages. It's a bit tedious, though, and I'm not sure whether it's worth the time and effort.

Unfortunately, backspace is not bound to a virtual key, so you can't force the key to a certain press state.

... This leads me to believe that Danmakufu has a "default package" that runs singles and plurals, which you can't edit. It seems that the resource folder only contains the stage codes for running plurals and singles, which are used by this hypothetical "hidden default package".

Of course, this is just my speculation, and may not actually be the case. However, what I can do is suggest to mkm a function that can change the key for retrying scripts, just like I had requested SetSkipModeKey.

Are you, perhaps, making a kind of typing game in Danmakufu?

Haha no, I'm nowhere near that creative. I'm using CommonAreaDatas to try and make some a menu-like scripts. I have it so that when you hit backspace during a stage you restart that stage, which is fine, but if you hit backspace during stage select it returns you to the difficulty screen instead of the main menu, which is not fine. It doesn't sound that bad, but it screws up all the CommonAreaDatas. But if it can't be helped I'll just find another way to do menus =P
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 08, 2015, 08:57:47 AM
Semi related, speaking of CommonDataAreas, why is it that when I try get the data it returns me the default value instead?

For example SetAreaCommonData("BGM","Vol",100). If I want to GetAreaCommonData("BGM","Vol",0) it will always keep returning me the 0 instead of the 100 as stored. Am I missing something?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: arby26 on January 08, 2015, 09:11:43 AM
Semi related, speaking of CommonDataAreas, why is it that when I try get the data it returns me the default value instead?

For example SetAreaCommonData("BGM","Vol",100). If I want to GetAreaCommonData("BGM","Vol",0) it will always keep returning me the 0 instead of the 100 as stored. Am I missing something?

I believe you need to create the common data area first, with CreateCommonDataArea ("BGM").
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 08, 2015, 09:31:21 AM
/me facepalms

Seriously the scripting is starting to take its toll for going all out for last 3 weeks. But I have to....

Thanks.

Edit: Though that makes me realise, Ph3 isn't warning you nor throwing errors at you for this. It perfectly accepts the fact you're setting AreaCommonData and trying to get it. I guess something along the lines of strings and such?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: arby26 on January 08, 2015, 10:13:34 AM
Common datas seem to be one of those things that we have to go out of our way to handle. I try to treat use them as a last resort.

There's an IsCommonDataAreaExists() for checking the areas themselves.

I like that it returns the default value instead of erroring. In my projects there is at least some common data for game settings change in the package script, but the default values let me still test parts of the game as singles/plurals/stages.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 08, 2015, 11:20:27 AM
I meant more like the Engine throwing errors because there is no such commondata defined but it seems like SetAreaCommonData already behaves like setting it but it is non existent or so  ???

Oh well.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 08, 2015, 09:19:51 PM
It seems like that's something enforced by Danmakufu. If you were testing your own scripts, you could design a quick package script to run the singles/plurals/stages you are making, since the "retry script" hotkey is disabled in packages. It's a bit tedious, though, and I'm not sure whether it's worth the time and effort.

Unfortunately, backspace is not bound to a virtual key, so you can't force the key to a certain press state.

... This leads me to believe that Danmakufu has a "default package" that runs singles and plurals, which you can't edit. It seems that the resource folder only contains the stage codes for running plurals and singles, which are used by this hypothetical "hidden default package".

Of course, this is just my speculation, and may not actually be the case. However, what I can do is suggest to mkm a function that can change the key for retrying scripts, just like I had requested SetSkipModeKey.

Are you, perhaps, making a kind of typing game in Danmakufu?

They're in the resource/script/ directory. Nothing about backspace, though.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on January 08, 2015, 09:37:19 PM
They're in the resource/script/ directory. Nothing about backspace, though.

It seems that the resource folder only contains the stage codes for running plurals and singles, which are used by this hypothetical "hidden default package".



Actually, it is possible to recreate Danmakufu's default script selection menu using these functions found here, and a bit of creativity:
http://www.geocities.co.jp/SiliconValley-Oakland/9951/pre/th_dnh_help_v3_data/func_common_std.html#sec_path

However, as I said it's probably not worth the time and effort required to create such a replication script.

I could always ask mkm about how script selection is handled (like a package or whatever) in order to support or refute my hypothesis, but, again...
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on January 09, 2015, 06:57:34 PM
I meant more like the Engine throwing errors because there is no such commondata defined but it seems like SetAreaCommonData already behaves like setting it but it is non existent or so  ???

Oh well.

That is what the default value is for when getting the commondata. If there were no default data then it would error or crash like using Obj_GetValue instead of GetValueD on an object that doesn't have the variable you set to it defined.

EDIT: Also, the backspace restart function is a line of code found in the TStageScene task of the default package system, of course the package is not available for us to edit for the standard danmakufu GUI but you can find the line of code in that task for creating your own package system.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 11, 2015, 02:45:53 AM
Why does StartStageScene throw an error about not finding the player? I've called SetStageIndex, SetStageMainScript, and SetStagePlayerScript, and don't know what I missed.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on January 11, 2015, 03:18:55 AM
Why does StartStageScene throw an error about not finding the player? I've called SetStageIndex, SetStageMainScript, and SetStagePlayerScript, and don't know what I missed.

#Player[] in the header of the script must contain the path to the player as well, (which I find to be kind of dumb, but eh.)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Vampi on January 11, 2015, 10:52:42 AM
Semi related, speaking of CommonDataAreas, why is it that when I try get the data it returns me the default value instead?

For example SetAreaCommonData("BGM","Vol",100). If I want to GetAreaCommonData("BGM","Vol",0) it will always keep returning me the 0 instead of the 100 as stored. Am I missing something?
U dont forget this?
CreateCommonDataArea
SetAreaCommonData
SaveCommonDataAreaA1
LoadCommonDataAreaA1
GetAreaCommonData
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 13, 2015, 04:15:08 AM
Do the text file object functions fail to handle UTF-16LE correctly? Of course, you can try encoding your file in ShiftJIS, until you want to translate your game into something such as Korean.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on January 13, 2015, 03:48:53 PM
Do the text file object functions fail to handle UTF-16LE correctly? Of course, you can try encoding your file in ShiftJIS, until you want to translate your game into something such as Korean.

Unicode little endian...? I'm sure it should work properly. All of my codes are encoded with UTF-8 without the Byte order mark, though.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 14, 2015, 05:27:58 AM
Unicode little endian...? I'm sure it should work properly. All of my codes are encoded with UTF-8 without the Byte order mark, though.

I wasn't talking about source code. I was talking about reading text files, and apparently mkm hasn't taken the relevant functions into account when making the transition to Unicode.

(and under what conditions does ObjSound_Play fail?)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on January 14, 2015, 09:25:51 AM
I wouldn't be surprised if he did, I mean he didn't even implement GetFilePathList (or whatever that new function introduced in pre6 was callled) even though he listed it as a new addition.

Did you use ObjSound_Load? Beyond that I think I'll have to take a look in your code for details
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Baron_Blade on January 14, 2015, 02:15:32 PM
I swear, each problem I have is worse than the last. I'm trying to make a Last Word package with a script that allows you to play through them all. But, I have two big problems. I can't load sounds or images through the bosses' scripts except for the boss herself, and when I try to play the plural script, Danmakufu crashes. No error, just a crash. I've compared everything in my function_lib to my other plurals and it should work just fine.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 14, 2015, 09:35:47 PM
I wouldn't be surprised if he did, I mean he didn't even implement GetFilePathList (or whatever that new function introduced in pre6 was callled) even though he listed it as a new addition.

Can I contact him about the problem then, or should I leave that for someone else?

Quote
Did you use ObjSound_Load? Beyond that I think I'll have to take a look in your code for details
Yes, I did. However, the sound object is created in a package script and stored into common data.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on January 14, 2015, 09:39:57 PM
You can contact him. Anyone can contact him. Over in LOCAA, we tend to just have one person collect bug reports from the other users and put it all under his name. Usually, that person is Ultima.

---

The way I do it in Digital Earth: Contest is like so:

I use User Events to notify the package script from the stage scripts.
Each time the package script receives a notification, the sound will be played. That means, the package script's @Event will contain the code for calling ObjSound_Play, instead of the stage script.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 14, 2015, 10:49:07 PM
You can contact him. Anyone can contact him. Over in LOCAA, we tend to just have one person collect bug reports from the other users and put it all under his name. Usually, that person is Ultima.

---

The way I do it in Digital Earth: Contest is like so:

I use User Events to notify the package script from the stage scripts.
Each time the package script receives a notification, the sound will be played. That means, the package script's @Event will contain the code for calling ObjSound_Play, instead of the stage script.

Thanks for your explanation of what you do. Anyway, I'll wait until there's an option for which encoding to choose when reading text files. Barring that, I'll just have to use a Python script to convert all the text files into a binary format.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on January 15, 2015, 12:14:10 AM
I already contacted mkm about my GetFilePathList() request not actually being implemented. He said that the function was named GetFileList() and that it will get its intended name in the next update.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 15, 2015, 12:22:19 AM
I already contacted mkm about my GetFilePathList() request not actually being implemented. He said that the function was named GetFileList() and that it will get its intended name in the next update.
I was asking about the inability to choose an encoding for reading from text file objects.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on January 15, 2015, 12:39:48 AM
I was asking about the inability to choose an encoding for reading from text file objects.

Code: [Select]
ObjFileB_SetByteOrder()
  ENDIAN_LITTLE:リトルエンディアン
  ENDIAN_BIG:ビッグエンディアン

ObjFileB_SetCharacterCode()
  CODE_ACP:ANSI (Shift-JIS)
  CODE_UTF8:UTF8
  CODE_UTF16LE:UTF16LE
  CODE_UTF16BE:UTF16BE

I'm pretty sure these two functions can do what you're asking.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 15, 2015, 12:42:25 AM
Code: [Select]
ObjFileB_SetByteOrder()
  ENDIAN_LITTLE:リトルエンディアン
  ENDIAN_BIG:ビッグエンディアン

ObjFileB_SetCharacterCode()
  CODE_ACP:ANSI (Shift-JIS)
  CODE_UTF8:UTF8
  CODE_UTF16LE:UTF16LE
  CODE_UTF16BE:UTF16BE

I'm pretty sure there's no difference between a text file and a binary file.

I believe those apply only to binary file objects. In fact, using these functions on a text file object doesn't even raise an error - it simply fails silently.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on January 15, 2015, 12:55:10 AM
Indeed they do, currently there is no way to change the reading for normal text files. You can try asking mkm about it however, it may not be implemented right away. Requests like those tend to get added to what we in locaa call "the list". Its pretty big and contains many requested functions that have not been implemented, or bugs that have not been fixed yet. Informing mkm about it is still worth a try, if it wasn't for people requesting specific visual effect capabilities (all added to "the list") we may not have had HLSL implemented.

You may have to find some clever workaround in order to achieve what you want, what that is, I can't help there.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 15, 2015, 01:28:17 AM
Indeed they do, currently there is no way to change the reading for normal text files. You can try asking mkm about it however, it may not be implemented right away. Requests like those tend to get added to what we in locaa call "the list". Its pretty big and contains many requested functions that have not been implemented, or bugs that have not been fixed yet. Informing mkm about it is still worth a try, if it wasn't for people requesting specific visual effect capabilities (all added to "the list") we may not have had HLSL implemented.

You may have to find some clever workaround in order to achieve what you want, what that is, I can't help there.

I can't seem to post to the official forums...

Sorry for annoying you.

YAE (Yet Another Edit): Those two functions don't even work on binary files.
YaeMk.II: I realized that it was due to my Python script reading text data in ANSI and not UTF-8.
YaeMk.III: Now the text won't display the proper characters. The guillemets appear as boxed question marks, and the letters with carons appear as unboxed question marks.
YaeMk.IV: Using the default font instead of Consolas solves the problems with guillemets, but the accented letters still appear incorrectly.
I Hope This Is The Last One I Have To Make: Apparently another bug on mkm's part. ObjFileB_ReadString apparently can't return a string with any characters outside the Shift-JIS character set (http://pastebin.com/syq3BHQt), regardless of the encoding set for it.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 15, 2015, 05:50:41 PM
OK. So here's a series of questions I really want to have answered for future use.

Firstly, what exactly does 'ref' mean in the Log Window? Is it how many copies of the file have been saved to RAM? Is it how many objects are using the file? Additionally, is the memory address the RAM memory address

Secondly, how does loading of assets such as sound and images actually work? If you do not load a file with LoadImage or LoadImageInThread, does it load automatically? If so, does RemoveTexture actually purge a loaded file from memory? I ask because purging large files from memory after they have been used for the last time is a reliable way to lower the amount of stress that is placed on ones computer. I ask because I load all of my main images and sounds during a loading phase of the package, and I am experimenting with a way to purge those files until they are needed again. More specifically, I plan to LoadImage in @Loading at the start of the stage for images that have already been loaded (in case the stage is replayed), and then RemoveTexture in @Finalize, so that the files are removed. Doing this, however, leaves references to the file, so I cannot be sure that it has been purged from Danmakufu's memory.

Finally, a question about archive files. I have noticed that archive files do not work based on a directory structure in that if you archive all the contents of a folder called 'img' and leave the archive in the folder img, Danmakufu cannot find it, but if placed outside of the directory 'img', Danmakufu will be able to read the files inside the archive. The path after loading still shows that the folder 'img' is in the file path despite the images' location on the computer not being in img but rather in an archive located one directory above img. How does this affect multiple-archive systems where some filenames are the same, and how does Danmakufu's archive system actually WORK?

Thank you.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on January 15, 2015, 10:28:51 PM
1: ref is the amount of times something was used while it is loaded. (the number is abit weird and doesn't always add up correctly)

2: Textures load when used regardless unless it already exists. RemoveTexture does exactly what it says. (I'm very disappointed that you asked this. You are no stranger to danmakufu at all, and the second question could've been answered on your own by testing it.)

Removing stuff after every script ends is kind of pointless unless its menu related things, you're still gonna have many textures hanging around during the stage; the performance increase is insignificant and won't weigh over the other more important things that will slow dmf down. Things that will have the biggest impact on danmakufu are: excessive running tasks(800+), excessive heavy math calculations, too many shots on screen with enabled hitboxes, too many shots on screen with more than one hitbox enabled(the cause of lag for curvy lasers), rendering the screen to a rendertarget. Those things are what you should be worrying about, not loading a bunch of textures and sound effects.

3: Archive files save the file path to the directory as if the files were not compressed, and the archive file was a folder. Danmakufu doesn't check by filename alone, it checks the file path exactly. You cannot however, compress different archives into one big archive. The tool itself works as a lock to prevent others from touching resources, there is some compression but it isn't anything big.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 15, 2015, 10:59:45 PM
3: Archive files save the file path to the directory as if the files were not compressed, and the archive file was a folder. Danmakufu doesn't check by filename alone, it checks the file path exactly. You cannot however, compress different archives into one big archive. The tool itself works as a lock to prevent others from touching resources, there is some compression but it isn't anything big.

If it checks the file path exactly, then does that mean that the 'folder' name Danmakufu reads from the archive file is the directory in which the files originated? Otherwise it should not be able to read CSD~system/img/filename.png when filename.png is inside system/imgarchive.dat

Or am I wrong.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on January 15, 2015, 11:33:49 PM
it acts as a folder, so if you move that archive somewhere it shouldn't have been then those files won't be referenced from the same location anymore. so if you had an img archive and moved it to the root directory of danmakufu, csd~"./mygame/img/ will not work and instead, module~"./img/ will be the new location. If the archive stays in the same location as the folder that held the files you packed then there is no need to change any file paths within your scripts, once AddArchiveFile is used then the engine will treat any path going to "./mygame/img/ as apart of that archive and read from there.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Justin on January 16, 2015, 12:31:10 AM
I have returned  :derp:
This time, I've got two issues.
My stage 1 script: (http://pastebin.com/7wfpMXyb) ((Interest around line 228))
The first is this error: すでにEnemyBossSceneオブジェクトが存在します. I see that this has come up before once here, but the issue then isn't the one I'm experiencing now. What happens is that whenever a player suicides before the midboss, the game will give that error and then crash. If one dies after the midboss fight, the game doesn't run the endscene thing (save replay, quit, replay) until the actual boss starts. Do I have too many bosses in one script? I mean, they're called separately, but could this still confuse the engine?

The second issue isn't really a coding issue, although it may be. In Touhou games, we've seen a form of "music syncing," like the midboss popping out at the most exciting part of a song. I did that for the first stage of the game, and it worked fine, until testing it on my friend's computer. The boss came 2-3 seconds late on his computer, but it syncs perfectly on mine. Something is causing one of us to go either too fast, or too slow. I have two dropbox links to show you what I mean (I'm Justin, friend is Cam): http://bit.ly/STG1CamVer and http://bit.ly/STG1JustinVer
 Something I may have narrowed it down to was that he's running Win 8.1, and I'm running Win 7. Just a theory, though.

Well, those are my problems for the time being.  I really hope I can get better at this and start returning the favor by helping others here, eventually.
Until then, thank you!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 16, 2015, 01:24:44 AM
The second issue isn't really a coding issue, although it may be. In Touhou games, we've seen a form of "music syncing," like the midboss popping out at the most exciting part of a song. I did that for the first stage of the game, and it worked fine, until testing it on my friend's computer. The boss came 2-3 seconds late on his computer, but it syncs perfectly on mine. Something is causing one of us to go either too fast, or too slow. I have two dropbox links to show you what I mean (I'm Justin, friend is Cam): http://bit.ly/STG1CamVer and http://bit.ly/STG1JustinVer
 Something I may have narrowed it down to was that he's running Win 8.1, and I'm running Win 7. Just a theory, though.

If it's an FPS issue, then the only way to guarantee anything is to have your music synced to 60 FPS and your script optimized as well as possible. Of course, you should make sure that the people playing your game have decent computers that are as good as yours or better, and are not having too many programs open while running Danmakufu.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Justin on January 16, 2015, 02:20:46 AM
If it's an FPS issue, then the only way to guarantee anything is to have your music synced to 60 FPS and your script optimized as well as possible. Of course, you should make sure that the people playing your game have decent computers that are as good as yours or better, and are not having too many programs open while running Danmakufu.
What you mean by syncing to 60 FPS is playing the game at 60 FPS and seeing what happens, yes?
Also, optimization- How so? Should I unload graphics when not needed (i.e the splash icon I have appearing before the stage starts- is simply deleting the object enough?)
As always, I appreciate the assistance.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 16, 2015, 02:47:01 AM
What you mean by syncing to 60 FPS is playing the game at 60 FPS and seeing what happens, yes?
Also, optimization- How so? Should I unload graphics when not needed (i.e the splash icon I have appearing before the stage starts- is simply deleting the object enough?)
As always, I appreciate the assistance.

Assume that the script should run at a constant FPS. Preload all boss scenes, sounds, and textures before playing the music. Short circuit your boolean expressions. Remove unneeded variables. Whatever you can do to make your game run at the intended 60 FPS on lower-end computers.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: ExPorygon on January 16, 2015, 03:10:45 AM
Sparen is basically saying that your friend's computer might not run your game without lag, which would desync the music. He's giving you ways to reduce the potential lag as much as possible.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Justin on January 16, 2015, 04:00:04 AM
Assume that the script should run at a constant FPS. Preload all boss scenes, sounds, and textures before playing the music. Short circuit your boolean expressions. Remove unneeded variables. Whatever you can do to make your game run at the intended 60 FPS on lower-end computers.
Sparen is basically saying that your friend's computer might not run your game without lag, which would desync the music. He's giving you ways to reduce the potential lag as much as possible.
Thank you to the both of you!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 16, 2015, 04:30:48 AM
I asked earlier, but no one seems to be answering: do you need to do something special to post on the official Danmakufu BBS? I can't seem to post a bug report to this thread (http://mkmqwerty.vs.land.to//usr/bin/perl/patio/read.cgi?no=71).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on January 16, 2015, 05:34:20 AM
I've asked mkm about it some time ago, he said to try using japanese in whatever you post due to the spam protection seeing english as spam, such as including 東方弾幕風. I've tried it, but no success either.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 16, 2015, 06:03:25 AM
I've asked mkm about it some time ago, he said to try using japanese in whatever you post due to the spam protection seeing english as spam, such as including 東方弾幕風. I've tried it, but no success either.

Tried including Japanese first and then only the Japanese, and it still returns a 403.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 16, 2015, 06:44:11 AM
Tried including Japanese first and then only the Japanese, and it still returns a 403.
Mkm's BBS denies all non-Japanese IPs. To get on their board, you need to use a Japanese Proxy or Japanese IP.
I assume you are already in the board and having difficulties to post the msg?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 16, 2015, 07:24:37 AM
Mkm's BBS denies all non-Japanese IPs. To get on their board, you need to use a Japanese Proxy or Japanese IP.
I assume you are already in the board and having difficulties to post the msg?

Yes. If that applies, then I'd gladly let someone else report the bug.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 16, 2015, 07:36:47 AM
Yes. If that applies, then I'd gladly let someone else report the bug.
Since you said 403 I am confused. If you get a 503 it is due to not having Japanese IP. If you are on the board and unable to post make sure you fill out the e-mail and a "edit post" password. Also http is not allowed but that will throw you an error message to edit out the urls.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 16, 2015, 07:44:03 AM
Since you said 403 I am confused. If you get a 503 it is due to not having Japanese IP. If you are on the board and unable to post make sure you fill out the e-mail and a "edit post" password. Also http is not allowed but that will throw you an error message to edit out the urls.

Yep, all done. Are you sure you didn't misread the 4 as a 5?

Edit: or you could post the report
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 17, 2015, 06:05:29 PM
A reminder that pre6a has been released, fixing a number of bugs in pre6. I assume this is a stable release.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 22, 2015, 12:17:55 AM
Has anyone been able to report the file I/O bug I mentioned yet? The success of my project depends on it.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 22, 2015, 01:36:20 AM
Has anyone been able to report the file I/O bug I mentioned yet? The success of my project depends on it.

If you can't use Text File Objects, use a workaround.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on January 22, 2015, 01:59:12 AM
Has anyone been able to report the file I/O bug I mentioned yet? The success of my project depends on it.

If you can't use Text File Objects, use a workaround.

I highly suggest using an array for the time being.

Have you been able to email mkm directly? He allows that as well. You should probably have a subject like 弾幕風ph3バグ報告 otherwise his spam filter kills your report because of English or something. I don't know whether he prefers the actual body of the message in Japanese or English, because all of my bug reports were in Japanese. I assume he doesn't mind either, as long as it's legible.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on January 22, 2015, 04:30:12 AM
All of my reports are in english which he has a fair understanding of (has gotten better since I first emailed him a year ago). Also, emails can be named TouhouDanmakufu ph3 blahblah or 東方弾幕風 ph3. I use both.

http://www.geocities.co.jp/SiliconValley-Oakland/9951/ email can be found on this website (under the profile section)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chester-low on January 24, 2015, 04:13:27 PM
Hey everybody !
I would like to know if someone could help me ! I don't really know how to make 3d background...and I really need to make 3d background for my game.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 24, 2015, 05:57:03 PM
Hey everybody !
I would like to know if someone could help me ! I don't really know how to make 3d background...and I really need to make 3d background for my game.
Oh quite the challenge you're taking here. I think I need to first poll your experience: Did you make any custom effects or worked with sprite objects before?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chester-low on January 24, 2015, 06:10:04 PM
Oh yeah of course, I animated myself my sprites, and I made myself my circle effect functions etc...^^
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 24, 2015, 06:44:45 PM
Ok well there aren't much resources or tutorials to make stages but I will try to explain very roughly.

Building 3D stages in Touhou is like building a cardboard house. Your sprites are your piece of cards and you're "placing them" in 3D in your field. This is how X Y and Z will work for a 3D environment.
[attach=1]

Let's try to first make a floor in 3D. Very very simple:
Code: [Select]
// Load your texture
let floorTex = etc...;

@Initialize {
renderStage;
}
@MainLoop { yield; }
@Finalize { }

// Your sprite, placed in 3D
function makePanel(posX,posY,posZ,angleX,angleY,angleZ) {
let obj = ObjPrim_Create(OBJ_SPRITE_3D);    // <----- Very important to create as 3D sprite!
ObjPrim_SetTexture(obj,floorTex);
Obj_SetRenderPriorityI(obj,20);
ObjRender_SetBlendType(obj,BLEND_ALPHA);
ObjRender_SetAlpha(obj,255);
ObjRender_SetScaleXYZ(obj,1,1,0);
ObjSprite3D_SetSourceDestRect(obj,0,0,512,512);
ObjSprite3D_SetBillboard(obj,false);
ObjRender_SetPosition(obj,posX,posY,posZ);
ObjRender_SetAngleXYZ(obj,angleX,angleY,angleZ);
}

// Main rendering
task renderStage {

// Required to let the engine draw past default 2048. If you make a long stage which has for example textures of 4096 or longer, you need to increase the value.
SetCameraPerspectiveClip(10,4096);

// Camera settings.
SetCameraFocusX(0);
SetCameraFocusY(0);
SetCameraFocusZ(0);
SetCameraAzimuthAngle(0);
SetCameraElevationAngle(16);

// Make a panel at X Y Z position 0 (centre) and flipped around X 90 degrees (floor)
makePanel(0,0,0,90,0,0);
}

ObjPrim_Create(OBJ_SPRITE_3D); is most important code here, because otherwise it won't listen to 3D functions.
ObjSprite3D_SetSourceDestRect Note how the function name contains 3D! On the wiki you can find many functions special for 3D.
ObjSprite3D_SetBillboard Prevents the sprite from "always facing the camera" if you turn the camera around.

The way I set my cameras gives you a slight overhead view of the floor. Play around with the values to discover how the camera works. This is very important for your 3D stage.

So why did I use function makePanel() ?
I am passing 6 parameters to my 3D sprite to flexible create it. This means I can just type the same code over and create multiple walls/floors/ceilings. Otherwise if you want to make 2 floors or 4 walls, you need to type the whole code 4x. This is why functions and parameters are useful.

Try to get the above right and see if you can summon a simple floor. Good luck.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 26, 2015, 12:47:07 AM
Can anyone explain the details of GetTransitionRenderTargetName? I know what it does at the basic level, but I need to know about the details such as what it captures and what it doesn't.

Edit: what the heck Danmakufu (http://i.imgur.com/3WO9Wuf.png) (large image)

Edit 2: How do I respawn a player after she's run out of lives? Or do I need some workaround such as having 0 lives = game over?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 26, 2015, 02:35:32 AM
Can anyone explain the details of GetTransitionRenderTargetName? I know what it does at the basic level, but I need to know about the details such as what it captures and what it doesn't.

Edit: what the heck Danmakufu (http://i.imgur.com/3WO9Wuf.png) (large image)

Edit 2: How do I respawn a player after she's run out of lives? Or do I need some workaround such as having 0 lives = game over?

You don't actually let the player run out of lives. :P

Code from DEC:
Code: [Select]
    case(EV_PLAYER_SHOOTDOWN){//To disable continue system, block comment this case.
if(GetCommonData("Practice",true)==false){//Disables invincibility for practice stages
  if(GetPlayerLife<0){//If equals 0, still have a life left (IE using last life)
    SetPlayerLife(0.123);//Copied from Arby, should prevent STATE_END. In theory.
    ContinueSystem;
  }//I pray this works. Correctly.
}
    }

ContinueSystem() will notify the package if there are continues remaining. The package will pause the game, process the user input, and then notify the stage to either kill the player (trigger end scene) or reset and resume.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 28, 2015, 01:01:47 AM
How to get a backslash in a string?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on January 28, 2015, 01:33:58 AM
Hi!

Is there a (simple) way to know in which direction go a move objet (for example a boss object)?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 28, 2015, 01:36:54 AM
Hi!

Is there a (simple) way to know in which direction go a move objet (for example a boss object)?

ObjMove_GetAngle
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on January 28, 2015, 01:47:51 AM
why I don't think to this ??
so if angle ?90 the object go left and if angle ?90 the object go right. it's right?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on January 28, 2015, 02:05:48 AM
How to get a backslash in a string?
Backslash is the escape character, so \\ gets you a backslash character ok nope. You also get quotes with \", and so on.

why I don't think to this ??
so if angle ?90 the object go left and if angle ?90 the object go right. it's right?
Not quite, since that won't work if the object is moving upwards. The angles work like this:

(http://i.imgur.com/YJvmH4I.png)

The easiest way to check if an angle is "left" or "right" is to get the cosine of the angle. cos(angle) will be < 0 on left and > 0 on right.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 28, 2015, 02:17:03 AM
why I don't think to this ??
so if angle ?90 the object go left and if angle ?90 the object go right. it's right?
Not necessarily.

Edit: \ doesn't work.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on January 28, 2015, 10:26:15 AM
It works perfectly. Thanks Drake and Fluffy8x.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Phasm on January 30, 2015, 10:32:41 PM
How do i remove the filters with Yukari and Tenshi's face in the Celestial Showdown script?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 30, 2015, 10:49:36 PM
How do i remove the filters with Yukari and Tenshi's face in the Celestial Showdown script?

AJS purposely did that, I believe. To change it, change the alpha values of the STG_Frame in the system file to 0.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Phasm on January 30, 2015, 10:54:05 PM
And how do i do that? I don't understand anything about Danmakufu...   :(
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: ExPorygon on January 31, 2015, 12:08:25 AM
Well, Helepolis suggested I take talk about the potential use of ZUN sound effects in scripts here, so here I am. I don't know the full story behind whether the sounds on nico commons are rips or not, or if that's even what the japanese danmakufu scripter are using in their games, but it would appear that the use of ZUN's sound effects in games is not taken as seriously as using other types of data, like art, music, and sprites.

However, I recently remembered that there is another MASSIVE library of sounds for games here: http://osabisi.sakura.ne.jp/m2/

It took me a long time to track this site down, but this is the source of game sound effects for MANY Japanese indie and doujin titles. The Exceed series, Suguri, Touhou Labryinth, Phantasmagoria Trues, Magical Singular Day, Danmakufu ITSELF and many more that I'm probably not aware of all use sounds from this library. As many will note, several of those games were sold. It's very difficult for me to read the terms of use (located here (http://osabisi.sakura.ne.jp/m2/material3.html) I believe) so to avoid any potential translation confusion, perhaps someone here with knowledge of japanese could translate the terms of use? I'm certain that these sounds if useable will be more than enough for many scripters looking for an alternative to official Touhou sound effects.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on January 31, 2015, 07:48:38 PM
Me again!
I want to make alternative spells depending of which boss is killed (like the prismriver) but I have no idea how to do this.
I try something like that in my plural script where NextStep common data is equal to "LETTY" or "LILY" at the end of the previous spell.
Code: [Select]
task TPlural {
loop(51) {yield;}
let ex = ObjMove_GetX(objScene);
let ey = ObjMove_GetY(objScene);

ObjEnemyBossScene_Add(objScene, 0, dir ~ "Nonspell1Li_N.txt");
ObjEnemyBossScene_Add(objScene, 1, dir ~ "Nonspell2Li_N.txt");
ObjEnemyBossScene_Add(objScene, 2, dir ~ "Spell1_N.txt");
if(GetCommonData("NextStep", "NULL") == "LETTY") {
ObjEnemyBossScene_Add(objScene, 3, dir ~ "Nonspell1Li_N.txt");
} else if(GetCommonData("NextStep", "NULL") == "LILY") {
ObjEnemyBossScene_Add(objScene, 3, dir ~ "Nonspell2Li_N.txt");
}

ObjEnemyBossScene_LoadInThread(objScene);
ObjEnemyBossScene_Regist(objScene);
while(!Obj_IsDeleted(objScene)){
yield;
}
}
But ObjEnemyBossScene_Add is set at the beginning of the boss and not after the spell.
I try to do that in another task but it don't work.

Any idea please?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Hope ♦ Metal on January 31, 2015, 08:08:23 PM
Me again!
I want to make alternative spells depending of which boss is killed (like the prismriver) but I have no idea how to do this.
I try something like that in my plural script where NextStep common data is equal to "LETTY" or "LILY" at the end of the previous spell.
-codehere-
But ObjEnemyBossScene_Add is set at the beginning of the boss and not after the spell.
I try to do that in another task but it don't work.

Any idea please?
Maybe if you put the check in a separate script?

EDIT: Or even better: Load both scripts and have one of them immediately skip to the end if the condition for the spell is met.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 31, 2015, 11:14:18 PM
Well, Helepolis suggested I take talk about the potential use of ZUN sound effects in scripts here, so here I am. I don't know the full story behind whether the sounds on nico commons are rips or not, or if that's even what the japanese danmakufu scripter are using in their games, but it would appear that the use of ZUN's sound effects in games is not taken as seriously as using other types of data, like art, music, and sprites.

However, I recently remembered that there is another MASSIVE library of sounds for games here: http://osabisi.sakura.ne.jp/m2/

It took me a long time to track this site down, but this is the source of game sound effects for MANY Japanese indie and doujin titles. The Exceed series, Suguri, Touhou Labryinth, Phantasmagoria Trues, Magical Singular Day, Danmakufu ITSELF and many more that I'm probably not aware of all use sounds from this library. As many will note, several of those games were sold. It's very difficult for me to read the terms of use (located here (http://osabisi.sakura.ne.jp/m2/material3.html) I believe) so to avoid any potential translation confusion, perhaps someone here with knowledge of japanese could translate the terms of use? I'm certain that these sounds if useable will be more than enough for many scripters looking for an alternative to official Touhou sound effects.
What are the conditions though for using these sounds? Are they truly free-to-use and allowed to be used when distributing for free or with a sale? We'll need to indeed figure out that link as you highlighted.

Edit:
Apparently as far as I could grasp something: Terms of use is "Free to use" as long as your game is free as well. Pretty much like the material my partner found about Dnh players. So unfortunately this is a no-go source for my game.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: ExPorygon on February 01, 2015, 12:44:09 AM
What are the conditions though for using these sounds? Are they truly free-to-use and allowed to be used when distributing for free or with a sale? We'll need to indeed figure out that link as you highlighted.

Edit:
Apparently as far as I could grasp something: Terms of use is "Free to use" as long as your game is free as well. Pretty much like the material my partner found about Dnh players. So unfortunately this is a no-go source for my game.
I'm not quite sure this is the case. I've found nothing myself that indicates that your work needs to be free. All of those games that I just listed use those sounds and many are sold, many of them are pretty well known too. This is why I want a proper translation of the terms on that page.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on February 01, 2015, 01:29:31 AM
How do you allocate more RAM space to Danmakufu. RSS is apparently going to continue (geez it's probably been 2 hours since I started this run) running at 5 FPS forever with this terrible use of memory allocation.

And yes, I believe Danmakufu is using about 1.10 GB RAM. And my processor is not running at full capacity.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on February 01, 2015, 08:43:26 PM
Quote from: Rumia w/ a chest-mouth
EDIT: Or even better: Load both scripts and have one of them immediately skip to the end if the condition for the spell is met.
Good idea. It works. Thanks.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 01, 2015, 09:10:09 PM
Anyone know why GetTransitionRenderTargetName might not get the most recent screenshot of the game that exists?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on February 03, 2015, 09:47:19 PM
Me again and again.

I make a player shot that pass through enemies an infinite number of time. But I want to do some stuff when it hurt an enemy.
Is there a way to know if the shot is in contact with a enemy and wich enemy?

I usually use the shot deletion but... it's not deleted in this case.

And another really stupid question.
With 
Code: [Select]
ObjSprite2D_SetSourceRect(obj, x1, y1, x2, y2);What is the size of the sprite I get if I have x1 = 0, y1 = 0, x2 = 16 and y2 = 16? It's 16*16 or 17*17?
And if I have a picture in 16*16, the up-left pixel coordinates is 0*0 or 1*1? And the down-right is 16*16 or 17*17?
I never understand how it's calculated by danmakufu and I always get some artifacts on the side.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on February 03, 2015, 10:41:39 PM
And another really stupid question.
With 
Code: [Select]
ObjSprite2D_SetSourceRect(obj, x1, y1, x2, y2);What is the size of the sprite I get if I have x1 = 0, y1 = 0, x2 = 16 and y2 = 16? It's 16*16 or 17*17?
And if I have a picture in 16*16, the up-left pixel coordinates is 0*0 or 1*1? And the down-right is 16*16 or 17*17?
I never understand how it's calculated by danmakufu and I always get some artifacts on the side.

This is not a stupid question at all. It is one of the most infuriating things in Danmakufu.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 03, 2015, 10:57:58 PM
This is not a stupid question at all. It is one of the most infuriating things in Danmakufu.

Along with the first parameter of object functions and the lack of first-class functions. Take your pick of which is the most infuriating, and please try to answer my question while deciding.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on February 04, 2015, 12:00:37 AM
Along with the first parameter of object functions and the lack of first-class functions. Take your pick of which is the most infuriating, and please try to answer my question while deciding.

The first parameter of object functions is annoying? Really?

Although there's a chance someone with the necessary understanding of render targets will respond, there are very few of them, so don't expect much.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on February 04, 2015, 12:10:36 AM
@Fluffy8x: I'd kind of like you to expand on what you mean by "most recent screenshot" ... ... It's a bit hard for me to interpret
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 04, 2015, 12:19:07 AM
@Fluffy8x: I'd kind of like you to expand on what you mean by "most recent screenshot" ... ... It's a bit hard for me to interpret

Sometimes that function gives a screenshot of something else such as the Danmakufu main menu or a previous playthrough. If you want more explanation, then I'll just release 0.03tr to the public.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: zemoo on February 04, 2015, 12:21:07 AM
having a little trouble with object lasers, I'm trying to make a laser then move it across the screen.

I did this
Code: [Select]
let las1 = CreateStraightLaserA1(-2*x1+xOffset,y1-3*x1*tan(theta),theta,2000,width,500,8*20+8%8,40);
wait(20);
ObjMove_SetSpeed(las1,3);
it made a bunch of lasers, each moving to the right

I tried manually moving it,
Code: [Select]
let las1 = CreateStraightLaserA1(-2*x1+xOffset,y1-3*x1*tan(theta),theta,2000,width,500,8*20+8%8,0);
wait(20);
let newX = ObjMove_GetX(las1);
loop(GetStgFrameWidth){
newX = newX+4;
ObjMove_setX(las1,newX);
}
also didn't work. and I had to change the delay to 0 so it would have a hitbox at any point. I just want one solid laser to move after spawning.

It seems that a laser is just a series of stretched out bullets that continuously spawn from the spawning point, I could just make an object bullet that has those properties and won't disappear when you hit it, but I'd rather learn the right way if at all possible.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on February 04, 2015, 12:27:50 AM
Sometimes that function gives a screenshot of something else such as the Danmakufu main menu or a previous playthrough. If you want more explanation, then I'll just release 0.03tr to the public.

I think you're gonna actually have to render every render priority layer TO the render target beforehand... are you doing so?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: gtbot on February 04, 2015, 01:44:54 AM
I make a player shot that pass through enemies an infinite number of time. But I want to do some stuff when it hurt an enemy.
Is there a way to know if the shot is in contact with a enemy and wich enemy?
I'm not entirely sure if that's exactly possible, sorry. You may want to send a feature request, as that seems to be a good feature to have.

Code: [Select]
ObjSprite2D_SetSourceRect(obj, x1, y1, x2, y2);What is the size of the sprite I get if I have x1 = 0, y1 = 0, x2 = 16 and y2 = 16? It's 16*16 or 17*17?
And if I have a picture in 16*16, the up-left pixel coordinates is 0*0 or 1*1? And the down-right is 16*16 or 17*17?
I never understand how it's calculated by danmakufu and I always get some artifacts on the side.
If your image is 16x16, then you will do ObjSprite2D_SetSourceRect(obj, 0, 0, 16, 16);
If you are getting any artifacts, ensure that your image sizes are saved with powers of 2. Otherwise, it will automatically resize it to a power of 2, and then rescale it back to the original size, creating all sorts artifacts and blurriness.

having a little trouble with object lasers, I'm trying to make a laser then move it across the screen.
A loop will execute in one frame if you don't yield it, so what you're doing, simplified, is actually just setting the X value to 4*GetStgFrameWidth. Add a yield; or wait(1); to your loop, and it will execute the loop one frame at a time, giving movement.

Also, it's probably better to use while(!Obj_IsDeleted(obj)){} for bullets/lasers (and just sticking with ObjMove_ functions, and only manually setting their X/Ys for complicated movements), but as always, it depends entirely on what your intended effect is.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 04, 2015, 03:26:36 AM
I think you're gonna actually have to render every render priority layer TO the render target beforehand... are you doing so?

Ehh?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on February 04, 2015, 05:00:23 AM
Ehh?

Aaah, you know.
RenderToTextureA1(GetTransitionRenderTargetName, 0, 100, true);

The "package script" of Danmakufu's script selection menu (I merely hypothesize of its existence) uses this function, so that's why you might sometimes see the main menu when using this function.

That's just my guess though.

Render targets will store the same image until you clear it and render to it once again. One of the tutorials tells the reader to picture it as more like a "canvas", on which you can do two things: 1)) draw things on top, and 2) clear the canvas.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 04, 2015, 05:59:25 AM
Anyone know why GetTransitionRenderTargetName might not get the most recent screenshot of the game that exists?
Sometimes that function gives a screenshot of something else such as the Danmakufu main menu or a previous playthrough. If you want more explanation, then I'll just release 0.03tr to the public.
The transition render target is drawn on by menu scripts. By default you'll get the last view of the title screen or the last view of the pause menu, because they draw to that target. The purpose is to get the last view of any scene immediately before the menu script is called. You would use this in a pause menu to render the "paused" game scene while in the menu, for example. How have you been using it?


Me again and again.

I make a player shot that pass through enemies an infinite number of time. But I want to do some stuff when it hurt an enemy.
Is there a way to know if the shot is in contact with a enemy and wich enemy?
I'm not sure what gtbot is talking about but ObjCol_IsIntersected() and ObjCol_GetListOfIntersectedEnemyID() are what you want.

Quote
Code: [Select]
ObjSprite2D_SetSourceRect(obj, x1, y1, x2, y2);What is the size of the sprite I get if I have x1 = 0, y1 = 0, x2 = 16 and y2 = 16? It's 16*16 or 17*17?
And if I have a picture in 16*16, the up-left pixel coordinates is 0*0 or 1*1? And the down-right is 16*16 or 17*17?
I never understand how it's calculated by danmakufu and I always get some artifacts on the side.
16*16. The left and top coordinates are inclusive; the right and bottom coordinates are exclusive.
Top-left is (0, 0). The bottom-right corner is (16, 16), but if you want the corner pixel itself for whatever reason it's (15, 15).
So if you wanted a one-pixel rectangle in the bottom-right corner it would be (15, 15, 16, 16).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: gtbot on February 04, 2015, 06:35:20 AM
I'm not sure what gtbot is talking about but ObjCol_IsIntersected() and ObjCol_GetListOfIntersectedEnemyID() are what you want.

woosh
somtimes i forget the simplest things
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 04, 2015, 12:13:34 PM
Not a question but more like verification whether I am on the right track. I'm about to implement difficulty scaling in my game but I want to know if I set the core structure correctly.

Basically using CommonData to set the selected difficulty then
Code: [Select]
// Difficulty scaling, 0 = normal, 1 = hard, 2 = lunatic
task fairyShot00(obj) {
if(GetCommonData("gameDifficulty",false) == 0)  {

}
if(GetCommonData("gameDifficulty",false) == 1)  {

}
if(GetCommonData("gameDifficulty",false) == 2)  {

}
}
To check what the fairy has to use depending on difficulty. Is this a safe and proper way or can it cause complications later on?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on February 04, 2015, 01:44:10 PM
Not a question but more like verification whether I am on the right track. I'm about to implement difficulty scaling in my game but I want to know if I set the core structure correctly.

Basically using CommonData to set the selected difficulty then
Code: [Select]
// Difficulty scaling, 0 = normal, 1 = hard, 2 = lunatic
task fairyShot00(obj) {
if(GetCommonData("gameDifficulty",false) == 0)  {

}
if(GetCommonData("gameDifficulty",false) == 1)  {

}
if(GetCommonData("gameDifficulty",false) == 2)  {

}
}
To check what the fairy has to use depending on difficulty. Is this a safe and proper way or can it cause complications later on?

This is similar to the system I use for stage enemies. The main concerns I had were:
-default values - When testing stages (not using a package), I had to manually set the difficulty I wanted in order to test different difficulties
-keeping a standardized default
-having to change code in multiple places - If something goes wrong, you may have to correct it for each and every case.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 04, 2015, 01:48:42 PM
This is similar to the system I use for stage enemies. The main concerns I had were:
-default values - When testing stages (not using a package), I had to manually set the difficulty I wanted in order to test different difficulties
-keeping a standardized default
-having to change code in multiple places - If something goes wrong, you may have to correct it for each and every case.
1) Similar thought, I might need to script in debug option ability to test difficulties for beta testers.
2) Struggling indeed
3) That is indeed troublesome.

I've studied MPP's difficulty scaling and they seem to use the alternative(var)  case(var)  method for this. I guess that is also optional.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on February 04, 2015, 03:14:28 PM
Thanks Drake and gtbot for the explanations. And ObjCol_GetListOfIntersectedEnemyID() work well  :)

edit:
Another thing.
If I make a non-touhou danmakufu game (with custom and legit ressources), can I share it on steam (or other things like that) for free? Is there some danmakufu use restrictions somewhere?
And can I send non Touhou danmakufu-game? (I don't want but I'm curious about that).


Sorry if there is already an answer somewhere.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 04, 2015, 04:03:31 PM
Thanks Drake and gtbot for the explanations. And ObjCol_GetListOfIntersectedEnemyID() work well  :)

edit:
Another thing.
If I make a non-touhou danmakufu game (with custom and legit ressources), can I share it on steam (or other things like that) for free? Is there some danmakufu use restrictions somewhere?
And can I send non Touhou danmakufu-game? (I don't want but I'm curious about that).


Sorry if there is already an answer somewhere.
If you make a non-touhou game without danmakufu ph3/0.12m, then you're not bound to ZUN's Touhou derived fanwork guidelines.
See here: https://www.shrinemaiden.org/forum/index.php/topic,17915.0.html

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: ExPorygon on February 04, 2015, 04:09:24 PM
Hold on, where does it say that Danmakufu cant go on steam (assuming non touhou)? You'd have to consult Danmakufus own license to find that out or perhaps mkm himself.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 04, 2015, 06:32:29 PM
That would be something to take up with mkm. Despite how general it is, the license does state that distribution of works using e.g. the default images and so on require you to note that the work is a derivative work of the Touhou Project. By default then, even if your work does not include Touhou whatsoever, you're still using a Touhou derivative as your base and as such it should also be considered one. There is a very detailed writeup about the use of Touhou game data (music, textures, etc) on the documentation that should probably be translated at some point, since if anything it makes clear why STOP HELEPOLIS was a thing and would be useful for newcomers that aren't aware of these guidelines. There is nothing in the license or documentation about commercialization specifically, likely because it doesn't even cross people's minds to publish a game that uses Danmakufu as a base under the assumption that it's a doujin derivative work -- especially if it weren't free. I find it quite likely that you're limited to the scope of doujin works by using Danmakufu, and unless clearly told otherwise you should not assume anything more than that.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: ExPorygon on February 04, 2015, 08:37:37 PM
Would that then mean that the removal of the default images from the game's distribution and the usage of ONLY the engine and no base assets would allow for the touhou derivative tag to be removed? I agree that its best to ask mkm directly but just throwing that out there.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 04, 2015, 09:46:59 PM
Not a question but more like verification whether I am on the right track. I'm about to implement difficulty scaling in my game but I want to know if I set the core structure correctly.

Basically using CommonData to set the selected difficulty then
Code: [Select]
// Difficulty scaling, 0 = normal, 1 = hard, 2 = lunatic
task fairyShot00(obj) {
if(GetCommonData("gameDifficulty",false) == 0)  {

}
if(GetCommonData("gameDifficulty",false) == 1)  {

}
if(GetCommonData("gameDifficulty",false) == 2)  {

}
}
To check what the fairy has to use depending on difficulty. Is this a safe and proper way or can it cause complications later on?

I'd prefer using a function to return the game difficulty, and branch only for radically different behavior.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on February 04, 2015, 09:59:40 PM
I'd prefer using a function to return the game difficulty, and branch only for radically different behavior.

Fluffy. GetCommonData("gameDifficulty",false) is a function that returns the game difficulty. He is branching for different behavior.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 04, 2015, 10:10:06 PM
Fluffy. GetCommonData("gameDifficulty",false) is a function that returns the game difficulty. He is branching for different behavior.

I meant defining a new one named getDifficulty (as I have it), and avoiding branches for similar but different behavior.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on February 04, 2015, 10:11:35 PM
Fluffy. GetCommonData("gameDifficulty",false) is a function that returns the game difficulty. He is branching for different behavior.

He means to do.
Code: [Select]
function GetDifficulty()
{
return GetCommonData("gameDifficulty",0);
}

Which is better than using commondata by itself as the conditional. What if you need to make changes to that commondata name. Have it return an array or something. It would be alot easier to just modify that function name, and then the changes take place everywhere. Or even better, having dedicated names for commondata so that you don't have to type Set/GetCommonData(blahblah).
I find it quite likely that you're limited to the scope of doujin works by using Danmakufu, and unless clearly told otherwise you should not assume anything more than that.

I don't think this is the case, I had asked mkm personally about selling a game made in Danmakufu (I didn't specify if it was Touhou on purpose), he simply replied that he was ok with it. I don't recall the documentation making a note of it either. So I personally will assume that non Touhou works are free of those limitations. I don't think mkm would enforce such things, if he was really serious about it, they would be mentioned (he would've made some extra attempt to mention it in the email as well).

Still, asking never hurt, and we have a better and easier chance at communicating with mkm than say, westerner ---> ZUN.

Not a question but more like verification whether I am on the right track. I'm about to implement difficulty scaling in my game but I want to know if I set the core structure correctly.

Basically using CommonData to set the selected difficulty then
Code: [Select]
// Difficulty scaling, 0 = normal, 1 = hard, 2 = lunatic
task fairyShot00(obj) {
if(GetCommonData("gameDifficulty",false) == 0)  {

}
if(GetCommonData("gameDifficulty",false) == 1)  {

}
if(GetCommonData("gameDifficulty",false) == 2)  {

}
}
To check what the fairy has to use depending on difficulty. Is this a safe and proper way or can it cause complications later on?

I would first put everything into a function. The above code is fine but would cause you to write a bunch of redundant copies of some patterns and enemy behavior. I personally pick pieces of the pattern apart and assign them to variables. like let diffvar_a = [easy value, normal value, hard value, lunatic][GetDifficulty];

The only time I ever rewrite code is if the pattern doesn't work well for all difficulties in it's current state.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 04, 2015, 11:32:23 PM
Would that then mean that the removal of the default images from the game's distribution and the usage of ONLY the engine and no base assets would allow for the touhou derivative tag to be removed? I agree that its best to ask mkm directly but just throwing that out there.
Perhaps, and I was going to mention this, but if you do so without asking it just makes it seem as though you're trying to loophole.

I don't think this is the case, I had asked mkm personally about selling a game made in Danmakufu (I didn't specify if it was Touhou on purpose), he simply replied that he was ok with it. I don't recall the documentation making a note of it either. So I personally will assume that non Touhou works are free of those limitations. I don't think mkm would enforce such things, if he was really serious about it, they would be mentioned (he would've made some extra attempt to mention it in the email as well).
You can sell doujin games just fine. We're talking about putting it on Steam, specifically, not just selling it. Again, publishing is very likely a topic that doesn't ever show up. Using game data is a much more pertinent topic and probably causes issues even within the Japanese fandom, but commercialization is not. The point is that it's best to err on the side of caution.



Also, the way RSS does difficulty changes is pretty good. There are just several parameters declared at the beginning, and those parameters are changed depending on difficulty. The behaviour itself doesn't branch unless the patterns are different; it's only one block (that you only need to change once) that makes use of the parameters (which are much easier to individually tweak). Even minor additions to the behaviour can be done using flags that are only set on certain difficulties.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 05, 2015, 05:16:00 PM
I'm not sure what gtbot is talking about but ObjCol_IsIntersected() and ObjCol_GetListOfIntersectedEnemyID() are what you want.
Just want to highlight this doesn't work for sprite Objects. I've been busy with my own Reimu's Musou Tensei spell card where I need to check if her Yin Yang ball is colliding, but it isn't triggering.

Wiki doesn't specify which objects it listens to. I believe it was similar with the Obj_Obj intersected functions. They only listen to Enemy objects and Shot objects.

This is quite troublesome.

Edit:
Even worse,  IsIntersected_Obj_Obj(obj1,obj2) isn't working either. Only for lasers and bullets (that is stated on wiki)

GetObjectDistance(obj1,obj2) worked for my sprite yin yang ball. if(GetObjectDistance(obj1,obj2) < 8) {  // do stuff }   <-  if the distance between 2 objects is smaller than 8 pixels, it will do stuff.

Unless someone has a better and easier solution.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: ExPorygon on February 05, 2015, 05:48:02 PM
One possible solution to your problem Helepolis is to create invisible bullets with no hitboxes and constantly assign their position to the sprite objects in question and use the collision function on them as a proxy.

Or you could continue using the GetObjectDistance method. I think that would be the most efficient way as I don't know how the Obj collision functions even work, like I don't know what collision radius it uses to detect the collision (it can't be just comparing the coordinates cause they'll virtually never be exactly the same). It might use the shot or enemy's hitbox size as set by other functions, I just don't know for sure.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 05, 2015, 10:14:05 PM
Just want to highlight this doesn't work for sprite Objects. I've been busy with my own Reimu's Musou Tensei spell card where I need to check if her Yin Yang ball is colliding, but it isn't triggering.

Wiki doesn't specify which objects it listens to. I believe it was similar with the Obj_Obj intersected functions. They only listen to Enemy objects and Shot objects.

This is quite troublesome.

Edit:
Even worse,  IsIntersected_Obj_Obj(obj1,obj2) isn't working either. Only for lasers and bullets (that is stated on wiki)

GetObjectDistance(obj1,obj2) worked for my sprite yin yang ball. if(GetObjectDistance(obj1,obj2) < 8 ) {  // do stuff }   <-  if the distance between 2 objects is smaller than 8 pixels, it will do stuff.

Unless someone has a better and easier solution.
Collision objects are really just the objects that you'd think would have collision detection by default. So yeah, enemies, shots and lasers, possibly players and items as well, etc.

So uh... think about Spell objects? They exist too, you know ;)

like I don't know what collision radius it uses to detect the collision (it can't be just comparing the coordinates cause they'll virtually never be exactly the same). It might use the shot or enemy's hitbox size as set by other functions, I just don't know for sure.
That's very likely the case. It would use DNH's internal collision system, and I would expect that only objects with defined collision properties are affected, hence why it's undefined for objects that don't collide. Because of this I would also expect non-registered enemies, bullets, and so on to not be counted, and is why I expect player and item objects to count. However, I'm not sure whether or not "collisions" between certain types are considered valid, like players to player shots, or enemy shots to player shots, or even enemies to enemies.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chester-low on February 06, 2015, 06:30:19 PM
Hey everyone , i have some troubles with my script (it's a shot object library i made). All was working good, and today I have this problem:
(http://img11.hostingpics.net/thumbs/mini_147302sanstitre.png) (http://www.hostingpics.net/viewer.php?id=147302sanstitre.png)

The library:

Code: [Select]
//////////////////////////////////////////
//Librairie de fonction pour les ennemis//
//////////////////////////////////////////

  task Shot1(enemyid,x,y,angle,g,v)//Tir basique avec effet d'apparition
    {
    let shot_obj = ObjShot_Create(OBJ_SHOT);

let alpha = 0;
let sx = 4;
let sy = 4;
    ObjShot_Regist(shot_obj);
    ObjShot_SetAutoDelete(shot_obj, true);
    ObjMove_SetPosition(shot_obj,x,y);
    ObjMove_SetAngle(shot_obj,angle);
    ObjShot_SetGraphic(shot_obj, g);
    ObjMove_SetSpeed(shot_obj,v);
       ObjRender_SetAlpha(shot_obj,alpha);
       ObjRender_SetScaleX(shot_obj, sx);
       ObjRender_SetScaleY(shot_obj, sy);
if(Obj_IsDeleted(enemyid)==true){Obj_Delete(shot_obj);}
loop(20)
{
ObjRender_SetAlpha(shot_obj,alpha);
ObjRender_SetScaleX(shot_obj, sx);
ObjRender_SetScaleY(shot_obj, sy);
sx -= 0.3135/2;
sy -= 0.3135/2;
alpha +=25.5;
loop(0.3){yield;}
}
}
  task Shot2(enemyid,x,y,angle,g,v)//Tir basique avec effet d'apparition + effet ralentit
    {
    let shot_obj = ObjShot_Create(OBJ_SHOT);
let alpha = 0;
let sx = 4;
let sy = 4;
    ObjShot_Regist(shot_obj);
    ObjShot_SetAutoDelete(shot_obj, true);
    ObjMove_SetPosition(shot_obj,x,y);
    ObjMove_SetAngle(shot_obj,angle);
    ObjShot_SetGraphic(shot_obj, g);
    ObjMove_SetSpeed(shot_obj,v);
       ObjRender_SetAlpha(shot_obj,alpha);
       ObjRender_SetScaleX(shot_obj, sx);
       ObjRender_SetScaleY(shot_obj, sy);
if(Obj_IsDeleted(enemyid)==true){Obj_Delete(shot_obj);}
loop(20)
{
ObjRender_SetAlpha(shot_obj,alpha);
ObjRender_SetScaleX(shot_obj, sx);
ObjRender_SetScaleY(shot_obj, sy);
sx -= 0.3135/2;
sy -= 0.3135/2;
alpha +=25.5;
loop(0.3){yield;}
}
loop(5)
{
ObjMove_SetSpeed(shot_obj,v);
v--;
loop(4){yield;}
}
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on February 06, 2015, 06:56:13 PM
Your text may be encoded in UTF-8 with Byte order mark. I suggest that it be saved without the byte order mark, or ANSI perhaps.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chester-low on February 07, 2015, 08:36:44 AM
I'm sorry but...How can I do that? I'm sorry, encoding stuffs are not easy for me ... I guess I will change that with notepad++?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 07, 2015, 08:43:51 AM
Yes. If you're using Notepad++ you just go under the Encoding menu, Convert to UTF-8 without BOM and save.

You should also check Settings -> Preferences -> New Document and make sure ANSI or UTF-8 without BOM is set as the default.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chester-low on February 07, 2015, 08:49:09 AM
It work, thank you guys !
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 08, 2015, 08:00:02 PM
Question regarding TextObjects and setting text.

For debugging purposes, I was wondering if it is possible to combine string and integer in one line? For example  ObjText_SetText(obj, "location X:" bossX); So the result on my screen becomes:  "Location X: 24"

Of course the above will toss an error back at you because it needed a special method. I remember something vaguely done in the old engine but tracking down old threads I couldn't find it any more so decided to ask again.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 08, 2015, 08:02:28 PM
Question regarding TextObjects and setting text.

For debugging purposes, I was wondering if it is possible to combine string and integer in one line? For example  ObjText_SetText(obj, "location X:" bossX); So the result on my screen becomes:  "Location X: 24"

Of course the above will toss an error back at you because it needed a special method. I remember something vaguely done in the old engine but tracking down old threads I couldn't find it any more so decided to ask again.

Never heard of it. You need to use IntToString and string concatenation.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 08, 2015, 08:09:14 PM
Never heard of it. You need to use IntToString and string concatenation.
How to perform the string concatenation? Can ya show an example with the above?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 08, 2015, 08:21:13 PM
How to perform the string concatenation? Can ya show an example with the above?

Code: [Select]
ObjText_SetText(obj, "location X: " ~ IntToString(bossX));
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: ExPorygon on February 08, 2015, 08:36:57 PM
How to perform the string concatenation? Can ya show an example with the above?
To expand on Fluffy's response, concatenation of strings means that you're joining one string with another. The way that is done is with ~. For example, if I have two strings, "Hi my name is" and "ExPorygon" writing "Hi my name is" ~ "ExPorygon" will result in the combining of the two, end to end:  "Hi my name is ExPorygon"

Fluffy's example takes a string "location X: " and concatenates it with the string that results from the IntToString function which converts an integer (like the one stored in the bossX variable) into a string.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 08, 2015, 08:38:44 PM
Aaaaah, understood.  Just tested it and works like a charm. Cheers Ozzy & Fluffy.

And for booleans I use ToString() and it works.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on February 08, 2015, 09:45:39 PM
you can also use the actual concatenate(array1,array2) function or the append(array,value) function
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 08, 2015, 09:48:45 PM
you can also use the actual concatenate(array1,array2) function or the append(array,value) function

Heh heh heh, functions for operators. Would be useful if Danmakufu had first-class functions.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on February 08, 2015, 10:05:09 PM
Would be useful if Danmakufu had first-class functions.

Danmakufu supports that. It's all about how you use them.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 08, 2015, 10:05:46 PM
Danmakufu supports that. It's all about how you use them.

Wait, what?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 09, 2015, 12:54:07 AM
Sparen, DNH does not have first-class functions.
That being said concatenation doesn't make much sense over functions unless you're just talking about composition so I'm not sure how useful it'd be anyways.

Anyway more specifically the concatenate operator is defined on arrays, as in [1,2,3] ~ [4,5,6] = [1,2,3,4,5,6], but strings are simply arrays of characters
i.e. "melon" = ['m','e','l','o','n'] so it of course is valid for string concatenation.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 12, 2015, 02:56:36 AM
but strings are simply arrays of characters
i.e. "melon" = ['m','e','l','o','n'] so it of course is valid for string concatenation.

Shameless self-promotion and exploiting this fact (http://dnhorror.blogspot.com/2015/02/apparently-danmakufu-treats-strings.html)

P. S. this doesn't always work well (http://dnhorror.blogspot.com/2015/02/more-about-string-adding.html)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 12, 2015, 06:41:38 AM
Yeah, that quirk mostly has to do with characters being treated as their codepoints. It gets pretty silly, since it doesn't seem consistent on how it's applied. In 0.12m it was mostly consistent that characters were treated as numbers for arithmetic, which also meant adding zero gave you the codepoint, for example. In ph3 you get type mismatches... unless you wrap it in an array first. Doing vector addition gives more type errors. In both 0.12m and ph3 having characters and numbers in an array gives type errors.

Code: [Select]
ph3:
'a' + 0 = type error
['a' + 0] = [97]
['a']+[0] = type error
'a' + 'b' = type error
['a' + 'b'] = [195]
"a" + "b" = ?

0.12m:
'a' + 0 = 97
['a' + 0] = [97]
['a']+[0] = type error
'a' + 'b' = 195
['a' + 'b'] = [195]
"a" + "b" = テ

The "wrong" example you give is basically because doing arithmetic turns the characters into numbers, despite still being able to be displayed as characters.



As an aside, I forgot about your other problem with the freezing a few pages back. I see that you've solved it, but you might not realize why moving the event code into a task worked. It's really just a matter of how the scheduling system works, and should be pretty obvious if you recognize what yield does. For example, test out what happens with this:

Code: [Select]
case(EV_PLAYER_SPELL){
loop(120){
AddGraze(1);
yield;
}
}

The thing is that the engine's main routines run sequentially. This is pretty much expected, I think. Because of this, every time you yield in @Event you're essentially yielding to other tasks (and back) an extra time before the frame is updated. In this case, using a bomb will make your graze shoot up by 120, and every thread will have advanced 120 yields in whatever state they're in (in other words it "skips" 120 "frames"). In your case where you yielded until a button was pushed, it yields, all the other threads run and yield, comes back and asks if a button is pressed, and since the frame never updated you'll never get any new button presses, and the game loops infinitely.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 12, 2015, 06:59:36 AM
Yeah, that quirk mostly has to do with characters being treated as their codepoints. It gets pretty silly, since it doesn't seem consistent on how it's applied. In 0.12m it was mostly consistent that characters were treated as numbers for arithmetic, which also meant adding zero gave you the codepoint, for example. In ph3 you get type mismatches... unless you wrap it in an array first. Doing vector addition gives more type errors. In both 0.12m and ph3 having characters and numbers in an array gives type errors.

Code: [Select]
ph3:
'a' + 0 = type error
['a' + 0] = [97]
['a']+[0] = type error
'a' + 'b' = type error
['a' + 'b'] = [195]
"a" + "b" = ?

0.12m:
'a' + 0 = 97
['a' + 0] = [97]
['a']+[0] = type error
'a' + 'b' = 195
['a' + 'b'] = [195]
"a" + "b" = テ

The "wrong" example you give is basically because doing arithmetic turns the characters into numbers, despite still being able to be displayed as characters.

And what about the quirk that things such as "a" + "b" can't be compared with regular strings such as "a"? I guess it's some difference lingering in the codebase? Then why doesn't the result become displayed as an array of numbers?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 12, 2015, 07:50:16 AM
i dunno lol

I'm pretty sure the intention is that you shouldn't be able to do arithmetic on characters at all, and that really these should all result in type errors. If these few rather non-obvious quirks are just missed cases, then it makes sense that nothing really makes sense when using them.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Samario on February 12, 2015, 10:14:55 PM
I've been developing a Danmakufu script over the past week or so, and I've encountered a strange bug.
I have the boss firing two shots left and right, which are intended to bounce at the player when they hit the wall, but they... don't.
Despite the fact that I have code for that in place which is really odd.

Here's my code, for reference. (http://pastebin.com/f3hmzfkx)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on February 13, 2015, 01:28:31 AM
I've been developing a Danmakufu script over the past week or so, and I've encountered a strange bug.
I have the boss firing two shots left and right, which are intended to bounce at the player when they hit the wall, but they... don't.
Despite the fact that I have code for that in place which is really odd.

Here's my code, for reference. (http://pastebin.com/f3hmzfkx)

Line 71: You need a ;
angletoplayer(): There is already a built-int function GetAngleToPlayer()


For more information on ObjMove_AddPattern, read http://sparen.github.io/ph3tutorials/ph3u1l8.html#sub5 (http://sparen.github.io/ph3tutorials/ph3u1l8.html#sub5) - you are setting the angle to player when you call ObjMove_AddPattern. If you do this, the bullet will set its angle to what ObjMove_AddPattern had when it was called, not the angle at the time it hits the wall. Read the rest of the tutorial I linked above - you will find a while loop such as the following:
Code: [Select]
task BulletCommands(obj){
    while(<insert code for inside walls here>){yield;}
    ObjMove_SetAngle(obj, GetAngleToPlayer(obj);
}
to work better. Also, use GetStgFrameWidth and GetStgFrameHeight instead of 384 and 448.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: FallenLegacy on February 13, 2015, 05:25:24 AM
What is the limitations of Danmakufu?  I am very new and although I wanna learn Unity I am worried I am walking through a land mine so if danmakufu is recommended for beginners and the limitations are not too bad I might use it to practice. (Please be the right thread I am sorry if it isn't I am trying)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 13, 2015, 05:46:34 AM
What is the limitations of Danmakufu?  I am very new and although I wanna learn Unity I am worried I am walking through a land mine so if danmakufu is recommended for beginners and the limitations are not too bad I might use it to practice. (Please be the right thread I am sorry if it isn't I am trying)

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 13, 2015, 07:58:18 AM
I wouldn't call most of those limitations, really. Not having arbitrary features in the language specification isn't a real limitation, I think. Noting a lack of features in the language makes sense when the language probably should support a capability because of its relation to another capability but doesn't, or where something should be accessible but isn't. Not being able to curry functions in a procedural language isn't something to lose sleep over.

- Speed is a concern, although really it doesn't get bad until you start doing a serious amount of work. On the level of fully polished games you will probably have to be careful and optimize.

- The type system is quite weak, as the only "raw" types available to you are boolean values, numbers (only one datatype) and characters (arrays of which are strings). Many things you manipulate in Danmakufu are various types in the program itself but the scripting language only lets you refer to them with numbered IDs (object IDs, enemy IDs, etc).

- The only data structures available are arrays (which really behave more like lists), so you have to implement other structures yourself if you need to. Map structures are sort of available in the form of object "values" and CommonData, but it's fairly clunky.

- There are many things the engine does in the background that would be really nice to be able to access but you have no way to, so some things are just plain hidden from you. This has improved since 0.12m, but still isn't as good as it could be.

- Although there are objects and most of your programming is about manipulating them, the object-oriented language features are very limited both in what you can access and how you access them. Again, better than it was in 0.12m, but still very limited when compared to using libraries on top of more feature-rich programming languages.

(- Anonymous functions would be nice considering how many tasks you write in DNH are just going to be run the next line anyways.)

Mainly I'm wondering what FallenLegacy expects as examples of limitations, and what they expect to be able to do, if this is one their first programming experiences.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: FallenLegacy on February 13, 2015, 08:47:42 AM
I wouldn't call most of those limitations, really. Not having arbitrary features in the language specification isn't a real limitation, I think. Noting a lack of features in the language makes sense when the language probably should support a capability because of its relation to another capability but doesn't, or where something should be accessible but isn't. Not being able to curry functions in a procedural language isn't something to lose sleep over.

- Speed is a concern, although really it doesn't get bad until you start doing a serious amount of work. On the level of fully polished games you will probably have to be careful and optimize.

- The type system is quite weak, as the only "raw" types available to you are boolean values, numbers (only one datatype) and characters (arrays of which are strings). Many things you manipulate in Danmakufu are various types in the program itself but the scripting language only lets you refer to them with numbered IDs (object IDs, enemy IDs, etc).

- The only data structures available are arrays (which really behave more like lists), so you have to implement other structures yourself if you need to. Map structures are sort of available in the form of object "values" and CommonData, but it's fairly clunky.

- There are many things the engine does in the background that would be really nice to be able to access but you have no way to, so some things are just plain hidden from you. This has improved since 0.12m, but still isn't as good as it could be.

- Although there are objects and most of your programming is about manipulating them, the object-oriented language features are very limited both in what you can access and how you access them. Again, better than it was in 0.12m, but still very limited when compared to using libraries on top of more feature-rich programming languages.

(- Anonymous functions would be nice considering how many tasks you write in DNH are just going to be run the next line anyways.)

Mainly I'm wondering what FallenLegacy expects as examples of limitations, and what they expect to be able to do, if this is one their first programming experiences.


So in other words it is not for beginners and I am better off with Unity or UDK til I know what I am doing? These issues you stated sound complex to fix.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 13, 2015, 08:56:03 AM

So in other words it is not for beginners and I am better off with Unity or UDK til I know what I am doing? These issues you stated sound complex to fix.

It is meant for beginners; the weaknesses target mostly advanced users.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 13, 2015, 10:28:48 AM
Yeah to the above, DNH is pretty beginner-friendly when starting out. The framework is straightforward and making things happen doesn't take too much effort as long as the question "can I do this" has the answer "there's a function for that". This is why I asked what you mean by "limitations".
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 13, 2015, 10:29:56 AM
@ FallenLegacy,

It is also quite black & white. If you decide to work in ph3, we can help you out here with info / questions. If you decide to pick Unity or other method, then you're kind of on your own. We have no resources like tutorials and such and you need to hope if others know about it.

Up to you how to approach this. We just provide you the info.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: FallenLegacy on February 13, 2015, 09:45:57 PM
I will give it a try,besides what have I got to lose besides time? xD I got plenty
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 15, 2015, 05:57:59 AM
Can NotifyEventAll be used in an event handler? If so, then what other circumstances might prevent an event from registering?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 15, 2015, 06:14:10 AM
You can, it'll just crash if you notify the same event without changing conditions. I can't really think of scenarios where an event just won't register at all, since if you use NotifyEventAll() and any script is running, it'll run at least some @Event routine. Whether it's handled after that is another matter.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 15, 2015, 06:16:36 AM
You can, it'll just crash if you notify the same event without changing conditions. I can't really think of scenarios where an event just won't register at all, since if you use NotifyEventAll() and any script is running, it'll run at least some @Event routine. Whether it's handled after that is another matter.

Really?

I have this in my system script:

Code: [Select]
@Event {
alternative (GetEventType())
case (EV_START_BOSS_SPELL) {
let path = dirCurrent ~ "system_magic_circle.dnh";
let id = LoadScript(path);
StartScript(id);
}
case (EV_GAIN_SPELL) {
let objScene = GetEnemyBossSceneObjectID();
let score = ObjEnemyBossScene_GetInfo(objScene, INFO_SPELL_SCORE);
TGainSpell(score);
}
case (EV_SUBMIT_COMPLETE) {
if (GetPlayerLife != 0.123) {
NotifyEventAll(EV_SUBMIT, [getCharacter, getDifficulty, isHidden, 12, GetScore]); // EV_SUBMIT = EV_USER + 6
while (!GetCommonData("HSSubmitDone", false)) {WriteLog("poop"); yield;}
SetCommonData("HSSubmitDone", false);
}
}
}

And in my package script:

Code: [Select]
@Event {
alternative (GetEventType)
case (EV_USER + 3) {
let path = GetEventArgument(0);
ObjSound_Stop(bgm);
if (path != "") {
ObjSound_Load(bgm, path);
ObjSound_Play(bgm);
let dPath = SplitString(path, "/");
SetAreaCommonData("Cy05", "HeardBGM " ~ dPath[length(dPath) - 1], true);
}
}
case (EV_USER + 4) {
let p = GetEventArgument(0);
if (p) {
TBackground;
}
else {
TStopBG;
}
PauseStageScene(p);
}
case (EV_USER + 5) {
whenYouAreDedz(GetEventArgument(0));
}
case (EV_USER + 6) {
RaiseError("event intercepted"); // <--!!
viewHS(GetEventArgument(0));
}
}

Notifying EV_SUBMIT_COMPLETE (which should happen at the end of the stage) doesn't raise any error.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 15, 2015, 06:21:35 AM
Output GetEventType() somewhere at the start of an @Event routine to dump all the events that happen. Are you sure EV_SUBMIT_COMPLETE triggers?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 15, 2015, 06:37:19 AM
Output GetEventType() somewhere at the start of an @Event routine to dump all the events that happen. Are you sure EV_SUBMIT_COMPLETE triggers?

It triggers.

Code: [Select]
2015/02/15 01:36:25.753 1000007pack
2015/02/15 01:36:25.772 1000007sys
2015/02/15 01:36:25.783 1000006sys

And EV_SUBMIT triggers ... but in the wrong script.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 15, 2015, 07:49:44 AM
I really can't replicate your problem. Can you get something simpler working, like NotifyEventAll(EV_USER+100,0) in the @MainLoop of your System script and if(GetEventType==EV_USER+100){ AddScore(1); } in your Package script?


Also silly me, many predefined events can only be called by certain scripts, like EV_REQUEST_LIFE by enemy scripts. These won't "register" if you notify it from another script. That isn't the issue here, but yeah.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 15, 2015, 10:01:12 AM
Since SetInvincibility isn't avail in ph3, I had made the following piece of code:

// Enemy or boss invul mode (since 0.12m doesn't have one)
task setInvulnerableTime(obj,t) {
   let lockHP = ObjEnemy_GetInfo(obj,INFO_LIFE);
   
   loop(t) {
      ObjEnemy_SetLife(obj,lockHP);
      yield;
   }
}


It works, but the HP is being visibly deducted (life bar) and then "reset" back to the initial value. I remember in 0.12m the bar didn't move at all. I know this has to do with the routine of the yield; because there is a 1 frame yield here which will indeed allow any other routines/threads to progress. Except how can I polish this up to act like 0.12m? Or perhaps alternative method?

Edit:
KimoKeine aka Blargel on IRC told me to work with DamageRates. How foolish of me to forget about this.

Here is the new code:
Code: [Select]
// Enemy or boss invul mode (since 0.12m doesn't have one)
task setInvulnerableTime(obj,t) {
// Get damage rate values from obj and store in vars.
let lockShotDmgRate = ObjEnemy_GetInfo(obj,INFO_DAMAGE_RATE_SHOT);
let lockSpellDmgRate = ObjEnemy_GetInfo(obj,INFO_DAMAGE_RATE_SPELL);

// Set damage rate to 0,0.
ObjEnemy_SetDamageRate(obj,0,0);

// yield for t-frames (similar to wait)
loop(t) { yield; }

// Reset damage rates to initial.
ObjEnemy_SetDamageRate(obj,lockShotDmgRate,lockSpellDmgRate);
}

Call the task by typing setInvulnerableTime(obj,t); where ever you want to give the boss or enemy object "god mode" for a while. This won't overwrite the initial damage rate because it is being locked before the actual "freezing" is happening. Unless you of course change the damage rates in between but that would be silly :V

Feel free to (ab)use if you want also.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 17, 2015, 08:45:05 AM
Apologies for the double post-look , but a new question after fooling around for a specific object bullet behaviour. I wish to achieve the following behaviour for an object bullet.

> Boss tosses a bullet (aimed or random) with a certain angle
> bullet hits the walls and starts moving exactly along the walls
> it moves either clockwise or counter-clockwise based on approach angle.

I'll try to roughly show it:
Code: [Select]
task bullet(.....) {
while() {
if(bullet hits "ceiling/floor") {
> Change angle 90 degree exact horizontal (so it goes up or down)
}
if(bullet hits "walls") {
> Change angle 90 degree exact vertical (so it goes up or down)
}
}
}

Important behaviour note: If the bullet is shot "towards left-down", when hitting the edge of the field it will move counter-clockwise. Example:
(http://i.imgur.com/EKhBz7h.png)
bullet is shot at 179 = make bullet move counterclockwise
" 181 = make bullet move clockwise
" 180 = random choice
" 89 = make bullet move counterclockwise
" 91 = make bullet move clockwise
etc...

What I attempted
I managed to get the bullet to change exact horizonta/vertical direction by calculating the "needs adjustment angle". Because if a bullet would fly 260 degrees (upwards) and you want to make it move counter-clockwise, the angle needs to be: -90. But -90 would make the bullet not travel at 180 degree (left), but at 170 degree. Because 260-90 = 170. So I need to calculate the initial approach. How I did for ceiling was: track bullet angle with constant updating let dir = ObjMove_GetAngle(obj); and then let adjustDir = 270 - ObjMove_GetAngle(obj); followed by dir = dir - 90 + adjustDir. So the calculation becomes adjustDir = 270 - 260 = 10 which will do:
> dir = dir - 90 + adjustDir
> dir = dir - 90 + 10
> dir = 260 - 90 + 10
> dir = 170 + 10
> dir = 180

Actual problem
Right, so here comes the problem. I can probably calculate this for every side of the field but the problem is the bullet will get into trouble when approaching the corners. Because the way my statements listen, 2 statements will trigger and start forcing the bullet odd forms making it either not move or shake around.

At this point I started fucking up by overcomplicated and probably useless scripting methods. Probably there is an easier method to achieve my behaviour but I fail to see at this point.

Edit:
- Elaborated the specific behaviour with angle examples
- Eventually I want to bullet to stop moving along the walls but just "leave" or perhaps make it "explode" "disappear" but that is lesser issue atm.
- Awesome mspaint explanation.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 17, 2015, 09:39:03 AM
Code: [Select]
function GetNeatoLockAngle(angle){
    return [round(angle/90)*90 , round((angle%90)/90)*-180+90];
}

val[0]+val[1] is the angle to send it at, then every time it hits a corner add val[1] to it.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 17, 2015, 05:40:25 PM
Alternatively, I thought of checking both x and y, so, for example, a large value of x and a large value of y would trigger turning right or left, depending on the current direction. Don't forget to wait for some times before checking for a corner again.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 17, 2015, 05:51:15 PM
Delaying the thread would be really troublesome in general. I applied the function from Drake and checked the walls + added as he suggested a bit of "space" to avoid double corners from hitting. So far it behaves like I want it.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Youmu970 on February 19, 2015, 07:47:04 AM
Why is This (http://pastebin.com/bSiMecLL (http://pastebin.com/bSiMecLL) ) creating this (http://imgur.com/tIhhU1I (http://imgur.com/tIhhU1I))?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 19, 2015, 08:39:34 AM
Why is This (http://pastebin.com/bSiMecLL (http://pastebin.com/bSiMecLL) ) creating this (http://imgur.com/tIhhU1I (http://imgur.com/tIhhU1I))?
You're calling  TFire; in the @MainLoop thread. MainLoop runs continuously, which means every frame, TFire is summoned and thus causing that what you're showing us.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Youmu970 on February 20, 2015, 01:10:04 AM
Why is ObjSprite2D_SetSourceRect(objRumia,64,1,127,64); not activating here? Rumia isn't switching back to her idle position. (http://pastebin.com/m8phaq9d (http://pastebin.com/m8phaq9d))

Also, why is this (http://pastebin.com/DSyUgsGY (http://pastebin.com/DSyUgsGY)) giving me an error at line 13 saying it can't comprehend it? o.0
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on February 20, 2015, 07:41:36 AM
Why is ObjSprite2D_SetSourceRect(objRumia,64,1,127,64); not activating here? Rumia isn't switching back to her idle position. (http://pastebin.com/m8phaq9d (http://pastebin.com/m8phaq9d))

Also, why is this (http://pastebin.com/DSyUgsGY (http://pastebin.com/DSyUgsGY)) giving me an error at line 13 saying it can't comprehend it? o.0

You forgot a semicolon on line 10.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 24, 2015, 06:35:33 PM
In my player script I've one remaining problem. I've sort of boomerangish behaviour for my shot type. Comparable to default Rumia's focus shot (the strange ball that appears and homes).

There is one major difference. My method uses a 2D Sprite as the "ball" and therefore cannot use any of the ObjMove functions (otherwise ObjMove_SetDestinationAtSpeed would've already saved my ass)  :ohdear:

I got the homing in place with calculating the direction between the ball and enemy object locked. I also used trig to add velocity to the ball to move towards the enemy using the following vars.
let dir = 0;
let x = ObjRender_GetX(obj);
let y = ObjRender_GetY(obj);
let v = 0;
let vx = v*cos(dir);
let vy = v*sin(dir);
x += vx;
y += vy;


By simply increasing v and setting the dir with atan2 makes it moves towards the enemy. Unfocussing also snaps it back to the player (because you simply set the v to 0 and x / y pos at the player.

But, how to make the ball return to the player while remaining focussed but not pressing the shot button? And also how to make the ball "stay" at the player to avoid it flying away or spassing around the place.

Edit

Manage to solve the issue by checking carefully the if/else statements. It returns to the player and stays there but the movement feels extremely wonky due to the calculations and such. I guess I'll revert to the Rumia style method: drawing my sprite on top of the invisible Shot object and use movement functions.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Shadow on February 25, 2015, 07:17:41 PM
I've got a quick way of smoothly returning the shot to the player, the calculation would be as follows:

Code: [Select]
x = (x*0.95)+(GetPlayerX*0.05);
y = (y*0.95)+(GetPlayerY*0.05);

You can adjust the multipliers to in turn adjust the smoothness of the movement, though I haven't experimented much with it myself.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 25, 2015, 08:25:02 PM
I guess I will have to try that out before I adapt to movement functions.

-- --

A different question regarding Enemies. I've studied the Wiki if there were any specific functions to grant the enemy a specific parameter. Like mark the enemy as a familiar / slave so certain homing functions don't home in on the EnemyID. I was initially thinking of creating my own array with EnemyIDs from those who are familiars. But if there is a parameter to be given to the enemy, it would be better. Bit like in 0.12m where you could specify GetArgument.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Shadow on February 26, 2015, 01:04:30 AM
Unless I'm misinterpreting your question, I believe Obj_SetValue and Obj_GetValue would be what you're looking for.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Aka Kyuketsuki on February 26, 2015, 02:00:42 PM
Hi ! I wanted to ask :
Is there a way to make each bullets (ObjShot) which have spawned at different frames change their speed at the same frame ? And how please ?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on February 26, 2015, 03:31:10 PM
Hi ! I wanted to ask :
Is there a way to make each bullets (ObjShot) which have spawned at different frames change their speed at the same frame ? And how please ?

Dump them into an array and then when you want them to change their speed, iterate through the array and use Obj_SetSpeed

Alternatively, count how many frames are passing between their spawn times and use ObjMove_AddPattern with a speed shift, but set the frame parameter in such a way that they all change at the same time.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on February 26, 2015, 05:08:30 PM
Unless I'm misinterpreting your question, I believe Obj_SetValue and Obj_GetValue would be what you're looking for.
. . . . .  :derp: :derp: :derp: :derp:

Right, I totally forgot about this function while I've spotted it few weeks ago. Though how the hell did I miss it on Wiki  :o

Thanks!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Aka Kyuketsuki on February 26, 2015, 06:41:50 PM
Quote
Dump them into an array and then when you want them to change their speed, iterate through the array and use Obj_SetSpeed

Alternatively, count how many frames are passing between their spawn times and use ObjMove_AddPattern with a speed shift, but set the frame parameter in such a way that they all change at the same time.

Since I'm not very good with arrays, the second method seems to work best for me, thank you !  :3
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on February 26, 2015, 09:31:58 PM
Since I'm not very good with arrays, the second method seems to work best for me, thank you !  :3

You're welcome.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on February 26, 2015, 09:32:06 PM
Hi! I have some questions about the item functions.
I want to create some power item. So i use CreateItemA2 (there are created at the player's death) with something like that:
Code: [Select]
CreateItemA2(ITEM_POWER, GetPlayerX, GetPlayerY, GetPlayerX+90*cos(adest), GetPlayerY-ydest+24*sin(adest), 100);(adest & ydest are variable used to set the final item position).

I get some beautiful power item but without any effect on the Player poser value. Same thing with 1UP items (and BOMBS item I guess...).
How this thing works? What I doing wrong/notdoing?

I see I can use user defined item or item script but I dont even know hom I'm supposed to use this.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on February 26, 2015, 09:48:48 PM
Hi! I have some questions about the item functions.
I want to create some power item. So i use CreateItemA2 (there are created at the player's death) with something like that:
Code: [Select]
CreateItemA2(ITEM_POWER, GetPlayerX, GetPlayerY, GetPlayerX+90*cos(adest), GetPlayerY-ydest+24*sin(adest), 100);(adest & ydest are variable used to set the final item position).

I get some beautiful power item but without any effect on the Player poser value. Same thing with 1UP items (and BOMBS item I guess...).
How this thing works? What I doing wrong/notdoing?

I see I can use user defined item or item script but I dont even know hom I'm supposed to use this.

You have to manually set the power yourself. In your item script, have power items increase power when they are collected by the player.

In EV_GET_ITEM if the @Event of your item script, GetEventArgument(0) is the Item ID. You can use this in an if statement to set power/lives/bombs.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on February 26, 2015, 10:25:07 PM
I see. It works now . Thank you :)

And always about item, I see in many scripts bullets turned into custom item and not in default star-item (without changing the default star-item sprite). I search a bit but I don't understand how to do this.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on February 27, 2015, 12:45:51 AM
First of all, you can use the function SetDefaultBonusItemEnable(false) in your item script's @Initialize to disable the star items.

To throw in your own behaviour, there's the event EV_DELETE_SHOT_TO_ITEM that triggers when bullets are itemized. GetEventArgument(0) will give you the shot object's ID, and GetEventArgument(1) will give you the position it's at. So you can just spawn a new item at that position.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on February 27, 2015, 05:51:44 PM
Thank you Drake :3
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on February 28, 2015, 05:21:27 PM
Sorry for double post but I have a strange issue with CreateStraightLaserA1.
(http://img110.xooimage.com/files/0/8/d/sans-titre-4a2381b.jpg)
This warning laser is always glitched and sometime juste dont spawn (but the laser spawn well and surpise-kill the player).
Code: [Select]
if(frame == 7) {
SE(laser02_path);
CreateStraightLaserA1(ex, ey, A+1, 800, 20, 80, C_LASER_RED, 60);
A += alt*360/(64);
}
if(frame == 8) {
SE(shot01_path);
CreateStraightLaserA1(ex, ey, A+1, 800, 20, 80, C_LASER_RED, 60);
Laser01(ex, ey, 4, A+5, 180, 24, LIGHTNING_RED, 30);
frame = 6;
A += alt*360/(56);
if((|A|) >= 360) {
alt = -1*alt;
A = 0;
frame = -360+20*step;
step++;
if(step > 6) {step = 6;}
ObjMove_SetDestAtSpeed(objBoss, rand(60,260), rand(60,130), 1.5);
}
}
This is the laser's part of the script. It's the same laser as the others but it is the only one that does not work properly. Why?

(my english is very bad today... I hope I'm at least understandable...)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on February 28, 2015, 07:03:36 PM
If you are talking about the fact that the delay laser does not render the way you want it to, that's not a bug - that's just a rendering issue with Danmakufu and all you can do is have more delay lasers or increase the width of the laser
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on February 28, 2015, 09:43:17 PM
So it just another danmakufu joke ok. Thank you  :)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on February 28, 2015, 10:29:43 PM
So it just another danmakufu joke ok. Thank you  :)

If you're talking about the upper right hand corner, with no lasers, that's your code, on the other hand.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on March 01, 2015, 10:52:06 AM
If you're talking about the upper right hand corner, with no lasers, that's your code, on the other hand.
Nope. I just take the screenshot before the upper right hand corner's laser spawn ;).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on March 06, 2015, 12:33:36 AM
How are numbers stored in Danmakufu? It seems to store them as doubles, but surprisingly (0.1 + 0.2 - 0.3) * 10^16 returns zero.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: JmLyan on March 06, 2015, 11:05:07 AM
How are numbers stored in Danmakufu? It seems to store them as doubles, but surprisingly (0.1 + 0.2 - 0.3) * 10^16 returns zero.

Shouldn't it? 0.1 + 0.2 - 0.3 is equal to zero, so your equation is basically multiplying 0 with 10 quadrillion.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on March 06, 2015, 02:09:55 PM
JmLyan:
http://en.wikipedia.org/wiki/Floating_point
http://stackoverflow.com/questions/588004/is-floating-point-math-broken


Anyways, they're definitely doubles, but the intriguing bit is how it gets from numbers in the script to the actual representation. 0.3 is actually not represented by the closest approximation, but rather it's that 0.3 = 0.30000000000000004 (0x3FD3333333333334). Meanwhile if you try to explicitly store 0.30000000000000004 you get 0.30000000000000010 (0x3FD3333333333335). If you play around with the LSBs you'll notice that it rounds (I call it "shoving" since it forces rounding even when the value written in script has an existing binary rep) towards ?∞, which by coincidence overcomes that popular example (since it's an issue of rounding to nearest). This itself isn't anything to be concerned about.

For a different example,  -0.3+0.1 != -0.2. When you take into account the shoving it makes it a bit clearer:
-0.3 -> -0.30000000000000004 (shoves to -∞)
0.1 -> 0.10000000000000001 (shoves to +∞)
-0.3+0.1 -> -0.20000000000000004
Which is correct calculation since -0.3 -> -0.30000000000000004. Now since -0.2 == -0.20000000000000001 (not ~04), they won't be equal.

Strange things happen because of the shoving now, like 0.1 != 0.10000000000000001 because 0.10000000000000001 written in script is shoved to 0.10000000000000002.
This then leads to -0.3+0.10000000000000001 == -0.2 (despite -0.3+0.1 != -0.2), since when shoving all these you get
-0.30000000000000004 + 0.10000000000000002 == -0.20000000000000001, which is true.

Its internally consistent, since once the values are in memory it works like it should. You shouldn't be relying on testing non-integer values for precise equality anyways (integers work perfectly fine, though), so really this whole thing should never be an issue anywhere to begin with.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on March 06, 2015, 05:30:42 PM
Hi!
I have some serious FPS drop in my current script  (and in all my script -_-) but I don't really know why except that I'm not a good scripter.
So, what can be the possible main sources of heavy FPS drop and what are things to do or not do to avoid this kind of issues? Most scripteur here do awesome things whitout lag so I have to do something wrong :/
I'm a bit desperate...
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 06, 2015, 06:59:04 PM
Hi!
I have some serious FPS drop in my current script  (and in all my script -_-) but I don't really know why except that I'm not a good scripter.
So, what can be the possible main sources of heavy FPS drop and what are things to do or not do to avoid this kind of issues? Most scripteur here do awesome things whitout lag so I have to do something wrong :/
I'm a bit desperate...

You'll need someone with experience to fully optimize your code...

Anyways... check loops. How often are you doing math? How much ADD/SUBTRACT/MULTIPLY/SHADOW/INVERT_DESTRGB are you using?

Open the log window. Are you deleting all of your floating background objects once they leave the screen? Are you properly removing all of your unneeded resources? How many instances of a certain graphic are there?

If it's across your entire script, then you may have to do some serious fixing.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 06, 2015, 09:46:04 PM
Hi!
I have some serious FPS drop in my current script  (and in all my script -_-) but I don't really know why except that I'm not a good scripter.
So, what can be the possible main sources of heavy FPS drop and what are things to do or not do to avoid this kind of issues? Most scripteur here do awesome things whitout lag so I have to do something wrong :/
I'm a bit desperate...
To expand and explain Sparen's post:
- First, open your LogWindow (if you don't have it, activate it from the config.exe)
- Breakdown your script into parts. What do we first want? Movement ? Bullets ?
- If you did the task-based approach you'll have your life easier, otherwise good luck...
- Comment out everything first.

Begin iteration:
1 - Launch the game and check how many objects/script tasks are running.
2 - Uncomment bits of parts > Test > monitor the FPS and log window. How many objects are made? What is the script task count etc etc
3 - Hold the ALT key to fast forward the game bit then monitor again.
4a - If your script is stable and no FPS drop happens > uncomment the next bit again.
OR
4b - If your script lags, you know where it happens. Start checking the code

Your comments and uncomments should be suspected things like: Effects, bullet patterns, Object based things.

Once you found which part lags, you can easier trace down what is happening.

Good luck.

Edit: The same applies to included scripts and such. What ever you're running you need to start from 0 then slowly uncomment things and test with each time. Don't uncomment huge blocks of code or you'll get lost.

Edit 2: I think I've seen you before using the @MainLoop based method for scripting. Yea, that is going to be trickier to comment/uncomment in general.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on March 07, 2015, 11:18:20 AM
Thank you. I start to do what you say Helepolis and I notice some things that bring me two new questions:

- I use a general task to load all the textures and sound at the beginning of my stage script but... it load the texture for all the scripts that will be called later (like boss scripts, item scripts, system script, etc) or it load the texture for this script only? I use the Texture part of the log windows and I see texture that appear several times. But I'm not sure if there are loaded texture of used texture...
However if textures are preloaded only in one script it can be one of the main fps drop source.

- It seem that sound object add fpsdrop in some case. I use a task like that to do sound effect but I'm not sure it's the best thing to do:
Code: [Select]
task SE(path) {
      let obj = ObjSound_Create;
ObjSound_SetSoundDivision(obj,SOUND_SE);
      ObjSound_Load(obj,path);
      ObjSound_Play(obj);
      ObjSound_SetVolumeRate(obj,100);
    loop(400) {yield;}
Obj_Delete(obj);
}

Quote from: sparen
If it's across your entire script, then you may have to do some serious fixing.
On my computer it run at 60 fps all the time exept in some case like when I use a bomb or when a spellcard is declared. But on other's computer it seem to run at ~50 fps all the time (like on your's if I trust your RaNGE video of my entry). It's a bit hard to know if it really fixed or not :/

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 07, 2015, 03:57:58 PM
- It seem that sound object add fpsdrop in some case. I use a task like that to do sound effect but I'm not sure it's the best thing to do:
Code: [Select]
task SE(path) {
      let obj = ObjSound_Create;
ObjSound_SetSoundDivision(obj,SOUND_SE);
      ObjSound_Load(obj,path);
      ObjSound_Play(obj);
      ObjSound_SetVolumeRate(obj,100);
    loop(400) {yield;}
Obj_Delete(obj);
}

What is the loop(400){yield;} for? Use something closer to the following:

Code: [Select]
function SE(path) {
      let obj = ObjSound_Create;
ObjSound_SetSoundDivision(obj,SOUND_SE);
      ObjSound_Load(obj,path);
      ObjSound_Play(obj);
      ObjSound_SetVolumeRate(obj,100);
        return obj;
}

Run this once per sound effect, and then use ObjSound_Play(returned value);
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on March 07, 2015, 04:40:54 PM
To be clear, Sparen means to create and load a Sound object only once, and then use that object every time you want to play that sound. You only need one object, and then you can play it as many times as you want. The flow might look something like this:


Code: [Select]
let SE_SHOT;
let SE_CHARGE;

function LoadSE(path) {  // Returns a Sound object that plays the given file
let obj = ObjSound_Create();
ObjSound_SetSoundDivision(obj, SOUND_SE);
ObjSound_Load(obj, path);
ObjSound_SetVolumeRate(obj, 100);
return obj;
}

@Initialize{
SE_SHOT = LoadSE(dir ~ "shot.wav");
SE_CHARGE = LoadSE(dir ~ "charge.wav");
}

task TPattern(){
loop{
ObjSound_Play(SE_CHARGE);
loop(60){yield;}
loop(60){
ShootBullets();
ObjSound_Play(SE_SHOT);
yield;
}
loop(240){yield;}
}
}


The only thing is that using one sound object means playing a sound when it's already playing will restart it, so if for whatever reason you want the sound to overlap itself you'll need one or two more sound objects.


- I use a general task to load all the textures and sound at the beginning of my stage script but... it load the texture for all the scripts that will be called later (like boss scripts, item scripts, system script, etc) or it load the texture for this script only? I use the Texture part of the log windows and I see texture that appear several times. But I'm not sure if there are loaded texture of used texture...
If you're seeing textures with the same (full) name but at different addresses, something isn't right. The number of different places that the texture is being used is under the Ref column, so that's what should be increasing.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on March 09, 2015, 10:08:23 PM
I don't know I can do that with Sound Object. It's cool and it orevent so many Object creation. Thank you both.

Quote
If you're seeing textures with the same (full) name but at different addresses, something isn't right. The number of different places that the texture is being used is under the Ref column, so that's what should be increasing.
Thanks, thanks and thanks again. I found my main problem whit that. I fail my texture/sound load and it load I don't know what at the beginning and load the use thing when it is used... everytime).
You save me.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on March 10, 2015, 07:37:28 PM
Is in ph3 some "event_script{} " like in 0.12m.
I want to make dialogue?or schould I do all this stuff with Prim-objects or graphic?  :V
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on March 10, 2015, 08:14:57 PM
Is in ph3 some "event_script{} " like in 0.12m.
I want to make dialogue?or schould I do all this stuff with Prim-objects or graphic?  :V

You can use text objects.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 10, 2015, 08:18:50 PM
Is in ph3 some "event_script{} " like in 0.12m.
I want to make dialogue?or schould I do all this stuff with Prim-objects or graphic?  :V

You can use text objects.

If you decide not to make your own, some people have released their own libraries for this. DO NOTE, HOWEVER: not everyone will let you use their libraries, because we have spent many hours making and testing, and seeing someone use a library this complex without permission is going to make some of us angry

If you decide to make your own, take into account using your own font as well as using virtual key functions to see if the player has pressed the Z button. Also aim for good readability.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 10, 2015, 08:54:35 PM
I think you two are actually forgetting to actually proper answer the post by adding unnecessary (imo) explanations for now. Not that you're wrong with your posts or did something bad, but the core question was: "Is there a event like script in ph3", not whether he wanted to use libraries or text objects. Let us try to answer the questions accurately  ;)

Let us also refrain from immediately being stepped on our toes about nothing when the user haven't actually 'used' or 'borrowed' any thing yet. I am pretty sure it is common sense to ask permission for materials. And even if the user did 'steal', I prefer to see it handled in a mature way.


To answer the question, Zhan: Unfortunately, no. Ph3 has no similar functions like 0.12m.

You'll need to create your own Dialogue script including everything from swapping faces to putting text on your screen. As you might have realised, this is quite the effort indeed. You're indeed going to use 2D sprite functions for the portraits and either sprite based text or Text Objects like suggested.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on March 10, 2015, 09:03:43 PM
Big thanks for all  :)
I will try to make my own library  :o
That nobody would be angry~
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 13, 2015, 08:50:37 PM
Apparently there seems to be a limit to the number of characters you can display in your LogWindow for ph3. I was happy putting the following Array in my commonData.
Code: [Select]
  SetAreaCommonData("core","Normal",[
   [[0,0,0],[0,0,0],[0,0,0],[0,0,0]], 
   [[0,0,0],[0,0,0],[0,0,0],[0,0,0]], 
   [[0,0,0],[0,0,0],[0,0,0],[0,0,0]], 
   [[0,0,0],[0,0,0],[0,0,0],[0,0,0]],
   [[0,0,0],[0,0,0],[0,0,0],[0,0,0]],   
   [[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
  ]);

When I tried to happy view the log window, ph3 crashed. I thought I made the array wrong but that is a negative as long as I don't touch the window everything runs fine.

So! I checked out the following things by adding x-number of characters in a CommonData and checking the log Window. the commondata used was SetAreaCommonData("testarea","test","X-characters"); as a string.
500 characters > Crash
400 characters > Crash
256 characters > Crash
255 characters > Crash
200 characters > Works fine.

Assuming the limit is between, I didn't arse myself to find the exact value. It already pissed me off that I couldn't work with arrays like this. Next attempt was test on regular number instead of string.  SetAreaCommonData("testarea","test",0000etc...);
200 characters > Crash
100 characters > Works fine but the result is interesting. I used: 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890

And the log window is like this:
(http://i.imgur.com/9CWOy4R.jpg)

So yeah, there you have it folks. Becareful when using arrays and commondata or large number of characters + you want to use the LogWindow.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on March 13, 2015, 08:58:11 PM
As for the number, that's because you've hit the limit of how large numbers can get. It's just so big that the accuracy is actually off by that much.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: FlareDragon on March 16, 2015, 02:48:16 AM
This might seem like an odd question, but could an event be describe within a task, or rather called by a task. An example:
Example Script
Code: [Select]
...
@Event{
    runEvent;
}
...
Example Separate Script
Code: [Select]
task runEvent{
    alternative(GetEventType())
    case(EV_REQUEST_LIFE){
        SetScriptResult(1500);
    }
    case(EV_REQUEST_TIMER){
        SetScriptResult(60);
      }
}

The reason I'm asking is because I'm attempting to create a shortcuts "script" so I can use it as templates whenever I make a new script and don't have to re-type it for each new script. Also, if this is actually a bad idea, be sure to tell me so I know it's a bad idea XD
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on March 16, 2015, 03:26:10 AM
You don't use a task; @Event is already a routine that runs every frame an event occurs, so there's no purpose in creating an extra thread for it. It'd be even worse if you had looping yields in it, since not only does @Event not even run every frame, but it would also spawn that task every time an event occurred, which would be hilariously bad.

The answer is yes, but just use a function/subroutine instead. In most cases this is a bit iffy just because you don't usually want to have the same events and results for every script, but if it works for you then sure.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: FlareDragon on March 16, 2015, 03:52:19 AM
You don't use a task; @Event is already a routine that runs every frame an event occurs, so there's no purpose in creating an extra thread for it. It'd be even worse if you had looping yields in it, since not only does @Event not even run every frame, but it would also spawn that task every time an event occurred, which would be hilariously bad.

The answer is yes, but just use a function/subroutine instead. In most cases this is a bit iffy just because you don't usually want to have the same events and results for every script, but if it works for you then sure.
*facepalm* When I said task, I meant function. Whoopsy me >n<
Also, the function would have arguments so that they could be different for each script (and thanks for the swift answer)

And I guess I learnt something new too: @Event runs every-time an event occurs, not simply the once at the beginning. ^u^
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on March 16, 2015, 04:06:36 AM
Specifically it's run every time that particular script has been notified an event has occurred, so sometimes it will run multiple times in one frame. Some events don't trigger @Event in some scripts, like EV_GRAZE only triggers the player script's @Event, and EV_GET_ITEM only triggers player scripts and item scripts. It's also the difference between NotifyEvent() and NotifyEventAll().
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 16, 2015, 11:47:05 AM
I have a question regarding the User Interface and Replay system for ph3. I know in particular the Locaa folks are far more advanced and experienced with the UI and replay system so hoping they might teach me in this. I have studied and made menu system for the game but the replay system seems to be confusing the hell out of me.

Studying Rumia's sample and digging through the endless acronyms and style isn't helping. In desperation I was considering on temporary copy-pasting Rumia's method and crediting (if I were to run out of time), but since there is some time left I was wondering if it is able to get done in a fashionable way.

I have honestly no idea where to start with the replay saving screen + Replay listing screen. Could perhaps someone explain me which essential functions I need to use or what the actual "structure" is for a replay save / display / load menu?

Thanks
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 16, 2015, 02:19:14 PM
I have a question regarding the User Interface and Replay system for ph3. I know in particular the Locaa folks are far more advanced and experienced with the UI and replay system so hoping they might teach me in this. I have studied and made menu system for the game but the replay system seems to be confusing the hell out of me.

Studying Rumia's sample and digging through the endless acronyms and style isn't helping. In desperation I was considering on temporary copy-pasting Rumia's method and crediting (if I were to run out of time), but since there is some time left I was wondering if it is able to get done in a fashionaaabluh way.

I have honestly no idea where to start with the replay saving screen + Replay listing screen. Could perhaps someone explain me which essential functions I need to use or what the actual "structure" is for a replay save / display / load menu?

Thanks

Personally, I based everything off of the sample/default scripts, and all I did was implement functionality for replay comments (AKA saving difficulty, effect settings, etc. to a replay in order for those to be loaded correctly). Most of the code refers to the menu, and all of the basic functions required for the replay to function correctly are in the sample scripts as well. I'd say to use the sample scripts and build on that, because for the Replay Save Scene and the Replay Select Scene, most of the code is already provided, and all you need to do is understand how it works.

Personally, replays were one of the most annoying things to get working, and my replay select scene looks terrible, though that's my issue
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: gtbot on March 16, 2015, 04:30:56 PM
Personally, instead of using replay comments, I have a common data that saves difficulty and player options, and I run Save/LoadCommonDataAreaToReplayFile first thing in the system script, and differentiate game playing/replay playback by using the IsReplay function.

The way the default Rumia scripts work is with a SetScriptResult system -- this is because the non-package menu scripts (pause, end scene, replay save scene) are handled by Danmakufu during a Single/Plural/Stage, but in a Package, you'll have to deal with it yourself (it's not much more code though).

For replay saving, SaveReplay is really all that's needed. Most of the code in the Rumia replay save scene is for displaying the GetReplay info (so the player can select which replay index to save to) and the name input keyboard (to input the replay's name).

It gets a little weird for replay playback, though. The ExRumia package and replay select was made with only ExRumia as the player in mind (kinda weird since everything else is sort of flexible). The way the ExRumia select scene script works is, it displays all the replays using GetReplayInfo, and once the player makes a selection, it will send back the path to the replay back to the package. The ExRumia package will then start the stage using the replay from the results of the select scene script (or if user cancelled, back to main menu). The stage scene in the ExRumia package always sets Default_Player_Rumia.txt as the player. If you're going to be having multiple players, you're going to exclude the SetStagePlayerScript function. The SetStageReplayFile function seems to set the player for you already, and if you try to "replace" it, you'll get errors thrown back at you. Otherwise, the setup is the same as if you were playing the game.

I don't know exactly how stage indices work for replays, since I haven't worked with those. It is possible to start replays at specific stages though.


To answer your question more concisely, SaveReplay, GetReplayInfo, SetStageReplayFile are the most essential functions. Saving the replay will need the index to save to, and the name to save it as. For displaying replays, you'll use the information from GetReplayInfo to create strings that'll relay the replay's information to the player. For playback, after the player has chosen a replay, you will then take the path of the replay and use it on the SetStageReplayFile function, with mostly the same setup as if you were playing the game; exceptions include excluding SetStagePlayerScript, and changing your pause/endscene menus to reflect the fact that it's a replay (you don't want to save a replay after watching a replay).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 16, 2015, 06:38:18 PM
@ Sparen & gtbot,  Hmmm, I don't intend to implement anything flashy or over the top. It is a replay screen after all and such improvements can be done later anyway. I rather focus on the core content and mechanics.

Exclude the SetStagePlayerScript? I assume that the replay file stores all values about the player and such, meaning your emphasis on "trying to replace" is the problem here right?  So that makes me think I need to check whether a replay menu has been loaded before the Stageplay is launched. That shouldn't be hard in my current structure as the loading is only 1 line so check around it should be minimum effort.

FinalizeStageScene has been marked on the wiki defining the ending point for a replay. Though that means you shouldn't be calling FinalizeStageScene in between the stage jumps, unless the player died/game over'd.

So to put it more into structure and to see if I understood this:
- The Replay playback menu is nothing more than retrieving all replays stored by using the GetReplayInfo in an iteration?
- SaveReplay is more than enough to technically save the replay but for "naming" purposes, an extra menu can be overlayed to type in playername or replayname?
- SetStagePlayerScript function should be excluded when a replay is initiated.
- SetStageReplayFile will kick off the replay. Path seems to the replay, but do I need to set the stage index before this?

To provide bit more technical info about my game structure:
- I only have 1 stage file which contains 3 functions/subroutines listening to a parameter. Basically  renderStage(stgnum)  >   if(stgnum == 1) { stg1 stuff } (ry
- Plurals are loaded within the stage files as common.
- There are two 'heartbeat' tasks which perma checks the state of the player and if you died. One is inside the Stagelauncher "pack" (not the stage structure)  and other inside the actual stage script.
- The first heartbeat listens to pausing, ending and such. The second heartbeat checks player status during stage play.
- Stage jumping is done by calling CloseStg at the end of the subroutine for my stage
- The stage pack heartbeat is triggered with STAGE_RESULT_CLEARED and will toss in an Ending Screen then check what the current stage index is. If it is last stage > launch all clear menu. Otherwise, increment index and re-initialize stage which is basically:
Code: [Select]
InitializeStageScene;
SetStageIndex(stgIndex);
SetStageMainScript("stagescript.txt");
SetStagePlayerScript;
StartStageScene;

Will any of the above influence my replay implementation?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on March 16, 2015, 07:38:52 PM
Im on mobile atm so excuse this messy post but replays are influenced by ingame elements only, outside data shouldn't be a problem. A replat menu is a menu that obtains all replay files and such, the save screen is the same but implemented slightly differently.

You use the getreplayinfo function to obtain the stage index data which returns an array for the score between each stage, telling the game what stage to load during a replay is just passing the correct stage index value before starting the stage using the setreplayindex function. I'll elaborate more when i get home.


Ok time to actually go into detail on how each menu work and how to get a replay to start from any stage.


For the replay select menu you'll need:
LoadReplayList(); This seems to just load all of the current replays in the replay folder into the game's memory, call it before doing anything else

GetValidReplayIndex(); Similar to the previous function but this returns the array of replays loaded, if a replay was saved on index 0 and another on index 3, indices 1 and 2 will return as invalid when using the IsValidReplayIndex() function.

Finally, you obviously need the GetReplayInfo(valid index,info type); function. Use this to append information about a replay to strings and display them as text objects or spritefonts if you use those instead.

The Replay Save menu is exactly the same except for the if statement that will control what happens when you press the OK button (Z), this is where you calculate and merge the data you need to grab from the replay when its time for the game to be loaded.
You can use the SaveAreaCommonDataToReplay(); function or SetReplayInfo(REPLAY_COMMENT,string of data); function (Safer but abit harder to manage). Make sure the string separates the data by a delimiter so that you can use SplitString(string, delimiter);.

That may be abit hard to understand just by word only, I don't have time to conjure up a tutorial however, I can upload the replay menus for MMS.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 17, 2015, 06:41:54 AM
Cheers, I will try to give it a go this week definitely and report whether I succeeded or not.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: FlareDragon on March 17, 2015, 08:40:49 AM
I've got another question (and this one might seem silly):
What is CommonData, what is it used for and how is it used?
I'm trying to learn aspects of Danmakufu and this one feels important to learn, but the wiki isn't helping me on the subject.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 17, 2015, 06:45:43 PM
I've got another question (and this one might seem silly):
What is CommonData, what is it used for and how is it used?
I'm trying to learn aspects of Danmakufu and this one feels important to learn, but the wiki isn't helping me on the subject.
CommonData is a function which allows you to communicate across scripts (mainly) or tasks/functions which aren't included/related directly in ph3. Normally you would need to include scripts to call variables from there (if global). CommonData is stored in the "memory" during the entire "play" and is active once it is called/set.

SetCommonData(<string>,<value>); is your starting point for example. The string parameter is the commondata identifier. The value can be a bool, int or string. The value can be called by using GetCommonData(<string>,defaultvalue>); The default value is always returned if the CommonData could not find a valid value from the SetcommonData.

A good example which was "common" in 0.12m was setting menu difficulty. Let us say you want to set the difficulty and call this value regardless of which script is running/closed. CommonData would be most useful here.
SetCommonData("difficulty","easy"); next, in some other script where you call enemy patterns, you want to know what the difficulty setting is:
if(GetCommonData("difficulty","easy") == "normal") { }   <-  will check if the commondata "difficulty" equals "normal". The defaultvalue is only retrieved if the commondata was "invalid", but since it has a value it will not return easy. You could also make it return something else like 'false'. But the default value might be useful in some cases.

Another example would be player power:
Code: [Select]
SetCommonData("playerPower",100);
// player picks up a P.
let power = GetCommonData("playerPower",0);
power++;
SetCommonData("playerPower",power);

Above example summons a commondata named playerPower with starting value of 100. In some P-pickup event, I retrieve the value and store it inside temp variable called: power (for easier calc). Next, the powervar is incremented once. So the value of power = 101. The power var is then stored again in the commondata under the same name. The old value will be overwritten and thus if you check your logwindow, you will notice playerpower became 101.

If playerpower was never set, like it didn't exist then the default value retrieved would be 0. Thus power would be 0 and incremented once becoming 1. So the new commondata would be 1. Simple as that.

Regular CommonData is also cleared from the "memory" when your running game/script is closed (i.e unloading back to menu in ph3). In the CommonData tab in Logwindow (activate it if you don't have it) you can see the results.

Logically there is more too it like saving your commondata and such, but baby steps are advised. Ph3 also empowers the use of CommonData by allowing you to use commondata areas, which is basically categorizing your commondata more efficiently. But that is one another step next. Try to fiddle around with the above first.



Edit quick question

Has anybody ever fiddled with INFO_IS_DURABLE_SPELL ? This:
Code: [Select]
@Event {
alternative(GetEventType())
case(EV_REQUEST_IS_DURABLE_SPELL) {
SetScriptResult(true);
}
}
Does not return 'true' when I check ObjEnemyBossScene_GetInfo(bossObj,INFO_IS_DURABLE_SPELL) with text object. Am I missing something?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on March 17, 2015, 11:24:01 PM
Edit quick question

Has anybody ever fiddled with INFO_IS_DURABLE_SPELL ? This:
Code: [Select]
@Event {
alternative(GetEventType())
case(EV_REQUEST_IS_DURABLE_SPELL) {
SetScriptResult(true);
}
}
Does not return 'true' when I check ObjEnemyBossScene_GetInfo(bossObj,INFO_IS_DURABLE_SPELL) with text object. Am I missing something?

Try setting the time limit as well.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 18, 2015, 06:40:06 AM
Try setting the time limit as well.
There is one, I removed it in the post for display reasons but guess that wasn't a good idea. (There was also a life result)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on March 18, 2015, 07:35:00 AM
There is one, I removed it in the post for display reasons but guess that wasn't a good idea. (There was also a life result)
What about the spell bonus?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 18, 2015, 07:49:56 AM
What about the spell bonus?
Negative. Funny thing is: If I set a spell bonus score, and try to retrieve that value it doesn't report it either. But if I capture the card, it will show the spell bonus I set with the default system.

Edit
Never mind, figured it out when I realised I had used the INFO_TIMER before in my SpellCircle code: ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_TIMER);

The magical missing value here is GetEnemyBossSceneObjectID which will retrieve the bossSceneID and then the function becomes usable. bossObj is wrong because that is the enemy boss obj. Also retrieving the scene id with commondata caused ph3 to freeze.

Now I can see that my debug text throws " true " for the DURABLE_SPELL result.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on March 18, 2015, 08:28:31 PM
Negative. Funny thing is: If I set a spell bonus score, and try to retrieve that value it doesn't report it either. But if I capture the card, it will show the spell bonus I set with the default system.

Edit
Never mind, figured it out when I realised I had used the INFO_TIMER before in my SpellCircle code: ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_TIMER);

The magical missing value here is GetEnemyBossSceneObjectID which will retrieve the bossSceneID and then the function becomes usable. bossObj is wrong because that is the enemy boss obj. Also retrieving the scene id with commondata caused ph3 to freeze.

Now I can see that my debug text throws " true " for the DURABLE_SPELL result.

Debugging is often a pain in Danmakufu, eh?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: RedLightingBolt on March 19, 2015, 10:06:50 AM
Yeah, I need some help with Danmakufu and AppLocale.
So, what will happen if I open Danmakufu without Applocale?
Also how do I install AppLocale? Willl it change my computer system and... <Insert More questions here>?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 19, 2015, 03:06:06 PM
Yeah, I need some help with Danmakufu and AppLocale.
So, what will happen if I open Danmakufu without Applocale?
Also how do I install AppLocale? Willl it change my computer system and... <Insert More questions here>?

Please read the sticky: https://www.shrinemaiden.org/forum/index.php/topic,6181.0.html
AppLocale info thread: https://www.shrinemaiden.org/forum/index.php?topic=4138.0

Regarding your questions:
If you open ph3 [.1] without AppLocale, it will run 100% fine. If you run ph3 [.0] without it, none of the scripts will load. 0.12m will crash
It's software, so no, it will not change your operating system.

Please read the FAQ and some of the tutorials - at this point it should be clear that you do not need AppLocale to run ph3
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on March 19, 2015, 03:12:14 PM
 0.12m will crash (http://0.12m will crash)
It don't crash if you have no japanese caracters in your scripts (at least it never crash with my scripts and without applocal).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on March 19, 2015, 09:04:24 PM
Danmakufu 12m doesn't work with Windows Aero(fancy window style introduced in Vista and 7), it doesn't need Applocale unless you try to play a script with Japanese characters.

Danmakufu Ph3 used to require applocale to run properly (mainly to see error messages) but since the support for Unicode in version 0.1 pre1, it is no longer needed. The engine will adjust itself depending on your computer's locale.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 20, 2015, 02:45:21 PM
So I am trying to load a 2D map from a text file. However, I do not how to load this into a 2D array in Danmakufu, as there do not seem to be ObjFile functions that can read individual characters from a text file.

Would it be best to write a C program to convert my text file to a binary one and then use ObjFileB_ReadByte() to obtain the character values in the map so that I can process and load them into a 2D array? Or is there a O(n^2) or better alternative solution?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on March 20, 2015, 03:08:11 PM
What's the current format of the map? Depending on what you're trying to get from the map a solution would vary.

EDIT: Yup.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 20, 2015, 03:28:48 PM
What's the current format of the map? Depending on what you're trying to get from the map a solution would vary.

It's a 36x36 grid of characters, each of which corresponds to a specific type of object. Excerpt below:
Code: [Select]
....................................
....................................
....................................
....00000.............#.............
....00000.............#.............
....00000...........#####...........
....00$00...........#...#...........
......*.............#...#*..........
......#.............#....$000.......
......#.............#....0000.......
......#.............#....0000.......
......#.............#...............
......#########...00000.............
......#.......#...00000.............
......#.......###*$0000.............

For example, the first . in the code would prompt me to ObjTile_Create(0,0) and then ObjTile_SetState(obj, OBJTILE_TYPE_WALL). However, I would need the character at (0,0) in order to determine which state to set it to, and there is no ObjFileT function for that.

Note: ObjTile is a custom object I created in Danmakufu that extends ObjRender



EDIT: GTbot found the super simple face palm-worthy solution

[3/20/15, 12:02:53 PM] Harley (gtbot): string = objfile_getline
[3/20/15, 12:03:08 PM] Harley (gtbot): string[0] = first character
string[1] = second character
[3/20/15, 12:03:08 PM] Harley (gtbot): etc

Thanks though, Drake.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 20, 2015, 06:41:21 PM
Related to earlier post about the limit of characters in the Logwindow, I've addressed this at Mkm's BBS, let us see what he has to say about this issue. Would be supreme if it would be fixed somehow (if it is an error or limitation), otherwise I am forced to spam more commondatas.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on March 20, 2015, 07:42:37 PM
So I am trying to load a 2D map from a text file. However, I do not how to load this into a 2D array in Danmakufu, as there do not seem to be ObjFile functions that can read individual characters from a text file.

Would it be best to write a C program to convert my text file to a binary one and then use ObjFileB_ReadByte() to obtain the character values in the map so that I can process and load them into a 2D array? Or is there a O(n^2) or better alternative solution?

An O(n^2) or better solution is impossible due to how arrays are handled in Danmakufu.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: keyshooter on March 23, 2015, 06:03:28 PM
Hello, i'm really new on danmakufu (I know some programming language [C#, Java, VB, PHP, JS] but this is new to me, so, i'm a newbie) and i know how to do basic stuff but of course, everything looks great if you do great so, to the point:

I want to know how to put a BG on movement in a Spellcard and also how to do a hp bar similar to TH13 hp bar. I know the basic i do some... simple spellcards (Sparen tutorials, Helepolis tutorials too) but i want to this thing look more... "touhouness"? That's the think, thanks everyone and hope somebody can help me out :D
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on March 23, 2015, 08:55:35 PM
Programming language experience won't do much since danmakufu isn't the same kind of OOP as the languages you mentioned. For backgrounds you need to use ObjPrim_Create(OBJ_SPRITE_2D) for 2D objects, followed by the appropiate ObjSprite2D_XXX functions and ObjRender_XXX functions. For 3D objects use OBJ_SPRITE_3D and the ObjSprite3D_XXX functions.

To create the lifebar like GFW - DDC, you'll need a decent understanding of how primitive objects work, as well as some basic knowledge of trig. Use ObjPrim_Create(OBJ_PRIMITIVE_2D);, set the primitive type to PRIMITIVE_TRIANGLESTRIP.

http://www.geocities.co.jp/SiliconValley-Oakland/9951/pre/th_dnh_help_v3.html

Here is the official documentation for ph3, which is currently more reliable than the english danmakufu wiki (wiki still needs to be cleaned up of incorrect information). Make use of this, it will help you alot, even if you just pop the function descriptions into google translate. For 10D's lifebar, look towards the bottom for the ObjPrim_XXX functions.

Alternatively, I can give you the code I used to make it for my game if you want.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 23, 2015, 09:14:15 PM
This is a question that may have no answer.

When using a render object or any non-vector graphic in Danmakufu phd (it did not exist in 0.12m), there is anti-aliasing, which blurs the edges of images. However, when pixel perfect precision is wanted, there is, as far as I know, no way to turn this off and keep the original pixels of the source image. Is there a way to turn off anti-aliasing in Danmakufu? If there is a solution involving shaders, I will consider it.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on March 23, 2015, 09:23:27 PM
You can use a x2 picture and keep pixel without blur if it don't move. But on moving picture it remain some very light blur pixels on the edges. It can work if you want a pixel perfect background or HUD and keep a blur tolerance on characters and bullets.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on March 23, 2015, 09:31:21 PM
Hello, i'm really new on danmakufu (I know some programming language [C#, Java, VB, PHP, JS] but this is new to me, so, i'm a newbie) and i know how to do basic stuff but of course, everything looks great if you do great so, to the point:

I want to know how to put a BG on movement in a Spellcard and also how to do a hp bar similar to TH13 hp bar. I know the basic i do some... simple spellcards (Sparen tutorials, Helepolis tutorials too) but i want to this thing look more... "touhouness"? That's the think, thanks everyone and hope somebody can help me out :D

You can look at my code (https://gist.github.com/bluebear94/69fe40e240131346d227).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: keyshooter on March 23, 2015, 11:07:47 PM
Thanks to everyone, the last topic it's really helpfull, but thanks to everyone, i still a little confuse about the Background Imag of the spellcard, so, i make a 3D render of the image and use in the system?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on March 23, 2015, 11:24:13 PM
Thanks to everyone, the last topic it's really helpfull, but thanks to everyone, i still a little confuse about the Background Imag of the spellcard, so, i make a 3D render of the image and use in the system?
You can draw 3D backgrounds anywhere you like. Most people follow the samples and just call a separate script with a bunch of 3D background code stored in it with the #Background[path] header

This is a question that may have no answer.

When using a render object or any non-vector graphic in Danmakufu phd (it did not exist in 0.12m), there is anti-aliasing, which blurs the edges of images. However, when pixel perfect precision is wanted, there is, as far as I know, no way to turn this off and keep the original pixels of the source image. Is there a way to turn off anti-aliasing in Danmakufu? If there is a solution involving shaders, I will consider it.

Its not anti-aliasing, or even close to what AA even does. The problem is that your texture's width and height are not a power of 2. This is a feature that DirectX9 has that will resize images that are not a power of 2 (n^2), which causes the image to be blurred and distorted.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 24, 2015, 01:46:30 AM
Its not anti-aliasing, or even close to what AA even does. The problem is that your texture's width and height are not a power of 2. This is a feature that DirectX9 has that will resize images that are not a power of 2 (n^2), which causes the image to be blurred and distorted.

...Except that the texture is 512x512.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on March 24, 2015, 01:49:18 AM
Oh boy, blurry aids question

You can use a x2 picture and keep pixel without blur if it don't move. But on moving picture it remain some very light blur pixels on the edges. It can work if you want a pixel perfect background or HUD and keep a blur tolerance on characters and bullets.
Its not anti-aliasing, or even close to what AA even does. The problem is that your texture's width and height are not a power of 2. This is a feature that DirectX9 has that will resize images that are not a power of 2 (n^2), which causes the image to be blurred and distorted.
This actually isn't entirely true. Yes, you do have to use images of dimensions 2n due to the aforementioned reason. Additionally though, the reason why moving pictures are blurred is largely due to rendering at non-integer positions. Even if you're drawing a sprite at a fixed location, but non-integer, it will also get blurry aids from interpolation gimmicks (not AA).

a) Drawn at (0, 0)
b) Drawn at (0.5, 0)
c) Moving with speed 2 and angle 45

(http://i.imgur.com/3bogwOJ.png)  (http://i.imgur.com/CtfDaVs.png)  (http://i.imgur.com/D4wywut.png)

One problem is that if you're using any sort of vector-based movement (SetSpeed() and SetAngle(), SetDestAtFrame(), etc) the position change is applied at the end of the frame by the engine (so you can no longer change it), but right before it's rendered, so you can't simply force the position and have it work like that.

However, when pixel perfect precision is wanted, there is, as far as I know, no way to turn this off and keep the original pixels of the source image. Is there a way to turn off anti-aliasing in Danmakufu? If there is a solution involving shaders, I will consider it.
There's a solution for Primitive objects. Unfortunately I haven't found a way to perfectly render things like Shot objects without introducing fairly significant overhead.
Basically though, you calculate the object's position in advance, get the decimal portion of the next position, and subtract it not from the object's position, but its rendering destination.

For example, if an object were moving at speed 2 and angle 40 from (100, 100), its next position will be (100 + 2*cos(40), 100 + 2*sin(40)) = (101.532089, 101.285575), so you want to offset the rendering location by (-0.532089, -0.285575) in order to get a clean (101, 101). The downside to this is that since you're actively trying to remove any interpolation, some movement (especially slow movement) might look not as smooth since it is moving a pixel at a time.

Code: [Select]
function ObjSprite2D_Clean(obj, l, t, r, b){
let hw = (r - l) / 2;
let hh = (b - t) / 2;
let a = ObjMove_GetAngle(obj);
let s = ObjMove_GetSpeed(obj);
let off_x = (ObjRender_GetX(obj)+cos(a)*s)%1;
let off_y = (ObjRender_GetY(obj)+sin(a)*s)%1;
ObjSprite2D_SetDestRect(obj, -hw - off_x, -hh - off_y, hw - off_x, hh - off_y);
}

For Primitive objects in general you'd have to change the position of each vertex accordingly. You should also be able to see why it won't work with Shot objects: they have no way to set their rendering location.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 24, 2015, 03:40:29 AM
Each tile object is permanently locked into a specific 24*x, 24*x integer position, fyi. I will live with it and have the tile sets cover up the fact that the issue even exists.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on March 24, 2015, 04:17:08 AM
If they're in static positions there is no reason that you couldn't get it to render properly. I'm not sure what you mean.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on March 24, 2015, 06:24:10 AM
If the positions are even and nothing is moving, then that goes back to what I said before about the texture sizes not being a power of 2. If the actual texture is 24x24 and not just the source/destination rectangle, then you need to change the canvas of your image to 32x32 using gimp, or Photoshop or whatever.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on March 24, 2015, 09:12:55 AM
...Except that the texture is 512x512.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 24, 2015, 12:49:13 PM
The image is 512x512, and each individual tile is 24x24, placed at an integer coordinate. There may be an issue when the 2D camera moves, but that's on me.

Examples of code:

       ObjSprite2D_SetSourceRect(map[j], 26, 276, 50, 300);

       ObjSprite2D_SetDestRect(map[j], 0, 0, 24, 24);

Code: [Select]
//Initializes a Tile Object
//Param: Grid X (int), Grid Y (int)
//Return: Object ID (int)
function ObjTile_Create(x, y){
    let obj = ObjPrim_Create(OBJ_SPRITE_2D);
    ObjTile_SetPosition(obj, x, y);
    ObjRender_SetPosition(obj, x*24, y*24, 1);
    return obj;
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on March 25, 2015, 01:14:02 AM
Dunno what you're doing, but this works just fine.

https://gist.github.com/drakeirving/f49aeb16fc0f9c8ac331
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 25, 2015, 03:22:10 AM
Dunno what you're doing, but this works just fine.

https://gist.github.com/drakeirving/f49aeb16fc0f9c8ac331

I give up. The issue isn't that serious anyways. Worst case scenario, nothing happens. Since functionality is not impaired, it won't be too much of a problem.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: FlareDragon on March 25, 2015, 08:13:54 AM
I dunno if it'll be of help, but perhaps the issue could be related to the Stage width/height? Or perhaps the window of Danmakufu isn't at its standard 640x480. If not those little thing, then I guess I'm of no help. Just figured I'd put my 2-cents worth in
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on March 25, 2015, 12:33:32 PM
I dunno if it'll be of help, but perhaps the issue could be related to the Stage width/height? Or perhaps the window of Danmakufu isn't at its standard 640x480. If not those little thing, then I guess I'm of no help. Just figured I'd put my 2-cents worth in

The issue is completely independent of the 640x480 window, which can be changed in the .def file
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 25, 2015, 08:43:14 PM
Want to update on the people who helped me with the replay question, thank you once more. Based on the example scripts + explanation, I managed to do this:

As there is no difficulty info, I am abusing REPLAY_COMMENT for this. I'll use commondata to retrieve the difficulty level then store it inside REPLAY_COMMENT.

I also noticed that in the example script the replay info is concatenated in an array then the array is directly shown as the text object. I guess this is just a style. I personally adapted different style with setting vars then concatenating the vars in the text object. Similar thing but the array confused me personally.

Of course there is no playback, yet, though I understand the way replays are stored and displayed.

Edit 27-03-2015
Managed to successfully playback a replay and set in the menu-flow mechanics. I.e: Returning back to replay overview if it is a replay and such. All that is left now is to create the "Replay from stage #X" when multiple stages available + Replay Save mechanics with name entering and such. If this is all set I have finished another core requirement of my game. Excitement++
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 27, 2015, 06:12:35 PM
Still stuck with the final part of my replay saving system which is when you actually decide to Save and exit without the stage ending / player dying. It throws me the following error:

"save target replay not found"

When you hit the ESC button a Pause screen is summoned. The result of the pause screen is passed on in Alternative(result) 
Code: [Select]
case(RESULT_SAVE_REPLAY) {
ObjText_SetText(stglist2,"SAVE REPLAY was chosen");
loop(120) { yield; }
TerminateStageScene;
gameReplaySaveScene;
break;
}
I even delayed the thing to see if the correct case was called. It was, so we can assume my menu choice is correctly passed through. gameReplaySaveScene is basically task that summons the replay list and allows the player to select a replay slot. This same menu is exactly called when you Game Over. So to sum up:
- If I Game Over >> the replay saving goes perfectly fine.
- If I use the mid-play replay and exit, it will throw me the above error.

I am suspecting this has something to do with the fact that the GetStageSceneState isn't receiving a PLAYER DOWN / STAGE CLEAR status. But even if we suspected this, I tried summoning my replay save menu through  STAGE_RESULT_BREAK_OFF but that didn't help out either.

If I try to call FinalizeStageScene it will throw me the error "not finished stage"

 :o

Edit:
Ok so it seems this has to do with the fact CloseStgScene is not called and therefore the GetStageSceneState isn't officially over. Except calling CloseStgScene is throwing me the error the function is not defined. Confusion even more now.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on March 31, 2015, 07:49:00 AM
Sorry please, if this question was already here, aaand maybe it is stupiest question,,,but how to make enemy (boss) float? (by Y goes up and down a little). I tried various way, but enemy started to behave weird?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on March 31, 2015, 08:36:56 AM
Sorry please, if this question was already here, aaand maybe it is stupiest question,,,but how to make enemy (boss) float? (by Y goes up and down a little). I tried various way, but enemy started to behave weird?
Use ObjSprite2D_SetDestRect(); and modify the ' top ' and ' bottom ' rect parameters so the Y-position of the sprite shifts. This way you won't be moving your actual Obj position and thus avoid weird behaviour.

Example for 64x64 sprite of a boss:
ObjSprite2D_SetDestRect(obj,0,0+hover,64,64+hover);

Then mutate the hover var as you please with sin() or something to make it smooth up/down.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on March 31, 2015, 08:48:20 AM
Use ObjSprite2D_SetDestRect(); and modify the ' top ' and ' bottom ' rect parameters so the Y-position of the sprite shifts. This way you won't be moving your actual Obj position and thus avoid weird behaviour.

Example for 64x64 sprite of a boss:
ObjSprite2D_SetDestRect(obj,0,0+hover,64,64+hover);

Then mutate the hover var as you please with sin() or something to make it smooth up/down.

Big big thanks! I would have not guessed  :X
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 01, 2015, 07:25:24 AM
Question regarding resource management and pre-loading of sounds and bgm.

Some background info
Before I've had a task which was  task playSFX("pathname/sound.wav");. The task simply loaded a sound taking in the pathname parameter, played it and done. Except when you do this throughout your entire game the number of objects will be 20.000+ which is eventually degrading your performance.

Based on Drake's previous page post I have replaced all instances with ObjSound_Play(soundname);  example: ObjSound_Play(SFX_TAN00); in my spell cards or non spells or anywhere sounds are used SFX_TAN00 is declared and loaded inside an #included sounds.txt. So let us say spellcard01 has #included sounds.txt.

Code: [Select]
Library: sounds.txt

let SFX_TAN00 = loadSFX("pathname/tan00.wav");
let SFX_LAZER00 = loadSFX("pathname/lazer00.wav");
let SFX_KIRA00 = loadSFX("pathname/kira00.wav");

function loadSFX(path) {
let obj = .....;
ObjSound_Load(path);
Sound stuff;
return obj;
}

However, if you do this for a plural script, your sounds.txt will be called like N times and thus result in unnecessary loading. So obviously I could #include my sound library from a more central place, like my main stage script.

Here comes the problem
Plural scripts and System scripts are loaded through the StartScript() and they too contain various sound effects. I am getting SFX_TAN00 not defined errors, which is logical because scripts don't share info among each other. So what to do?

If I #include my sounds inside system script or my plural scripts it will defeat the purpose of optimization. Plural scripts being booted from the stage are also unable to access my sounds library.



Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: FlareDragon on April 01, 2015, 07:35:17 AM
With the first scenario, couldn't you set it up so that it checks if particular sound objects exist (are loaded), and if they aren't, THEN they're loaded? Means that, although it'll look at the script multiple times, it would only load the sounds the once since it'll check if they're loaded.

The second scenario, I wouldn't have an idea (though this isn't helped by being a Danmakufu Novice)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 01, 2015, 09:51:05 AM
You're basically correct, actually (although the implementation isn't quite that). After some thinking I have a fairly good solution:

https://gist.github.com/drakeirving/64833e1ef543fc713a2b

To use this, you include it once in your "main" script (stage, etc, EDIT: not packages), call InitSounds(), and then also include it in any other script you'd want sounds in. By doing so you'll be able to just use ObjSound_Play() with any of the pseudo-constants you write in.

This way you:

I haven't seen a big script so far that doesn't have at least one of these problems, I think.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 01, 2015, 10:48:09 AM
Ok so attempted what Drake said and we seem to have success here.  I have tested it with just one sound for now (to avoid doing it 120x wrong)

When I monitor the logwindow I can see the reference to the sound file is maximum of 2 for some unknown reason. But this still means I need to include my sounds.txt everywhere where a script is launched using StartScript(); because otherwise the variables cannot be called.

I kept few old style code to compare. I can see for example 1 sound file being referred 15x and Drake's method 2x. Regardless how many times I call the #include sounds.txt, it will keep reference at two. I have tested bit more elaborate because I summoned the sounds.txt in the following locations for my own game:
- System.txt
- Globals.txt (contains some vars and stuff)
- MainStageScript
- Playerscripts (2x)

I'll try to see if I can load this all the way from my Main Package script + adding all sound files. Will report later tonight.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: gtbot on April 01, 2015, 01:59:15 PM
Drake's style is the style I currently use as well (loading objects, storing them into common data), but I do want to note one limitation: if you were to load the sound effects (and create the objects) inside the Package script, it will not work if you try to play the objects in the game script (the Package objects seem to not be recognized from the game script... or maybe I was just doing something wrong idk, but in any case user events are pretty cool anyway).

An alternative, which I haven't tried but I'm certain it works, would be to use user events and constants. In your Package script initialize all your object sound effects, you then create a new user event, and inside you get the event argument (which we would use here as either a string or number, your choice), and based on that argument, you play a certain sound. For example code, refer to this sample code (http://pastebin.com/9jcUgyVn).

There are definitely ways you can improve upon the sample code. One really unique way I thought of would be to use ObjFile, duplicate the SE_Constants.txt (so that you can have an empty file and a new "working" file, created/overwritten each time the sound effects are loaded, that you reference in your code), fill in all the variables with the object ID, and by doing that, you can forgo the SE_SOUND_OBJ variables in the package script, and just directly play the given event argument instead of checking all the constants to determine which one to play.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 01, 2015, 07:12:38 PM
Indeed, it seems package scripts are completely isolated from from everything and sound objects don't seem to function in there.

Though it seems I am running into more issues. First of all when I boot a boss through plural mode, I have all sounds except sounds being called inside my System.txt. If I boot the game through my stage script and meet the same boss, I don't have player sounds any more (shooting, spell card). Sounds.txt is called from all locations but problem keeps being persistent. Even more weird, when I load my own spell practise through my package script, which then eventually boots up the stage script to do a spell practise, it will start mixing sounds. Suddenly it will play voices or BGMs during spell cards.

And I did add #System["<pathto>/function_system.txt"] in each plural script so the system should be always loaded.

[Setup]
System.txt > calls sounds.txt  (in this file, spell card declare SFX (like se_cat00) is played or when boss step ends, another sound is played)
Plural scripts > #System is defined.
nonspells/spell cards > calls sounds.txt (regular sounds played like se_power / se_tan00 etc)
Stage script > calls sounds.txt and boots system script (handles the stage looks etc, loads sounds because it can be used for enemy wave patterns and such)
Player script(s) > calls sounds.txt (player spell card declare sound, fire sound, graze sound etc)

Plural mode:
- spell/nonspell sounds OK
- Player sounds OK
- System.txt are missing

Package play story mode (which eventually loads stage script)
- spell/nonspell sounds OK
- Player sounds missing
- System.txt sounds OK

I am extremely confused atm.

Edit: made some post edits to explain hopefully better.

Edit2
The mixing of sounds probably occurs due to sounds being unloaded or commondata being cleared. I can see it happening in my Sound log window.
1) Package script booted
2) Spell practise chosen (boots stage script then a plural script which loads 1 spell card)
3) All sounds work fine (log window shows sounds present)
4) Exit through the pause menu (sounds still present
5) Pick same spell card again
6) For some reason now, sounds are completely cleared / disappeared / unloaded.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 02, 2015, 06:44:45 AM
Ok so uh yeah, packages are a no-go. After some testing, the objects created in a Package script persist when you start other scripts, as expected, but:
1) New scripts lose control of the package's objects entirely, and the engine reassigns new object IDs starting back at 0
2) But, the package script still uses the existing object IDs
3) When you "come back" to the package script it actually just restarts, so the same objects are then recreated with IDs counting up from where the other scripts left off
4) Which means the package script can't even use/delete the objects it made the last time it ran, creating an object limbo and potential memory leaking!
5) When starting another script again, repeat step 1

Anyways yes gtbot, use of events the other idea I had. At first I was wary of flooding the event scheduler so I opted not to, but all things considered in regular circumstances you won't be calling many sounds on any given frame anyways. That is, as long as you're using a specific NotifyEvent() and not All(). However, I think using an ObjFile is overly convoluted, and playing with files isn't exactly quick. Just use an array to store the object IDs and you're done.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 03, 2015, 06:27:15 AM
Some rather silly but significant problems with what I posted before:
- The variables are never set to the proper values for whichever script is meant to call InitSounds(), since the common data won't be set
- In the same way, any scripts that import the sounds before InitSounds() is called won't have their values set, which is often quite a few (e.g. player)

So rather than think of a way to get around that I just redid it using the event-based method in my last post:
https://gist.github.com/drakeirving/64833e1ef543fc713a2b

To start this you'd instead just run StartScript(LoadScript(dir ~ "lib_soundhandler.dnh")) in your base script, and include lib_sounds.dnh where you want sounds. To actually play them, use _PlaySE() instead.

Again, benefits:

Unfortunately, it looks like starting a stage from a package doesn't just wipe the existing object IDs, but also the existing script IDs. If you run this from a package script, you get the benefit of only ever having one script that just handles all the sounds for everything else and never launching anything more than once, but once a stage starts the engine drops the script IDs and so you cannot simply use NotifyEvent() to trigger only the sound handler, which would be ideal. The script doesn't close, so you can still use NotifyEventAll() as I've written, but you no longer have any direct access to the script. That being said, if you don't use a package as the base script (stage, plural, etc), you can just toss around the sound handler's script ID and use NotifyEvent() just fine.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 03, 2015, 10:54:32 AM
Based on the latest posts I too had suggested for my own game with Drake to summon 1 script which boots with StartScript as soon as my package starts, processes all files then starts listening to the @Event to play the sounds. Drake received my original files and he took a closer look at it all.

function_sound.txt is kicked off in my main package. My main package is handling the texture, commondata and such.
const_sound.txt is a file which contains all the vars as enum/identify (i.e let SHOT = 0;  let KIRA = 1; etc). but also the functions to summon a NotifyEventAll

Inside const_sound.txt Drake wrote function PlaySFX(id) { NotifyEventAll(EV_USER,id); } . The function before was the old regular let obj = sound(ry.

Now wherever I want to play sounds, whether it be my Player Script or isolated function_system.txt I can call my sound library by using the above function. All I have to do is #include the const_sounds.txt and that is it.

Extensive testing shows that regardless of what happens in the game (stage load/unload, practise mode, etc) the sound library remains loaded in the memory. Meaning loading times are only existent when the game is booted. This is the perfect scenario so far Drake has managed for me.

I have expanded the usage by adding a PlayMusic(id) (because playbgm is default ph3 function :V I also ran into this) and StopMusic(id). As well as adding function to change the RestartEnable value. I wanted to separate the IDs and make a clear distinction between SFX and BGM.

Feels like a huge weight got lifted off my shoulders, because this was core requirement for my game. Thanks to you all I managed to get one step closer to the completion of my game.

Thank you all.  :getdown:
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Agent17 on April 03, 2015, 04:09:00 PM
Hi, is there something to make bullet change when they enter an area (no matter their ID) ?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 03, 2015, 04:29:44 PM
GetShotIdInCircleA2(x, y, radius, TARGET_ENEMY) will grab all the shot IDs in the circle around point (x, y). You can then loop through those IDs and modify them however you want.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Agent17 on April 03, 2015, 04:44:40 PM
I tried this :
Code: [Select]
let Area = GetShotIdInCircleA2(ObjMove_GetX(obj),ObjMove_GetY(obj),100,TARGET_ENEMY);

while(!Obj_IsDeleted(obj)) {
ObjMove_AddPatternA1(Area,0,0.8,90);
Area = GetShotIdInCircleA2(ObjMove_GetX(obj),ObjMove_GetY(obj),100,TARGET_ENEMY);

yield;
}

but it doesn't work. What should I do to make it work ?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on April 03, 2015, 05:38:03 PM
You're not using it correctly.

Code: [Select]
let ObjArray; //Create a variable

while(!Obj_IsDeleted(obj))
{
//Store Bullet IDs within the radius into the variable. The variable's type is now considered an array.
ObjArray = GetShotIdInCircleA2(ObjMove_GetX(obj),ObjMove_GetY(obj),100,TARGET_ENEMY);

//Loop through the length of that array with "i"
ascent(i in 0..length(ObjArray))
{
//Apply a change in speed, and angle, after 1 frame for all bullets in the array.
ObjMove_AddPatternA1(ObjArray[i],1,0.8,90);
}

yield;
}

You were treating your Area array as a normal variable when you passed it into the ObjMove_AddPattern function, which really just passes an ID of 0. To grab the IDs from an array you reference them by index.

ex: let first_bullet = ObjArray[0];

Remember that the first index in any array starts at 0, and the last index ends with (the total length - 1). So an array of 10 indices would have its last index be 9 since you start from 0. The length(array) function returns the size of an array automatically.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on April 06, 2015, 10:08:36 AM
Could anybody help me please? What an error is this? (I don't find it in Blargel error list)
-----------
ErrorWindow
-----------
_NextChar: (and something on Japanese)
-----------
OK
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on April 06, 2015, 10:17:42 AM
Check if you don't have a /* without a */ after. I already get this type of error and (if I remember) it is due to a lack or incomplete */ commenting the rest of the script and cuting  functions/task/other important things.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 06, 2015, 10:21:31 AM
Please either copy the message using ctrl+c, or screenshot the message. What you've posted gives zero information as to what the error actually is.
EDIT: Thanks
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on April 06, 2015, 10:34:44 AM
>Lefkada
  - Thanks! Error was near, it was a problem with /" and " .
>Drake
  - Sorry please, my fault, this will not happen more.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Miplouf Saigyouki on April 06, 2015, 12:14:57 PM
Sorry to bother you guys, but I wanted to know if someone had any intention to make a "Array and Bullets Guide", to explain how you can use arrays of bullets to create interactions with any elements.
That would be most definitely useful for many of us, i'm sure. (unless i'm the only guy who is too scared of arrays)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 06, 2015, 12:42:15 PM
Could you specify? I could probably write something when I get up.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Miplouf Saigyouki on April 06, 2015, 12:59:34 PM
Well it's mostly bullet / laser interactions...

example: When the bullets hit a laser, split bullets in three (a bit like the SCC alice spell)

But really, it's just to see how to do arrays, all i can do with them are just simple things like set shot graphics, positioning, and such... I don't really know much about bullet arrays.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on April 06, 2015, 01:05:27 PM
Well it's mostly bullet / laser interactions...

example: When the bullets hit a laser, split bullets in three (a bit like the SCC alice spell)

But really, it's just to see how to do arrays, all i can do with them are just simple things like set shot graphics, positioning, and such... I don't really know much about bullet arrays.

Well, you can iterate through an array and call commands on each of the items inside. You would probably use obj-obj collision for bullets hitting a laser - I did this and the amount of lag due to accessing arrays was phenomenal.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Miplouf Saigyouki on April 06, 2015, 01:14:34 PM
Hm, I see...
Well then, i guess i'll just go and try for myself.

Thanks anyway.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on April 07, 2015, 01:49:15 AM
Well, you can iterate through an array and call commands on each of the items inside. You would probably use obj-obj collision for bullets hitting a laser - I did this and the amount of lag due to accessing arrays was phenomenal.

On a sidenote, Sparen has asked mkm to make array accesses constant-time.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on April 07, 2015, 01:57:13 AM
On a sidenote, Sparen has asked mkm to make array accesses constant-time.

Well, although I have not received a reply stating "I will consider it" ... I doubt it will be implemented anytime soon
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 07, 2015, 04:37:13 AM
Curious, by what means have you concluded array access isn't constant? Because from my own testing, it very much is. I think it's very likely you're seeing non-constant times from something else.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on April 07, 2015, 05:13:41 AM
Curious, by what means have you concluded array access isn't constant? Because from my own testing, it very much is. I think it's very likely you're seeing non-constant times from something else.

It depends on the size of the array.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 07, 2015, 05:28:50 AM
Uh, I mean how have you tested this. Because it really doesn't.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on April 07, 2015, 07:47:55 PM
Hi! I was wondering, how sometime (if it's not very often), replays are completly broken and the player starts to do anything (but certainly not what I do in the run) after a random time? Even juste after I record the replay.
It's not the first time I notice that but I have no idea why it happen and why. And how to avoid this? It's really problematic for full games or serious scripts.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on April 07, 2015, 08:19:26 PM
Hi! I was wondering, how sometime (if it's not very often), replays are completly broken and the player starts to do anything (but certainly not what I do in the run) after a random time? Even juste after I record the replay.
It's not the first time I notice that but I have no idea why it happen and why. And how to avoid this? It's really problematic for full games or serious scripts.

If it occurs in a package, watch out for CommonData like effect settings and the like. A single rand or the existence/non-existence of a single object can desync the entire replay. Make sure to reset all CommonData that were specific to a game at the start of your main package task (which should run after a script has ended), and make sure you are using replay comments wisely.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Aka Kyuketsuki on April 10, 2015, 05:44:08 PM
It's me again !  :ohdear: I would like to have some help with some maths...

Code: [Select]
let angle = 0;
let r = 100;
let r2 = 0;

loop(10){
loop(40){

let id = CreateShotA1(GetEnemyX(objBoss) + r*cos(angle), GetEnemyY(objBoss) + r2*sin(angle), 1, angle, 11, 10);
angle += 360/40;
}

r -= 10;
r2 += 10;
wait(2);
}

In this pattern, the bullets spawn from a variable radius, ant it forms a horizontal oval who goes into a vertical one. However the problem is : I want this oval to move depending of the player, so the bullet are aimed at the player. But this oval transformation seems "fixed" and the bullets goes in a weird angle when aimed. How to make this oval rotate at the angle to the player please ?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on April 10, 2015, 06:54:04 PM
It's me again !  :ohdear: I would like to have some help with some maths...

Code: [Select]
let angle = 0;
let r = 100;
let r2 = 0;

loop(10){
loop(40){

let id = CreateShotA1(GetEnemyX(objBoss) + r*cos(angle), GetEnemyY(objBoss) + r2*sin(angle), 1, angle, 11, 10);
angle += 360/40;
}

r -= 10;
r2 += 10;
wait(2);
}

In this pattern, the bullets spawn from a variable radius, ant it forms a horizontal oval who goes into a vertical one. However the problem is : I want this oval to move depending of the player, so the bullet are aimed at the player. But this oval transformation seems "fixed" and the bullets goes in a weird angle when aimed. How to make this oval rotate at the angle to the player please ?

You will need to use rotation matrices (http://en.wikipedia.org/wiki/Rotation_matrix)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Shadow on April 10, 2015, 07:52:46 PM
This requires some fairly complex trigonometric calculations, as Sparen said. Worry not, I have the answer. I'll provide you two functions here:

Code: [Select]
function GetEllipticX(let bX, let xLength, let yLength, let gapAngle, let dispAngle){
return bX+xLength*cos(gapAngle)*cos(dispAngle)-yLength*sin(gapAngle)*sin(dispAngle);
}

function GetEllipticY(let bY, let xLength, let yLength, let gapAngle, let dispAngle){
return bY+xLength*cos(gapAngle)*sin(dispAngle)+yLength*sin(gapAngle)*cos(dispAngle);
}

You can use these to form an ellipse centered on the coordinates bX and bY, adjust its minimum and maximum radii with xLength and yLength, and also adjust the angular alignment of the ellipse itself with dispAngle. gapAngle is used to create the actual ellipse, akin to how you use "x+radius*cos(angle)" or "y+radius*sin(angle)". Applying these functions to your code, we would have:

Code: [Select]
let angle = 0; // Since we're offsetting the angle of the ellipse, the position of the first bullet should stay at 0 degrees to ensure it aims at the player.
let angle2 = GetAngleToPlayer(objBoss); // The angular alignment of the ellipse, aimed at the player.
let r = 100;
let r2 = 0;
loop(10){
loop(40){
let sX = GetEllipticX(GetBossX,r,r2,angle,angle2-90); // Utilizing the GetEllipticX function.
// As the ellipse is supposed to begin in a horizontal position, we subtract 90 from angle2.
let sY = GetEllipticY(GetBossY,r,r2,angle,angle2-90); // The GetEllipticY variant of the above.
let trueAngle = angle+(angle2-90); // Still, using the above offsets the actual angle of the bullet due to the rotation.
// We fix this by adding "angle2-90" back to the original angle.
let id = CreateShotA1(sX, sY, 1, trueAngle, 11, 10);
angle += 360/40;
}
r -= 10;
r2 += 10;
wait(2);
}

I hope that helps~
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Aka Kyuketsuki on April 10, 2015, 08:33:09 PM
Quote
You will need to use rotation matrices

Still, how to use them, I really suck at maths x)

Quote
I hope that helps~

Thanks a lot ! It works perfectly !  :3
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 10, 2015, 09:34:12 PM
Question regarding replay play back:

GetReplayInfo REPLAY_STAGE_INDEX_LIST should return an array of all indexes used. However, even if I "played through" three stages, it only returns me the last StageIndex  [ 3 ]. I am expecting it to return [1 , 2 , 3]

During the stage jumping, I am not Finalizing until the 3rd stage has ended and the Clear Screen is called. I am though using InitializeStageScene each time a stage jump occurs.

Below a very rough setup how the stuff flows.
Code: [Select]
task initStage {
InitializeStageScene;
if(replay) { SetStageReplayFile()  SetStageIndex(<index get from replay> }
else { Playerscript(ry... SetStageIndex(1);  }
Kick off STG script...
}
 
// if stage cleared
task clearStage {
if(stage != 3) { jump stage (index + 1) initStage; }
else { FinalizeStageScene, clear game menu, save replay etc }

}

Edit

Documentation on Wiki doesn't make sense or the usage / explanation is wrong. Either way, I tried many things with Finalize / Terminate / Initialize but none of them seem to return me a proper array of indexes.

Took a look also at MPP and RSS and both didn't even utilize the INDEX method. It seems these two games don't allow replay playback based on stage choice but just fully playback.

I decided to do the same and ditched the stage jumping with Index setting. For my game too, there will be a single replay. The difference between Story and Practise is made inside the replay comment by adding values to the string and later on splitting it with SplitString.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 12, 2015, 08:57:24 PM
So over the last 2 hours I have been lit. tearing my hair out with the ANSI - UTF-8 and SHIFT-JIS encoding/conversion.

Within Notepad++ I was happy adding spellcard names in both English and Japanese.
- My Japanese characters turn gibbrish kanji/symbols. Even if I see them in notepad correctly displayed, if I set Character Set to Shift-JIS, they turn to gibbrish.
- Saving file / reloading countless times keeps this problem up
- UFT-8 without BOM is being set each and every time
- Even worse, if I rewrite the kana/kanji manually , save and reload the file it jumps to ANSI even.

And even more worse. This occurred to half the spell cards. Most of them I fixed by reloading/resaving/reencoding etc. But these last few keep on being persistent and ***** annoying.

Am I doing something wrong in regarding to setting to Japanese characters Shift-Jis? Why is it constantly jumping to ANSI?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on April 12, 2015, 09:28:48 PM
So over the last 2 hours I have been lit. tearing my hair out with the ANSI - UTF-8 and SHIFT-JIS encoding/conversion.

Within Notepad++ I was happy adding spellcard names in both English and Japanese.
- My Japanese characters turn gibbrish kanji/symbols. Even if I see them in notepad correctly displayed, if I set Character Set to Shift-JIS, they turn to gibbrish.
- Saving file / reloading countless times keeps this problem up
- UFT-8 without BOM is being set each and every time
- Even worse, if I rewrite the kana/kanji manually , save and reload the file it jumps to ANSI even.

And even more worse. This occurred to half the spell cards. Most of them I fixed by reloading/resaving/reencoding etc. But these last few keep on being persistent and ***** annoying.

Am I doing something wrong in regarding to setting to Japanese characters Shift-Jis? Why is it constantly jumping to ANSI?

I'm not sure what's the problem, but there's a UTF-8 reading library (https://gist.github.com/bluebear94/804553f3e84f361f841b) if you just want to save everything in UTF-8.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 13, 2015, 04:28:29 AM
It's more a problem of NP++ autodetection or something than anything else. Without seeing what's happening it's a bit hard to tell.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 13, 2015, 06:35:07 AM
Pretty much whenever it spots Japanese characters it reverts to ANSI, which is odd. For example:

- New file in ANSI automatically made.
- Insert random text in english > convert to UTF-8 w/o BOM
- Save and reload file
- Bottom right corner shows UTF8 no BOM.
- Set character set to shift-jis
- Insert Japanese characters now into the file
- Save and reload > boom, back to ANSI.

I have aprox 40+ spell cards which are all in shift-jis detection and a dialogue file. But these 6 files refuse to cooperate.

I tried removing the japanese characters > encode to utf8 w/o BOM then paste it in a fresh new file with steps above but nope.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 13, 2015, 08:07:38 AM
for other readers, problem was because DNH reads UTF-16 w/ BOM, not UTF-8, oops
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 13, 2015, 08:23:20 AM
For the troublesome cards I set it too UTF-16 LE with BOM in Sublime Text editor. Notepad++ sees it as UCS-2 Little Endian but Drake suggested me to ignore that and not convert inside NP++

Not touching the rest of my cards since they are all in shift-jis. Random check on RSS fangame script also shows shift-jis.

I am not sure what is going on but yea. Weird stuff.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chester-low on April 14, 2015, 09:05:29 AM
Hey guys ! I need your help :)
Okay I'm actualy creating ? game with danmakufu (original game, not ? touhou game) and I have some problems:

+ I don't manage to realise a custom shot data script. I tried everything but it don't work, I have ?n error message in which it's writtenthat the two values at the beggining  are not defined...

+ I have somes trouble with plural scripts too. It work but when ? nonspell is finished the enemy is deleted and an other enemy (the same) come from x = 0 and y =0 and continue his attack

+ I need ? mean to check the direction of the boss. My sprite is always on same direction, i would like to turn it when the boss move at the left

+ I also need help for dialog and menu script i didn't find any tutorials :/

Hum I'm so sorry to have all these problems uh. Moreover english is not my native language, so...sorry for mistakes or if you didn't understand !
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 14, 2015, 10:25:06 AM
1. Please post what you have in a pastebin (http://pastebin.com/).

2. The boss position should automatically be tracked by the Boss Scene. In many cases, between patterns you might have one frame where the boss object does not exist, so its position is reported to be (0,0), so if you're using a custom movement function it might be affected. Anyways, please post what you have in a pastebin as well.

3. For the easy way, you can use if(cos(ObjMove_GetAngle(obj)) > 0) to check if the object is moving to the right, and if it's < 0 it's moving to the left.

However, this only works if you use movement-based functions like ObjMove_SetDestAtFrame() and ObjMove_SetAngle(), so it might not work in all cases. If you want something a bit sturdier, you can get the difference between the object's x-position and its x-position on the previous frame:
Code: [Select]
let x0 = ObjMove_GetX(objEnemy);
while(!Obj_IsDeleted(objEnemy)){
let x = ObjMove_GetX(objEnemy);
if(x - x0 < 0){
// left
}else if(x - x0 > 0){
// right
}else{
// idle
}
x0 = x; // update x-position
yield;
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on April 14, 2015, 08:29:27 PM
Is there any LastSpell; functions like in 0.12? I haven't find them ???
If there no one, so what I need to do to make a "last spell sense" in a [Single] type?
[When character lose one life, current script should be closed] I tried with GetPlayerLife, but it started to behave wierd?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on April 14, 2015, 08:41:24 PM
Not a function but an event.
Put this in @Event of your enemy script:
Code: [Select]
alternative(GetEventType())
case(EV_REQUEST_IS_LAST_SPELL){SetScriptResult(true);}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on April 15, 2015, 05:15:50 AM
Not a function but an event.
Put this in @Event of your enemy script:
Code: [Select]
alternative(GetEventType())
case(EV_REQUEST_IS_LAST_SPELL){SetScriptResult(true);}

Thank ya :)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jimmy on April 18, 2015, 09:53:52 PM
I've currently got a strange issue with Danmakufu which honestly don't know how to handle it anymore  :V
It's the following:

I've been working on an own custom shot sheet for a time, everything used to work perfectly, until today when I started Danmakufu, the bullet graphics suddenly didn't show up, the sounds of the bullets firing are still audible though.
The image file doesn't even appear in the 'Texture' section of the log window anymore.
The code is still all the same.

For the bullet definition file (bullet_def.txt):

Code: [Select]
#UserShotData

shot_image = "./img/enm_eff/bullet00.png
delay_rect = (29,958,65,994)

...

which I included into the shot constants file (bullet_lib.txt):

Code: [Select]
local
{
    let current = GetCurrentScriptDirectory();
    let customShot = current ~ "bullet_def.txt";
    LoadEnemyShotData(customShot);
}

...

which is again included in my main boss script:

Code: [Select]
#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["ASM - Aragami01"]
#Text["nonspell"]

#include "script/Tutorial/bullet_lib.txt"
#include "script/Tutorial/boss_effects.txt"
#include "script/Tutorial/effect_MagicCircle.txt"

let bossObj;
...

and then included the defined shot IDs in the CreateShotA1 function. But the graphics don't show up when I execute the script. ???


I really don't know if I did something wrong or it is just a technical error, so if someone here can give some advice would be greatly appreciated. :)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on April 18, 2015, 10:02:21 PM
I've currently got a strange issue with Danmakufu which honestly don't know how to handle it anymore  :V
It's the following:

I've been working on an own custom shot sheet for a time, everything used to work perfectly, until today when I started Danmakufu, the bullet graphics suddenly didn't show up, the sounds of the bullets firing are still audible though.
The image file doesn't even appear in the 'Texture' section of the log window anymore.
The code is still all the same.

For the bullet definition file (bullet_def.txt):

//...

and then included the defined shot IDs in the CreateShotA1 function. But the graphics don't show up when I execute the script. ???

I really don't know if I did something wrong or it is just a technical error, so if someone here can give some advice would be greatly appreciated. :)

First thing's first - is the file path correct? And if so, are you using the shot constants or just the number? (shot constant sheet requires an #include)

If that doesn't work, is the texture file path correct in the shot sheet?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 19, 2015, 12:58:34 AM
Well, if that's a direct paste of your script, the shot_image doesn't have any ending double-quote.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jimmy on April 19, 2015, 11:14:16 AM
Well, if that's a direct paste of your script, the shot_image doesn't have any ending double-quote.
Oh sorry, my bad, there's a closing double quote in my actual script, I didn't directly copy-pasted it here.

First thing's first - is the file path correct? And if so, are you using the shot constants or just the number? (shot constant sheet requires an #include)

If that doesn't work, is the texture file path correct in the shot sheet?
The file paths were the first thing I've checked when the issue first occurred. Everything is like when it still worked normally about two days ago, the bullets showed up as expected. Until the time when this problem began, I didn't make any change on the code and file paths of the shot image, definition and constants files, except for adding some more bullet definitions. After that, the bullet graphics didn't show up, the path of the texture file also doesn't appear in the log window anymore.

I'm using the numbers defined for each bullet, and I did and do still use #include on the shot constants file in the main boss script.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 19, 2015, 12:05:35 PM
Check the bullet definitions you recently added (or just pastebin the whole thing).
If you can't find anything by eye, comment out all the bullet definitions but one and test it by gradually adding in more until it breaks again.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 19, 2015, 03:28:33 PM
Trial & error only solution here. Confirming it here from own experience. A shot sheet will never throw an error at you. The bullets will simply not show up at all and you will wonder what happened.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Senkan on April 26, 2015, 07:19:38 AM
I saw that the engine uses the function rand() and the syntax is pretty similar to C, is the rand used in the engine the same as the stdlib rand() from C?
http://www.tutorialspoint.com/c_standard_library/c_function_rand.htm
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 26, 2015, 11:20:13 AM
There is a copyright notice for the Mersenne twister in the license, so that's almost definitely no. Mersenne is much better than C's rand() anyways, which is a pretty crap RNG.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Senkan on April 26, 2015, 11:28:19 AM
There is a copyright notice for the Mersenne twister in the license, so that's almost definitely no. Mersenne is much better than C's rand() anyways, which is a pretty crap RNG.

Yes I know stdlib's rand() is crap, can you set up the rand() function as you can Mersenne twister in C? (it has many settings).

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 26, 2015, 02:19:50 PM
No, unfortunately. Even the seed is set by the engine on script start, and can't be manually overridden. Is there anything particular you were aiming to do?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Senkan on April 26, 2015, 02:25:43 PM
Hmm I thought it could be interesting to see how different distribution types affect the same bullet spawn patterns.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Eredom on April 26, 2015, 04:11:50 PM
Hey ^.^

Today danmakufu produced an error message I have never seen before:

"@" cannot use in inner function and task.
(イベントを深い階層に記述することはできません)

What does that mean?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on April 26, 2015, 06:14:55 PM
It just mean you can't use a @ (like @Initialize, @Event, @Mainloop, etc) in a task or a function.
I think you forgot a } somewhere and a @something is included in a task/function. Check above the @ in your script ;)

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Gusano Wornis on April 26, 2015, 07:52:53 PM
Hi, I have an small question about something in dnh.

I want in a spell of PG to create familiars that have an square made of lasers, that rotate(like Youkai Kori Kassen's final boss last spellcard for both sides, but those are triangles)
I know its using CreateStraightLaserA, but how about the laser movement(along with their angle so it always will be a square)?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on April 26, 2015, 08:21:09 PM
Hi, I have an small question about something in dnh.

I want in a spell of PG to create familiars that have an square made of lasers, that rotate(like Youkai Kori Kassen's final boss last spellcard for both sides, but those are triangles)
I know its using CreateStraightLaserA, but how about the laser movement(along with their angle so it always will be a square)?

Maybe a task that takes the laser object and its offset from the center (angle, and if the square is not of a constant size, radius) as its parameters.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 27, 2015, 02:23:12 AM
Hi, I have an small question about something in dnh.

I want in a spell of PG to create familiars that have an square made of lasers, that rotate(like Youkai Kori Kassen's final boss last spellcard for both sides, but those are triangles)
I know its using CreateStraightLaserA, but how about the laser movement(along with their angle so it always will be a square)?

Drawing this up:
(http://i.imgur.com/RF4ttDU.png)

In general this is how you'd make an n-gon (triangle, pentagon, heptagon, whatever). You have your center point, and each "corner" point is going to be r distance from the center. The angle a will start at an offset of 0, and each next corner point will increase the angle by 360/n. The position of the point is then (r*cos(a), r*sin(a)), plus the x/y of the center. The length of the sides (the lasers, in this case) will be 2*r*sin(180/n) and should be pointed at the angle a+90+180/n. Spinning the whole n-gon around is just a matter of increasing the angle offset per frame and recalculating the positions and directions. Additionally you can replace the lasers with bullets with just a little extra work.

I can write down some code if you find this too difficult to implement.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on April 27, 2015, 03:25:53 AM
Drawing this up:
(http://i.imgur.com/RF4ttDU.png)

In general this is how you'd make an n-gon (triangle, pentagon, heptagon, whatever). You have your center point, and each "corner" point is going to be r distance from the center. The angle a will start at an offset of 0, and each next corner point will increase the angle by 360/n. The position of the point is then (r*cos(a), r*sin(a)), plus the x/y of the center. The length of the sides (the lasers, in this case) will be 2*r*sin(180/n) and should be pointed at the angle a+90+180/n. Spinning the whole n-gon around is just a matter of increasing the angle offset per frame and recalculating the positions and directions. Additionally you can replace the lasers with bullets with just a little extra work.

I can write down some code if you find this too difficult to implement.

Addendum: what I also did (with bursts, though), was return one laser of the formation and task the others to move to its position every tick. In your case none of the lasers are at the center, but you can use an invisible, hitboxless bullet in the center as a substitute.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: rsy_type1 on April 27, 2015, 04:18:58 AM
The problem may appears to be caused by the ObjText_SetText function packaged in th_dnh.exe.
Is there anyone who has dissambled the .exe and knows how to make it read non-Shift-JIS text?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 27, 2015, 05:11:11 AM
It also reads UTF16-LE with BOM, as written in the official documentation. You should be fine using this, I think.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: rsy_type1 on April 27, 2015, 08:34:37 AM
it works,however it has no use.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on April 27, 2015, 09:17:58 AM
I'm not really sure what you mean by that, sorry.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: rsy_type1 on April 27, 2015, 09:24:44 AM
well, I mean,Simplified Chinese shows ????? in this game text.

our programmer solved this problem by adding an empty line in lib_boss.dnh and lib_enemylibs.dnh
[attach=1]
[attach=2]
line numbers of ?#include? goes wrong when changing to UTF-16.


eg.[attach=3]

[attach=4]

it should read "zakodraw", but it reads"/zakolib/zakolib/..."



edit:it causes more strange bugs, sad
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on April 27, 2015, 09:00:46 PM
well, I mean,Simplified Chinese shows ????? in this game text.

our programmer solved this problem by adding an empty line in lib_boss.dnh and lib_enemylibs.dnh
[attach=1]
[attach=2]
line numbers of ?#include? goes wrong when changing to UTF-16.


eg.[attach=3]

[attach=4]

it should read "zakodraw", but it reads"/zakolib/zakolib/..."



edit:it causes more strange bugs, sad

You have to use an appropriate font.

Also, if you're talking about ObjFileB_ReadString, that function can read non-Shift-JIS text with the correct setting, but it will not output non-Shift-JIS characters. Read here (https://gist.github.com/bluebear94/804553f3e84f361f841b) for a workaround.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on April 29, 2015, 03:09:04 AM
I'm getting a silent crash. No error; only a vague message at the end of the log, and sometimes even that doesn't appear:

Code: [Select]
2015/04/29 02:58:05.581 DirectSound:音声データ解放[C:/Users/Kook/Desktop/TISTUFF/.touhou/th_dnh_ph3_1pre6/th_dnh_ph3/script/CYws/cy5/se/cut00.wav]
2015/04/29 02:58:05.583 DirectSound:音声データ解放[C:/Users/Kook/Desktop/TISTUFF/.touhou/th_dnh_ph3_1pre6/th_dnh_ph3/script/CYws/cy5/se/eco01.wav]
2015/04/29 02:58:05.585 DirectSound:音声データ解放[C:/Users/Kook/Desktop/TISTUFF/.touhou/th_dnh_ph3_1pre6/th_dnh_ph3/script/CYws/cy5/se/freeze07.wav]
2015/04/29 02:58:05.588 DirectSound:音声データ解放[C:/Users/Kook/Desktop/TISTUFF/.touhou/th_dnh_ph3_1pre6/th_dnh_ph3/script/CYws/cy5/se/loop001.wav]
2015/04/29 02:58:05.589 DirectSound:音声データ解放[C:/Users/Kook/Desktop/TISTUFF/.touhou/th_dnh_ph3_1pre6/th_dnh_ph3/script/CYws/cy5/se/on01.wav]
2015/04/29 02:58:05.590 DirectSound:音声データ解放[C:/Users/Kook/Desktop/TISTUFF/.touhou/th_dnh_ph3_1pre6/th_dnh_ph3/script/CYws/cy5/se/paper00.wav]
2015/04/29 02:58:05.592 DirectSound:音声データ解放[C:/Users/Kook/Desktop/TISTUFF/.touhou/th_dnh_ph3_1pre6/th_dnh_ph3/script/CYws/cy5/se/power14.wav]
2015/04/29 02:58:05.594 DirectInput:終了開始
2015/04/29 02:58:05.595 DirectSound:音声データ解放[C:/Users/Kook/Desktop/TISTUFF/.touhou/th_dnh_ph3_1pre6/th_dnh_ph3/script/CYws/cy5/se/sha00.wav]
2015/04/29 02:58:05.596 DirectInput:終了完了
2015/04/29 02:58:05.600 DirectSound:終了開始
2015/04/29 02:58:05.600 DirectSound:音声データ解放[C:/Users/Kook/Desktop/TISTUFF/.touhou/th_dnh_ph3_1pre6/th_dnh_ph3/script/CYws/cy5/system/se/seUseSpellCard.wav]
2015/04/29 02:58:05.712 DirectSound:終了完了
2015/04/29 02:58:05.717 ShaderManager:Shaderを解放しました(Shader Released)[ float4 lightDirection; 
float4 materialAmbient : MATERIALA]
2015/04/29 02:58:05.719 TextureManager:テクスチャを解放しました[__RESERVED_RENDER_TARGET__2]
2015/04/29 02:58:05.720 TextureManager:テクスチャを解放しました[__RESERVED_RENDER_TARGET__1]
2015/04/29 02:58:05.721 TextureManager:テクスチャを解放しました[__RESERVED_RENDER_TARGET__0]
2015/04/29 02:58:05.722 TextureManager:テクスチャを解放しました[__RENDERTARGET_TRANSITION__]
2015/04/29 02:58:05.724 DirectGraphics:終了開始
2015/04/29 02:58:05.725 DirectGraphics:終了完了
2015/04/29 02:58:05.727 アプリケーション終了処理完了

Obligatory code:

Code: [Select]
#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["St1 Sp3"]
#Text["Third spell!"]
#Player["./../../player/player0.dnh"]
#System["./../../system/system.dnh"]
#include "./../../prologue.dnh"
#include "./../../player/shotc.dnh"
let id = 28;
let level = 7;
#include "./../spell_header.dnh"
#include "./render_boss.dnh"

@Event {
alternative (GetEventType)
case (EV_REQUEST_LIFE) {
SetScriptResult(6000);
}
case (EV_REQUEST_TIMER) {
SetScriptResult(72);
}
case (EV_REQUEST_IS_DURABLE_SPELL) {
SetScriptResult(true);
}
case (EV_REQUEST_SPELL_SCORE) {
SetScriptResult(spellBonus);
}
}

@Finalize {}

task TWork {
let height = GetStgFrameHeight;
let width = GetStgFrameWidth;
ObjEnemy_SetDamageRate(objBoss, 0, 0);
let d = getDifficulty;
let speed = 1 + 0.1 * d;
let count = truncate(1 + 0.34 * d);
let period = 240 / (1 + 0.15 * d);
let ways = 16 + 4 * d;
ascent (i in 0 .. 21) {
loop (count) {
let s = createCircleShot(width / 2, height / 2, 15 * i, period / rand(-1, 1), rand(0, 360),
DS_BALL_M_A_RED + truncate(rand(0, 8)), 120, 99999);
ObjShot_SetSpellResist(s, true);
ObjShot_SetAutoDelete(s, false);
}
}
task amulet(s, g) {
ObjMove_SetAngularVelocity(s, m * g);
wait(30);
ObjMove_SetAngularVelocity(s, 0);
}
let m = 1;
while (!isDead) {
let g = randomSign;
let a = GetAngleToPlayer(objBoss - 30 * m * g);
loop (ways) {
let s = CreateShotOA1(objBoss, 2.9, a, DS_BILL_RED, 0);
amulet(s, g);
a += 360 / ways;
}
m += 0.05;
wait(period / 3);
}
ObjEnemy_SetDamageRate(objBoss, 100, 100);
}

And no, it's probably not a divide-by-zero error.

Edit: yep, misplaced parenthesis. I don't know why DNH doesn't show an error such as "Attempted operation on invalid object".
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Eredom on April 29, 2015, 12:07:41 PM
I have a question regarding BGM and sounds.

When I load my Stage, i am loading the BGM with
        let objBGM = ObjSound_Create;
   ObjSound_Load(objBGM,BGMPath);
Everything works great, i can play it later with

   ObjSound_Play(objBGM);

But as soon as I spawn some enemys, the strange thing starts.
After 5-6 Enemy explosion sounds, the BGM "jumps" a few seconds forward and then continues playing normally. It happens again after ~2min (when the stage is already over) that the music "jumps" again

Enemy Explosion sound:
The enemy starts the sound with this Task as soon as it dies:

task PlaySFX(name, Volume){
   let SFXPath = "script/ShatteredSky/snd/SFX";
   let objSound = ObjSound_Create;
   ObjSound_Load(objSound,SFXPath ~ name);
   ObjSound_SetVolumeRate(objSound,Volume);
   ObjSound_Play(objSound);
   loop(180) { yield; }
   Obj_Delete(objSound);
}

The enemy itself has a loop of 200 frames before the script closes.
€dit2: I figured out that not deleting the sound object (SFX) fixes the problem. But I don't want to not-unload them, because I don't want it to affect the framerate.

Can you help me?
Edit: didn't wanted to post it that early ._. Keyboard WHYY??
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on April 29, 2015, 01:32:43 PM
I have a question regarding BGM and sounds.

?dit2: I figured out that not deleting the sound object (SFX) fixes the problem. But I don't want to not-unload them, because I don't want it to affect the framerate.

Can you help me?
Edit: didn't wanted to post it that early ._. Keyboard WHYY??

ObjSound_SetSoundDivision

Use this - if DNH treats a BGM as a Sound Effect, strange things happen. Other way as well.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Eredom on April 29, 2015, 01:46:15 PM
Thank you for your answer :P
I am using SoundDivision, still doesn't work the way I want it to.


task PlayMusic(Volume){
   ObjSound_SetVolumeRate(objBGM,Volume);
   ObjSound_SetSoundDivision(objBGM,SOUND_BGM);
        ObjSound_SetRestartEnable(objBGM, true);
        ObjSound_SetLoopEnable(objBGM, true);
        ObjSound_SetLoopTime(objBGM, 1,204);
   ObjSound_Play(objBGM);
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on April 29, 2015, 01:54:13 PM
Hi!
I try to implement a Continue system. I try to do this in the EndScene script. When the player has no remaining lives, the EndScene start and all work well but the stage script end and I can't return to it at the exact point where it stopped. I search in the function list on the wiki but i found nothing useful that can help me.
I also try to use a pause-like script but I can't pause the entire game while the pause-like script is running. I try to use PauseStageScene function but it don't work on a stage script.

How I can do a clean and simple Continue system? Is there a way to integrate this in my EndScene script? I am a bit out of ideas...
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Eredom on April 29, 2015, 03:11:18 PM
I still have no idea how to solve my problem, I tried EVERYTHING!!!

- Playing BGM with #BGM
- Playing BGM with ObjSound
- Playing BGM with PlayBGM

- Playing SFX with Obj_Sound
- Playing SFX with PlaySE

For Obj_Sound I always used SetSoundDivision.
I made it working, that the SFX of the Enemys exploding doesn't make the BGM jump (by removing the Obj_Delete) , but as soon as the Midboss explodes (with a different explosion sound), the BGM jumps around again .__________.
Using my own shottype makes the music jump as well, using a downloaded shottype is fine. I looked into the script and there's no difference (both scripts load the SFX with LoadSound and play it with PlaySE)

It feels like Danmakufu just doesn't like me!

Edit: Here's a video of the problem. https://youtu.be/0kUzadDvsmI
The Script for loading the stage enemy explosion sound is the same as the one for loading the boss explosion at ~1:00.
But the BossExplosion buggs the music, the stage explosion doesn't. I just don't get it!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 29, 2015, 03:39:38 PM
@ Eredom, post entire script in pastebin.com here please. I think we're having trouble reading your code because you are posting bits of it.

Hi!
I try to implement a Continue system. I try to do this in the EndScene script. When the player has no remaining lives, the EndScene start and all work well but the stage script end and I can't return to it at the exact point where it stopped. I search in the function list on the wiki but i found nothing useful that can help me.
When a player dies or has no more remaining lives, GetStageSceneResult is mutated but also GetPlayerState is mutated. Debug text output those result and see what happens. What you need to do is prevent your stage script from closing. I have no continue mechanics but the pause method pretty much works the same way is my guess. A player who runs out of lives does nothing. Just like boss scripts, you need to define what happens when the game "ends".

Don't call CloseStgScene when your player died. Create a 'hearbeat / listener' inside your stage which tracks for if(GetPlayerState == STATE_END). Inside this loop, force a pause with a special menu or w/e you wish. Treat the menu like a normal pause and decide what happens. You can try to add lives here and then force continue the game to see what happens.

Most important is to mutate GetPlayerState, but I think that automatically happens if you add lives. Because STATE_END means no more lives left.

Debug text your values and see what happens. This is all I can come up with for now.

Quote
I also try to use a pause-like script but I can't pause the entire game while the pause-like script is running
This makes no sense. If you call the pause functions, everything in the stage script will stop running. PauseStageScene(bool); will enforce this.

Edit:
[attach=1]

This is how I have my game composed. The core script kicks off a loop which will track the ESC button and Stage results. The stage script contains the heartbeat/listener for player state.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Eredom on April 29, 2015, 03:54:26 PM
Hey Helepolis :)

Here's the paste http://pastebin.com/BVGU0Mxc

It's not Everything but I think the most important stuff :P
The script was running on pre3, but i tried it with pre6a too and the error stayed the same.
I also uploaded the entire script folder to MediaFire: http://www.mediafire.com/download/dyw2go5ce1ohhe1/ShattSky.zip
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 29, 2015, 04:16:24 PM
Hey Helepolis :)

Here's the paste http://pastebin.com/BVGU0Mxc

It's not Everything but I think the most important stuff :P
The script was running on pre3, but i tried it with pre6a too and the error stayed the same.
I also uploaded the entire script folder to MediaFire: http://www.mediafire.com/download/dyw2go5ce1ohhe1/ShattSky.zip
Try the following.
- Don't create global var for your music object like that (let musicobj = sound_create) etc.
- Change task PlayMusic into function prepareMusic(path) (remove the other parameters)
- Move the global let objBGM into your function.
- Remove the ObjSound_Play function.
- Add as final line in the function return objBGM;

Now create your sound obj by typing  for example: let music01 = prepareMusic(pathname); And then use  ObjSound_Play(music01) to play the music obj or w/e you want to do with it.

Important:
- Music files have to be OGG for lesser problems. Convert them to OGG if they aren't.
- Don't use  ObjSound_SetLoopTime but use ObjSound_SetLoopSampleCount and work with samples to define the loop region. More accurate and works better.

Try that first.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on April 29, 2015, 04:19:08 PM
Helepolis> Thanks. I do that (in fact it's done since a long time but I call another CloseStgScene in an include of the script)
Code: [Select]
task TCloseScript {
while(GetPlayerState() != STATE_END) {yield;}
loop(140){yield;}
if(GetScore >= GetAreaCommonData(CDAN, "HiScore",1000000)) {SetAreaCommonData(CDAN, "HiScore", GetScore);}
SaveCommonDataAreaA1(CDAN);
loop(10){yield;}
if(GetCommonData("CONTINUES",-1) < 0) {
CloseStgScene();
} else {

}
}
When the player is out of lives, the script don't end and continue to run. But I have still no idea how to manually call a PauseScene in this else:
Code: [Select]
if(GetCommonData("CONTINUES",-1) < 0) {
CloseStgScene();
} else {

}
I call a script with    
Code: [Select]
StartScript(LoadScriptInThread(path)); but the stage don't stop running like in a Pause Script.
Oh and I do that out of a Package Script for the moment.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 29, 2015, 04:24:06 PM
Helepolis> Thanks. I do that (in fact it's done since a long time but I call another CloseStgScene in an include of the script)
Code: [Select]
task TCloseScript {
while(GetPlayerState() != STATE_END) {yield;}
loop(140){yield;}
if(GetScore >= GetAreaCommonData(CDAN, "HiScore",1000000)) {SetAreaCommonData(CDAN, "HiScore", GetScore);}
SaveCommonDataAreaA1(CDAN);
loop(10){yield;}
if(GetCommonData("CONTINUES",-1) < 0) {
CloseStgScene();
} else {

}
}
When the player is out of lives, the script don't end and continue to run. But I have still no idea how to manually call a PauseScene in this else:
Code: [Select]
if(GetCommonData("CONTINUES",-1) < 0) {
CloseStgScene();
} else {

}
I call a script with    
Code: [Select]
StartScript(LoadScriptInThread(path)); but the stage don't stop running like in a Pause Script.
Oh and I do that out of a Package Script for the moment.
I don't think you should call anything manual. My core script isn't a package either. It is a normal loaded script. Stage script is basically Stg. I have 2 listeners in my game:  One runs inside the core script (for pause / stageresult) and one runs inside the stage script.

Did you try to move your TCloseScript into a perma running loop outside of the stage script? Don't use it as included part of the Stage script. I think your problem is there as you said yourself. Did you also try to catch a PlayerState outside the stage script?

Edit: Something like this:
Code: [Select]
Inside [ Core script or w/e.txt ]
{
Initialize stage(ry;
StateListener;
}

task StateListener {
// Pause menu
if(pressed ESC) { pausemenu; }

if(playerstate == DED && hascontinues > 0) {
launch special continue pause menu;
}

// To handle when a stage is cleared/player ded/stage disrupted
if(stageSceneState == STAGE_STATE_FINISHED) { }
}

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Eredom on April 29, 2015, 04:39:38 PM
Try the following.
- Don't create global var for your music object like that (let musicobj = sound_create) etc.
- Change task PlayMusic into function prepareMusic(path) (remove the other parameters)
- Move the global let objBGM into your function.
- Remove the ObjSound_Play function.
- Add as final line in the function return objBGM;

Now create your sound obj by typing  for example: let music01 = prepareMusic(pathname); And then use  ObjSound_Play(music01) to play the music obj or w/e you want to do with it.

Important:
- Music files have to be OGG for lesser problems. Convert them to OGG if they aren't.
- Don't use  ObjSound_SetLoopTime but use ObjSound_SetLoopSampleCount and work with samples to define the loop region. More accurate and works better.

Try that first.

Thank you for your answer :)
I changed the task into this function now:

function prepareMusic(path){
   let objBGM = ObjSound_Create;
   ObjSound_Load(objBGM, path);
   ObjSound_SetVolumeRate(objBGM,100);
   ObjSound_SetSoundDivision(objBGM,SOUND_BGM);
        ObjSound_SetRestartEnable(objBGM, true);
        ObjSound_SetLoopEnable(objBGM, true);
   return objBGM;
}

and I am calling it like this now in my stage script (in @Initalize):

   let music01 = prepareMusic(BGMPath);
   ObjSound_Play(music01);

But it didn't  work, the music is still bugging. (skipping a few seconds as soon as the midboss explodes).
I am using .ogg for the stage bgm and .wav for the sfx
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 29, 2015, 04:48:17 PM
/me shrugs

That is strange. And what happens if you disable / comment out the SFX?. Disable all SFX in your game by commenting out (especially boss) and then play through. What happens when the enemies spawn and die?

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Eredom on April 29, 2015, 04:51:50 PM
If I disable
   // PlaySFX("/Enemy/ExplosionBoss(PH).wav", 90);
in my Midboss Script it works fine.

I have to go now for ~3 hours. (Stream) :/
Thank you very much for your help!

Oh and the enemys are loaded with entire scripts like a midboss (just declared as OBJ_ENEMY and not as OBJ_ENEMY_BOSS).

If they die, this gets executed (example is from the midboss):
{
   while(ObjEnemy_GetInfo(F1, INFO_LIFE) > 0)
   {
      yield;
   }

   let ex = ObjMove_GetX(F1);
   let ey = ObjMove_GetY(F1);
   PlaySFX("/Enemy/ExplosionBoss(PH).wav", 90);
   loop(10){
   DieAnimationBoss(ex,ey);
   }
   Obj_Delete(F1);
   Obj_Delete(Mark);
   DeleteShotAll(TYPE_ALL, TYPE_ITEM);
   loop(120){
   DeleteShotAll(TYPE_ALL, TYPE_ITEM);
   yield;
   }

   CloseScript(GetOwnScriptID());
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on April 29, 2015, 05:26:23 PM
Helepolis> Actually my core script is the stage (with the #TouhouDanmakufu[Stage] label a the begening) script in witch I call another script for each stage.
Code: [Select]
if(pressed ESC) { pausemenu; } How I can do that? for the pressed ESC I know but for the pausemenu;... ?
Or it's a script different from the Default Pause Script? And if it's the case, how I can stop the stages and bosses scripts during this Script run?

edit:
I don't see that:
Quote
(https://www.shrinemaiden.org/forum/index.php?action=dlattach;topic=16584.0;attach=39337;image)
I see how you do but it don't work for me.
I make this:

CORE SCRIPT (which is a stage script in fact)
V
STAGES SCRIPTS loaded one after the other like that in a task called at in@Initialize
Code: [Select]
StartScript(stg1ID);
while(!IsCloseScript(stg1ID)) {yield;}
loop(10){yield;}
StartScript(stg2ID);
while(!IsCloseScript(stg2ID)) {yield;}
        etc.
V
BOSSES and other stuff loaded in each stage script with the same way.

I already try to use PauseStageScene(bool) but it don't work and danmakufu return me an error like "function not defined".

edit2:
Oh! I don't know StartStageScript exist. Maybe it can help me... or maybe not :(

edit3: Ok it just work in package script in fact :(
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 29, 2015, 06:51:15 PM
@ Eredom > I have no idea any more to be honest. Something tells me something is wrong with the sound files you use themselves but not quite sure about that.

@ Lefkada, So you got it working now or? I couldn't really get it from your last edit.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on April 29, 2015, 07:05:26 PM
Nope. Nothing work and if I have understand how you do in your game I can't do this for the moment. You use Packages scripts's functions that don't work in stage scripts. But I'll work on a package script to handle all this stuff and I think I can do something like you.
Thanks for your help and sorry for the waste of time :(
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 29, 2015, 07:21:02 PM
lol, I am sure none of this is a waste of my time. Otherwise I wouldn't bother helping now would I ? :V

I am using package functions indeed, and they aren't called from my StageScript. That is why I showed you the diagram. My title script is my actual package script. So I guess because I am running the core script from my Title (package) it allows me to use those. The stage script runs as a separate instance as also shown and is only booted by the StartStageScript function. Personally to me it sounds you got an issue with your core mechanics like the way you handle menus/stages and such which is preventing you from effectively using package functions.

Makes me bit curious how you actually Terminate and Initialize the stages. (TerminateStageScene etc).

Also I've been struggling really hard with the whole menus and stuff as well and for now, I have found this method the most effective (maybe not most efficient).

Once my game is finished and uploaded as online version, feel free to elicit / use code in there as learning sample. (Goes to every dnh person here, I don't mind people using my code to learn/change). But for that you need to have patience with that until I am back from Japan.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Eredom on April 29, 2015, 07:46:00 PM
I tried using a BGM of white names spoiled past and dadada - works ._. but WHYYY? ._____. what's wrong with the file I have here? That's the big question
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on April 29, 2015, 08:04:22 PM
For the moment my project is a giant work in progress mess so I don't have title script or menus yet. Therefore to test my stuff I just use a simple stage script to load/start/do all my stuff. My core script is just a stage script which call other stages scripts in fact. But it's just temporary. I planned to do something like you with just one more step (a package-title script, a core script to do all I need to do, a general stage script and several sub stages scripts).
To initialize the stages I start them with
Code: [Select]
StartScript and to end them I use
Code: [Select]
CloseScript(GetOwnScriptID);.

Thanks for the proposition. I'll download the online version to play it anyway :)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on April 29, 2015, 08:39:05 PM
Oh I see. I intend also to expand my video tutorials now that I got more time on my hands. Sparen is already doing great job with the written ones so the videos will be simply visual aid.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Eredom on May 01, 2015, 06:25:32 PM
Is there a good tutorial to learn how to make custom Item scripts out there?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on May 01, 2015, 07:36:52 PM
Is there a good tutorial to learn how to make custom Item scripts out there?

As of right now, there is no such thing.

I could potentially write one, but Ultima is the person to ask for that, since he actually knows what he's doing when he works with items.

But basically, you will need a sprite sheet, an item shot sheet, perhaps specialized functions to create your items, and an item script that handles the EV_GET_ITEM and EV_DELETE_SHOT_TO_ITEM event cases. The item shot sheet functions as any other shot sheet:
Code: [Select]
#UserItemData

item_image = "./img/Item.png"

ItemData{
id = 1 //StrabiBonus
//type = POINTS
                rect = (0, 0, 19, 19)
render = ALPHA
out = (0, 23, 19, 37)
}

As for the item script, it can get a little confusing. Just make sure to do the following somewhere (preferably in @Initialize of your System file):
Code: [Select]
StartItemScript(GetCurrentScriptDirectory~"./../Item.dnh");
LoadItemData(GetCurrentScriptDirectory~"./../item_shotsheet.dnh");
The first line sets the given item script to your item script, and the second one loads the item shot sheet.

EDIT: I accidentally HTML.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Eredom on May 02, 2015, 10:13:35 AM
One more question regarding Items.
I have a custom item that is dropped by a boss. But if I collect it, nothing happens. The EV_GET_ITEM in my player script doesn't trigger. (I placed a bullet shoot function in it to see IF it triggers and nothing happened).

Or is there a way to have the EV_GET_ITEM called in a non-player script?

I just don't get it.

EV_GET_ITEM is not defined.
(EV_GET_ITEMは未定義の識別子です)
script/ShatteredSky/SYSTEM/CustomItemScript.dnh
CustomItemScript.dnh line(行)=13

?dit: There's one thing I really don't understand. Why can't I call "EV_GET_ITEM" in my item script? It keeps saying EV_GET_ITEM is not defined.

That's everything in the item script atm:
@Initialize{
   LoadItemData("script/ShatteredSky/SYSTEM/lib_Item.dnh");
   SetDefaultBonusItemEnable(false);
}
@MainLoop{
   yield;
}
@Event{
   alternative(GetEventType())
   case(EV_USER+3){
      CreateItem(200, 200);
   }
   case(EV_GET_ITEM){
   }
}

(CreateItem Task down here)

and it keeps saying that EV_GET_ITEM isn't defined ._.
How can I get EV_GET_ITEM called when collecting a custom item?


Nevermind... After 4 hours I found my problem and I feel really dumb now ._.
I copy/pasted stupidly and had the item script always loaded as normal script
And I needed 4 hours to find that out!

Stupid me
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on May 06, 2015, 01:30:50 AM
Is it possible to save a screenshot as a .png, instead of always being stuck with .bmp?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on May 16, 2015, 10:26:15 AM
SOS!   ???  I have a problem with items. I tried different ways. When enemies die by player they spawn items. okay. But when enemy were not killed by player, and flew outside the screen (their lifes = 0) items spawn on x=0, y=0.

task ManageEnemy_Spirit(object,color){
            while(!Obj_IsDeleted(object) && ObjEnemy_GetInfo(object,INFO_LIFE)>0{
            ...
            yield;}
      loop(10){CreateItemA1(...);}}
      Obj_Delete(object);
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on May 16, 2015, 10:34:06 AM
Code: [Select]
if (canDeleteEnemy(enemy)) {Obj_Delete(enemy); return;}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on May 16, 2015, 12:02:33 PM
Is it possible to save a screenshot as a .png, instead of always being stuck with .bmp?
Afaik you can't. 0.12m did also defaults also bmp files.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TresserT on May 18, 2015, 10:49:08 PM
Is it possible to spawn enemy shots in a player script? For some reason CreateShotA1 won't work in a player script... is it designed that way or am I doing something wrong?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on May 18, 2015, 11:20:05 PM
Is it possible to spawn enemy shots in a player script? For some reason CreateShotA1 won't work in a player script... is it designed that way or am I doing something wrong?
It depends what you mean by enemy shots. Can you use CreateShotA1() and so on? Yes, but the bullets won't show up unless the shot data is loaded with LoadPlayerShotData(), as usual. LoadEnemyShotData() won't do anything useful (it will load the shot data somewhere, but is moot). However, any bullets fired like this are still player bullets, and won't hit you. If you use GetShotCount(TARGET_PLAYER), they will count.

Why specifically enemy bullets?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on May 18, 2015, 11:33:32 PM
Why specifically enemy bullets?

You know, some people just do weird things like that. Here, maybe to restrict the player's movement (as in Danmaku Paranoia).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on May 18, 2015, 11:40:52 PM
I'm not really *curious* about the motivation; if they explain what they want to do from the beginning then you can recommend an alternative, rather than looking only at one particular way to do things.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TresserT on May 19, 2015, 12:15:18 AM
I'm not really *curious* about the motivation; if they explain what they want to do from the beginning then you can recommend an alternative, rather than looking only at one particular way to do things.

Just for fun I'm trying to make some Phantasmagoria style players. I've changed the default system to accomodate multiple players, but I'm having trouble with the level 2 and level 3 spells.

If I can't figure out how to do it all in a player script, what I may end up doing is linking every player script to a single script and using a common data system, but that would make it difficult to implement multiple players.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on May 19, 2015, 05:01:02 AM
If you're looking for a way for players to trigger a hit on players, you can do so by creating a dummy enemy and checking for intersections.
Code: [Select]
makeDummyHitbox(objPlayer, 1);

task makeDummyHitbox(parent, radius){
while(!Obj_IsDeleted(parent)){
let e = ObjEnemy_Create(OBJ_ENEMY);
while(!ObjCol_IsIntersected(e)){
ObjEnemy_SetIntersectionCircleToShot(e, ObjMove_GetX(parent), ObjMove_GetY(parent), radius);
yield;
}
doSomething();
Obj_Delete(e);
}
}

You can then use user events or something to handle "player hit" behaviour. However, your own bullets will hit this enemy, so just make sure they don't, I guess.

I realize a more rigorous way of setting this up might be to mark your own shots. You can do this with something like Obj_SetValue(shot, "PlayerSource", GetOwnScriptID()), and then checking only those shots for collision, or something. The downside with this approach is that you'd have to make sure to set the object values to all player shots like this.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TresserT on May 19, 2015, 04:13:11 PM
If you're looking for a way for players to trigger a hit on players, you can do so by creating a dummy enemy and checking for intersections.
Code: [Select]
makeDummyHitbox(objPlayer, 1);

task makeDummyHitbox(parent, radius){
while(!Obj_IsDeleted(parent)){
let e = ObjEnemy_Create(OBJ_ENEMY);
while(!ObjCol_IsIntersected(e)){
ObjEnemy_SetIntersectionCircleToShot(e, ObjMove_GetX(parent), ObjMove_GetY(parent), radius);
yield;
}
doSomething();
Obj_Delete(e);
}
}

You can then use user events or something to handle "player hit" behaviour. However, your own bullets will hit this enemy, so just make sure they don't, I guess.

I realize a more rigorous way of setting this up might be to mark your own shots. You can do this with something like Obj_SetValue(shot, "PlayerSource", GetOwnScriptID()), and then checking only those shots for collision, or something. The downside with this approach is that you'd have to make sure to set the object values to all player shots like this.

Yeah, I considered the 2nd one but I don't like constantly running GetShotIdInCircle or other shot count functions as they can cause some slowdown if there are too many shots on the screen. I didn't think of the first one, though, and that might work. Thanks.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on May 26, 2015, 05:30:04 PM
Could somebody give an advice, how to keep good fps (I mean that, fps rate was round 60/58fps)? Maybe some functions? Should I always beware of something? Loops? Always to delete all objects?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on May 26, 2015, 06:21:08 PM
A good habit is to not abuse sprite objects or anything that renders graphics. Always delete objects when you're done using them. Don't have tasks that linger around doing nothing. A good practice I've found is to turn off bullet collision for bullets that are not in range of the player. It works really well for dense patterns or anytime you use curvy lasers since those have about as many hitboxes as the length you specify.

In general its just being mindful of the stuff you're doing.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Failure McFailFace on May 27, 2015, 03:36:00 AM
Is this a valid MainLoop? The effect I want here is the enemy to shoot a stream of any bullet at a certain speed at the player's hitbox:
Code: [Select]
@MainLoop
{
let playerX = ObjMove_GetX(player)
let playerY = ObjMove_GetY(player)
CreateShotA1(playerX, playerY, 2, [don't know what to do with angle], [bullet graphic here], 5)
}
Am I right to say that the third value (the 2) is in frames/second, and the last value is in frames?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on May 27, 2015, 03:38:22 AM
Is this a valid MainLoop? The effect I want here is the enemy to shoot a stream of any bullet at a certain speed at the player's hitbox:
Code: [Select]
@MainLoop
{
let playerX = ObjMove_GetX(player)
let playerY = ObjMove_GetY(player)
CreateShotA1(playerX, playerY, 2, [don't know what to do with angle], [bullet graphic here], 5)
}
Am I right to say that the third value (the 2) is in frames/second, and the last value is in frames?

CreateShotA1(x [pixels], y [pixels], speed [pixels/frame], angle [degrees], graphic [unitless], delay [frames]);
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on May 27, 2015, 04:40:00 AM
Is this a valid MainLoop? The effect I want here is the enemy to shoot a stream of any bullet at a certain speed at the player's hitbox:
Code: [Select]
@MainLoop
{
let playerX = ObjMove_GetX(player)
let playerY = ObjMove_GetY(player)
CreateShotA1(playerX, playerY, 2, [don't know what to do with angle], [bullet graphic here], 5)
}
Am I right to say that the third value (the 2) is in frames/second, and the last value is in frames?

You have to yield.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on May 27, 2015, 05:15:04 AM
They don't really, unless they try to yield out from somewhere else. Obviously it's good practice to just throw it in there by default, but it isn't strictly necessary.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Gamer251 on May 27, 2015, 06:21:34 AM
I'm currently following Sparen's ph3 tutorial.
I don't really know what I'm doing wrong, but every time I run the script, Danmakufu hangs.
Here's (http://pastebin.com/VXqT33Nj) my script.
I don't really know what to do now...
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on May 27, 2015, 06:37:09 AM
I'm currently following Sparen's ph3 tutorial.
I don't really know what I'm doing wrong, but every time I run the script, Danmakufu hangs.
Here's (http://pastebin.com/VXqT33Nj) my script.
I don't really know what to do now...

Code: [Select]
task MainTask {
        movement;
        while(ObjEnemy_GetInfo(objBoss, INFO_LIFE)>0){
        let angleT = GetAngleToPlayer(objBoss);
        loop(13){
                ascent(i in 0..3){
                        CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2.5-i/3, angleT, DS_FIRE_RED+1, 5);
                }
                angleT+=360/13;
                }
        yield; // <--------
        }
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Gamer251 on May 27, 2015, 07:00:30 AM
Ohhh right, forgot to yield...  :derp:
Thanks for the help~
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on May 31, 2015, 06:04:08 PM
When does GetShotIdInCircleA2 return a non-array?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Shadow on May 31, 2015, 09:53:42 PM
Correct me if I'm wrong, but I would think never. If GetShotIdInCircleA2 detects one bullet, it'll return its ID as a one-element array. If there are no bullets, it'll simply return an empty array.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on May 31, 2015, 10:03:28 PM
Correct me if I'm wrong, but I would think never. If GetShotIdInCircleA2 detects one bullet, it'll return its ID as a one-element array. If there are no bullets, it'll simply return an empty array.

The problem seems to be that empty arrays can't be compared with arrays with elements. Reported the bug to mkm.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Shadow on May 31, 2015, 10:11:45 PM
I don't know what you're trying to do, but returning the length of array and adding a dummy element (like ID_INVALID) if it's empty should be a plausible workaround, I think.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on June 01, 2015, 12:20:03 AM
Empty arrays are basically treated as empty strings in the interpreter.
In the case where you're just writing [] in scripts for comparison, we get the following:
Code: [Select]
[] == [1]    #=> error
[] == ["a"]  #=> error
[] == ['a']  #=> false
[] == ""     #=> true

But in practice empty arrays are in fact empty arrays:
Code: [Select]
erase([1], 0)                      #=> []
erase([1], 0) == erase([2], 0)     #=> true
erase([1], 0) == erase([true], 0)  #=> error
[1, 2, 3][0..0]                    #=> []
[1, 2, 3][0..0] == [4][0..0]       #=> true
[1, 2, 3][0..0] == [true][0..0]    #=> error

Really the only problem is that you're doing something sneaky and avoiding length checks or something. The main "issue" is that all arrays are typed; you can't really have an empty array that could compare against every other empty array. Writing a [] in script just happens to be arbitrarily chosen to be a char array. Additionally, when library functions return an empty array it's usually a char array (in which case you could technically compare it to []).

Note: That being said, the concatenation operator seems to have no problem working with any type of empty array.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Aka Kyuketsuki on June 06, 2015, 07:16:50 PM
Hello ! I would like some help. I have seen this error and I don't know why I still have it on the same script...

"It's script does not allow to alone period
(単独のピリオドはこのスクリプトでは使いません)"

This is the first time I see this error, does anyone know what it means or when it appears ?  :ohdear:

EDIT : Nevermind I fixed it. I wrote a . instead of ;  :blush:
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on June 08, 2015, 08:17:04 AM
Because I'm doing 3D backgrounds:

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on June 08, 2015, 10:23:28 AM
The yaw-pitch-roll system is rotating an object (in this case the camera) about its own y-x-z axes. When the object is upright, the y-axis points up and down, the x-axis points to your left and right, and the z-axis points at and away from you.
The best way I find to visualize the camera's viewing angle is with an analogue to your monitor:

- Spinning your monitor around its base is change in yaw (rotation about y-axis)
- Tilting your monitor's viewing angle up and down is change in pitch (rotation about x-axis)
- Flipping your monitor 90 degrees to vertical orientation is change in roll (rotation about z-axis)

The direction your monitor points here is camera's perspective. Changing the yaw, pitch and roll change where the camera points, from a fixed position.

(http://i.imgur.com/ZI5Ou6g.png)

But the camera doesn't have to be fixed. If you change where the camera is positioned in 3D space but fix the viewing angle, clearly it will point at something else. The camera's focal point is the position in 3D space where the camera bases its own position on.

Imagine a sphere (or a dome) defined around the focal point. The camera lives on that sphere, and you can then think of the focal point as a center point at "ground level".
The radius of the sphere is the distance from the camera to the focal point.
The elevation angle is the angle from the ground, moving into the sky (or negative, moving beneath the ground). Put another way, increasing the elevation angle is like fixing the x-position of the camera and moving it along the sphere, starting by intersecting the z-axis at 0 and eventually intersecting the y-axis at 90.
The azimuth angle is the angle circling around the focal point from a fixed elevation. If the elevation is 0, for example, changing the azimuth is like circling around the focal point at ground level. If the elevation is 90, changing the azimuth keeps you in the same place. In terms of the axes, increasing the azimuth angle is like fixing the y-position of the camera and moving it around the sphere, starting by intersecting the z-axis at 0 and eventually intersecting the x-axis at 90.

(http://i.imgur.com/djnmKea.png)

Important to note is that camera systems will by default always try to aim at the focal point. Whether you increase the elevation or azimuth, the camera will keep aiming at the focal point. Because of this, changing the yaw-pitch-roll is more like changing the camera's offsets in perspective, away from the focal point. So when trying to relate the two images together, note that with zero yaw and pitch, the roll axis will point directly from the camera to the focal point. Additionally, the camera will try to stay upright relative to the focal point, so if you increase the elevation beyond 90 it'll flip itself over.

Lastly, if you want to move the camera around in its absolute position, without messing with the perspective, just change the focal point's position.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on June 08, 2015, 11:03:39 PM
The yaw-pitch-roll system is rotating an object (in this case the camera) about its own y-x-z axes. When the object is upright, the y-axis points up and down, the x-axis points to your left and right, and the z-axis points at and away from you.
The best way I find to visualize the camera's viewing angle is with an analogue to your monitor:

- Spinning your monitor around its base is change in yaw (rotation about y-axis)
- Tilting your monitor's viewing angle up and down is change in pitch (rotation about x-axis)
- Flipping your monitor 90 degrees to vertical orientation is change in roll (rotation about z-axis)

The direction your monitor points here is camera's perspective. Changing the yaw, pitch and roll change where the camera points, from a fixed position.

But the camera doesn't have to be fixed. If you change where the camera is positioned in 3D space but fix the viewing angle, clearly it will point at something else. The camera's focal point is the position in 3D space where the camera bases its own position on.

Imagine a sphere (or a dome) defined around the focal point. The camera lives on that sphere, and you can then think of the focal point as a center point at "ground level".
The radius of the sphere is the distance from the camera to the focal point.
The elevation angle is the angle from the ground, moving into the sky (or negative, moving beneath the ground). Put another way, increasing the elevation angle is like fixing the x-position of the camera and moving it along the sphere, starting by intersecting the z-axis at 0 and eventually intersecting the y-axis at 90.
The azimuth angle is the angle circling around the focal point from a fixed elevation. If the elevation is 0, for example, changing the azimuth is like circling around the focal point at ground level. If the elevation is 90, changing the azimuth keeps you in the same place. In terms of the axes, increasing the azimuth angle is like fixing the y-position of the camera and moving it around the sphere, starting by intersecting the z-axis at 0 and eventually intersecting the x-axis at 90.

Important to note is that camera systems will by default always try to aim at the focal point. Whether you increase the elevation or azimuth, the camera will keep aiming at the focal point. Because of this, changing the yaw-pitch-roll is more like changing the camera's offsets in perspective, away from the focal point. Additionally, the camera will try to stay upright relative to the focal point, so if you increase the elevation beyond 90 it'll flip itself over.

Lastly, if you want to move the camera around in its absolute position, without messing with the perspective, just change the focal point's position.

Thanks for the explanation. Perhaps an illustration would help as well?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on June 09, 2015, 06:49:09 AM
Just remembered I had also posted about this long long long looooong ago. Contains illustration.

https://www.shrinemaiden.org/forum/index.php/topic,10181.msg999303.html#msg999303
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on June 09, 2015, 08:42:17 AM
added drawings
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TresserT on June 12, 2015, 05:04:45 AM
Is it possible to use a video as a texture? For example, could I make a video as the background for a stage? I want to reduce the number of objects in my backgrounds to help reduce slowdown (and thus be able to make more complex backgrounds), so if using a video is even possible would running one cause even more slowdown?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on June 12, 2015, 05:11:41 AM
Is it possible to use a video as a texture? For example, could I make a video as the background for a stage? I want to reduce the number of objects in my backgrounds to help reduce slowdown (and thus be able to make more complex backgrounds), so if using a video is even possible would running one cause even more slowdown?

You'd have to render multiple images in sequence, so running one would cause even more slowdown.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TresserT on June 12, 2015, 05:14:01 AM
You'd have to render multiple images in sequence, so running one would cause even more slowdown.

Yeah, that's what I was afraid of. Thanks though!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on June 12, 2015, 05:56:19 AM
I want to reduce the number of objects in my backgrounds to help reduce slowdown (and thus be able to make more complex backgrounds),
How many sprites (objects) do you have anyway in your stage? Or do you have large number of meshes?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TresserT on June 12, 2015, 06:32:53 AM
How many sprites (objects) do you have anyway in your stage? Or do you have large number of meshes?

I'm literally just learning how to do these, I really only fully understand 2d sprites. For more complicated backgrounds I'm using maybe 20 of them with vertexes. I was hoping to take the lazy man's route if the video thing worked out (I could just do a video of my 20 objects then use that one video as the background) but since that didn't work out I'm going to learn more about 3d sprites and look into metasequoia. I just figured it was worth asking if it could be done before I went and tried to learn a new skill. I'd like to do something like the columns in SA extra.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on June 12, 2015, 06:42:13 AM
20 sprites is in my opinion nothing to make the engine lag / cause FPS issues. Why are you using 2D sprites with Vertexes? Triangle strips and fans and such I guess? Why not just rectangles using the 3D sprite?

Edit: Columns in SA Extra or MoF stg6 are quite easy to make in Meta and being 6-sided they won't have much impact on the engine either.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TresserT on June 12, 2015, 07:01:09 AM
20 sprites is in my opinion nothing to make the engine lag / cause FPS issues. Why are you using 2D sprites with Vertexes? Triangle strips and fans and such I guess? Why not just rectangles using the 3D sprite?

Edit: Columns in SA Extra or MoF stg6 are quite easy to make in Meta and being 6-sided they won't have much impact on the engine either.

I can do some pretty fancy stuff with 2d objects but beyond that I have no idea what I'm doing. I don't want to waste anyone's time, I'm sure I can learn how to use the other stuff (I don't even have Metasequioa), I was just asking if I needed to learn how to do that or if I could stick to my 2d objects.

Anyways, when I say vertexes I'm using around 60 of them for some objects which I thought was a lot (usually those aren't in the background though). If that shouldn't be causing lag... I don't know what could be causing it :/. Maybe my computer is just too old.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on June 12, 2015, 07:58:40 AM
Well, 60 is quite a lot for one object. One column should only be about 16/20 vertices (for 8/10 sides) and maybe another 3 if you have a top part.  And really many of those can be taken out if you never see the backs of the columns.

Prerendering a 3d model into a single sprite and playing with the camera properly is often more than good enough, just to mention. People have a tendency to overcomplicate backgrounds when it often isn't necessary at all. Many really nice backgrounds in Touhou games barely use anything but rectangles. What textures you use for backgrounds are more important than moar vertices, imo.

Either way, I think it would be useful to learn how to manipulate simple 3D backgrounds. If you can fiddle around with flat 2D sprite movement you can fiddle around with 3D sprite movement. The main thing is how to work the camera, and my post on the last page is basically half of a tutorial on its own.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on June 12, 2015, 08:25:00 AM
Pretty sure you're wasting nobody's time. Out of my own curiosity I asked because reading things like: " My 3D stage lags / fps drops " means something is wrong.

@ Drake's post: Was about to say, Tresser is having lots of vertexes and if you're also "moving"  them around, the Engine is logically going to have lots of trouble rendering. ZUN hardly uses any complicated backgrounds if you examine the textures for the levels.

Meta is free to download if you stick to the free version which has all the functionalities you need to make simple models. (if you really want to use meshes)

In my HouEnbu, I have a city level which consists of lots of rectangles creating quite "complex" 3D background and I haven't heard people complaining about FPS drop. I also have several 3D models in the level, but they are usually cube-shaped. I tried avoiding as much as possible multi-sided models. Though originally, I wanted to add cars in the level. I had these free to use models with immense number of polygons. It ran fine on my system but I was afraid it could cause lag for weaker ones thus I omitted them. The actual mqo files are inside the game files and the code is commented out.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on June 15, 2015, 05:38:12 PM
I need help. I would be very pleased to your help.
1) Items used to spawn in (0;0). Is there a way to delete them?
2) What I need to do, that touhou.exe opened a script immediately?
3) How to make glowing effect in 3-D backgrounds? (For example an glowing Lantern).  I can use Metasequoia  :V
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on June 15, 2015, 07:59:59 PM
I need help. I would be very pleased to your help.
1) Items used to spawn in (0;0). Is there a way to delete them?
2) What I need to do, that touhou.exe opened a script immediately?
3) How to make glowing effect in 3-D backgrounds? (For example an glowing Lantern).  I can use Metasequoia  :V
Not quite sure if I understood your questions but:

1) If items are spawning at 0,0 it means the "location" they tried to spawn isn't existent (like an object which got deleted). Unless you mean your items keep on spawning randomly even when the object is dead > check your tasks whether you kill them proper.

2) th_dnh.def file inside your root folder can define a path to your package script package.script.main = <path to package script>. You will need to build your game as a package script. Are you familiar with package scripts?

3) Glowing effect in 3D? I am not quite sure whether you can have active glowing on a model. Not sure if ph3 allows animating textures in meshes either. I would personally use a 3D sprite (like a flare) with BillBoard function active and then manipulate that sprite in size / colour / opaque values to give the same effect. You can place the lantern itself as a mesh in the stage and use the 3D sprite for the "glowing"
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on June 15, 2015, 08:35:05 PM
@Helepolis
Big Thanks (^_−)−☆
Yes, I'm familiar with the Package scripts. I' preparing quite big project.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on June 16, 2015, 02:56:27 AM
Why is the circle in this task rendering with its center northwest to where it should be, at (sx, sy)?

Code: [Select]
task graphics {
let mirror = ObjPrim_Create(OBJ_PRIMITIVE_2D);
ObjPrim_SetPrimitiveType(mirror, PRIMITIVE_LINESTRIP);
let vc = 64;
let vci = vc + 1;
ObjPrim_SetVertexCount(mirror, vci);
ascent (i in 0 .. vci) {
let t = 360 * i / vc;
ObjPrim_SetVertexPosition(mirror, i, cos(t), sin(t), 0);
ObjPrim_SetVertexColor(mirror, i, 0, 255, 255);
ObjPrim_SetVertexAlpha(mirror, i, 200);
}
Obj_SetRenderPriority(mirror, 0.3);
while (!isDead) {
ObjRender_SetPosition(mirror, sx, sy, 0);
ObjRender_SetScaleXYZ(mirror, sr, sr, 1);
yield;
}
Obj_Delete(mirror);
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on June 16, 2015, 03:20:04 AM
You're using a Line Strip vertex layout, and not a Triangle Fan, which seems to be what you want.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on June 16, 2015, 03:23:26 AM
You're using a Line Strip vertex layout, and not a Triangle Fan, which seems to be what you want.

So?

Elaboration: what about line strips that causes this behavior?

(And using triangle strips - not fans - causes even more problems.)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on June 16, 2015, 04:18:02 AM
Oh, sorry. I thought you were trying to render an image in triangles but the triangles weren't appearing properly, since you called it "mirror". I also interpreted that you were using Triangle Strips instead, which would obviously render the whole thing incorrectly.

This would be because you're trying to scale the whole object, rather than position the vertices differently. SetScale seems to be doing something strange, but I can't immediately tell what it is. To fix this, just set the vertex positions to cos(t)*sr instead.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chester-low on June 29, 2015, 01:38:52 PM
Hi everyone !

I need some advices for pogramming my game (again, yes sorry ._.). Okay so I really need to know how making dialogs (like touhou 13,14 and 15 if it's not too horrible to do haha)... I don't really know how Obj_Texts work.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on June 29, 2015, 01:48:43 PM
Saying just "I don't know how things work" is in my opinion not the correct attitude to show.

Do you know how to use objects? (Like obj bullets / sprites?)

If yes > text objects are the same. You just use the Text functions to draw/shape the text as you please.

Did you check the Wiki about text functions?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chester-low on June 29, 2015, 02:08:11 PM
Oh yes of course I know how objects work I just never made dialogs. Yes I checked the wiki but I don't know how to manage the character graphic with the dialog (I just made dialogs with 0.12m version and functions were more precise and easy to use)...that's my main problem.
Do I have to make an object for each sentences?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on June 29, 2015, 02:44:53 PM
Oh yes of course I know how objects work I just never made dialogs. Yes I checked the wiki but I don't know how to manage the character graphic with the dialog (I just made dialogs with 0.12m version and functions were more precise and easy to use)...that's my main problem.
Do I have to make an object for each sentences?

To use a line break in ph3, use [r] within a string. That will allow you to span multiple lines with the same text object, unless you want a different color for each word or something. So no, you do not need a separate object for each sentence.

Use ObjRender_SetX/Y/Z/Position functions to change the position of the text object on the screen.

I suggest giving the dialogue box and all dialogue higher render priorities than everything else (but not above .8) so that they always render above, and you can use ObjText_SetText() to change the text displayed using a text object
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on June 29, 2015, 08:20:51 PM
The dialogue system itself is non existent Chester low in ph3. So you will need to manually built everything yourself from scratch.

- You need to handle the portrait displays yourself (so when someone is talking, you bring forward that picture etc)
- Meaning you will have to handle the text being put on the screen and "deleted"
- You will need to handle the key pressing (Z) to go to the next text / portrait

It is for unknown people quite a challenge if I might say.

I wish I could help with that but it is impossible to just explain in one post. . . (considering a tutorial.)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chester-low on June 29, 2015, 08:54:43 PM
Okay thank you very much everybody ! I managed to make a dialog and it wasn't easy omgg.  I define a valu count = 0 and if count = 1 or 2 etc, display this text... My problem now (I'm so sorry ._.) I don't know how make this kind of thing "if w is pushed, count ++", I tried much things with key functions but it does not work, count stay 0 even if a push the key.
To "solve" the problem i made a loop in mainloop like loop{count++;wait(200);} without key... But it would be better to make a dialog with keys.

(I apologize for my weird english, french dumb here)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on June 29, 2015, 11:16:34 PM
Okay thank you very much everybody ! I managed to make a dialog and it wasn't easy omgg.  I define a valu count = 0 and if count = 1 or 2 etc, display this text... My problem now (I'm so sorry ._.) I don't know how make this kind of thing "if w is pushed, count ++", I tried much things with key functions but it does not work, count stay 0 even if a push the key.
To "solve" the problem i made a loop in mainloop like loop{count++;wait(200);} without key... But it would be better to make a dialog with keys.

(I apologize for my weird english, french dumb here)

All you need for a dialogue is to prepare everything, then edit as needed. As in, create all of your objects, then manipulate them (i.e. change the image path or text contents)

As for keys, use virtual keys. For example, one of my dialogue functions is the following:
Code: [Select]
function EventWaitA3(frames){//Original Implementation (skips through dialogue quickly) Sparen
while(GetVirtualKeyState(VK_OK) == KEY_FREE){yield;}
wait(frames);
PlaySFX(pshot);
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: unofficialsofonisba on July 08, 2015, 06:29:36 AM
Hi,

I'm pretty new to this whole danmakufu thing, and while Sparen and Helepolis' tutorials have been massively helpful, I'm still coming across the occasional sticking point, and one such point has just reared its ugly head: casting animations. I've looked all over the forum, but I can't find a single person talking about how to do them. I've been fiddling with my code for ages, trying to create a casting animation, but I can't quite get it to work properly; the animation keeps freezing on me, and nothing I do seems to fix it. If one of you could either tell me your method for casting animations or point out what I could be doing differently with my code, it would be much appreciated. Here's my code: http://pastebin.com/bRYyZtpG (http://pastebin.com/bRYyZtpG). The section I'm trying to iron out the kinks in is task fireB, but I figured I'd paste the whole code in case I messed something up elsewhere that's interfering. I've already checked and doublechecked that the coordinates for the spritesheet are properly aligned, so I know that's not the problem.

Thanks,
Dwyll
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on July 08, 2015, 06:56:37 AM
Can you elaborate a bit what you mean with: " Casting animation " ?

Is this like Byakuren's animation where a scroll is unfolded and then glowing?

Edit:
Yea ok I see what you're trying to do and that is not how it should be done. You're correct that nowhere such things are discussed. Not because they are "Expert" stuff but not necessary basic either.

What you need to do is integrate that animation block in fireB into your renderBoss task. Currently, your fireB and renderBoss are conflicting. They are both trying to animate the sprite object but that won't be happening. Remember that tasks are threads which are run simultaneous as long as "they are alive". Since both renderBoss and fireB have 1 frame (yield) delay, they will be rapid executed.

Migrate your fireB into renderBoss as follow (don't migrate sound effects or other effects). Remember that it depends on whether you want to overrule all animations when "Casting" or only when your boss is "idle" I'll give you two methods:

First define a global variable let attack = 0;

Method that will only show casting animation if the boss isn't moving around.
Code: [Select]
if(speed == 0){
if(attack == 0) {
// idle anim
}
if(attack == 1) {
// casting animation
}
}
else if(cos(dir) < 0){}
else if(cos(dir) > 0){}

Method that will overrule all animations when the casting animation is active:
Code: [Select]
if(attack == 0) {
if(speed == 0){
// idle anim
}
else if(cos(dir) < 0){}
else if(cos(dir) > 0){}
}
if(attack == 1) {
// casting anim
}

Notice the difference because it is important for the desired result. Next, anywhere you want, you just type attack = 1; to activate the casting animation and then set it back to 0 again after you're done. An example would be:

Code: [Select]
task fireShot {
attack = 1;
// Sound / visual effects or something to show it happening (concentration effect)
wait(15);
attack = 0;
// rest of your attack pattern
}

This isn't "the best" method, but easy to implement and maintain.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: unofficialsofonisba on July 09, 2015, 04:10:10 AM
Helepolis - thank you so much for your help! That's solved the problem beautifully.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chester-low on July 12, 2015, 01:30:29 PM
Hii everyone. Okay I wanna made a trial version of my danmakufu project, I made the 3 first stages with bosses and dialogs etc... Now I want to know if it's possible to configure the application to read directly the main script of my project? I didn't used package script (I don't even know how to use that ...).  My main script is a stage script :

http://pastebin.com/7F8NZxMj
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on July 12, 2015, 01:58:15 PM
Hii everyone. Okay I wanna made a trial version of my danmakufu project, I made the 3 first stages with bosses and dialogs etc... Now I want to know if it's possible to configure the application to read directly the main script of my project? I didn't used package script (I don't even know how to use that ...).  My main script is a stage script :

http://pastebin.com/7F8NZxMj

You must use a package if you want Danmakufu to load your script upon opening.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chester-low on July 12, 2015, 02:05:40 PM
Oh okay...but I didn't find any tutorial about package script unfortunately... So can someone help me about that? 
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on July 12, 2015, 03:22:43 PM
Oh okay...but I didn't find any tutorial about package script unfortunately... So can someone help me about that?

Look at the sample package that comes with Danmakufu and build it yourself. There probably won't be a tutorial for packages for a while due to the knowledge required prior.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Elektron124 on July 12, 2015, 08:36:06 PM
Is there a way to make the same task run using different values at the same time?
For example, I'm making the boss shoot a bullet at the player that stops, shoots out lots of bullets and then disappears.
Now I want it to instead fire bullets at 45 degrees left of where the player is and 45 degrees right of where the player is, but it seems that if i use a while loop it has to execute the entire task first, so this is the best i can do: http://pastebin.com/aqVmC4yj

Is there a way to simplify this code?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on July 13, 2015, 06:31:14 AM
Running one task multiple times at once is half the point. You can just give your task an angle parameter that controls where the initial bullet goes, just as you would a function.

http://pastebin.com/ghHj5y3x

This probably won't work immediately, but this should make it clear what you want to do.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Electroll on July 16, 2015, 08:40:39 AM
Although I downloaded Reimu and Marisa script by Mr Blue and placed them in script>player, Reimu and Maria do not seem to appear on my player select screen.  The only character that appeared was default Rumia. Can anyone help me? I'm using Danmakufu ph3 and the game script I used was Koishi Hell 2 and Satori's Recollection of Scripter's Past
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on July 16, 2015, 08:54:35 AM
If I am not mistaking, those are Danmakufu version 0.12m scripts for the old engine. Old scripts are not compatible with ph3.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on July 18, 2015, 01:06:56 PM
Maybe it's not the good thread for this but, is there somewhere I can find all (or at least almost all) the non offcials CtC Touhou sprites? I found only the kirbio's sprites on MoK.
Or at least if you have a Koishi CtC style sprite ><
Thanks.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on July 18, 2015, 07:32:58 PM
Where can PlaySE be called and actually play a sound?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on July 18, 2015, 10:16:03 PM
Where can PlaySE be called and actually play a sound?

Anywhere, as long as it is given a legitimate path to a legitimate sound file that has been loaded using LoadSound()
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on July 19, 2015, 09:35:06 PM
Anywhere, as long as it is given a legitimate path to a legitimate sound file that has been loaded using LoadSound()

I used LoadSound() in the system script and the sound still doesn't play. I'm pretty sure I'm feeding it legitimate paths.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: PhantomSong on July 20, 2015, 12:45:41 AM
I used LoadSound() in the system script and the sound still doesn't play. I'm pretty sure I'm feeding it legitimate paths.

are you using PlaySound()? Because LoadSound can be called anywhere. As long as the path is not a non-global variable, it should work.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on July 20, 2015, 12:46:36 AM
are you using PlaySound()?

Actually, that function doesn't exist. Did you mean PlaySE()?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: PhantomSong on July 20, 2015, 12:47:52 AM
Actually, that function doesn't exist. Did you mean PlaySE()?
Ah yes, apologies, I actually have touched that since I made my own library for it.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on July 20, 2015, 09:40:25 AM
Did you load the sound in the system script but try to play it from a different script? Because the loaded sound's ID won't be accessible from another script.

Can you get a minimal example working, at least?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on July 21, 2015, 12:02:01 AM
[in response to deleted post]
You can't use textures loaded from one script in another script either, and I'm sure you're fine with that.

LoadSound(), PlaySE(), etc probably use one sound manager, and it's limited to begin with. Manipulating Sound objects is usually preferable, and you probably won't screw up that way, since you already know you won't be able to use the object in other scripts unless they know the Sound object's ID. However, because you'd have to manage the objects and the loaded resources yourself, it's more prone to wasteful usage if you aren't careful, of course.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on July 23, 2015, 05:04:14 PM
 ??? HELP!
I wrote a Package script, and it works normally, ok.
But, when I start playing threw the "th_dnh.def", it starts normally, but can't begin the game, because he cannot find a player.
I have no idea where is the problem.

Edit
~ How works SetCommonData? ~
There is no tutorials for this. I tried to understand how it works from other scripts. But it does no matter. Could somebody tell me please, how it works? (I want to make a Language selection)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on July 25, 2015, 05:21:59 PM
SetCommonData works exactly like in 0.12m.  You set a key and a value for it and you can retrieve that value or manipulate it by setting it again.

Example:
Code: [Select]
SetCommonData("spellcard",5);
let getcards = GetCommonData("spellcard",0);

If you debugtext getcards (or the commondata), you will see that the value should be 5. If for some reason, when GetCommonData is called, cannot retrieve the value, it will return the default value, in this case 0.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on July 25, 2015, 05:31:35 PM
??? HELP!
I wrote a Package script, and it works normally, ok.
But, when I start playing threw the "th_dnh.def", it starts normally, but can't begin the game, because he cannot find a player.
I have no idea where is the problem.
Did you set a stage and player script to run using SetStageMainScript() and SetStagePlayerScript()? When running a stage from the default script select menu you can choose your character, but if you're running a package script, you can't do that. You have to tell the package script which player script you want to use for the stage.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on July 25, 2015, 06:35:00 PM
Did you set a stage and player script to run using SetStageMainScript() and SetStagePlayerScript()? When running a stage from the default script select menu you can choose your character, but if you're running a package script, you can't do that. You have to tell the package script which player script you want to use for the stage.
Yes I set both of them. I'm using Package script.
When I run script from simple touhou.exe (as usual) it runs properly, and finds all players.
But when I'm running threw th_dnh.def, he writes that there is no player found.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on July 25, 2015, 06:42:38 PM
Could you please put your package script and .def file in a pastebin?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on July 25, 2015, 06:49:05 PM
SetCommonData works exactly like in 0.12m.  You set a key and a value for it and you can retrieve that value or manipulate it by setting it again.

Example:
Code: [Select]
SetCommonData("spellcard",5);
let getcards = GetCommonData("spellcard",0);

If you debugtext getcards (or the commondata), you will see that the value should be 5. If for some reason, when GetCommonData is called, cannot retrieve the value, it will return the default value, in this case 0.

Problem is that I don't really understand how SetCommonData works even in 0.12 (._.)
Soooo, I want to make two languages, it means that I should do:
SetCommonData("language","english");
SetCommonData("language","japanese");
And when I need to write a text, I should write:
if(GetCommonData("language","english"){ text="hello" }
?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on July 25, 2015, 06:50:39 PM
Could you please put your package script and .def file in a pastebin?
Ok (^_^'), just a moment...

edit

Could you please put your package script and .def file in a pastebin?
It quite messy, sorry :0
Error in a row 824
pastebin.com/Hn1acQ1W (Package script)
pastebin.com/2g4YzDB4 (Def)


Please use the edit button if you're the last poster, unless there is a very good reason for double posting. Otherwise I see none. -Hele
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on July 25, 2015, 08:10:50 PM
Quote
And when I need to write a text, I should write:
if(GetCommonData("language","english"){ text="hello" }
Nope. You must write:
if(GetCommonData("language","english") == "english") { text="hello" }
"language" is the name of the common data.
the first "english" is the default value of the common data
the second "english" is what you check with the if.

CommonData are used to store numbers, texts, arrays, variables values, etc. and share them between differents scripts/task/fuction (or in the same script.task/function) with GetCommonData and SetCommonData.

The arguments of SetCommonData are the name of the CommonData and the value of the CommonData.
The arguments of GetCommonData are the name of the CommonData and the default value returned if the CommonData has no value.

Is it clearer now?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on July 25, 2015, 10:45:00 PM
Nope. You must write:
if(GetCommonData("language","english") == "english") { text="hello" }
"language" is the name of the common data.
the first "english" is the default value of the common data
the second "english" is what you check with the if.

CommonData are used to store numbers, texts, arrays, variables values, etc. and share them between differents scripts/task/fuction (or in the same script.task/function) with GetCommonData and SetCommonData.

The arguments of SetCommonData are the name of the CommonData and the value of the CommonData.
The arguments of GetCommonData are the name of the CommonData and the default value returned if the CommonData has no value.

Is it clearer now?

Oh, thanks! :D much better.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: WatermelonSprite on July 26, 2015, 12:53:21 AM
Hi,
  I'm pretty new to Danmakufu ph3 and I don't have any experience with coding. I tried making a simple script of just the boss and no bullets but, an error message came up:

Unable to be interpreted (Don't forget ";"s).
(解釈できないものがあります(「;」を忘れていませんか))
C:/Users/hp/Desktop/th_dnh_ph3/script/My scripts/Reference.txt
Reference.txt line(行)=16


      case(EV_REQUEST_LIFE)
   {
      SetScriptResult(100);
   }

}

According to a thread by Blargel, I wrote something really weird, which means I messed up. I don't know what I wrote weird though. I was following Sparen's tutorials and I wrote word to word according to what he said but, I don't know what I wrote weird ;_;


Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on July 26, 2015, 06:34:29 AM
You'll need to post your full script in pastebin.com link for review, but ph3 already is returning you possible mistake:  Unable to be interpreted (Don't forget ";"s).

Sounds like a missing semicolon.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on July 26, 2015, 07:07:34 AM
Ok, that's a slightly nonobvious problem (assuming this is actually the problem). When using SetStagePlayerScript(), the only valid player scripts that you can use are the ones you list in the package script's #Player header. If you don't have a #Player header, it defaults to #Player[ALL], which contains only the player scripts under the script/player folder. Since your player scripts aren't there, it will tell you none are available.
Add a #Player["./Reimu/Reimu.txt"] to the package script and try that.

If that doesn't work, can you:
1) List what player scripts you have in the script/player folder
2) Explain what happens when you launch th_dnh main menu (without a .def) -> select Package -> start your script and keep going until it errors
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on July 26, 2015, 04:10:09 PM
Ok, that's a slightly nonobvious problem (assuming this is actually the problem). When using SetStagePlayerScript(), the only valid player scripts that you can use are the ones you list in the package script's #Player header. If you don't have a #Player header, it defaults to #Player[ALL], which contains only the player scripts under the script/player folder. Since your player scripts aren't there, it will tell you none are available.
Add a #Player["./Reimu/Reimu.txt"] to the package script and try that.

If that doesn't work, can you:
1) List what player scripts you have in the script/player folder
2) Explain what happens when you launch th_dnh main menu (without a .def) -> select Package -> start your script and keep going until it errors

I tried, but it just turned off. Maybe I should send you a hole script  :|
That will be easier.
Always problem is in "couldn't find a player".
Even the path is right.
if (as an alone folder) {
1) Reimu, Marisa by Mr. Blue
2) (with .def only) I turn on game.Menu "Play". Rank Select "Normal", Player Select "Reimu", and when the game should be started, it just turn off.
}
if (in normal ph3 folder, with all projects) {
1) Too many players, but Reimu and Marisa (by Mr. Blue) included.
2) (without def) Plays all normal.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: DLS on July 26, 2015, 09:43:31 PM
Hello. I've been having some problems with Danmakufu now.
I'm almost finishing my script [with 4 difficulties and 2 extra spells in Single], but, for some reason:

1. The script does not automatically end on the 4 difficulties.
2. The extra spells are crashing Danmakufu when Remilia's HP reaches 0.

The scripts are here: http://pastebin.com/jMhSCDbj and http://pastebin.com/0YaTEhFv
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on July 27, 2015, 05:47:30 AM
Hello. I've been having some problems with Danmakufu now.
I'm almost finishing my script [with 4 difficulties and 2 extra spells in Single], but, for some reason:

1. The script does not automatically end on the 4 difficulties.
2. The extra spells are crashing Danmakufu when Remilia's HP reaches 0.

The scripts are here: http://pastebin.com/jMhSCDbj and http://pastebin.com/0YaTEhFv
- You're not closing the the script in your finalize, just summoning an explosion after the boss HP reaches 0.
- Take a closer look at your MainTask. How does the MainTask "walkthrough" the code if you were to say out loud what is all happening there. What do you think what happens when the HP is 0 or lower?

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: DLS on July 27, 2015, 09:06:55 PM
- You're not closing the the script in your finalize, just summoning an explosion after the boss HP reaches 0.
- Take a closer look at your MainTask. How does the MainTask "walkthrough" the code if you were to say out loud what is all happening there. What do you think what happens when the HP is 0 or lower?

- Changed the Finalize to others Singles' Finalize, but the Plural still didn't finish.
- Oh wait...just now I noticed it was the second "while(HP>0)" on MainTask that was crashing Danmakufu. Well, regardless of what you were trying to point out [unless if it was exactly the second "while(HP>0)"], thanks! ^.^
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on July 28, 2015, 05:43:39 AM
- Changed the Finalize to others Singles' Finalize, but the Plural still didn't finish.
I am confused, plural? Do these cards end when you play them separately but not in plural? I think you're missing the point about closing scripts. In both your posted pastebin links, I cannot track the function to close scripts.

Hint: CloseScript(); function
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: DLS on July 28, 2015, 04:56:30 PM
I am confused, plural? Do these cards end when you play them separately but not in plural? I think you're missing the point about closing scripts. In both your posted pastebin links, I cannot track the function to close scripts.

Yes, they do end in Single, but the Plural doesn't end after the last spell finishes. (And I knew that function already :P)
Shall I give you the Plural code?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on July 28, 2015, 07:31:33 PM
Please do so. I mean, we're staring at a problem here where you're only giving us guessing work instead of the full thing.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: DLS on July 28, 2015, 07:48:57 PM
Welp, if so, then I'll post the Explosion Effect text too.

Explosion effects - http://pastebin.com/Ffc5x75k
Plural [Normal] - http://pastebin.com/hJvYL5Yu (Forgot to change title...  :V)
Updated Remilia's last spell - http://pastebin.com/AUzXH1XZ
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on July 28, 2015, 07:57:49 PM
Where are you setting CommonData for EndScript? Because it suddenly pops there in your plural. I hope you realise that if the commondata cannot return a value it will return its default value meaning your plural will technically never end. You're also nowhere mutating this value in your single scripts.

Edit:
Also interesting method on "yielding" your plural, but it isn't really efficient and as I can see only causing trouble. It would be easier and better if you used while(!Obj_IsDeleted(<yoursceneobj>) { yield; } . Since you're using objects, it is more effective to work with them. That way you don't have to use CommonData.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: DLS on July 28, 2015, 08:19:44 PM
Thanks for the tip! The Plural is closing now. ^_^

On an unrelated note, how do I post scripts in BulletForge? [Sorry if it's a dumb question...] :P

EDIT: Nvm, found out how to post scripts there.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: SusiKette on July 31, 2015, 03:27:54 PM
Just started learning ph3 and I'm getting a really weird error here. Danmakufu says that on "while(x<5) { }" I'm using a variable that has not been set yet even though I did that a few lines before it.

Code: [Select]
task fire01 {
let x = 0;
let dir = 0;
loop {
while(x<5) {
loop(36) {
CreateShotA1(obj_boss_x,obj_boss_y,3,dir,15,15);
dir+=360/36;
}
wait(5);
x++;
}
wait(60);
let x = 0;
let dir = 0;
}
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: DLS on July 31, 2015, 03:59:36 PM
I see you declared a variable called 'x' and 'dir' twice (A.K.A. you wrote "let x" and "let dir" twice in the same loop), I guess maybe removing the second "let x" and "let dir" should solve.

Someone might give you a better answer, though.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on July 31, 2015, 04:30:31 PM
I would just like to expand on DLS's answer. He's on the right track, I think. You may be wanting to reset the x and dir variables to 0 -- in that case you should be reassigning values to the two variables rather than making new variables that are conveniently named the same as the ones before.

In that case, just remove the "let" part from the lines after the while loop.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: SusiKette on July 31, 2015, 04:46:19 PM
Yeah, I actually noticed that some time ago. It's weird how Danmakufu pointed out the error. Giving "variable has already been set" error or something and pointing to the line where the duplicate was set would make more sense.

The next issue is that my background is not drawing. What am I missing here?

Code: [Select]
task mainTask {
bossAnim;
backgroundDraw;
movement;
scriptEnd;
}
Code: [Select]
task backgroundDraw {
let bg = ObjPrim_Create(OBJ_SPRITE_2D);
Obj_SetRenderPriorityI(bg,21);
ObjPrim_SetTexture(bg,bg_eerie);
ObjSprite2D_SetSourceRect(bg_eerie,0,0,386,450);
ObjSprite2D_SetDestRect(bg_eerie,0,0,GetStgFrameWidth,GetStgFrameHeight);
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on July 31, 2015, 04:48:38 PM
ObSprite2D_SetSourceRect and DestRect should be pointing to bg, not bg_eerie
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: SusiKette on July 31, 2015, 05:08:36 PM
Works now, thanks.

By the way is there a way to create either of these effects in ph3 without using 32 or so background "slices"?

2D Version (https://www.youtube.com/watch?v=ekgPo0YfGRI)
3D Version (https://www.youtube.com/watch?v=5JuFV2DoB7s)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on July 31, 2015, 05:11:33 PM
I believe fragmenting the background (as you have already done) is already the best way to create that effect.

Making a single object is not good because each fragment would be affected the same way by fog, if you were to use it.

That's just what I think, though.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: DLS on July 31, 2015, 09:20:03 PM
Umm, I'm currently 'animating' my script's enemy, but I have no idea of how to check the angle my enemy face. Can anyone help with this?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on July 31, 2015, 09:26:01 PM
Umm, I'm currently 'animating' my script's enemy, but I have no idea of how to check the angle my enemy face. Can anyone help with this?

ObjMove_GetAngle()

In the future, please read the tutorials and the function list before asking a question
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: SusiKette on August 04, 2015, 04:05:16 PM
I've been having this issue where when the boss dies bullets will be fired from the top left corner for a while. If I remember right this is due to the script not despawning the boss correctly, but I don't remember how to fix it because I can't find the tutorial that mentioned it.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on August 04, 2015, 04:49:45 PM
I've been having this issue where when the boss dies bullets will be fired from the top left corner for a while. If I remember right this is due to the script not despawning the boss correctly, but I don't remember how to fix it because I can't find the tutorial that mentioned it.

Every time you yield, you must check if the boss is dead before spawning more bullets.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on August 04, 2015, 05:55:26 PM
Every time you yield, you must check if the boss is dead before spawning more bullets.
That is imo unnecessary method. There is no reason to keep checking for the boss with each yield. And also very shallow explanation too and not helping in discovering why it is going wrong so the user keeps it in mind for future routines/tasks/methods.

First, many people use this method.
Code: [Select]
task fire {
loop {
CreateShot(ry
yield;
}
}
In 0.12m this would be probably safe to use. In ph3 however you need to make sure things are handled proper.

What Fluffy refers to is this or something similar with "checking boss":
Code: [Select]
task fire {
loop {
CreateShot(ry
yield;
if(Obj_IsDeleted(obj)) { break; }
}
}
Which isn't wrong but when you have many many other yields / routines / areas you need to check it will become a huge mess.

So simply use this:
Code: [Select]
task fire {
while(!Obj_IsDeleted(obj)) {
CreateShot(ry
yield;
}
}
What this does it checks whether the boss is existent (or the obj) before it tries to run the while-loop. The checking is done within the while statement. This gives you a much clean and more defined control on whether to run the loop or not. Keep in mind though you will need to think of possible delays once the loop is executed but for general use, this will do the trick.



Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on August 04, 2015, 05:57:56 PM
@Helepolis - yes, in that case, the while loop checks whether the boss is still alive before shooting again. I was just generalizing.

As for the reason? Getting the X and Y of a deleted object yields returns 0 for each case.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: SusiKette on August 05, 2015, 09:12:28 AM
So simply use this:
Code: [Select]
task fire {
while(!Obj_IsDeleted(obj)) {
CreateShot(ry
yield;
}
}
What this does it checks whether the boss is existent (or the obj) before it tries to run the while-loop. The checking is done within the while statement. This gives you a much clean and more defined control on whether to run the loop or not. Keep in mind though you will need to think of possible delays once the loop is executed but for general use, this will do the trick.

Thanks.

Another questions I've had a long time (all the way back from 0.12m) are these:
-How to loop music? It feels kind of weird to have the music just stop and start over. Especially if the song doesn't loop from the very beginning.
-How to calculate rotation for a bullet to circle around it's spawn point (with speed, radius from center and rotation direction)? For an example if I'd want to fire a bullet at player that explodes into several rings with different distance (radius) from the explosion point and have them circle around the point before disappearing. Of course I could just try values and find it manually, but having the script (or custom function) to calculate it for you would be easier in the long run.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on August 05, 2015, 09:49:51 AM
First question:  You will need to use OGG files for your music then check the Wiki for the sound object functions. You can set the looping, start and end location through the so called "Sample values". Using Audacity or another free program you can check the exact samples and create near-perfect looping.

Second question. Uhm, not quite sure if I am correct with this. Perhaps someone with some more math knowledge can help out but: But increase a bullets distance from its spawnpoint, you need to work with Trig method and increase the radius when you want to make the bullet move away from its spawn location as centre. The story you write sounds like fireworks or something so I think something like this:

CreateShotA1(x+r*cos(dir),y+r*sin(dir),0,dir,<type>,<delay>);

And then store that inside a var so you can modify the dir in a separate task to make the bullets circle around. The greater the value, the faster they will spin around. Radius is randomized as you probably intended.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 05, 2015, 11:26:15 AM
Code: [Select]
angular_velocity = velocity / radius
It's that easy. Well, not quite, since the equation is expressed in radians (because this is pretty much how radians are defined!) For degrees, simple conversion everyone learns in math class:

Code: [Select]
angular_velocity = (velocity / radius) * 180 / pi
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on August 05, 2015, 01:02:08 PM
Additional info:

If you want to do a spiral around the explosion point, use a task that takes not only the shot ID but also the coordinates of the center as parameters. Then use ObjMove_SetPosition.

(or, as Drake said, change the angular velocity - you should know about curvature edit2 and the arc length parameter.)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 05, 2015, 01:53:07 PM
Well, as long as the center stays the same, you can just plug a changing radius into the above equation. Increasing from a radius of near-zero to anything else will still give you a perfect orbit, so you can use a CreateShotA1() with a given speed and position and do everything just by changing the angular velocity with ObjMove_SetAngularVelocity().
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: SusiKette on August 06, 2015, 11:52:32 AM
Okay. I'll try that out once I'm done trying to get a background effect that I made once in 0.12m to work on ph3. Since the effect uses 64 (might be more) or so trigonometric functions per frame, I thought that it would be more optimal to pre-calculate the values and read them from a table. I just don't know how to create such table and how to read from it using another variable as offset.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 06, 2015, 12:10:49 PM
Does it really necessitate using all that? I mean yes, it would probably be better to use a lookup table but 64 sines (or whatever) per frame seems a bit much to begin with.

In any case, you'd just make an array and populate it with values, but considering you haven't described how you intend to use it in the first place I can't really expand on that very much...
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: SusiKette on August 06, 2015, 12:38:14 PM
Does it really necessitate using all that? I mean yes, it would probably be better to use a lookup table but 64 sines (or whatever) per frame seems a bit much to begin with.

In any case, you'd just make an array and populate it with values, but considering you haven't described how you intend to use it in the first place I can't really expand on that very much...

Well, the background is composed out of "slices" that do wavy motion both vertically and horizontally in a sideways 8 pattern. I know that I can use array, but it feels unnecessary to create an array and fill it with values if you could have a table of values saved in the script and read directly from it.

The way I calculate the offset for what value to read the table would be something like this:

Code: [Select]
// slice_offset is incremented every time one slice has been "processed" and reset to 0 after the background drawing has finished

h_offset = (frame_roll + slice_offset) & 31        // frame_roll + slice_offset is AND-ed with %0001 1111 to limit the variable to 32 different values
v_offset = (frame_roll + slice_offset) & 15        // frame_roll + slice_offset is AND-ed with %0000 1111 to limit the variable to 16 different values

// The table with horizontal positions has 32 values and the table with vertical positions has 16 values

EDIT: Here is what it looks like
2D Version (https://www.youtube.com/watch?v=ekgPo0YfGRI)
3D Version (https://www.youtube.com/watch?v=5JuFV2DoB7s)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on August 06, 2015, 01:15:00 PM
Wait, does PH3 still have the same performance problem with arrays as 0.12m?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 06, 2015, 01:51:06 PM
First of all, Danmakufu doesn't have any bitwise operators. Gonna have to work with modulo for that. Also, I did mean just writing the values out in the script itself if you want. Calculating them just once on-run isn't a waste though, and you can change the values if you ever need to without calculating yourself, so I suggest doing that.

Ok, so the figure-8 pattern is somewhat important, because essentially all you're doing is using a single incrementing variable to plug into sin() and cos(), and then multiplying it by some amplitude. I imagine it's like
Code: [Select]
t = (t + 360/32) % 360;
h_pos = cx + sin(t) * 50;
v_pos = y + sin(t*2) * 10;
for one slice or something, where y and t increase for each slice.

This means you can either:
- Have two tables where one maps 32 hardcoded values of sin(t)*50 and the other maps 16 of sin(t*2)*10; or
- Have one table that just maps 32 hardcoded values of sin(t), but use two different indices (i and i*2) and multiply by 50 and 10 afterwards

These would look like
Code: [Select]
h_offsets = [sin(0*360/32)*50, sin(1*360/32)*50, sin(2*360/32)*50, (29 more...)]; // Or use a loop to populate these lol
v_offsets = [sin(0*360/16)*10, sin(1*360/16)*10, sin(2*360/16)*10, (13 more...)];
// ...
h_pos = cx + h_offsets[(frame_roll + slice_offset) % 32];
v_pos = slice_offset*slice_size + v_offsets[(frame_roll + slice_offset) % 16];
or
Code: [Select]
offsets = [sin(0*360/32), sin(1*360/32), sin(2*360/32), (29 more...)];
// ...
h_pos = cx + offsets[(frame_roll + slice_offset) % 32] * 50;
v_pos = slice_offset*slice_size + offsets[(frame_roll + slice_offset) * 2 % 32] * 10;

The first looks a bit nicer, but comes at the disadvantage of not being able to change parameters without rewriting the table every time. The second you can freely change the amplitudes and whatnot.

Wait, does PH3 still have the same performance problem with arrays as 0.12m?
I'm not sure what you mean by performance problems. I haven't used 0.12m in eons so I don't even know if it has array issues (and I don't really care tbh), but could you elaborate? The main issue with ph3 arrays is that you can't just allocate a given size.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on August 06, 2015, 05:03:59 PM
I assumed that the problem with arrays in 0.12m (that array access was slow for large arrays) applied to PH3 too, but I tested (http://pastebin.com/XmEgwX5p) this hypothesis and got similar results for all array sizes tested; i. e. array access is constant-time with respect to both the array size and the index. In fact, when I inline se and ee, the latter benchmark gives twice as long of a time, just because calculating n - 1 takes a significant chunk of the computation time.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 07, 2015, 05:03:44 AM
Yeah, I think I had confronted you (or Sparen?) about this before but didn't get an answer. In any case, I had done fairly rigorous tests for array access a while back.

https://gist.github.com/drakeirving/e999d52c50cc7dc54e2c
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: SusiKette on August 07, 2015, 07:02:04 PM
First of all, Danmakufu doesn't have any bitwise operators. Gonna have to work with modulo for that.

:c
I hope the author of Danmakufu adds them in a future update. They are pretty basic (and useful) operations after all.
I have never heard of modulo and I couldn't find anything about how Danmakufu uses them.

Also, I did mean just writing the values out in the script itself if you want.

What kind of formatting/syntax do I have to use for that?

Another language I work with uses this (and I'm pretty sure Danmakufu doesn't):

Code: [Select]
LookupTable:
 .db 0,1,2,3,4,5,6,7,8,7,6,5,4,3,2,1
.db 0,-1,-2,-3,-4,-5,-6,-7,-8,-7,-6,-5,-4,-3,-2,-1
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on August 07, 2015, 10:16:39 PM
:c
I hope the author of Danmakufu adds them in a future update. They are pretty basic (and useful) operations after all.
I have never heard of modulo and I couldn't find anything about how Danmakufu uses them.

I was kind of disappointed by the lack of bitwise operators as well; I think MKM didn't feel the need for them. Only concern is that ^ is already used for exponentiation, and it's too late to use ** instead unless we want a PH4.

Quote
What kind of formatting/syntax do I have to use for that?

Another language I work with uses this (and I'm pretty sure Danmakufu doesn't):

Code: [Select]
LookupTable:
 .db 0,1,2,3,4,5,6,7,8,7,6,5,4,3,2,1
.db 0,-1,-2,-3,-4,-5,-6,-7,-8,-7,-6,-5,-4,-3,-2,-1

You're an assembly programmer, aren't you?

Code: [Select]
let lookUpTable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -7, -6, -5, -4, -3, -2, -1];
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: SusiKette on August 08, 2015, 06:39:24 AM
Only concern is that ^ is already used for exponentiation

Well, we could still use AND, ORA, EOR, ROR, ROL, ASL, LSR, etc. for bitwise operations. Technically it would be possible to use bitwise operations in Danmakufu by making a function that first converts it to binary (and stores in array?) and after the operation converts back to decimal. I'm just concerned that it will be pretty slow.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 08, 2015, 08:35:31 AM
That would be near-totally pointless, yes.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on August 08, 2015, 12:45:59 PM
That would be near-totally pointless, yes.

Bitwise operators are useful for holding a large number of flags.

And another thing I'd like to see, but will probably break compatibility, is a formal distinction between integers and real numbers.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 08, 2015, 01:53:00 PM
Bitwise operators are useful for holding a large number of flags.
The thing is that any implementation is going to be built using structures and operations that are much more wasteful in space and time, and then those emulated bitwise operations are just going to be used to run some algorithm or make some structure that you already could just have done with the tools already available. It's like an anti-API at that point. You can't say it's space-efficient to use a bit vector to hold flags and perform fast operations on, when your ""bit vector"" isn't space-efficient at all and the operations are just emulated by a bunch of slow stuff anyways.

EDIT: Yeah, sort of figured that's what you meant.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on August 08, 2015, 03:41:05 PM
The thing is that any implementation is going to be built using structures and operations that are much more wasteful in space and time, and then those emulated bitwise operations are just going to be used to run some algorithm or make some structure that you already could just have done with the tools already available. It's like an anti-API at that point. You can't say it's space-efficient to use a bit vector to hold flags and perform fast operations on, when your ""bit vector"" isn't space-efficient at all and the operations are just emulated by a bunch of slow stuff anyways.

Yeah, I meant that implementing them yourself defeats the purpose, so they should be added into the language.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on August 10, 2015, 06:43:41 PM
Please help.
How to make a "HighScore"?
I can't understand  :(
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 11, 2015, 03:33:40 AM
It's Common Data manipulation. Any sort of record-keeping is usually done by changing Common Data and saving it to a file. (Unless you want to write your own format)

- First, records are usually given their own Common Data Area (which is just a kind of organization for Common Data).
- Then, you set the "high score" Common Data in that Area by default to 0.
- Create a task that checks if the current score is greater than the high score. If it is, set the high score Common Data to the current score.
- At the end of the script, save the Common Data Area to a file.
- Once this is working, change it so that at the start of the script, you load the file into Common Data instead of just setting it to 0.

Code: [Select]
task THighScore(){
CreateCommonDataArea("RECORDS"); // Create the Common Data Area

// LoadCommonDataArea returns true if it was loaded properly
let loaded = LoadCommonDataAreaA2("RECORDS", GetCurrentScriptDirectory() ~ "records.dat"); 
if(!loaded){
SetAreaCommonData("RECORDS", "HIGH_SCORE", 0);  // If no high score was loaded, sets the high score to 0
}

loop{
if(GetScore() > GetAreaCommonData("RECORDS", "HIGH_SCORE", 0)){
SetAreaCommonData("RECORDS", "HIGH_SCORE", GetScore());
}
yield;
}
}

// When your script finishes
SaveCommonDataAreaA2("RECORDS", GetCurrentScriptDirectory() ~ "records.dat");
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on August 11, 2015, 03:35:18 AM
No need to set a common data entry ahead of time.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on August 11, 2015, 05:25:06 AM
Nope, but if you're putting many entries into e.g. the "RECORDS" area, it's good practice (imo) to manually set them all up to a default at the beginning rather than making sure every "default" argument in GetAreaCommonData() matches the intended default. Additionally, you can guarantee getting the list of keys with GetCommonDataValueKeyList() gives you a full list of keys, and that saving it to file doesn't miss any keys. These aren't necessarily relevant at all times, but I think it's relevant when you're setting up things like high scores and clear histories.

Again though, yes, the if(!loaded) block isn't strictly necessary.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on August 11, 2015, 06:11:20 AM
Code: [Select]
task THighScore(){
CreateCommonDataArea("RECORDS"); // Create the Common Data Area

// LoadCommonDataArea returns true if it was loaded properly
let loaded = LoadCommonDataAreaA2("RECORDS", GetCurrentScriptDirectory() ~ "records.dat"); 
if(!loaded){
SetAreaCommonData("RECORDS", "HIGH_SCORE", 0);  // If no high score was loaded, sets the high score to 0
}

loop{
if(GetScore() > GetAreaCommonData("RECORDS", "HIGH_SCORE", 0)){
SetAreaCommonData("RECORDS", "HIGH_SCORE", GetScore());
}
yield;
}
}

// When your script finishes
SaveCommonDataAreaA2("RECORDS", GetCurrentScriptDirectory() ~ "records.dat");

All is working, except saving.
And how to make .dat file? I made one, but i think it's not that.

Code: [Select]
task THighScore(){
let pathDigit = GetCurrentScriptDirectory() ~ "img/Default_SystemDigit.png";
let count = 12;

let obj = ObjPrim_Create(OBJ_SPRITE_LIST_2D);
ObjPrim_SetTexture(obj, pathDigit);
ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
Obj_SetRenderPriority(obj, 0.9);
ObjRender_SetY(obj,100);

CreateCommonDataArea("RECORDS");

let loaded = LoadCommonDataAreaA2("RECORDS",GetCurrentScriptDirectory() ~ "./../../../../records.dat");
if(!loaded){
SetAreaCommonData("RECORDS","HIGH_SCORE",0);}
while(true){
if(GetScore() > GetAreaCommonData("RECORDS","HIGH_SCORE",0)){ //Need here exactly a zero?
SetAreaCommonData("RECORDS","HIGH_SCORE",GetScore());}

let score = GetScore();
score = min(score, 999999999999);
let listNum = DigitToArray(score, count);
ObjSpriteList2D_ClearVertexCount(obj);
ascent(iObj in 0 .. count){
let num = listNum[iObj];
ObjRender_SetX(obj, 495 + iObj * 10);
ObjSpriteList2D_SetSourceRect(obj, num * 36, 0, (num + 1) * 36, 32);
ObjSpriteList2D_SetDestRect(obj, 0, 0, 12, 24);
ObjSpriteList2D_AddVertex(obj);}
yield;}}

And a end of STG script:

Code: [Select]
...
SaveCommonDataAreaA2("RECORDS",GetCurrentScriptDirectory() ~ "./../../../../records.dat");
loop(200){yield;}
Obj_Delete(music);
CloseStgScene();
...
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on August 11, 2015, 06:38:07 AM
The dat file is automatically created inside 'data' folder inside your script root when you start saving. But since A2 is being used here it will be saved in target directory.

And I would encourage to use absolute pathing if you're having a directory which is ../../../../ etc. I have no idea what that directory is suppose to be but that is like what, 5th sub folder in root?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on August 11, 2015, 06:59:46 AM
The dat file is automatically created inside 'data' folder inside your script root when you start saving. But since A2 is being used here it will be saved in target directory.

And I would encourage to use absolute pathing if you're having a directory which is ../../../../ etc. I have no idea what that directory is suppose to be but that is like what, 5th sub folder in root?

Yes it's all one folder(directory) :D
So, dat file will appear automatically?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on August 11, 2015, 07:03:02 AM
No I mean, don't use ./../../../ etc as pathname but use for example script/yourproject/folder1/folder2/records.dat  (absolute path).

It should appear automatically when your script calls the save commondata area.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on August 11, 2015, 07:07:25 AM
No I mean, don't use ./../../../ etc as pathname but use for example script/yourproject/folder1/folder2/records.dat  (absolute path).

It should appear automatically when your script calls the save commondata area.
Oh, thanks!
(Sorry for my English :T )
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Failure McFailFace on August 16, 2015, 12:50:35 PM
Does Danmakufu have a built-in "wait" function that waits for X number of frames?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on August 16, 2015, 12:52:54 PM
Does Danmakufu have a built-in "wait" function that waits for X number of frames?

No.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on August 16, 2015, 02:28:44 PM
Does Danmakufu have a built-in "wait" function that waits for X number of frames?

function wait(frames)
{
loop(frames){yield;}
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Failure McFailFace on August 16, 2015, 02:58:00 PM
function wait(frames)
{
loop(frames){yield;}
}
Huh, that's all it takes? neat

Thanks!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lollipop on August 18, 2015, 04:35:21 PM
How do you make one of those dual-boss fights, i.e there are two bosses on the screen and they both share 1 lifebar.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on August 18, 2015, 04:58:26 PM
Ok, this method works for both sharing and or having an independent lifebar.

You should create a simple enemy object using ObjEnemy_Create(OBJ_ENEMY); assign animations, and stuff and use ObjEnemy_Regist(the id of the enemy); to initialize it.

That is pretty much it, the rest is just transferring from one single to another. Now there are two ways of doing this, one way (what I prefer to do) is to pass the second boss's object id to commondata, and then get that id back in the next single and continue controlling the second boss. Method 2 is similar to method 1 but instead of object id, you pass in the position of the second boss.

Method 1
Code: [Select]
You might not have this depending on how you update dnh, as one of the updates replaces this task for an if statement in the MainLoop. The logic however, is mostly the same.

task TEnd()
{
while(main boss has health){yield;}
Obj_Delete(main boss);
//
SetcommonData("Boss 2 object",boss2);
CloseScript(GetOwnScriptID);
}

Next Single....

@Initialize()
{
boss2 = GetCommonData("Boss 2 object",ID_INVALID); // if this does not exist, then the function will substitute with a different value, in this case, I choose ID_INVALID constant or -1.
}

Method2

Code: [Select]
task TEnd()
{
while(main boss has health){yield;}
Obj_Delete(main boss);

//This time we're saving the boss's position to an array and passing that array.
SetcommonData("Boss 2 Position",[ObjMove_GetX(boss2),ObjMove_GetY(boss2)]);
Obj_Delete(boss2);
CloseScript(GetOwnScriptID);
}

Next Single....

@Initialize()
{

// same as before, if the commondata doesn't exist, use a default value.
let position = GetCommonData("Boss 2 Position",[0,0]);
ObjMove_SetPosition(boss2,position[0],position[1]);
}

Any other questions (or something isn't clear), feel free to PM me.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lollipop on August 18, 2015, 06:02:09 PM
Ok, this method works for both sharing and or having an independent lifebar.

You should create a simple enemy object using ObjEnemy_Create(OBJ_ENEMY); assign animations, and stuff and use ObjEnemy_Regist(the id of the enemy); to initialize it.

That is pretty much it, the rest is just transferring from one single to another. Now there are two ways of doing this, one way (what I prefer to do) is to pass the second boss's object id to commondata, and then get that id back in the next single and continue controlling the second boss. Method 2 is similar to method 1 but instead of object id, you pass in the position of the second boss.

Method 1
Code: [Select]
You might not have this depending on how you update dnh, as one of the updates replaces this task for an if statement in the MainLoop. The logic however, is mostly the same.

task TEnd()
{
while(main boss has health){yield;}
Obj_Delete(main boss);
//
SetcommonData("Boss 2 object",boss2);
CloseScript(GetOwnScriptID);
}

Next Single....

@Initialize()
{
boss2 = GetCommonData("Boss 2 object",ID_INVALID); // if this does not exist, then the function will substitute with a different value, in this case, I choose ID_INVALID constant or -1.
}

Method2

Code: [Select]
task TEnd()
{
while(main boss has health){yield;}
Obj_Delete(main boss);

//This time we're saving the boss's position to an array and passing that array.
SetcommonData("Boss 2 Position",[ObjMove_GetX(boss2),ObjMove_GetY(boss2)]);
Obj_Delete(boss2);
CloseScript(GetOwnScriptID);
}

Next Single....

@Initialize()
{

// same as before, if the commondata doesn't exist, use a default value.
let position = GetCommonData("Boss 2 Position",[0,0]);
ObjMove_SetPosition(boss2,position[0],position[1]);
}

Any other questions (or something isn't clear), feel free to PM me.

Thanks!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: GuardianTempest on September 03, 2015, 03:48:04 AM
Pardon the bump, but I'm trying to follow Sparen's tutorial and I'm stuck on recreating Eternal Meek.

Code: [Select]
//Variables, constants and inclusions
let objBoss;
let objScene = GetEnemyBossSceneObjectID();
let objPlayer =GetPlayerObjectID();

#include"script/default_system/Default_ShotConst.txt"
#include"script/default_system/Default_Effect.txt"

@Event{
alternative(GetEventType())
case(EV_REQUEST_LIFE){
SetScriptResult(500);
        }
case(EV_REQUEST_TIMER){
//SetScriptResult(60);
SetScriptResult(13);
}
case(EV_REQUEST_SPELL_SCORE){
SetScriptResult(1000000);
}
}

@Initialize{
objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
ObjEnemy_Regist(objBoss);
//ObjMove_SetDestAtFrame(objBoss, GetCenterX, 60, 60);

ObjEnemyBossScene_StartSpell(objScene);

TDrawLoop;
TFinalize;
MainTask;
}

@MainLoop{
        ObjEnemy_SetIntersectionCircleToShot(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 32);
        ObjEnemy_SetIntersectionCircleToPlayer(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 24);
        yield;
}

// Tasks ###############
task TDrawLoop {
let imgExRumia = GetCurrentScriptDirectory ~ "ExRumia.png";
ObjPrim_SetTexture(objBoss, imgExRumia);
ObjSprite2D_SetSourceRect(objBoss, 64, 1, 127, 64);
ObjSprite2D_SetDestCenter(objBoss);
}

task MainTask {
    ObjMove_SetDestAtFrame(objBoss, GetCenterX, 60, 60)
    wait(120);
    while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){
CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), rand(3,6), rand(0,360), DS_BALL_S_BLUE, 20);
yield;
    }
}
}

task TFinalize {
    while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){yield;}
if(ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT)
+ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) == 0){
AddScore(ObjEnemyBossScene_GetInfo(objScene,INFO_SPELL_SCORE));
}
let ex = ObjMove_GetX(objBoss);
let ey = ObjMove_GetY(objBoss);
TExplosionA(ex, ey, 10, 0.6);
Obj_Delete(objBoss);
DeleteShotAll(TYPE_ALL,TYPE_ITEM);
SetAutoDeleteObject(true);
CloseScript(GetOwnScriptID());
return;
}

// Functions ###############

function GetCenterX{
     return GetStgFrameWidth/2;
}

function GetCenterY{
     return GetStgFrameHeight/2;
}

function wait(n){
     loop(n){yield;}
}

function rand_int(min, max){
return round(rand(min, max));
}

The weird thing is that, aside from removing the bullet scripts, there's little difference with my earlier sandbox script (http://pastebin.com/7CaH2pqx).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on September 03, 2015, 03:58:58 AM
In MainTask(), you are missing a semicolon and you have an extra closing bracket.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: GuardianTempest on September 03, 2015, 04:22:50 AM
Thanks for the quick response, I had a weird feeling I just had programming errors.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: GuardianTempest on September 04, 2015, 01:37:01 PM
Pardon the double posting, but is there a way to make my delay laser follow the player?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on September 04, 2015, 01:45:11 PM
Pardon the double posting, but is there a way to make my delay laser follow the player?
You can edit your post.

Just use the movement functions plus ObjStLaser_SetAngle.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: finn183 on September 05, 2015, 04:26:48 AM
Help! I've tried to run Danmakufu using AppLocale and somehow it still crashes! Any idea why?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: DLS on September 05, 2015, 06:55:33 PM
Umm...sir...if you didn't notice, in this subforum, there's a sticky topic called "Q&A for Danmakufu 0.12m"  and "Q&A for Danmakufu ph3" or something like that.

Sorry if I was a bit harsh, but you just bumped an old thread [a bump of almost 3 years, even!] just for asking a completely irrevelant question. :T



No harshness imo but only the truth there, I merged the posts -Hele
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Gusano Wornis on September 07, 2015, 10:46:32 PM
This question can be a bit difficult to be answered because of the complexity of it.

I am working on nanbei Project, it does have a multi-language system (between english and spanish).
the system Works fine, but to make it selectable I need to create a options menu in the package script. the question is. how to do a basic options screen?.

I do know i need CommonDataArea and things, but I need help to make the selectable (yes/no) options and the volume (%) options too. any help?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on September 07, 2015, 11:07:09 PM
This question can be a bit difficult to be answered because of the complexity of it.

I am working on nanbei Project, it does have a multi-language system (between english and spanish).
the system Works fine, but to make it selectable I need to create a options menu in the package script. the question is. how to do a basic options screen?.

I do know i need CommonDataArea and things, but I need help to make the selectable (yes/no) options and the volume (%) options too. any help?

Key reading and text objects.


You know, at least have some courtesy and be of good cheer to explain more elaborately instead of a one-liner with vague directions. -Helepolis
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on September 08, 2015, 12:59:32 AM
This question can be a bit difficult to be answered because of the complexity of it.

I am working on nanbei Project, it does have a multi-language system (between english and spanish).
the system Works fine, but to make it selectable I need to create a options menu in the package script. the question is. how to do a basic options screen?.

I do know i need CommonDataArea and things, but I need help to make the selectable (yes/no) options and the volume (%) options too. any help?
Key reading and text objects.

You will store the results of the Yes/No as well as the Volume, as Fluffy stated, using keys set using SetAreaCommonData.
For example:
Code: [Select]
    }else if(selectIndex == INDEX_MUSIC) {
selectIndex2++;
if(selectIndex2 > 20) { selectIndex2 = 20; }//Music doesn't wrap to 0
SetAreaCommonData("Config","BGMVolume", 5*selectIndex2);//Index goes up to 20
NotifyEventAll(EV_USER_PACKAGE+82, 0);//Alter music bgm volume
PlaySFX(select);

For text, use text object similarly to how they work in the default package. Just make sure that you have a way of telling the player which option they are currently on.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on September 14, 2015, 08:16:34 PM
I'm having an extremely strange issue (https://github.com/nagakawa/cy06/issues/2) with declared players in a script called by the package that declared these players. However I order the player files in the #Player declaration or which ones I include, ./../player/player0.dnh is the only one that is recognized.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: FlareDragon on September 14, 2015, 09:12:00 PM
While making reflective bullets (which make for a fun maths problem >w<), I'm coming up with a weird issue with getting the frame's positions: GetStgFrameLeft() gives me a position a fair distance right from the left of frame, with GetStgFrameWidth() giving me a distance further right of it as well (inside the frame). The frame itself seems to work fine since the player's hitbox hits the exact edges of the frame, but the reflected bullets reflect some distance from where they should (makes for an annoying safe area). Funnily enough, GetStgFrameTop() and GetStgFrameHeight() seem to work fine. Anyone know what's wrong?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on September 14, 2015, 09:30:06 PM
@ FlareDragon, that is something odd indeed. I do know that you can edit the frame width/height of your game + also decide when the player will "hit" the edge of the frame. But I've never really paid attention to this. Let me try this out tomorrow and see what the results are. I have a spellcard with reflecting lasers/bullets.

@ Fluffy, the shown code / explanation is bit insufficient to really see what you're doing and how you're trying to load the player. You need to post more core, or preferred the exact code where you try to load the player and related scripts. Keep in mind, the order should be in core:
- InitializeStageScene
- SetStagePlayerScript
- SetStageIndex
- SetStageMainScript
- StartStageScene

If your player is not found. Then it is really not found and I don't remember running into such things.

Also why the #Player you speak of?  Nowhere in my own 'Hou Enbu' I use the #Player header in my scripts. Not even in my spell cards.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: FlareDragon on September 14, 2015, 09:45:09 PM
Okay. I've discovered something about it: The GetStgFrameWidth() returns a 40, like it's supposed to (According to how it's set up), but it looks like the distance the shot reflects is 40 from the frame border instead of the window, which puts it at 80 from the window - double what it's supposed to be. Similarly, reflection off the top is actually offset the same way: double the distance from the top of the window than it should be.
I have a feeling that means I'm not supposed to be using GetStgFrame(Left/Top/Width/Height) when determining where objects inside (as opposed to on top of) are suppose to be (such as where a shot goes to).
However, it doesn't explain why GetStgFrameWidth gives me 480 when it's set to 520 (aside from the fact that the dissonance is exactly the width of the window's left to the frame's left)

EDIT: Well, that's pretty inconsistent. I'm supposed to be using 0 as opposed to GetStgFrame(Left/Top) for objects in the frame, but using GetStgFrame(Width/Height) gives me the right relative number (the intersection was because of the length of the shot VS the actual position of the shot). Something new everyday :/
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on September 14, 2015, 09:54:12 PM
The script in question is play.dnh (https://github.com/nagakawa/cy06/blob/master/package/play.dnh), and I'm following your directions as far as I know. All of the relevant player scripts exist; otherwise, I'd be getting another error. The unusual thing is that only player0.dnh loads properly; trying to use any other file as the player script crashes.

(And #Player is used to tell the package script which player scripts are valid to use. You probably (should have) used in in the package header.)

Edit: fixed. It turns out that the other scripts were encoded in UTF-8, not Shift-JIS. Derp, I wish Danmakufu would somehow allow UTF-8 encoded files.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on September 15, 2015, 12:42:29 AM
Okay. I've discovered something about it: The GetStgFrameWidth() returns a 40, like it's supposed to (According to how it's set up), but it looks like the distance the shot reflects is 40 from the frame border instead of the window, which puts it at 80 from the window - double what it's supposed to be. Similarly, reflection off the top is actually offset the same way: double the distance from the top of the window than it should be.
I have a feeling that means I'm not supposed to be using GetStgFrame(Left/Top/Width/Height) when determining where objects inside (as opposed to on top of) are suppose to be (such as where a shot goes to).
However, it doesn't explain why GetStgFrameWidth gives me 480 when it's set to 520 (aside from the fact that the dissonance is exactly the width of the window's left to the frame's left)

EDIT: Well, that's pretty inconsistent. I'm supposed to be using 0 as opposed to GetStgFrame(Left/Top) for objects in the frame, but using GetStgFrame(Width/Height) gives me the right relative number (the intersection was because of the length of the shot VS the actual position of the shot). Something new everyday :/
The drawing origin depends on the render priority of the object being drawn. If its priority is between 20 and 80 inclusive (more specifically GetStgFrameRenderPriorityMinI() and GetStgFrameRenderPriorityMaxI()) then the origin is at the corner of the play area (STG frame); if it's outside these values the origin is the corner of the window. Using GetStgFrameLeft/Top is mostly for positioning things relative to the frame itself, like the score display. GetStgFrameWidth/Height gets the dimensions of the play area, so you can use it in both contexts.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: FlareDragon on September 15, 2015, 02:28:51 AM
The drawing origin depends on the render priority of the object being drawn. If its priority is between 20 and 80 inclusive (more specifically GetStgFrameRenderPriorityMinI() and GetStgFrameRenderPriorityMaxI()) then the origin is at the corner of the play area (STG frame); if it's outside these values the origin is the corner of the window. Using GetStgFrameLeft/Top is mostly for positioning things relative to the frame itself, like the score display. GetStgFrameWidth/Height gets the dimensions of the play area, so you can use it in both contexts.
Ahh. This makes perfect sense. I'll certainly have to remember this in the future. Thanks, Drake ^w^
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on September 16, 2015, 04:27:42 PM
Maybe this questions is not for a ph3? but
Why most of all scripts slow down fps?
Problem with Ph3 Engine?
Or problem with my PC?
It's really annoying?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on September 16, 2015, 04:38:25 PM
Maybe this questions is not for a ph3? but
Why most of all scripts slow down fps?
Problem with Ph3 Engine?
Or problem with my PC?
It's really annoying?

It is most likely a poor graphics card and/or unoptimized code.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on September 16, 2015, 04:53:52 PM
It is most likely a poor graphics card and/or unoptimized code.

Oh  :wat:
Earlier all scripts worked properly. Anyway,
What should I do now?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: ExPorygon on September 16, 2015, 06:55:34 PM
It is most likely a poor graphics card and/or unoptimized code.
It was my understanding that the graphics card barely matters for Danmakufu. It's mostly the CPU strength.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: DLS on September 16, 2015, 07:08:35 PM
Maybe this questions is not for a ph3? but
Why most of all scripts slow down fps?
Problem with Ph3 Engine?
Or problem with my PC?
It's really annoying?

There's 3 possibilities:
1. There's either too many curvy lasers;
2. Bomb-resistant bullets might lag upon using bombs onto them; (Take Lefkada's Youmu's bomb as an example. I experienced heavy lag upon using the bomb on a completely bomb-resistant spell)
3. Too many bullets onscreen, like 2000 bullets or so. That is either an issue with your PC or an issue with Danmakufu.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on September 16, 2015, 07:34:49 PM
It was my understanding that the graphics card barely matters for Danmakufu. It's mostly the CPU strength.

Earlier all scripts worked properly. But now most of them lag 30~50fps. Does it mean that CPU strength decreased? If yes, if there any solution to increase CPU strength?

There's 3 possibilities:
1. There's either too many curvy lasers;
2. Bomb-resistant bullets might lag upon using bombs onto them; (Take Lefkada's Youmu's bomb as an example. I experienced heavy lag upon using the bomb on a completely bomb-resistant spell)
3. Too many bullets onscreen, like 2000 bullets or so. That is either an issue with your PC or an issue with Danmakufu.

Thanks for advices! Taking them for a note. But as I said above, all scripts worked properly…

Edit: Wow, I increased CPU power, and it made Danmakufu more working. But there's still some minuses, like there's something else~
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on September 16, 2015, 10:29:16 PM
Maybe this questions is not for a ph3? but
Why most of all scripts slow down fps?
Problem with Ph3 Engine?
Or problem with my PC?
It's really annoying?

Danmakufu isn't exactly the most performance pretty engine. In fact, it is pretty poor with performance ratings. Lag comes from an excessive amount of something. In dnh this can be having too many bullets (1000+), too many sprites, tasks, etc... Also keep in mind that dnh is not a multi-threaded engine, and collision, drawing logic, etc... is handled on a single thread.

With that being said, your computer's overall performance does play a part in this. Can it do all of the calculations needed within 16 milliseconds? The answer is reflected by what the average fps says. Mkm, traded performance for flexibility but didn't add anything to help the performance side. The best thing you can do is use your own engine or an alternative, whatever that may be.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on September 17, 2015, 12:53:45 AM
If scripts were running at 60 before and now they're running slower, check to see if your computer's power options are set to use a power plan that cuts performance to save power. I remember I had a laptop with a "balanced" power plan set and it crippled performance badly with DNH.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on September 17, 2015, 04:17:33 AM
Is there any reason (performance or otherwise) not to use a mesh for the entire background?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on September 17, 2015, 08:37:07 PM
Danmakufu isn't exactly the most performance pretty engine. In fact, it is pretty poor with performance ratings. Lag comes from an excessive amount of something. In dnh this can be having too many bullets (1000+), too many sprites, tasks, etc... Also keep in mind that dnh is not a multi-threaded engine, and collision, drawing logic, etc... is handled on a single thread.

With that being said, your computer's overall performance does play a part in this. Can it do all of the calculations needed within 16 milliseconds? The answer is reflected by what the average fps says. Mkm, traded performance for flexibility but didn't add anything to help the performance side. The best thing you can do is use your own engine or an alternative, whatever that may be.

Thank a lot for more detail description. I didn't know most of information that you said. But now, when I know, I'll try to solve problem.

If scripts were running at 60 before and now they're running slower, check to see if your computer's power options are set to use a power plan that cuts performance to save power. I remember I had a laptop with a "balanced" power plan set and it crippled performance badly with DNH.

Yes I did it. But it didn't remove  fps lag

Edit: I fixed it. So funny, I had a dream, where ZUN personally explains me how I have to fixed it x)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Aka Kyuketsuki on September 26, 2015, 02:50:58 PM
Hi ! I want to ask something : If we have 5 tasks (Attack1, Attack2, Attack3, Attack4, Attack5), how do I call one of these tasks randomly ?
As if the script can begin either with Attack2 or even Attack5, but with random ?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on September 26, 2015, 03:09:25 PM
Hi ! I want to ask something : If we have 5 tasks (Attack1, Attack2, Attack3, Attack4, Attack5), how do I call one of these tasks randomly ?
As if the script can begin either with Attack2 or even Attack5, but with random ?
Note sure if best method but:

I tested whether I can add tasks inside an array but Danmakufu doesn't likes that so that is out of the question I think.

Possible solution: Somewhere when your script kicks off or when you want to make the randomized attack --> Create a loop and use the function rand (don't forget to round it to get a int) to randomize a variable (integer) and then perform statements. Example: If randAttack == 0  >> Attack1  if randAttack == 1 >> etc. Decide the delay (yield / wait) in which the rand function needs to pick a new number in the loop.

Perhaps not the most award winning method but works.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Aka Kyuketsuki on September 26, 2015, 04:06:57 PM
Note sure if best method but:

I tested whether I can add tasks inside an array but Danmakufu doesn't likes that so that is out of the question I think.

Possible solution: Somewhere when your script kicks off or when you want to make the randomized attack --> Create a loop and use the function rand (don't forget to round it to get a int) to randomize a variable (integer) and then perform statements. Example: If randAttack == 0  >> Attack1  if randAttack == 1 >> etc. Decide the delay (yield / wait) in which the rand function needs to pick a new number in the loop.

Perhaps not the most award winning method but works.

Ah yes, thank you, it works very well ! :D
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on September 26, 2015, 05:19:44 PM
Is there any reason (performance or otherwise) not to use a mesh for the entire background?

Quoting myself in case people didn't see my question.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on September 26, 2015, 06:17:12 PM
Quoting myself in case people didn't see my question.
Not sure what you're trying to ask here. Mesh for the entire background? Any specific reason why you would prefer one single mesh for entire background? I remember someone had inserted a detailed Pagoda mesh as test and there was no FPS drop or something. Though I cannot remember the youtube video.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on September 26, 2015, 11:42:05 PM
Not sure what you're trying to ask here. Mesh for the entire background? Any specific reason why you would prefer one single mesh for entire background? I remember someone had inserted a detailed Pagoda mesh as test and there was no FPS drop or something. Though I cannot remember the youtube video.

One of the collaborators wanted to do the background in Blender then export it to an .mqo file.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on September 27, 2015, 08:20:54 AM
As long as you're not creating overly complex meshes with immense number of polygons and not trying to perform complicated movement in Danmakufu I don't see an issue.

My Touhou Hou Enbu actually had free to use 3D car models (YOU WOULDN'T DOWNLOAD A CAR?). These cars decorated the 3rd stage by moving around. There is a significant impact for low / medium end computers (fps drop).  And those cars had aprox 3000 triangles or something. The actual mqo files are in the official release and the code is existent but disabled.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: GuardianTempest on September 27, 2015, 02:21:40 PM
I have a complex request, I'm currently hustling a fangame demo for use in my thesis. Are there any tutorials for:
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on September 27, 2015, 02:28:10 PM
I have a complex request, I'm currently hustling a fangame demo for use in my thesis. Are there any tutorials for:
  • Character dialogue
  • Spell Card declarations (namely the visual and sound effects)
  • Automatically running a script on startup that bypasses Danmakufu's default menu, much like Helepolis' game.

Dialogue: No. You will need to build your own system of render and text objects, or you will need to use someone else's

Spell Card Declarations: You'll have to be a bit more specific here. If you are referring to cut ins, all you are basically doing is rendering text and images on-screen with a sound effect or two. There are a number of existing cut in libraries (GTbot and Helepolis's come to mind), but you can make one yourself using standard text objects and render objects.

Bypass the start menu: Include the path to your package in th_dnh.def, like so:
Code: [Select]
//--------------------------------------------------------------
package.script.main = script/Digital Earth Conquest/DEC_Package_Main.dnh


//--------------------------------------------------------------

window.title = DIGITAL EARTH: CONQUEST
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: GuardianTempest on September 28, 2015, 05:29:56 AM
I see, thank you for the response.

EDIT: I knew I forgot something! Is there a tutorial on character select screens?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on September 29, 2015, 05:50:48 AM
I see, thank you for the response.

EDIT: I knew I forgot something! Is there a tutorial on character select screens?
Unfortunately there is no such tutorial  :ohdear:. You'll have to design it all yourself, including difficulty select screen, stage select screens or any form of Menu system.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: GuardianTempest on September 29, 2015, 01:19:41 PM
One long trip at the IRC later...

Situation: A single script causes program crash
Plan: Identify What in these single scripts are messing up their inclusion in plural scripts.
Relevant Code: Plural Script File (http://pastebin.com/PGLMNDrN), Single Script File (http://pastebin.com/hgx9ZbDL) (with minor revisions)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on September 29, 2015, 01:50:06 PM
One long trip at the IRC later...

Situation: A single script causes program crash
Plan: Identify What in these single scripts are messing up their inclusion in plural scripts.
Relevant Code: Plural Script File (http://pastebin.com/PGLMNDrN), Single Script File (http://pastebin.com/hgx9ZbDL) (with minor revisions)

You must add to the 0th lifebar instead of the 2nd (in the plural). Additionally,

Code: [Select]
let objScene = GetEnemyBossSceneObjectID();

#include"script/default_system/Default_ShotConst.txt"
#include"script/default_system/Default_Effect.txt"

These three lines should be removed. The first of the three is likely causing the crash (there *is* no boss scene before you create it later in the plural), while the other two are completely irrelevant to a Plural script because you probably won't control boss explosions inside, and you never create bullets in a plural script.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: GuardianTempest on September 29, 2015, 04:05:58 PM
What? I thought I already got ri- oh yeah, outdated paste. I already did that in the current one and still doesn't work.
Code: [Select]
#TouhouDanmakufu[Plural]
#ScriptVersion[3]
#Title["Sandbox File 08"]
#Text["Tutorial Thing - Plural Scripts"]
// Note: Default game field is 384 x 448

//Variables, constants and inclusions
// Empty

@Event{
}

@Initialize{
TPlural;
}

@MainLoop{
        yield;
}

// Tasks ###################

task TPlural{
let dir=GetCurrentScriptDirectory();
let obj=ObjEnemyBossScene_Create();
ObjEnemyBossScene_Add(obj,0,dir~"SandboxFile2.txt");
ObjEnemyBossScene_LoadInThread(obj);
ObjEnemyBossScene_Regist(obj);
while(!Obj_IsDeleted(obj)){
yield;
}
CloseScript(GetOwnScriptID());
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on September 29, 2015, 04:21:44 PM
Ok, did extensive trial & error with various changes /codes. The only reason it is crashing is because your filename is most likely wrong. If I straight copy-paste your code and name my Single script  SandboxFile2.txt it will work. No errors, no crashes.

If I misstype SandboxFile2.txt  then it will crash. Check your file names on your computer. Make sure it is called SandboxFile2.txt and make sure it is in the same directory as your plural.

Doesn't matter whether you change lifebar number or not. That has nothing to do with the actual processing of plurals. That number becomes important when you're tracking Attack steps for lifebar purposes (Intermediate/Expert stuff when you want custom lifebars) or want to use the default Lifebar of ph3 and show the correct sizes. Though it is always good practise to stay consistent and keep clean code. As I discussed on IRC with Ginko and you, don't add variables and things you're not using. @Event thread is even not required here unless you want to catch / process Events.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: GuardianTempest on September 29, 2015, 04:30:18 PM
Thank you so much for your assistance, I'll go to sleep now and resume work tomorrow. I'll make sure that this won't happen again.

EDIT: I now have figured out one of the roots of my problem. It seems that my plural script doesn't recognize .dnh files even if I explicitly said "SandboxFile3.dnh" It looks like I have to convert all my files to txt.

EDIT2: I also discovered that it doesn't support backslashes in file paths. My only problem now is why isn't my boss sprite disappearing? Disregard that, I figured it out.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on October 01, 2015, 10:00:15 AM
Hello there, I'm new over here and with Danmakufu and with programming in general. I'm learning with Sparen's tutorial and I think they are amazingly well done.

Anyway, just a simple doubt about bullet graphics. In game, some bullets apprear "above" others and I don't know how to control this.

http://puu.sh/kuys8/b5fc8c4b29.jpg (http://puu.sh/kuys8/b5fc8c4b29.jpg)

Note that the small bullets are below the bigger ones, so this makes difficult playing since you cannot see them very well.

Thanks.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on October 01, 2015, 01:08:48 PM
Primarily, order of spawning will auto layer the bullets. So if you want to order the bullets you can do two things:
- Mind the spawn order of the bullets
- Force layers by using Obj bullets and use the layer function to set the desired layers. In ph3, we can now work with double digits for layers instead of single digit. So gives more flexibility.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on October 01, 2015, 01:36:16 PM
- Force layers by using Obj bullets and use the layer function to set the desired layers. In ph3, we can now work with double digits for layers instead of single digit. So gives more flexibility.

Mind to explain with an example? Sorry I don't get it how to use that.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on October 01, 2015, 02:31:11 PM
Do you know about Object bullets (or spawning bullets as obj for complicated behaviour / modifying) ? If not, then it is my advise to look into this. Because that way you have more control over a specific bullet, including the layer order. (See tutorials / wiki)

Layer order means the bullet is placed on a specific order. Layer 100 is most highest and 0 being lowest. If I am not mistaking, by default bullets are layer 40 / 50 and player layer 30. (See wiki about Layer functions for Objects)

So for example you can force a bullet on layer 41 and another on on layer 40 so the layer 41 will be always on top, no matter when or where you spawn them.

TL DR: Suggesting to learn how to spawn a bullet as an object.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on October 01, 2015, 02:59:50 PM
Do you mean tasks and "let obj=createshot..."? I already know how those work but I can't find anything related to layers in the tutorials or wiki. And the tutorials about object bullets are for 0.12 (and don't mention layers either).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: GuardianTempest on October 01, 2015, 04:09:16 PM
http://pastebin.com/M3dnaGwC

I'm having problems with my package script, for a reason I probably fail to understand. When I reach running the Stage script through it, it gives me an error saying "LoadEnemyShotData is not defined" (or some other function that should be default). However it works when I try to run the Stage.txt itself so it's nothing inside there, and I've been told that I have to define the basic functions on the package. My question is: How? I've tried using #Include but that's obviously wrong.

This is my last hurdle, after which I can start piling everything together.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on October 01, 2015, 05:12:35 PM
Do you mean tasks and "let obj=createshot..."? I already know how those work but I can't find anything related to layers in the tutorials or wiki. And the tutorials about object bullets are for 0.12 (and don't mention layers either).

Layers are as follows. Please note that this only applies for Render Priorities between 0.2 and 0.8.

Let's say you have a bullet rendered with the default render priority (50?). Now, if we were to do the following:

let obj = CreateShotA1(192, 224, 0, 0, 0, 0);
Obj_SetRenderPriority(obj, 0.51);

Then this new object would render above all other shot objects on the screen due to its render priority being higher than those of the other shots. In fact, it will render above all things with a render priority below 0.51. If multiple objects are spawned with the same render priority, the ones created later will render over the ones created earlier.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on October 01, 2015, 05:16:21 PM
http://pastebin.com/M3dnaGwC

I'm having problems with my package script, for a reason I probably fail to understand. When I reach running the Stage script through it, it gives me an error saying "LoadEnemyShotData is not defined" (or some other function that should be default). However it works when I try to run the Stage.txt itself so it's nothing inside there, and I've been told that I have to define the basic functions on the package. My question is: How? I've tried using #Include but that's obviously wrong.

This is my last hurdle, after which I can start piling everything together.

In Package Mode, which you are in, you cannot simply load a plural script and play it - the system is very different. You must start a Stage and inside the stage, load your plural.

To make a Stage Scene, you must
InitializeStageScene();//Loads stage path
SetStageIndex(indexStage); //where index Stage is the stage number
SetStageMainScript(pathMainScript); //stage path
SetStagePlayerScript(pathPlayer);//replays ignore this
StartStageScene();

After this, you use TerminateStageScene(); to terminate the stage scene (if you want to) and use STAGE_STATE_FINISHED as your control statement.

See http://dmf.shrinemaiden.org/wiki/Package_Functions for more information
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on October 01, 2015, 05:53:17 PM
Layers are as follows. Please note that this only applies for Render Priorities between 0.2 and 0.8.

Let's say you have a bullet rendered with the default render priority (50?). Now, if we were to do the following:

let obj = CreateShotA1(192, 224, 0, 0, 0, 0);
Obj_SetRenderPriority(obj, 0.51);

Then this new object would render above all other shot objects on the screen due to its render priority being higher than those of the other shots. In fact, it will render above all things with a render priority below 0.51. If multiple objects are spawned with the same render priority, the ones created later will render over the ones created earlier.

Thank you! That worked just fine.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Channy on October 01, 2015, 06:40:00 PM
(I hope this is the right place to ask this question ><)

I (might) want to make a Double Spoiler-style danmakufu game so I am trying to re-create the shooting mechanics. I found this author (E.Over0.01) who already made the engine (website: http://anythingfantasy.blog104.fc2.com/blog-entry-137.html ) although it is not compatible with the latest version of ph3. The last seen activity from the author is at Feb 2014 so do I still try to seek permission from him to use the systems? Or is it alright to help translate the codes without permission, but still giving him the credit?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on October 01, 2015, 08:29:55 PM
(I hope this is the right place to ask this question ><)

I (might) want to make a Double Spoiler-style danmakufu game so I am trying to re-create the shooting mechanics. I found this author (E.Over0.01) who already made the engine (website: http://anythingfantasy.blog104.fc2.com/blog-entry-137.html ) although it is not compatible with the latest version of ph3. The last seen activity from the author is at Feb 2014 so do I still try to seek permission from him to use the systems? Or is it alright to help translate the codes without permission, but still giving him the credit?

If you are porting the code, you must give credit to the original source. It is highly recommended that you seek permission when possible. If the language barrier is an issue, then check with someone familiar with the language before sending the e-mail, just to make sure that your writing is clear. You may want to write your request in both Japanese and English.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: GuardianTempest on October 01, 2015, 11:48:33 PM
In Package Mode, which you are in, you cannot simply load a plural script and play it - the system is very different. You must start a Stage and inside the stage, load your plural.

To make a Stage Scene, you must
InitializeStageScene();//Loads stage path
SetStageIndex(indexStage); //where index Stage is the stage number
SetStageMainScript(pathMainScript); //stage path
SetStagePlayerScript(pathPlayer);//replays ignore this
StartStageScene();

After this, you use TerminateStageScene(); to terminate the stage scene (if you want to) and use STAGE_STATE_FINISHED as your control statement.

See http://dmf.shrinemaiden.org/wiki/Package_Functions for more information

Thank you for the reply, although when I tried the code as-is, the stage automatically stops upon playing. Nope, I just don't know how to stave-off ClosePackage().

All I got so far is while(stageSceneState!=STAGE_STATE_FINISHED){yield;} but that doesn't work.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on October 02, 2015, 12:44:16 AM
Thank you for the reply, although when I tried the code as-is, the stage automatically stops upon playing. Nope, I just don't know how to stave-off ClosePackage().

All I got so far is while(stageSceneState!=STAGE_STATE_FINISHED){yield;} but that doesn't work.

In most standard packages, you have a royal mess of if statements and cyclomatic complexity dealing with pause scenes, end scenes, input, and the like. Inside that while loop, my package for SeitenTouji has about 60 lines of code controlling the three possibilities for GetStageSceneResult. You'll want to have a thing in your while loop controlling the pause menu options, and you'll also want a switch statement controlling the following:
STAGE_RESULT_CLEARED
STAGE_RESULT_PLAYER_DOWN
STAGE_RESULT_BREAK_OFF

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: GuardianTempest on October 02, 2015, 02:20:27 AM
Yikes, what if I just want the loop to keep yielding until the stage script is finished?

EDIT: Eureka! I got it!

Code: [Select]
while(GetStageSceneState()!=STAGE_STATE_FINISHED){yield;}

ClosePackage;
break;

Barebones, but that's what I'm aiming for.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Miplouf Saigyouki on October 07, 2015, 11:29:03 AM
Hey there, I'm currently experimenting with text objects and I would like to know how to return to the next line in a text string.

Code: [Select]
AttackName("SUPER ULTRA MEGA GIGA DEATH VORTEX OF ULTIMATE DOOM EX ++ MARK II ENHANCED FROM HELL AND STUFF OMG I AM RUNNING OUT OF THINGS TO SAY RIGHT NOW BUT IT'S OKAY YOU'RE GONNA DIE BY THE TIME YOU'RE DONE READING THIS ","RED");

Do i have to add spaces until it returns to the next line? Or is there a way to do so quicker?

(Don't ask me why i wrote that though, it was but a simple spiral at first)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on October 07, 2015, 01:21:02 PM
Use  [r]. Example:

Code: [Select]
"This is a very long piece of text [r] but this part will be put on the next line"

Put [r] for the next line from desired point. Otherwise, ph3 will auto next line depending on the width you forced using the text object functions. But that cuts off by the character. So better to manually use the commands.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on October 07, 2015, 01:23:14 PM
Use
Code: [Select]
[r] to next line. Otherwise, ph3 will auto next line depending on the width you forced using the text object functions. But that cuts off by the character. So better to manually use the commands.

Depending on your operating system, the width of each character and the space between each character may change, however, so the Max Width method actually even less reliable than it seems.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on October 07, 2015, 01:26:00 PM
Huh? Is that so? How come though? Isn't there a specific font set by default? And there is also default width and spacing between characters. You can even manipulate these with the text object commands.

Curious. Which OS difference btw?

Edit
Tbh, by default you don't want to rely on the max width and let ph3 cut it for you. It cuts characters and not words.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Miplouf Saigyouki on October 07, 2015, 01:46:37 PM
Aaah thank you :)
I can now make unnecessary long attack names with no problems :)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on October 07, 2015, 02:58:20 PM
Huh? Is that so? How come though? Isn't there a specific font set by default? And there is also default width and spacing between characters. You can even manipulate these with the text object commands.

Curious. Which OS difference btw?

Edit
Tbh, by default you don't want to rely on the max width and let ph3 cut it for you. It cuts characters and not words.

On Mac, fonts are rendered with less width than on Windows, etc. So like, I had an issue where the last letter of some words was dumped onto a new line. It was annoying.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on October 07, 2015, 05:03:24 PM
On Mac, fonts are rendered with less width than on Windows, etc. So like, I had an issue where the last letter of some words was dumped onto a new line. It was annoying.
Oh, that is good to know. In that case it would be safer to use [r] with plenty of space left compared to actual width of the object.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on October 07, 2015, 09:58:34 PM
Hi. Is there a tutorial or something to leark how to make custom players? I search in the wiki but can't find anything for ph3, the same with the videtutorials, I only found Helepolis' but they are for 0.12.

Thanks.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on October 07, 2015, 10:58:38 PM
Hi. Is there a tutorial or something to leark how to make custom players? I search in the wiki but can't find anything for ph3, the same with the videtutorials, I only found Helepolis' but they are for 0.12.

Thanks.

There is currently no tutorials (afaik) for making player scripts.

Once you have gained proficiency with Render, Primitive, and Movement objects, as well as @Event and other aspects of the language, implementing your own player based off of the default is a relatively simple task.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Aka Kyuketsuki on October 09, 2015, 10:02:13 AM
Hi again, wanted to ask, how do I make an object collision circle radius ? All I can do for now is a square radius :

Code: [Select]
if(ObjMove_GetX(id) <= GetPlayerX+50 && ObjMove_GetX(id) >= GetPlayerX-50 && ObjMove_GetY(id)<=GetPlayerY+50 && ObjMove_GetY(id)>=GetPlayerY-50){
//stuff happens;
}

Is it possible to make this radius circular ?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on October 09, 2015, 01:16:41 PM
Hi again, wanted to ask, how do I make an object collision circle radius ? All I can do for now is a square radius :

Code: [Select]
if(ObjMove_GetX(id) <= GetPlayerX+50 && ObjMove_GetX(id) >= GetPlayerX-50 && ObjMove_GetY(id)<=GetPlayerY+50 && ObjMove_GetY(id)>=GetPlayerY-50){
//stuff happens;
}

Is it possible to make this radius circular ?

Of course! The general algorithm for radial collision detection is to see if the distance between the centers of the two objects (given by the distance formula) is less than the sum of their collision radii. So if you have an object with radius 5 and an object of radius 3, they will be considered colliding as long as the distance between their center points is less than 8.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Aka Kyuketsuki on October 09, 2015, 05:08:32 PM
Hum, can you make an example as a code please ? Because I don't really understand how to use that formula in a code  :ohdear:
I'm not talking about bullets' hitboxes or anything, just a radius zone where thing happens if a bullet is inside (named "id").
[attach=1] [attach=2]
(Excuse the poorly made pictures  :V)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on October 09, 2015, 05:17:36 PM
Hum, can you make an example as a code please ? Because I don't really understand how to use that formula in a code  :ohdear:
I'm not talking about bullets' hitboxes or anything, just a radius zone where thing happens if a bullet is inside (named "id").
[attach=1] [attach=2]
(Excuse the poorly made pictures  :V)

Code: [Select]
if (GetObjectDistance(player, bullet) < radius) {
  doStuff();
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Aka Kyuketsuki on October 09, 2015, 06:10:31 PM
Thanks a lot ! I didn't know about this function before  :3
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on October 09, 2015, 10:59:33 PM
Manually, and what Sparen was talking about:
Code: [Select]
if (((ObjMove_GetX(player) - ObjMove_GetX(bullet))^2 + (ObjMove_GetY(player) - ObjMove_GetY(bullet))^2 )^0.5 < radius) {
  doStuff();
}

The distance between two points (x1, y1) and (x2, y2) is sqrt((x1 - x2)^2 + (y1 - y2)^2).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on October 10, 2015, 06:43:23 PM
I need a help!
How can I make spell, that not depends of boss life.
For example: Spell without boss life, and it finishes, only when time is threw. But, also there should be a SpellCardBonus!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on October 10, 2015, 09:05:25 PM
Set the following in your spellcard @Event
Code: [Select]
case(EV_REQUEST_IS_DURABLE_SPELL) {
SetScriptResult(true);
}

Make sure the boss has no collision (so you cannot harm it). Unless you do want to harm it but prevent HP going down, set Damage rates to 0.


In case of custom system scripts > Timeout triggers the following event which you can catch in a system script or somewhere. You can use this to do something special in case of a time out (FX, SFX etc).
Code: [Select]
case(EV_TIMEOUT) {
if(!ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_IS_DURABLE_SPELL)) {
// Show custom FAIL SPELLCARD etc.
}
}

case(EV_GAIN_SPELL)  is automatically triggered when a spellcard is set to durable and the player captures it, so scoring and such can be handled there.

Hope that helps out.

Edit:
Did some adjustments.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on October 11, 2015, 07:28:56 PM
@Helepolis
Thanks a lot! All is working!

(P.S. I'm making Touhou Treasure Castle Labyrihtn Extra Stage full! Will be super.Soon coming.)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Failure McFailFace on October 21, 2015, 06:47:39 AM
Is there any specific scripting/programming language Danmakufu is based off on? It feels like JavaScript, but you can do multiple things at once...
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on October 21, 2015, 07:34:41 AM
The script engine (and assumedly the game engine as well) is written in C++ and script syntax is meant to resemble a C-like language with some special extras for working with the engine's event loops and tasks and stuff.

Also, to clarify, Danmakufu does not run any sort of "true" parallelism either, it performs its multitasking through a coroutine implementation, not that that's super important to know for scripters.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on October 21, 2015, 02:39:12 PM
JavaScript, and dnh only has it's C syntax in common. There are alot of things that dnh doesn't do, such as how all functions in JS are considered objects and can be stored as variables with their own invocation methods, etc... Certain implementations of JavaScript support coroutines for asynchronous like behavior btw. Although, you'd have to control it yourself.

Danmakufu gives you bare bones syntax with no real special qualities, which is fine given the ultimate goal of the engine is to make Touhou fanworks easy.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lollipop on October 23, 2015, 06:22:41 PM
How would I make it so that the boss starts with an idle animation, but when it moves, it switches to a moving animation which overrides the idle animation until it stops moving?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on October 23, 2015, 06:50:40 PM
How would I make it so that the boss starts with an idle animation, but when it moves, it switches to a moving animation which overrides the idle animation until it stops moving?

One way to implement this is to set the idle source rect, and then check if the boss is moving (i.e. ObjMove_GetSpeed() > 0). If so, set a new source rect.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lollipop on October 23, 2015, 09:21:40 PM
Oh, there's a function for that? (I feel like an idiot)

edit:
Another question, when I declare a variable (say, a bullet) in a loop{} (which is in a task), it seems to be local to the loop{} only, not public i.e I can't call it outside of the loop{} in the same task or outside of the task. Anyone know how to make them public? (At least to the task, but to the whole script would be cool.)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on October 24, 2015, 01:51:06 AM
Another question, when I declare a variable (say, a bullet) in a loop{} (which is in a task), it seems to be local to the loop{} only, not public i.e I can't call it outside of the loop{} in the same task or outside of the task. Anyone know how to make them public? (At least to the task, but to the whole script would be cool.)

If you would like to make a variable global to a block, simply declare it outside of the block. If you want to make true global variables, define them outside all blocks. The usual place to declare global variables is between the Danmakufu Header and @Initialize.

For further reading: http://sparen.github.io/ph3tutorials/ph3u1l4.html#sub6 (http://sparen.github.io/ph3tutorials/ph3u1l4.html#sub6)

Edit: I've added an additional example of scope. It should make things clearer for now.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: GuardianTempest on October 29, 2015, 01:25:02 AM
Is it possible to make the BGM persist between phases when you declared it within the first single script instead of the stage or plural script?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on October 29, 2015, 02:37:52 AM
Is it possible to make the BGM persist between phases when you declared it within the first single script instead of the stage or plural script?

Technically speaking, a BGM loaded in one script cannot be accessed outside of that script.

If you want a BGM to persist throughout part of or most of a boss battle, you must control the music in the plural, in the stage, or you must use a NotifyEvent to trigger the start and stop of the sound.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Nefer007 on October 31, 2015, 01:20:56 PM
Hello. This is Nefer Nightbug, Shinto God of Insects here.

I've had an idea sitting in the back of my head for, like, ages now.
My original intention was to do it in Blender, but, there's no way to aim bullets.

Is Danmakufu capable of handling...

Thank you.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on October 31, 2015, 01:39:17 PM
Hello. This is Nefer Nightbug, Shinto God of Insects here.

I've had an idea sitting in the back of my head for, like, ages now.
My original intention was to do it in Blender, but, there's no way to aim bullets.

Is Danmakufu capable of handling...
  • Circular combat, like in a circular arena?
  • Actual stages, with fairies and things?
  • Six stages, the Extra Stage, the Phantasm Stage, and one more stage?
  • Stages without midbosses or bosses?
  • Heavy amounts of Blender modeling and animation?
  • Multiple hitpoints, but no lives (a bit like a cross between Legacy and Pointdevice Modes?)

Thank you.
I am not quite sure if this is a joke question or not. I'll answer them regardless:
1) Yes
2) Yes
3) Yes
4) Yes
5) Until you hit limits, yes
6) Yes, if you script it yourself.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on November 01, 2015, 01:28:28 AM
It seems like you haven't researched the engine at all. There have been a number of full Touhou fangames made in danmakufu.

Your 5th question is abit concerning, you cannot go crazy with heavy model rendering, dnh is very fragile with performance and things like that aren't it's specialty at all. Animations are supported by a japanese animating program but the it is a moot point, the animation functions error. The author of the engine has taken an unexpected leave and it doesn't seem like he will be back soon. If this is something essential to your game then I would gladly direct you to use something that could better suit that requirement.

Danmakufu does alot but it isn't your all in one anything. It is designed primarily for danmaku games but obviously through exploiting the flexibility of the engine you can achieve other things. Should you settle for cheap tricks? no. Use something that better suits your requirements.

tldr: with the exception of the 5th question, everything else is highly possible.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on November 01, 2015, 02:28:15 AM
Another 3D question: what is the standard method to render a long, endless path or hallway?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on November 01, 2015, 08:17:50 AM
Another 3D question: what is the standard method to render a long, endless path or hallway?
There is no standard method, only preferred method. For simplicity with little to no 3D-elements you can use Texture UV scrolling. For more control + complexity you can use Z-position scrolling and resetting the pieces behind fog / vision.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on November 03, 2015, 03:22:49 AM
Are there any ph3 player scripting tutorials out there? I can't find any and most player scripts I do find are for 0.12m. If there aren't, how would I go about learning how to make one myself?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on November 03, 2015, 04:35:51 AM
Are there any ph3 player scripting tutorials out there? I can't find any and most player scripts I do find are for 0.12m. If there aren't, how would I go about learning how to make one myself?

You can use this example (http://dmf.shrinemaiden.org/wiki/How_to_Write_Scripts#Player_Script).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TalosMistake on November 03, 2015, 05:17:06 AM
Are there any ph3 player scripting tutorials out there? I can't find any and most player scripts I do find are for 0.12m. If there aren't, how would I go about learning how to make one myself?

I started with downloading one of gtbot's players (you can find it on bulletforge). Gtbot really wrote well-organized code that you can easily understand it. Then I started to make my own player by using gtbot's code as a template. xD
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on November 04, 2015, 03:56:26 AM
I started with downloading one of gtbot's players (you can find it on bulletforge). Gtbot really wrote well-organized code that you can easily understand it. Then I started to make my own player by using gtbot's code as a template. xD
You can use this example (http://dmf.shrinemaiden.org/wiki/How_to_Write_Scripts#Player_Script).

Thanks! I'd already downloaded a few players to see if I could learn from them but it's good to know that GtBot was a good choice. He also made an awesome cutin function that I've used, really good stuff.

Thanks for the help!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on November 04, 2015, 04:21:24 AM
Hi. The only way to deal with the Magic Circle that follows the boss (like, changing the sprite, deleting it, etc) is creating a custom system script and adding it in #System in the single/plural/etc?

Thanks!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on November 04, 2015, 05:10:27 AM
Hi. The only way to deal with the Magic Circle that follows the boss (like, changing the sprite, deleting it, etc) is creating a custom system script and adding it in #System in the single/plural/etc?

Thanks!

You can create a magic circle for a boss wherever you want as long as it is not in a package script. Keeping one in the system script is a good idea if it will only be used on bosses. However, if you do not want to do that, you can create a magic circle in a task and call that task from a script that either has that magic circle code or #includes the file containing it. In this case, make sure you are either deleting the magic circle manually or have Object AutoDelete set to true.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on November 04, 2015, 05:49:59 AM
Thanks for the answer. However, I don't know how to get rid of the default Magic Circle that comes with danmakufu (actually, the only way I found is modifying the default_system folder's files, but I don't think it is a good idea).

I also tried to copy-paste the default_system folder in my own script folder, modify the copied files, and call them in #system in my plural scrpit (I'm making only plural scripts so far). But it seems that they are ignored and it's used the default ones anyway.

Sorry if my explanation is a bit weird, English is not my first language.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TalosMistake on November 04, 2015, 07:26:27 AM
Thanks for the answer. However, I don't know how to get rid of the default Magic Circle that comes with danmakufu (actually, the only way I found is modifying the default_system folder's files, but I don't think it is a good idea).

I also tried to copy-paste the default_system folder in my own script folder, modify the copied files, and call them in #system in my plural scrpit (I'm making only plural scripts so far). But it seems that they are ignored and it's used the default ones anyway.

Sorry if my explanation is a bit weird, English is not my first language.

You can copy-paste default_system folder to your script folder. At the top of your script, write this
Code: [Select]
#System["./default_system/Default_System.txt"]then you can modify Default_System_MagicCircle.txt in the system folder that you copied. Hope this help xD

Edit : Just saw that you already tried it, but I think you were doing it wrong. Try to put the above code to every single file you have (and of course, plural) , because it worked fine for me  :)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on November 04, 2015, 02:19:21 PM
Thanks to you both and sorry. I wasn't puting #system in the non-spells, seems that was the problem.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on November 04, 2015, 09:08:44 PM
http://fat.gfycat.com/PaleDistantAxisdeer.webm

I was messing around with changing patterns into new ones, trying to get ideas for fun things I could do, but I noticed that bullets that fly off the screen are triggered and altered early (as you can see in the top of the screen), most of the pattern is transformed properly but the part that goes offscreen transforms instantly and doesn't home the player, but goes from one side of the screen to the other before being deleted instead.

I tried a whole bunch of things to counteract this but nothing seems to work. I tried having the task not trigger if the bullets disappear with this

Code: [Select]
if(Obj_IsVisible(objD2) == false){Obj_Delete(objD2);}
But that didn't seem to do anything. Any suggestions? I altered the code so the circles would make a flower pattern with the homing butterflies in the end, but the missing piece at the top really messes it up visually. I really hope this is fixable.

Here's the pattern's code in case it's relevant.

http://puu.sh/l9tnh/c5911d58a9.txt
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on November 04, 2015, 11:26:34 PM
http://fat.gfycat.com/PaleDistantAxisdeer.webm

I was messing around with changing patterns into new ones, trying to get ideas for fun things I could do, but I noticed that bullets that fly off the screen are triggered and altered early (as you can see in the top of the screen), most of the pattern is transformed properly but the part that goes offscreen transforms instantly and doesn't home the player, but goes from one side of the screen to the other before being deleted instead.

I tried a whole bunch of things to counteract this but nothing seems to work. I tried having the task not trigger if the bullets disappear with this

Code: [Select]
if(Obj_IsVisible(objD2) == false){Obj_Delete(objD2);}
But that didn't seem to do anything. Any suggestions? I altered the code so the circles would make a flower pattern with the homing butterflies in the end, but the missing piece at the top really messes it up visually. I really hope this is fixable.

Here's the pattern's code in case it's relevant.

http://puu.sh/l9tnh/c5911d58a9.txt

You are spawning bullets from a deleted object, most likely. When creating objects at another object's position, the position of the new object will default to (0,0) if the parent object does not exist. To counteract this, make sure that parent bullets are not deleted before you spawn new bullets at their positions.

Obj_IsVisible(objD2) only toggles whether or not the bullet will be rendered on screen and has no relation to whether the object exists or the position of the object.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on November 05, 2015, 01:03:54 AM
So, would verifying whether the object is deleted before spawning from its location be possible? Also, is it possible to work with offscreen bullets?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on November 05, 2015, 03:10:06 AM
So, would verifying whether the object is deleted before spawning from its location be possible? Also, is it possible to work with offscreen bullets?

Please refer to the documentation.
http://dmf.shrinemaiden.org/wiki/Object_Functions#Obj_IsDeleted (http://dmf.shrinemaiden.org/wiki/Object_Functions#Obj_IsDeleted)
http://dmf.shrinemaiden.org/wiki/Shot_Functions#SetShotAutoDeleteClip (http://dmf.shrinemaiden.org/wiki/Shot_Functions#SetShotAutoDeleteClip)

(More specifically, you can work with any object that is currently existing, regardless of whether or not they are on the screen. Even if an object such as a bullet is 'offscreen', it may still exist depending on various conditions. So yes, it is possible to work with offscreen bullets)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on November 05, 2015, 04:00:50 AM
And ObjShot_SetAutoDelete (http://dmf.shrinemaiden.org/wiki/Shot_Object_Functions#ObjShot_SetAutoDelete) too.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on November 05, 2015, 11:32:34 AM
I'm dumb, it was contained in Sparen's tutorial and I'd missed it because I was too busy trying to fix the code to actually read the damn tutorial.

Still, thank you so much! This'll fix a whole lot of issues that I've been having with ph3.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on November 09, 2015, 07:44:21 PM
(I think I post this topic on right place)
I'm writing a Danmaku Game, a very big project. And I need help in hiding game resource (code, graphics, music,?). Because it would be not interesting, if each person can change code (open Extra, without finishing Normal mode; extra lives and bombs, ?). Also there is MY graphics and MY music ( and code, sounds,? only engine is not). I'm writing on [TouhouDanmakufu] Ph3. Sorry for my English.

1000 Thankyou to a person, who will help me to solve a problem. I hope you understand me.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on November 09, 2015, 07:45:59 PM
Use the archiver?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on November 09, 2015, 07:50:15 PM
Use the archiver?
I have installed some, but I had no imagination how there working '(mostly not working)
Maybe you know a good archiver?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Python on November 09, 2015, 10:00:36 PM
He means the archiving program that comes with Danmakufu. I have no experiences with it, but supposedly you can compress multiple files into a single DAT file with it and then use specific functions to access the files inside that DAT archive.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on November 09, 2015, 11:34:19 PM
When using Danmakufu Archives (the executable is located in tools/FileArchiver.exe), you can safely archive your code. However, please note that your file paths must be EXACT (capitalization matters), and that directories can be a little funky without proper guidance.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on November 10, 2015, 06:09:56 AM
When using Danmakufu Archives (the executable is located in tools/FileArchiver.exe), you can safely archive your code. However, please note that your file paths must be EXACT (capitalization matters), and that directories can be a little funky without proper guidance.
I completly forgot about that's Archiver :000
Oh my "stupidness", I should try this one!

Edit: Yes, it archives all scripts/music/graphic to one dat file. But it doesn't hide all this stuff, or if I delete this stuff, he couldn't find the way. HELP! Maybe I should wright a specific path?  ???

Edit: Okay, An easier question. How to read images/sounds from Archiver file? There should be one method, because there is helpful function "AddArchiverFile(path)", "Adds the path to use when reading images or sounds from an archive file. Returns true if the archive was successfully read, false otherwise."



Please use the Edit button if your post is the last one and it is on same topic. -Hele
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lollipop on November 13, 2015, 04:30:27 AM
My tasks are shaped like this:

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

task fire1 {
   let setime = 0;
   let angleA = 90;

   loop(45){
      let obj1 = CreateShotA1(GetPlayerX + 60*cos(angleA),GetPlayerY + 60*sin(angleA),0,angleA,211,30);
      angleA += 360/45;
      update(obj1);
   }

   loop{
      let obj2 = CreateShotA1(bossX,bossY,rand(2.5,4),rand(0,360),23,0);
      let obj3 = CreateShotA1(bossX,bossY,rand(2.5,4),rand(0,360),19,0);
      let obj4 = CreateShotA1(bossX,bossY,rand(2.5,4),rand(0,360),35,0);
      let obj5 = CreateShotA1(bossX,bossY,rand(2.5,4),rand(0,360),39,0);
      let obj6 = CreateShotA1(bossX,bossY,rand(2.5,4),rand(0,360),179,0);
      let obj7 = CreateShotA1(bossX,bossY,rand(2.5,4),rand(0,360),183,0);
      if(setime == 7){
         setime = 0;
         PlaySE(shotfx);
      }
      setime++;
      wait(2);
   }

   inRadius(obj1,obj2);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

task update(obj){
   loop{
      ObjMove_SetPosition(obj,GetPlayerX + 55*cos(ObjMove_GetAngle(obj)),GetPlayerY + 55*sin(ObjMove_GetAngle(obj)));
      yield;
   }
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Currently, my inRadius task is empty. My two questions are;
1. When I call the task inRadius(obj1,obj2), Danmakufu says "obj1 cannot be found." how to fix?
2. How do I shape my inRadius task so that if a bullet is inside the ring I created in task fire1, the speed of the bullet slows down?

(Sorry if this post is stupidly long)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on November 13, 2015, 04:47:06 AM
The first problem is that obj1 is defined within the scope of a loop, and so can't be referenced outside of the loop. Normally this would be fixed just by declaring let obj1; before the loop (it wouldn't find obj2 either). However this won't fix anything because you have 45 separate declarations for obj1, and so you can't know what you actually mean when referring to obj1 for the inRadius call (do you mean one particular bullet? All 45 of them?). Additionally, because you have a loop without a counter or terminating condition the script will never get to inRadius in the first place.

You don't actually need to reference any of those bullets in the ring at all for your slowdown effect. Your circle has a radius of 55 and is relative to the player position, so this is essentially collision detection. You would have to write inRadius to detect if the bullet is close to the player, then call inRadius(obj2) after you fire obj2 (and again for the other five). However, because the bullets are all pretty much the same and you aren't actually doing anything with those variables afterwards you can plop the bullet creation right in the task itself instead.

Code: [Select]
task slowBullet(graphic){
  let obj = CreateShotA1(bossX, bossY, rand(2.5,4), rand(0,360), graphic, 0);
  while(!Obj_IsDeleted(obj)){
    // if bullet is within a distance of 55 to the player
    if(((GetPlayerX() - ObjMove_GetX(obj))^2 + (GetPlayerY() - ObjMove_GetY(obj))^2)^0.5 < 55){
      // slow down
    }
    yield;
  }
}

And then in your loop instead of firing the six bullets you would write slowBullet(23); slowBullet(19); etc.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lollipop on November 13, 2015, 05:10:45 AM
thanks  :)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on November 15, 2015, 02:31:36 PM
1) How to read music/sounds/graphic that is in the .dat file? (When it was Archived by FileArchiver for ph3)

2) Which program/engine can run TouhouDanmakufu scripts too? (Please no 0.12m, ph3)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on November 15, 2015, 03:50:01 PM
1) How to read music/sounds/graphic that is in the .dat file? (When it was Archived by FileArchiver for ph3)

2) Which program/engine can run TouhouDanmakufu scripts too? (Please no 0.12m, ph3)

First one: Reference them as you would normally. If you had a file ScriptName/img/effect.png, and you archived it to img.dat, you should place img.dat inside ScriptName, but you do NOT need to change any of your paths. (i.e. GetCurrentScriptDirectory/img/effect.png is correct)

Just remember to give Danmakufu the archive path in your System script or something.

Second one: There is none. Danmakufu is a custom scripting language and the Danmakufu ph3 interpreter is the only way to run it unless you were to build or find a transpiler to another language.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on November 15, 2015, 06:44:16 PM
Thanks!

First one: Reference them as you would normally. If you had a file ScriptName/img/effect.png, and you archived it to img.dat, you should place img.dat inside ScriptName, but you do NOT need to change any of your paths. (i.e. GetCurrentScriptDirectory/img/effect.png is correct)

Just remember to give Danmakufu the archive path in your System script or something.

I didn't quite understand with first one. And what if, in one ".dat" file archived more than one graphic?

Edit: Already all understand, Big big thank you to you.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Asthmagician on November 18, 2015, 12:15:14 PM
I'm attempting to implement some bullets that only collide if the player is moving, and I've run into some trouble.
I can't figure out how to test if the player is currently moving.
The function "GetPlayerSpeed" returns the possible speeds of the player, not the current one
Using "ObjMove_GetSpeed" on the ID returned from "GetPlayerObjectID" always returns 0 (I assume that the player object is not counted as a move Object?)
Is there a way to easily get the player's speed that I'm missing?
Is there another implementation of testing if the player is moving that I'm missing?

Here is the relevant code:
Code: [Select]
        let r = GetShotDataInfoA1(ObjShot_GetImageID(obj),TARGET_ENEMY,INFO_COLLISION);
        ObjShot_SetIntersectionEnable(obj,false);
        let pl = GetPlayerObjectID;
        while(!Obj_IsDeleted(obj)){
            if(GetObjectDistance(pl,obj)<r&&ObjMove_GetSpeed(pl)>0){
                let shot = CreateShotOA1(pl,0,0,2190,0);
                ObjRender_SetAlpha(shot,0);
                yield;
                Obj_Delete(shot);
                return;
            }
            yield;
        }
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on November 18, 2015, 05:05:05 PM
If the player is not pressing any movement keys, then it's not moving at all. If the player is focused, it's moving at the focused speed. If the player is unfocused, then it's moving at the unfocused speed.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: TalosMistake on November 18, 2015, 08:13:06 PM
I'm attempting to implement some bullets that only collide if the player is moving, and I've run into some trouble.
I can't figure out how to test if the player is currently moving.
The function "GetPlayerSpeed" returns the possible speeds of the player, not the current one
Using "ObjMove_GetSpeed" on the ID returned from "GetPlayerObjectID" always retturns 0 (I assume that the player object is not counted as a move Object?)
Is there a way to easily get the player's speed that I'm missing?
Is there another implementation of testing if the player is moving that I'm missing?

As Fluffy8x said, you can use GetVirtualKeyState to check whether the arrow keys are being pressed or not. If the answer is yes, then you can assume that player is moving. (You can also check the player's unfocused/focused state with this function.)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on November 19, 2015, 02:43:22 AM
Why is the extra shot to kill the player needed? You already seem to know how SetIntersectionEnable works. Also since it takes a boolean you can just plop the condition right in there.

Code: [Select]
task bullet(){
let obj = // CreateShotBla();
while(!Obj_IsDeleted(obj)){
ObjShot_SetIntersectionEnable(obj, condition);
yield;
}
}
So if you want to check movement keys, you can use it as that condition.

However, I wouldn't really recommend this from a design perspective. This is because checking the pressed keys happens before your player even moves, and so seems to me like one frame too early before you should actually collide. The "standard" way of checking something like this would look like:

Code: [Select]
task bullet(){
let p = [ObjMove_GetX(player), ObjMove_GetY(player)];
let op = p;

let obj = // CreateShotBla();
while(!Obj_IsDeleted(obj)){
p = [ObjMove_GetX(player), ObjMove_GetY(player)];
ObjShot_SetIntersectionEnable(obj, (p != op));
op = p;
yield;
}
}

Which would only hit the player if they both collide with the bullet and have actually just moved, on the same frame. One minor disadvantage to this is that it'll be recalculating the player positions for every bullet, which can be slightly expensive. If you care about these sorts of things like me then you can use the following sort of design pattern, where you have one object that holds the movement state and a single routine that updates it, and only ever access that one value.

Code: [Select]
let state = ObjShot_Create(OBJ_SHOT);
function IsPlayerMoving(){ return Obj_GetValueD(state, "STATE_PLAYER_MOVING", false); }

task UpdatePlayerMoving(){
let player = GetPlayerObjectID();
let p = [ObjMove_GetX(player), ObjMove_GetY(player)];
let op = p;
while(!Obj_IsDeleted(state)){
p = [ObjMove_GetX(player), ObjMove_GetY(player)];
Obj_SetValue(state, "STATE_PLAYER_MOVING", (p != op));
op = p;
yield;
}
}
UpdatePlayerMoving();

task bullet(){
let obj = // CreateShotBla();
while(!Obj_IsDeleted(obj)){
ObjShot_SetIntersectionEnable(obj, IsPlayerMoving());
yield;
}
}


Really though the first one is fine, I'm just writing this for completeness' sake.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Asthmagician on November 19, 2015, 04:25:16 AM
Thank you all, that's very helpful.
For clarity's sake, am I right in my guess that the player is not counted as a move object?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: zemoo on November 20, 2015, 07:57:59 AM
I'm writing a script that is intended to be synced to the music and I was wondering if there was a way to have music that slows down if the game lags.
i'm using
Code: [Select]
function Sound(path){
     let obj = ObjSound_Create;
     ObjSound_Load(obj,path);
     ObjSound_SetSoundDivision(obj, SOUND_BGM);
     ObjSound_SetRestartEnable(obj, true);
     ObjSound_SetLoopEnable(obj, true);
     ObjSound_SetLoopTime(obj, 0,300);
     ObjSound_Play(obj);
     ObjSound_SetVolumeRate(obj,95);
     return obj;
 }
instead of #bgm, but I'm open to switching to something else if that wold work better.

Is it something like(pseudo code)
Code: [Select]
@event{
     case(game lags){
     let lagAmount = Calculate Lag
     Slow music(lagAmount)
     }
}

Also, I have the music stopping if I pause, but it still plays when I click over to another window, even though that effectively pauses the rest of the script is there a way to fix that?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on November 20, 2015, 08:14:29 AM
I'm writing a script that is intended to be synced to the music and I was wondering if there was a way to have music that slows down if the game lags.
There isn't.

You can try to heavy experiment with stopping the music and fiddling with the restartenable function. But I doubt it is something to be done effectively.

Why don't you just make sure the script doesn't lag anyway?  (i.e: securing 60fps running)

Also, I have the music stopping if I pause, but it still plays when I click over to another window, even though that effectively pauses the rest of the script is there a way to fix that?
Afaik, nope. Danmakufu behaviour as you have noticed. So far nobody has even tried to attempt something like this (making music lag / not continue when focussing the main window). The solution I guess is to play full screen (which you probably guessed yourself).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on November 20, 2015, 08:42:08 AM
Thank you all, that's very helpful.
For clarity's sake, am I right in my guess that the player is not counted as a move object?
No, it is a Move object, but essentially all players are going to be implemented by moving using SetPosition-like functions, rather than setting an angle and speed. GetAngle and GetSpeed will only return useful values if the objects have those attributes set to something. In the same way, if you create a Shot object without giving it an angle or speed and move it around with SetPosition, it won't return useful values for those functions either.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: zemoo on November 20, 2015, 05:12:45 PM
Why don't you just make sure the script doesn't lag anyway?  (i.e: securing 60fps running)

How do I do this? is it code I need to include in my scripts/system or a vPatch type of thing; cause all my games still lag even with vpatch.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on November 20, 2015, 05:37:10 PM
How do I do this? is it code I need to include in my scripts/system or a vPatch type of thing; cause all my games still lag even with vpatch.
vPatch? Why would you try to apply that for Danmakufu? What do you mean with all your games?

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: zemoo on November 20, 2015, 07:07:41 PM
It made sense to me that vpatch would work on other stgs(e.g. danmakufu) apparently this is not the case, so forget about vpatch.
,
I found this function
StartSlow(TARGET_ALL, 60);
is this what I want to do? I tried it in @initialize and it changed some of the timing for the script, but the fps in the hud still fluctuated between 59.3 and 60.4. I tried slowing it to 40 which worked but "slowing" it to 70 did not make it go any faster. Is this the intended function to secure 60fps, I am quite inept when it comes to danmakufu.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: ExPorygon on November 20, 2015, 09:31:15 PM
It made sense to me that vpatch would work on other stgs(e.g. danmakufu) apparently this is not the case, so forget about vpatch.
,
I found this function
StartSlow(TARGET_ALL, 60);
is this what I want to do? I tried it in @initialize and it changed some of the timing for the script, but the fps in the hud still fluctuated between 59.3 and 60.4. I tried slowing it to 40 which worked but "slowing" it to 70 did not make it go any faster. Is this the intended function to secure 60fps, I am quite inept when it comes to danmakufu.
That function simply changes the frame rate of Danmakufu, which is already 60 by default. It is not an anti-lag function, its intended purpose is to create a Youmu-esque sIowdown effect. It also cannot be used to speed the game up.

If it ends up lower than that anyway, then either your scripts need to be better optimized or your computer hardware (specifically the CPU) needs to be upgraded. Do you have a ton of objects running tasks all at once? Are you deleting objects after you are finished with them? Are you using too many curvy lasers? Those in particular are WAY more process intensive than the ones that ZUN himself uses. Do you have an abundance of visual effects, possibly with primitive objects using large numbers of vertices? Are you making Danmakufu do an excessive amount of trig calculations (i.e. once every frame)?

There are quite a few things you can do to reduce lag in your scripts, many more than I'm capable of thinking of at the moment. Maybe it would help to make a more comprehensive list of things that can bog Danmakufu's framerate down.

but the fps in the hud still fluctuated between 59.3 and 60.4.
However, this is not really a significant source of lag. I've observed Danmakufu keeping these fluctuations (on the main menu at least) even under the most ideal of conditions. If small fluctuations like this are all you're experiencing, then syncing music to Danmaku shouldn't be an issue when it comes to the framerate.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: zemoo on November 20, 2015, 11:22:25 PM
If it ends up lower than that anyway, then either your scripts need to be better optimized or your computer hardware (specifically the CPU) needs to be upgraded. Do you have a ton of objects running tasks all at once? Are you deleting objects after you are finished with them? Are you using too many curvy lasers? Those in particular are WAY more process intensive than the ones that ZUN himself uses. Do you have an abundance of visual effects, possibly with primitive objects using large numbers of vertices? Are you making Danmakufu do an excessive amount of trig calculations (i.e. once every frame)?

There are quite a few things you can do to reduce lag in your scripts, many more than I'm capable of thinking of at the moment. Maybe it would help to make a more comprehensive list of things that can bog Danmakufu's framerate down.
However, this is not really a significant source of lag. I've observed Danmakufu keeping these fluctuations (on the main menu at least) even under the most ideal of conditions. If small fluctuations like this are all you're experiencing, then syncing music to Danmaku shouldn't be an issue when it comes to the framerate.

99% sure it's my my comp: 4 tasks, no lasers curvy or otherwise, black background,  I don't even have many bullets yet just moving and animating the boss. I do use a lot of trig so that might be it. But I'mnot trying to get rid of all lag, it can't be helped with my comp. I was originally thinking of something like
Code: [Select]
task lagMusic{
lagMemory += 60-GetCurrentFps();
if(lagMemory>60){
ObjSound_Stop(bgm);
wait(1);
ObjSound_Play(bgm);
lagMemory -= 60;
}
}
but wanted to see if anyone had a more elegant solution. I also wanted a way to skip ahead if the framerate speeds up like it does when you hold ctrl, but I couldn't find a speed up music function.

I find it a little surprising that no one has ever needed synchronized music before. I noticed when moving the files to and from my laptop to my pc (i sometime work on my scripts when I go places and expect to have downtime) that the sync was off and I didn't want to finish syncing my script to the lagged version when everybody else who plays it will play on the lagless one. Even small fluctuation are noticeable on a ~4min script, they add up toward the end.
Why don't you just make sure the script doesn't lag anyway?  (i.e: securing 60fps running)
made it seem like there was a trivial way to force a framerate, if there is i would like to use it instead of a hack
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on November 21, 2015, 05:33:01 AM
Hele meant that you should be writing your script so it isn't so heavy that it causes unstable framerate.


99% sure it's my my comp: 4 tasks, no lasers curvy or otherwise, black background,  I don't even have many bullets yet just moving and animating the boss. I do use a lot of trig so that might be it.
It would have to be a heck of a lot to cause any sort of slowdown with that barebones of a script.

Your code seems like it could work with some modifications, if GetCurrentFps worked the way you wanted it to. The way you've written it, it'll only pause for one frame (theoretically) after accumulating 60 frames-worth of lag. If you wanted to wait for one frame when one frame is lost, you'd have to check (lagMemory >= 1) and subtract 1. You'd probably also want to center the timing around +/- 0 frames, so (lagMemory >= 0.5) and subtracting 1 would be better.

However, this is moot since GetCurrentFps gives you an average over one second, rather than calculating (the inverse of) wall time elapsed between one frame and the next. You can do much better with GetStageTime, but its resolution is still only down to milliseconds and you will not accurately be counting deviation from 60FPS. A simple test on a stable script averaged 0.1232s deviation over 5 seconds, or roughly 1.5 frames late per second. That might not necessarily be correct due to the resolution, but it might be good enough to do that silly skipping method.

Quote
I find it a little surprising that no one has ever needed synchronized music before
That isn't the case, there just usually isn't a situation where your computer performs poorly enough that this is a concern.

Regardless, you should be able to write a synchronized script even without being able to run it well yourself, if you can confirm the BPM and time your script accordingly. A 120 BPM song is 2 BPS (second) and so 30 frames per beat.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on November 21, 2015, 07:04:17 AM
Hi! How can I make a bullet with a "curved" fall? Something like a parabola. Like in a free fall.

Something like this: http://puu.sh/lta27/98a497a6a6.png

More general: http://puu.sh/lta0c/c89e578c7c.png

Thanks!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on November 21, 2015, 07:43:21 AM
Synchronized BGM discussion on last page
Okay I just implemented this myself out of interest. Works pretty decently. Would appreciate testers.

https://gist.github.com/drakeirving/d7ce1bf229395509025c



Hi! How can I make a bullet with a "curved" fall? Something like a parabola. Like in a free fall.
The CreateShotB series uses x-speed and y-speed parameters rather than speed and angle. In particular, CreateShotB2's usage is:
Code: [Select]
CreateShotB2(x, y, x_speed, y_speed, x_accel, y_accel, x_max_speed, y_max_speed, graphic, delay)By having any initial x/y-speeds and a positive y-acceleration you will get a gravity-like effect.

ObjMove_AddPatternB2 also works the same way if you want to modify an existing bullet rather than fire a new one:
Code: [Select]
ObjMove_AddPatternB2(obj, frame, x_speed, y_speed, x_accel, y_accel, x_max_speed, y_max_speed)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: zemoo on November 21, 2015, 07:14:24 PM
First off, thank you all for replying

Your code seems like it could work with some modifications, if GetCurrentFps worked the way you wanted it to. The way you've written it, it'll only pause for one frame (theoretically) after accumulating 60 frames-worth of lag. If you wanted to wait for one frame when one frame is lost, you'd have to check (lagMemory >= 1) and subtract 1. You'd probably also want to center the timing around +/- 0 frames, so (lagMemory >= 0.5) and subtracting 1 would be better.

not quite, if I understand you correctly
Code: [Select]
task lagMusic{
lagMemory += 60-GetCurrentFps();
if(lagMemory>=1){
ObjSound_Stop(bgm);
wait(1);
ObjSound_Play(bgm);
lagMemory -= 1;
}
}
would see 59 fps for 1 frame then skip the next frame, meaning that a script running at 59fps would have music running at half speed. In my original (which is still a naive approach) would run at 59fps for 60 frames before skipping one so 61 frames of music for 60 frames of gameplay. The difference in the actual fps and the expected fps per frame is only worth 1/60 of a frame which is why I waited to get 60 of them before skipping one. Either way, this method wasn't really fleshed out, just my first blush idea.(It is less accurate the farther from 60fps your script goes now that I think more of it)

I'll try out PlaySyncBGM(path, loop_start, loop_end, skip_param) later on today, I have a few ideas and I'm sure I can induce lag if I try.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on November 21, 2015, 08:19:35 PM
Hi! How can I make a bullet with a "curved" fall? Something like a parabola. Like in a free fall.

Something like this: http://puu.sh/lta27/98a497a6a6.png

More general: http://puu.sh/lta0c/c89e578c7c.png

Thanks!

CreateShotB1 / B2.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on November 21, 2015, 09:34:12 PM
Thanks to both, that's exactly what I was looking for  :D

Btw, there is a guide or some script that I can use to learn how to put dialogues?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on November 21, 2015, 10:39:52 PM
Thanks to both, that's exactly what I was looking for  :D

Btw, there is a guide or some script that I can use to learn how to put dialogues?

Literally any script that has dialogue.


Less spam, more proper help posts please. -Helepolis
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on November 21, 2015, 10:42:28 PM
There isn't a guide for dialogue scenes but it is very simple to make. Stealing code from others isn't always a good choice either, especially if you don't get permission to use their code.

The general idea is that you need: one sprite object for the player's cutin, another for the boss, a background sprite object for the text background, and finally a text object. so you can just setup a system that works like this.

Code: [Select]
CreatePlayerSpriteObject() just change the texture or source rects to show difference faces
CreateBossSpriteObject() same as the player
CreateDialogueBox() best to just have one of these unless you want the GFW - Present style floating dialogue boxes
CreateTextObject() for whoever is talking, again only one is needed, just change the text for whoever is talking

blahblahblah talking...

CleanUp everything else afterwards, deleting the previously created objects, removing textures, etc...
I can't really come up with an example code right now but that's sort of a quick step by step guide to how it could work for something extremely simple. The functions I mentioned don't actually exist but you'll be using ObjSprite_Create(OBJ_SPRITE_2D); for the player, boss, and text background, and finally ObjText_Create() for the actual dialogue text. I suggest looking at the official danmakufu documentation for ph3 (Google Translate does well enough here), the danmakufu wiki we have is also applicable but I always recommend using the official documentation because it contains more information about the engine and is more accurate atm.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on November 22, 2015, 09:37:58 AM
<code> would see 59 fps for 1 frame then skip the next frame, meaning that a script running at 59fps would have music running at half speed. In my original (which is still a naive approach) would run at 59fps for 60 frames before skipping one so 61 frames of music for 60 frames of gameplay. The difference in the actual fps and the expected fps per frame is only worth 1/60 of a frame which is why I waited to get 60 of them before skipping one.
Beep boop, I was mistaken, yes. I didn't scale it in my head properly and figured "FPS is a measure of frames so a difference of 1 means 1 frame".

Anyways, I'd like to see how my method performs when faced with horrible lag like you're reporting. I can't really emulate that very well on my machine.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on November 27, 2015, 12:07:43 PM
Ah,Hello there everyone :derp:
I know it's kinda silly question
BUUUTT :V
I was wondering how to spawn bullets on the laser?Like on the end of the laser and stuff? ???
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on November 27, 2015, 04:00:05 PM
Ah,Hello there everyone :derp:
I know it's kinda silly question
BUUUTT :V
I was wondering how to spawn bullets on the laser?Like on the end of the laser and stuff? ???

You know the starting point, angle, and length of the lasers. Knowing that, you can use trigonometry to place bullets along the length of the laser.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on November 27, 2015, 05:32:23 PM
You know the starting point, angle, and length of the lasers. Knowing that, you can use trigonometry to place bullets along the length of the laser.

That's the problem
I don't understand trigonometry
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on November 27, 2015, 05:44:07 PM
That's the problem
I don't understand trigonometry

What are you doing here? Get your butt out of your chair and go to school for once.

Anyway, I'd suggest learning basic trigonometry. There are many resources on the Internet that they're not worth linking from here.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on November 27, 2015, 05:51:32 PM
What are you doing here? Get your butt out of your chair and go to school for once.

Anyway, I'd suggest learning basic trigonometry. There are many resources on the Internet that they're not worth linking from here.

No thanks!Don't wanna go to school again :u
Nah,I'm too stupid to understand this stuff

ALSO

I think I got it,thank you two for response!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on November 28, 2015, 01:22:54 PM
There isn't a guide for dialogue scenes but it is very simple to make. Stealing code from others isn't always a good choice either, especially if you don't get permission to use their code.

The general idea is that you need: one sprite object for the player's cutin, another for the boss, a background sprite object for the text background, and finally a text object. so you can just setup a system that works like this.

Thanks, that was more or less what I imagined. The real problem was how to pass through the text but I could do it.

Now, I'm having problems with the background. I try to make a BG that moves. The code is very simple (I don't put a loop yet), just for test purpose:

Code: [Select]
#include"./FuncList.dnh"

@Initialize{
RenderBG;
}

task RenderBG {
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
let imgpath = currdir~"./img/cielo2.png";

let alpha = 150;
let scale = 0.8;

ObjPrim_SetTexture(obj, imgpath);
ObjSprite2D_SetSourceRect(obj, 0, 0, 512, 1024);
ObjSprite2D_SetDestCenter(obj);
ObjRender_SetPosition(obj, CenterX, CenterY, 0);
ObjRender_SetAlpha(obj, alpha);
Obj_SetRenderPriority(obj, 0.21);
ObjRender_SetScaleXYZ(obj, scale, scale, 1);

moverBG(obj);
}

task moverBG(obj){
let x = 0;
let y = 0;

while(!Obj_IsDeleted(obj)){
ObjRender_SetPosition(obj, x, y, 0);
x++;
y++;

yield;
}
}

But if I call this file with #Background in the plural script, the image doesn't move at all. However, if I put the task "RenderBG" in the @Initialize of the plural script, it works (obviously deleting the @Initialize in the BG script).

Why does this happen? Thanks.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on November 28, 2015, 03:52:53 PM
But if I call this file with #Background in the plural script, the image doesn't move at all. However, if I put the task "RenderBG" in the @Initialize of the plural script, it works (obviously deleting the @Initialize in the BG script).

Why does this happen? Thanks.

In order for a task to run in a script, you must always have a yield; in your @MainLoop. You don't have a @MainLoop with a yield in this script.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on November 28, 2015, 07:19:08 PM
Thank you Sparen, it worked  :D

Btw, there is no default item script?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on November 28, 2015, 07:26:45 PM
Thank you Sparen, it worked  :D

Btw, there is no default item script?

What do you mean by a 'default item script'? There are default items in Danmakufu, if that's what you are referring to.

http://dmf.shrinemaiden.org/wiki/Functions_(ph3)#Item_Functions
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on November 29, 2015, 12:08:52 AM
Yes, I know that. What I mean is... if exist something like this by default: http://puu.sh/lCeO3/be248c3d7c.png so I can edit it and make my own (that is an example used in an user script I downloaded).
Just like the Rumia boss and player script that comes with danmakufu by default, but with items.
The idea is to take the default script and use it as a "basis" to make a custon one, but I couldn't find any script that refers to items.

Sorry if I can't explain myself very well, it's difficult when English is not your first language.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on November 29, 2015, 01:41:33 AM
There is no 'default' item script that comes with Danmakufu, afaik. Mine is based off of Ultima's. It's one of those things that scripters tend to make on their own once they begin working on large-scale projects such as full games.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on November 29, 2015, 02:25:20 AM
Oh, I see. Thanks!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on November 29, 2015, 03:37:39 AM
There is a Item Script system that contains events for how custom items are handled when they are collected, or when bullets are converted to items, etc...

That is what I use, however if you do not define one for danmakufu to use, custom items will not be properly handled. The official ph3 documentation has an example of what the item script should be like (you will have to also add a @MainLoop{yield;} since iirc, the example didn't do that and it is the only way for tasks to yield properly. Once you have an item script you can use StartItemScript() with a path to the script itself.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on November 29, 2015, 09:14:35 AM
The example given in the official documentation doesn't have an explicit MainLoop (and so no yield statement in one) because it doesn't need one as it's written. Once you start defining fancy custom behaviour and effects it would be necessary of course, but for simple stuff you don't even need it.

Here's a really basic outline extending the doc's a bit:
http://pastebin.com/NLjHdwjS

EDIT: Sage I never meant to imply otherwise, just mentioning that detail :)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on November 29, 2015, 03:03:01 PM
Sure the script doesn't require it to be there, but for the sake of avoiding the "why doesn't my task yield?" question, I mentioned to add it in now.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on November 29, 2015, 07:21:38 PM
Good day, everyone.
Who had wrote often STGs?
Which fps-problem can I face during writing STGs? What should I beware? My big problem is that Boss Fight in Stage runs in low fps (Even if I upload it from the beginning of the Stage). But when I play just Plural, all work successfully. Somebody knows that trick?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on November 29, 2015, 07:36:40 PM
Good day, everyone.
Who had wrote often STGs?
Which fps-problem can I face during writing STGs? What should I beware? My big problem is that Boss Fight in Stage runs in low fps (Even if I upload it from the beginning of the Stage). But when I play just Plural, all work successfully. Somebody knows that trick?

It's not a 'trick' when it comes to FPS over a long period of time. It is known as optimization, and constitutes more than just mere 'tricks'.

Ways to improve your FPS:
-Short circuit your boolean expressions:
Code: [Select]
if (x && y) {} //if x is false, then y won't even be evaluated -Kill all tasks when they are completed
-Delete all objects when they are no longer needed
-Remove unused variables and redundant statements
-Use variables for things that are used multiple times (e.g. GetCurrentScriptDirectory, or for trigonometry)
-Avoid indexing large arrays
-etc.

If you are using the log window, then it should be clear where some of your resource management is going haywire.

Optimization is a process that cannot be taught - only experienced. You will have to see for yourself how to improve your code and resource management.

P.S. Excessive curvy lasers and ADD/INVERT bullets significantly lag Danmakufu when used in excess.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on November 29, 2015, 08:18:25 PM
Ways to improve your FPS:
-Short circuit your boolean expressions:
Code: [Select]
if (x && y) {} //if x is false, then y won't even be evaluated -Remove unused variables and redundant statements
-etc.

These two yield zero increase in performance, variables are just value lookups on the script's virtual stack. Mkm handles these things quite well.

Optimization can be taught, but you really want to focus on optimization after you reach a certain level in your project, for example: after finishing a boss battle, stage, or even cleaning up and preparing for a demo. If there's one thing about programming games you should know, you build your game the smart way, and worry about "what can I do make improve performance" later. The last thing you need to do is develop unnecessary lag safety habits early on, danmakufu is not a very performance optimized engine so there is a limit to what you can do to improve and avoid lag.

I suggest being mindful of sprite objects you have going around, deleting unused things is best, textures can stay in memory no problem but sprites, bullets, enemies etc... need to go. Be mindful of the calculations you make, you don't need to have an ellipse formula for a ring of bullets, or some other unnecessary trig ran each frame.

But after all of these things are said and done, at the end of the day, it is all left up to how good your computer is. Don't let worrying about optimization discourage you and take away the fun of making games. I had to learn that the hard way, and most serious programmers will tell you the same. (after I spent nights worrying about improving my personal danmaku engine I made in both C++ and C#, I ended up seeing that those efforts were unnecessary)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on November 29, 2015, 08:55:27 PM
Thank you @Sparen.
Thank you @Sage.
I will consider it.
Maybe.. later I need some people to test my Danmaku-game, before it will be published.
Who wants to play (test) Extra stage? Touhou Treasure Castle Labyrinth   :V
> zhan.fox.12@gmail.com

Edit
One more question..
For what is this " .def " file?
Which programm language used there? What can I add there more?
Where I can learn more about this file (language)?


Please use the edit button if your post is the last one -Helepolis
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on November 30, 2015, 05:12:43 PM
One more question..
For what is this " .def " file?
Which programm language used there? What can I add there more?
Where I can learn more about this file (language)?

It is a configuration file.

Code: [Select]
// Path to the package script
package.script.main = script/ExRumia/ExRumia_Package_Main.txt

// Window title
window.title = test

// Screen dimensions
screen.width=1024
screen.height=576


A second sincere request to make your posts more elaborate if you're willing to help. -Helepolis
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on November 30, 2015, 05:49:08 PM
It is a configuration file.

Code: [Select]
// Path to the package script
package.script.main = script/ExRumia/ExRumia_Package_Main.txt

// Window title
window.title = test

// Screen dimensions
screen.width=1024
screen.height=576

Yes, that I know already. But if there something more than that? Where can I see more information about this configuration file?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on November 30, 2015, 06:55:43 PM
Yes, that I know already. But if there something more than that? Where can I see more information about this configuration file?

The code posted is basically all you need to know.

You place the th_dnh.def file in the same directory as your executable.

Comments are preceded by //

Keep each statement on a separate line.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on December 01, 2015, 07:19:35 PM
Sorry please..
How do I point CreateStraightLaserA1 angle, to object, that moves with ObjMove_SetAngularVelocity.
When I make this, lasers angle points to object askew.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on December 01, 2015, 07:26:36 PM
Sorry please..
How do I point CreateStraightLaserA1 angle, to object, that moves with ObjMove_SetAngularVelocity.
When I make this, lasers angle points to object askew.

What are you trying to do? Are you trying to move the base of the laser depending on the location of a bullet or are you aiming the laser at a specific place? You need to state your intention more clearly.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on December 01, 2015, 07:30:45 PM
What are you trying to do? Are you trying to move the base of the laser depending on the location of a bullet or are you aiming the laser at a specific place? You need to state your intention more clearly.
Sorry my English.
Aiming lasers to Shot object that moving in angular velocity.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on December 01, 2015, 07:52:47 PM
Sorry my English.
Aiming lasers to Shot object that moving in angular velocity.

You can't use ObjMove_SetAngularVelocity for that. You need to use a task.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on December 01, 2015, 08:15:37 PM
You can't use ObjMove_SetAngularVelocity for that. You need to use a task.

Approximately I had this

Code: [Select]
task Lantern{

ascent(ang in 0..20){
     let obj = CreateShotA1( … );
     Laser(obj);
     }

     task Laser(object){
          ObjMove_SetAngularVelocity(object, 0.5);
          let laser = CreateStraightLaserA1( … );
          while(!Obj_IsDeleted(object)){
                 ObjStLaser_SetAngle(laser, ObjMove_GetAngle(object));
          yield;
     }}

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on December 01, 2015, 08:51:19 PM
Approximately I had this

Code: [Select]
task Lantern{
?
ascent(ang in 0..20){
     let obj = CreateShotA1( ? );
     Laser(obj);
     }

     task Laser(object){
          ObjMove_SetAngularVelocity(object, 0.5);
          let laser = CreateStraightLaserA1( ? );
          while(!Obj_IsDeleted(object)){
                 ObjStLaser_SetAngle(laser, ObjMove_GetAngle(object));
          yield;
     }}
?

Change it to

Code: [Select]
task Laser(object){
          let laser = CreateStraightLaserA1( ? );
          while(!Obj_IsDeleted(object)){
                 ObjStLaser_SetAngle(laser, ObjMove_GetAngle(object) + 0.5);
                 yield;
          }
     }
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on December 01, 2015, 09:03:24 PM
Change it to

Code: [Select]
task Laser(object){
          let laser = CreateStraightLaserA1( ? );
          while(!Obj_IsDeleted(object)){
                 ObjStLaser_SetAngle(laser, ObjMove_GetAngle(object) + 0.5);
                 yield;
          }
     }

Also askew..
Laser angle doesn't aiming exactly to shot object.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: zemoo on December 02, 2015, 12:32:11 AM
I've been messing around with PlaySyncBgm. I have a loop of 33 seconds of music with an in game visual cue that loops every 1980 (viz 60*33) frames. With regular music the script lags behind the music, with PlatSyncBgm at 60fps the music is slightly slower than the script,but only on the first loop, it seems to get more accurate with each passing loop. The music stopping is noticeable on 40 fps and for all intents and purposes mutes the audio at 30 fps. As the framerate gets slower it seems to be less accurate It slows the music too much. It sounds like a skipping record so that likely means the skip_param needs to be raised if you expect to go to such extreme lag. I have a very small sample size and I know that all my scripts seem to lag in the first few frames of running which would explain why it is off on the first loop.

I'm a little confused by:
Code: [Select]
if(sdt*60 > skip_param/2){
sdt -= skip_param/60;
ObjSound_Stop(bgm);
c = 0;
}

skip_param/2 : The only thing I can think of is to center the swing of time around sdt=0 and not higher. I don't see why the math would be wrong, this basically just uses GetStageTime to calculate the real fps instead of calling fps. There may be some error in calculating GetStageTime or not enough precision in the system's calculations such that enough time gets lost in the rounding. Also if you raise skip param there are greater local extremes where the music would be off sync. so even if it does stay holistically synced you would be able to notice if it just happened to be at sdt=((skip_param/120)-1) when you have an audio cue and would seem off-sync.

tl:dr Works pretty well at baseline conditions on my comp, much better than before, wouldn't recommend for lag worse than 55 fps. Thanks for the help
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on December 02, 2015, 12:50:32 AM
Yes, the intention is to limit any potential music offsets between the range [-skip_param/2, skip_param/2], rather than [0, skip_param]. This way the average offset is as close to 0 as possible. And yes, skip_param should be raised if it's slowing down enough that it sounds like skipping.

Something playing at 40~30fps sounds completely unusable and I pretty much expected that. Clearly it isn't anything close to normal and you couldn't possibly have a method that could fix it without literally slowing down the music to half speed. I'm going to tentatively guess that because I'm trying to aim for a zero center with regular FPS conditions (~60), what's happening as the FPS gets really low is that more time is spent near the beginning [-skip_param/2, 0] half due to constant resets, and when the music plays it very quickly reaches skip_param/2 and resets again. Maybe look into changing it so that the range really is [0, skip_param] and see if it works for you.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on December 03, 2015, 08:48:31 PM
Good day.
How can I forbid 'backskape' key in Package script?
I want forbid players to retry game with this key method. Only: -> Esc -> Retry.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on December 03, 2015, 09:22:52 PM
Good day.
How can I forbid 'backskape' key in Package script?
I want forbid players to retry game with this key method. Only: -> Esc -> Retry.

As long as you don't explicitly program this functionality in, pressing backspace shouldn't retry the stage.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on December 03, 2015, 10:10:55 PM
As long as you don't explicitly program this functionality in, pressing backspace shouldn't retry the stage.
Pressing "Backspace", stage will always start from the beginning (like a retry)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on December 04, 2015, 04:28:39 AM
Pressing "Backspace", stage will always start from the beginning (like a retry)

This is programmed into the default package, I believe.

Ctrl-F for KEY_BACK in your package and you will find it.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on December 04, 2015, 06:45:03 AM
No that is not the case. Fluffy is right here. The Backspace will never restart a script if you're playing it through package mode. By default it gets disabled. The CTRL function (speed up) doesn't gets disabled, so that needs to be done manually in the package script.

Most likely, Zhan isn't playing/launching his game as a package. Make sure you are.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on December 04, 2015, 09:33:59 AM
no, sparen is right lol (well fluffy is technically right too)

Code: [Select]
if(!IsReplay() && GetKeyState(KEY_BACK) == KEY_PUSH){
TerminateStageScene();
TStageScene("");
return;
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on December 04, 2015, 11:59:44 PM
Where can I find documentation on how to change the magic circle graphic or remove it altogether? I can't seem to find it anywhere. Thanks in advance.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on December 05, 2015, 12:11:43 AM
Ops, sorry.
It was in the Package script, Thank you all.
( I was using Rumia's Package script as a example, and haven't see this function )
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on December 05, 2015, 01:43:34 AM
Where can I find documentation on how to change the magic circle graphic or remove it altogether? I can't seem to find it anywhere. Thanks in advance.

The default magic circle is located in your System file. If you do not specifically state your system file, that defaults to the default system file in your default_system/Default_System. This is calling the script Default_System_MagicCircle.txt.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on December 05, 2015, 03:30:11 AM
Ahh, I see. Thanks! Also, is there a way to rotate a primitive object around its axis? I made a pentagram for my boss that flickers, "breathes" and wobbles behind her slightly, but it looks kind of dull without the pentagram itself rotating as well. ObjMove doesn't seem to work on it. Would I have to register it as some type of object to be able to apply rotation to it? Since ObjRender_SetAngle doesn't really do that, it just spins it in a 3D-ish sort of way.

Thanks again!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on December 05, 2015, 03:59:18 AM
Ahh, I see. Thanks! Also, is there a way to rotate a primitive object around its axis? I made a pentagram for my boss that flickers, "breathes" and wobbles behind her slightly, but it looks kind of dull without the pentagram itself rotating as well. ObjMove doesn't seem to work on it. Would I have to register it as some type of object to be able to apply rotation to it? Since ObjRender_SetAngle doesn't really do that, it just spins it in a 3D-ish sort of way.

Thanks again!

You need to center it at (0, 0, 0) and use ObjMove_SetPosition and ObjMove_SetAngleZ.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on December 05, 2015, 04:07:01 AM
You need to center it at (0, 0, 0) and use ObjMove_SetPosition and ObjMove_SetAngleZ.

Fluffy. You can't use ObjMove functions on primitive objects.

Ahh, I see. Thanks! Also, is there a way to rotate a primitive object around its axis? I made a pentagram for my boss that flickers, "breathes" and wobbles behind her slightly, but it looks kind of dull without the pentagram itself rotating as well. ObjMove doesn't seem to work on it. Would I have to register it as some type of object to be able to apply rotation to it? Since ObjRender_SetAngle doesn't really do that, it just spins it in a 3D-ish sort of way.

Thanks again!

The standard way is to (if you are manually setting vertices), to use trigonometry and apply a transform to each vertex depending on the angle you want. Otherwise, keep in mind that ObjRender_SetAngleXYZ has three separate components that rotate in different axes, with x being side to side, y being front to back, and z being up/down (correct me if I am wrong).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on December 05, 2015, 04:15:39 AM
Fluffy. You can't use ObjMove functions on primitive objects.

Whoops. I mean ObjRender.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on December 05, 2015, 04:45:19 AM
ObjRender_SetAngleXYZ is indeed what you want.

(http://i.imgur.com/zJItehQ.png)

As you can see here, the axis "facing" the screen (normal/perpendicuar to the 2D plane) is the z-axis, so rotating along the z-axis is what you want to be doing.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on December 05, 2015, 11:37:20 AM
Alright, so I've been messing with the Z axis (since I already had something for the X and Y axes that gave the pentagram a slight wobble) but it doesn't seem to really achieve what I want. It kinda looks like I'd have to choose between either the 3D-looking wobble or the 2D rotation, since even a full rotation on the Z axis doesn't really seem to do the job. For the record, here's the task I wrote for the pentagram, maybe I did something that I didn't notice that you guys can see(I ommitted the Z axis line because nothing I tried even got remotely close)

Code: [Select]
task Penta{ // Pentagram to surround her that rotates

let objPen = ObjPrim_Create(OBJ_SPRITE_2D);
let scale = 0.7;
let angle = 180;
let switch = 0.001;

ObjPrim_SetTexture(objPen, cDir ~ "sprite/fx/penta.png");
ObjSprite2D_SetSourceRect(objPen, 0, 0, 256, 256);
ObjSprite2D_SetDestCenter(objPen);
ObjRender_SetBlendType(objPen, BLEND_ALPHA);
Obj_SetRenderPriorityI(objPen, 21);
ObjMove_SetAngularVelocity(objPen, 2);

while(BossLife > 0){
ObjRender_SetPosition(objPen, BossX, BossY, 0);
ObjRender_SetAlpha(objPen, rand_int(155, 255)); // Flickering
ObjRender_SetScaleXYZ(objPen, scale, scale, scale); // Breathing
ObjRender_SetAngleX(objPen, 40 * cos(angle)); // Wobbling/rotating
ObjRender_SetAngleY(objPen, 40 * sin(angle));

angle += 0.5;
scale += switch;
if(scale >= 0.8 || scale <= 0.7){switch *= -1;}

yield;
}


}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on December 05, 2015, 12:18:17 PM
Adding something like ObjRender_SetAngleZ(objPen, angle*6) isn't what you want?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on December 05, 2015, 12:29:07 PM
I expected the answer to be something simple but damn ;_;. That worked perfectly, thanks again!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on December 05, 2015, 03:00:53 PM
I expected the answer to be something simple but damn ;_;. That worked perfectly, thanks again!

When you said it was a primitive, I expected something significantly more complicated. But yeah, what Drake said is *all you need* for 2D sprites.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Bic?- on December 07, 2015, 08:56:07 PM
Hi! I'm a newbie of Danmakufu and this is my first post. Also due to my age, I haven't much knowledge of trigonometry and stuff like that.
So, I have a question:  how do apply gravity to a bullet? I mean, if I shoot a bullet upward, how can I make it go downward.
Like in the Suwako's spell "Froggy Braves the Elements"

Sorry my English by the way-
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on December 07, 2015, 10:41:38 PM
Hi! I'm a newbie of Danmakufu and this is my first post. Also due to my age, I haven't much knowledge of trigonometry and stuff like that.
So, I have a question:  how do apply gravity to a bullet? I mean, if I shoot a bullet upward, how can I make it go downward.
Like in the Suwako's spell "Froggy Braves the Elements"

Sorry my English by the way-

The easiest way to apply gravity to bullets in Danmakufu is to use CreateShotB2 (http://dmf.shrinemaiden.org/wiki/Shot_Functions#CreateShotB2). By giving the bullets a positive y acceleration and no x acceleration, they will fall towards the bottom of the screen.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Bic?- on December 07, 2015, 11:34:31 PM
Ok thanks, got it... It looks gorgeous **
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on December 09, 2015, 08:24:29 AM
Is there any method to unpack dat. files, that were archived by FileArchiver for ph3.
I lost my original scripts.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Paty on December 09, 2015, 08:34:52 AM
Is there any method to unpack dat. files, that were archived by FileArchiver for ph3.
I lost my original scripts.

You can use X-Ripper, but it unpacks them with generic names like "file000, file001", etc.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Bic?- on December 09, 2015, 01:15:11 PM
Here I am again-
I've got another question: how do I switch the HUD to "fullscreen" in a script?

Like this https://youtu.be/t9ICLqUh5vA?t=192 (https://youtu.be/t9ICLqUh5vA?t=192)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on December 09, 2015, 03:52:22 PM
Here I am again-
I've got another question: how do I switch the HUD to "fullscreen" in a script?

Like this https://youtu.be/t9ICLqUh5vA?t=192 (https://youtu.be/t9ICLqUh5vA?t=192)

To 'switch't to fullscreen... requires knowledge of how the System files work as well as a number of other things. Simply put, you will have to set a flag to move to fullscreen, and will then need to gradually change the default clips (for shots, player, etc) as well as a bunch of other things (such as the positioning of your score, etc) in order to reach fullscreen.

If you are new, I suggest not trying this right away, because it will most likely be a source of frustration without knowledge of how sprite lists and text are positioned, etc.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on December 09, 2015, 05:40:45 PM
Is there any place that talks about how to spawn star patterns like Sanae's? I've been looking all over but can't find any. I tried looking at Ultima's MoF script but it kept crashing so I assume it's probably due to the version of the script being too old or something.

I do have an idea of how to spawn them but I'm worried it might be overly complicated. Is there any simple way to spawn them, and if so, could anyone share that?

Thanks!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on December 09, 2015, 06:04:15 PM
Is there any place that talks about how to spawn star patterns like Sanae's? I've been looking all over but can't find any. I tried looking at Ultima's MoF script but it kept crashing so I assume it's probably due to the version of the script being too old or something.

I do have an idea of how to spawn them but I'm worried it might be overly complicated. Is there any simple way to spawn them, and if so, could anyone share that?

Thanks!

The way ZUN does it was to spawn an invisible enemy and move the enemy around changing angles. Of course, we can do it abit differently than that, see the attached file. It isn't exactly how I did it in my old Sanae boss but this should prove to work better than that one anyway.

Here I am again-
I've got another question: how do I switch the HUD to "fullscreen" in a script?

Like this https://youtu.be/t9ICLqUh5vA?t=192 (https://youtu.be/t9ICLqUh5vA?t=192)

Disregarding what sparen said this is pretty simple to do, yes it does require you to modify the default system script (make sure to include this in your script when uploading it for others to play), but the task itself isn't particularly difficult at all for anyone.

You mainly just want to remove all of the HUD and use the SetStgFrame(left,top,right,bottom,min pri, max pri); the min and max priority arguments are 20 and 80 by default. For fullscreen you can use SetStgFrame(0,0,640,480,20,80);, to get the original screen back you use SetStgFrame(32,16,416,464,20,80);. The rest is just removing the HUD elements which are found within the system script, the default system script is located in script/default_system/ folder.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on December 09, 2015, 06:12:20 PM
I see, I had thought of spawning an invisible enemy to do the job as well. I didn't expect this other method though, thanks!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Bic?- on December 09, 2015, 06:24:32 PM
Disregarding what sparen said this is pretty simple to do, yes it does require you to modify the default system script (make sure to include this in your script when uploading it for others to play), but the task itself isn't particularly difficult at all for anyone.

You mainly just want to remove all of the HUD and use the SetStgFrame(left,top,right,bottom,min pri, max pri); the min and max priority arguments are 20 and 80 by default. For fullscreen you can use SetStgFrame(0,0,640,480,20,80);, to get the original screen back you use SetStgFrame(32,16,416,464,20,80);. The rest is just removing the HUD elements which are found within the system script, the default system script is located in script/default_system/ folder.

Oh ok got it, thank you very much.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on December 09, 2015, 07:44:02 PM
Just to make sure though; how does ZUN do it with the invisible enemy? I've been trying and I can't seem to get it to work no matter what I do. I mean maybe it's too advanced and should be saved for later but I didn't expect stars to be this difficult to make.

On that note; is it possible to spawn bullets in a line between two points? Like, let's say I have two enemies standing diagonal from each other across the screen, is it possible to spawn a line of bullets between them? Thanks!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on December 09, 2015, 08:24:54 PM
You can use X-Ripper, but it unpacks them with generic names like "file000, file001", etc.
Good program, but it unpacks only graphics, audio and video. Ok. But I have .txt files too. How to unpack them?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on December 09, 2015, 08:25:24 PM
tween two points? Like, let's say I have two enemies standing diagonal from each other across the screen, is it possible to spawn a line of bullets between them? Thanks!

Yes it is. You take the two enemy positions (or positions in general), and first find the total distance and the angle from the first enemy to the second (using atan2). Then you figure out how many bullets you want to spawn.

If you want to spawn on the enemies as well, the space between bullets will be the total distance divided by (number of bullets - 1). Then start from the first enemy and use a for loop.
Code: [Select]
ascent (i in 0..numbullets) {
    //CreateShot at Enemy1X + i*(totaldistance/numbullets - 1)*cos(angle), Enemy1Y + i*(totaldistance/numbullets - 1)*sin(angle)
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on December 09, 2015, 08:37:17 PM
Ahh, I see. Is there a function for getting the distance between two objects or would I have to make one manually? I vaguely recall reading about something like that in the documentation but I can't seem to find it right now.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on December 09, 2015, 08:58:57 PM
Ahh, I see. Is there a function for getting the distance between two objects or would I have to make one manually? I vaguely recall reading about something like that in the documentation but I can't seem to find it right now.

Use the distance formula, or use http://dmf.shrinemaiden.org/wiki/Other_Functions#GetObjectDistance
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on December 10, 2015, 12:28:27 AM
Ahh, I knew there was one. Thanks!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on December 10, 2015, 02:19:58 AM
Sparen did the same thing I did a while back:

(http://i.imgur.com/6ksesXw.png)

Except "frames" here is the number of bullets - 1 because you want to spawn at 0 too. Don't need an angle to draw a line when you already have the two points that define the line!

Code: [Select]
function bulletLine(x1, y1, x2, y2, n){
let dx = (x2 - x1) / (n - 1);
let dy = (y2 - y1) / (n - 1);
ascent(i in 0..n){
bullet(x1 + i*dx, y1+ i*dy);
}
}

Really this is just a matter of "I don't want to bloat by using distance and trigonometric functions when unneeded". It's still correct but yeah.

EDIT: fixed
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on December 10, 2015, 04:37:31 AM

o_O

I completely forgot that you could do it that way.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on December 10, 2015, 10:41:44 PM
My god I need to brush up on my mathematics. I have no idea what that code does just by reading it.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on December 11, 2015, 07:23:14 AM
dx and dy are the changes in x-position and y-position between each bullet. Takes the x-distance (and y-distance) between the two points (  (|x|) is absolute value of x) difference in x-position (and y-position) between the two points and divides it into n-1 chunks.

Say the second point is 60 pixels to the right from the first point, and 80 pixels downwards, and you want to make 21 bullets. Then dx is 60/20 = 3 and dy is 80/20 = 4, so each bullet is separated by +3 pixels horizontally and +4 pixels vertically. The loop starts by making a bullet at the same position as the first point (x1 + 0*3, y1 + 0*4) = (x1, y1) and it increments to put bullets (+3, +4) away from the first point, (+6, +8) away, (+9, +12) away, and so on until it eventually reaches the second point. You can see by looking at the picture that if you do this it makes a line.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on December 11, 2015, 10:12:13 AM
Actually, the code isn't correct if it uses the absolute value of the difference.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on December 11, 2015, 11:16:13 AM
Uh, yup. My bad.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: koosh_ on December 11, 2015, 04:58:45 PM
Ahhh, I see. That makes a lot of sense, thanks!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on December 11, 2015, 07:21:26 PM
Help  ???
Is there programm that can extract .dat files that where archived by FileArchiver Ph3. There gives programm that could extract pictures and audio. But no one extract .txt files. I have archived some .txt files, and accidentally deleted original one. Help!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on December 12, 2015, 01:52:17 AM
There is no way to get them back, and no one has made an archive dumper for ph3. Never delete your backups and always keep backups for this exact reason.

You could probably do some trick with ObjFile objects and reprint the text from the files in the archive assuming you know the name of them.

Code: [Select]
task TxtExtractor(filepath)
{
let objF = ObjFile_Create(OBJ_FILE_TEXT); // create a text file stream object
ObjFile_Open(objF,filepath); // open the file (not entirely sure if this part will work on archive files but worth a try)
ObjFile_Store(objF); // store the file again, since dnh itself cannot write to files it should make a copy on the HDD
Obj_Delete(objF); // cleanup
}

Tell me if it works since I don't have time to try it myself. If it doesn't then the data will be permanently stored in the archive.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on December 12, 2015, 09:42:25 AM
There is no way to get them back, and no one has made an archive dumper for ph3. Never delete your backups and always keep backups for this exact reason.

You could probably do some trick with ObjFile objects and reprint the text from the files in the archive assuming you know the name of them.

Code: [Select]
task TxtExtractor(filepath)
{
let objF = ObjFile_Create(OBJ_FILE_TEXT); // create a text file stream object
ObjFile_Open(objF,filepath); // open the file (not entirely sure if this part will work on archive files but worth a try)
ObjFile_Store(objF); // store the file again, since dnh itself cannot write to files it should make a copy on the HDD
Obj_Delete(objF); // cleanup
}

Tell me if it works since I don't have time to try it myself. If it doesn't then the data will be permanently stored in the archive.

Unfortunately, it doesn't work. If using <ObjFile_OpenNW>* then it saves empty file, but of course with the same name.
Also thanks a lot for helping!

Edit:Danmkufu ph3 engine could see this .txt files in .dat files
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on December 12, 2015, 10:56:35 AM
and no one has made an archive dumper for ph3.

Not this? (https://www.shrinemaiden.org/forum/index.php?topic=4731.0)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on December 12, 2015, 03:54:15 PM
That was written for 12m, not ph3.


Unfortunately, it doesn't work. If using <ObjFile_OpenNW>* then it saves empty file, but of course with the same name.
Also thanks a lot for helping!

Edit:Danmkufu ph3 engine could see this .txt files in .dat files

Using NW will create a file if one doesn't exist. Before making sure you did this correctly, did you test the function after using the AddArchiveFile() feature? If so, then you are out of luck.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on December 12, 2015, 05:59:06 PM
That was written for 12m, not ph3.


Using NW will create a file if one doesn't exist. Before making sure you did this correctly, did you test the function after using the AddArchiveFile() feature? If so, then you are out of luck.

I did it after AddArchiveFile() too. And many other different way, and nothing works  :( I'm out of luck.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Bic?- on December 16, 2015, 08:20:35 PM
How can I create bullets that are constantly aimed at you? Like in "Fantasy Seal", so to say.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on December 16, 2015, 09:37:17 PM
How can I create bullets that are constantly aimed at you? Like in "Fantasy Seal", so to say.

Pass the bullet ID as a parameter to a task. In that task, have a statement where, while the bullet has not been deleted and the boss is not dead (if applicable), the bullet sets its angle to GetAngleToPlayer(bullet) every x frames. Make sure to yield in @MainLoop as well as in the while loop.

Ex:
Code: [Select]
task BulletCommandsA1(obj) {
    while (!Obj_IsDeleted(obj) && ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
        ObjMove_SetAngle(obj, GetAngleToPlayer(obj));
        yield;
    }
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Bic?- on December 17, 2015, 04:45:02 PM
Pass the bullet ID as a parameter to a task. In that task, have a statement where, while the bullet has not been deleted and the boss is not dead (if applicable), the bullet sets its angle to GetAngleToPlayer(bullet) every x frames. Make sure to yield in @MainLoop as well as in the while loop.

Ex:
Code: [Select]
task BulletCommandsA1(obj) {
    while (!Obj_IsDeleted(obj) && ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
        ObjMove_SetAngle(obj, GetAngleToPlayer(obj));
        yield;
    }
}

And if I want the bullet to stop following the player after like 60 frames, what do I do?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on December 17, 2015, 04:49:51 PM
And if I want the bullet to stop following the player after like 60 frames, what do I do?

Exit the task after 60 frames if it hasn't already.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Vigor (NecroHeart) on December 20, 2015, 09:07:25 AM
I'm wondering why after I running "th_dnh" in th_dnh_ph3
My keyboard somehow won't work, even though I update with the latest version of ph3
And I didn't make any single changes with the config
I still can press Alt F4 to quit from it though...
Besides running "th_dnh", I still can type normally without problems...
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on December 20, 2015, 01:02:03 PM
Hi!
I want to get the X and Y (orat least the ID?) coordinate of any enemy shot deleted by a player shot. But I have no idea how I can do this...
Someone have a simple idea to do this? Or a miracle function I miss?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on December 20, 2015, 02:14:20 PM
Hello there!
I'm really bad at math,but was wondering how to make :
An oval of bullets(I mean their spawn form is oval) rotaiting clockwise
I mean..uhm..like this http://cs631629.vk.me/v631629252/5963/MDqfxQ15VHY.jpg
so bullet's spawn position is 'rotating' clockwise
I hope you understand u-u
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on December 20, 2015, 02:55:20 PM
I don't test it but if you use something like this it didn't work?
Code: [Select]
CreateShotA1(x+R1*cos(a), y+R2*sin(a), speed, angle, graphic, delay;
R1 = r*cos(n);
R2 = r*sin(n);
n++;
Were "r" is the max distance from the center of spawn.

I really don't know if it works or not and if it's clear but I think I search in this direction if I want to do what you want...
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on December 20, 2015, 03:28:36 PM
Hi!
I want to get the X and Y (orat least the ID?) coordinate of any enemy shot deleted by a player shot. But I have no idea how I can do this...
Someone have a simple idea to do this? Or a miracle function I miss?
Depends a bit what context this is and what you're trying to accomplish. If this is intended to be part of a player, you can use an item script to be able to gain access to the EV_DELETE_SHOT events and have fairly good control over the shots you delete. Depending on how you're deleting them you might have an easier method as well.


I'm wondering why after I running "th_dnh" in th_dnh_ph3
My keyboard somehow won't work, even though I update with the latest version of ph3
And I didn't make any single changes with the config
I still can press Alt F4 to quit from it though...
Besides running "th_dnh", I still can type normally without problems...
So, you can't control the characters or even navigate the menus? That sounds strange. Even though you didn't change the config, can you check what config.exe shows in the Key section?


Lefkada: Not quite, the math is a bit more complicated and involves rotation matrices :)
Hello there!
I'm really bad at math,but was wondering how to make :
An oval of bullets(I mean their spawn form is oval) rotaiting clockwise
I mean..uhm..like this http://cs631629.vk.me/v631629252/5963/MDqfxQ15VHY.jpg
so bullet's spawn position is 'rotating' clockwise
I hope you understand u-u
Code: [Select]
// x0 : origin x-coordinate
// y0 : origin y-coordinate
// width, height : size of ellipse
// u : angle of ellipse
// num : number of bullets
ascent(t in 0..360/num){
let x = x0 + width*cos(t*num)*cos(u) - height*sin(t*num)*sin(u);
let y = y0 + width*cos(t*num)*sin(u) + height*sin(t*num)*cos(u);
CreateShotA1(x, y, s, t*num + u, g, d); // s, g, d are same as usual
}

So what you'll want to do with this is set up the ellipse like you want, then loop this while incrementing u each time to rotate the ellipse.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Vigor (NecroHeart) on December 21, 2015, 03:13:04 AM
Quote
So, you can't control the characters or even navigate the menus? That sounds strange. Even though you didn't change the config, can you check what config.exe shows in the Key section?
Not like I can change it neither know how to change it though...
[attach=1]
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on December 21, 2015, 06:32:11 AM
highlight the input you want to change and press a key on your keyboard or a button on your controller to change it
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Vigor (NecroHeart) on December 21, 2015, 10:41:58 AM
highlight the input you want to change and press a key on your keyboard or a button on your controller to change it
I tried it along with several random tries but nothing is changed
Neither I tried pressing all the buttons on keyboard won't navigate me around inside the ph3
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on December 21, 2015, 02:52:25 PM
Does your keyboard have some special settings, features, etc... that can be modified in order to get them to work in dnh? Your issue is very unusual. Remember that dnh uses the legacy DirectX API like alot of indie titles and small games, even worse than just using the visual tools, it uses DirectInput (depreciated by XInput) which may not be compatible with whatever keyboard you have, or whatever features it may support. Just a thought, other than that I have no idea what the problem could be.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on December 22, 2015, 06:34:54 AM

Lefkada: Not quite, the math is a bit more complicated and involves rotation matrices :)
Code: [Select]
// x0 : origin x-coordinate
// y0 : origin y-coordinate
// width, height : size of ellipse
// u : angle of ellipse
// num : number of bullets
ascent(t in 0..360/num){
let x = x0 + width*cos(t*num)*cos(u) - height*sin(t*num)*sin(u);
let y = y0 + width*cos(t*num)*sin(u) + height*sin(t*num)*cos(u);
CreateShotA1(x, y, s, t*num + u, g, d); // s, g, d are same as usual
}

So what you'll want to do with this is set up the ellipse like you want, then loop this while incrementing u each time to rotate the ellipse.
Thank you! x3
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on December 22, 2015, 07:02:29 AM
Does somebody know how to divide lifes/bombs in pieces. Like in last TouhouGames. When you collect 3 life-pieces, You will get one life. I hope somebody understands me  :V
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on December 22, 2015, 07:09:56 AM
Does somebody know how to divide lifes/bombs in pieces. Like in last TouhouGames. When you collect 3 life-pieces, You will get one life. I hope somebody understands me  :V

Use a separate counter for the fragments, and if it reaches a high enough of a value, reset it (subtract it by the required quantity) and give one life.

It is also possible to give fractions of a life, but I don't recommend this method because of precision errors.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on December 22, 2015, 04:04:21 PM
Quote
Depends a bit what context this is and what you're trying to accomplish. If this is intended to be part of a player, you can use an item script to be able to gain access to the EV_DELETE_SHOT events and have fairly good control over the shots you delete. Depending on how you're deleting them you might have an easier method as well.
I want to make a spell bullet that delete Enemy Shots and spawn Player Shot at their positions. I just use the ObjShot_SetEraseShot to delete enemy shots.
It work if I make an item script and if I use it in the player script? It does no issues if there is already an item script running in the main boss script? And how I can get the X and Y of the shot in the player script by using the EV_DELETE_SHOT of the item script (without using common data or tons of endless array)?

edit:
I found another wreid way to do that. Actually i'm using a ring of invisible detection bullets that delete enemy shots and are deleted themself. And when there are deleted, they spawn a player shot and respawn another detection bullet. It's not perfect but it seems it work almost well. But if you have a better way to do that, I'll take it (at least for another case like that).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on December 22, 2015, 06:26:07 PM
It is also possible to give fractions of a life, but I don't recommend this method because of precision errors.

I had mkm fix this in pre6 (not pre6a) before then the live and bomb values in replays would be saved as 32bit integers, now they save as floats. (assuming since that's what everything else uses)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on December 22, 2015, 06:38:24 PM
I had mkm fix this in pre6 (not pre6a) before then the live and bomb values in replays would be saved as 32bit integers, now they save as floats. (assuming since that's what everything else uses)

I meant rounding errors, as in 1/3+1/3+1/3 not being exactly 1.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Failure McFailFace on December 23, 2015, 02:27:02 AM
Can someone explain tasks? I can't find any information anywhere, except for some info for 0.12.

Are they like functions, but they all run at the same time?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on December 23, 2015, 03:35:47 AM
From a technical standpoint, tasks are what is generally known as coroutines. Coroutines are designed to emulate asynchronous-like behavior by pausing the execution of a script function until the next frame, this gives other coroutines (tasks) a chance to run. In danmakufu, the pause is represented by the "yield" keyword.

Yes, tasks work just like functions but you can use them to multitask which is something that is not possible in normal functions as they aren't designed to yield control to another task until the next frame.

Code: [Select]

task DoSomething(x,y)
{
        loop
        {
                CreateShotA1(x,y, ...);
                yield;
        }
}


You can run this as many times as you want, and they will all be running together. Now if you were to change task DoSomething into function DoSomething, you'd notice that only the first one would run, and since it is an infinite loop, any other time you call this function will not be ran because the first instance never ends.

So in short, tasks can run along side other tasks without blocking anything, functions can only be read one at a time and they block execution of anything else until they have finished.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Failure McFailFace on December 23, 2015, 09:00:24 PM
Ah, so pretty much exactly what I'm expecting, then. Thanks!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on December 28, 2015, 10:20:55 AM
Hello again
It's a stupid question
but how can I make multiple bosses?
like,more than one boss appears on the screen?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on December 28, 2015, 10:33:17 AM
You can use a boss object for the main boss and enemy objetcs for the other bosses ;). It works almost the same way.

Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on December 28, 2015, 10:54:41 AM
You can use a boss object for the main boss and enemy objetcs for the other bosses ;). It works almost the same way.

Thanks,I think I got it..

=====================

And how do I make enemies that share 1 lifebar?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on December 29, 2015, 03:20:56 AM
And how do I make enemies that share 1 lifebar?

The quick and dirty way is to place a hitbox on the non-boss enemies while directing the damage to the boss.

Ex:
Code: [Select]
ObjEnemy_SetIntersectionCircleToShot(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 32);
        ObjEnemy_SetIntersectionCircleToPlayer(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 24);
ObjEnemy_SetIntersectionCircleToShot(objBoss, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 32);
        ObjEnemy_SetIntersectionCircleToPlayer(objBoss, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 24);
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on December 30, 2015, 07:54:21 AM
The quick and dirty way is to place a hitbox on the non-boss enemies while directing the damage to the boss.

Ex:
Code: [Select]
ObjEnemy_SetIntersectionCircleToShot(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 32);
        ObjEnemy_SetIntersectionCircleToPlayer(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 24);
ObjEnemy_SetIntersectionCircleToShot(objBoss, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 32);
        ObjEnemy_SetIntersectionCircleToPlayer(objBoss, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 24);

Thanks a lot!
Aslo,I wonder how do I make statement like "if Boss' health is less than (insert number here)" :0
I made this once and forgot how to do it ,_,
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on December 30, 2015, 08:16:41 AM
if(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) < x)
You should already have it in your script to check if the boss isn't dead yet.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on December 30, 2015, 08:35:33 AM
if(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) < x)
You should already have it in your script to check if the boss isn't dead yet.

YAS
thankssss

===========================
Also,I want to make boss stop doing anything,when something happens
So it's interesting to know how to make boss just stop doing anything : tasks and stuff.
Is there an easy way to do that?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on January 01, 2016, 08:16:10 PM
Hi.
I see some peoples using their own curved lasers instead of default laggy&shitty curved lasers. But I don't really understand how it works and how I can do this. Someone have some ideas and can help me? I already watch into custom lasers scripts but It's hard to understand with almost no informations and help.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on January 02, 2016, 12:55:51 PM
Hi all again
I wonder how should I change the timer from 80 to 40 for ex.
ObjEnemyBossScene_SetSpellTimer is not working :u
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lunarethic on January 02, 2016, 12:59:11 PM
Hi.
I see some peoples using their own curved lasers instead of default laggy&shitty curved lasers. But I don't really understand how it works and how I can do this. Someone have some ideas and can help me? I already watch into custom lasers scripts but It's hard to understand with almost no informations and help.
Well sometimes people create their own by using Object Lasers and build it off from there , or another option is a trail of (ADD) bullets instead which is much harder and could potentially lag, it's just a matter of imagination i guess
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 02, 2016, 04:48:53 PM
Hi all again
I wonder how should I change the timer from 80 to 40 for ex.
ObjEnemyBossScene_SetSpellTimer is not working :u
Wrong function and code. You need EV_REQUEST_TIME see here:
Code: [Select]
@Event {
alternative(GetEventType())
case(EV_REQUEST_LIFE) {
SetScriptResult(x);
}
case(EV_REQUEST_TIMER) {
SetScriptResult(y);
}
case(EV_REQUEST_SPELL_SCORE) {
SetScriptResult(z);
}
}

I was quite surprised with this question, it is basic stuff actually.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on January 02, 2016, 04:56:55 PM
Wrong function and code. You need EV_REQUEST_TIME see here:
Code: [Select]
@Event {
alternative(GetEventType())
case(EV_REQUEST_LIFE) {
SetScriptResult(x);
}
case(EV_REQUEST_TIMER) {
SetScriptResult(y);
}
case(EV_REQUEST_SPELL_SCORE) {
SetScriptResult(z);
}
}

I was quite surprised with this question, it is basic stuff actually.

((9
I know thisss
I mean I need to change the timer WHILE spellcard is active
like,suddenly change the timer
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 02, 2016, 07:51:16 PM
((9
I know thisss
I mean I need to change the timer WHILE spellcard is active
like,suddenly change the timer
Well, you didn't exactly say that in your original post.

I don't think you can even freeze / re-edit the timer.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Chronojet ⚙ Dragon on January 02, 2016, 09:12:13 PM
Well, you didn't exactly say that in your original post.

I don't think you can even freeze / re-edit the timer.

Instead of using the real timer, why not just avoid setting the default timer ? It will default to infinite time remaining, and you can then use your own custom timer with multiple variables. You will have to set a "spellcard get" score manually however.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on January 02, 2016, 09:30:44 PM
Instead of using the real timer, why not just avoid setting the default timer ? It will default to infinite time remaining, and you can then use your own custom timer with multiple variables. You will have to set a "spellcard get" score manually however.

Eeeeeh?Custom timers?
jeez
never thought of that
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Shadow on January 03, 2016, 02:07:54 AM
You can in fact edit the timer via ObjEnemyBossScene_SetSpellTimer. I've only used it to freeze the timer, however, so I don't know if it'll be able to accomplish what you want, but theoretically it should be able to suit your needs.

EDIT: Seems like you've tried using this before, so I'll clarify. The function's parameters are 1. the object ID of the Boss Scene, and 2. the timer itself, in frames. You can use GetEnemyBossSceneObjectID to retrieve the Boss Scene ID, so changing the timer from 80 seconds to 40 seconds is just a matter of calling ObjEnemyBossScene_SetSpellTimer(GetEnemyBossSceneObjectID,60*40).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on January 03, 2016, 02:21:47 AM
1) It's a boss scene function, so the first parameter has to be the scene object, not the enemy object
2) The time given is in frames, not seconds
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on January 03, 2016, 07:57:51 AM
Thank you all!
I've got it
Now it's working -u-
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on January 03, 2016, 06:53:40 PM
Quote
Well sometimes people create their own by using Object Lasers and build it off from there , or another option is a trail of (ADD) bullets instead which is much harder and could potentially lag, it's just a matter of imagination i guess
I see almost how to do with bullets but with Object Lasers? How can I do this (without using actual CreateCurveLaserA1)?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lunarethic on January 03, 2016, 07:22:12 PM
I see almost how to do with bullets but with Object Lasers? How can I do this (without using actual CreateCurveLaserA1)?
Doing it with lasers , is just the same as trailing bullets but the "tip" is a small object curvy laser that leaves more lasers making it seems like a curvy laser but its actually just trailing, you can make the tip and the trail as an object if you really dont want to use default functions
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on January 03, 2016, 07:57:26 PM
Okay. I never thought I can use lasers (loose lasers i guess?). But it don't cause more fps drops with long lasers than with bullet trail?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lunarethic on January 04, 2016, 12:37:26 AM
Okay. I never thought I can use lasers (loose lasers i guess?). But it don't cause more fps drops with long lasers than with bullet trail?
A laser leaving a trail of lasers that are like 10 in length Shouldn't cause fps drops , just try to make sure those trails get deleted afterwards
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 06, 2016, 11:57:15 PM
Just curious: how to let the player start a replay at an arbitrary stage (like all of the official Touhou games from EoSD, as well as PoIB)? Obviously, that would require saving stats for each stage, but what else, then, to get to the keypresses recorded at the correct stage? Do they simply discard the first n frames of the file?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on January 07, 2016, 05:47:26 AM
Danmakufu has that feature built in. Use SetStageIndex() and load the correct stage. The Score, Graze, etc... is already recorded per stage
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Uruwi on January 07, 2016, 06:24:30 AM
Danmakufu has that feature built in. Use SetStageIndex() and load the correct stage. The Score, Graze, etc... is already recorded per stage

CommonData is recorded as well, right?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sage Ω (Ultima) on January 07, 2016, 07:42:43 AM
Use the Load/SaveAreaCommonDataToReplay functions
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on January 07, 2016, 01:20:38 PM
Hello you guys
I wonder how should I make a statement for collision of two obj bullets if they are in different tasks,like :

Code: [Select]
task bullet1{
let obj1=.....
stuff;
}


task bullet2{
let obj2=.....
stuff;
}


Just danmakufu  doesn't see one of these IDs
I hope you understand :V
Or how should I make an bullet ID that I can use in other tasks?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on January 07, 2016, 01:59:55 PM
Before you get into implementing this, what exactly is the pattern you're trying to make with this?

How complicated it gets comes down to whether one set of objects, both, or neither, will be changing (i.e. adding more or deleting some) throughout the pattern. If you have one set of objects where they just maybe move around without leaving the screen and the other is a bunch of bullets that are fired and then deleted, then that's easier than having two different sets of bullets where both of them are very dynamic and changing all the time.

In any case, here's the general outline for something like this:

Code: [Select]
function ObjectA(){
    let objA = ObjSomething_Create();
    // initialize objA
    task DoStuffA(objA){
        while(!Obj_IsDeleted(objA)){
            // running object behaviour
            yield;
        }
    }
    DoStuffA(objA);
    return objA;
}

function ObjectB(){
    let objB = ObjSomething_Create();
    // initialize objB
    task DoStuffB(objB){
        while(!Obj_IsDeleted(objB)){
            // running object behaviour
            yield;
        }
    }
    DoStuffB(objB);
    return objB;
}

let objA1 = ObjectA();  // makes an A object and puts its object ID into this variable
let objB1 = ObjectB();  // makes a B object and puts its object ID into this variable

// do things with both objA1 and objB1

If you have multiple instances of objA and objB (which is likely) you would make an array for each and add to the array for new objects, like

Code: [Select]
let listA = [];
let listB = [];
loop(m){
    listA = listA ~ [ObjectA()];
}
loop(n){
    listB = listB ~ [ObjectB()];
}

And then work with those arrays. However when you might want to add and delete stuff from the arrays a lot, that's where things get complicated, which is why it's important to know if your problem can be simplified somewhat (which is pretty likely).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: BobTheTanuki on January 07, 2016, 02:08:41 PM
Well,I have rings of bullets(just a ring fired several time) and after some time there is another ring of different bullets
And all I want to do is :  these different bullets gonna do some stuff to the first ones when they go near them :derp:
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: DemonSorcerer on January 08, 2016, 02:03:32 PM
Here's the code I'm using:  http://pastebin.com/rjGhW2aX (http://pastebin.com/rjGhW2aX)

I'm new to Danmakufu. I'm using Sparen's tutorial (http://sparen.github.io/ph3tutorials/ph3u1l8a.html (http://sparen.github.io/ph3tutorials/ph3u1l8a.html)), but on the part of replicating Eternal Meek, something seems wrong. For all other scripts it works fine, however, when I try to replicate Eternal Meek, it says GetCenterX is undefined, same for any other task and function. It works for every other script, but for this one it doesn't. I tried putting the tasks and functions on the top of the script and now there's no error about stuff not being defined, but now it says there should be a } before wait(120);. However, if I add that, it'll point to MainTask's end } and say it's unable to be interpreted.

Can anyone tell me if I'm doing something wrong and how I should fix it? Yes, I did check if everything is spelled right; yes, I did check if there's the same amounts of {'s and }'s. And no, those errors don't seem to be happening on any other scripts.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on January 08, 2016, 02:23:00 PM
Well, check the line before that wait(120) again. It's line 19.

In the future, these sorts of one-off questions generally go in the stickied ph3 Q&A threads (https://www.shrinemaiden.org/forum/index.php/topic,16584.0.html).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: DemonSorcerer on January 08, 2016, 03:02:23 PM
Well, check the line before that wait(120) again. It's line 19.

In the future, these sorts of one-off questions generally go in the stickied ph3 Q&A threads (https://www.shrinemaiden.org/forum/index.php/topic,16584.0.html).

I'm sorry, I didn't notice I forgot the ; at the end of that line. Anyways, fixed now.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on January 08, 2016, 07:26:14 PM
Quote from: Lunar
A laser leaving a trail of lasers that are like 10 in length Shouldn't cause fps drops , just try to make sure those trails get deleted afterwards
You use LooseLasers or StraightLasers to make the trail?
I try with LooseLasers but they need a speed or they don't have any sprite. But with speed... I don't know how I can make a decent trail.
With StraightLasers It's better but I get stripped and blur effect at the end of the trail.
Anyway, I can't get a curved laser close to ZUN's one :(.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on January 11, 2016, 08:05:25 PM
Good day.
Sorry for the stupid question.
But how could I indicate in #Player[ ? ] more than one player?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on January 11, 2016, 08:55:56 PM
#Player["player1_path", "player2_path", "etc"].

Juste use a , between every path ;).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on January 12, 2016, 06:48:47 PM
#Player["player1_path", "player2_path", "etc"].

Juste use a , between every path ;).

Thanks! It's working!  :)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Miplouf Saigyouki on January 14, 2016, 08:20:25 PM
Hello, i'd like to know how to use
Code: [Select]
#ID[YourScriptIDHere]in the header, and know if I can use it to trigger certain events in stage,like:
Code: [Select]
if(GetOwnScriptID()=="MIDBOSS"){ stuff;}
I've been trying to do so, but without success.Can somebody help?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 14, 2016, 11:37:34 PM
Hello, i'd like to know how to use
Code: [Select]
#ID[YourScriptIDHere]in the header, and know if I can use it to trigger certain events in stage,like:
Code: [Select]
if(GetOwnScriptID()=="MIDBOSS"){ stuff;}
I've been trying to do so, but without success.Can somebody help?

#ID is meant for player scripts, I believe. It takes the form of a user-defined string.

GetOwnScriptID() is a function that gets the internal identification code for the current script.

If you want to have events in-stage, please use @Event and NotifyEvent (http://dmf.shrinemaiden.org/wiki/Script_Functions#NotifyEvent) in conjunction with EV_USER.

Miransu's EV_USER guide: http://dmf.shrinemaiden.org/wiki/Miransu%27s_EV_USER_Guide

For all the script functions, please refer to http://dmf.shrinemaiden.org/wiki/Script_Functions
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Miplouf Saigyouki on January 15, 2016, 09:34:50 PM
Thanks a lot!
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: iVAwalys on January 23, 2016, 09:32:36 PM
hello im pretty fresh here  :V

I tried figuring this out for such a long time, to no avail: How do I make bullets spawn in a circle (or any other pattern) continuously, similarly to this (https://www.youtube.com/watch?v=_j-yefQtzmA)?
This definitely probably is a noob question, but that's because I'm quite new to Danmakufu.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 24, 2016, 12:30:39 AM
hello im pretty fresh here  :V

I tried figuring this out for such a long time, to no avail: How do I make bullets spawn in a circle (or any other pattern) continuously, similarly to this (https://www.youtube.com/watch?v=_j-yefQtzmA)?
This definitely probably is a noob question, but that's because I'm quite new to Danmakufu.

If you want a pattern to fire continuously, use a while loop where the while condition is whether or not the boss has more than 0 HP. Make sure you have at least one yield; in the while loop, and a yield in @MainLoop.

As for the circle, use standard trigonometry to fire the bullets. For example, if I want a circle with 5 bullets in it and a radius of 60, I would do
Code: [Select]
loop(5){
    CreateShotA1(ObjMove_GetX(objBoss) + 60*cos(angleT), ObjMove_GetY(objBoss) + 60*sin(angleT), 1, angleT, 1, 0);
    angleT += 360/5;
}

where angleT is the starting angle to fire at.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: iVAwalys on January 24, 2016, 10:09:44 AM
If you want a pattern to fire continuously, use a while loop where the while condition is whether or not the boss has more than 0 HP. Make sure you have at least one yield; in the while loop, and a yield in @MainLoop.

As for the circle, use standard trigonometry to fire the bullets. For example, if I want a circle with 5 bullets in it and a radius of 60, I would do
Code: [Select]
loop(5){
    CreateShotA1(ObjMove_GetX(objBoss) + 60*cos(angleT), ObjMove_GetY(objBoss) + 60*sin(angleT), 1, angleT, 1, 0);
    angleT += 360/5;
}

where angleT is the starting angle to fire at.

But that would make all the bullets spawn at the same time.
What I'm trying to do is spawn the bullets one at a time around the boss, just like in Satellite Himawari.


I'm thinking it might work like this, but I could be wrong:

Code: [Select]
CreateShotA1(x, y, 3, 60, 1, 10) //x and y are values increasing or decreasing every frame, depending on the timing
If I time it right, could I potentially make a circle one bullet at a time?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 24, 2016, 11:12:05 AM
What you're looking for is delaying the looping code for the circular spawn by adding a "wait" for 1 frame or more. See the following:

Will spawn 36 bullets in a circle instantly.
Code: [Select]
loop(36) {
CreateShotA1(x+r*cos(dir),y+r*sin(dir),v,dir,type,delay);
dir+=360/36;
}

Will spawn 36 bullets in a circle, but each bullet spawns with 1-frame delay (at 60fps).
Code: [Select]
loop(36) {
CreateShotA1(x+r*cos(dir),y+r*sin(dir),v,dir,type,delay);
dir+=360/36;
yield;   // Added a yield for 1-frame delay
}
I typed only variables because you decide the rest. r = radius.

You probably want to use the 2nd one if I judge your post. The more frame-delay, the slower the circle is formed.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: iVAwalys on January 24, 2016, 04:00:58 PM
Tried it out, and it's not really what I'm looking for...

Referring to Satellite Himawari again. See how the places where the bullets spawn kind of circle around Patchouli, instead of creating one, singular ring at the same time? That's what I'm looking for.

Sorry if I'm being bothersome, I just can't get this to work at all...
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Helepolis on January 24, 2016, 04:57:03 PM
Tried it out, and it's not really what I'm looking for...

See how the places where the bullets spawn kind of circle around Patchouli, instead of creating one,
And that is exactly achieved with delaying the loop for spawning such a circle per frame.
[attach=1]


You know, you might want to actually show us some code in pastebin, so we can see what you're doing. This is going nowhere to be honest.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 24, 2016, 04:58:10 PM
Tried it out, and it's not really what I'm looking for...

Referring to Satellite Himawari again. See how the places where the bullets spawn kind of circle around Patchouli, instead of creating one, singular ring at the same time? That's what I'm looking for.

Sorry if I'm being bothersome, I just can't get this to work at all...

Well, I didn't want to give you the entire thing, but w/e
Code: [Select]
while(!Obj_IsDeleted(objBoss){
    loop(2){
        CreateShotA1(ObjMove_GetX(objBoss) + 60*cos(angleT), ObjMove_GetY(objBoss) + 60*sin(angleT), 1, angleT, 1, 0);
        angleT += 360/2;
    }
    angleT+=2.6; //angle to increment each time. Should not divide into 360
    wait(2);
}
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: iVAwalys on January 24, 2016, 05:19:59 PM
Well, I didn't want to give you the entire thing, but w/e
Code: [Select]
while(!Obj_IsDeleted(objBoss){
    loop(2){
        CreateShotA1(ObjMove_GetX(objBoss) + 60*cos(angleT), ObjMove_GetY(objBoss) + 60*sin(angleT), 1, angleT, 1, 0);
        angleT += 360/2;
    }
    angleT+=2.6; //angle to increment each time. Should not divide into 360
    wait(2);
}

Oh my lord, it worked! Thank you so very much!!
The problem was, I wasn't increasing the value of angleT... The moment I put "angleT++;" in @MainLoop, it magically started working. :getdown:
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Asthmagician on January 24, 2016, 06:10:20 PM
I've been looking through Danmakufu's default system functions and messing with them, and I've hit a problem.
Where do I tell a script to use a different pause script to the default?
Is a specific kind of script needed? (e.g. stage/package)
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Sparen on January 24, 2016, 08:01:46 PM
I've been looking through Danmakufu's default system functions and messing with them, and I've hit a problem.
Where do I tell a script to use a different pause script to the default?
Is a specific kind of script needed? (e.g. stage/package)

Use this function: http://dmf.shrinemaiden.org/wiki/Private_System_Functions#SetPauseScriptPath (http://dmf.shrinemaiden.org/wiki/Private_System_Functions#SetPauseScriptPath)

I put it in @Initialize of my System file.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: iVAwalys on January 28, 2016, 06:49:16 PM
EDIT: Alright, nevermind. Figured it out myself...
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Asthmagician on January 29, 2016, 03:31:52 PM
iVAlways: I think it'd be a good idea to leave the question up and edit in how you answered it for the sake of others scrolling / searching this thread looking for answers.
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on January 29, 2016, 08:38:15 PM
Help please.
How should I connect two objects (for example: GetObjectDistance( obj1, obj2 ); when both of objects are in different loops?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on January 29, 2016, 09:49:36 PM
Use CommonData to get all the parametters about the objects you need?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Drake on January 30, 2016, 02:24:51 AM
Help please.
How should I connect two objects (for example: GetObjectDistance( obj1, obj2 ); when both of objects are in different loops?
See my post last page:
https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1230565.html#msg1230565

The answer is essentially, define the variables that store the object IDs in a scope accessible by both loops. If your loops create your objects and assign it some behavior, do like I write in that post where you wrap the "behavior" task in a function that returns the new object.

Again, the level of detail changes depending on your actual problem. How many objects? Are they created and deleted often?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on January 30, 2016, 08:31:04 AM
See my post last page:
https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1230565.html#msg1230565

The answer is essentially, define the variables that store the object IDs in a scope accessible by both loops. If your loops create your objects and assign it some behavior, do like I write in that post where you wrap the "behavior" task in a function that returns the new object.

Again, the level of detail changes depending on your actual problem. How many objects? Are they created and deleted often?

I did completly what you write on that post (before that). But problem is loop. I need a ring of bullets. That means:
Code: [Select]
function ObjectA(){
    ascent( i in 0..10){ // for example creating rings, but naturally this will wrong, because id will not return
        let objA = ObjSomething_Create();
    }
    // initialize objA
    task DoStuffA(objA){
        while(!Obj_IsDeleted(objA)){
            // running object behaviour
            yield;
        }
    }
    DoStuffA(objA);
    return objA;
}
that's why I made than this
Code: [Select]
task TShot{
   ascent(i in 0..10){
      let obj = ObjectA(); //Creating rings, but id is again in the loop.
   }
}
Is it possible to get this id out or something like that?
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Lefkada on January 30, 2016, 09:19:54 AM
Maybe I'm wrong but if I understand, in your function you create a ring of 10 bullets and then, in the task, you repeat 10 time the same ring of bullets?
If you want just a ring of bullet, you don't need one of the two ascent I think. Of maybe I just don't understand what you want to do...

Or if you really want to use the two ascent, can you do something like that?

Code: [Select]
function ObjectA(){
    let objA = ObjSomething_Create();
    // initialize objA
    task DoStuffA(objA){
        while(!Obj_IsDeleted(objA)){
            // running object behaviour
            yield;
        }
    }
    DoStuffA(objA);
    return objA;
}
and then, if the task
Code: [Select]
task TShot{
   ascent(i in 0..10){
      ascent(j in 0..10){
         let obj = ObjectA(); //Creating rings, but id is again in the loop.
      }
   }
}
You do the function's ascent with ascent (i in 0..10) and then, the task's ascent with ascent (j in 0..10).
Title: Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
Post by: Jean Fox on January 30, 2016, 09:33:50 AM
Maybe I'm wrong but if I understand, in your function you create a ring of 10 bullets and then, in the task, you repeat 10 time the same ring of bullets?
If you want just a ring of bullet, you don't need one of the two ascent I think. Of maybe I just don't understand what you want to do...

Oh, Sorry my English is not clear?
I want to connect two objects (like for example GetObjectDistance(obj1,obj2) ), but both objects are in different loop making rings. With SetCommonData (as you said before) I have no imagination how could I do that.