Maidens of the Kaleidoscope

~Hakurei Shrine~ => Rika and Nitori's Garage Experiments => Topic started by: Helepolis on January 30, 2016, 12:51:16 PM

Title: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on January 30, 2016, 12:51:16 PM
Welcome to the Question and Answer (or any problem/help me) thread for Danmakufu

Important notice (26-04-2016): This thread will function as the general Danmakufu Q&A from this point on
As we all know, 0.12m is heavily outdated. It has become ancient :V So far, we've been keeping two threads to help people with their questions or problems. However, Ph3 is no longer considered scary or difficult as we got a skilled community with various people to help out. It is time to move on and leave 0.12m alone.

If you have 0.12m questions (because of old scripts and such), feel free to ask them in here.





Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on January 30, 2016, 02:23:21 PM
Last ongoing question by Zhan_Fox   (https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1234122.html#msg1234122) which had started here (https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1234032.html#msg1234032). Below a guote from the last post.

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.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 31, 2016, 07:52:25 AM
I was waiting for an elaboration because I'm pretty sure my last post (https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1230565.html#msg1230565) needed a concrete example.

Code: [Select]
let listA = [];
let listB = [];

// note that this is specifically a function, which creates and sets up a single object we want
function ObjectA(y){
    // create and initialize the object
    let objA = CreateShotA1(20, y, 1, 25, DS_BALL_S_RED, 20);
    // task *within* a function, which keeps running even when the function returns
    task DoStuffA(){
        // running loop
        while(!Obj_IsDeleted(objA)){ 
            // in this example, A bullets change color when they collide with B bullets
            let collision = false;
            ascent(i in 0..length(listB)){
                if(GetObjectDistance(objA, listB[i]) < 20){
                    ObjShot_SetGraphic(objA, DS_BALL_S_BLUE);
                    collision = true;
                    break;
                }
            }
            if(!collision){
                ObjShot_SetGraphic(objA, DS_BALL_S_RED);
            }
            yield;
        }
    }
    // run the above task
    DoStuffA();
    // return the object ID you just created to store it in a variable with higher scope
    return objA;
}

// similar to above
function ObjectB(y){
    let objB = CreateShotA1(364, y, 1, 155, DS_BALL_S_RED, 20);
    task DoStuffB(){
        while(!Obj_IsDeleted(objB)){
        let collision = false;
            ascent(i in 0..length(listA)){
                if(GetObjectDistance(objB, listA[i]) < 20){
                    ObjShot_SetGraphic(objB, DS_BALL_S_BLUE);
                    collision = true;
                    break;
                }
            }
            if(!collision){
                ObjShot_SetGraphic(objB, DS_BALL_S_RED);
            }
            yield;
        }
    }
    DoStuffB();
    return objB;
}

ascent(i in 0..10){
    listA = listA ~ [ ObjectA(20+i*20) ]; // creates ten of the ObjectA bullets
    listB = listB ~ [ ObjectB(20+i*20) ]; // creates ten of the ObjectB bullets
    loop(10){yield;}
}

There are better ways to code this particular example, but hopefully this illustrates my previous post. Note that both A objects and B objects are created in different function scopes and have different behaviour, but still reference each other. The functions that create the objects return their IDs, so you can store the object IDs using variables declared in higher scopes (so they're more accessible). The tasks within each function still run independently of each other, even though the function surrounding it returns.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on January 31, 2016, 08:56:14 AM
I was waiting for an elaboration because I'm pretty sure my last post needed a concrete example.

Code: [Select]
let listA = [];
let listB = [];

function ObjectA(y){
    let objA = CreateShotA1(20, y, 1, 25, DS_BALL_S_RED, 20);
    task DoStuffA(){
        while(!Obj_IsDeleted(objA)){
            let collision = false;
            ascent(i in 0..length(listB)){
                if(GetObjectDistance(objA, listB[i]) < 20){
                    ObjShot_SetGraphic(objA, DS_BALL_S_BLUE);
                    collision = true;
                    break;
                }
            }
            if(!collision){
                ObjShot_SetGraphic(objA, DS_BALL_S_RED);
            }
            yield;
        }
    }
    DoStuffA();
    return objA;
}

function ObjectB(y){
    let objB = CreateShotA1(364, y, 1, 155, DS_BALL_S_RED, 20);
    task DoStuffB(){
        while(!Obj_IsDeleted(objB)){
        let collision = false;
            ascent(i in 0..length(listA)){
                if(GetObjectDistance(objB, listA[i]) < 20){
                    ObjShot_SetGraphic(objB, DS_BALL_S_BLUE);
                    collision = true;
                    break;
                }
            }
            if(!collision){
                ObjShot_SetGraphic(objB, DS_BALL_S_RED);
            }
            yield;
        }
    }
    DoStuffB();
    return objB;
}

ascent(i in 0..10){
    listA = listA ~ [ ObjectA(20+i*20) ]; // creates ten of the ObjectA bullets
    listB = listB ~ [ ObjectB(20+i*20) ]; // creates ten of the ObjectB bullets
    loop(10){yield;}
}

There are better ways to code this particular example, but hopefully this illustrates my previous post. Note that both A objects and B objects are created in different function scopes and have different behaviour, but still reference each other. The functions that create the objects return their IDs, so you can store the object IDs using variables declared in higher scopes (so they're more accessible). The tasks within each function still run independently of each other, even though the function surrounding it returns.

WOW! IT'S WORKING!
I never would have guessed to do like that.
Thank you! My superhero!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on February 05, 2016, 10:57:35 PM
2 questions.

1. How to do a magic circle (the circles that spin around the boss)
2. How to spawn familiars
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 06, 2016, 05:49:58 AM
2 questions.

1. How to do a magic circle (the circles that spin around the boss)
2. How to spawn familiars

1. Depends on what you want. The built-in system uses a primitive object with a large number of vertices. You can also use a 2D sprite (or multiple 2D sprites) instead of a primitive.
2. Depends on what you mean by 'familiar'. If they have life bars, implement them as Obj_Enemy. If they do not have life bars, you can use 2D sprites and control their movement and positioning using trigonometry.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on February 06, 2016, 10:18:28 AM
Since someone asked me to explain how I made the following code work, and since the old thread has reached its limit, I couldn't edit it, so I'm posting it here:

Basically, this line of code was supposed to spawn a circle of bullets out of a bigger bullet if it reaches the sides of the screen:
Code: [Select]
task BulletCommandExplosions(shot){
let rx = ObjMove_GetX(shot);
let ry = ObjMove_GetY(shot);
let angleR = rand(0, 360);
while(rx > 0 && rx < GetStgFrameWidth){yield;}
if(rx <= 0){
loop(12){
CreateShotA2(rx, ry, 4, angleR, -0.1, 1, rand(30,32), 10);
CreateShotA2(rx, ry, 4, angleR, -0.1, 1, rand(30,32), 10);
ObjShot_SetDeleteFrame(shot, 0);
angleR += 360/12;}
}
if(rx >= GetStgFrameWidth){
loop(12){
CreateShotA2(rx, ry, 4, angleR, -0.1, 1, rand(30,32), 10);
CreateShotA2(rx, ry, 4, angleR, -0.1, 1, rand(30,32), 10);
ObjShot_SetDeleteFrame(shot, 0);
angleR += 360/12;}
}
}
However, the bullets exploded instantly after being spawned. So, why didn't it work? It was a mistake to put while(rx > 0 && rx < GetStgFrameWidth){yield;} so far in the task. I just needed to put it one line after the task is declared, and it started to work!
And, after a few tweaks and fixes to prevent 0,0 spawning, I finally got my explosions.
Code: [Select]
task BulletCommandExplosionsSide(shot){
while(ObjMove_GetX(shot) > 20 && ObjMove_GetX(shot) < GetStgFrameWidth-20){yield;}
        // Replace Width with Height and GetX with GetY if you want it to explode if it touches the upper and lower screen instead of the sides.
let rx = ObjMove_GetX(shot);
let ry = ObjMove_GetY(shot);
let angleR = rand(0,360);
if(rx <= 20&&!Obj_IsDeleted(shot)){
        // Replace rx with ry if you want it to explode if it touches the upper and the lower screen instead of the sides.
loop(14){
CreateShotA2(rx, ry, 4, angleR, -0.1, 1, rand(30,32), 5);
ObjShot_SetDeleteFrame(shot, 5);
angleR += 360/14;}
}
if(rx >= GetStgFrameWidth-20&&!Obj_IsDeleted(shot)){
        // Replace Width with Height if you want it to explode if it touches the upper and the lower screen instead of the sides.
loop(14){
CreateShotA2(rx, ry, 4, angleR, -0.1, 1, rand(30,32), 5);
ObjShot_SetDeleteFrame(shot, 5);
angleR += 360/14;}
}
}
And just wanted to point out, the "3" in the thread title is in Arabic, while the "II" in the old was in Greek. Just a meaningless observation.
also, yes, i did edit my post that many times because why not do everything wrong
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on February 06, 2016, 07:00:49 PM
How do you make bullets fire not in a ring, but in a square?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on February 06, 2016, 07:40:33 PM
How do you make bullets fire not in a ring, but in a square?

Here. (http://www.wolframalpha.com/input/?i=polar+equation+of+a+line)

Create four line segments for a square.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 07, 2016, 06:17:56 AM
Um, that Wolfram link doesn't exactly give anything useful over here (misinterpreted query?), and even if it gave some equations it isn't necessarily obvious how you would implement it to do what you want, and that's still assuming they could follow the math required.



Where you start is that you want to get a line segment that describes one side. For a square this could be a line between points (1,0) and (0,1), but I'm continuing with general regular polygons. We're going to draw an n-sided polygon inside of the unit circle (radius is 1). Since going all the way around the circle is 360 degrees, splitting that into n sides means each corner is at a multiple of 360/n degrees. Since these corner points are supposed to lie on the unit circle, the first corner's coordinates are (cos(360/n), sin(360/n)), so the first side will be a line segment from (1,0) to (cos(360/n), sin(360/n)) (see here, which is one side of a triangle, n=3 (http://www.wolframalpha.com/input/?i=line+segment+from+%281,0%29+to+%28cos%28360%2F3+deg%29,+sin%28360%2F3+deg%29%29)). Note that if n=4 for a square, (cos(360/n), sin(360/n)) = (cos(90), sin(90)) = (0,1).

Now you can convert this line to polar coordinates (which I didn't work through myself), and this ends up with r = cos(180/n) / cos(angle - (180/n)). However, this is only what we want for the single side, with angles from 0 to 360/n (see here (http://www.wolframalpha.com/input/?i=polar+plot+r+%3D+cos%28180%2F4+deg%29%2Fcos%28theta-%28180%2F4+deg%29%29,+theta%3D0+to+360%2F4+deg)). If you keep increasing the angle past that, the value for the radius r you get just keeps increasing, which is useless (see here (http://www.wolframalpha.com/input/?i=polar+plot+r+%3D+cos%28180%2F4+deg%29%2Fcos%28theta-%28180%2F4+deg%29%29,+theta%3D0+to+120+deg)). But the first side's angles work, so you can make sure you get the same radii for the other sides as the first side by throwing in a modulo (so the radius for angle=360/n+1 is the same as for angle=1, etc).
The equation is then r = cos(180/n) / cos((angle % (360/n)) - (180/n)). You can see this working here (http://www.wolframalpha.com/input/?i=polar+plot+r+%3D+cos%28180%2Fn+deg%29%2Fcos%28%28theta+mod+%28360%2Fn+deg%29%29-%28180%2Fn+deg%29%29,+theta%3D0+to+360+deg,+n%3D4). Change the n=4 at the end to other values for different polygons.

Soooo, what this gives you is a base unit. You can think of the radius r values as the required speed for a bullet moving at a given angle, so that the overall shape moves at a speed of 1. If you want to rotate the shape, just change the angle in the equation to (angle - offset) instead.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on February 07, 2016, 05:04:14 PM
Thanks!

But how would you shoot it? Can I have a code example from an actual script?

(Wow, I need to brush up on my advanced math skills)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 07, 2016, 05:15:39 PM
Thanks!

But how would you shoot it? Can I have a code example from an actual script?

(Wow, I need to brush up on my advanced math skills)

This depends on how you want to spawn the bullets. If you want to spawn the actual shape, then do as Drake said, calculating the x and y coordinates to spawn the bullet at. If you want to fire a shape from the boss (rather than spawning the shape around the boss), then that's going to require a slightly different type of math.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 08, 2016, 02:48:46 AM
No, either way is fine, and I was actually specifically looking at shooting the shape outwards. Because this is already done in polar coordinates, it uses an angle (which you're already going to loop through just as though you were shooting a circle), and a "radius", which is given by the above equation. Like I wrote in the last post, you can interpret this radius as a speed and just plug it in, multiplying it for a faster shape. Basically "increase the radius of the shape by speed each frame".

Code: [Select]
function CreateShotShapeOA1(obj, sides, gap, speed, angle_off, graphic, delay){
let x = ObjMove_GetX(obj);
let y = ObjMove_GetY(obj);
let t = 0;
while(t < 360){
let r = cos(180/sides) / cos(((t - angle_off) % (360/sides)) - (180/sides));
CreateShotA1(x, y, r * speed, t, graphic, delay);
t += gap;
}
}

Meanwhile spawning the shape at a location and size is also a matter of multiplying ("give the shape a certain radius size") and converting back to x,y coordinates, so

Code: [Select]
CreateShotA1(x + size*r*cos(t), y + size*r*sin(t), s, a, g, d);
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on February 08, 2016, 05:28:42 PM
No, either way is fine, and I was actually specifically looking at shooting the shape outwards. Because this is already done in polar coordinates, it uses an angle (which you're already going to loop through just as though you were shooting a circle), and a "radius", which is given by the above equation. Like I wrote in the last post, you can interpret this radius as a speed and just plug it in, multiplying it for a faster shape. Basically "increase the radius of the shape by speed each frame".

Code: [Select]
function CreateShotShapeOA1(obj, sides, gap, speed, angle_off, graphic, delay){
let x = ObjMove_GetX(obj);
let y = ObjMove_GetY(obj);
let t = 0;
while(t < 360){
let r = cos(180/sides) / cos(((t - angle_off) % (360/sides)) - (180/sides));
CreateShotA1(x, y, r * speed, t, graphic, delay);
t += gap;
}
}

Meanwhile spawning the shape at a location and size is also a matter of multiplying ("give the shape a certain radius size") and converting back to x,y coordinates, so

Code: [Select]
CreateShotA1(x + size*r*cos(t), y + size*r*sin(t), s, a, g, d);

Thanks alot  :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on February 09, 2016, 04:05:46 AM
Is it possible to set a spawn point for the player i.e when you start the script, you start at the top of the screen or something like that.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 09, 2016, 04:40:14 AM
GetPlayerObjectID() gets the player object ID, so you can use ObjMove_SetPosition() to move them at the start of the stage script.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on February 09, 2016, 04:53:57 PM
How can I modify an object  with a laser (ex. if a bullet is close to a laser, the bullet is destroyed)?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Badz on February 13, 2016, 06:34:06 PM
How can I modify an object  with a laser (ex. if a bullet is close to a laser, the bullet is destroyed)?

IsIntersected_Obj_Obj (http://dmf.shrinemaiden.org/wiki/Other_Functions#IsIntersected_Obj_Obj) might be the solution to your problem. You could use it in a loop to check if a bullet is intersecting with the laser, and do something (in this case, destroy the bullet) if that's the case.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on February 14, 2016, 09:19:46 AM
Thanks :D And homing bullets? How do they work?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 14, 2016, 09:32:33 AM
Thanks :D And homing bullets? How do they work?
Please define though for which purpose you want to use them. Do the bullets home accurately (like Reimu's homing amulets) or only upon firing (so the player can graze them). The latter is achieved by calculating the angle between the object bullet and player using: GetAngleToPlayer(obj); or if you're happy with manual labour using: atan2(y1-y2,x1-x2);  when setting the angle of the object bullet. Where x/y positions of the object + player is filled in.

Example:
Code: [Select]
let dir = GetAngleToPlayer(obj);
ObjMove_SetAngle(obj,dir);

or

let dir = atan2(GetPlayerY-ObjMove_GetY(obj),GetPlayerX-ObjMove_GetX(obj));
ObjMove_SetAngle(obj,dir);


Edit: Thanks Drake for reminding me GetAngleToPlayer(obj). Keep forgetting about that one.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on February 14, 2016, 10:52:39 AM
I want the homing bullets like Reimu?s ones, but less accurate.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 14, 2016, 07:19:24 PM
I am afraid my knowledge lacks on that part :ohdear: and hopefully someone else can come help out .




A question to the people who've been building full fledged games with menu system and everything: Did you manage to successfully implement a continue system?

As far as my research, testing and analysing other full fan games such as well known MPP, RSS and BSM, I have to conclude it is impossible to build a continue system using the functions ph3 offers. Things like GetStageSceneState cannot be called from a Stage Script and GetPlayerState cannot be called outside a Stage Script.

Even thinking of certain detours results in a dead-end. At least, that is my personal conclusion.

So I am curious if anybody successfully managed to achieve this and what did you use to avoid the StageSceneState or PlayerState from going to DED. (As you can't alter playerstate with any function)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 14, 2016, 10:54:34 PM

My continue system is an absolute mess, but I got it to work. It depends on NotifyEvents and CommonData.

In @Event, I use
Code: [Select]
    case(EV_PLAYER_SHOOTDOWN){//To disable continue system, block comment this case.
  if(GetPlayerLife<0){
      SetPlayerLife(0.123); //from Arby26
      ContinueSystem;
  }
    }
By setting the player life to be above 0, you prevent the script from ending. My Continue System task handles communication with the package - if the player has continues left and it's not a replay, the package is notified to Pause the Stage. From here, the player decides in the package which course they would like to take, and the stage is notified from the package via NotifyEvent.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on February 14, 2016, 11:59:09 PM
I want the homing bullets like Reimu?s ones, but less accurate.

I assume something like this would work:

Code: [Select]
loop{
      let dir = atan2(GetPlayerY-ObjMove_GetY(obj),GetPlayerX-ObjMove_GetX(obj));
      ObjMove_SetAngle(obj,dir);
      yield;
}

If you wanted it to be less accurate, there are two ways to go about this. (i think)

1. Have the angle change less frequently

Code: [Select]
loop{
      let dir = atan2(GetPlayerY-ObjMove_GetY(obj),GetPlayerX-ObjMove_GetX(obj));
      ObjMove_SetAngle(obj,dir);
      loop(n){yield;} // where n is a variable
}

2. Have the angle be slightly off

Code: [Select]
loop{
      let dir = atan2(GetPlayerY-ObjMove_GetY(obj),GetPlayerX-ObjMove_GetX(obj));
      ObjMove_SetAngle(obj,dir+rand(-1,1));
      yield;
}

Or you could do both.

I hope this helps.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 15, 2016, 04:58:44 AM
Rather than changing less frequently, many (most?) dynamic "soft" homing implementations will change a set amount towards the direction of e.g. the player.

Code: [Select]
task homing_test{
let obj = CreateShotA1(192, 150, 4, 90, 77, 20);
let speed = 4;
let a = 90;
let a_spd = 5; // rate of angle change
while(!Obj_IsDeleted(obj)){
let angle_to = GetAngleToPlayer(obj);

// choose to increase or decrease angle depending on which is closer
let da = [a_spd, -a_spd][((a - angle_to) % 360) < 180];

// if the angles are close enough, just snap instead
if( (|a - angle_to|) < a_spd){
a = angle_to;
}else{
a = (a + da) % 360;
}

ObjMove_SetAngle(obj, a);

// optionally scale speed so it slows down to adjust angle
let scale = (|(a - angle_to) % 360 - 180|) / 180; // ranges [0,1]; is 1 when angles are equal
ObjMove_SetSpeed(obj, speed * scale^2); // squaring also optional, increases slowdown
yield;
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 15, 2016, 06:24:48 AM
By setting the player life to be above 0, you prevent the script from ending. My Continue System task handles communication with the package - if the player has continues left and it's not a replay, the package is notified to Pause the Stage. From here, the player decides in the package which course they would like to take, and the stage is notified from the package via NotifyEvent.
Oh I see. That is quite a clever workaround. Because 0 lives in Touhou actually means it is your last life right? So preventing it from going to -1? Events are strong it seems, guess I have to call in its help again.

Any side effects of keeping never triggering the PlayerState or StageSceneState to PLAYER_DOWN? Like replays breaking. Desyncing, etc.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 15, 2016, 03:00:07 PM
Oh I see. That is quite a clever workaround. Because 0 lives in Touhou actually means it is your last life right? So preventing it from going to -1? Events are strong it seems, guess I have to call in its help again.

Any side effects of keeping never triggering the PlayerState or StageSceneState to PLAYER_DOWN? Like replays breaking. Desyncing, etc.

I am unsure, but ExPorygon has a replay-safe continue system (which he uses for Ephemeral Unnatural Balance). So if you're interested in a system that definitely works with replays, you should consider PMing him. Personally, my system handles replays in a very haphazard way.

Rule of thumb is that if something is done in the actual play through that is not done exactly the same way in the replay, things will break. If PlayerState is never triggered in either the original play through nor the replay, it should be consistent.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 15, 2016, 04:17:26 PM
Will see if he shows up here. Though from what you explained and what I know:

A replay file is "cut/edited" based on the FinalizeStageScene function and the PauseStageScene. Technically a PauseStageScene is called when the user manually pauses it. Thus the replay knows how to handle the moment until PauseStageScene is set back to false

Currently my game calls the "ending scene" in two conditions:
- STAGE_RESULT_PLAYER_DOWN = FinalizeStageScene -> launches a Ending scene.
- Escape button pressed = PauseStageScene -> launches a Pause scene.

The stage closing happens in the Stage script with GetPlayerState.

So basically the STAGE_RESULT_PLAYER_DOWN should be never checked. The GetPlayerState should never be used to check and changed into sort of manual event / commondata I guess. Inside the package script, when the event/commondata is triggered, a forced PauseStageScene needs to be called inside the ending scene. As long as you don't spawn / set / modify anything during the pause, your replays should be in my opinion safe. Actually, PauseStageScene will pretty much make sure of this.

Seems I need to adjust my ending scene and inject a part of the pause scene into it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on February 17, 2016, 08:04:42 PM
What are the easiest Touhou bosses to replicate, or base on, in Danmakufu?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 18, 2016, 05:47:08 AM
What are the easiest Touhou bosses to replicate, or base on, in Danmakufu?

Depends on what you mean by 'base on' or 'replicate', as well as the general availability of graphical assets. This question is extremely broad, but characters with simpler danmaku (Stage 1-2 bosses) without custom graphics (IE not Nazrin) tend to be less of a logistical hassle. It is for this reason that Rumia used to be one of the most commonly used bosses in early scripts.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: TalosMistake on February 18, 2016, 09:13:28 AM
What are the easiest Touhou bosses to replicate, or base on, in Danmakufu?

Cirno.
Just follow Helepolis tutorial. Very easy xD
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on February 18, 2016, 01:20:21 PM
Depends on what you mean by 'base on' or 'replicate', as well as the general availability of graphical assets. This question is extremely broad, but characters with simpler danmaku (Stage 1-2 bosses) without custom graphics (IE not Nazrin) tend to be less of a logistical hassle. It is for this reason that Rumia used to be one of the most commonly used bosses in early scripts.

Hmm... Rumia seems to be a good option. I'll try to replicate her boss battle, maybe add some new spells.

Cirno.
Just follow Helepolis tutorial. Very easy xD

Well, she DOES use pretty simple patterns, and to top it all off, there is indeed the Helepolis tutorial...
...At this rate, I'm going to recreate the entire EoSD...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: DLS on February 18, 2016, 06:34:49 PM
I'm sure you'll have trouble replicating Patchouli I guess :V

And then there's also Meiling's 1st spell which is probably the most confusing to replicate...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on February 18, 2016, 07:41:44 PM
...At this rate, I'm going to recreate the entire EoSD...
If you're aiming to practice making patterns, EoSD is honestly a good game to replicate patterns from. The majority of bullet patterns in EoSD are relatively basic, probably due to ZUN's relative inexperience in pattern making. The only big part that really comes to mind as difficult to replicate would be Sakuya's spellcards, as those rely on a mechanic that's by default absent from Danmakufu Ph3: the time stop. A few other hard ones like Kagome Kagome, Laevateinn, and maybe Royal Flare come to mind, but they aren't very numerous and limited mostly to the extra stage.

Edit: That said, many older PC-98 patterns might be even more simple so that's not a bad option either.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: DLS on February 18, 2016, 09:48:25 PM
But can't you simulate time stop by stopping the pellets / knives and using SetPlayerSpeed(0, 0);, and if possible get the player speed before "stopping time"?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 18, 2016, 10:15:55 PM
But can't you simulate time stop by stopping the pellets / knives and using SetPlayerSpeed(0, 0);, and if possible get the player speed before "stopping time"?

Yes you can. But manually 'stopping time' is a major hassle that involves communicating between different scripts and large-scale array accesses. Additionally, like with Python's Artifact 3, it's a royal pain to debug because everything must be restored if the boss attack is cleared during timestop (which caused his player speed and forbid shot/spell to be disabled for the rest of the game until he fixed it).

There are ways to do it but there is no one *good* way.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: DLS on February 19, 2016, 12:13:08 AM
And that's why you don't hand your stopwatch to a fox.

Oh...

Also, would it be bad if you defined the player speed on @Initialize of the first script knowing that your script lets you choose any player you have?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on February 19, 2016, 12:49:13 AM
Hello there folks,

I'm stuck with the attempt to make a 3D render of the red circle that spins around the boss:
http://pastebin.com/M12w2ZuA (http://pastebin.com/M12w2ZuA)

I went with creating a 3D-sprite of the graphic first and applying its properties, including positioning it right at the boss' coordinates.
However, the graphic is rendered at a completely different place than the boss sprite, although still moving at exactly the same speed and in the same direction as the boss does.
I've already tried a number of things with the destination rectangle and the x,y-coordinates, but the circle doesn't position itself right at the boss.

That all worked just fine for the 2D-sprite version of it.

Anyone's got an idea?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 19, 2016, 08:00:38 AM
Well, you're both pointing out the problem and the answer slightly yourself :V 

You're using a regular render function to mutate a 3D sprite object. The coordinates of a 3D sprite are based on the XYZ of the danmakufu 3D space and the 2D sprites are based on the game field, except when you set the Layer 80+ (or 0.8 if you're using the regular one), which then the entire window of the program become the coordinates. To clarify:

Let us say your game field is X: 200 and Y: 400. You decide to centre your boss using your own GetCenterX / GetCenterY code (Which is field / 2). The boss X,Y position is 100,200. Imagine we try to draw a texture/sprite on Layer 80 using the same functions. We have to keep in mind that our Danmakufu window is by default 640x480. Drawing our texture and giving the GetCenterX/Y will put it at 320,240. Because after all, that is the centre of the whole window. Obviously this won't align with the boss, as they are calculating their coordinates differently. But what if we put our texture on Layer 30? Suddenly, it will align proper, as both are calculating the centre based on the play field.

The same story goes for 3D, except more complicated when you're involving the camera. First of all, 3D coordinates of danmakufu are fixed. If you put something at 0,0,0 in 3D space and you put your camera -256 on the X-axis, your sprite will be off-centre for you, but in terms of code it is still located 0,0,0.

TL DR: You don't want to mix 2D ad 3D to align things because generally it will be a hassle regardless.

Is it an aesthetic thing you wish to put your magic circle in 3D? The 2D sprite allows X Y Z angling as well. Or you think that looks a bit too "thin paper"?

Alternative solution I can offer you is a Mesh object. Because it takes the function: ObjMesh_SetCoordinate2D(obj,boolean);  http://dmf.shrinemaiden.org/wiki/Mesh_Object_Functions#ObjMesh_SetCoordinate2D which then allows you to use 2D coordinates. Had similar issue with my Tewi Mochi hammer in my game. So what you need to do is:
- Make a flat mesh object in a 3D modelling program.
- Texture it with the magic circle
- Summon it in your script using the mesh functons
- Set the ObjMesh_SetCoordinate2D to true.
- Continue further using regular ObjRender functions.

Either use 2D sprite and angle it X Y Z giving it that "3D-ish" feeling. Or use the Mesh trick.

Edit note: explaining more added to original post.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on February 19, 2016, 11:14:17 AM
Well, you're both pointing out the problem and the answer slightly yourself :V 

You're using a regular render function to mutate a 3D sprite object. The coordinates of a 3D sprite are based on the XYZ of the danmakufu 3D space and the 2D sprites are based on the game field, except when you set the Layer 80+ (or 0.8 if you're using the regular one), which then the entire window of the program become the coordinates. To clarify:

Let us say your game field is X: 200 and Y: 400. You decide to centre your boss using your own GetCenterX / GetCenterY code (Which is field / 2). The boss X,Y position is 100,200. Imagine we try to draw a texture/sprite on Layer 80 using the same functions. We have to keep in mind that our Danmakufu window is by default 640x480. Drawing our texture and giving the GetCenterX/Y will put it at 320,240. Because after all, that is the centre of the whole window. Obviously this won't align with the boss, as they are calculating their coordinates differently. But what if we put our texture on Layer 30? Suddenly, it will align proper, as both are calculating the centre based on the play field.

The same story goes for 3D, except more complicated when you're involving the camera. First of all, 3D coordinates of danmakufu are fixed. If you put something at 0,0,0 in 3D space and you put your camera -256 on the X-axis, your sprite will be off-centre for you, but in terms of code it is still located 0,0,0.

TL DR: You don't want to mix 2D ad 3D to align things because generally it will be a hassle regardless.

Is it an aesthetic thing you wish to put your magic circle in 3D? The 2D sprite allows X Y Z angling as well. Or you think that looks a bit too "thin paper"?

Edit note: explaining more added to original post.

Whoops, totally forgot that the 3D objects are affected by the camera angles and position  :V
Considering that, I adjusted the camera settings and it works well by now. Currently fiddling around with the background graphics, but that's ok.

Yep, it's just an aesthetic thing, I guess I like the 'real' 3D rendition a bit too much (damn I'm way too picky with stuff).

Thanks!  :D
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 19, 2016, 01:59:20 PM
3D Sprite objects are essentially made for background use (as should be obvious now). There shouldn't really be any difference between rotating a 2D Sprite object and a 3D one as far as I'm aware; is there a reason you switched when you could spin around the previous one just the same? As it is you might also get background interference/clipping.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on February 19, 2016, 04:59:45 PM
3D Sprite objects are essentially made for background use (as should be obvious now). There shouldn't really be any difference between rotating a 2D Sprite object and a 3D one as far as I'm aware; is there a reason you switched when you could spin around the previous one just the same? As it is you might also get background interference/clipping.

I'm aware of that. Rotating does work identically on both 2D and 3D, it's the position of the graphic that initially confused me when I switched. As its movement is tied to that of the boss, I have adjusted the camera's position to project it right behind the boss sprite, which didn't actually essentially affect the background in my case, aside from the change of perspective.

I switched to 3D because of aesthetic reasons, and wanted to try out something new  :3
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on February 19, 2016, 06:33:21 PM
How do you put quotation marks inside strings?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Badz on February 19, 2016, 07:44:07 PM
How do you put quotation marks inside strings?

You put a \ before the quotation marks that should be part of the string, like this:
Code: [Select]
let name = "Something Sign \"Something Something\"";
Is it possible to put square brackets inside a string without the spaces between the brackets being removed?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 19, 2016, 07:44:41 PM
How do you put quotation marks inside strings?

\" or &quot;

The former uses the escape character, while the latter uses the ISO SGML (https://www.w3.org/MarkUp/HTMLPlus/htmlplus_13.html) standard (the HTML and the like)

More info: http://sparen.github.io/ph3tutorials/ph3u1l4.html#sub8
Documentation: http://www.geocities.co.jp/SiliconValley-Oakland/9951/pre/th_dnh_help_v3.html
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on February 20, 2016, 01:36:19 AM
How do you put quotation marks inside strings?
Simply typing this inside a string also works:

Code: [Select]
&quot;
EDIT: Could have sworn Sparen's post didn't mention that, oops.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on February 20, 2016, 09:08:07 AM
How much damage should a player do? I mean for the most used shot types.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on February 20, 2016, 12:29:03 PM
It depend of how life the scripters give to their bosses. Personnally I give arround 1500~2000 for the nonspells and 2000~3000 for the spells. And I use players with ~200-300 dps.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: DLS on February 20, 2016, 12:39:21 PM
I personally give 3500 HP for spells and nonspells for my bosses. The only exception is when I decide to make a spell with more patterns, that kind of spell usually falls on 6000 HP.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 20, 2016, 03:52:20 PM
How much damage should a player do? I mean for the most used shot types.

As has been said above, it depends on the life and Damage Rate of your bosses and stage enemies.

There is, however, a standard DPS range that should be obeyed if you want your players to be usable in other people's scripts. The Random Player Generator, Mr. Blue's Reimu, and a large number of other players fall in this range - as Lefkada said, it's typically the 200-300 DPS range.

My Artifact 2 Marisa uses the following:
Unfocused Shot:
-Damage: ~300 DPS
Focused Shot:
-Damage: ~282 DPS

There are a number of Player DPS testing scripts.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on February 20, 2016, 04:15:41 PM
Ok, thanks.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on February 24, 2016, 05:43:14 PM
How do you spawn a 2D sprite and keep updating its position and/or angle every frame without creating a new one every time (For example, a magic circle on a boss object)?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 24, 2016, 06:24:32 PM
I'm confused. How are you even putting the sprite somewhere without using the functions that you'd use to update its position? Are you actually using SetDestRect to draw the sprite at some position?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on February 24, 2016, 07:02:13 PM
I guess I should've been more clear...
I'm trying to create a magic circle, that would spin and follow the boss. The problem is, it never actually spins, or follows the boss at all.
To clear some things out, I put the function in @Initialize, but the function itself is placed in a different file than the main script, along with many other functions. spin++ is in the main file, in @MainLoop though. X and Y are boss' coordinates.

This is my code (It's a bit messy):

Code: [Select]
function MagicCircle(x, y){
let eff = CSD ~ "// Image Folder.";
let spin = 0;

let obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj, eff);
ObjSprite2D_SetSourceRect(obj, 0,255,255,292);
ObjSprite2D_SetDestRect(obj, 0,0,256,45);
Obj_SetRenderPriorityI(obj, 21);
ObjRender_SetX(obj, x);
ObjRender_SetY(obj, y);
ObjRender_SetScaleXYZ(obj, 1, 1, 0);
ObjRender_SetAngleXYZ(obj, 0, 0, spin);
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 24, 2016, 07:51:24 PM
Putting spin++ in another script (or even outside of your MagicCircle function) won't affect the spin variable inside of the function.

Are you aware of how tasks work? That's how you would get this done, and more generally how you do any kind of "update" loop. Besides this, you'll want to grab the boss' object ID so that you can keep getting its current position.

Code: [Select]
task MagicCircle(){ // note `task` and no params needed
let eff = CSD ~ "// Image Folder.";
let spin = 0;

let objEnemy = GetEnemyBossObjectID()[0]; // if you've defined the boss' object ID globally already you don't need this
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
// the other setup

while(!Obj_IsDeleted(objEnemy)){ // update loop runs until enemy object is deleted
ObjRender_SetPosition(obj, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 0);
ObjRender_SetAngleXYZ(obj, 0, 0, spin);
spin++;
yield; // stops this task from running until next frame
}
}

(Note that constructing the magic circle this way might have some unwanted effects, but if this works for you then good enough.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on February 24, 2016, 08:24:55 PM
Argh, I knew it had something to do with while(!Obj_IsDeleted), but I forgot about yield;  :V
...Anyway, thank you very much!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 25, 2016, 08:38:43 AM
Adding the following as information for beginners (or people who didn't know):

As a general design rule, you can be for sure that any update-per-frame or behaviour-per-frame for an object involves a while(<statement>) { } loop. The Obj_IsDeleted(obj); is a function which returns a boolean value whether the object is alive or not. Don't confuse it with Obj_Delete(obj); (notice how there is no 'is') which actually deletes the object. The Obj_IsDeleted asks Danmakufu: "Is my object deleted?". And Danmakufu will return you a true/false.

The exclamation mark '!' in front of the function reverses the result of the statement. This is important because if you don't, the while loop statement results in a 'false' and will exit immediately. Remember, the statement needs to result in 'true' to keep it looping. If the object is alive and you ask Danmakufu with the function, it tells you: "Nope, it is not deleted yo."

This is how it would 'translate' if you didn't or did use the exclamation mark:
Code: [Select]
while(Obj_IsDeleted(obj)) -> results in: while(false)  -> Conclusion: Immediate exit loop.

while(!Obj_IsDeleted(obj)) -> results in: while(!false) -> Because of exclamation mark, the result is reversed -> becomes: while(true) -> Conclusion: keep looping.

Thus your while loop stays alive and you can do anything per-frame (update position, change size, morph the colour, etc). Don't forget to yield; your loop once, otherwise your game will freeze.

Beginners might be often using this too:
Code: [Select]
while(Obj_IsDeleted(obj) == false) -> results in: while(false == false) which is 'true' -> while(true) -> Conclusion: Continue looping. It is perfectly legal, but people don't use it for tons of reasons. Not going to go into a debate of 'How To Write Clean Code'.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on February 25, 2016, 04:14:56 PM
Im trying to #include some stuff :

Code: [Select]
#include "script/"scriptname"/commonLoad.txt"
But the script that I want to include this library is inside a different folder:

Code: [Select]
"script/"scriptname"/data/boss/N1"

I usually fix it using an absolute path, but now I want to change the script name folder. Can someone help me?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 25, 2016, 04:39:39 PM
Im trying to #include some stuff :

Code: [Select]
#include "script/"scriptname"/commonLoad.txt"
But the script that I want to include this library is inside a different folder:

Code: [Select]
"script/"scriptname"/data/boss/N1"
I usually fix it using an absolute path, but now I want to change the script name folder. Can someone help me?

You can use relative paths (./../ for the previous folder, for example) to move around the directories. For more information, please use Helepolis's Paths and Directories Guide (https://www.shrinemaiden.org/forum/index.php?topic=4752.0)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on February 25, 2016, 05:04:55 PM
Ok it works now. Thanks.
Also, how often do you carry out (perform, do, make... ) the RaNGE contest?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 25, 2016, 05:16:09 PM
Also, how often do you carry out (perform, do, make... ) the RaNGE contest?
There is no specific description, rule or guideline to make one or when to make one. Occasionally, someone comes up with a good idea + contest rules + judges and present it to the community. If the community shows enough attention, I will sticky it and magically call it a contest on RikaNitori.

Anybody can host one. You don't need to be some famous person or expert scripter or long time forum member to host one. But I do expect serious dedication + contribution from the host. As in: prepare well. Unprepared contests are sort of troublesome.

Usually there is some sort of "break" which the community takes between contests. Duration is variable.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 25, 2016, 06:29:33 PM
Ok it works now. Thanks.
Also, how often do you carry out (perform, do, make... ) the RaNGE contest?

As Helepolis said above, there are no specific guidelines for when to make one. I have a list of former contests here (http://sparen.github.io/projects/contestdatabase.html). If you set the query box to the third option, it will generate a timeline of contests.

Generally speaking, the trend is for there to be a few months in between contests. Some contests are also more complex than others (i.e. RaNGE 16 was much more complex than RaNGE 3, which was a single spell card).

Regarding advance planning, spontaneous contests tend to go poorly, especially when the host does not have a good grasp of all of the rules and guidelines beforehand. For example, for the next LOCAA Contest, AJS spent at least a few weeks preparing the rules and details of the contest, and he planned it more than a month in advance so that the timing would be appropriate. A lot of thought goes into the more successful contests.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on February 25, 2016, 06:55:58 PM
Thanks.

And last thing, how can I make the effect that appears when Alice make appear familiars/bullets in Last Boss Rush.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 25, 2016, 09:26:41 PM
Um, could you show the thing you're actually talking about
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on February 25, 2016, 09:43:02 PM
(http://imagizer.imageshack.us/v2/xq90/923/4nwaYf.jpg) (https://imageshack.com/i/pn4nwaYfj)

Those stars that are moving randomly on the left of the image, that?s the effect that I want.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: zemoo on February 26, 2016, 08:16:01 PM
does this tutorial work in ph3? https://www.shrinemaiden.org/forum/index.php?topic=210.0 (https://www.shrinemaiden.org/forum/index.php?topic=210.0)
I started doing it and then noticed that the header is different from my EX-Rumia's; also when I tried to play it it wouldn't let me use my character.
It's old enough that I suspect it was made for 0.12m, but I may just be doing something wrong
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on February 26, 2016, 08:47:53 PM
That tutorial won't work if you're using ph3.  I recommend you to look inside other script players and learn how do they work. I believe that there aren't player script ph3 tutorials actually.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 26, 2016, 10:02:00 PM
That tutorial won't work if you're using ph3.  I recommend you to look inside other script players and learn how do they work. I believe that there aren't player script ph3 tutorials actually.

You are correct. That tutorial is for 0.12m.

And yes, there are no player script tutorials in existence that I know of. If someone writes one that will change, of course. But for now, nobody has written one due to the sheer scale and difficulty of the task.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on February 29, 2016, 01:33:08 PM
I`ve found the effect by my own ways :] It is confusing when you look at it, but it is, in fact, "easier".

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on March 03, 2016, 07:40:20 PM
How do I know the time an object spends if the object is moved by the function ObjMove_SetDestAtWeight ? Because it does not spend the exact amount of time I want.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on March 03, 2016, 09:09:27 PM
You can always use a counter to.... well, "count" how many frames a boss spends when it's not stationary.
You can display that number with a text object or with the WriteLog function.

Alternatively you can always create your own smooth movement function that uses ObjMove_SetPosition manually.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on March 07, 2016, 07:56:42 PM
Hello again! I have two questions, regarding the spell card bonus counter.

(http://i.imgur.com/5xh7SAn.png)
Code: [Select]
        let bool = true;

while(bool==true){
ObjText_SetText(textBonus, ObjEnemyBossScene_GetInfo(objScene, INFO_SPELL_SCORE));
yield;
}
while(bool==false){
ObjText_SetText(textBonus, "Failed");
yield;
}
while(ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT)
        +ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) >= 1){
bool=false;
}

1. How can I make those useless zeros disappear? (The original spell bonus is 2400000 if that's relevant.)
2. For some reason, I can't get "Failed" to show up when the player bombs or misses. Any reasons why?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on March 07, 2016, 08:04:59 PM
Hello again! I have two questions, regarding the spell card bonus counter.

(http://i.imgur.com/5xh7SAn.png)
Code: [Select]
        let bool = true;

while(bool==true){
ObjText_SetText(textBonus, ObjEnemyBossScene_GetInfo(objScene, INFO_SPELL_SCORE));
yield;
}
while(bool==false){
ObjText_SetText(textBonus, "Failed");
yield;
}
while((ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT)
        +ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT)) >= 1){
bool=false;
}

1. How can I make those useless zeros disappear? (The original spell bonus is 2400000 if that's relevant.)
2. For some reason, I can't get "Failed" to show up when the player bombs or misses. Any reasons why?

Code: [Select]

let bonusget = true;
let bonus = ObjEnemyBossScene_GetInfo(objScene,INFO_SPELL_SCORE);
while(bonusget) {
   bonusget = (ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT)
        +ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT)) == 0;
   bonus = ObjEnemyBossScene_GetInfo(objScene,INFO_SPELL_SCORE);
   ObjText_SetText(textBonus, IntToString(bonus));
   yield;
}
ObjText_SetText(textBonus, "Failed");

You might be wanting to do something like this instead.

It checks for whether the player died or bombed during the while, which I think you were trying to do with bool.

(Disclaimer: this code is untested... I'm at school so I'm just throwing down a quick fix.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on March 07, 2016, 08:21:13 PM
Wow, thank you!  It works perfectly!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on March 08, 2016, 07:45:14 AM
This is strange.

Since some time, whenever I edit an external file (e.g. for effects) that I include into my main script, there is always this Unable to be interpreted-error showing up, not pointing out any specific mistake but always the first line with this ・ソ-thingy appearing before the code begins. This also happens to the main scripts. although more rarely.
Could this be possible because of mistakes somewhere deeper in the code, or is this some kind of a bug?

The affected script here, just in case: http://pastebin.com/Lm9c8wzy (http://pastebin.com/Lm9c8wzy)

The error message:

************************************************

Unable to be interpreted (Don't forget ";"s).
(解釈できないものがあります(「;」を忘れていませんか))
C:/Users/Jimmy/Saved Games/Touhou Danmakufu/th_dnh_ph3/script/Sandbox/Kanjuden Boss Rush/eff/effects.txt
effects.txt line(行)=1


・ソfunction delay(d) {
   loop(d) { yield; }
}

//-----------------------------------------------

task shockwave(tobj,color){
   let obj = ObjPrim_Create(OBJ_SPRITE_2D);
   let Xscale = 0.2;
   let Yscale = 0.2;
   let alpha = 255;
   
   ObjPrim_SetTextur
~~~

************************************************
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on March 08, 2016, 08:29:46 AM
This might be the UTF-8 byte order mark. If your editor supports it, save the file without it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on March 08, 2016, 09:09:26 AM
Welp, didn't think that encoding was a thing here. Maybe that was because I used a different editor for hasty edits and it perhaps saved the files with a different encoding by default than Notepad++ (which I use mostly, with c# syntax highlighting).
Saved the affected files with Unicode format, the script works (again). Thanks! :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 08, 2016, 10:10:50 AM
Even if ph3 doesn't requires Locale setting to show Japanese characters, unicode for your script files is still in effect. You will get a lot of headache when you're using Japanese chars or anything else and not saving your files supporting the correct Unicode.

I would advise anyone who is using this to default save their files with the required unicode support. Especially when you're copy/pasting things from Rumia script or anywhere where a Japanese comment was made. Just to be sure
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BobTheTanuki on March 11, 2016, 12:14:33 PM
Hello you gyus
I'm struggling so much
help me pleeease :V
When I'm playing singles it's okay,no bugs and stuff
BUTTTT
when I'm playing the plural,there is this horrible bug
there are some random collisions happen and they screw up all the bullets too(like not firing bullets,gaps in lines of bullets and stuff)
(the collision on the top is the collision with boss and the collision on the bottom is some random collision)
(https://pp.vk.me/c628120/v628120252/42578/fOTeZHgDpvI.jpg)
Anything should I do to fix this?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 11, 2016, 02:19:01 PM
We don't have enough information to analyse this.

Can you post like your boss code in pastebin? And does the same happen with the default Rumia player?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Fujiwara no Mokou on March 12, 2016, 01:58:58 AM
help me pleeease :V
...
Anything should I do to fix this?

If it's a snippet, post code with code tags, or use pastebin (http://pastebin.com/) for entire scripts.
Also, hello I'm back everyone. Yaaay :3
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: TalosMistake on March 12, 2016, 04:56:12 AM
Hello you gyus
I'm struggling so much
help me pleeease :V

Anything should I do to fix this?

IIRC, it's the problem with Ultima's Reimu player, not the script itself. Better wait for him to fix it. xD
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BobTheTanuki on March 12, 2016, 05:53:24 AM
IIRC, it's the problem with Ultima's Reimu player, not the script itself. Better wait for him to fix it. xD
Whaaaaa :V
Jeez
thank you all so much
I'm so happyyy :V
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 12, 2016, 12:44:06 PM
That is why I had asked whether the same happens with Default Rumia player  :o

So what is actually the problem with that player script. You made me curious Talos.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Bic?- on March 13, 2016, 06:48:09 PM
Hi guys, how do i create "wings" with bullets, like in Glorious and Huge Singer's nonspells?

Also how can I shoot bullets out of the wings?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 14, 2016, 02:50:03 AM
Shoot bullets outward at some variable angle a, and alternate increasing and decreasing a to make it wave. Add more bullet lines and offset them from a for more layers.

You can't reasonably shoot bullets out of the wings; you would normally just use spawn positions that appear to be in the same area.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: zemoo on March 15, 2016, 11:22:13 PM
I was following Helepolis's new custom player tutorial an I ran into a weird problem, my character's sprite is ~28 pixels to the left of where it should be. I followed the code as closely as I could, only modifying file names and draw rects where appropriate.

Code: [Select]
task renderPlayer{

ObjPrim_SetTexture(playerObj, playerSprite);
Obj_SetRenderPriority(playerObj, 31);
ObjRender_SetBlendType(playerObj,BLEND_ALPHA);
ObjRender_SetAngleXYZ(playerObj, 0,0,0);
ObjRender_SetScaleXYZ(playerObj, 1, 1, 0);
ObjRender_SetAlpha(playerObj, 255);
ObjSprite2D_SetSourceRect(playerObj, 0,0,32,32);
ObjSprite2D_SetDestCenter(playerObj);
       //ObjSprite2D_SetDestRect(playerObj,-16,-16,16,16); this didn't work either

ObjRender_SetPosition(playerObj,GetPlayerX,GetPlayerY,0);

while(!Obj_IsDeleted(playerObj)){
ObjRender_SetPosition(playerObj,GetPlayerX,GetPlayerY,0);
yield;
}
}

I could do a quick fix of ctrl-f replace all GetPlayerX with GetPlayerX+28, but that is inelegant and may lead to issues later if I want to scale the sprite or modify anything else. Any ideas as to why this may be happening? I feel like GetPlayerX (and Y?) may be returning the wrong value or the top left most value instead of the center

(http://i.imgur.com/VUs7445.png)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on March 15, 2016, 11:35:17 PM
Code: [Select]
task renderPlayer{

ObjPrim_SetTexture(playerObj, playerSprite);
Obj_SetRenderPriority(playerObj, 31);
ObjRender_SetBlendType(playerObj,BLEND_ALPHA);
ObjRender_SetAngleXYZ(playerObj, 0,0,0);
ObjRender_SetScaleXYZ(playerObj, 1, 1, 0);
ObjRender_SetAlpha(playerObj, 255);
ObjSprite2D_SetSourceRect(playerObj, 0,0,32,32);
ObjSprite2D_SetDestCenter(playerObj);
       //ObjSprite2D_SetDestRect(playerObj,-16,-16,16,16); this didn't work either

ObjRender_SetPosition(playerObj,GetPlayerX,GetPlayerY,0);

while(!Obj_IsDeleted(playerObj)){
ObjRender_SetPosition(playerObj,GetPlayerX,GetPlayerY,0);
yield;
}
}

As a note, most of your code is unnecessary or redundant. The below is all you need:

Code: [Select]
task renderPlayer{
ObjPrim_SetTexture(playerObj, playerSprite);
Obj_SetRenderPriority(playerObj, 0.31); //This is your error
ObjSprite2D_SetSourceRect(playerObj, 0,0,32,32);
ObjSprite2D_SetDestCenter(playerObj);
}

Angle defaults to 0, Scale defaults to 1, Blend type defaults to Blend_Alpha, Alpha defaults to 255, and the player object and the graphic are actually the same object - the player graphic moves automatically with the player (someone please correct me if I am wrong).

As for the error, I believe it has to do with your usage of Obj_SetRenderPriority(playerObj, 31);. Render priorities go from 0.0 to 1.0. If you want to use the 0-100 scale, you must use Obj_SetRenderPriorityI instead of Obj_SetRenderPriority.

Hope that helps.



As for why it displays ~ 28 pixels to the left, using 31 (out of a 0.0-1.0 scale) is above the 0.80 playing field boundary, so your player is being rendered with respect to the top left of the window rather than the top left of the playing field.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: zemoo on March 16, 2016, 01:32:25 AM
Thanks Sparen, that was it, the missing 'I'.

As for the unnecessary code, I assume Helepolis was just being thorough, later in the Tutorial he implements a practical use for some of the other functions (viz. SetAlpha).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Meowstic on March 19, 2016, 11:30:05 PM
Hey uhh, How do I implement Extends?
I bet It's really simple and I'm just going to annoy someone with that question.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 20, 2016, 02:53:49 AM
SetPlayerLife(GetPlayerLife() + 1); for increasing lives in general. For score extends, perhaps something like this:

Code: [Select]
task TExtends(){
let EXTENDS = [10000000, 30000000, 80000000];
let extend_count = 0;
while(extend_count < length(EXTENDS)){
if(GetScore() >= EXTENDS[extend_count]){
SetPlayerLife(GetPlayerLife() + 1);
extend_count++;
}
yield;
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Meowstic on March 20, 2016, 06:59:07 AM
What about pickup extends? CreateItemA1 ones don't work properly and I have no idea how to do it otherwise.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 20, 2016, 07:18:09 AM
Item behaviour is generally implemented by the player script. The preset items you can use with CreateItemA1 just skip the need to make your own item definitions and whatnot. To get an ITEM_1UP item to actually give you an extra life you toss something like this in the player script's @Event loop.

Code: [Select]
alternative(GetEventType())
case(EV_GET_ITEM){
if(GetEventArgument(0) == ITEM_1UP){
SetPlayerLife(GetPlayerLife() + 1);
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on March 20, 2016, 12:00:51 PM
Are there any Danmakufu ph3 tutorials covering dialogue systems?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on March 20, 2016, 12:22:07 PM
No :_)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on March 20, 2016, 02:45:08 PM
Well then...
Guess I have to figure it out myself.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on March 20, 2016, 03:13:54 PM
A good way to figure out is to read other people's code. (https://github.com/bluebear94/cy05/blob/master/stage/stage_header.dnh#L68)

Basically, you need sprite objects for the character portraits, as well as for either the dialogue bar at the bottom in older games, or speech bubbles if you're into those. The dialogue text itself uses text objects.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on March 20, 2016, 04:01:58 PM
Oh, so it's as simple as "place some images and text objects". I seriously thought it was going to be some sort of pre-built function or something...
Thanks for the dialogue code, I'll look through it!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Youmu970 on March 20, 2016, 09:33:44 PM
Well, this is depressing. My player script isn't even being recognized. It is in the player directory.
Code:
http://pastebin.com/9NkXFmFG
http://pastebin.com/TEbv6dCg
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 20, 2016, 09:42:03 PM
Well, this is depressing. My player script isn't even being recognized. It is in the player directory.
Code:
http://pastebin.com/9NkXFmFG
http://pastebin.com/TEbv6dCg
Not sure which version of ph3 you're running, but try #TouhouDanmakufu[Player] instead of the Japanese expression.

Edit: Ok this seems to be a similar case of file encoding which Fluffy had pointed out here (https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1240324.html#msg1240324)  :). If you use #東方弾幕風[Player] you need proper UTF-8 encoding for your player script to make it show up. Otherwise use the regular English expression.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Youmu970 on March 20, 2016, 09:49:35 PM
That's what I had originally, and then I changed it to see if this would work. Perhaps I mis-typed it originally? I'll try again...

EDIT: Looks like I did mis-type it. Working now. (Well, getting an actual error message, but at least it's being recognized lol)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 20, 2016, 09:51:11 PM
That's what I had originally, and then I changed it to see if this would work. Perhaps I mis-typed it originally? I'll try again...
You need to completely close and restart Danmakufu in order to reload the script. Changing it on the fly won't make it appear.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Youmu970 on March 20, 2016, 09:51:52 PM
You need to completely close and restart Danmakufu in order to reload the script. Changing it on the fly won't make it appear.

I know. :)

EDIT: Ok, fixed that error, got my crappy sprite to appear, but it has no hitbox collision and she can't shoot. :(
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on March 21, 2016, 12:37:48 AM
Not sure which version of ph3 you're running, but try #TouhouDanmakufu[Player] instead of the Japanese expression.

Edit: Ok this seems to be a similar case of file encoding which Fluffy had pointed out here (https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1240324.html#msg1240324)  :). If you use #東方弾幕風[Player] you need proper UTF-8 encoding for your player script to make it show up. Otherwise use the regular English expression.

Shift-JIS or UTF-16LE with BOM. Danmakufu does not recognize UTF-8.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 21, 2016, 08:17:23 AM
You're absolutely correct. Shift-JIS or UTF-16LE with BOM is much better.

I remember I struggled alot in Notepad++ which for some reason didn't allow me to save to that format and it would also keep ignoring my Shift-JIS encoding. I think Drake helped me out with Sublime back then. That was major rage.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on March 21, 2016, 09:52:37 AM
Code: [Select]
task Tran{
let target = GetTransitionRenderTargetName();
let obj = ObjPrim_Create(OBJ_SPRITE_2D);

ObjPrim_SetTexture(obj, target);
Obj_SetRenderPriority(obj, 0.1);
ObjSprite2D_SetSourceRect(obj, 0, 0, 640, 480);
ObjSprite2D_SetDestCenter(obj);
ObjRender_SetPosition(obj, 320, 240, 0);

while(true){
ObjSprite2D_SetSourceRect(obj, 0, 0, 640, 480);
yield;
}
}

The code up there is supposed to put an image of the stage when the script is paused, but it doesn't work. Why? Note : this code is used in a pause script, initialized in a package script.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on March 21, 2016, 05:55:19 PM
1) Are you calling Tran(); ?
2) Are you rendering to GetTransitionRenderTargetName() before initiating the pause script? For some reason I had a bit of trouble with that before

Also unless you're planning on doing something else with the source rect continuously, I'm pretty sure calling ObjSprite2D_SetSourceRect in the while loop wouldn't change much visually ...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 21, 2016, 06:25:13 PM
Doesn't necessary have to be launched from package script. GetTransitionRenderTargetName specifically is triggered when a pause is happening. This can be also done during regular single attack script.

Did some testing in a single script, the image would sometimes not appear unless I hit ESC button once. The image got rerendered every time I hit escape without calling the testRender again which is interesting. Seems like the object is dynamic?
Code: [Select]
task testRender {
wait(60);
let tex = GetTransitionRenderTargetName;

let obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj,tex);
ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
ObjRender_SetAlpha(obj,255);
Obj_SetRenderPriorityI(obj,80);
ObjRender_SetScaleXYZ(obj,1,1,0);
ObjSprite2D_SetSourceRect(obj,0,0,256,256);
ObjSprite2D_SetDestCenter(obj);
ObjRender_SetPosition(obj,200,100,0);
}


About your code, if your goal is purely to snapshot the screen as a still, you could actually use way more shorter version:
Code: [Select]
let tex = GetTransitionRenderTargetName;
RenderToTextureA1(tex, 0, 100, true);

PauseStageScene(true);

// Summon your pause script.


Edit No duplication but actual dynamic refresh?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on March 23, 2016, 08:51:52 PM
Thanks for the help, the problem has been fixed. Andddd I have another question : how can I create bullets that do not destroy when they leave the frame / gamefield?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on March 24, 2016, 12:08:09 AM
Thanks for the help, the problem has been fixed. Andddd I have another question : how can I create bullets that do not destroy when they leave the frame / gamefield?

ObjShot_SetAutoDelete(obj, false)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on March 24, 2016, 01:15:56 AM
Thanks for the help, the problem has been fixed. Andddd I have another question : how can I create bullets that do not destroy when they leave the frame / gamefield?
You can also determine at which distance from each side outside of the stage frame the bullets should be deleted:

Code: [Select]
SetShotAutoDeleteClip( distance from the left side, top side, right side, bottom side);
Default distance is 64 from each side.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on March 24, 2016, 08:42:48 AM
Thanks :D
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on March 31, 2016, 06:47:23 PM
Maybe it will be a stupid question, but?
Is there really no way to improve ph3 graphics drawing?
It's really annoying, it kills graphic quality too much.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on March 31, 2016, 08:10:30 PM
Maybe it will be a stupid question, but?
Is there really no way to improve ph3 graphics drawing?
It's really annoying, it kills graphic quality too much.
I think you're going to have to be more specific. What aspects of Ph3's drawing do you think are inadequate? If it's the resolution, than that can be changed from the default 640x480 to most any resolutions that you may desire, which should improve graphical fidelity by a lot. The only caveat is that you'd need textures (particularly bullet graphics and sprites) that can work with that resolution.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Fujiwara no Mokou on March 31, 2016, 10:09:34 PM
Maybe it will be a stupid question, but?
Is there really no way to improve ph3 graphics drawing?
It's really annoying, it kills graphic quality too much.

Are you talking about the quality of textures or the number of primitives being drawn?
If it's the quality of textures, try asserting the criterion that the image dimensions are in discrete powers of two (32 x 32, 256 x 256, etc).
On the other hand, if it's the number of primitives you're having issues with, you can try using a single effect object with multiple primitive triangle list, and partition a set of triangles for each 'object', assuming each object uses the same image and render state. The way I know it, Danmakufu uses a single draw() call for each effect, so partitioning effects this way allows you to draw multiple 'objects' with a single draw call. Be weary of computational overhead, however. Since all the logic is done through a virtual machine, you'd want to optimize it where possible.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on April 01, 2016, 06:57:26 PM
How do MOF Marisa A`s familiar works? (I mean how do they move, not the shoot).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on April 02, 2016, 10:39:53 AM
Not quite sure, but I think the closest familiar makes the same moves as the player, minus some distance to not end up inside the player, the second one moves like the first familiar, with the same rules, the third one moves like the second familiar, and so on.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 08, 2016, 11:07:41 AM
Alrighty, so out of personal interest I coded this up. Writing code for generic gradius options was pretty easy; setting it up like MoF where focus movement locks the options was much more difficult and I had to rework the approach a few times.

https://gist.github.com/drakeirving/1ef0f9a315468dc864a678caf550116b

As always, I aimed to make this as generic as possible. The number of options is arbitrary, and with the non-player version you can attach options to any Move object (e.g. a bullet).
You could very easily modify the for-player version to fire bullets and work properly when the player dies, which I didn't bother with.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on April 08, 2016, 01:44:28 PM
You can save a different version of the same common data area per stage by calling SaveCommonDataAreaToReplay on each stage, right?

Edit: someone on LoCaA told me that this was possible. Thanks!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on April 08, 2016, 03:06:43 PM
Alrighty, so out of personal interest I coded this up. Writing code for generic gradius options was pretty easy; setting it up like MoF where focus movement locks the options was much more difficult and I had to rework the approach a few times.

https://gist.github.com/drakeirving/1ef0f9a315468dc864a678caf550116b

As always, I aimed to make this as generic as possible. The number of options is arbitrary, and with the non-player version you can attach options to any Move object (e.g. a bullet).
You could very easily modify the for-player version to fire bullets and work properly when the player dies, which I didn't bother with.


Thanks man! :D
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on April 13, 2016, 07:49:25 PM
My Stage script starts to lag gradually about a minute after initiating the plural script. After 2 minutes, there's already only about 15FPS.
I checked and debugged my script many times, I came to realize it's definitely not an undeleted object, or a missing "yield;", and I still don't know what it is.
Is there a reason as to why my script might lag so much?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on April 13, 2016, 08:00:59 PM
My Stage script starts to lag gradually about a minute after initiating the plural script. After 2 minutes, there's already only about 15FPS.
I checked and debugged my script many times, I came to realize it's definitely not an undeleted object, or a missing "yield;", and I still don't know what it is.
Is there a reason as to why my script might lag so much?
Doesn't needs to be undeleted objects. Could be something that spawns endless number of threads being started doing things endlessly. Btw, missing yields cannot cause lag (directly). A missing yield in a loop would insta-freeze your game. A missing yield in a regular task with no loop would instant finish the the task and then become 'dead'.

You'll need to do some checking:
- What is happening in your Log Window when you look at threads, values and such after the plural has been started?
- What happens if you don't activate the plural script in your stage? (Not summoning the boss)
- What happens if you run the plural script alone from the dnh menu?


Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Fujiwara no Mokou on April 13, 2016, 08:27:34 PM
I came to realize it's definitely not an undeleted object, or a missing "yield;", and I still don't know what it is.

Two things come to mind.
First, can you ensure that all of your task blocks are able to terminate? If you're calling tasks left and right, and they get caught up in an infinite loop somewhere, they can bottleneck your fps.
Please take a look below:
Code: [Select]
task foo( let bar )
{
    // ex1:
    loop
    {
        ...
        // no break
    }

    // ex2:
    let baz = true;
    while( baz )
    {
         ...
        // baz not accessed, no break
    }
}

if foo is called, as an example, it may never return.
There's also a second thing. You want to ensure that scripts themselves terminate and don't just hang in limbo when they finish their job.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on April 14, 2016, 06:41:19 PM
So, by good ol' trial and error, I managed to find the problem.
It's the system file. :o

I still can't find the issue with it. I'm 100% sure there are no problems with the pause and replay scripts, because when I excluded them from the system file, the lag still persisted.
I've been looking at it for hours now, and I'm still struggling. (I swear if it's going to be something glaringly obvious--)

Here's my system script. (http://pastebin.com/gFubChRf)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on April 14, 2016, 08:24:14 PM
So, by good ol' trial and error, I managed to find the problem.
It's the system file. :o

I still can't find the issue with it. I'm 100% sure there are no problems with the pause and replay scripts, because when I excluded them from the system file, the lag still persisted.
I've been looking at it for hours now, and I'm still struggling. (I swear if it's going to be something glaringly obvious--)

Here's my system script. (http://pastebin.com/gFubChRf)
You'll need more trial and error. The fun just started.

Start commenting out everything in @Initialize. Everything.

- Now start from the top by removing the comment from InitFrame(); first.
- Run your game > observe Log Window for threads, tasks, objects, shots, etc.
- If lag / fps drop > you found your problematic thread/task.
- If no lag, uncomment the next line > repeat from run game.

In the mean while I'll use this system file on my own end to observe and repeat same steps when there is lag.

Edit
Well, it is as I suspected. There is a reason why I told you to observe your Log Window. It is your best friend with detecting lag and such. Always use it when debugging/testing these things. If you haven't activated your log window. Shame on you!  :flamingv:

So quickly activate it here.
[attach=1]


Now your problem is that there are objects being created endlessly.
[attach=2]

See how first there were ~500 and few moments later there are over 5000? Apply the above trial & error to find which task is responsible for this.

Edit 2
- Upon enabling TBossLife(); I started seeing object_count going up.

Edit 3
At Line #290 you're creating an object inside function RenderLife(); which is called when ObjScene statement is no longer invalid (the loop calls the function thus you're continuously making objects). You might want to deal with that, so the object is created once and then mutated/modified instead of recreated. No idea what you're trying to achieve here. But that might be source of your problems.

Make sure you check the rest of your script. Don't just stop here. Comment out the obj2 creation and continue checking other tasks for similar behaviour.

Hope you learned some effective trial & error. Will save you struggling in future  :D
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on April 15, 2016, 04:05:42 PM
ouch.
ouch.

Well, it is as I suspected. There is a reason why I told you to observe your Log Window. It is your best friend with detecting lag and such. Always use it when debugging/testing these things. If you haven't activated your log window. Shame on you!  :flamingv:

i didn't actually know it was a thing that exists, and when you told me in the last post, i couldn't find the option to activate it, so i... guess there's that. and i could've just asked but i'm a stubborn idiot :getdown:
i've never learned a single thing, have i.
also this log window is a godsend why haven't i heard of it before.

No idea what you're trying to achieve here.

To be honest, neither do I.
I should have put "ObjPrim_Create(OBJ_SPRITE_2D);" at the start of the task, not in the RenderLife function. (By the way, it's supposed to be a lifebar container thingy.)

So, yeah... I fixed the issue.
I sincerely apologize for wasting your time on this mess. And thank you.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on April 16, 2016, 07:16:56 AM
If you were wasting my time I wouldn't posting you know :V

To be honest, neither do I.
I should have put "ObjPrim_Create(OBJ_SPRITE_2D);" at the start of the task, not in the RenderLife function. (By the way, it's supposed to be a lifebar container thingy.)
Ooh, now I remember. Yea the little bars under the lifebar, counting the number of spell cards.


Good to hear you managed to fix it. Just keep in mind that any object or task you've made, and shouldn't be alive, should be killed/finished. I always test effects and such separately in a blanc script and monitor the object / task count to see if they are removed correctly.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on April 18, 2016, 05:57:51 PM
So, I really didn't want to clog up this thread with myself again, but...
WHAT THE ACTUAL HELL IS WRONG WITH THIS SCRIPT. (http://pastebin.com/FZZrfj7A) (<- link) It seems to be stable, yet Danmakufu keeps yelling at me!

The error says:

CreateOrbsS is not defined.
(CreateOrbsSは未定義の識別子です)
line(行)=102

That task is already defined!

Changing any of the parameters in the function results in the same error.

Now, this is where it gets interesting.
When I move the "CreateOrbsS(type, pos)" task above "Pattern", it results in THIS error:

BulletCommandsA1 is not defined.
(BulletCommandsA1は未定義の識別子です)
line(行)=134

Which is even weirder, considering it completely avoided the first half of the task, and decided to give me an error of the second half, which again, seems completely stable!
Oddly, when I remove "BulletCommandsA1(yinyang);" from the task, it then shows me the same error, but replaces "BulletCommandsA1 is not defined." with "MoveCommandsA1 is not defined.", and I have no clue why. All of these are properly defined.

Before anyone asks, yes, I did check if all the parentheses are matched. Yes, if I remove all mentions taks from the script, it runs perfectly (but it doesn't really do anything without them).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on April 18, 2016, 06:17:57 PM
So, I really didn't want to clog up this thread with myself again, but...
WHAT THE ACTUAL HELL IS WRONG WITH THIS SCRIPT. (http://pastebin.com/FZZrfj7A) (<- link) It seems to be stable, yet Danmakufu keeps yelling at me!

Check for missing semicolons, }, and ) in all of your #include files.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on April 18, 2016, 06:51:56 PM
Check for missing semicolons, }, and ) in all of your #include files.

The script worked perfectly before I added the two tasks I talked about in my post, so I don't think there's a problem with my #include files.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on April 18, 2016, 07:56:44 PM
The script worked perfectly before I added the two tasks I talked about in my post, so I don't think there's a problem with my #include files.

Oh wow I'm stupid. You have : instead of ; in various places in your script.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on April 18, 2016, 10:20:31 PM
You have : instead of ; in various places in your script.

oh
let objAwalys = Obj_Create(OBJ_IDIOT);
ObjPrim_SetTexture(objAwalys, GetCurrentScriptDirectory ~ "./well.png");
RaiseError("i'm done");
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 19, 2016, 08:57:14 AM
I just added functionality to sublime-danmakufu (https://www.shrinemaiden.org/forum/index.php/topic,16965.0.html) to highlight colons as invalid characters for this reason (whether you're using it or not). They really don't have any meaning in the language, so hey whatever.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on April 19, 2016, 09:31:29 AM
I just added functionality to sublime-danmakufu (https://www.shrinemaiden.org/forum/index.php/topic,16965.0.html) to highlight colons as invalid characters for this reason (whether you're using it or not). They really don't have any meaning in the language, so hey whatever.

I'm currently using Notepad++, but I think I might just switch to Sublime Text for the upgrade. Hopefully someone makes a version for NP++ (though it could be much harder).
Thank you.

EDIT: This syntax is beautiful. It was definitely worth switching from Notepad++ to this.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on April 19, 2016, 05:39:58 PM
Hopefully someone makes a version for NP++ (though it could be much harder).
I actually have such a version. I cannot remember where I found it, but I'm pretty sure it was not from here. It's semi outdated but adequate for me. I could try to get it up to date and send it to you if you haven't become too attached to Sublime already.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on April 19, 2016, 07:07:21 PM
I actually have such a version. I cannot remember where I found it, but I'm pretty sure it was not from here. It's semi outdated but adequate for me. I could try to get it up to date and send it to you if you haven't become too attached to Sublime already.

No need to, actually found one on these forums. (https://www.shrinemaiden.org/forum/index.php?topic=18133.0)
It's for ph3, and it also supports the Bespin theme, which is nice. Not quite sure if it's up to date or not.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on April 19, 2016, 08:07:09 PM
No need to, actually found one on these forums. (https://www.shrinemaiden.org/forum/index.php?topic=18133.0)
It's for ph3, and it also supports the Bespin theme, which is nice. Not quite sure if it's up to date or not.
The last update Danmakufu Ph3 received was in January 2015, two months before that post was made. So assuming the person who made it was thorough, it should be complete and up to date. Might have to try that one myself.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on April 26, 2016, 06:22:12 PM
Mod notice:
0.12m questions, if any, are welcome in this thread from now on. The main focus remains ph3, but we no longer wish to keep two separate threads. We don't expect people (or encourage them) to develop in the old engine as there is in our opinion no reason to do so any more.

Don't cry people. 0.12m served us well until this point on. But we know ph3 does it better. We will never forget you.

/me salutes.  ( ̄^ ̄)ゞ
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: arch on April 27, 2016, 10:49:04 PM
I need help figuring out how to implement this gameplay feature in my danmakufu project.

Basically what I want is a character that only gets shot down only if 2 or more bullets are touching the players hitbox.

At first I thought making this work would be easy. My initial idea was to have the hitbox disabled unless a bullet was touching a phantom hitbox, but I realized that the bullet that activated the phantom hitbox would immediately trigger the real one unless I could identify the exact bullet touching the phantom hitbox and making sure it wouldn't trigger a death.

Does anyone have an idea if making a hitbox that can ignore a particular object ID can be done?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on April 28, 2016, 02:21:35 AM
I need help figuring out how to implement this gameplay feature in my danmakufu project.

Basically what I want is a character that only gets shot down only if 2 or more bullets are touching the players hitbox.

At first I thought making this work would be easy. My initial idea was to have the hitbox disabled unless a bullet was touching a phantom hitbox, but I realized that the bullet that activated the phantom hitbox would immediately trigger the real one unless I could identify the exact bullet touching the phantom hitbox and making sure it wouldn't trigger a death.

Does anyone have an idea if making a hitbox that can ignore a particular object ID can be done?

Ignoring a particular object is very hard if you don't know precisely what object that is. However, if you want the player to only die if multiple bullets are colliding, then that's not too bad.

You'll want to use GetShotIdInCircleA1(GetPlayerX, GetPlayerY, reasonable value) and from there iterate over the array of shots returned. In each case, use GetShotDataInfoA1 to obtain the radius of the bullet hitbox (this value is defined in the shot sheet or defaults based off of the dimensions of the shots). If the distance between the player and the bullet is less than or equal to the sum of the bullet's hitbox radius and the player hitbox radius, that's a collision.

From there, just make sure that at least two shots are colliding, and you're all good to go (you will need to disable the player's hitbox or disable the bullet's hitbox if only one is touching so that the player does not die unintentionally)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: arch on April 28, 2016, 03:35:20 PM
Thank you Sparen, GetShotIdInCircleA1 was just what I needed!  :]

In case anyone is curious, here's how I've implemented it ATM. I still need to add proper detection of bullet size.

Code: [Select]
task tHitBox
{
loop{
while (length(GetShotIdInCircleA1(GetPlayerX,GetPlayerY,8))>1){
ObjPlayer_AddIntersectionCircleA1(objPlayer, 0, 0, 100, 20);
yield;
}//while
ObjPlayer_ClearIntersection(objPlayer);
yield;
}//loop
}

I do still have a small problem, since I'm using a non standard resolution and playing field size my character doesn't spawn in the lower center of the screen anymore, I can't seem to find where the default spawn coordinates are defined.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 29, 2016, 09:17:19 AM
Player starting position is (GetStgFrameWidth() / 2, GetStgFrameHeight() - 32).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on April 29, 2016, 04:39:27 PM
How do I make star shaped danmaku (like Sanae)?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on April 29, 2016, 06:36:38 PM
How do I make star shaped danmaku (like Sanae)?

Depends. You can create a shot and have it move and turn to make a star shape, spawning bullets at those locations, for example. Or you could spawn bullets using a parametric equation with appropriate offsets. Personally, I'd identify the five points you would like to use as the points, calculate the angle of each line, and spawn bullets along those lines to create the star.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 29, 2016, 07:57:42 PM
Like Sparen said, the best method is probably to find the points you want to draw between and then make lines of bullets between them. It's the easiest way to draw shapes in general.

Here is a good method on how to do this (more details are in a post immediately below):
https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1226299.html#msg1226299
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on April 29, 2016, 08:40:01 PM
I forgot about that. Thanks!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Nefer007 on April 30, 2016, 11:20:11 PM
I'm having a problem.

I'm trying to make a plural stage, but now it's crashing Danmakufu whenever I run it.

Code: [Select]
#TouhouDanmakufu[Plural]
#ScriptVersion[3]
#Title["EX Rumia Plural Script"]
#Text["EX Rumia Spell Cards"]
#Image[".\img\ExRumia(?????u?~?b?h?i?C?g?????@???G?v).png"]
#Background["script/default_system/Default_Background_IceMountain.txt"]

@Initialize
{
TPlural();
}

@MainLoop
{
yield;
}

@Finalize
{
}


task TPlural
{
let dir = GetCurrentScriptDirectory();

//Creates the boss scene
let obj = ObjEnemyBossScene_Create();
ObjEnemyBossScene_Add(obj, 0, dir ~ "boss1attack1.txt");
ObjEnemyBossScene_Add(obj, 0, dir ~ "boss1attack2hard.txt");
ObjEnemyBossScene_LoadInThread(obj);
ObjEnemyBossScene_Regist(obj);

//Stands by until the boss scene is finished
while(!Obj_IsDeleted(obj))
{
yield;
}

//The end of the script
CloseScript(GetOwnScriptID());
}

The nonspells are boss1attack1 and boss1attack2hard. Why isn't it going to load?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 01, 2016, 02:59:12 AM
I'm having a problem.

I'm trying to make a plural stage, but now it's crashing Danmakufu whenever I run it.

The nonspells are boss1attack1 and boss1attack2hard. Why isn't it going to load?

What is #Image[".\img\ExRumia(?????u?~?b?h?i?C?g?????@???G?v).png"] supposed to be? Danmakufu can't parse the stuff you put there.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on May 01, 2016, 10:13:03 AM
Hi!
Is there a way to manually open the pause script? Like a function when it called it open the pause menu without pressing any pause key?
I want to create a pseudo-continue system that occur before the actual danmakufu gameover by oppening a pause script but I don't know how to freeze the game during the pause menu and unfreeze it when the player leave the menu.


Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on May 01, 2016, 05:32:56 PM
I`m trying to make a circle :

Code: [Select]

let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
ObjPrim_SetPrimitiveType(obj,PRIMITIVE_TRIANGLESTRIP);
ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "MG1.png");
Obj_SetRenderPriority(obj, 0.69);

ObjPrim_SetVertexCount(obj,64);

ascent(a in 0..64){
ObjSpriteList2D_AddVertex(obj);
ObjSprite2D_SetSourceRect(obj, 1024/64*(a), 0, 1024/64*(a+1), 64);
ObjSprite2D_SetDestCenter(obj);
ObjPrim_SetVertexPosition(obj,a,bossX+64*cos(a*360/64),bossY+64*sin(a*360/64),0);
}

ObjSpriteList2D_CloseVertex(obj);

ObjRender_SetBlendType(obj,BLEND_ADD_RGB);

Aaand it doesn`t work. The circle does not appear. Why?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on May 01, 2016, 07:34:07 PM
You're trying to create a primitive object but using it as if it were a sprite list. Those are different.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on May 01, 2016, 07:53:28 PM
Then what should I do?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Nefer007 on May 01, 2016, 07:53:56 PM
This is just impossible...

Code: [Select]
#TouhouDanmakufu[Plural]
#ScriptVersion[3]
#Title["EX Rumia Plural Script"]
#Text["EX Rumia Spell Cards"]
#Image[".\stage/derp.png"]
#Background["script/default_system/Default_Background_IceMountain.txt"]

@Initialize
{
TPlural();
}

@MainLoop
{
yield;
}

@Finalize
{
}


task TPlural
{
let dir = GetCurrentScriptDirectory();

//Creates the boss scene
let obj = ObjEnemyBossScene_Create();
ObjEnemyBossScene_Add(obj, 0, dir ~ "boss1attack1.txt");
ObjEnemyBossScene_Add(obj, 0, dir ~ "boss1attack2hard.txt");
ObjEnemyBossScene_LoadInThread(obj);
ObjEnemyBossScene_Regist(obj);

//Stands by until the boss scene is finished
while(!Obj_IsDeleted(obj))
{
yield;
}

//The end of the script
CloseScript(GetOwnScriptID());
}

There's at least one error in this that is causing Danmakufu to crash, and I cannot find it. I need it to be fixed so I can have the workings of a finished game.

Can someone tell me why the ExRumia demo script works with a plural, but not this?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on May 01, 2016, 08:18:42 PM
Code: [Select]
#Image[".stage/derp.png"]
#Background["script/default_system/Default_Background_IceMountain.txt"]

Delete that code. Maybe that`s the problem.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on May 01, 2016, 08:41:47 PM
Use a forward slash instead of a backslash.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Nefer007 on May 01, 2016, 11:15:21 PM
Use a forward slash instead of a backslash.
Code: [Select]
#Image[".stage/derp.png"]
#Background["script/default_system/Default_Background_IceMountain.txt"]

Delete that code. Maybe that's the problem.

I can't delete the code. I managed to cobble together a working #SetScriptPath and it worked but the boss didn't spawn. What do?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on May 01, 2016, 11:54:49 PM
I repost it on the new page:
Hi!
Is there a way to manually open the pause script? Like a function when it called it open the pause menu without pressing any pause key?
I want to create a pseudo-continue system that occur before the actual danmakufu gameover by oppening a pause script but I don't know how to freeze the game during the pause menu and unfreeze it when the player leave the menu.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 02, 2016, 01:48:30 AM
I can't delete the code. I managed to cobble together a working #SetScriptPath and it worked but the boss didn't spawn. What do?

Did you follow Fluffy8x's advice and use / instead of \ for the image path?

Also, what do you mean by 'a working #SetScriptPath'
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 02, 2016, 05:31:04 AM
You do need to use a forward slash rather than a backslash in script, but it doesn't matter in the headers.


Honestly there must be something else to your problem since I can copypaste your code and have it run fine given I name files properly.

Hi!
Is there a way to manually open the pause script? Like a function when it called it open the pause menu without pressing any pause key?
I want to create a pseudo-continue system that occur before the actual danmakufu gameover by oppening a pause script but I don't know how to freeze the game during the pause menu and unfreeze it when the player leave the menu.
There is probably an acceptable way to accomplish what you're thinking of, so maybe you should describe it in more detail rather than asking for a particular kind of solution.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on May 02, 2016, 08:23:20 AM
Well. I just want to create a continue system without using the package script. So I thought to use a simple Pause menu with options like in a Game Over menu (but I still keep a true pause menu beside). And I want to call this menu when it remain one life (with this, I avoid the true danmakufu end menu).
But I have no idea how I can do this.
(I hope it's almost clear  :ohdear:)

edit: I think I actually found a way to do that by using a common data in my main script and opening pause script in package script with this. But I don't know if it's possible to do without a package script...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on May 02, 2016, 02:39:28 PM
Well. I just want to create a continue system without using the package script. So I thought to use a simple Pause menu with options like in a Game Over menu (but I still keep a true pause menu beside). And I want to call this menu when it remain one life (with this, I avoid the true danmakufu end menu).
But I have no idea how I can do this.
(I hope it's almost clear  :ohdear:)

edit: I think I actually found a way to do that by using a common data in my main script and opening pause script in package script with this. But I don't know if it's possible to do without a package script...

I think it's possible with any type of script (even Single), if you just mess around with the system files.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on May 02, 2016, 06:21:06 PM
Well. I just want to create a continue system without using the package script. So I thought to use a simple Pause menu with options like in a Game Over menu (but I still keep a true pause menu beside). And I want to call this menu when it remain one life (with this, I avoid the true danmakufu end menu).
But I have no idea how I can do this.
(I hope it's almost clear  :ohdear:)

edit: I think I actually found a way to do that by using a common data in my main script and opening pause script in package script with this. But I don't know if it's possible to do without a package script...
I have made this precise system you're looking for in my game, Ephemeral Unnatural Balance. You are correct in your thought process, however the only way to induce the game to pause outside of pressing the Pause key is to use this function: PauseStageScene

The only problem with this process is that PauseStageScene can only be called within a Package script, anywhere else will cause an error. This pretty much means a continue system in this manner REQUIRES a Package script unfortunately. If you want to know more about how precisely I made this system work, let me know and I'll be happy to elaborate on what I did.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Fujiwara no Mokou on May 02, 2016, 06:49:41 PM
This is just impossible...

There's at least one error in this that is causing Danmakufu to crash, and I cannot find it. I need it to be fixed so I can have the workings of a finished game.

Can someone tell me why the ExRumia demo script works with a plural, but not this?

Try placing a few yields at the very start of the task. This seems to be a prevalent problem with Danmakufu.
Unlike in my engine, which is coming along nicely...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 03, 2016, 01:41:25 AM
Try placing a few yields at the very start of the task. This seems to be a prevalent problem with Danmakufu.
Wat. I've never had this sort of problem, and it makes no sense to arbitrarily yield tasks for a frame. This was a problem in 0.12 if you wanted to start a task that tried to render image resources before @Initialize was finished (or something along those lines, it's been a while), but ph3 doesn't have this issue.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on May 03, 2016, 09:25:36 AM
Nefer> Try
Code: [Select]
let obj = ObjEnemyBossScene_Create(); out of any task or @ instead of in the TPlural. If you put it in TPlural, obj will exist only in this task and not in the entire script.
I'm not sure ti was the problem but It's a bit wreid for me.

ExPorygon> Thanks. That's what I thought. But since I'm trying to do a full game, I'll use package script. I just want to avoid any return to package script before the actual end of the script (by death with no continue remaining or by end of the game). If I have any question, I'll ask you :D
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 03, 2016, 09:56:08 AM
Nefer> Try
Code: [Select]
let obj = ObjEnemyBossScene_Create(); out of any task or @ instead of in the TPlural. If you put it in TPlural, obj will exist only in this task and not in the entire script.
I'm not sure ti was the problem but It's a bit wreid for me.
It shouldn't matter, since the Scene object isn't referenced outside the task. Having it be undefined outside the task and trying to reference it would throw an error instead of crashing anyways.
Like I said, you can copypaste the code just fine and have it work. There's something else to the problem that they haven't described.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on May 06, 2016, 08:09:20 PM
Hi! It's not an actual question about danmakufu but more a question about organisation and project making. I ask this espacially to people who make actual full games.
How do you organize your work? What do you make first? Danmaku or all the menus and system? And about all graphics and sounds? And about scenario?
I start new full game project but I don't really know (or I actually know but I want others advinces and experiences) how to plan my task and I know how it's really hard to stay in the right way.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Whatever on May 07, 2016, 02:03:15 PM
Hi, I needed some help with my spell background.
I've been trying to replicate Junko's background but there are some (lots of) problems.

http://imgur.com/a/5JhDp (I don't know how to attach images...)

In the first picture there's a line where the bg originate out from, I want it to originate from a specific point, not from a line.
In the second picture, as the time passes on, the bg becomes stretched out and more uniformed, I don't want this to happen.
Here's the code:
Code: [Select]
let path2 = current~ "cdbg06a.png";
let bg2 = ObjPrim_Create(OBJ_PRIMITIVE_2D);
ObjPrim_SetPrimitiveType(bg2,PRIMITIVE_TRIANGLEFAN);
ObjRender_SetBlendType(bg2, BLEND_SUBTRACT);
Obj_SetRenderPriority(bg2, 0.21);
ObjPrim_SetTexture(bg2, path2);
ObjSprite2D_SetDestRect(bg2,-0, 0, GetX, GetY);

let t = 0;
let ti = 10;
let alpha = 0;
loop{
determine;
if(isSpell){alpha=1;}
else{alpha=0;}
                let px = GetCenterX;
let py = GetCenterY-150;
let vc = 62;

ObjSprite2D_SetDestCenter(bg2);
ObjPrim_SetVertexCount(bg2,vc);

ObjPrim_SetVertexPosition(bg2,0,px,py,1);
ObjPrim_SetVertexUVT(bg2,0,512*(t/300),1048);

ascent(i in 0..vc){
ObjPrim_SetVertexPosition(bg2,i+1,px+ti*cos((360/(vc-3))*i-90),py+ti*sin((360/(vc-3))*i-90),1);
ObjPrim_SetVertexAlpha(bg2,i,alpha*200);
}

ascent(i in 0..vc){
ObjPrim_SetVertexUVT(bg2,i+1,0,(512/vc*5)*i);
}
ObjPrim_SetVertexPosition(bg2,vc-1,px+ti*cos(0-90),py+ti*sin(0-90),1);
ObjPrim_SetVertexUVT(bg2,vc-1,0,512);
ObjPrim_SetVertexAlpha(bg2,vc-1,alpha*200);
t++;
ti+=1;
yield;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 07, 2016, 05:03:23 PM
Hi! It's not an actual question about danmakufu but more a question about organisation and project making. I ask this espacially to people who make actual full games.
How do you organize your work? What do you make first? Danmaku or all the menus and system? And about all graphics and sounds? And about scenario?
I start new full game project but I don't really know (or I actually know but I want others advinces and experiences) how to plan my task and I know how it's really hard to stay in the right way.

It's really up to you. Personally, I built a stable in-game system over the course of a year or so, and then I only worked on the package when I began Digital Earth: Conquest. And of course, I started rather simple and gradually added new features (e.g. Spell card Practice, Continue System, etc.). This method is the least painful and most intuitive, though it results in ugly code when you retrofit older code to work with newer features.

As for the content itself, I personally cannot work on a stage without having the stage background, graphics, and music all complete beforehand. And for bosses, I need to have all of the assets ready.

This is because there's a flow and an aesthetic to each component of your game, and, for example, if your stage background scrolled fast but your music was slow and your enemies spawned at weird times and at weird places, that would feel 'off' to the player. So especially for stages, I highly recommend having all of your assets ready beforehand so that you can make the stage flow well with the music (i.e. have a distinct part of the song where the mid boss appears).

So for me, menus and systems are a gradual process, and graphics + sound need to come before the actual danmaku.

As for content, it is imperative that you know the entire plot, the characters and their interactions, etc. BEFORE starting your project. Otherwise you risk losing quite a lot - for me personally, I didn't solidify the main plots of either Pok?DigiDanmaku or Digital Earth: Conquest until late in the game, and the stories were pretty bad as a result. It's especially important to know your plot and how the characters interact with each other beforehand if you're making original characters - their actions, personality, and abilities will have a direct impact on the aesthetic they present, including the music, graphics, sprite animations, spell names, and most importantly, the type of danmaku they fire.

If a character is hyperactive and flamboyant and uses guns, then you make danmaku that represents that character, etc. It's very easy to overthink this, however, so I recommend planning the type of non spells a character has as well as general danmaku style before starting the first stage they appear in.

And another thing: In regards to organization, I *highly* recommend having one folder specifically for images that will hold EVERY image asset you use in your game. This way it's very easy to archive later on, and you always know where things are. The same goes for sound - have one folder specifically to hold sound effects, and label your bgm tracks in the filename (e.g. boss1.ogg instead of <Name of track>.ogg) I also highly discourage having libraries everywhere (it makes things hard to find), and always keep all of your fonts in one place.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Agent17 on May 08, 2016, 12:38:35 PM
Hi, i've got a little problem on a task, it shows me this error :
(http://puu.sh/oKt5S/22f1ff3503.png)
, and i don't really know what to do to fix it.

Heres the code used for the task if it can help you :
EDIT : i found a way to fix the first error, but now it shows me the "you are using a variable that has not been set yet." error, heres the updated task :
Code: [Select]
task DeleteShotToItem(x,y,radius,type,deltype) { //Deletes bullets and leaves a bullet break image
let iArray = GetShotIdInCircleA2(x,y,radius,TARGET_ENEMY);
ascent(i in 0..length(iArray)) {
let col = ObjShot_GetImageID(iArray[i]);
let color = GetShotDataInfoA1(col,TARGET_ENEMY,INFO_DELAY_COLOR); //Line where the error occurs
DelEffect(GetX(iArray[i]),GetY(iArray[i]),type,[color[0],color[1],color[2]]);
DeleteShotInCircle(TYPE_ALL,deltype,GetX(iArray[i]),GetY(iArray[i]),2);
}

task DelEffect(x,y,typ,Col) { //Bullet break image task
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
let path = GetCurrentScriptDirectory~"./img/Effect/BulletBreak.png";
Obj_SetRenderPriorityI(obj,35);
ObjPrim_SetTexture(obj,path);
ObjRender_SetPosition(obj,x,y,0);
ObjSprite2D_SetSourceRect(obj,0,0,32,32);
ObjSprite2D_SetDestCenter(obj);
ObjRender_SetColor(obj,Col[0],Col[1],Col[2]);
ObjRender_SetAlpha(obj,200);
ObjRender_SetScaleXYZ(obj,0.5,0.5,0);
ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
ascent(i in 0..8) {
ObjSprite2D_SetSourceRect(obj,32*(i-1),0,32*i,32);
wait(5);
}
Obj_Delete(obj);
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 08, 2016, 01:30:31 PM
For one, color is already [color[0],color[1],color[2]] so you can just pass it directly. As for the problem, I am noticing a bit of potential variable name confusion but I'm not sure. You never specified on which line or variable the current error is about.

In any case, can I ask why you're making a function to do this delete-to-item effect? Are you only ever going to use this effect when using this function? Because this sounds like something you'd do a lot. Item scripts provide you with a way to have this sort of effect occur whenever bullets are deleted, as the engine will fire EV_DELETE_SHOT_* events and you can handle the effect behaviour in the item script. Then when you want to delete bullets you can just call the DeleteShotInCircle method as you usually would. It would be more efficient than your current method as well. (You would have to learn a bit on how to set this up, but you've already done most of the effect work already.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Agent17 on May 08, 2016, 02:24:24 PM
Thanks for the reply, that function was basically made for overall shot deleting, with the deltype parameter being either TYPE_IMMEDIATE or TYPE_ITEM with a bullet break effect.
My problem was with getting the bullet's color, but i fixed it by deleting the bullet in a separate ascent loop after the one for making the break effect.
So, thank you anyway !
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on May 09, 2016, 06:02:43 PM
Thanks Sparen.

Just about this:
Quote
I *highly* recommend having one folder specifically for images that will hold EVERY image asset you use in your game. This way it's very easy to archive later on, and you always know where things are.
Do you mean a separated file where you put every images used in any way in the project with .psd and all other layered stuff or an actual file of the game with all the images in?

So, now I need to found someone to make me cool musics before I can start stage and bosses making :(

If someone else have advices about full game making, don't hesitate ^^. I have almost my way to do but other point of view are always a good thing ;).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 09, 2016, 08:36:15 PM
Thanks Sparen.

Just about this:Do you mean a separated file where you put every images used in any way in the project with .psd and all other layered stuff or an actual file of the game with all the images in?

So, now I need to found someone to make me cool musics before I can start stage and bosses making :(

If someone else have advices about full game making, don't hesitate ^^. I have almost my way to do but other point of view are always a good thing ;).

I personally keep my .psd, .svg, and .xcf files in a separate folder elsewhere, and I only keep the exported .png and .jpg files directly used by the game in my script's img folder. It's up to you, of course.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on May 10, 2016, 06:50:18 PM
That's exactly what I'm doing. Actually my ask is:
By this:
Quote
I *highly* recommend having one folder specifically for images that will hold EVERY image asset you use in your game. This way it's very easy to archive later on, and you always know where things are.
You mean "have every images used in the game in one unique picture folder in the game file" right? And not "keep every .psd and other in one unique folder out of the game folder".
I'm not sure if it's clear or not :(
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 10, 2016, 08:17:37 PM
That's exactly what I'm doing. Actually my ask is:
By this: You mean "have every images used in the game in one unique picture folder in the game file" right? And not "keep every .psd and other in one unique folder out of the game folder".
I'm not sure if it's clear or not :(

That's what I meant, yes.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on May 11, 2016, 12:43:19 PM
Code: [Select]
task TBossTimer
{
let objNum = ObjText_Create;
let objScene;

loop{
objScene = GetEnemyBossSceneObjectID();
while(objScene != ID_INVALID){
RenderTimer;
}
yield;
}

function RenderTimer{
while(objScene == ID_INVALID){yield;}
let timer = ObjEnemyBossScene_GetInfo(objScene, INFO_TIMER);
        ObjText_SetFontSize(objNum, 24);
        ObjText_SetText(objNum, rtos("00", timer));
        ObjText_SetFontType(objNum, "Russell Square Regular");
        ObjText_SetFontBold(objNum, true);
        ObjText_SetFontColorTop(objNum, 255, 255, 255);
        ObjText_SetFontColorBottom(objNum, 255, 255, 255);
        ObjText_SetFontBorderType(objNum, BORDER_FULL);
        ObjText_SetFontBorderColor(objNum, 0, 0, 0);
        ObjText_SetFontBorderWidth(objNum, 2);
        Obj_SetRenderPriority(objNum, 0.5);
        ObjRender_SetX(objNum, 395);
        ObjRender_SetY(objNum, 2);
        while(true){
                timer = ObjEnemyBossScene_GetInfo(objScene, INFO_TIMER);
                timer = min(timer, 999);
                ObjText_SetText(objNum, rtos("00", timer));
                yield;
        }
}
}

My timer works only during the midboss; It just stays at zero during the boss battle. Any reasons why? It works well when I use the default timer. (You might see some random useless garbage thrown in to the code, but that's just because I've been going crazy to fix it for like 3 days.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Agent17 on May 11, 2016, 02:25:40 PM
My timer works only during the midboss; It just stays at zero during the boss battle. Any reasons why? It works well when I use the default timer. (You might see some random useless garbage thrown in to the code, but that's just because I've been going crazy to fix it for like 3 days.)
The issue might be because the timer doesn't delete after a single script is closed. Here's the code with not that issue when playing it in single scripts, i might test it with plurals later but i got to go right now :
Code: [Select]
task TBossTimer
{
let objNum = ObjText_Create;
let objScene;

loop{
objScene = GetEnemyBossSceneObjectID();
if(objScene != ID_INVALID){
RenderTimer;
}
yield;
}

function RenderTimer{

let timer = ObjEnemyBossScene_GetInfo(objScene, INFO_TIMER);
        ObjText_SetFontSize(objNum, 24);
        ObjText_SetText(objNum, rtos("00", min(timer,999)));
 
        ObjText_SetFontBold(objNum, true);
        ObjText_SetFontColorTop(objNum, 255, 255, 255);
        ObjText_SetFontColorBottom(objNum, 255, 255, 255);
        ObjText_SetFontBorderType(objNum, BORDER_FULL);
        ObjText_SetFontBorderColor(objNum, 0, 0, 0);
        ObjText_SetFontBorderWidth(objNum, 2);
        Obj_SetRenderPriority(objNum, 0.5);
ObjText_SetFontType(objNum, "Russell Square Regular");
        ObjRender_SetX(objNum, 395);
        ObjRender_SetY(objNum, 2);
        loop(ObjEnemyBossScene_GetInfo(objScene, INFO_TIMER)*60) { 
timer = ObjEnemyBossScene_GetInfo(objScene, INFO_TIMER);
ObjText_SetText(objNum, rtos("00", min(timer,999)));
yield;
}
Obj_Delete(objNum);
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on May 11, 2016, 04:43:15 PM
It doesn't work. All it changed is that it now deletes the whole timer after the boss appears. Also, I specifically said it worked well with the midboss, but stopped working during the boss, meaning I'm making a Stage script, not a Single or Plural script. It works perfectly in Single.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on May 11, 2016, 07:09:57 PM
Here, my timer code. If it can help you:
Code: [Select]
//----------------------------------------------------
//BOSS TIMER
//----------------------------------------------------
task TBossTimer {
let timer = -1;
let time01_path =  GetCurrentScriptDirectory() ~ "se/se_timeout.wav";
let time02_path = GetCurrentScriptDirectory() ~ "se/se_timeout2.wav";
let timer_end = false;
let f = 0;
let count = 5;
let num_id = [ObjText_Create,ObjText_Create,ObjText_Create,ObjText_Create,ObjText_Create,ObjText_Create];
let sep = "";
let sep_space = 6;
let size_min = -6;
let pulse = 0;
let r = 0;
let listNum = DigitToArray(timer, 5);
let objScene = ID_INVALID;
let taskOn = true;

ascent(iObj in 0 .. 5) {
if((4-iObj) == 2) {
sep_space = 0;
size_min = 0;
}
if((4-iObj) == 3) {
sep_space = 0;
}
let num = listNum[4-iObj];
Text(num_id[4-iObj], "",196-iObj*12+sep_space, 14-0.75*size_min, 18+size_min, 255, 255-r, 255-r, 255, 255-r, 255-r, 8+r, 8, 8, 0.70);
}


while(taskOn == true) {
objScene = GetEnemyBossSceneObjectID();
if(objScene == ID_INVALID) {
ascent(iObj in 0 .. 5) {
let num = listNum[4-iObj];
if((4-iObj) == 3) {
if((iObj) < count) {
sep = ",";
} else if((iObj) == count) {
sep = " ";
}
} else {
sep = "";
}
ObjText_SetText(num_id[4-iObj], "");
}
} else if(objScene != ID_INVALID) {
if(timer == -1) {timer = 100*ObjEnemyBossScene_GetInfo(objScene, INFO_TIMER);}
if(timer < 100*ObjEnemyBossScene_GetInfo(objScene, INFO_TIMER)) {timer = 100*ObjEnemyBossScene_GetInfo(objScene, INFO_TIMER);}
f += 1/0.6;
timer -= 1/0.6;
if(timer < 0) {timer = 0;}
if(timer > 1000) {r = 0;}
if(timer <= 1000) {r = 80;}
if(timer <= 500) {r = 120;}


if(timer <= 1000 && timer > 997) {
SE(time01_path);
timer_end = false;
}
if(timer <= 900 && timer > 897) {SE(time01_path);}
if(timer <= 800 && timer > 797) {SE(time01_path);}
if(timer <= 700 && timer > 697) {SE(time01_path);}
if(timer <= 600 && timer > 597) {SE(time01_path);}

if(timer <= 500 && timer > 495) {SE(time02_path);}
if(timer <= 400 && timer > 395) {SE(time02_path);}
if(timer <= 300 && timer > 295) {SE(time02_path);}
if(timer <= 200 && timer > 195) {SE(time02_path);}
if(timer <= 100 && timer > 95) {SE(time02_path);}
if(timer <= 0 && timer_end == false) {
SE(time02_path);
timer_end = true;
}

count = truncate(log10(1+timer));
if(count < 3) {count = 3;}
let listNum = DigitToArray(timer, 5);
ascent(iObj in 0 .. 5) {
let num = listNum[4-iObj];
if((4-iObj) == 3) {
if((iObj) < count) {
sep = ",";
} else if((iObj) == count) {
sep = " ";
}
} else {
sep = "";
}
if((iObj) > count) {
ObjText_SetText(num_id[4-iObj], "");
} else {
ObjText_SetText(num_id[4-iObj], sep ~IntToString(num));
}
ObjText_SetFontColorTop(num_id[4-iObj],  255, 255-r, 255-r);
ObjText_SetFontColorBottom(num_id[4-iObj],  255, 255-r, 255-r);
ObjText_SetFontBorderColor(num_id[4-iObj],8+r, 8, 8);
}
}
yield;
}
}
(don't mind about while(taskOn == true), I don't know loop{stuff} works when I wrote this).

If I remember correctly, when there is no boss, the timer is still here but invisible with space instead of numbers. And when there is a boss, it take the value of the actual boss timer.
I don't know if it's the best way to do but it works fine.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on May 11, 2016, 07:10:24 PM
It doesn't work. All it changed is that it now deletes the whole timer after the boss appears. Also, I specifically said it worked well with the midboss, but stopped working during the boss, meaning I'm making a Stage script, not a Single or Plural script. It works perfectly in Single.

Once a boss scene is created, objScene becomes equal to the id of the boss scene (via GetEnemyBossSceneObjectID). Once that happens, however, it can never become ID_INVALID again due to how you wrote the code. This is because the while loop never closes and the objScene = GetEnemyBossSceneObjectID(); line never gets run again. In fact, the way you have it set up makes the while(objScene != ID_INVALID) an infinite loop, which in turn is starting another infinite loop within the RenderTimer function.

If the GetEnemyBossSceneObjectID were to change, like when one boss dies and another one later on in the stage is created, then the objScene variable would still be stuck on the previous, now deleted, object scene id.

Because of this, Agent's solution should be working, but it isn't because there's nothing recreating the text object. By moving the let objNum = ObjText_Create; line inside the function, it can be made to work. The other problem with Agent's solution was that he changed the while loop in the function to one that looped for the specific amount of time the a spell would go until timeout, which doesn't work if the spell is ended early by damaging the boss. This is what I've come up with:

Code: [Select]
task BossTimer
{
let objScene;
loop{
objScene = GetEnemyBossSceneObjectID();
if(objScene != ID_INVALID){
RenderTimer;
}
yield;
}

function RenderTimer{
let objNum = ObjText_Create;
let timer = ObjEnemyBossScene_GetInfo(objScene, INFO_TIMER);
        ObjText_SetFontSize(objNum, 24);
        ObjText_SetText(objNum, rtos("00", min(timer,999)));
 
        ObjText_SetFontBold(objNum, true);
        ObjText_SetFontColorTop(objNum, 255, 255, 255);
        ObjText_SetFontColorBottom(objNum, 255, 255, 255);
        ObjText_SetFontBorderType(objNum, BORDER_FULL);
        ObjText_SetFontBorderColor(objNum, 0, 0, 0);
        ObjText_SetFontBorderWidth(objNum, 2);
        Obj_SetRenderPriority(objNum, 0.5);
ObjText_SetFontType(objNum, "Russell Square Regular");
        ObjRender_SetX(objNum, 395);
        ObjRender_SetY(objNum, 2);
        while(GetEnemyBossSceneObjectID() != ID_INVALID) { 
timer = ObjEnemyBossScene_GetInfo(objScene, INFO_TIMER);
ObjText_SetText(objNum, rtos("00", min(timer,999)));
yield;
}
Obj_Delete(objNum);
}
}
I have tested this in a stage setting and it indeed works. Hope my explanation make sense, I'll try to explain more if you're still unsure.

EDIT: Whoops, I forgot to change the X and Y coordinates of the timer back to their original values, I had moved them so I could make sure that I was seeing the timer. My bad, feel free to change them back.
EDIT2: I fixed it, hopefully I didn't miss anything else. In any case, the timer should at least be appearing during all bosses now.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on May 11, 2016, 08:21:12 PM
Highly intelligent stuff.

Oh, I can see why it didn't work now. Thank you so much for helping me with the problem, your explanation was superb.
I seem to be remarkably good at making chains of accidental infinite loops :V
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on May 11, 2016, 10:12:06 PM
Oh, I can see why it didn't work now. Thank you so much for helping me with the problem, your explanation was superb.
I seem to be remarkably good at making chains of accidental infinite loops :V
Don't sweat it, it was actually a fun problem to debug. Until my debug functions needed debugging...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on May 12, 2016, 05:49:04 AM
Don't sweat it, it was actually a fun problem to debug. Until my debug functions needed debugging...

I'll try, but I'm pretty much crap at debugging. That's why you see me so many times in this thread.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 16, 2016, 08:34:22 AM
Hi, I needed some help with my spell background.
I've been trying to replicate Junko's background but there are some (lots of) problems.

http://imgur.com/a/5JhDp (I don't know how to attach images...)

In the first picture there's a line where the bg originate out from, I want it to originate from a specific point, not from a line.
In the second picture, as the time passes on, the bg becomes stretched out and more uniformed, I don't want this to happen.
Hi, I had forgotten about this. I saw it and set it aside for later because I knew it'd be problematic and I didn't want to think about how to do it properly, and just never got back to it until recently.

As for why it becomes more stretched out, that's just because your U-values for v0 are moving while the U-values for v1 ... v52 are all staying at 0.

The main issue here is that you can't accomplish what you want using trianglefans. There's really no way to map the texture into a circle coming out from a point using a fan because there isn't just one origin point in the texture. Here is what you're currently doing (click):

(https://i.imgur.com/2DOILpl.png)

This is at some point in time when your v1's U-value hits 512. The lines end at the left edge of the image (which repeats vertically) and the endpoints (i.e. the rest of the vertices) are evenly spaced vertically, if you can imagine that. These are the triangles that are wrapped around in the circular fan. You should be able to see that the two "edges" of the fan are never going to have the pattern match up, which creates that big line.

After rigorously examining Junko's actual background to see how ZUN does it, this is what I have:

(https://i.imgur.com/zX6XPFF.png)

This is an example of what would be the proper mapping. Each strip here is distorted into a triangular shape (each of the two vertices on the right are squished together) and arranged in a fan. One important difference is that the vertices that meet in the center are all different for each triangle. You can look at the whole mapped texture as if the entire right side of the UV rectangle is condensed into a point, and the rest is wrapped around that point. This way the two "edges" of the fan will match up (except not quite because the texture doesn't perfectly tile vertically, lol ZUN). Then, getting to background to scroll the way it does is just moving the whole UV rectangle to the right.

Now that I've explained how the background is supposed to work, there's still a big problem. Because it works by distorting rectangles, there is a problem where you won't get the results you'd expect. Because rectangles are rendered as just two triangles stuck together, what happens is that when you try to distort it they are distorted as separate shapes rather than one contiguous shape, and the overall texture barely looks like it's supposed to. This is a classical problem with a solution called perspective correct texture mapping (example (http://stackoverflow.com/questions/15242507/perspective-correct-texturing-of-trapezoid-in-opengl-es-2-0)), but implementing this doesn't seem to be very feasible in Danmakufu. You might be able to program a shader to do this, but I don't have much experience with it.

In any case, you can mostly work around it by increasing the number of vertices until it looks smooth enough. I don't particularly like this solution but it'll work. I've made the background myself, and this is what you get.

(http://i.imgur.com/b35Yiik.png) (http://i.imgur.com/O71kTrC.png) (http://i.imgur.com/2um3BDp.png)

Code: https://gist.github.com/drakeirving/8283a5ed47061c19bc4cc4d26e849226

i spent way too long on this
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Whatever on May 16, 2016, 10:07:42 AM
I thought no one noticed my question so I already went ahead and fixed it myself a little while ago...
Thanks anyway.... :getdown:
http://imgur.com/6Hixkz0

P.S. lol, that spell history cover-up :V.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: fareed_asyraaf on May 21, 2016, 07:28:19 AM
Hello guys, I'm new here and in Danmakufu 0.12m.
can someone help me anim this sprite for danmakufu 0.12m?
https://www.mediafire.com/?5pdgyuentafdm4v <--- Flandre Scarlet sprite..
please guys help me! T_T
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on May 21, 2016, 04:27:21 PM
Hello guys, I'm new here and in Danmakufu 0.12m.
can someone help me anim this sprite for danmakufu 0.12m?
https://www.mediafire.com/?5pdgyuentafdm4v <--- Flandre Scarlet sprite..
please guys help me! T_T
There are at least a couple tutorials for animation in 0.12m like this one. (https://www.youtube.com/watch?v=JUj6xG79-TY) It's old, but so is 0.12m (I really recommend you learn ph3 instead).

More tutorials for both versions can also be found here. (https://www.shrinemaiden.org/forum/index.php/topic,6181.msg345023.html#msg345023)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Asthmagician on May 25, 2016, 02:56:13 PM
I've been searching the wiki and the official documentation, and I've been wondering, how does danmakufu handle dictionaries / associative arrays (if at all)?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 25, 2016, 03:10:33 PM
I've been searching the wiki and the official documentation, and I've been wondering, how does danmakufu handle dictionaries / associative arrays (if at all)?

As of now, there is no native support for any form of mapping except for the standard arrays.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on May 25, 2016, 03:16:16 PM
You can use common data instead, or you can implement hashtables yourself.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Asthmagician on May 25, 2016, 04:27:47 PM
You can use common data instead, or you can implement hashtables yourself.
Common data seems to be a rough fit for what I'm looking to do, thanks
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mеа on May 25, 2016, 04:46:48 PM
Common data is apparently tricky since it's shared across scripts, totally global, and can (I think sometimes) get corrupted or screwed up on replays. Doesn't sound too reliable. You're probably better off with that hash table suggestion, it's not too hard to do it yourself.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on May 25, 2016, 08:22:55 PM
MKM appears to have problems with null pointers when it comes to loading common data. Just avoid empty arrays and strings like the plague for areas you want to save to replays or files.

Of course, if you need to manage multiple hash tables, then implementing them yourself is the way to go.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 26, 2016, 02:50:30 AM
You can very much use the exact same functionality as CommonData without messing around with global scope clutter by using Obj_SetValue and GetValue. It's probably a sort of hashing implementation under the hood anyways; the main barrier is that they need an object to be attached to and there isn't any kind of truly generic object. You can effectively work around this by just using an Enemy object and never registering it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Asthmagician on May 26, 2016, 11:19:01 AM
You can very much use the exact same functionality as CommonData without messing around with global scope clutter by using Obj_SetValue and GetValue. It's probably a sort of hashing implementation under the hood anyways; the main barrier is that they need an object to be attached to and there isn't any kind of truly generic object. You can effectively work around this by just using an Enemy object and never registering it.
This seems to be a much better fit, can't believe I missed this, thanks.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on June 01, 2016, 05:54:30 PM
How do I take the texture of the stage BEFORE it finishes (I?m talking about packages), so I wouldn?t have a black background?

http://pastebin.com/BaAFBkfw
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 02, 2016, 05:33:29 AM
I don't really understand the question. You don't seem to do anything on the finish state besides call other functions and I don't know what they do. I'm assuming TilteScreen goes to the title screen and Stage restarts the stage; does ClearScene launch another script and return a script result? I'm not sure what you're doing at all.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Whatever on June 02, 2016, 11:16:42 AM
*an another overly complex question arrives...
I'm currently experimenting with hlsl's, but I found out that it can somehow screw up the alpha of the spell background.
It also apparently affects the stage background too, but the change isn't much noticeable.
what it looks like:
http://imgur.com/a/zcgw2 (still don't know image attaching)
I tried fixing it for quite sometime now, but I can't find what causes the darkening.
Here's both the code for hlsl and the task that calls it:
http://pastebin.com/aardDBgg

EDIT: The issue has been resolved.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Random Sphere on June 02, 2016, 06:42:22 PM
How do I take the texture of the stage BEFORE it finishes (I?m talking about packages), so I wouldn?t have a black background?

http://pastebin.com/BaAFBkfw


Nevermind, I fixed my problem.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on June 06, 2016, 07:21:23 PM
Hi!

I'm searching how I can change the alpha value of an OBJ_SPRITE_LIST_2D object.
I try to use ObjRender_SetAlpha but it does nothing.
I found ObjSpriteList2D_CloseVertex that's supposed to allow to transform all rectance of the list with ObjRender_ but it still not work.

I'd pastebin a part of the script here: http://pastebin.com/raw/zGkurXzh

I need help  :ohdear:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 07, 2016, 10:54:00 AM
Before you use CloseVertex, using coordinate transforms like SetPosition/Angle/Scale are applied only to the next sprite added. After you use CloseVertex, it affects the whole object together, taking (0,0) as object center.
So ObjSpriteList2D_SetDestRect maps the texture relative to a sprite's position, ObjRender_SetPosition sets the sprite's position relative to the object's position, and using ObjSpriteList2D_CloseVertex and then ObjRender_SetPosition sets the object's position. So depending on how you use these all together you can get some interesting results with how you map sprites.

For example, if you position sprites at (0,0), (10,0), (20,0), close the list, then position the object at (100,100), the sprites will end up at actual positions (100,100), (110,100), (120,100).
(But you already know this given how you're moving the dialogue box.)


ObjRender_SetAlpha works fine as long as you use it per-sprite, but it doesn't work on the whole thing. And like other render functions, it also applies to every sprite added afterwards without needing to call it again. But considering you want to use it on the whole object post-construction, you're going to have to do it differently by using ObjPrim_SetVertexAlpha instead (since 2D Sprite List objects are still Primitive objects).

Code: [Select]
function ObjSpriteList2D_SetAlpha(obj, a){
ascent(v in 0..ObjPrim_GetVertexCount(obj)){
ObjPrim_SetVertexAlpha(obj, v, a);
}
}

Considering some of this confusion is due to the wiki's pretty crappy documentation on it, I changed it a bit to hopefully make it clearer how the sprite lists work.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on June 07, 2016, 03:49:25 PM
I think about using ObjPrim_SetVertexAlpha but I didn't know how. Now, I know. Thanks a lot :D.
I think it's the same thing for changing the color right?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 08, 2016, 07:07:13 AM
Yeah it'd be the same way to set color over the whole object.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Pruns on June 08, 2016, 06:57:29 PM
Hello everyone !
I'm trying to write a little script and I have a little problem.
I explain :

The boss fires some bullets,
Just before she dies, I want all bullets spawned since the beginning of the spell come back to the boss, here is my code :

Code: [Select]
task Bullet(x, y, v, angle,delaie) {
    let papillon=ObjShot_Create(OBJ_SHOT);
    ObjShot_Regist(papillon);

    ObjMove_SetX(papillon, x);
    ObjMove_SetY(papillon, y);
    ObjMove_SetAngle(papillon, angle);
    ObjMove_SetSpeed(papillon, v);
    ObjShot_SetGraphic(papillon, 107);
    ObjShot_SetDelay(papillon, delaie);
    ObjShot_SetSpellResist(papillon, true);
    ObjShot_SetAutoDelete(papillon,false);
    change(papillon);
}

task change(papillon){
while(ObjEnemy_GetInfo(objEnemy, INFO_LIFE)>=500){
yield;
}
ObjMove_SetSpeed(papillon, -3 );
}

When I reach 500 hp
instead of modify speed of every bullets fired,
she fires new bullets with -3 speed from her.

I looked at some tutorials about using yield but It's still blur in my mind.
After a bullet reach the boss, I want to delete it, but I firstly would like to solve this problem.

Can anyone helps me please ?
Thanks for helping !
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on June 08, 2016, 07:13:42 PM
First of all, there's always CreateShotA1 for firing a bullet with presets.

Second, it's better to use

Code: [Select]
ObjMove_SetSpeed(papillon, 3);
ObjMove_SetAngle(papillon, ObjMove_GetAngle(papillon) + 180);

unless you don't mind your bullets facing the same direction when the reverse.

And third, new bullets are going to have a speed of -3 when the boss has less than 500 HP. You can stop shooting bullets at that point by checking if the boss has at least 500 HP before shooting.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Pruns on June 08, 2016, 07:32:36 PM
Thanks for replying

I've made all modifications you told me,so I get :

Code: [Select]
task Bullet(x, y, v, angle,delaie) {
    let papillon=CreateShotA1(x,y,v,angle,107,delaie);
    ObjShot_SetSpellResist(papillon, true);
    ObjShot_SetAutoDelete(papillon,false);
    change(papillon);
}

task change(papillon){
while(ObjEnemy_GetInfo(objEnemy, INFO_LIFE)>=500){
yield;
}
ObjMove_SetSpeed(papillon, 3);
ObjMove_SetAngle(papillon, ObjMove_GetAngle(papillon) + 180);
}

The boss stops shooting when she reaches 500 hp.
but still no change, bullets don't come back
It seems the task "change" doesn't affect the bullet that she musts affect.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on June 08, 2016, 08:24:58 PM
What do you have in your @MainLoop?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Pruns on June 08, 2016, 08:33:08 PM
What do you have in your @MainLoop?

http://pastebin.com/a5ED2QDT

Please don't blame me about the optimization, It's my first script

Won't blame for that, but will blame for not putting this in pastebin. :V It is too much code to show here directly. -Helepolis
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on June 08, 2016, 08:49:53 PM
You forgot to yield in your @MainLoop.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Pruns on June 08, 2016, 08:56:35 PM
You forgot to yield in your @MainLoop.

Wait ... really !?
Now it works !
I've never included any   "yield" in my mainloop scripts. I'm going to correct that.
Thanks you very much !
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on June 09, 2016, 04:28:04 AM
Wait ... really !?
Now it works !
I've never included any   "yield" in my mainloop scripts. I'm going to correct that.
Thanks you very much !

We all probably forgot to place a yield; in our @MainLoop at least once.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on June 09, 2016, 05:20:56 AM
I've never included any   "yield" in my mainloop scripts. I'm going to correct that.
That is because as soon as you're using tasking and threading, you always need to. In your script, you're using a combination of mainloop and tasking, so you need to yield your mainloop.

To explain more precisely:
At #161 you're invoking a while loop which is a way of tasking/threading. That section will never get a chance to run. The MainLoop is the first thread being launched when your script loads. Yielding MainLoop allows the engine check for any other tasks/threads to run/execute.

task TEnd at #130 is not a thread as it contains no loop. It is more like a method with a plain if-statement. And that method is called within the MainLoop, so it will execute.

task change(papilion) is called from Bullet in #153 and Bullet is again called from the MainLoop. The bullet will appear fine. Each bullet will also successfully call its change(papilion) task, but none of these will ever run/execute because the MainLoop doesn't allow it.

Not sure if this is a good way to say it but the @MainLoop is very greedy. Unless yielded once, it will remain greedy the entire time.

Edit2
Each individual's own choice, however the confusion and incoherence MainLoop-style scripting brings along makes it not advisable to use as a scripting style. There are simply no advantages. Only confusion and awkward timing code with statements and such.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Pruns on June 09, 2016, 11:45:18 AM

To explain more precisely:
At #161 you're invoking a while loop which is a way of tasking/threading. That section will never get a chance to run. The MainLoop is the first thread being launched when your script loads. Yielding MainLoop allows the engine check for any other tasks/threads to run/execute.

task TEnd at #130 is not a thread as it contains no loop. It is more like a method with a plain if-statement. And that method is called within the MainLoop, so it will execute.

task change(papilion) is called from Bullet in #153 and Bullet is again called from the MainLoop. The bullet will appear fine. Each bullet will also successfully call its change(papilion) task, but none of these will ever run/execute because the MainLoop doesn't allow it.


I see...
I understand now why my previous scripts worked without any yield in their mainloop.
it is way clearer in my mind.
Thank you for your explanations
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sami-Fire on June 23, 2016, 12:30:36 AM
Hello!

I wasn't sure if this merited a new thread or not, so I apologize if I've put this in the wrong place... what are some good example scripts a beginner can look at to see certain patterns and techniques in action?  I'm particularly interested in seeing spell cards or full bosses with cut-ins and text because I haven't really seen how to do those (I've checked a few tutorials and it's slowly coming together for me, but I'm still really weak on scripting). Thanks!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 23, 2016, 03:12:11 PM
Hello!

I wasn't sure if this merited a new thread or not, so I apologize if I've put this in the wrong place... what are some good example scripts a beginner can look at to see certain patterns and techniques in action?  I'm particularly interested in seeing spell cards or full bosses with cut-ins and text because I haven't really seen how to do those (I've checked a few tutorials and it's slowly coming together for me, but I'm still really weak on scripting). Thanks!

If you want script recommendations, the question is whether you want visuals or code. If you are more interested in seeing the danmaku, the gold standard is the official Touhou games, but there are many Youtube channels out there (mine, ExPorygon/Ozzie840's, AJS's, etc.) that feature danmakufu scripts.

If you're looking for actual code, then it gets harder to recommend scripts simply because everyone has a different coding style and not everyone adheres to recommended guidelines (e.g. effective use of whitespace, logical variable names, etc.). That said, I would suggest the more recent scripts of experienced danmakufu scripters. The issue there is that they may have custom systems that may obscure what is being written, but the danmaku itself should be relatively easy to decode.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Pruns on June 30, 2016, 09:12:01 PM
Hello everyone !

I would like to use the function : "SetScriptArgument" in order to transfer some variables from a script to another, but due to my bad english, I have a lot of troubles for understanding how it works.

I've loaded my script, used setScriptArgument and then startScript like the wiki says :

Code: [Select]
let idScript = LoadScript (pathToScript);
SetScriptArgument(idScript, 2, var);
StartScript(idScript,var);

// But since StartScript has only 1 argument, I've also tried

let idScript = LoadScript (pathToScript);
SetScriptArgument(idScript, 2, var);
StartScript(2);

But nothing work, I tried other combinations and I've looked up for more explanations about this function but I didn't found anything else than danmakufu wiki.
If someone can explain me how this function works, I would be grateful.

Edit : I mean, this argument is a bgm, otherwise, I would have used commondata

Thanks in advance !
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: FlareDragon on June 30, 2016, 11:42:11 PM
Hello everyone !

I would like to use the function : "SetScriptArgument" in order to transfer some variables from a script to another, but due to my bad english, I have a lot of troubles for understanding how it works.

I've loaded my script, used setScriptArgument and then startScript like the wiki says :

Code: [Select]
let idScript = LoadScript (pathToScript);
SetScriptArgument(idScript, 2, var);
StartScript(idScript,var);

// But since StartScript has only 1 argument, I've also tried

let idScript = LoadScript (pathToScript);
SetScriptArgument(idScript, 2, var);
StartScript(2);

But nothing work, I tried other combinations and I've looked up for more explanations about this function but I didn't found anything else than danmakufu wiki.
If someone can explain me how this function works, I would be grateful.

Edit : I mean, this argument is a bgm, otherwise, I would have used commondata

Thanks in advance !
The way that SetScriptArgument works is:
-You give the script the value using SetScriptArgument
-You start the script as normal
-You then retrieve the variable in the started script
That is:
Code: [Select]
//First script
let idScript = LoadScript (pathToScript);
SetScriptArgument(idScript, 2, var);
StartScript(idScript);

//Second script (the one you just started)
let newvar = GetScriptArgument(2);
//Then you can just use it as normal
PlayBGM(newvar);
As you can see, the new script is passed the variable which you can access using GetScriptArgument.
Hope this helps
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Pruns on July 01, 2016, 01:02:45 PM
The way that SetScriptArgument works is:
-You give the script the value using SetScriptArgument
-You start the script as normal
-You then retrieve the variable in the started script
That is:
Code: [Select]
//First script
let idScript = LoadScript (pathToScript);
SetScriptArgument(idScript, 2, var);
StartScript(idScript);

//Second script (the one you just started)
let newvar = GetScriptArgument(2);
//Then you can just use it as normal
PlayBGM(newvar);
As you can see, the new script is passed the variable which you can access using GetScriptArgument.
Hope this helps

It works perfectly, thanks for your help !
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Whatever on July 03, 2016, 03:44:57 AM
How can I correctly display multiply shaders in a single scene?
http://imgur.com/A4UIXEC
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on July 03, 2016, 04:00:33 AM
To begin with, shaders cannot overlap on a particular pixel on a particular priority.

In my version of the inversion shader (link) (http://www.bulletforge.org/u/misaki-rindou/p/death-effects-with-hlsl), I just stored a ton of variables inside the same HLSL file and checked if the distance between the given pixel was inside the certain of each point. In the example I only have 2 points being checked.

If you wanted to be really inefficient, you'd probably render to one render target, render the shaded stuff to another render target, shade that render target, and so on for each shader, but of course that would be way too much on the engine now, wouldn't it.

I think the best way would be to store points and radii into an array, checking for the distance between each point, but I had a couple problems with that for some unknown reason. It's as if some of the values just simply were not stored (they seemed to reset to zero mysteriously). If you can get this method to work properly, let me know.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: WatermelonSprite on July 04, 2016, 03:59:41 AM
Hello!
I'm a beginner in danmakufu and I have a problem. I'm getting the error "@ cannot use in inner function and task." This error has something to do with the @Finalize part. However, I do not know what to fix about it or how to fix this error. This is my script:
http://pastebin.com/MZwYfjHW

(I have put your large paste in pastebin --Hele)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on July 04, 2016, 05:00:59 AM
You missed the brace that was supposed to close TaskA.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: FlareDragon on July 04, 2016, 05:21:46 AM
^^^^

Okay. What's immediately wrong is you're missing a few "}" at the end of TaskA. However, there's something more glaring:
--Your MainLoop is starting a loop (MainLoop --> MainTask --> TaskA (which has a loop)). Not bad on its own, but TaskA's loop goes on while the boss is alive. This creates a HUGE number of loops
--The "while" loop in TaskA doesn't yield (though it looks like you were intending for it to). If you have a loop that doesn't yield, Danmakufu freezes. Every loop either needs to loop a specified number of times or yield

I will give you some suggestions, but I would like to know what your intentions were.
Code: [Select]
...
...
@Initialize{
   objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
   ObjEnemy_Regist(objBoss);
   ObjEnemyBossScene_StartSpell(objScene);
   ObjPrim_SetTexture(objBoss, imgExRumia);
   ObjSprite2D_SetSourceRect(objBoss, 64, 1, 127, 64);
       ObjSprite2D_SetDestCenter(objBoss);
   ObjMove_SetDestAtSpeed(objBoss, 82, 100, 100);
   
   //Instead of starting your MainTask in @MainLoop, you should start it in @Initialize and make MainTask loop
   MainTask;
}   
@MainLoop{
   bossX = ObjMove_GetX(objBoss);
   bossY = ObjMove_GetY(objBoss);
   yield;
} <--- Insert here

task MainTask{
   //Rather than looping in fireA, you shoudl loop here and have MainTask call fireA each time
   while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){ <---Move from "fireA"
      let wait = 120;  //What is this for? For now, let's make it loop "wait" amount of frames with the next line:
      loop(wait){yield;}  //One of the greatest bits of code you'll use in Danmakufu. Remember it
      fireA;
   }

   task fireA{
      let angleT = 0;
      loop(30){
         CreateShotA1(bossX + 90*cos(angleT), bossY + 90*sin(angleT), 2, angleT, 1, 0);
         angleT += 360/30;
      }
   }
} <---Insert here
...
...

If you have any questions about this, go right ahead and ask
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: WatermelonSprite on July 04, 2016, 10:19:26 PM
Thank you everyone and especially to you, Flare Dragon! To be honest, I'm not sure what my intentions are because I have limited ideas about while loops. I was just doing a tutorial from Sparen's Danmakufu ph3 site. The reason I put the while loop in is because it's something common on all of Sparen's tutorials.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on July 06, 2016, 06:52:00 AM
Even though, you should understand why or when a while-loop is used. Don't use it because it is common appearance or not. This is also a major problem with people trying to combine tasking method with the MainLoop and such.

A while-loop is the same as a regular loop { } except you must give it a condition. As in: "While this condition is true, keep looping my piece of code between the { }"

Code: [Select]
// Plain loop which runs as long as the script is active. Delay is 1 frame at the end of the loop.
loop {
CreateShotA1(....);
yield;
}

// Plain loop which runs 10 times. Delay is 1 frame at the end of the loop.
loop(10) {
CreateShotA1(....);
yield;
}

// A while loop which will execute as long as the bossObj is NOT deleted (alive). Delay is 1 frame at the end of the loop.
while(!Obj_IsDeleted(bossObj)) {
CreateShotA1(....);
yield;
}

// A while loop which will execute as long as 'counter' is smaller than 10. Each loop, 'counter' is increased by 1. Delay is 1 frame at the end of the loop.
let counter = 0;
while(counter < 10) {
CreateShotA1(....);
counter++;
yield;
}

About yielding loops
As FlareDragon mentioned, a yield; at least once is mandatory for most conditional loops or plain loop to avoid freezing. A loop(10) { }  or while(counter < 10) { } will NOT freeze your danmakufu if you don't yield it. If you don't yield, it means both loops will immediately execute 10x within the same frame. Or in other words: It will fire 10 bullets on top of each other, making it look as if 1 bullet got fired.

If you don't use a yield here, you must increment counter within the loop. If you remove counter++ from the loop, and it has no yield, it will freeze dnh.

About the @MainLoop
The @MainLoop won't cause freezing if not yielded. However, when you want to use tasking and multi-threading method, you must yield the @MainLoop. The reason for this I have explained it few posts above (https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1263809.html#msg1263809).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on July 13, 2016, 07:06:13 PM
Hello again!
How can I make sure all my fonts are installed correctly at the start of my script?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on July 13, 2016, 08:19:12 PM
Hello again!
How can I make sure all my fonts are installed correctly at the start of my script?

Say you had an array of paths to your font files.
Code: [Select]
let fontstoload = ["path1", "path2", "etc"];
What you'd want to do is check while loading each font, and use a flag to indicate the failure of any font loading.
Code: [Select]
let checkloadedfont = true;
ascent(nF in 0..length(fontstoload)) {
    if(! InstallFont(fontstoload[nF])) {
        checkloadedfont = false;
        // do other things here as well, for example, giving a visual notification that a particular font failed.
    }
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 13, 2016, 08:45:00 PM
Just to clarify, InstallFont itself returns true/false depending on if the font actually loaded properly.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: arch on July 13, 2016, 10:35:55 PM
I'm trying to make my own point item from scratch, I can draw the sprite, but I can't get the object to move at all or set it's position.

Code: [Select]

task MagicPoints(x,y){

// Randomly chooses one of the four sprites form the sprite sheet.
let ex = rand2(128,128+32);
let ey = rand2(0,32);

let path = GetCurrentScriptDirectory() ~ "img/sprite/items.png";
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj, path);
ObjMove_SetPosition(obj,x,y);  // Doesn't work
Obj_SetRenderPriority(obj, 100);
ObjSprite2D_SetSourceRect(obj, ex, ey, ex+32, ey+32);
ObjSprite2D_SetDestRect(obj, ObjMove_GetX(obj), ObjMove_GetY(obj), ObjMove_GetX(obj)+32, ObjMove_GetY(obj)+32);

ObjMove_SetSpeed(obj,2); // Doesn't work
ObjMove_SetAngle(obj,90); // Doesn't work

loop{

// When the player gets close to the item it's deleted and the item count is updated.
if(ObjecttoPlayer(obj) <= 4){
//PlaySound(shot1);
Scores += 1;
Obj_Delete(obj);
}
yield;
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 13, 2016, 10:37:52 PM
I'm trying to make my own point item from scratch, I can draw the sprite, but I can't get the object to move at all or set it's position.

Code: [Select]


You cannot use ObjMove functions on a Render object. Consider using ObjRender functions to set the position or use a custom item script instead.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: netugi on July 13, 2016, 11:23:12 PM
I'm having this issue where my laptop can't read(?) player scripts that I download. Not sure if this is for any custom player script or just certain ones, since the default Rumia player script works just fine. These player scripts work on my desktop however, and both have their system locale set to Japanese. They simply don't show up on the list of player scripts when I open up the Danmakufu program, and when I use the DnhViewer, I can't interact with anything and I'm forced to close it and move my custom player scripts elsewhere and stick with the Rumia script when I work on my laptop. My Danmakufu folder is kept on a flashdrive so it's gotta be the computer's fault. I haven't made my own player script yet, as I'm just playing around with the engine, getting a feel for it, so I'm temporarily using this Mountain of Faith Reimu script someone made ( http://www.bulletforge.org/u/frenticpony/p/player-re-creation-project-mof-reimu ).
I haven't tried using AppLocale, just changed the system locale, but I don't see how that'd make a difference since I do the same on my desktop. Both are Windows 7.
UPDATE: Maybe related to the files in the player script folder? Found out that an .ogg file in my own script folder was causing DNHViewer to freeze up just like with the player scripts. Still can't quite narrow it down myself. I tried removing the sound library and SE folder for the Reimu script and that didn't work, so I dunno.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 13, 2016, 11:41:09 PM
(http://i.imgur.com/jKNajPq.png)

object hierarchy for reference
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on July 14, 2016, 12:55:52 AM
Thank you all! I didn't know InstallFont returns a boolean.  (Thay may or may not actually be basic programming knowledge :V)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on July 14, 2016, 04:11:51 AM
I'm having this issue where my laptop can't read(?) player scripts that I download. Not sure if this is for any custom player script or just certain ones, since the default Rumia player script works just fine. These player scripts work on my desktop however, and both have their system locale set to Japanese. They simply don't show up on the list of player scripts when I open up the Danmakufu program, and when I use the DnhViewer, I can't interact with anything and I'm forced to close it and move my custom player scripts elsewhere and stick with the Rumia script when I work on my laptop. My Danmakufu folder is kept on a flashdrive so it's gotta be the computer's fault. I haven't made my own player script yet, as I'm just playing around with the engine, getting a feel for it, so I'm temporarily using this Mountain of Faith Reimu script someone made ( http://www.bulletforge.org/u/frenticpony/p/player-re-creation-project-mof-reimu ).
I haven't tried using AppLocale, just changed the system locale, but I don't see how that'd make a difference since I do the same on my desktop. Both are Windows 7.
UPDATE: Maybe related to the files in the player script folder? Found out that an .ogg file in my own script folder was causing DNHViewer to freeze up just like with the player scripts. Still can't quite narrow it down myself. I tried removing the sound library and SE folder for the Reimu script and that didn't work, so I dunno.

Make sure you have ph3 .1 [pre6a] instead of ph3 .0.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Junky on July 16, 2016, 04:10:04 PM
I'm trying to work on a player with Youmu's option style from Ten Desires or Marisa's type A from Mountain of Faith. I have no clue how to get them to move like they do in the games. Any help? q-q
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 17, 2016, 12:46:46 AM
I actually did exactly this a few pages back for somebody else. Cheers.

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

EDIT: um hello?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sami-Fire on July 22, 2016, 01:13:12 AM
Hello again! I'm trying to create a circle of bullets that, after traveling forward for a number of frames, reverses direction and keeps going in the reversed direction. However, what I'm getting is more like a spiral due to how it forms and also how one side of bullets reverses before the other. Here's my code (it's supposed to be based on the bullet command tasks Sparen uses in the tutorial):

Code: [Select]
task OscReverse(obj){
wait(80);
ObjMove_SetSpeed(obj, -2);
}


task OscillateA{
while(ObjEnemy_GetInfo(objBoss,INFO_LIFE) > 0){
let angleT = GetAngleToPlayer(objBoss);
loop(13){
ascent(i in 0..3){
let obj = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 1.5 - i/6, angleT, DS_BUTTERFLY_RED + i, 5);
OscReverse(obj)
}
angleT += 360/13;
yield;
}
wait(120);
}
}

How can I fix this to make it more circle and less spiral?

Thank you!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 22, 2016, 01:37:10 AM
Don't yield between the angle changes. That waits a frame between each three bullet group and so bullets around the circle will spawn (and reverse) later.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: arch on July 23, 2016, 08:50:08 AM
I'm working on a custom pause menu, but there are two things I can't get working.

GetPlayerLife and ObjMove_GetX are both standard functions, so I don't understand why having them called in menu script is causing problems.



Also I've got a simple item that can execute some commands when you collect it, but since it only checks if the item is deleted the same event will happen if it falls off-screen. How can I check if the item has been collected by the player?

Code: [Select]
task LifeItem(x,y){
let obj = CreateItemU1(1,x,y,0);
while(!Obj_IsDeleted(obj)){yield;}
PlaySE(shot1);
LifeFragment += 3;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on July 23, 2016, 12:03:54 PM
Quote
GetPlayerLife and ObjMove_GetX are both standard functions, so I don't understand why having them called in menu script is causing problems.
I think it's because these functions are not defined in the Package Script. Pause Menu is called in the Package and depend of it. Even if a Stage Script is runnig.
A lot of stage script functions are not defined i the package. I have the same issue. But you just need to remove all functions and task using these default function from your file and put it in another file.


Anyway, I have a question.
I want to make bullet that reflect on a round surface instead of on walls. I know how to calculate the angle after reflection on a wall but I have no idea for the reflection on a round surface.
Did someone know what math formula I need to use to know this final angle, depending on the initial angle?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: _siht_deppilf_sah_ajies_ on July 23, 2016, 05:29:37 PM
So I made a player script using Helepolis's tutorial, but it always has the same crash report even if I do it word for word.
The report reads as follows:
 ObjPrism_Create is not defined.
(ObjPrism_Createは未定義の識別子です)
G:/th_dnh_ph3/script/player/marisa/playermarisa.txt
playermarisa.txt line(行)=11


 let playerObj = ObjPrism_Create縺ッ譛ェ螳夂セゥ縺ョ隴伜挨蟄舌〒縺・;
 let hitboxObj = ObjPrism_Create縺ッ譛ェ螳夂セゥ縺ョ隴伜挨蟄舌〒縺・;
 let count = -1;
 let isFocus = false;
 
 // Shot Sheet
 let shotMarisa = CSD ~ "playershot.txt";
 
 // Texture Sheet
~~~
I don't understand why it won't work.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Conarnar on July 23, 2016, 05:30:15 PM
To make something bounce off of a non horizontal or vertical surface, you use the formula
Code: [Select]
360 - angle + 2 * surfacewhere angle is the angle of the object and surface is the angle of surface.

Since the object is bouncing off of a round surface, the angle of the surface would be the angle of the tangent line to the circle where the object is. That would be
Code: [Select]
angle + 90where 90 is the angle from the object to the center of the circle.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on July 23, 2016, 06:00:30 PM
Thanks.
So, if I understand well, the code will be somethinng like this:

Code: [Select]
newangle = 360 - ObjMove_GetAngle(obj) + 2 * (atan2(ObjMove_GetY - CircleCenterY, ObjMove_GetX - CicleCenterX) + 90);I think the angle of the surface is the same as the angle between the point were the object colide with the circle and the center of this circle. Right?

edit: tested and it actually work. I'm not sure if it work really well but it work and the angle seems correct most of the time. Thanks a lot.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 23, 2016, 10:59:19 PM
So I made a player script using Helepolis's tutorial, but it always has the same crash report even if I do it word for word.
The report reads as follows:
 ObjPrism_Create is not defined.
Prim as in "Primitive"
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on July 24, 2016, 10:21:53 PM
I'm working on a custom pause menu, but there are two things I can't get working.
  • Including a file of standard tasks and functions, I get an error saying ObjMove_GetX is not defined in the file I'm trying to have included.
  • Trying to get the player's current life, I get GetPlayerLife is not defined.

GetPlayerLife and ObjMove_GetX are both standard functions, so I don't understand why having them called in menu script is causing problems.



Also I've got a simple item that can execute some commands when you collect it, but since it only checks if the item is deleted the same event will happen if it falls off-screen. How can I check if the item has been collected by the player?

Code: [Select]
task LifeItem(x,y){
let obj = CreateItemU1(1,x,y,0);
while(!Obj_IsDeleted(obj)){yield;}
PlaySE(shot1);
LifeFragment += 3;
}

You may think of pause menus as being categorized as the same as package scripts. You should assume that there is no such thing as an object that can use ObjMove_ series of functions.
That said, anything with ObjMove_ is considered as not a usable function. Similarly, since there is no such thing as a player, GetPlayerLife is not defined.

You may want to split your general-use tasks and functions #include file into another file for use in stages, along with the original file. Just remember to include the new file in all of your stages / singles / etc.

By the way, one way is that you can constantly keep track of the player's life using common data. It's kind of an annoying thing to do, but it's one simple workaround.



If you constantly keep track of the object's y-coordinate inside your while(!ObJ_IsDeleted(obj)) { } loop, you can have conditional behaviour based on your variable that represents the y-coordinate. That way you won't constantly hear the sound or have the life fragment count raised when it shouldn't be raised.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on July 25, 2016, 02:09:16 AM
So I made a player script using Helepolis's tutorial, but it always has the same crash report even if I do it word for word.
The report reads as follows:
 ObjPrism_Create is not defined.
(ObjPrism_Createは未定義の識別子です)
G:/th_dnh_ph3/script/player/marisa/playermarisa.txt
playermarisa.txt line(行)=11


 let playerObj = ObjPrism_Create縺ッ譛ェ螳夂セゥ縺ョ隴伜挨蟄舌〒縺・;
 let hitboxObj = ObjPrism_Create縺ッ譛ェ螳夂セゥ縺ョ隴伜挨蟄舌〒縺・;
 let count = -1;
 let isFocus = false;
 
 // Shot Sheet
 let shotMarisa = CSD ~ "playershot.txt";
 
 // Texture Sheet
~~~
I don't understand why it won't work.

It's ObjPrim, not ObjPrism.  :]

Question was already answered few posts above, please read the new posts fully before posting selectively. -Hele
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sami-Fire on August 03, 2016, 03:46:37 AM
Hello again, and thank you for the help on my previous problem! Now I have a problem that I've been throwing myself at for hours but can't seem to figure out... I'm trying to make a bullet pattern that functions like the "wave" portion of Border of Wave and Particle (where the bullets are connected and wobble, not the part where they seem to go separate), but with an extra wobbly wave to it. Ideally, the pattern would produce 5 curved partitions that rotate, then stop and wobble/have another wave go through them before rotating again. I've managed to get curves that reverse direction and other interesting effects, but not what I'm looking for. I have two different tries of this task code; below is the more recent and cleaner version of the code (the other one involves an alternative case used as a timer that really messes things up, so I scrapped it).

Code: [Select]
task LostWaves{
    let angleT = rand(0, 360);
    let objcount = 18;
    loop{
        loop(5){
let obj = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2, angleT, 45, 5);
            angleT += 360/5;
wait(0.001);
        }
        angleT += sin(objcount) * 8;
if(objcount > 36){
objcount = 18;
angleT += cos(objcount) * 8;
}else{
objcount++;
}
        yield;
    }
}

This code makes the curved lines rotate and change direction (or it did at some point... now it just makes a break in the lines...), which is close but not quite. Does anyone have any ideas?

Thanks in advance!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on August 03, 2016, 01:14:07 PM
Could you perhaps draw out an example of what you're looking for? I can't really envision what you want here. Drawing something should be accurate enough since you're probably aware the individual bullets in the pattern all just move in a straight line anyways.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Asthmagician on August 03, 2016, 05:45:07 PM
@ Sami-Fire:
I was about to type out an explanation of BoWaP and link you to Sparen's tutorial on it here (http://sparen.github.io/ph3tutorials/ph3u1l11a.html (http://sparen.github.io/ph3tutorials/ph3u1l11a.html)), but looking at his code it seems you've already done so. (also it's better explained there)
The reason it doesn't change direction is here:
Code: [Select]
        angleT += sin(objcount) * 8;
        if(objcount > 36){ // Note here
            objcount = 18;
            angleT += sin(objcount) * 8;
        }else{
            objcount++;
        }

The issue is that the sin function takes values 0 to 360 to give a value of 1 to -1 and back to 1. sin(18) gives a(n approximate) value of 0.3
0.3 * 8 is 2.4. This is really small, however it does add up. the gap that appears occaisionally is just the difference between angles changing back to sin(18)*8 from sin(36)*8.

This is also why it doesn't reverse direction. the sine function takes 0-90 to get from 1 to 0, 0 to -1, etc. so 0-18 doesn't have much of an effect.
It's late for me and i'm afraid this style of code is sort of hard for me to follow so I'll give this much now and try and play with it more tomorrow.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sami-Fire on August 03, 2016, 07:27:36 PM
@ Drake: Sorry about that! Here's a diagram. Hope it helps: here. (http://i218.photobucket.com/albums/cc294/Sami-Fire/WaveDanmakuSketch.png)

@Asthmagician: I see! Thank you for explaining. After poking the code a little more, I figured it had something to do with the sine value being at or above a certain point. Do you have any ideas on how to keep it at a wiggling line (see my diagram above) without it going to the "particle" stage? (It seems that the bullet lines separate about midway through sine counts).

I've revised my code a bit. I've finally gotten the lines to wiggle how I want, at least in the beginning. However, the direction reverses and never seems to go back the other way. objcount is supposed to bounce between 240 and 60 to make the wiggling happen, and it doesn't seem to be doing that. What am I missing?

Code: [Select]
task LostWaves{
    let angleT = rand(0, 360);
    let objcount = 40;
//let oscount = 0;
    loop{
        loop(5){
let obj = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2, angleT, 45, 5);
            angleT += 360/5;
wait(0.001);
        }
        //angleT += sin(objcount) * 8; //BOWAP- Sine makes the oscillation, * 6 ensures there are gaps.
if(objcount >= 240){
angleT -= sin(objcount) * 8;
objcount -= 3;
}else if(objcount <= 60){
angleT -= sin(objcount) * 8;
objcount += 3;
}else{
angleT -= sin(objcount) * 8;
objcount += 3;
}
        yield;
    }
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Asthmagician on August 04, 2016, 06:17:29 AM
@ Sami-Fire:
The wiggling doesn't happen because objcount doesn't bounce between 240 and 60.
I'll use & comment your code here for reference:
Code: [Select]
    task LostWaves{
    let angleT = rand(0, 360);
    let objcount = 40; // objcount is initialized here
    //let oscount = 0;
    loop{   
        loop(5){
            let obj = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2, angleT, 796, 5);
            angleT += 360/5;
            wait(0.001); //???
        }
        //angleT += sin(objcount) * 8; //BOWAP- Sine makes the oscillation, * 6 ensures there are gaps.
        // if-else block is here and down
        if(objcount >= 240){ // A
            angleT -= sin(objcount) * 8;
            objcount -= 3;
        }else if(objcount <= 60){ // B
            angleT -= sin(objcount) * 8;
            objcount += 3;
        }else{ // C
            angleT -= sin(objcount) * 8;
            objcount += 3;
        }
        yield;
    }
}
The main issue is that the if-else block is tested every frame (actually every sixth frame but I'll discuss that later).
When objcount is initialized, the part I marked C is selected until objcount gets past 60 (61 to be exact) where the part I marked B happens.
As an aside note, B and C look like they do the same thing. is there any reason they're both there?
when objcount reaches A, it has the value of 241. Since this test occurs every (sixth) frame, A is triggered, which reduces objcount by 3.
This means it goes down to 238, thus triggering B, and adding 3, triggering A and taking 3, etc.
The sequence of values looks roughly like:
220, 223, 226, 229, 232, 235, 238, 241, 238, 241, 238, 241, 238, etc.
This is where it seems to get stuck : /\
The stuck behaviour occurs beccause (the sin of) objcount controls the change in angle, rather than the plain angle.
If (the sin of) objcount controlled the actual angle what happened would look a lot more obvious, as the shots would just form straight lines.

On another note, I'll point out that the wait() function (assuming it's the one I'm thinking of) rounds to an integer (whole number), so 0.001 is turned into 1.
The wait function acts as a number of frames rather than a number of seconds, so replacing the current line with wait(1); or just a yield; would functionally change nothing.

The diagram is much clearer, I'll play around and see if I can come up with anything.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: arch on August 04, 2016, 11:07:05 PM
Does anyone know if the speed an item flies to a player when auto-collect is called can be changed? 

My project's resolution is much higher than the standard 640x480, one side affect of the higher regulation is that default of speeds of items/players are slower because of how much more pixels they have to cross to get to the other side of the screen.

Having the items be auto-collected quickly when passing the PoC or bombing is necessary for my project since my project's scoring system is similar to DDC.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on August 05, 2016, 06:40:17 AM
Yes, but not through the existing item functions presented on the wiki. You'll need to create your own 'movement' piece of code.

Create a custom item tied to an obj variable like
Code: [Select]
let obj = CreateItemU2(....);
Then add movement behaviour code to it using the obj variable to increase dropping speed /spinning etc.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on August 14, 2016, 10:43:46 AM
Hi, I started looking into animating my boss with the help of Helepolis's tutorial.
The problem is, i'm using a spritesheet from a fighting game, so I only want to use the idling animation (which uses 8 sprites). But the tutorial uses the "if" and "else", does that mean that if i copy the code, change the numbers to suit my needs and delete the part that isn't for the idling it won't work ? (Danmakufu is my first experience with coding...)
Also, since the idling for my script is twice longer than the one in the tutorial, should i reduce the numbers from 0,15,30,45,60 to 0,7.5,15,22.5,30,37.5,45,52.5,60 if it works ?
Thanks in advance :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on August 14, 2016, 04:22:16 PM
Instead of copying and pasting it in, write the code yourself! Think of it as an exercise.

As for the numbers, assuming you're talking about the frames in which the sprite changes, you shouldn't use decimals. For example, if your idle animation uses 8 sprites, instead of "15,30,45,60" just simply write "10,20,30,40,50,60,70,80".

If the animation takes too long, simply adjust the speed in which the variable you use for counting those frames increases it's value. (Just don't change it to a decimal!)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: wobuffet3 on August 18, 2016, 04:51:01 AM
I'm not sure if this is the right place to ask, but has the Riverbed Soul Saver english patch been completed? This is the newest thing I could find and I didn't want to bump a dead thread.

https://www.shrinemaiden.org/forum/index.php/topic,17407.msg1162315.html#msg1162315
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on August 18, 2016, 11:07:57 PM
is it possible to declare i global variable from inside a task?

also, how do i make the boss use the 'moving left' sprites when it moves left, and make the boss use the 'moving right' sprites when it moves right?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on August 18, 2016, 11:50:55 PM
is it possible to declare i global variable from inside a task?

also, how do i make the boss use the 'moving left' sprites when it moves left, and make the boss use the 'moving right' sprites when it moves right?

You cannot declare a global variable from within a task because when you declare a variable within a block such as a task, it cannot be accessed from outside that block.

If you want your boss to use a different set of sprites when it's moving in a different direction, first obtain the direction the boss is moving at (ObjMove_GetAngle), normalize the angle/use trigonometry to determine the direction, and use an if statement to select which sprites to use.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on August 19, 2016, 02:10:52 AM
You cannot declare a global variable from within a task because when you declare a variable within a block such as a task, it cannot be accessed from outside that block.

If you want your boss to use a different set of sprites when it's moving in a different direction, first obtain the direction the boss is moving at (ObjMove_GetAngle), normalize the angle/use trigonometry to determine the direction, and use an if statement to select which sprites to use.

Can I please have an example?

My scripting skills are bad  :(
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on August 19, 2016, 05:30:16 AM
Can I please have an example?

My scripting skills are bad  :(
As rude as it may sound, but did you check the tutorials?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on August 19, 2016, 05:44:02 AM
https://www.youtube.com/watch?v=XL51t2_gxs8

As for the "can I declare a global variable in a task" question, it's important to note what you want to use this for in the first place. Because if the answer is just "no" (which it is), then we can't help any further until you do tell us what you wanted it for.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Whatever on August 19, 2016, 10:33:28 AM
is it possible to declare i global variable from inside a task?
Variables can only be used inside the "block" it was declared in, so no.
However, you can do something like this:
Code: [Select]
let x = 1; //declared a global variable "x" with the value of 1
task whatever(){
//...
x = 3; //x is now 3 and will remain 3 throughout the entire file until changed
}
I might misunderstand your question but this is how I interpreted it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on August 19, 2016, 04:32:42 PM
As rude as it may sound, but did you check the tutorials?

Well, it seems like I've made a fool of myself.

The answer was in the tutorial  :blush:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on August 20, 2016, 01:18:27 PM
You could technically alter a global variable from inside a task using Obj_SetValue, or SetCommonData.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on August 21, 2016, 01:34:30 AM
Sorry to bother you guys again, but are there any tutorials on how to make a stage?

More specifically, I want a stage that would only have a midboss and a boss, each with their own music and backgrounds.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on August 21, 2016, 01:28:20 PM
There is no such thing as "sorry to bother". Of course many people do this due to being polite.

A good question. We have exactly 0 tutorials on making stages in ph3.

Summary: A stage is created using #TouhouDanmakufu[Stage] as header. You spawn enemies within the stage and at a certain point you call the Plural script for the boss.

A set of question you need to ask yourself to tackle this is:
- Can I make a single boss attack (regular or spell card)
- Can I make a boss with multiple attacks/spellcards?
- Can I make a familiar/enemy which is NOT a boss?
- Do I understand SFX and BGM using .wav and .mp3/.ogg?

If the above is all yes, then we can tell you the rest. If not, you should tackle all of the above first.

Also this seems like a good idea for a video tutorial I think. Hmmm
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on August 21, 2016, 06:15:43 PM
There is no such thing as "sorry to bother". Of course many people do this due to being polite.

A good question. We have exactly 0 tutorials on making stages in ph3.

Summary: A stage is created using #TouhouDanmakufu[Stage] as header. You spawn enemies within the stage and at a certain point you call the Plural script for the boss.

A set of question you need to ask yourself to tackle this is:
- Can I make a single boss attack (regular or spell card)
- Can I make a boss with multiple attacks/spellcards?
- Can I make a familiar/enemy which is NOT a boss?
- Do I understand SFX and BGM using .wav and .mp3/.ogg?

If the above is all yes, then we can tell you the rest. If not, you should tackle all of the above first.

Also this seems like a good idea for a video tutorial I think. Hmmm

I already have everything ready, I just need to put it together.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on August 21, 2016, 08:07:11 PM
I already have everything ready, I just need to put it together.
Oh. Why didn't you say so :V

Declare global in your stage file:
Code: [Select]
let idScript;
Then call anywhere during your stage this for your mid or stage boss:
Code: [Select]
idScript = LoadScriptInThread("pathtoyourscript");
StartScript(idScript);

The LoadScriptInThread will allow you to run a script while your stage script is still active. This can be used for any loadable scripts but in general often used for mid/stage bosses.

Enemies can be spawned anywhere during the stage. No need for specific script loading.

If you want to change music for the midboss and stage boss, you need to stop and load/play your desired song somewhere. Could be done from the boss script, plural or during a "dialogue".
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on August 21, 2016, 10:28:52 PM
Oh. Why didn't you say so :V

Declare global in your stage file:
Code: [Select]
let idScript;
Then call anywhere during your stage this for your mid or stage boss:
Code: [Select]
idScript = LoadScriptInThread("pathtoyourscript");
StartScript(idScript);

The LoadScriptInThread will allow you to run a script while your stage script is still active. This can be used for any loadable scripts but in general often used for mid/stage bosses.

Enemies can be spawned anywhere during the stage. No need for specific script loading.

If you want to change music for the midboss and stage boss, you need to stop and load/play your desired song somewhere. Could be done from the boss script, plural or during a "dialogue".

How would I make everything else wait until the midboss dies?

thanks for the help, by the way
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on August 22, 2016, 12:36:30 AM
How would I make everything else wait until the midboss dies?

thanks for the help, by the way

Code: [Select]
StartScript(idScript);
while(!IsCloseScript(idScript)){yield;}

The code after the "while" statement waits for the midboss script to terminate before activating.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on August 25, 2016, 12:28:56 AM
I've been wondering about a thing for a while, which I didn't think of earlier.

Is there any way that the rate, at which the spellcard bonus decreases, can be influenced/changed? I'm not referring to the types of spells (e.g. survivals where the bonus doesn't decrease at all), but a place where said decrease of the bonus on normal spells can be changed. Is there one?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on August 25, 2016, 12:44:09 AM
I've been wondering about a thing for a while, which I didn't think of earlier.

Is there any way that the rate, at which the spellcard bonus decreases, can be influenced/changed? I'm not referring to the types of spells (e.g. survivals where the bonus doesn't decrease at all), but a place where said decrease of the bonus on normal spells can be changed. Is there one?

Ph3 has a default handling of Spell Card Bonuses and it doesn't seem possible to directly alter. However, it wouldn't be too hard use Obj_Values to set your own bonus and write logic that governs its decay. Then using the EV_GAIN_SPELL flag in @Event, you can simply use AddScore to apply the bonus to the score and play a visual effect that displays the bonus. I think you could probably even just use the default "Spell Card Bonus" text and effect for that too. You'd probably have to disable the default handling of the bonus by altering the System script, but I don't remember if that's exactly true right now.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: SusiKette on August 28, 2016, 08:03:47 AM
I kinda wanted to get back to programming Danmakufu after a while : p
Wasn't it possible to make stand alone game in Danmakufu? Like so that you don't have to go through Danmakufu's own menus to select stages etc. and have custom main menu and stuff.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on August 28, 2016, 08:28:50 AM
I kinda wanted to get back to programming Danmakufu after a while : p
Wasn't it possible to make stand alone game in Danmakufu? Like so that you don't have to go through Danmakufu's own menus to select stages etc. and have custom main menu and stuff.
Yes. The th_dnh.def file in your root can call to a package file to use it as a "entry point" for your game. Example from my game:
Code: [Select]
package.script.main = script/thdcs/DanceContestMain.txt
DanceContestMain.txt decorates the screen with menu title and such. Of course, you'll need to get comfortable with package scripts for this all. There should be a sample in your default dnh folder for the Rumia called th_dnh.def.sample
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JmLyan on September 01, 2016, 05:13:39 PM
So apparently, Danmakufu's ToString function insists on turning integers into floats. So telling it to write the number 5 causes it to write 5.000000 instead. Is there any workaround for this, or am I missing something obvious?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on September 01, 2016, 05:50:51 PM
It is not the ToString function. Numbers / integers in Danmakufu are both in 0.12m and ph3 tracked as float. If you draw the X / Y position of your boss as text on your screen, you will see it as a float too.

Afaik you can use 'rtos' or 'vtos' to truncate the value and decide the number of digits as decimal. If I can find an example then I will update my post. Or you might already fix it in the mean while.

Edit: I think atoi is what you seek.
Edit2: Nope, misread the function. It isn't atoi. My apologies.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on September 02, 2016, 04:35:02 AM
It is not the ToString function. Numbers / integers in Danmakufu are both in 0.12m and ph3 tracked as float. If you draw the X / Y position of your boss as text on your screen, you will see it as a float too.

Afaik you can use 'rtos' or 'vtos' to truncate the value and decide the number of digits as decimal. If I can find an example then I will update my post. Or you might already fix it in the mean while.

Edit: I think atoi is what you seek.
Edit2: Nope, misread the function. It isn't atoi. My apologies.

It's IntToString.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JmLyan on September 02, 2016, 03:55:56 PM
It is not the ToString function. Numbers / integers in Danmakufu are both in 0.12m and ph3 tracked as float. If you draw the X / Y position of your boss as text on your screen, you will see it as a float too.

Afaik you can use 'rtos' or 'vtos' to truncate the value and decide the number of digits as decimal. If I can find an example then I will update my post. Or you might already fix it in the mean while.

Edit: I think atoi is what you seek.
Edit2: Nope, misread the function. It isn't atoi. My apologies.

It's IntToString.

Both rtos and IntToString worked perfectly.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on September 03, 2016, 06:24:15 PM
Not really that important for now, but I noticed the function to set the enemy's hitbox only created a circle. My sprite is 68x117 and either the circle is too small or way too big on the sides. Is there any way to make a square instead (i looked in the danmakufu wiki ph3 function list but there was only the one with a circle)?

Also, more importantly, Helepolis' tutorial uses "if" and "else if" to select sprites in the spritesheet. But my spritesheet has only one animation (for idling), and i don't need the part with "else if" but if i remove it it gives me an error. Is there something else i could use instead of "if" and "else if" ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on September 03, 2016, 06:50:03 PM
Also, more importantly, Helepolis' tutorial uses "if" and "else if" to select sprites in the spritesheet. But my spritesheet has only one animation (for idling), and i don't need the part with "else if" but if i remove it it gives me an error. Is there something else i could use instead of "if" and "else if" ?

For starters, you might want to think about getting a spritesheet with more animations, as a spritesheet with only one animation is generally frowned upon.

But if you only have one sprite, the following should work. (I'm assuming you don't have animations to move, in which case you don't even need an if statement).

Code: [Select]
@MainLoop{
ObjSprite2D_SetSourceRect(the name of your boss variable,insert coordinates here);
ObjSprite2D_SetDestCenter(the name of your boss variable);
}

You could also place those two lines in a task.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on September 11, 2016, 04:21:33 PM
I have several sprites but they're only for idling. Helepolis used a spritesheet with movement animations and other stuff (from an official touhou game), so my problem still isn't solved :/
Also is there anyone i could just chat with who knows some stuff about danmakufu ? Because i probably have tons of newbie questions and i don't really want to spam this topic
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on September 11, 2016, 05:36:14 PM
Also is there anyone i could just chat with who knows some stuff about danmakufu ? Because i probably have tons of newbie questions and i don't really want to spam this topic

You could PM me, but I'm not that active on the weekdays  :(

I have several sprites but they're only for idling. Helepolis used a spritesheet with movement animations and other stuff (from an official touhou game), so my problem still isn't solved :/

Something like this should work.

first, make a variable called animframe (or whatever you feel like calling it) and set it to 0.

then, in @MainLoop.

Code: [Select]
@MainLoop{
                if(animFrame < 20) { ObjSprite2D_SetSourceRect(boss,coords); }
if(animFrame >= 20 && animFrame < 40) { ObjSprite2D_SetSourceRect(boss,coords); }
if(animFrame >= 40 && animFrame < 60) { ObjSprite2D_SetSourceRect(boss,coords); }
                if(animFrame > 60) { animFrame = 0;}
               
                animFrame ++;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: EPICI on September 11, 2016, 05:38:20 PM
I have several sprites but they're only for idling. Helepolis used a spritesheet with movement animations and other stuff (from an official touhou game), so my problem still isn't solved :/
Also is there anyone i could just chat with who knows some stuff about danmakufu ? Because i probably have tons of newbie questions and i don't really want to spam this topic
Sure, I'll help.
I have school to deal with and I'm somewhat new myself but I've been able to make somewhat decent bosses and players. Good for a newbie, terrible compared to regular standards, like what you'd see in Koishi Heck and Experiment 354.
Try Not My Spellcard with Reimu C and see how it goes. (I'm working on a better dialogue system for my next project, more similar to the classic)
https://www.shrinemaiden.org/forum/index.php/topic,19819.0.html
Anyways, if you're truly new then I should be able to help with anything. Send me a PM from the top navigation bar, expect a reply within a day if I'm not busy.

Pretty much every sprite ever can be found here:
< link removed by Hele >
Just have a look around, download the sheet you need and crop out just the bit you're using. You might need to do some more editing to make it usable, Danmakufu won't handle everything for you.

Also I dug up the link for all the sound effects from all games.
< link removed by Hele >
Not sure who made this, but thanks so much.
Somebody should put this somewhere more visible.

Anyways is there a way to create some sort of save file in Danmakufu?
In the Package (full game) I'm working on I've decided to have the difficulty change depending on how well you're doing, so if you're failing horribly you get easier stages and bosses, if you have a perfect run you get much harder stuff and lots more score. Depending on how well you did you also unlock a certain difficulty Extra stage.
I only need to track the best run.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on September 11, 2016, 05:44:34 PM
Pretty much every sprite ever can be found here:
< link removed by Hele >
Just have a look around, download the sheet you need and crop out just the bit you're using. You might need to do some more editing to make it usable, Danmakufu won't handle everything for you.

Also I dug up the link for all the sound effects from all games.
< link removed by Hele >
Not sure who made this, but thanks so much.
Somebody should put this somewhere more visible.

Are those allowed? Didn't ZUN say something about touching original stuff?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 11, 2016, 05:46:24 PM
Are those allowed? Didn't ZUN say something about touching original stuff?

Technically we are not allowed to use his original resources, but it's done anyways.

However, do note that not everything that ZUN uses is his originally - sound effects and background source images in particular may come from other sources.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on September 11, 2016, 06:10:34 PM

first, make a variable called animframe (or whatever you feel like calling it) and set it to 0.


That's actually what Helepolis put on his tutorial and i tried removing the else if part with success (i have no idea what i did the first time but it wasn't working). Right now i'm almost done with my animation (had to redo a spritesheet because i didn't lay the previous one out correctly so i had trouble), i'm just a bit confused about the first 2 numbers of  ObjSprite2D_SetSourceRect (the 0), i looked this function up on the danmakufu wiki but it isn't very accurate and i don't get what to write there. By the way, my spritesheet isn't from touhou but i can share it if anyone wants it .

Code: [Select]
if (speed == 0) {
ObjRender_SetAngleXYZ(bossObj,0,0,0);
if(animFrame < 15) { ObjSprite2D_SetSourceRect(bossObj,0,0,64,117); }
if(animFrame >= 15 && animFrame < 30) { ObjSprite2D_SetSourceRect(bossObj,0,0,128,117); }
if(animFrame >= 30 && animFrame < 45) { ObjSprite2D_SetSourceRect(bossObj,0,0,192,117); }
if(animFrame >= 45) { ObjSprite2D_SetSourceRect(bossObj,0,0,256,117); }
animFrame2 = 0;
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on September 11, 2016, 06:21:06 PM
Right now i'm almost done with my animation (had to redo a spritesheet because i didn't lay the previous one out correctly so i had trouble), i'm just a bit confused about the first 2 numbers of  ObjSprite2D_SetSourceRect (the 0), i looked this function up on the danmakufu wiki but it isn't very accurate and i don't get what to write there.

the first two numbers are x,y coordinates of the top-left of your sprite, and the last two numbers are the x,y coordinates of the bottom-right of your sprite. It essentially draws a rectangle from the top-left of your sprite to the bottom-right.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on September 11, 2016, 06:27:40 PM
Alright
I tinkered a bit with the numbers and the sprites aren't all fucked up like at the beginning, BUT during a movement the boss will lock on a sprite (basically it will pause the animation during the movement and when it stops moving it resumes the animation). If anyone knows how to fix this...

Code: [Select]
if (speed == 0) {
ObjRender_SetAngleXYZ(bossObj,0,0,0);
if(animFrame < 15) { ObjSprite2D_SetSourceRect(bossObj,0,0,64,117); }
if(animFrame >= 15 && animFrame < 30) { ObjSprite2D_SetSourceRect(bossObj,64,0,128,117); }
if(animFrame >= 30 && animFrame < 45) { ObjSprite2D_SetSourceRect(bossObj,128,0,192,117); }
if(animFrame >= 45) { ObjSprite2D_SetSourceRect(bossObj,192,0,256,117); }
animFrame2 = 0;
}
animFrame++; // count animFrame. (++ is +1)
animFrame2+=2; // count animFrame2.
if(animFrame > 60) { animFrame = 0; } // reset animFrame when it is higher than 60.
yield;

By the way, thanks a lot to everyone because i would have given up since long if it weren't for your help.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Romantique Tp on September 11, 2016, 06:40:39 PM
Technically we are not allowed to use his original resources, but it's done anyways.

However, do note that not everything that ZUN uses is his originally - sound effects and background source images in particular may come from other sources.

That doesn't change anything. Outside of the things he made himself, ZUN uses stuff he paid for pretty much exclusively.
Using any number of his assets is potentially violating the rights of multiple people. It's no better than pirating paid royalty-free content directly.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on September 12, 2016, 08:29:23 PM
For that reason I've removed the links containing those sources.


@ Jojo,  this shows only the 0-speed code though. Could you post the entire animation code you have in pastebin?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: EPICI on September 12, 2016, 08:44:22 PM
Alright, I understand. Sorry about the misunderstanding.

Going to ask again, is there a way to create some kind of save file?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on September 13, 2016, 06:41:48 AM
Yes you can. You could use the commondata to keep track of all parameters and write them to the commondata file.

Take a look at http://dmf.shrinemaiden.org/wiki/Common_Data_Functions

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: SuperSupermario24 on September 13, 2016, 11:19:07 PM
(I'm assuming this is the right place for this)

So I'm confused about something. I see things about the All-Star Shotsheet by Ozzy basically all over the place. I see it mentioned a lot, and used in lots of scripts, even recent ones (like, from the past couple of weeks). It certainly seems like a very good shotsheet, judging by what I've found looking through scripts' files.
But... I can't seem to actually find it anywhere.
I've certainly tried to find it. I've done searches on Google, on BulletForge, and on MotK, but I've found nothing at all; the closest I've found is the ZUN Expanded Shotsheet by Ozzy (http://www.bulletforge.org/u/ozzy/p/zun-expanded-shotsheet-for-ph3) which, while also good, doesn't give quite as much variety, and seems to just be rips of ZUN's data. I know I can just take it from other scripts, but I dunno, for some reason something about that just feels wrong, like I'm using something I'm not supposed to.
Does anybody know if there's a reason for this? Or am I just being stupid somehow? (And if I am, you're welcome to slap me.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 14, 2016, 12:37:28 PM
(I'm assuming this is the right place for this)

So I'm confused about something. I see things about the All-Star Shotsheet by Ozzy basically all over the place. I see it mentioned a lot, and used in lots of scripts, even recent ones (like, from the past couple of weeks). It certainly seems like a very good shotsheet, judging by what I've found looking through scripts' files.
But... I can't seem to actually find it anywhere.
I've certainly tried to find it. I've done searches on Google, on BulletForge, and on MotK, but I've found nothing at all; the closest I've found is the ZUN Expanded Shotsheet by Ozzy (http://www.bulletforge.org/u/ozzy/p/zun-expanded-shotsheet-for-ph3) which, while also good, doesn't give quite as much variety, and seems to just be rips of ZUN's data. I know I can just take it from other scripts, but I dunno, for some reason something about that just feels wrong, like I'm using something I'm not supposed to.
Does anybody know if there's a reason for this? Or am I just being stupid somehow? (And if I am, you're welcome to slap me.)

The All Star Shotsheet was made by Ozzy/ExPorygon for a now-defunct project to create a Touhou All Stars (similar to Yuke's unreleased one). He made the shot sheet, the image containing the shots was made by gore (who must be cited).

Naturally, there is not official download link to the shot sheet, because it was simply located in the collaborators folder, which was open to members of LOCAA who were working on the project. It's just that the majority of us decided that the ZUN Expanded Shotsheet was inferior and switched to the All Star Shotsheet.

Beyond this, many newer scripters have gained access to it by copying it from other scripts that use it. However, if you use it, both ExPorygon/Ozzy and gore MUST be cited, and do be aware that there are some errors in the shot sheet as well.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on September 14, 2016, 02:21:23 PM
Mine
Code: [Select]
while(!Obj_IsDeleted(bossObj)) {

// update boss speed/dir locally
dir = ObjMove_GetAngle(bossObj);
speed = ObjMove_GetSpeed(bossObj);

// animation handling
if (speed == 0) {
ObjRender_SetAngleXYZ(bossObj,0,0,0);
if(animFrame < 15) { ObjSprite2D_SetSourceRect(bossObj,0,0,64,117); }
if(animFrame >= 15 && animFrame < 30) { ObjSprite2D_SetSourceRect(bossObj,64,0,128,117); }
if(animFrame >= 30 && animFrame < 45) { ObjSprite2D_SetSourceRect(bossObj,128,0,192,117); }
if(animFrame >= 45) { ObjSprite2D_SetSourceRect(bossObj,192,0,256,117); }
animFrame2 = 0;
}
animFrame++; // count animFrame. (++ is +1)
animFrame2+=2; // count animFrame2.
if(animFrame > 60) { animFrame = 0; } // reset animFrame when it is higher than 60.
yield;
}
}

The original
   
Code: [Select]
while(!Obj_IsDeleted(bossObj)) {

// update boss speed/dir locally
dir = ObjMove_GetAngle(bossObj);
speed = ObjMove_GetSpeed(bossObj);

// animation handling
if(speed == 0){
ObjRender_SetAngleXYZ(bossObj,0,0,0);
if(animFrame < 15) { ObjSprite2D_SetSourceRect(bossObj,0,0,64,64); }
if(animFrame >= 15 && animFrame < 30) { ObjSprite2D_SetSourceRect(bossObj,64,0,128,64); }
if(animFrame >= 30 && animFrame < 45) { ObjSprite2D_SetSourceRect(bossObj,128,0,192,64); }
if(animFrame >= 45) { ObjSprite2D_SetSourceRect(bossObj,192,0,256,64); }
animFrame2 = 0;
}
else if(cos(dir) < 0){
ObjRender_SetAngleXYZ(bossObj,0,180,0); // flip vertical
if(animFrame2 < 15) { ObjSprite2D_SetSourceRect(bossObj,0,64,64,128); }
if(animFrame2 >= 15 && animFrame2 < 30) { ObjSprite2D_SetSourceRect(bossObj,64,64,128,128); }
if(animFrame2 >= 30 && animFrame2 < 45) { ObjSprite2D_SetSourceRect(bossObj,128,64,192,128); }
if(animFrame2 >= 45) { ObjSprite2D_SetSourceRect(bossObj,192,64,256,128); }
}
else if(cos(dir) > 0){
ObjRender_SetAngleXYZ(bossObj,0,180,0); // flip vertical
if(animFrame2 < 15) { ObjSprite2D_SetSourceRect(bossObj,0,128,64,192); }
if(animFrame2 >= 15 && animFrame2 < 30) { ObjSprite2D_SetSourceRect(bossObj,64,128,128,192); }
if(animFrame2 >= 30 && animFrame2 < 45) { ObjSprite2D_SetSourceRect(bossObj,128,128,192,192); }
if(animFrame2 >= 45) { ObjSprite2D_SetSourceRect(bossObj,192,128,256,192); } 
}
animFrame++; // count animFrame. (++ is +1)
animFrame2+=2; // count animFrame2.
if(animFrame > 60) { animFrame = 0; } // reset animFrame when it is higher than 60.
yield;
}
}

Basically based off your tutorial with a part removed (because i only have an idling animation) and with the right numbers.
(By the way sorry for not using spoilers but i'm new to this site and haven't found how to use spoilers :/ )
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on September 14, 2016, 04:44:19 PM
Our forum doesn't have the unfolding spoiler button thing to hide/show things. Instead for large piece of code we use  http://pastebin.com/ and post the link here. It is also easier to maintain.

About your code: I can see what is confusing you. First, realise that when your boss is moving, the if(speed == 0) {} part is never executed. Why? Because speed is no longer 0. It is another number, but 0. So your script will skip over this block of code, because the statement resolves in 'false'.

This is why your sprite "locks" onto a specific animation. The game doesn't know what statement/animation to show if the boss is having speed higher or lower than zero. So it will freeze a sprite or the sprite it was showing. When the boss stops moving and has exactly 0 speed, the statement will be run and thus animation will occur.

So in your case, you need to delete the following piece of code:
- if (speed == 0) {  line
- the closing curly brace } for that block.

That will fix your problem. To clean up your code, you can remove:
- animFrame2+=2; as this is no longer used.
- dir = ObjMove_GetAngle(bossObj);  also no longer used.
- speed = ObjMove_GetSpeed(bossObj);   also no longer used.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: SuperSupermario24 on September 14, 2016, 08:40:24 PM
The All Star Shotsheet was made by Ozzy/ExPorygon for a now-defunct project to create a Touhou All Stars (similar to Yuke's unreleased one). He made the shot sheet, the image containing the shots was made by gore (who must be cited).

Naturally, there is not official download link to the shot sheet, because it was simply located in the collaborators folder, which was open to members of LOCAA who were working on the project. It's just that the majority of us decided that the ZUN Expanded Shotsheet was inferior and switched to the All Star Shotsheet.

Beyond this, many newer scripters have gained access to it by copying it from other scripts that use it. However, if you use it, both ExPorygon/Ozzy and gore MUST be cited, and do be aware that there are some errors in the shot sheet as well.
Alright, that'd explain it, thanks. (And I didn't know I have to credit gore as well; I'll keep that in mind.)
I actually have taken it from another script and played with it a bit, and yeah, I did notice the errors in it, which I think I've fixed for the most part.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on September 15, 2016, 08:29:20 PM
Thanks a looooooot ! Everything's working now !
Well, almost :

http://puu.sh/rcqmz/7cd6efe508.jpg
As you can see here there's a weird line of blue pixels on the top left corner of the sprite (of course unrelated to the background since it moves along with the sprite). I can assure you that the spritesheet does not have it. I also had this problem when i was using a single sprite. Do you know what could have caused it ? (it's not that important anyway)

Also, is it possible to disable the ugly EoSD circle thing ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 16, 2016, 12:01:34 AM
Thanks a looooooot ! Everything's working now !
Well, almost :

http://puu.sh/rcqmz/7cd6efe508.jpg
As you can see here there's a weird line of blue pixels on the top left corner of the sprite (of course unrelated to the background since it moves along with the sprite). I can assure you that the spritesheet does not have it. I also had this problem when i was using a single sprite. Do you know what could have caused it ? (it's not that important anyway)

Also, is it possible to disable the ugly EoSD circle thing ?

Blue pixels: add 1 to the top coordinate of your sprites (it has to do with the way things are rendered in DNH)
Disable circle: For a local solution, ensure that your script's System file does not have the magic circle enabled. This assumes that you have a separate copy of default_system within your script folder that is used specifically for the script.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: EPICI on September 16, 2016, 01:36:20 AM
My stage isn't closing properly for some reason.
I use tasking and have SetAutoDeleteObject(true); in TFinalize, which is called at the end of TMain, which is called somewhere in @Initialize.
The music stops and the background disappears confirming the script has closed, yet the end menu doesn't pop up. Normally it just waits a few seconds but here it seems to be stuck. I can continue to move around and do whatever (so the player script is still running).
What could I have possibly done wrong?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on September 16, 2016, 04:33:31 AM
My stage isn't closing properly for some reason.
I use tasking and have SetAutoDeleteObject(true); in TFinalize, which is called at the end of TMain, which is called somewhere in @Initialize.
The music stops and the background disappears confirming the script has closed, yet the end menu doesn't pop up. Normally it just waits a few seconds but here it seems to be stuck. I can continue to move around and do whatever (so the player script is still running).
What could I have possibly done wrong?
Since you're not showing any code, I have to ask first: Are you actually closing the stage with CloseStgScene?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on September 16, 2016, 05:43:05 PM
So, I've been trying out stuff...
http://pastebin.com/UfnW7Dpc
(I don't know the function to shoot a circle so i just copy pasted CreateShotA1 with every angle needed :d, if anyone knows that btw)
I kind of broke my script : the boss isn't shooting at all anymore...
Also the code i had before some changes was supposed to spawn bullets on him, but it worked only once over 2 times, the second time always popped on a random point (i changed the X movement value for the boss so it kind of fixed it but he couldn't move)...
Where did it all go wrong ?
http://pastebin.com/UfnW7Dpc
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 16, 2016, 06:11:04 PM
Where did it all go wrong ?

 CreateShotA1(192,-100,5,365,172,15);

Your bullet is spawning 100 pixels offscreen. All of them are.

For information on shooting circles, please refer to:
https://sparen.github.io/ph3tutorials/ph3u1l7.html#sub3
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on September 16, 2016, 06:19:33 PM
You're shooting the bullets from out of the game field.  :D

Remember that the most top-left corner of your field is X = 0, Y = 0. Meaning if you shoot something at Y = -100, it will be fired outside the field and instant deleted.

That is fine if you wish to shoot things from the boundaries of the field into the field, but then beware of the Auto Delete boundary, which is by default 16 pixels on each side. So you can maximum fire at maximum 16 pixels on each side out of bounds.

Now, since you probably want to fire from your boss, why don't you use bossX and bossY? You are tracking those in the MainLoop, which updates those two variables. So your shot should be:

Code: [Select]
CreateShotA1(bossX,bossY,5,10,12,30);
Of course, you don't want to do that tedious copy-paste of each angle. So let us introduce trigonometry (often here called trig). To spare the math details, this approach allows you to spawn circular patterns for example. Here it how it goes:
Code: [Select]
task fire {
let radius = 32;
let direction = 0;
let numberOfBullets = 36;

loop(numberOfBullets) {
CreateShotA1(bossX+radius*cos(direction),bossY+radius*sin(direction),5,direction,12,0);
direction += 360/numberOfBullets;
}

loop(60) { yield; }
}

Before you're scared what is happening. Here is the thing.
Code: [Select]
radius = how far the bullets spawn from the location (in this case, the boss). 0 = in the middle of the boss.
direction = starting direction of the first bullet (before the circle is made)
numberOfBullets = how many bullets you wish to fit into this circle.
cos and sin = math. I am bad at explaining this.

The direction += 360/<variable> part tells the script which direction and location on the "circle" to place the bullet. For example, if we had 10 bullets. 360 / 10 would be 36. So each bullet would be 36 pixels away from the previous one forming a nice circle. If you would have 36 bullets, then each bullet would be 10 pixels away. Meaning they are closer together and thus a more dense circle.

You want the circle to start tight or already expanded? Just increase/decrease the radius variable. You can also instantly fill in bossX+64 and bossY+32 for example to get an oval shape. Experiment with it.

Notice how the "Angle/direction"  parameter (4th in CreateShotA1) is the same variable as the direction variable. This is required so the bullet flies into the right direction. But if you replace it with a number you wish, the whole circle will be flying towards that direction. Just like Suwako's Rings for example. Try it out for sure!

Remember, this loop of bullets (or circle of bullets) is instantly created. Because the loop has no yield in it. Just go ahead and add 1 single yield after the direction += part. You'll see that suddenly the circle isn't made instantly, but like a spiral.

Hope this gives you more insight in circular patterns.

Edit I see Sparen went with the brief explanation while I was typing this wall-o-text :V . Definitely would adsvise check out his link to get even more insight in circular patterns.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on September 16, 2016, 06:30:01 PM
It all makes sense now lol. I tried inputting the 192/-100 thing because it was what was the boss' position but i had the problem i told you about before when i did it with bossX/Y so i kinda tried stuff on my own...
Thanks a lot  :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on September 16, 2016, 06:46:48 PM
Aye, but it fully functions as I copy-pasted your entire script into my own ph3 and made the changes. This is why it is quite handy when people post their code in pastebin.

Good luck.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on September 16, 2016, 07:36:12 PM
Quote
That is fine if you wish to shoot things from the boundaries of the field into the field, but then beware of the Auto Delete boundary, which is by default 16 pixels on each side. So you can maximum fire at maximum 16 pixels on each side out of bounds.
According to the wiki, it's not 16 pixels but 64.

@Jojo: Note that you also can change theses values by using
Code: [Select]
SetShotAutoDeleteClip (more informations here: http://dmf.shrinemaiden.org/wiki/Shot_Functions#SetShotAutoDeleteClip)



And when we are on shooting circles of bullets, I have a question.
On danmakufu, in term of math, performance and frame rate, is it better to do circle of bullets like that:
Code: [Select]
let A = 0;
let N = 64;
loop(N){
    CreateShotA1(bossX, bossY, speed, A, graphic, delay);
    A += 360/N;
}

or

Code: [Select]
let N = 64;
ascent(i n 0..N){
   CreateShotA1(bossX, boss Y, speed, i*360/N, graphic, delay);
}

?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: EPICI on September 16, 2016, 08:07:29 PM
Since you're not showing any code, I have to ask first: Are you actually closing the stage with CloseStgScene?
It works! Doesn't look like the objects are getting deleted but the stage ends right on cue.
I've always relied on putting CloseScript(GetOwnScriptID()); at the very end, and I've never had a problem with it.
So I'm going with the assumption that CloseStgScene() is just a way to force any script to end.
If I'm making a full game I guess I'll have to switch back to CloseScript(GetOwnScriptID()); and put CloseStgScene(); somewhere in the package?

Anyways thanks a lot!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on September 16, 2016, 08:58:54 PM
@Lefkada, ah right. 64 pixels. Thanks for clearing that up.

It works! Doesn't look like the objects are getting deleted but the stage ends right on cue.
I've always relied on putting CloseScript(GetOwnScriptID()); at the very end, and I've never had a problem with it.
So I'm going with the assumption that CloseStgScene() is just a way to force any script to end.
If I'm making a full game I guess I'll have to switch back to CloseScript(GetOwnScriptID()); and put CloseStgScene(); somewhere in the package?
Actually, CloseStgScene is not a way to force any script end. It only closes the Stage Scene. It will tell the engine that the stage has actually ended and thus will process it all. In ph3, boss fights and stages are actually 'scenes'. You will run into these more when use plural scripts.

Don't trust auto deletion of objects. Exact reasons are unknown (at least, not known to me). But it is better to clean up all objects yourself before calling the CloseScript or CloseStgScene.

The CloseScript only closes the script which is called from. However, it seems the Stage it self uses a different thread/routine to process.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Pruns on September 18, 2016, 09:51:04 PM
Hello,
I have a little problem about creating a "distorsion field" around the boss,
You know ? like the sample PS03 in the danmakufu folder.
These kind of things are made with the HLSL, but all the documentation and stuffs to learn are too much for me compared to what I want to do with that.

Initially, The sample PS03 code is clearly enough for my use, so I just copy-pasted in my script,
the task TwaveCircle() of the first file
and the whole file " SamplePS03_HLSL.txt "

I just changed few things like putting ( baseEffectRadius etc... ) in parameters.

The problem is that when I face up the boss who contains the "distorsion field",  when I back to the title screen, everything is black, my screen is not loaded correctly.
But I still can select and restart the game / options / quit
It can also happen that some background elements don't appear when I start the game again. ( even before modifying the original code ).

Beside this, the distorsion field itself works perfectly

I absolutly don't see how to fix this bug since I don't have any knowledge about HLSL.
I wish I could have time then I could try to understand how it works
Someone has a solution here or maybe just know why it doesn't work ??
Any help is welcomed
Thanks in advance !

This is the original task TWavecircle
http://pastebin.com/Rw6KrFpp (http://pastebin.com/Rw6KrFpp)

This one is the file which contains HLSL
http://pastebin.com/ABX58fJT (http://pastebin.com/ABX58fJT)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on September 19, 2016, 08:07:01 PM
Hey, it's me again ! So this time I have a problem with a different script (yeah i know writing several scripts at the same time as a beginner is bad but it's like just a troll script with just a non spell so whatevs) and it's pretty weird. Basically i copy pasted my first script and edited the values (just the values, the number of values is the same). But it keeps giving me random errors like "movement is not defined" while the exact same thing works in the first script. I couldn't spot errors like missing semi colons and stuff like that so i don't really know where it's coming from and the weird error alert system of danmakufu isn't helping :s
http://pastebin.com/LfgeDASq
This script isn't that important but i suppose knowing what caused it could be useful later so yeah.

Also, concerning my main script, it works fine, but i'd like to change the attack a bit and i don't know how to do it :

Code: [Select]
task fire {
let radius = 32;
let direction = 0;
let numberOfBullets = 36;
loop(numberOfBullets) {
CreateShotA1(bossX+radius*cos(direction),bossY+radius*sin(direction),5,direction,54,0);
CreateShotA1(bossX+radius*cos(direction),bossY+radius*sin(direction),5,direction,156,30);
direction += 360/numberOfBullets;
}

loop(60) { yield; }
}

Right now the two waves overlap each other. I would like to set in a way where the second wave would fire in the gap left by the first one. I tried setting direction+5 instead of just direction to try to change the angle but it didn't work i think so i don't really know how to do this.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 19, 2016, 08:43:35 PM
But it keeps giving me random errors like "movement is not defined" while the exact same thing works in the first script. I couldn't spot errors like missing semi colons and stuff like that so i don't really know where it's coming from and the weird error alert system of danmakufu isn't helping :s
http://pastebin.com/LfgeDASq

Hint: Do your braces { and } match up? I think you'll find your answer around Line 93. :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on September 20, 2016, 03:32:19 PM
Quote
Right now the two waves overlap each other. I would like to set in a way where the second wave would fire in the gap left by the first one. I tried setting direction+5 instead of just direction to try to change the angle but it didn't work i think so i don't really know how to do this
Try direction+360/(2*numberOfBullets) insted of direction for one of the bullets  ;)


Anyway, I found a strange.. glitch? Or I don't really know what is it.
When  I work on my package script, I can't see any CommonData in the LogWindow. Even in I create them in an active task of the package script it just don't appears. It's still existing since I can use it for condition or other stuff but it is just totally invisible on the LogWindow.
Someone have an idea about that?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on September 20, 2016, 05:58:42 PM
Thanks a lot Sparen !  :D

I've been adding stuff to my pattern but i'm having trouble with the distance between bullets.

Code: [Select]
task fire {

let dir = AngleToPlayer;
let radius = 32;
let direction = 0;
let numberOfBullets = 36;
loop(numberOfBullets) {
CreateShotA1(bossX+radius*cos(direction+360/(2*numberOfBullets)),bossY+radius*sin(direction+360/(2*numberOfBullets)),2,direction+360/(2*numberOfBullets),54,0);
CreateShotA1(bossX+radius*cos(direction),bossY+radius*sin(direction),2,direction,156,15);

direction += 360/numberOfBullets;
}

CreateShotA1(GetPlayerX-160,GetPlayerY,3,360,318,120);
wait(60);
CreateShotA1(GetPlayerX+160,GetPlayerY,3,180,318,120);
wait(60);
CreateShotA1(bossX,bossY,3,dir,328,30);
wait(120);

loop(120) { yield; }
}

Right now the code works without problems but i can't find how to increase distance between the aimed bullets : increasing delay just makes the loop start later but then it stays a line of close bullets. Increasing the speed does increase the distance but of course i don't want to increase the speed.
http://puu.sh/rhWZJ/91c3afb3be.jpg
That's kinda how i want it to be but without the bonus speed.
Also, not as important but how do I set the boss name ? (Like how it shows "Yukari Yakumo" on top left corner or like any boss in Touhou, you know). It would be way nicer with the boss name and i suppose it's not too hard to set ? I looked by myself in the function list but i didn't find any that looked like the one i needed.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on September 20, 2016, 08:31:57 PM
You can increase delay to increase the distance. Or increase the number of frame between two fired bullets. ActuallyI don't really understand your problem and which bullet is in cause (butterflies? amulets? arrowhead??). It's not really clear.
You can try to fire your two patterns in two tasks. With that you can do whant you want with one of them wihtout changing the behavior of the other.

To make your boss name you can uses various things.
You can use a picture of the boss name and dosplay it by using the ObjectRender functions or you can use directly texts.
Try this (it's the text method):

Code: [Select]
let bossname = ObjText_Create;
ObjText_SetText(bossname, "NameOfTheBoss");
ObjRender_SetPosition(bossname, 16, 12, 0);
If I do this right, it will display it in the top left corner.

You can also use other text object functions to change color, size, order, etc.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on September 20, 2016, 08:40:25 PM
Rather than doing complex explainations i'll just let you play it :
 https://www.mediafire.com/folder/b8yl6mymvc0t4/JoJo&#39;s_Bizarre_Adventure
The bullets in cause here are the aimed ones : meaning the red stars and green hearts.
You can try changing their delay and you'll see that it just makes the loop start later, so it doesn't actually impact the distance between bullets. I've already tried increasing the number of frames for the wait function but it doesn't do anything either. 
By the way i suggest you use a Reimu player script to play it or something with a small hitbox because it's a pretty tight pattern.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: EPICI on September 21, 2016, 02:27:51 AM
You know, all this stuff can be a lot simpler if you use ascent loops and extra tasks. Trust me, it makes things way easier.
Example (uses x and y as boss x and y):
Code: [Select]
task spiral(offset){//Individual spiral
    ascent(i in 0..30){
        CreateShotA1(x,y,1.5,i*12+offset,DS_SCALE_S_WHITE,15);
        yield;
    }
}
task attack1{//Composite attack
    ascent(i in 0..6){
        spiral(i*60);
        wait(15);
    }
}
This would create 6 spirals beginning at different angles.
Not too hard to integrate
Code: [Select]
GetAngleToPlayer(). Just remember though, it's not easy on the engine, save it once to a variable called
Code: [Select]
angleT or something, recalculate it once a frame if you need to. It's much easier to fetch the value of
Code: [Select]
angleT than to recalculate using
Code: [Select]
GetAngleToPlayer().
On another note, I didn't see you use
Code: [Select]
dir (which was set to
Code: [Select]
GetAngleToPlayer()) anywhere. If you want to aim it at the player change it to
Code: [Select]
let direction = GetAngleToPlayer().
Also,
Code: [Select]
360/(2*direction) is redundant when you can save yourself a calculation with
Code: [Select]
180/direction.

If you want to create delays, it's pretty easy to just use the delay value at the end of
Code: [Select]
CreateShotA1() or any of the other shot functions. However, this can create a coloured cloud, which can fill up the entire screen. Instead you might want to create something like this:
Code: [Select]
task delayBullet(x,y,s,r,g,d){//Waits before spawning a bullet with 15 frame delay, change all mentions of "15" for a different delay value
    let count = 15;
    if(d<15){count=d;}else{wait(d-15);}
    CreateShotA1(x,y,s,r,g,15);
}
That way you don't end up with a messy cloud.
Alternatively you can use timing, like so:
Code: [Select]
let tick = 0;
while(!Obj_IsDeleted(objBoss)){
    alternative(tick%180)
    case(60){attack1;}
    case(120){attack2;}
    tick++;
    yield;
}//This triggers tasks attack1 and attack2 on a 3 second cycle
I personally use timing because it keeps things more organized, but you can do the same thing in many ways.
Remember, it is possible to pass as many parameters as you want to tasks. Most commonly I just use it for position, angles, offsets, delays, etc. but I also recommend using
Code: [Select]
tick or whatever you named it as a seed for pseudo-randomness. I don't know anything about the randomness but I like my attacks to be completely deterministic and consistent between runs.
Also try and keep the angles between 0 and 360. If it can get large (ex.
Code: [Select]
x^y+y^x as a seed) add brackets and put
Code: [Select]
%360 at the end.

Hope this helps to some extent.
Have a look at Not My Spellcard (https://www.shrinemaiden.org/forum/index.php/topic,19819.0.html), it's my most recent completed script. It's far from perfect but it's optimized to some extent and uses these techniques.
(where are the spoiler blocks on this forum, this post is going to be huge)

halp plz
Can anyone explain the 3D camera? I spent more than an hour trying to figure it out, it's confusing because (0,0,0) is not at a corner or centered, x does not correspond to horizontal, y does not correspond to vertical, and z does not correspond to depth. Also the rotation is confusing. I was trying to create a scrolling background at an angle, I had all the math worked out and it would have worked perfectly, and it ended up being a mess. I changed some constants and made the angle (0,0,0) and it worked, but I may as well have been using the 2D sprites since it would be more intuitive. I'm sticking to 2D until someone can explain the 3D.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 21, 2016, 09:46:27 AM
Here's a primer on how the camera system works:
https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1190637.html#msg1190637

Helepolis also has three videos that are more hands-on and have relatable visuals:
https://www.youtube.com/watch?v=kEM1LUTrur4&index=6&list=PLsqimF6_OUHBNeOrp_k2t9bPk5Q6PsB_P

Both of these together should be good for understanding how the systems work and how to implement what you want. I would suggest reading my post first even if you don't get it entirely, then watching the videos, then rereading the writeup. But that's up to you.



Tutorials aside, one likely reason you're having trouble is because the default camera position/orientation is not very obvious (radius: 500, elevation: 55, azimuth: 15), and when coming from 2D graphics you tend to ignore the camera at the beginning, which is actually the most important part. The other part is that even if you're working with the camera, the engine's camera is set up in a non-intuitive way, because at 0 elevation and 0 azimuth it doesn't correlate the X/Y axes the same way as they work on the 2D plane. Instead its 3D axes are based on a convention where the X axis increases southwards, the Y axis increases upwards, and the Z axis increases eastwards. For the most part it's suggested to rotate azimuth by default to -90 and use that as a "canonical zero", since that sets the camera up in the way that typically makes sense to most people.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Asthmagician on September 21, 2016, 12:00:04 PM
Hi all,
I'm working on a stage script and have encountered an issue.
I have a Midboss and Boss plurals, both of which seem to close without issue.

I have the following code in my Stage Script.
Code: [Select]
task AliceMidBoss{
  let path = dir ~ "AliceBossPlural.dnh";
  let scriptID = LoadScriptInThread(path);
  StartScript(scriptID);
  while(!IsCloseScript(scriptID)){
    yield;
  }
  MarisaBoss;
}

task MarisaBoss{
  let path = dir ~ "MarisaBossPlural.dnh";
  let scriptID = LoadScriptInThread(path);
  StartScript(scriptID);
  while(!IsCloseScript(scriptID)){
    yield;
  }
}

Which in theory, should work without issue.
However, when I beat the midboss, the boss doesn't start up?
I tested further and am now very confused.
This code:
Code: [Select]
task AliceMidBoss{
  let path = dir ~ "AliceBossPlural.dnh";
  let scriptID = LoadScriptInThread(path);
  StartScript(scriptID);
  while(!IsCloseScript(scriptID)){
    MarisaBoss;
    yield;
  }
}

Crashes with an error about EnemyBossScene (presumably that it can't be created twice), which makes perfect sense.
This Code:
Code: [Select]
task AliceMidBoss{
  let path = dir ~ "AliceBossPlural.dnh";
  let scriptID = LoadScriptInThread(path);
  StartScript(scriptID);
  while(!IsCloseScript(scriptID)){
    yield;
    MarisaBoss;
  }
}

Runs like the frst block?
Even though it should crash like the second block?
All of this is based on looking at other stage scripts (Mainly Aldryn's) which are structured very similarly, and work fine.
Any ideas?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 21, 2016, 12:44:28 PM
Hi all,
I'm working on a stage script and have encountered an issue.
I have a Midboss and Boss plurals, both of which seem to close without issue
Please show us an example of a plural script as well. Plural scripts should run CloseScript(GetOwnScriptID()); once they have finished to notify the stage that it's OK to move on to the next one.

I tested further and am now very confused.
This code:
Code: [Select]
task AliceMidBoss{
  let path = dir ~ "AliceBossPlural.dnh";
  let scriptID = LoadScriptInThread(path);
  StartScript(scriptID);
  while(!IsCloseScript(scriptID)){
    MarisaBoss;
    yield;
  }
}

Crashes with an error about EnemyBossScene (presumably that it can't be created twice), which makes perfect sense.

Calling MarisaBoss every single frame means that Danmakufu will not work in general. As to why switching the yield; and MarisaBoss calls works, I personally cannot explain it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on September 21, 2016, 01:14:56 PM
I just pulled the aimed bullet function (with the angleToPlayer part) from one of the first tutorial videos of Helepolis because i remembered it had aimed bullets, and i just copied the whole function without changing anything because safer is better. About the whole delay and distance between bullets, i already explained the problem : increasing delay started the loop later, but didn't affect the actual distance between bullets for whatever reason. I'm gonna look some more into it, thanks for all the info though :)
I'll edit this post later if i run into trouble or have a question
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Asthmagician on September 21, 2016, 02:06:22 PM
Please show us an example of a plural script as well. Plural scripts should run CloseScript(GetOwnScriptID()); once they have finished to notify the stage that it's OK to move on to the next one.

This (http://pastebin.com/r8ySDWA3)  is one of the two plurals.
The other is the same (except for having different singles).

Calling MarisaBoss every single frame means that Danmakufu will not work in general. As to why switching the yield; and MarisaBoss calls works, I personally cannot explain it.

I get that calling MarisaBoss should stop danmakufu from working, I was focusing specifically on the switch between yield and MarisaBoss.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 22, 2016, 02:39:04 AM
Right now the two waves overlap each other. I would like to set in a way where the second wave would fire in the gap left by the first one. I tried setting direction+5 instead of just direction to try to change the angle but it didn't work i think so i don't really know how to do this.
The way you had set it up originally is correct. What you want is making the displacement in spawn position (bossX + bla, bossY + bla) at angles offset from the first wave. Also, instead of using delay to time bullets, you should explicitly code the timing. Bullet delay should just be effect.
Code: [Select]
task fire {
    let radius = 32;
    let direction = 0;
    let numberOfBullets = 36;
    loop(numberOfBullets) {
        CreateShotA1(bossX+radius*cos(direction),bossY+radius*sin(direction),5,direction,54,10);
        direction += 360/numberOfBullets;
    }
    loop(30) { yield; }
    direction = 360/(numberOfBullets*2); // or just 5
    loop(numberOfBullets) {
        CreateShotA1(bossX+radius*cos(direction),bossY+radius*sin(direction),5,direction,156,10);
        direction += 360/numberOfBullets;
    }
}

Anyway, I found a strange.. glitch? Or I don't really know what is it.
When  I work on my package script, I can't see any CommonData in the LogWindow. Even in I create them in an active task of the package script it just don't appears. It's still existing since I can use it for condition or other stuff but it is just totally invisible on the LogWindow.
Someone have an idea about that?
You probably know Common Data is divided into Areas. When you work just using SetCommonData it uses a default Area, which is empty string. If you click on the first row in the log, the data should show up.

This (http://pastebin.com/r8ySDWA3)  is one of the two plurals.
The other is the same (except for having different singles).
What you've posted shouldn't give you the errors you describe (besides the tests that should obviously error). I can copypaste code and have it run smoothly, so something else is going on. Please zip up your project and post it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Asthmagician on September 22, 2016, 05:58:11 AM
Here (http://www.mediafire.com/download/fsdurn2bftb8ud0/ZippedProject.zip) is the zipped folder containing all the files in the project.
It also contains a non-standard th_dnh.def because of a changed window size.

Any help is appreciated.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 22, 2016, 07:43:26 AM
Code: [Select]
// StgTest.dnh

@MainLoop{}

:|
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on September 22, 2016, 07:49:30 AM
Quote
You probably know Common Data is divided into Areas. When you work just using SetCommonData it uses a default Area, which is empty string. If you click on the first row in the log, the data should show up.
Yes I know this. But... no. The first row is empty even if I click on it and there is no common data in the default area according the LogWindow (but actually they exist for danmakufu and they can be used).
It's not really an issue for the game itself but it is for debug.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Asthmagician on September 22, 2016, 07:59:06 AM
Code: [Select]
// StgTest.dnh

@MainLoop{}

:|

Wow. Wow.
Lesson learned: MainLoop doesn't crash danmakufu if it isn't yielded.
Sorry if I wasted anyone's time.
Thanks for the help.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 22, 2016, 08:02:34 AM
Yes I know this. But... no. The first row is empty even if I click on it and there is no common data in the default area according the LogWindow (but actually they exist for danmakufu and they can be used).
It's not really an issue for the game itself but it is for debug.
Can you create an Area and see it? Do other packages (e.g. full games) also not log any CommonData?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on September 23, 2016, 02:37:21 PM
I have created Area Common Data in my package and now i can see all the common data, even thoses in the default area. I d'ont really know if it was just a random bug or if it'simpossible to see common data if there is no area common data created/loaded but anyway, it seems to work now. Thanks.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on September 23, 2016, 10:10:28 PM
So, I've started trying out spell making, and I've ran into a little problem :
Code: [Select]
// name the boss
let bossname = ObjText_Create;
ObjText_SetText(bossname, "Boss Name");
ObjText_SetFontSize(bossname,9);
ObjRender_SetPosition(bossname, 16, 12, 0);

// name a spellcard
let spellName = ObjText_Create;
ObjText_SetText(spellName, "Name of spell");
ObjText_SetFontSize(spellName,9);
ObjRender_SetPosition(bossname, 500,60, 0);

I expected it to work but when i play the script it just shows the name of the spellcard in the top left corner. I tried random coordinates to see if it would change but nothing moved, also the boss name stops showing if there's the spell name.
Any idea on how to fix it ?

Also more importantly how do I chain a nonspell to a spellcard ? And how do I add lives to a boss (because a lifebar = 1 nonspell + 1 spell is cleaner than everything on a single lifebar) ?

And last question for now : how do I force a player script for my whole script ? (is it easy and short to do ?)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: EPICI on September 24, 2016, 01:24:48 AM
This should cover everything you'll need to know about text objects. (http://sparen.github.io/ph3tutorials/ph3u2l17.html)

This should cover everything you'll need to know about plurals. (http://sparen.github.io/ph3tutorials/ph3u2l12.html)

Player scripts can be specified in the header with #Player. (http://sparen.github.io/ph3tutorials/ph3u1l3.html)

I recommend reading everything, but if you just need those little bits, Ctrl+F will be your best friend.
Also you should probably start transferring commonly used stuff to a function script and use #include in every script to add it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 24, 2016, 04:03:15 AM
So, I've started trying out spell making, and I've ran into a little problem :
Code: [Select]
// name the boss
let bossname = ObjText_Create;
ObjText_SetText(bossname, "Boss Name");
ObjText_SetFontSize(bossname,9);
ObjRender_SetPosition(bossname, 16, 12, 0);

// name a spellcard
let spellName = ObjText_Create;
ObjText_SetText(spellName, "Name of spell");
ObjText_SetFontSize(spellName,9);
ObjRender_SetPosition(bossname, 500,60, 0);

I expected it to work but when i play the script it just shows the name of the spellcard in the top left corner. I tried random coordinates to see if it would change but nothing moved, also the boss name stops showing if there's the spell name.
You keep using bossname in the second bit instead of spellName, and an x-coordinate of 500 is outside the game field so you won't see it. Changing the first SetPosition won't do anything because the second one will overwrite it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on September 24, 2016, 07:07:37 AM
i didn't see i forgot to change the setPosition. I'm feeling stupid now lol
Thanks i guess

Edit : I've made a plural script. It almost works, but when a pattern ends (for example when the non spell links to the spellcard) bullets spawn in the top right corner. Also, the BGM stops playing when a pattern ends. I've removed the PlayBGM from the spell single script because it would just replay the BGM from the beginning. How do I set it up so the music just keeps playing normally ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: EPICI on September 24, 2016, 03:51:58 PM
Put the BGM stuff in the plural. If you make stages later, transfer the BGM code to the stage script.
Some more info (http://sparen.github.io/ph3tutorials/ph3u2l15.html)

Also make sure in the bullet spawning tasks you have
Code: [Select]
if(!Obj_IsDeleted(obj)){//or whatever you named the variable
    //stuff
    wait(n);//insert number here
}
That way you don't get the bullets spawning in the corner.
If you're worried about lag replace your ascent loops with a while loop, like so
Code: [Select]
let count = 0;
while(!Obj_IsDeleted(obj)&&count<m){//replace m with the number of times you want it to loop
    //stuff
    count++;
    wait(n);//set your own timer value
}
That way the loop breaks when the object is gone.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on September 27, 2016, 08:27:25 PM
I'm not sure it can go here because it's not directly related to danmakufu scripting but I'll try since it's at least related to game making.
Someone exactly know what is wrote in green on the officials Touhou loading script?
(http://img110.xooimage.com/files/b/3/6/touhou-loadscreen-ref-5081bda.jpg)
It seems it's alwas the same thing but I can't read japanese and I don't know where I can found a translation of this.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Romantique Tp on September 27, 2016, 09:07:33 PM
This game is a work of fiction. All characters and organizations that appear have passed into fantasy.

THCrap has translation patches for all recent games.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on September 27, 2016, 09:30:13 PM
Thanks a lot. I don't really know about translation since I don't have they after Touhou 8.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Whatever on September 29, 2016, 06:20:59 AM
How do I make a player not die when they are hit? (without removing the hitbox)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on September 29, 2016, 07:05:23 AM
How do I make a player not die when they are hit? (without removing the hitbox)

You could trigger a counter bomb on the last frame allowed for counter bombs, which does nothing except keep the player alive. Just remember to add an extra bomb just before doing so. The implementation is up to you, of course.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 29, 2016, 07:15:51 AM
From the player side or the enemy side? What do you mean by not die? Not lose a life? Not disappear? Can't really tell what the intended purpose is.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: netugi on October 11, 2016, 12:46:36 AM
Question, I'm trying to make a custom player script, where the character has a laser shot. I have the laser working in all ways except for that no collisions are actually happening. I have my code for the laser on pastebin: http://pastebin.com/7aC4APZ2 (I can post the whole player script if needed)
The only other relevant code is starting the task in @Initialize. The lasers are animated using a custom animation (noodles shooting out), there's an animation for the noodles firing out, looping as you hold the shot button, then exit.
I'm not sure why the laser isn't colliding with anything, any help for this would be lovely.
(sorry if the code's crap, this is my first project in Danmakufu)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 11, 2016, 04:40:24 AM

Since this is a straight laser, I suggest using ObjStLaser_SetAngle() instead of ObjMove_SetAngle(). They behave quite differently. I'm not sure if that's the source of the problem (it might be, it might not be), but I suggest fixing this and testing once more.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 11, 2016, 10:29:07 AM
(Above isn't actually the problem, to note)



There are a few things going on that are just due to neatness, but the main "problem" is just your control flow.

It starts with a loop if the laser is hitting anything. It won't be since it hasn't been set to a position yet, so the loop doesn't run. None of the other loops trigger either and are skipped, until you hold the shot key. The laser still won't hit anything that frame, and the animation loop starts. Once the animation loop starts the laser is positioned and actually should work more or less. However because you're in that loop until you stop shooting, you'll never get back to the logging loop, which is why you won't notice any collision. Similarly you won't actually check if the player still exists until you shop shooting. Lastly, in the no-shoot state you aren't really doing anything, which could potentially trip you up in the future if you do want something to happen when not shooting. Basically you just have to pay a bit more attention to how your flow works, but otherwise it probably already functions correctly. Part of it is just that you misplaced your logging code and probably didn't test on a boss or something.

You can turn your logging code into its own task and then run it before your !Obj_IsDeleted(op_obj) loop, or you can plop it inside the shooting loop. The former would look like this:

Code: [Select]
// ...
ObjRender_SetScaleXYZ(playerShot,1,1,1);

task log(){
    while(!Obj_IsDeleted(op_obj)){
        if(ObjCol_IsIntersected(obj)) {
            WriteLog("collision");
        }
        yield;
    }
}
log();

while(!Obj_IsDeleted(op_obj)) {
// ...

(The following is just my advice and a full example of a player laser. If your stuff is fixed and you don't care about making it cleaner or easier to build on later, you can ignore this)

You seem to have three main states and cycle through them. Often I like to explicitly define my states, like you do a bit with animPhase, since it gives you more control over how your states transition.
Here's an example of how I would structure a player laser like yours. It should be immediately usable as long as you have a shot with ID 1 and have objPlayer defined.
https://gist.github.com/drakeirving/21d142646e9588a694bab30b5f968b31
It looks pretty similar to the structure you have now, but the loops are controlled only by the states, which are switched around inside each one. Stuff to run between state switches are just put between the loops. Also note how in the cooldown state you can wait for it to finish and turn off, or press the shot button again to fire before the disappear animation ends.

Another tip would be considering changing ObjShot_SetDamage(obj,0) to ObjShot_SetIntersectionEnable(obj,false) like I do above. It totally disables collision instead of just changing the damage, which is relevant for example right now, when you're testing to see if it's hitting anything; it will react regardless of whether the laser is visibly out or not because the collision is always active.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: netugi on October 17, 2016, 12:33:25 AM
I tried what you said about the collision test while loop, changed it to a task, but it makes no difference. I've tried many things, including making my code more like the example one you gave me, and nothing's changed aside from the small improvements from your code. Lasers render and follow my character's position as before. I'd tried your code with my animations and I was getting nothing, not even lasers rendering, hence why I modified my own code.
http://pastebin.com/7mWj5ihE
Note: I tried changing all the while loops (aside from !Obj_IsDeleted) into if statements, hence all the commented out yields, and it doesn't appear to make any difference. Also, I've tried other people's player scripts with lasers (a recreation of MarisaB from MoF) against the boss and they work, so it's gotta be an issue with my laser.

Here's a video showcasing the game in action (very bare-bones atm, been stuck on this for a while):
https://www.youtube.com/watch?v=vsH6CfrJUzc&feature=youtu.be
Sorry about the game not being Touhou, but I assure you I take a lot of gameplay inspiration from Touhou, hence why I chose to use Danmakufu.

If all else fails, I'll probably just make the laser into a stream of bullets to resemble a laser, which would coincidentally fit with the noodly theme, but I'd like to figure this out if possible because I'm stubborn.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on October 17, 2016, 01:24:09 AM
https://www.youtube.com/watch?v=vsH6CfrJUzc&feature=youtu.be
This video has been marked private.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 17, 2016, 02:38:10 AM
I'd tried your code with my animations and I was getting nothing, not even lasers rendering, hence why I modified my own code.
If my code doesn't work drag-and-drop, and your main problem is that the laser renders (which is a Sprite) but not collides (which is a Laser object), my intuition says that either your shotsheet is incorrect or not loaded, and nothing is actually being fired. This would cause both your original problem and the problem you're finding with my code. Please make sure you can at least fire your ID 1 shot as a bullet.

EDIT: On inspection, you had originally given your laser the shot ID=1, but in your current code you use the texture variable which will absolutely not work. ObjShot_SetGraphic requires a shot ID. The above still applies though, make sure it actually fires something at all.
Also for the log task, you haven't called it wait no you did, just in the wrong place. Note that in my blurb I define the task and then immediately call it; that's what you want. If you put it in your while loop it will keep launching new tasks every frame that each try to log on every frame, and log a billion times.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: TheTeff007 on October 19, 2016, 01:59:02 PM
Just got into learning ph3 (since programming on 0.12m has given me so much troubles) and I noticed that in the th_dnh.def file there is an option for resolution. Does this means that I can make it bigger and use higher quality images or just merely adjusts the size of the program and scales everything?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 19, 2016, 02:16:06 PM
Just got into learning ph3 (since programming on 0.12m has given me so much troubles) and I noticed that in the th_dnh.def file there is an option for resolution. Does this means that I can make it bigger and use higher quality images or just merely adjusts the size of the program and scales everything?

You can actually choose to use HD graphics and have your game run with them. Do note that performance wise, you will have to compensate since DNH isn't the most... optimized when it comes to rendering.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jeremie on October 21, 2016, 11:33:42 AM
I'm not sure I'm posting in the right thread (since this is about Danmakufu Q&A) even though I've browsed some of the boards and posts to try making sure where I should ask this question. I also tried looking up if I could find information about this here but it's been somewhat limited. I suppose it could fall under the guidelines but this is about a game project I've been working on.

A while ago I posted on this forum about a RPG project I was making. There's a little bit about guidelines I failed to notice until a recent interview with ZUN about not using data from his projects in their original form. Truth be told, I've been using music AND sounds in my RPG project from Touhou games. This is a free project that will never have a commercial release (it's budget beyond RPG Maker XP is also 0$) and while one could say that the music is used as a tool to say the story in my game project, that obviously doesn't pass when it comes to copyright laws and the likes. I was wondering what would be a good alternatives to use Touhou-related music since I still wish to use music that I feel is in tone with the events in the game and I feel music is very important for a RPG project too. I'm currently looking into certain options but any ideas, recommendations, etc. would be very welcome.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on October 21, 2016, 02:47:46 PM
It's been a while since I've posted on this thread (or used Danmakufu).
So, I'm looking to get back into it.
My main problem is that music is not playing correctly when I use the plural script : if i put the music in the plural it does nothing, if i put it only in the first single it stops playing when it gets to the next single and if i put it in each single it starts playing from the beginning when it gets to the next single.

Also, is there any site or video or whatever that explains in detail how to fire basic shapes (lines/circles/spirals)and how it works ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on October 21, 2016, 03:50:40 PM
< snip >
You have two options in this case:
- Use remixes, covers or rearrangements of the original songs from ZUN. But you'll need to ask permission from the artists who made those arrangements/mixes.
- Make your own rearrangement/mix/cover

My main problem is that music is not playing correctly when I use the plural script : if i put the music in the plural it does nothing, if i put it only in the first single it stops playing when it gets to the next single and if i put it in each single it starts playing from the beginning when it gets to the next single.
Question is how you exactly put it in the plural. If you're putting it as a header, then that won't work. You'll need to separately load and play the music using the Danmakufu functions. Just like how sound effects are loaded and used, you do the same for music.

Edit: You will need to look into http://dmf.shrinemaiden.org/wiki/Functions_(ph3)#Sound_Object_Functions
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on October 21, 2016, 05:12:17 PM
Thanks ! I was putting it normally but i only used the functions in http://dmf.shrinemaiden.org/wiki/Audio_Functions and didn't know there was the Sound Object section.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jeremie on October 21, 2016, 09:01:18 PM
You have two options in this case:
- Use remixes, covers or rearrangements of the original songs from ZUN. But you'll need to ask permission from the artists who made those arrangements/mixes.
- Make your own rearrangement/mix/cover

Ah, alrighty then, I guess that'll have to be plan A either way since I'm not gifted when it comes to music and editing it. Thanks. ~
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 22, 2016, 01:23:35 AM
Thanks ! I was putting it normally but i only used the functions in http://dmf.shrinemaiden.org/wiki/Audio_Functions and didn't know there was the Sound Object section.
You can pretty much forget about the top-level Audio functions since they're very limited. They're basically just leftovers from 0.12m.

However, with the more powerful Sound objects you have to do a bit more management to make sure you aren't creating a million objects or have a bunch of invisible garbage. It probably won't matter if you're just playing BGM.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on October 22, 2016, 07:44:39 PM
Hi. I'm trying to make a circle render by using OBJ_PRIMITIVE_2D like in the default magic circle thing. I tried different things but I just can't affich it.
I already make it, based on the magic circle used by default in the player script;
Code: [Select]
task TCircle {
let dir = GetCurrentScriptDirectory();
let countVertex = 64;
function CreatePrimRender(){
let path = dir ~ "img/lb.png";
let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
ObjPrim_SetVertexCount(obj, countVertex);
ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
Obj_SetRenderPriority(obj, 0.60);
ObjPrim_SetTexture(obj, path);
ascent(iVert in 0..countVertex / 2) {
let left = iVert * 128;
let indexVert = iVert * 2;
ObjPrim_SetVertexUVT(obj, indexVert + 0, left, 0);
ObjPrim_SetVertexUVT(obj, indexVert + 1, left, 128);
}
let r = 120;
ascent(iVert in 0..countVertex / 2){
let indexVert = iVert * 2;
let a = 360 / (countVertex / 2 - 1) * iVert;
let vx1 = r * cos(a);
let vy1 = r * sin(a);
ObjPrim_SetVertexPosition(obj, indexVert + 0, vx1, vy1, 0);

let vx2 = r * cos(a);
let vy2 = r * sin(a);
ObjPrim_SetVertexPosition(obj, indexVert + 1, vx2, vy2, 0);
}
ObjRender_SetPosition(obj, 200, 200, 0);
}
CreatePrimRender();
}
I'm doing something wrong for sure but... I don't know what. It's almost the same thing than the magic circle, The task is well called, the path is right, The object and primitive type seems correct... I just don't know why it don't work. I'm depressed.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on October 23, 2016, 12:09:27 AM
http://pastebin.com/PuFkEQe9

My boss just shoots a circle once, doesn't move at all, and then does nothing. What did i do wrong ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Whatever on October 23, 2016, 03:09:48 AM
I'm doing something wrong for sure but... I don't know what. It's almost the same thing than the magic circle, The task is well called, the path is right, The object and primitive type seems correct... I just don't know why it don't work. I'm depressed.
1. If you are using primitive objects with textures, you must use ObjSprite2D_SetDestCenter (or SetDestRect, if that's your thing).
2. If you want the circle to keep rendering, you'll need to put CreatePrimRender() in a loop.
Hope this helps (?).

edit:
http://pastebin.com/PuFkEQe9

My boss just shoots a circle once, doesn't move at all, and then does nothing. What did i do wrong ?
It's because you called attack() 3 times simultaneously without telling danmakufu to wait, so they overlap.
The solutions to this problem are:
1. Put loop(n){yield;} after attack()'s in Pattern().
2. Change attack() from task to function, that way, Pattern() will wait until attack() has ended before continuing.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 23, 2016, 06:53:05 AM
As long as he changes attack() to a function, the yields he already has there will work fine. (That being said, it's arguable that putting the waiting code in the higher-level Pattern() task instead, and having attack() just be the shooting alone, makes it a bit cleaner. But really it doesn't matter.)
Also you should move playing the shot sound to outside the loop since right now it'll just stack up a bunch of calls for no reason. (Again, not that it would affect anything really.)


@Whatever: Neither points about rendering are correct, sorry. ObjSprite2D functions are just convenience functions for rectangular primitives so they aren't absolutely necessary (nor do they apply to non-rectangles), and you also don't need the code in a loop to keep it being rendered, it'll just only draw once and stay there without changing, that's all. Appreciate the intent though.
Hi. I'm trying to make a circle render by using OBJ_PRIMITIVE_2D like in the default magic circle thing. I tried different things but I just can't affich it.
I already make it, based on the magic circle used by default in the player script
Check out the vertex positions being set. Each pair of vertices represents a "top" and a "bottom" point, and all of these lined up makes your shape. Yet when you're positioning your vertices each top and bottom vertex are going to be set to the same position, so at best you have a 0-width circle. The reason the default system circle seemingly does this is because it uses a weird method to keep track of what radius every vertex should be at and then converts those points to where they should be in the circle. In your case all you have to do is make sure the "outside" radius is some width further out than the inside radius.
So let vx2 = (r+width) * cos(a) or something.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on October 23, 2016, 07:27:59 AM
Thanks a lot Drake. I do it and it magically appears. So, that's the point of listRadius[indexVert] used in the default scripts... It's good to know.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 23, 2016, 12:34:05 PM
Just to clarify, the only reason they store the radius values for all vertices is because when you capture a spell the circle squashes into you like a star, and they chose to keep track of all the vertex radii in an array instead of using a formula to determine what radius each vertex should have at any point in time.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: netugi on October 24, 2016, 01:40:03 AM
If my code doesn't work drag-and-drop, and your main problem is that the laser renders (which is a Sprite) but not collides (which is a Laser object), my intuition says that either your shotsheet is incorrect or not loaded, and nothing is actually being fired. This would cause both your original problem and the problem you're finding with my code. Please make sure you can at least fire your ID 1 shot as a bullet.

EDIT: On inspection, you had originally given your laser the shot ID=1, but in your current code you use the texture variable which will absolutely not work. ObjShot_SetGraphic requires a shot ID. The above still applies though, make sure it actually fires something at all.
Also for the log task, you haven't called it wait no you did, just in the wrong place. Note that in my blurb I define the task and then immediately call it; that's what you want. If you put it in your while loop it will keep launching new tasks every frame that each try to log on every frame, and log a billion times.

Sorry about the slightly late reply, but I have got it working now. You pointed me in the right direction, it was an issue with my shot sheet. I can't pinpoint what exactly I changed that fixed it, but I did tinker with the shoot sheet and whatnot, and eventually got it working. Again, I didn't use your code because I understood my code a bit better. I've cleaned up my code slightly, getting rid of unnecessary things. http://pastebin.com/hSBb9Vna
An interesting observation, it seems like the ObjStLaser_SetAngle is off by 90 degrees from the usual angle, so I had to throw in a -90 degree modifier to my task's angle variable for that, that may have been part of why I didn't get any collision.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on October 25, 2016, 01:36:54 AM
Code: [Select]
           let Player = GetPlayerObjectID;
   let AngleToPlayer = GetAngleToPlayer(Player);
   CreateStraightLaserA1(60,110,AngleToPlayer,500,25,5,25,30);

So I tried making a laser on my own. It works almost well, but the aiming is totally off. It looks like it's firing at random directions (for example behind the boss).
What did I do wrong ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 25, 2016, 03:27:22 AM
Well, you are asking what angle the player is to the player. (After testing, still not sure why it ends up pretty random when moving diagonally, but yeah.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on October 25, 2016, 12:04:14 PM
I thought it would just aim at the player...
How do i do it then ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 25, 2016, 01:04:11 PM
The argument should be the object from which to get the angle to the player. It already knows about the player, it doesn't know about the other point. So GetAngleToPlayer(objEnemy) or whatever else you're trying to aim from.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gengetsu on October 26, 2016, 08:45:31 AM
Hi everyone.
I was experimenting with the default effect shown in DMF(ph3)'s SamplePS03.txt.
I'd like to apply it behind the boss (and magic circle) but before the background (i.e. background is distorted)

My background has 3 layers:
top layer:
Code: [Select]
Obj_SetRenderPriorityI(obj,21);
ObjPrim_SetTexture(obj,sbg1);
ObjRender_SetBlendType(obj,BLEND_SUBTRACT);
middle&bottom layer:
Code: [Select]
Obj_SetRenderPriorityI(obj,20);
ObjPrim_SetTexture(obj,sbg2);
ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);

TWaveCircle()
Code: [Select]
task TWaveCircle(){
let renderTexture = GetReservedRenderTargetName(0);

let frame = 0;
let baseEffectRadius = 128;
let outerFluct = 16;
let effectRadius = 0;
let cirspd = 5;


let priEffectMin = 20;
let priEffectMax = 20;

SetInvalidRenderPriorityA1(priEffectMin, priEffectMax);

let frameWidth = GetStgFrameWidth();
let frameHeight = GetStgFrameHeight();
let frameLeft = GetStgFrameLeft();
let frameRight = frameLeft + frameWidth;
let frameTop = GetStgFrameTop();
let frameBottom = frameTop + frameHeight;

let objWave = ObjPrim_Create(OBJ_SPRITE_2D);
Obj_SetRenderPriorityI(objWave, 23);
ObjPrim_SetTexture(objWave, renderTexture);
ObjSprite2D_SetSourceRect(objWave, frameLeft, frameTop, frameRight, frameBottom);
ObjSprite2D_SetDestRect(objWave, 0, 0, frameWidth, frameHeight);
Obj_SetRenderPriorityI(objWave, priEffectMax + 1);
let pathShader = GetCurrentScriptDirectory ~ "SamplePS03_HLSL.txt";
ObjShader_SetShaderF(objWave, pathShader);
ObjShader_SetTechnique(objWave, "TecWave");

let objEnemy = GetEnemyBossObjectID[0];
while(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) > 0){
effectRadius = baseEffectRadius + outerFluct * sin(frame*cirspd);

let enemyX = ObjMove_GetX(objEnemy);
let enemyY = ObjMove_GetY(objEnemy);

RenderToTextureA1(renderTexture, priEffectMin, priEffectMax, true);

ObjShader_SetFloat(objWave, "frame_", frame);
ObjShader_SetFloat(objWave, "enemyX_", enemyX + frameLeft);
ObjShader_SetFloat(objWave, "enemyY_", enemyY + frameTop);
ObjShader_SetFloat(objWave, "waveRadius_", effectRadius);

frame++;
yield;
}
Obj_Delete(objWave);
ClearInvalidRenderPriority();
}

With this the effect can affect the bottom 2 layers only (because priEffectMax is 20 I guess). screenshot1,2
However when I change RenderPriorityI of top layer to 20, the whole background turns black. screenshot3
Yet when the Render Mode of top layer is changed to BLEND_ALPHA or BLEND_ADD_ARGB, the background works again. screenshot4,5

Images (changed to links for better safety at work):
sbg1 (http://imageshack.com/a/img923/9152/GuPUEI.png)
sbg2 (http://imageshack.com/a/img924/7509/DW4qXm.png)
Screenshot1 (http://imageshack.com/a/img921/748/ekJVJq.png)
ScreenShot 2 (http://imageshack.com/a/img921/6418/YtP23h.png)
ScreenShot 3 (http://imageshack.com/a/img922/9984/MbrBlz.png)
ScreenShot 4 (http://imageshack.com/a/img922/4314/Bymfco.png)
ScreenShot 5 (http://imageshack.com/a/img923/5776/KK5IjD.png)

My question is: I wonder if there's any method to use the TWave effect while using subtraction rendering?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on October 26, 2016, 04:27:57 PM
Becareful with the Twave effect. I'm not sure if I don't use it badly or not but it can cause heavy FPS drops.

Anyway, i see that your circle have a nive rotation effect like in Touhou. How did you do this? I know I should use X, Y and Z angle but I can't find the exact formula to do this without having something awful.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gengetsu on October 27, 2016, 03:24:29 AM
Becareful with the Twave effect. I'm not sure if I don't use it badly or not but it can cause heavy FPS drops.

Anyway, i see that your circle have a nive rotation effect like in Touhou. How did you do this? I know I should use X, Y and Z angle but I can't find the exact formula to do this without having something awful.

While it's possible (difficulty: post-phantasm  :D) to derive from sin & cos, I just adopted other's function (credits to TalosMistake):

Code: [Select]
task magiccircle(boss,type){ // draw magic circle
let obj=ObjPrim_Create(OBJ_SPRITE_2D);
let img=GetCurrentScriptDirectory()~"./MG.png";
let spin = GetCommonData("CircleSpin",0);
let s = 0;
let size = 0;
let GetBossX;
let GetBossY;
LoadTexture(img);
ObjPrim_SetTexture(obj,img);
ObjSprite2D_SetSourceRect(obj,0,0,256,256);
ObjSprite2D_SetDestCenter(obj);
ObjRender_SetScaleXYZ(obj,size,size,size);
ObjRender_SetAlpha(obj,192);
ObjRender_SetBlendType(obj,BLEND_ALPHA);
Obj_SetRenderPriorityI(obj,24);
while(!Obj_IsDeleted(boss) && !Obj_IsDeleted(obj)){
spin += 1/3;
size = GetCommonData("CircleSize",1);
ObjRender_SetAngleXYZ(obj,30*sin(spin*1.5)*type,25*cos(spin*1.5-30*sin(spin*3))*type,spin*3*type);
ObjRender_SetPosition(obj, ObjMove_GetX(boss), ObjMove_GetY(boss), 0);
ObjRender_SetScaleXYZ(obj, size, size, 0);
yield;
}
SetCommonData("CircleSpin", spin);
Obj_Delete(obj);
}

Example: magiccircle(objBoss,-1);
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 27, 2016, 08:35:18 AM
Congratulations Gengetsu, you seem to have found a bug.

It doesn't have to do strictly with the shader technique at all. Rather it looks to be a problem with the render target being used to draw onto before the shader is applied. After some testing, it seems like when blend types interact while being drawn onto a render target, their alpha values are erroneously affected somehow. If you subtract a white texture from another image, the result is transparent, but as you'll see below even subtracting the black parts gives transparent results, presumably because the alpha values are also being subtracted. Multiply-blend and invert-blend are also affected; if you invert with a 50% transparent white texture, the image is somewhat inverted but also somewhat transparent, while if it's the full white texture the image is fully transparent. Curiously, if you save the rendered textures to file, they look fine.

Subtract-blend render texture saved to file:
(http://i.imgur.com/n2wQEgi.png)

Subtract-blend results (http://i.imgur.com/TNvPLfn.png)
Subtract-blend results, 50% alpha texture (http://i.imgur.com/bRsxOXk.png)
Multiply-blend results (http://i.imgur.com/YjIW31e.png)
Invert-blend results, 50% alpha texture (http://i.imgur.com/2ZpA9lw.png)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 27, 2016, 09:13:04 AM
Now, despite this, you can circumvent this for the most part, although it's a really shitty workaround that I hate myself for having to do. Because the actual problem is the render targets, if you need to use a fancy blend type for some texture, you can apply the shader directly to that object individually, rather than rendering your whole background to one texture and using the shader on that (which is what you should be doing). This ignores the whole purpose of using the render targets, since you never really want to apply the shader multiple times because that's stupid, but it works.

So for objects with problematic blend types you can use this to apply it per-object, but if at all possible you should be doing the usual way of rendering to a render target and using that instead.

Code: [Select]
task ObjShader_TWaveCircle(obj){
let frame = 0;
let baseEffectRadius = 128;
let outerFluct = 16;
let effectRadius = 0;
let frameLeft = GetStgFrameLeft();
let frameTop = GetStgFrameTop();

ObjShader_SetShaderF(obj, GetCurrentScriptDirectory() ~ "SamplePS03_HLSL.txt");
ObjShader_SetTechnique(obj, "TecWave");

let objEnemy = GetEnemyBossObjectID[0];
while(!Obj_IsDeleted(objEnemy)){
effectRadius = baseEffectRadius + outerFluct * sin(frame*4);

ObjShader_SetFloat(obj, "frame_", frame);
ObjShader_SetFloat(obj, "enemyX_", ObjMove_GetX(objEnemy) + frameLeft);
ObjShader_SetFloat(obj, "enemyY_", ObjMove_GetY(objEnemy) + frameTop);
ObjShader_SetFloat(obj, "waveRadius_", effectRadius);

frame++;
yield;
}
}

Result: http://i.imgur.com/SuUqAx5.png
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Whatever on October 29, 2016, 04:51:41 AM
My question is: I wonder if there's any method to use the TWave effect while using subtraction rendering?

As far as my knowledge on hlsl with danmakufu goes, my way of making it work is:
1. Go into the _HLSL file.
2. Find this line:
Code: [Select]
        Out.color = color;

return Out;
3. Add "color.a = 1;" just before "Out.color = color;"
4. Done
So far, everything renders the same as when the shader is not present, but maybe I haven't found another bug yet.
Sagume's spell background is also BLEND_SUBTRACT and so far, everything looks fine.
http://imgur.com/a/pj6NU
Without the shader:
http://imgur.com/a/3pLFn
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 29, 2016, 06:16:37 AM
Neat. I hadn't considered using the shader itself to circumvent the problem with the render target. I'm not too sure why that fixes it either, since the texture should already be flattened before the shader step, but it doesn't really matter. I think there's some very slight difference in brightness (likely due to the opacities) with what I was doing but this is clearly better in all ways.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Whatever on October 29, 2016, 07:59:32 AM
And, is there a way in which I can put custom icons to th_dnh.exe?
(Like BoSM, FFF, PoIB)

Edit: I got it to work using some third-party software.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on November 01, 2016, 07:37:27 PM
Hi. It's me again. I wondered, what kind of scripting mistake can lead to a broken replay? I know some mistakes on ComonData can do it but is there other things? Accelerating Danmakufu with Ctrl during replay can do it too or absolutly not? I try to chase the reason of all my replays issues but I'm a bit lost now...

Gengetsu> Thanks for that.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on November 01, 2016, 07:46:44 PM
Hi. It's me again. I wondered, what kind of scripting mistake can lead to a broken replay? I know some mistakes on ComonData can do it but is there other things? Accelerating Danmakufu with Ctrl during replay can do it too or absolutly not? I try to chase the reason of all my replays issues but I'm a bit lost now..

There are a number of things that can desync replay. Sometimes a new version of DNH will break old replays, for example.

The biggest reply breakers are the following:
-Virtual Keys
-Common Data & Replay Comments

Virtual Keys
If at any time during the game your player touches a key and the game registers an action because of it (e.g. press I for invincibility, etc), an effect will occur in-game. However, replays only save the state of Virtual Keys, so those superficial changes will not be saved in the replay unless the keys in question (e.g. I) are mapped to Virtual Keys.

CommonData and Replay Comments
CommonData is the more common and more aggravating issue. Oftentimes, you will set CommonData that sets things during gameplay. For example, graphics settings, difficulty, etc. It is of the utmost importance that these settings persist as part of the replay and as such, you must use replay comments to save the CommonData involved. Note that only CommonData that result in different calls to the RNG have major impacts on the replay - things such as CommonData for music sound volume and the like do not matter in this case.

Upon loading the replay, you must parse the replay comment and set the CommonData appropriately. If you use config settings for graphics, you may also have to ensure that the user's preferred settings are restored after playing the replay.

There are other issues that can result in a desynced replay as well, but I can't name any specific ones off of the top of my head.

I hope this helps.

NOTE: Using CTRL to fast forward has absolutely no impact on the replay.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on November 01, 2016, 08:41:07 PM
In fact, at the begining of the script I clear all the common data to avoid any remaning common data. I think i should be enough and the script must create all common data as he should during the replay. The only common data that are saved and not cleared are the common data area where I store all the data like max score, spellcard history, ect per player and per difficulty. But these data must be updated even during the replay.
I'm not sure what kind of common data can desync the replay. I see for things like difficulty or player but how I'm supposed to do with common data that are alwas updated like spellcard score value, items value or position of a random moving boss?

I also don't know why the replay desync randomly, sometimes very quicklyand sometimes at a few seconds before the end of the script. If a specific common data is involved, replays should be desync arroud the same moment no?

Anyway, thanks for your answer.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on November 01, 2016, 09:11:19 PM
In fact, at the begining of the script I clear all the common data to avoid any remaning common data. I think i should be enough and the script must create all common data as he should during the replay. The only common data that are saved and not cleared are the common data area where I store all the data like max score, spellcard history, ect per player and per difficulty. But these data must be updated even during the replay.
I'm not sure what kind of common data can desync the replay. I see for things like difficulty or player but how I'm supposed to do with common data that are alwas updated like spellcard score value, items value or position of a random moving boss?

If CommonData are only used within the script (i.e. boss positioning), that does NOT need to be saved. Only CommonData that can differ on each run of the script (Difficulty, effect settings) need to be saved to Replay Comments.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on November 02, 2016, 08:30:44 PM
I don't use any package scripts on these scripts so all the common data are set directly in the script (even difficulty) and are, I suppose, registered in the replay. I don't see why these common data can alter the replay. Or maybe it's due to some remanings common data that change graphical effects even if there are never set or changed in the script?
I follow my common data in the log window and the only one that change endlessly is the one used to pass the angle of the boss circle from a spell to the other.

I think it's due to some flaws in the code but what ind of flaws if it's not due to CommonData? Any one have also issue with replay on their scripts?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on November 02, 2016, 09:01:57 PM
It doesn't have to do with the flaws of the code, but flaws of coding. Aka human error.

InitializeStageScene and FinalizeStageScene are start and end points for a Replay. Thus they are stage functions for stage scripts. Recording from outside the stage is asking for trouble.

Any commondata that is being processed from the very point you called InitializeStageScene should avoid RNG. I have plenty of commondata in my game too, running as background scripts (system) and such. As long as they don't RNG and have tight controll on what values are being set / read, then you're fine. You said you're doing this (like resetting and such) so I doubt there are issues here.

Again, RNG and bad design of commondata breaks/desyncs replays. CommonData can be perfectly updated.


In the end, you're going to do a lot of testing.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gengetsu on November 03, 2016, 04:43:38 AM
Now, despite this, you can circumvent this for the most part, although it's a really shitty workaround that I hate myself for having to do. Because the actual problem is the render targets, if you need to use a fancy blend type for some texture, you can apply the shader directly to that object individually, rather than rendering your whole background to one texture and using the shader on that (which is what you should be doing). This ignores the whole purpose of using the render targets, since you never really want to apply the shader multiple times because that's stupid, but it works.

So for objects with problematic blend types you can use this to apply it per-object, but if at all possible you should be doing the usual way of rendering to a render target and using that instead.

Code: [Select]
task ObjShader_TWaveCircle(obj){
let frame = 0;
let baseEffectRadius = 128;
let outerFluct = 16;
let effectRadius = 0;
let frameLeft = GetStgFrameLeft();
let frameTop = GetStgFrameTop();

ObjShader_SetShaderF(obj, GetCurrentScriptDirectory() ~ "SamplePS03_HLSL.txt");
ObjShader_SetTechnique(obj, "TecWave");

let objEnemy = GetEnemyBossObjectID[0];
while(!Obj_IsDeleted(objEnemy)){
effectRadius = baseEffectRadius + outerFluct * sin(frame*4);

ObjShader_SetFloat(obj, "frame_", frame);
ObjShader_SetFloat(obj, "enemyX_", ObjMove_GetX(objEnemy) + frameLeft);
ObjShader_SetFloat(obj, "enemyY_", ObjMove_GetY(objEnemy) + frameTop);
ObjShader_SetFloat(obj, "waveRadius_", effectRadius);

frame++;
yield;
}
}

Result: http://i.imgur.com/SuUqAx5.png
As far as my knowledge on hlsl with danmakufu goes, my way of making it work is:
1. Go into the _HLSL file.
2. Find this line:
Code: [Select]
        Out.color = color;

return Out;
3. Add "color.a = 1;" just before "Out.color = color;"
4. Done
So far, everything renders the same as when the shader is not present, but maybe I haven't found another bug yet.
Sagume's spell background is also BLEND_SUBTRACT and so far, everything looks fine.
http://imgur.com/a/pj6NU
Without the shader:
http://imgur.com/a/3pLFn
It worked like miracle!
Thank you both!!  :D
(sorry for my late reply lol)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: namohysip on November 07, 2016, 01:31:43 AM
So I don't have a question or problem about code not working, but the entire Danmakufu engine itself not working. And no, it's not because I'm not using applocale--it RUNS and all that... in fact, it runs very well overall, except for one critical issue: 0.12m constantly hovers at around 58 fps or so, even in the main startup menu. Even odder, it runs at ~500-700 fps when on the pause menu, or where you can select "play" or a replay.

Windows 10, so that's probably a red flag. I have the 'region' setting to Japanese, which is why it lets me play these no problem.  ph3 has zero issues that I know about, and it properly hovers at 60 fps. I haven't seen it struggle at all, no matter what happens on the screen. My computer is very powerful, so that's why I think it's so odd for it to hover specifically at 58 fps. According to the task manager, it's taking up 1% of its processing power, too. I even manually tried to put it under Nvidia's settings, and that had no effect. Am I just stuck with 58 fps if using Windows 10? I know it sounds like a small issue, but when you play with stages that sync up with the music, going a tiny bit slower really messes with the rhythm and fun of it...

tl;dr version: Windows 10, set to Japanese region, runs successfully. ph3 is a solid 60 fps, but 0.12m consistently hovers around 58 in the start menu and during gameplay, and 500-700 when paused. What's up?

EDIT: I figured out what was up with the pause button having massive framerates. Seemed to have something to do with the config option with four bullets, two in Japanese, and one that says 1/2 and one that says 1/3. It was on the rightmost option. I wish I knew Japanese, but by inference, I'd say this is talking about frame skips, since it looked very choppy when I set it to 1/3. Maybe the rightmost was realtime or something? But that aside, all options had no effect on the main problem of hovering at 58 fps.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on November 07, 2016, 08:59:59 AM
The config.exe was translated somewhere on this forum section, if I can find it I will update this post.

Though it is completely true what you're mentioning. And it isn't just Win10. With Win7 I also never had solid 60 fps.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: namohysip on November 07, 2016, 09:41:08 AM
So does that mean I'll never be able to properly play those scripts where the music is in sync with the danmaku...? Aw man...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ZoomyTsugumi on November 07, 2016, 10:19:16 AM
I had a lot of issues with my 0.12m framerates except I was getting massive frames on the start menu too.

I tried this  (http://enbdev.com/download_convertor_dx8todx9.htm)and it's worked fine for me, maybe it will be of use to you too?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on November 07, 2016, 08:47:28 PM
Hey, been a while since I worked on my script.
So far I've completed a first spell, so i'm starting to think about my plural script.
I know audio goes in there, but can I put graphics such as the boss's spritesheet/animation stuff and backgrounds in there too ?

Also, is there any website or whatever that teaches how to fire basic shapes and explains the code for it ? I know how to fire a spiral and a circle but i don't know about other shapes such as lines. I could find out myself about it but it would take some time so if you guys know any place that might save me time i'll gladly take the link.

(Also, thanks a lot, you're all awesome)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on November 07, 2016, 10:33:14 PM
Also, is there any website or whatever that teaches how to fire basic shapes and explains the code for it ? I know how to fire a spiral and a circle but i don't know about other shapes such as lines. I could find out myself about it but it would take some time so if you guys know any place that might save me time i'll gladly take the link.

Depends what you mean by shapes. If you want to fire a line of bullets from the boss, then just set the angle and fire at a constant rate. If you want to place a line of bullets somewhere on the screen, then use the formula y = mx + b to plot your line with an ascent loop. Alternatively, if you know the starting point and end point, you can ascent evenly from the start to end point, spawning your shots.

As for other shapes, I'm afraid there's no unified way to handle it (some of the other scripters here may be able to provide code samples for specific shapes or general shapes). There are many scripts that use shapes but you'll have to be more specific overall for an example. Things such as whether or not the shape maintains its shape after firing, etc. can add additional complexity to the code.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JoJo on November 08, 2016, 05:49:44 PM
Well i meant really in general,  but thanks a lot for the formula.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: namohysip on November 08, 2016, 10:15:51 PM
I had a lot of issues with my 0.12m framerates except I was getting massive frames on the start menu too.

I tried this  (http://enbdev.com/download_convertor_dx8todx9.htm)and it's worked fine for me, maybe it will be of use to you too?

That didn't work for me, but I figured out what did! First off, I needed two things:
 UPX unpacker tool  (https://github.com/upx/upx/releases/tag/v3.91) - I downloaded the wind32 one, since even though I have a 64 bit machine, there doesn't appear to be one, and generally 64 is backwards-compatible with 32... usually. Moving on.
 The vpatch zip found on this post.  (https://www.shrinemaiden.org/forum/index.php?topic=1848.msg70073#msg70073) It contains three important files: the vpatch exe, the config file of the same name and different extension, and vpatch_th_dnh.dll.

1. Get the two file sets above, as well as th_dnh.exe (if you renamed it for some reason, name it back to this.)
2. Go into the upx folder; you should see a bunch of files along the lines of "BUGS" "CUPYING" "LICENSE" "upx" as a word document, and "upx" as an exe. Move th_dnh.exe into this folder.
3. create in notepad a new file and name it something.bat
make sure the extension is .bat, and have it in the same place as upx and th_dnh. in this file, write just this line:
upx -d th_dnh.exe
This basically does a command line call to upx to "unpack" danmakufu.
4. Double click on this .bat file. You should see th_dnh change from its original filesize to 1444 KB in size. Not sure if the exact size changes from system to system, but that's what it did for me.
5. Move th_dnh back to its original area, with the 'script' folder and all that.
6. Now go into the vsync patch folder. move three files from there into the same area as th_dnh.exe. Move in vpatch, both the exe and ini files (configuration settings), as well as vpatch_th_dnh.dll.
7. double-click on vpatch.exe. If all goes well, it should launch danmakufu at 60 fps! Now all you need to do is always click vpatch instead of th_dnh itself, and it'll run. I just pinned vpatch to my task bar instead of danmakufu itself, and it's just as convenient.

Now I can play "Touhou music barrage" or whatever those four scripts are called, right in sync! So satisfying.

Oddly enough, Phantasmagoria Trues lagged like crazy after a while of playing. When I restarted the program, it lagged right from the start. As in, 30 fps, but only taking up 3% CPU. But when I restarted my computer, it was just fine, and remained so. So that's... weird... but it works, I guess? I'll edit this post if it happens again and/or I figure out the source or fix to the problem.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on November 10, 2016, 11:16:15 PM
Is there a way to optimize this trail effect, so that it doesn't completely lag the game whenever there's a large amount of bullets on the screen?

Code: [Select]
task EffectTrail1(shot, graphic, frame, blend){
while(!Obj_IsDeleted(shot)){
CreateEffTrail1(shot, graphic, blend);
wait(frame);
}
}

task CreateEffTrail1(shot, graphic, blend){
let rect = GetShotDataInfoA1(graphic, TARGET_ENEMY, INFO_RECT);
let eff = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(eff, "./resource/shot/Shot/ZUNShot.png");
ObjSprite2D_SetSourceRect(eff, rect[0], rect[1], rect[2], rect[3]);
ObjSprite2D_SetDestCenter(eff);
ObjRender_SetPosition(eff, ObjMove_GetX(shot), ObjMove_GetY(shot), 0);
ObjRender_SetAngleZ(eff, ObjMove_GetAngle(shot)+90);
ObjRender_SetBlendType(eff, blend);

let alpha = 100;
while(!Obj_IsDeleted(shot)){
ObjRender_SetAlpha(eff, alpha);
ObjRender_SetAngleZ(eff, ObjMove_GetAngle(shot)+90);
alpha-=5;
if(alpha <= 0){
Obj_Delete(eff);
}
yield;
}
Obj_Delete(eff);
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on November 11, 2016, 01:44:18 AM
Is there a way to optimize this trail effect, so that it doesn't completely lag the game whenever there's a large amount of bullets on the screen?

You are creating an effect every `frame` frames. And those delete after 20 frames.

Therefore, what it comes down to is how often you are spawning the graphics. You're going to have to sacrifice prettiness for performance, and I assume `frame` is reasonable (i.e. not below 6 or so).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on November 11, 2016, 08:51:54 AM
Actually, now that I think about it, it's reasonable. If 200 bullets are present on the screen, and "frame" is set to 6, that's already 1200 graphics the game has to render.

I knew the game would lag if I applied the trail effect to a large amount of bullets, but not to this extent. I thought that maybe there was an other way to optimize the effect besides simply increasing "frame", but there doesn't seem to be any...

I'm just going to blame it on Danmakufu and move on :V
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on November 11, 2016, 01:18:02 PM
Actually, now that I think about it, it's reasonable. If 200 bullets are present on the screen, and "frame" is set to 6, that's already 1200 graphics the game has to render.

Also, each trail lasts for 20 frames, so it's possible to have even MORE on the screen.

Anyways, one possible solution is to use a Sprite List to render the trail effects. This, however, can be exceptionally clunky and requires that you maintain the state of each trail effect.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on November 13, 2016, 07:20:53 PM
Hi! I'm still on my broken replay issues and I still have absolulty no idea why. I check all my common data, I comment all common data implied in player, practice or difficulty select and replays still break ramdomly. Sometime it's fine, sometime not, sometime on the very end of the script, sometime in the middle or the begining... I'm lost with that  :(

So, I wonder if things like:
Code: [Select]
task Task1() {
    loop{
        do_stuff;
        yield;
    }
}
running aside tasks like:

Code: [Select]
task Task1() {
    loop{
        yield;
        do_stuff;
    }
}

can lead to broken replays. The second thing is some leftovers from the time where I didn't really know how to use yield;. I'm not sure about that but I know it cancause strange things in certain conditions. And I'm enough depressed with that problem right now.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 14, 2016, 03:22:50 AM
That shouldn't affect replays. The main difference is that with the first you have the loop body execute once on the frame it starts, whereas with the second nothing will happen on the frame it starts; when the loop ends the reverse happens, where the code will execute on the frame the loops ends (because it continues from the yield point, runs the code, hits the bottom and loops back up, where the condition fails and the loop exits). This usually shouldn't create particularly weird behaviour, but it will give weird behaviour if for example it's a while(!Obj_IsDeleted) loop where the code inside depends on the object existing, since it'll still execute the code on the frame the object is deleted despite the loop condition not being true anymore.

If you're really stuck and have no ideas on what to even look for, you should probably just pack up your project for people to take a look at. Nobody can really help you if they have no information on what you're doing, and pasting random scripts one at a time isn't going to help much either.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 14, 2016, 07:11:46 AM
Also here's one clumsy solution for the bullet trail effect.

https://gist.github.com/drakeirving/885fe82e4da206e8b4f87ba2b6cd36c7

(http://i.imgur.com/8oXBEL3.png)

What this does is create a render target for each "frame" of the effect, and an object associated with that texture. Every step, one render target reproduces the current bullets on screen, and each of the textures gradually fade out. When they reach the end of the cycle they instead take the place as the "lead".

Unfortunately due to how render targets work, you can't only use one render target, as when a render target texture is assigned to an object, if the render target is updated the object reflects that. Any objects using it as a texture just look at that chunk of memory to see what to draw, which makes sense. Also unfortunately, as many people know, you cannot use non-integer drawing layers without huge bugs. Because of this, you can either have every texture on the same layer, which causes some visual hiccups due to the draw ordering, or you can try putting each texture on descending layers (see the commented-out bit), which is visually better but can interfere with the rest of the game if the effect spans too many layers. That being said, this is definitely viable in terms of efficiency, I think.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: TheTeff007 on November 14, 2016, 10:08:26 AM
http://pastebin.com/eX6yefEe

Been following Helepolis Player tutorial for ph3 to the letter, and while Marisa does appear in the game screen, attempting to move her does not seem to work, as she stays in the initial location and the sprite does not move at all. No error appears, so no idea what could be causing this.

Please advice, Thanks in advance.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: FlareDragon on November 14, 2016, 11:33:40 AM
From what I know, there's no need to use "ObjRender_SetPosition" for the player texture. Simply using "ObjSprite2D_SetDestCenter(playerObj)" means the sprite is centred onto the player object and should move with it, so "ObjRender_SetPosition(playerObj, GetPlayerX, GetPlayerY, 0);" is completely unnecessary (and might be interfering).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 14, 2016, 12:32:46 PM
Well, this should error, as renderHitBox doesn't seem to be defined, and loading the shot data would also error unless you've already finished writing that. Both of these are later in the tutorial than you're at, so this shouldn't work. If I copypaste what you've given, commenting out `LoadPlayerShotData` and the `renderHitbox` call, it works fine.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lefkada on November 14, 2016, 04:44:38 PM
Drake. Okay thanks.
So, here is one of my project where I have broken replays:
https://www.mediafire.com/?91qu4xemmtz7wxn (https://www.mediafire.com/?91qu4xemmtz7wxn)
or another one with slightly different code (actually it's just an older version of the code, before all tries to fix that):
http://www.bulletforge.org/u/lefkada/p/lunatic-magical-girl-flanscript (http://www.bulletforge.org/u/lefkada/p/lunatic-magical-girl-flanscript)
Anyway, all my scripts have this issue...

Thanks to thoses who will look at this mess.


Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on November 14, 2016, 06:09:55 PM
What this does is create a render target for each "frame" of the effect, and an object associated with that texture. Every step, one render target reproduces the current bullets on screen, and each of the textures gradually fade out. When they reach the end of the cycle they instead take the place as the "lead".

Unfortunately due to how render targets work, you can't only use one render target, as when a render target texture is assigned to an object, if the render target is updated the object reflects that. Any objects using it as a texture just look at that chunk of memory to see what to draw, which makes sense. Also unfortunately, as many people know, you cannot use non-integer drawing layers without huge bugs. Because of this, you can either have every texture on the same layer, which causes some visual hiccups due to the draw ordering, or you can try putting each texture on descending layers (see the commented-out bit), which is visually better but can interfere with the rest of the game if the effect spans too many layers. That being said, this is definitely viable in terms of efficiency, I think.

Hmm... This is seriously very efficient, but I honestly think the amount of things you need to correct before using this trail effect is really not worth the payoff for me. It did shed me some new light on how render targets work, and I greatly appreciate that! This actually left me very confused at first, but now I sort of understand it.

...Anyways, I think I'm simply going to stick with my own, old effect, since it's so simple.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: TheTeff007 on November 14, 2016, 07:03:57 PM
Seems like FlareDragon was right, and the renderHitBox was in the script, just did not copied it into the pastebin for whatever reason.

Thanks for the help!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on November 14, 2016, 07:23:12 PM
Also here's one clumsy solution for the bullet trail effect.
I'm really intrigued by this effect. Do you think that this would be effective at creating a motion blur effect? I'm thinking of 0.12m's SetEffectForZeroLife function that had a motion blur effect as one of the things it could do.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 15, 2016, 02:44:22 AM
It depends how deep you want the motion blur to go, probably. This works because it copies only layer 50 (i.e. bullets) and draws immediately underneath it, so it aims to still draw over everything that would be drawn below bullets. If you wanted to have the effect covering many layers you'd have to draw the effect under all those layers and make sure it doesn't bork.

It also isn't really motion blur at all because a real motion blur is an interpolated effect, not just the texture at several positions. If an object moves four pixels in one frame you'd still have to fill that gap somehow. It might still look fine though.

Honestly the real solution here is probably shaders. I used render targets because I figured it might work and I wanted to see how it could be done.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on November 15, 2016, 05:48:47 AM
It depends how deep you want the motion blur to go, probably. This works because it copies only layer 50 (i.e. bullets) and draws immediately underneath it, so it aims to still draw over everything that would be drawn below bullets. If you wanted to have the effect covering many layers you'd have to draw the effect under all those layers and make sure it doesn't bork.

It also isn't really motion blur at all because a real motion blur is an interpolated effect, not just the texture at several positions. If an object moves four pixels in one frame you'd still have to fill that gap somehow. It might still look fine though.

Honestly the real solution here is probably shaders. I used render targets because I figured it might work and I wanted to see how it could be done.
Ah yes, shaders, the one thing I may never really get how to use well. Yeah, it would be cheap, fake motion blur in this way. It just an idea that I had. What I'd give for a basic shaders tutorial for Danmakufu.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 15, 2016, 11:49:57 AM
Okay so I turned it into a full motion blur. It does look pretty cool and is definitely usable as long as you follow the layer constraints. In this case there shouldn't be anything from layers (79-n) to 79.

https://gist.github.com/drakeirving/2677c2eefe353266bed0425fed8ef3c5

(http://i.imgur.com/6NDFDgh.png)

pls test
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on November 15, 2016, 08:45:29 PM
Okay so I turned it into a full motion blur. It does look pretty cool and is definitely usable as long as you follow the layer constraints. In this case there shouldn't be anything from layers (79-n) to 79.
pls test
I will indeed. I'll try to make a SetEffectForZeroLife like function and try it out in my game, EUB, if I have your permission to include it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 16, 2016, 02:58:33 AM
Yeah no problem.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: NatheArrun on November 23, 2016, 02:15:00 AM
Hello, I'm new to danmakufu ph3 and I need some help. I keep getting a variable error with the following code. Can you please teach me how to fix this error? Thanks.
http://pastebin.com/NSJe6Zj8
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 23, 2016, 06:34:15 AM
- There's no `function` keyword before the function declaration, which was maybe just a mistake when putting it on pastebin?
- DS_BEAM_RAINBOW isn't a default shot type, make sure it is a valid shot
- You're using square brackets as parentheses which won't work at all since it defines an array instead

It'd be great if you could explain what this code is even supposed to do, because I don't understand what most of the parameters do and I can't figure it out by looking at the math.
I'm also confused at how you got so much code written before getting to this point. Did you just try writing everything out at once? Because that's always a bad decision.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Junky on November 26, 2016, 07:57:08 PM
When running the huge plural script, it starts out fine, but then bullets start to go missing and other graphics (such as parts of the spell card background) don't show up at all. So how should I deal with this?

Is there any way to make this more efficient? I'm pretty new to dealing with large amounts of scripts.  :blush:

 http://pastebin.com/1p0zPBjH   (http://pastebin.com/1p0zPBjH)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on November 26, 2016, 10:43:40 PM

Please use Pastebin for your code.

Additionally, this task does not include enough information for us to determine what's going wrong. There's a lot of purging textures from memory, but nowhere in the code posted do you actually load anything.

If you have issues with bullets going missing and other graphics not showing up (the wording suggests that the bullet GRAPHICS disappear, but the bullets themselves are still collidable? Please clarify), please show us some of that code.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 26, 2016, 11:24:09 PM
A lot of the problems might disappear if you actually organize your bosses into individual plural scripts and use a stage to link them all together.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Junky on November 26, 2016, 11:36:04 PM
Please use Pastebin for your code.

Additionally, this task does not include enough information for us to determine what's going wrong. There's a lot of purging textures from memory, but nowhere in the code posted do you actually load anything.

If you have issues with bullets going missing and other graphics not showing up (the wording suggests that the bullet GRAPHICS disappear, but the bullets themselves are still collidable? Please clarify), please show us some of that code.

I can't access my computer at the moment, but I'll try my best to respond:
1: Now pastebinned.

2: I made a sepperate task that loads in all the textures off the cutin images, for example:

Code: [Select]
let dankCutin = 'insert file path here';

task LoadImages
{
    LoadTexture(dankCutin);
}

3: I'll put it this way, objects aren't appearing at all. For example, arround the 9th spellcard (Lumen's spell card), bullets aren't there at all, including the graphic and hitbox. As the plural script goes on, it becomes more noticable, such as the spellcard main backdrop doesn't appear in the firstplace. In terms of the single scripts, there's nothing wrong with them if ran 10 one after athother, and with the Purging textures, it removes all the cutin images after that section of the bossrush. My main theory is that I'm not removing things when each script progress or just making a large plural script in general causes some issues.

4: Sorry for not being specific.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Junky on November 26, 2016, 11:37:58 PM
A lot of the problems might disappear if you actually organize your bosses into individual plural scripts and use a stage to link them all together.

I didn't think of that. Thanks! I'll be sure to try that out. Please can you give me a short example though?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ombsik33 on November 27, 2016, 02:59:56 AM
I'm having a problem with (0,0) spawning after a player death. I've looked on Sparen's tutorials and saw his code and how to fix it, but his fixes (0,0) after boss death (at least that's what I understood. I'm still really new to this lol). The attack I'm using is below.

Code: [Select]
task fire{
let angleT = 0;
let dir = angleToPlayer;
GetPlayerState;
loop(10){
let objBullet = CreateShotA2(bossX,bossY,2,angleT,-0.05,0,40,10);
BulletCommands(objBullet);
angleT+=360/10
}

task BulletCommands(objBullet){

while(ObjMove_GetSpeed(objBullet) > 0) {yield;}
wait(60);
let angleT = rand(0,360);
loop(10){
CreateShotA1(ObjMove_GetX(objBullet),ObjMove_GetY(objBullet),2,angleT+(rand(-4,4,)*angleT),rand(33,39),10);
angleT += 360/10
}
Obj_Delete(objBullet);
}
}

Basically, it's an exploding bullet type attack. I let my character die to check if it's working and then the multicolored bullets from  "task BulletCommands(objBullet)"appear at (0,0). I'd really appreciate any feedback or tips!!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on November 27, 2016, 12:34:40 PM
Hello ombsik33, welcome.

Your problem lies within the bullets themselves. Nothing to do with the boss or player. Problem: You're spawning new bullets based on the position of the old bullet (example: the original before exploding).

Let us call the first bullets, before they explode, the master bullet. The child bullets are spawned based on the XY location of their master. When a player dies, it will clear out all the bullets on the screen (by default). If the master bullet is gone, there will be no XY coordinate available for the child bullet to know. And therefore, it will automatically spawn at 0,0.

With this info, you should be able to figure it out.


Edit: I can give you the answer, but I would rather not yet (unless you insist). This is a typical design error made by many people (even experts) and therefore in my opinion it is better to understand what is going on. A perfect lesson moment. Of course, you could just go ask someone else who might immediately spoil it for you.

Though I'll give you a tip: Verify whether the master bullet is still alive before spawning the child bullets. If not, don't spawn the childs.

Edit 2: If you're really unsure, at least show me your changes/attempt and I'll give you the solution.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on November 27, 2016, 02:53:43 PM
I'm having a problem with (0,0) spawning after a player death. I've looked on Sparen's tutorials and saw his code and how to fix it, but his fixes (0,0) after boss death (at least that's what I understood. I'm still really new to this lol).

I assume you are referring to Lesson 16 (https://sparen.github.io/ph3tutorials/ph3u2l16.html)? If so, I'll ensure that the examples are clearer.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ombsik33 on November 27, 2016, 04:16:35 PM
Quote from: Helepolis
Your problem lies within the bullets themselves. Nothing to do with the boss or player. Problem: You're spawning new bullets based on the position of the old bullet (example: the original before exploding).

Let us call the first bullets, before they explode, the master bullet. The child bullets are spawned based on the XY location of their master. When a player dies, it will clear out all the bullets on the screen (by default). If the master bullet is gone, there will be no XY coordinate available for the child bullet to know. And therefore, it will automatically spawn at 0,0.

Thank you so much for your help!! I think I figured it out. If you have another way, I'd love to see it as well.

task fire{
   let angleT = 0;
   let dir = angleToPlayer;
   GetPlayerState;
   loop(10){
      let objBullet = CreateShotA2(bossX,bossY,2,angleT,-0.05,0,40,10);
      BulletCommands(objBullet);
      angleT+=360/10
   }

   task BulletCommands(objBullet){
      while(ObjMove_GetSpeed(objBullet) > 0) {yield;}
      wait(60);
      let angleT = rand(0,360);
      loop(10){
         if(Obj_IsDeleted(objBullet)) {return;}
         CreateShotA1(ObjMove_GetX(objBullet),ObjMove_GetY(objBullet),2,angleT+(rand(-4,4,)*angleT),rand(33,39),10);
         angleT += 360/10
      }
      Obj_Delete(objBullet);
   }
}

Thank you so much for the hints. They really helped!! All I added in "task BulletCommands(objBullet)" was "if(Obj_IsDeleted(objBullet)) {return;}" and it seems to work perfectly. Again thank you so much!!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 28, 2016, 05:06:42 AM
I didn't think of that. Thanks! I'll be sure to try that out. Please can you give me a short example though?
http://pastebin.com/Lnrvf44V

Here is a slight modification of the ExRumia stage (which itself only launches the one plural and ends) to run multiple plurals back to back. You should just be able to copypaste to a new script and have it work.
Split your one big plural into regular ones where you have only one boss scene per plural, and run those from a stage.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on November 28, 2016, 07:13:26 AM
Thank you so much for your help!! I think I figured it out. If you have another way, I'd love to see it as well.

Thank you so much for the hints. They really helped!! All I added in "task BulletCommands(objBullet)" was "if(Obj_IsDeleted(objBullet)) {return;}" and it seems to work perfectly. Again thank you so much!!
Ah, you figured it out with the easiest and most effective solution.

An alternative I also designed was enclosing the loop section in the while-statement. The difference is, if I am not mistaking, that in your case the loop is always executed but "returned" due to the check and in my alternative case, the loop is never executed if the master bullet is gone. Not that there is a huge performance difference for this. So you're fine. Well done.

Keep in mind that this problem goes for any object, not just bullets. For example: If you try to spawn familiars from a fairy which is gone, the familiars will also have no XY to spawn and thus default appear at 0,0. If you're curious about this: You can always debug the X Y values of the master using the text objects to draw them on screen.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: lolpudding on December 03, 2016, 11:00:12 PM
Hi! I have had some experience with Danmakufu and I am ready to move into stage scripts with stage enemies in it. However, I am experiencing strange issues where the stage enemies do not render correctly because they do not spawn with hit boxes and do not animate. When I put a wait function before spawning the enemies, they will not spawn at all. I am not sure if it is a rendering issue or if I am doing something wrong with the stage script itself.  :ohdear:

Here are the two scripts:
Fairy Rendering Script: http://pastebin.com/jjSp70eV
Stage Script: http://pastebin.com/uDJEC0Af
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Asthmagician on December 05, 2016, 06:10:01 AM
Shouldn't your rendering function be a rendering task instead?
Since it's a function, danmakufu waits until the function is complete to continue with the main section of code.
As a result, the script will wait until the render function is complete before moving on, and since the render function doesn't complete until the fairy is deleted, following enemies wouldn't spawn.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: lolpudding on December 06, 2016, 12:00:47 AM
Okay, so I turned the function into a task instead and there hasn't been a change. The fairies still act strange and I am still trying to find a solution for this, but thank you for the suggestion. It narrows down the issue more since I have been stuck on this issue for several months now. It could be possible that I just haven't found a correct way to summon them.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Asthmagician on December 06, 2016, 05:25:07 PM
Hi again.
I've done some further testing with your provided code and I have a question:
When you say the fairy doesn't animate, do you mean it gets stuck at the first frame? or do you mean it freezes at the end?
If the latter, that's because that fits with the code. Since animFrame2 is never set back to 0 like animFrame, it continues to be >45 forever
If the former, I'm afraid I can't help you, because I don't understand the issue.
I was also unable to reproduce your issue with hitboxes.

P.S As an unrelated note, I noticed that you use absolute pathing in your stage script
That is, your paths all start with "script/Stage Test/<path>"
This shouldn't break anything, but it's generally considered to bad.
This is because if, for example, you moved or renamed the Stage Test folder,
or released it onto the internet, every  "script/Stage Test/<path>" would have to be changed manually
You can easily fix this by making the paths relative
That is, replace  "script/Stage Test/" with GetCurrentScriptDirectory() ~ "<path>
As the name suggests, GetCurrentScriptDirectory() gets the folder containing the current script's path and returns it as a string.

Sorry I couldn't be more help.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on December 06, 2016, 05:53:56 PM
None of that matters. He misspelled main loop. Loop needs to be with a capital L >> @MainLoop

The best thing about Danmakufu is that it totally accepts Mainloop. However, because it is not THE actual MainLoop, it will create one for you implicitly (behind the scenes). Meaning that his MainLoop is never yielded.

This is also the reason why none of your tasks or functions or collision handling works. For the engine to look for other tasks/routines to perform, the MainLoop needs a yield.

Edit: You can add:
Code: [Select]
@DumbFakeShit {

}
To your code and Danmakufu won't even complain for one bit.

Always return back to basics when you're having issues. Don't start trying everything when you haven't checked the basics. Of course, this is also a matter of experience for effectively conducting trial & error. I'll explain:

I didn't instantly catch the error at first glance. I first simplified his code and merged it so it was one file. Then I ditched the entire render codeblock and spawned 1 fairy just on the screen with just the collision functions. Fairy was there, but my bullets went through and the homing amulets of my Reimu were going crazy. Neither she would go Pichuun when touching. The following question popped into my mind:
Q: Why isn't there collision? 
A: Collision functions are definitely spelled correctly (quadruple checked on wiki). The while loop is solid. Not the problem.

Q: Is there something wrong with the script?
A: Dunno. Is there? Well, let us find out. Let's write a new stage file from scratch in a different file with a @Initialize  @MainLoop @Finalize and paste the same exact code -> WTF, it works now?

Q: So what is going on with the structure or the old file?
A: Comparing time! Check @Initialize -> spelled correctly,   check Mainloop. . . Mainloop? Lower case L? Aha! Gotcha!

Mistakes were made, hopefully lessons were learned.


Edit2:
This shouldn't break anything, but it's generally considered to bad.
This is because if, for example, you moved or renamed the Stage Test folder,
or released it onto the internet, every  "script/Stage Test/<path>" would have to be changed manually
Actually, nothing is considered bad. Both relative and absolute pathing are fine to use. It is up to the programmer to deal with it correctly. While it is true that renaming would cause things to break, it has nothing to do with releasing to the internet as if you ship the entire structure. The downloader just has to unpack it inside the script directory. He/she shouldn't touch the folder structure or names, obviously.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: lolpudding on December 07, 2016, 02:55:20 AM
So the error was because I had to captialize the L  :o Thank you so much for solving this really simple error. I feel extremely stupid.

and @Asthmagician, I was planning to use relative pathing soon in the future after I finished creating the script. Thanks for being extremely helpful and requesting solutions.

update: So after having the stage enemy issue solved, I continued working on the stage script and letting them shoot bullets until I realized there's another issue where the script may sometimes crash the whole Danmakufu engine with no error. I have examined the script many times and realised that it could be that I am spawning too many enemies. Does Danmakufu automatically delete enemies after they have left the screen? I could provide the code again if anyone wishes. Sorry, I am not that experienced with stages however
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on December 08, 2016, 02:00:24 PM
Short answer: No, by default objects are NOT autodeleted when they leave the screen.

Longer answer: Do you have the console log window open while testing? The log window can be activated through the config.exe by ticking the box for it. It will show info about number of bullets, objects, tasks running etc.


Edit
Got a question of my own for implementing Continue System. I can vaguely remember I might have asked this before (unsure) though here I go (again perhaps):  How did you do it mechanical wise? (if you have a continue system)

The problem I am having is that STATE_END is kicked in for your player when you have zero lives left and go Pichuun. Meaning your player won't respawn, even if you added lives. So I am guessing the trick is to prevent the player from going into that state.

Handling STATE_DOWN at zero lives is not working as intended. Example:
Code: [Select]
if(GetPlayerState == STATE_DOWN && GetPlayerLife == 0 && GetCommonData("remainingContinue", 0) > 0) {
SetPlayerLife(3);
}
Because technically you're on your last life. Validating it at -1 is non existent, because STATE_END will kick in.

So what do I do? Add +1 life, adjust the HUD so if you're at 1 life, it shows 0 hearts?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on December 08, 2016, 11:14:03 PM
So what do I do? Add +1 life, adjust the HUD so if you're at 1 life, it shows 0 hearts?
Yes, actually. That is the only way I managed to make it work. In my experiments, once STATE_END was triggered there was no stopping it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on December 09, 2016, 06:32:20 AM
Yes, actually. That is the only way I managed to make it work. In my experiments, once STATE_END was triggered there was no stopping it.
Check. If that is the case, then we have no choice.

It also somewhat surprised me that the creators of Star Mythology aren't using a continue system at all.

Edit
Progress update: HUD shows no filled hearts. Now I just need to re-map the triggering of the menu and not use CloseStgScene. Thanks Porygon
[attach=1]


Edit2:
Almost there. Managed to now make STATE_END kick in when the player is on the last life. I added a check in my stage heart beat loop. When the player had no continues, plus was hit and about to enter his last life, it would quickly call SetPlayerLife(0); to sync the game. Therefore, the next hit will sure trigger STATE_END for the stage script and also trigger STAGE_RESULT_PLAYER_DOWN in the package script.

Now I need to make sure the Continue choice is not available at the final ending screen and also prevent replays from being saved once a continue is used.  (The original games also prevent this)

/me wipes sweat, blood and tears.

That was some ride for me after being away from my game quite a while.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: lolpudding on December 10, 2016, 12:37:42 AM
Short answer: No, by default objects are NOT autodeleted when they leave the screen.

Longer answer: Do you have the console log window open while testing? The log window can be activated through the config.exe by ticking the box for it. It will show info about number of bullets, objects, tasks running etc.

Ah, I dont use the log window, but it seems really useful. It turns out the stage constantly crashed because I spammed "if(ObjEnemy_GetInfo(obj, INFO_LIFE) <= 0){break;}" too many times and found a way to let the enemies delete themselves.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on December 10, 2016, 08:38:48 AM
Probably you've done similar, but the most common method is to delete an enemy once it crosses a certain boundary of your play field.

For example I use:
Code: [Select]
// leave field == delete
if(ObjMove_GetX(obj) < GetClipMinX-17 || ObjMove_GetX(obj) > GetClipMaxX+17 || ObjMove_GetY(obj) < GetClipMinY-17 || ObjMove_GetY(obj) > GetClipMaxY+17) {
Obj_Delete(obj);
}

GetClipMinX and such are self written functions which quickly get the minimum X coordinate for my play field.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on December 10, 2016, 10:05:14 AM
Semi-relevant reminder that if you have a package script and start a stage (, etc) from it, script IDs are reset and the ID of the original package script is dropped, so you can't target events to package scripts directly, nor to miscellaneous scripts started from the package before the stage begins. NotifyEventAll will still work.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: DichotomousCreator on December 29, 2016, 12:02:33 PM
Okay, so I'm having a problem that was reported in one of these threads before but never had an answer posted...however, the project that was having the problem appears to have progressed past it, so I figure it's worth asking if a solution was found at some point. (For reference, that report was here --- https://www.shrinemaiden.org/forum/index.php?topic=16584.540 --- by a user by the name of Eredom)

Basically I'm attempting to insert BGM into a script, but it skips ahead a few seconds the first time one of a few specific conditions are met. These are:
- Whenever a spell card is declared
-- Whether the default spell card sound effect was changed, but NOT if it was removed
- Whenever a "bad" sound effect is used
-- Does not happen if the place where the "bad" sound effect was used is changed to a "good" sound effect
-- Whether a sound effect is "bad" or not seems to be random (my shot sound effect is fine, but another one for shots moving around without being "fired" isn't)

It doesn't skip again after the first time. I've tried different BGMs and they also skip. I followed the instructions Helepolis gave when this came up before. Code is as follows:

For setting up the BGM (NOTE: Has been tried without passing loop arguments, and with the loop starting at 0) :

Code: [Select]
function SetUpBGM(bgmpath, loopStart, loopEnd) {
let obj = ObjSound_Create();
ObjSound_Load(obj, bgmpath);
ObjSound_SetSoundDivision(obj, SOUND_BGM);
ObjSound_SetLoopEnable(obj, true);
ObjSound_SetLoopTime(obj, loopStart, loopEnd);
return obj;
}

For running the BGM (placed in the @Initialize section of the Plural) :

Code: [Select]
let bgmpath = GetCurrentScriptDirectory() ~ "/sound/bgm.ogg";
let bgmObj = SetUpBGM(bgmpath, 13.6, 177.2);
ObjSound_Play(bgmObj);

For setting up a sound effect:

Code: [Select]
function SetUpSoundEffect(soundpath, volume) {
let obj = ObjSound_Create();
ObjSound_Load(obj, soundpath);
ObjSound_SetSoundDivision(obj, SOUND_SE);
if (volume > 0) {
ObjSound_SetVolumeRate(obj, volume);
}
return obj;
}

For playing a "bad" sound effect:

Code: [Select]
let moveStarSoundPath = "script/experimentation/Sanae/sound/bulletmove.wav";
let moveSoundObj = SetUpSoundEffect(moveStarSoundPath, 35);
ObjSound_Play(moveSoundObj);

For declaring a spell (nothing fancy) :

Code: [Select]
ObjEnemyBossScene_StartSpell(objScene);
If anyone knows how/if Eredom ultimately solved this problem, I'd greatly appreciate it.

(P.S. I am currently going through Sparen's tutorial set and will probably just move on from the sound section in the meantime, but having it almost-but-not-quite-working is kind of maddening)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on December 29, 2016, 04:33:47 PM
From reading the older posts you linked to, it seems that Eredom tried using a different BGM track (from White Name Spoiled Past) and it worked. That doesn't make much sense to me, but it's possible that it's a problem with the specific track being used. It wouldn't be the first time Danmakufu behaved strangely with specific audio files.

I use a very similar setup to what you do for BGM and sound effects and I've never run into such a skipping problem. Perhaps share with us the specific music track you're using and we can test if that somehow causes problems.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: DichotomousCreator on December 30, 2016, 01:59:01 AM
Sure thing...except, as far as I can see, there's no way to attach files to a forum post here? I'm not familiar with any sound or general file uploading services, either, though I probably should be :/. So how should I provide it?

As a side note, Eredom got back to me on Facebook and let me know that you need a .ogg file (check)...with a specific bitrate, preloaded before it needs to be used (not check >_>). So the issue is probably that all my attempts were MP3s converted using Audacity, which produces some kind of variable bitrate. That said, I'll tool around with the export quality setting (which affects the bitrate) and pre-loading all my sound effects and maybe using a .wav file for the BGM (even though this isn't practical for any sort of publicly released script) just to see what works.

EDIT: Well I'll be damned...an export quality of exactly 6 doesn't have any problems (5, 7, and 10 all did!). I guess that solves my issue, hopefully the same export quality works for any other MP3s I screw around with.

EDIT2: Ah, spoke to soon. It just reduces the skipping to the point where if you're at certain points in the BGM you don't notice it.

EDIT3: Okay, so more testing results...6 had minimal skipping, 5, 7, 8, and 10 all had a noticeable skip on the first spell card declare, 9 skips the first time you run the script but doesn't if you restart the script and run it again?? That's bizarre. Maybe I'll find some permutation of things that works.

EDIT4: More testing...6 and 9 skip less but still noticeably, but restarting the script using Danmakufu's default restart function in the menu completely stops the skipping on ANY quality level. (also I might have been imagining the skipping differences for the quality levels >_>)

So...I guess what I want to know now is, how does restarting a Plural script in Danmakufu work? I might be able to pull a solution out of that (simply waiting before playing the BGM didn't work, so I guess I need some way to have the asset "already loaded" in some specific meaningful way)

Anyway this pretty conclusively shows that it's the BGM that's the problem (since modifying it modified the issue), so I'm guessing the lesson is "don't use BGM converted from MP3 using Audacity". If I ever get around to releasing things publicly, I'll have to keep that in mind.

While I'm here, though, how does render priority on bullets work? I tried Obj_SetRenderPriorityI(bullet, <priority>) and setting it to 80+ caused them to render out of place as expected (i.e. treating the top left of the window as 0,0 rather than the top left of the playing area) but bullets with an ostensibly lower render priority were appearing on top of bullets with a higher one. Is there some trick I need to be aware of?

And actually, come to think of it, I have another question...whenever I try to use GetCurrentScriptDirectory() for a #include, Danmakufu crashes. This is irritating because it means all my includes are full filepaths rather than being flexible based on where the script folder is (and I'm trying to separate out things like essential functions and animation data into a separate code file that I can just include in each script). Is there any remedy for this?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on December 30, 2016, 12:21:38 PM
You can't directly upload files below a certain number of posts, probably. Keeps malicious users from uploading harmful files.

While I'm here, though, how does render priority on bullets work? I tried Obj_SetRenderPriorityI(bullet, <priority>) and setting it to 80+ caused them to render out of place as expected (i.e. treating the top left of the window as 0,0 rather than the top left of the playing area) but bullets with an ostensibly lower render priority were appearing on top of bullets with a higher one. Is there some trick I need to be aware of?
Higher priority -> drawn on top. Meanwhile stuff under 20 and over 80 uses the window for the origin, while stuff in 20~80 uses the STG frame. Within the same priority, whatever starts drawing later is drawn on top. I'm not sure of the circumstances you're talking about but any object will behave the same way.

And actually, come to think of it, I have another question...whenever I try to use GetCurrentScriptDirectory() for a #include, Danmakufu crashes. This is irritating because it means all my includes are full filepaths rather than being flexible based on where the script folder is (and I'm trying to separate out things like essential functions and animation data into a separate code file that I can just include in each script). Is there any remedy for this?
You need to be aware that there's a difference between the script's main interpretation stage and the pre-processing stage(s). Most of the #Stuff headers are read way in advance for use in the script select menu, but when you open the script there's a pre-processing stage that glues all the #includes together and checks for errors and whatnot. This isn't a place where you can put code, it just reads the path you provide and pastes that script into the current one at that line. To get relative paths you use . to reference current directory and .. for the parent directory, so if in the same folder you have bla.dnh you use #include "./bla.dnh", and if there's a lib folder above the script's folder with a lib_anim.dnh file you'd use #include "../lib/lib_anim.dnh".
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: DichotomousCreator on December 30, 2016, 04:28:08 PM
Ah alright, thanks. That should make organizing a bit easier

The issue I'm having with bullet render priorities is that I'm doing this:

Code: [Select]
ascent(j in 0..20) {
    //Fill up shots array here
    Obj_SetRenderPriorityI(shots[j], 50);
}

ascent(j in 0..20) {
    //Fill up shots array here
    Obj_SetRenderPriorityI(shots2[j], 55);
}

and shots in the first array are still appearing over the top of shots in the second array if they were spawned earlier, as though their priorities were identical. The shot arrays are generated in a task which takes a render priority value as an argument (the code above shows the numbers for the sake of clarity) and passes it directly on to each shot generated using the function above.

I wanted to see if there were some weird special rules for making various shots outprioritize each other, since if I set the priority value too high (i.e. 81 and above) it treats the origin differently as I expect it to...but the shots with priority 55 aren't being drawn on top of the shots with priority 50.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on December 30, 2016, 08:25:18 PM
Question about arrays:  Was there a function to quickly check whether an Object or value is within the array or do I have to check that manually myself with a loop through the Array?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on December 31, 2016, 02:51:52 AM
shots in the first array are still appearing over the top of shots in the second array if they were spawned earlier, as though their priorities were identical. The shot arrays are generated in a task which takes a render priority value as an argument (the code above shows the numbers for the sake of clarity) and passes it directly on to each shot generated using the function above.
Yeah I'm not too sure why that would be the case. I would suspect that the function isn't actually being applied to the objects, but if you can use your method to make them 80+ then that's not the case.

I can do this:

Code: [Select]
task bla(g,p){
  let shots = [-1,-1,-1,-1,-1];
  ascent(i in 0..5){
    shots[i] = CreateShotA1(192, 100, 2, 90, g, 0);
    Obj_SetRenderPriorityI(shots[i], p);
  }
}
bla(SHOT_AMULET_RED, 50);
yield;
bla(SHOT_AMULET_BLUE, 55);

And the priorities work as they should. So I dunno, I'm just going to ask for your actual code so I can look more concretely.


Question about arrays:  Was there a function to quickly check whether an Object or value is within the array or do I have to check that manually myself with a loop through the Array?
Without any other data structures that are more appropriate for contains checks, or other special properties to the data that would make it easier (e.g. the array is already sorted, in which case you can binary search (https://en.wikipedia.org/wiki/Binary_search_algorithm)) you're going to have to go through it all.

You can create a dummy Primitive object and use Obj_Set/GetValue with strings of the object IDs as keys, then use Obj_IsValueExists to scrub it together; this is essentially the interface to a hash table, but even now I still haven't bothered to see whether it actually has the properties of a hash table and whether it has too much overhead to be useful. It's probably ok though.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on December 31, 2016, 09:33:08 AM
Bah, guess I'll have to handle it after all. Also good point you make: I was thinking of using 2D arrays for the key value pair behaviour, Obj_Set/Get is far more effective and useful here.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: DichotomousCreator on December 31, 2016, 11:06:07 AM
Okay never mind figured it out, I'm constantly applying the priority to the first side of the star rather than applying it to all five sides. I changed the iteration and it's working fine now (I realized that it wasn't in fact the whole star that was being displaced when I set the priority to 81, but rather just the first side). Apologies!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on January 04, 2017, 02:17:02 PM
I've always seen these "%" in scripts. Can anybody say me please, what are they doing? And an example to that (or examples?)   :wat:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 04, 2017, 03:21:44 PM
That's the modulo operator. Computing a % b gets the remainder when dividing a by b. For example, 11 % 4 = 3, because when dividing 11 by 4 you get 2, with 3 remaining: 11 = 4*2 + 3. For some other examples,
7 % 2 = 1  (because 7 = 2*3 + 1)
10 % 5 = 0  (because 10 = 5*2 + 0)
2 % 3 = 2  (because 2 = 3*0 + 2)

The most relevant uses you'll see of it are checking to see if (a % b == 0), which is true if a is cleanly divisible by b, and to check (a % 2), which is 0 if a is even and 1 if a is odd.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on January 04, 2017, 04:01:02 PM
I begin to remember the nightmares of the higher arithmetic with this "mod" signs  :D
Anyway, it's a nice function. Thank you, Drake, for the clarifying.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Skilvrel on January 08, 2017, 02:25:22 AM
'lo everyone. Newcomer here. I've been toying with the creation of some basic patterns, but I'm finding myself stuck on two problems that I can't seem to figure out.

The first is the creation of prefight chatter. While I've managed to display text with ObjText, managed to create image overlays of those speaking, and even creating semi-transparent pictures, I'm still not sure how to put all of this together into one single smooth system for talking. If anyone could tell me how to do this, I'd be grateful.

The second question is related to creating my own bullets. I've created some cuttlefish shaped bullets on a .png file. However, when I try to use them in a pattern, the bullets don't fire at all. If I change the bullet ID to one of the default shots, it fires just fine, so the problem isn't with firing the bullet in the first place.

The pastebin for my shots are here.
http://pastebin.com/fEc2xZgE (http://pastebin.com/fEc2xZgE)

Shot constant sheet is here.
http://pastebin.com/cg7QQKzq (http://pastebin.com/cg7QQKzq)

And the shot single file is here.
http://pastebin.com/xP3XJyKX (http://pastebin.com/xP3XJyKX)

The code that I think is relevant, but I've stared myself blind at it and still can't see the fault if so, is here.
Code: [Select]
#TouhouDanmakufu[Single]
#ScriptVersion[3] //This is required for ph3 scripts
#Title["Border of cliche and beginner"]
#Text["SampleA01:Shooting Bullets Straight Down"]
#BGM ["./LLS - Alice Maestra.mp3"]

//Danmakufu basic has dimensions 384 x 448
//Load the default shotsheet
#include"script/default_system/Default_ShotConst.txt"
#incluce"script/default_system/Extra_ShotConst.txt"

task MainTask{
BoWaP
}

task BoWaP{
    let angleT = rand(0, 360);
    let objcount = 0;
    while (ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){
CreateShotA1(102, 134, 3, angleT, 1, 5);
CreateShotA1(282, 134, 3, angleT, 601, 5);
angleT += sin(objcount) * 12; //BOWAP
objcount += 1;
yield;
        }
    }

Thanks in advance.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Junky on January 08, 2017, 10:19:21 PM
The next Len'en character on my list is Tenkai. The biggest issue is I have no clue how their borders work and how bullets hitting the edges of the spinning square border spawns on a the edge of another corresponding square border that's spinning in the opposite direction. Conarnar did it within one of his scripts. Sorry if that sounded confusing.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 09, 2017, 01:16:57 AM
'lo everyone. Newcomer here. I've been toying with the creation of some basic patterns, but I'm finding myself stuck on two problems that I can't seem to figure out.

The first is the creation of prefight chatter. While I've managed to display text with ObjText, managed to create image overlays of those speaking, and even creating semi-transparent pictures, I'm still not sure how to put all of this together into one single smooth system for talking. If anyone could tell me how to do this, I'd be grateful.

Dialogue events require waiting for player input in a blocking manner, as well as other things. Usually, it is implemented as part of a Plural or Stage script. Usually, you must create or use an existing library for the purpose.

The second question is related to creating my own bullets. I've created some cuttlefish shaped bullets on a .png file. However, when I try to use them in a pattern, the bullets don't fire at all. If I change the bullet ID to one of the default shots, it fires just fine, so the problem isn't with firing the bullet in the first place.

The pastebin for my shots are here.
http://pastebin.com/fEc2xZgE (http://pastebin.com/fEc2xZgE)

Shot constant sheet is here.
http://pastebin.com/cg7QQKzq (http://pastebin.com/cg7QQKzq)

And the shot single file is here.
http://pastebin.com/xP3XJyKX (http://pastebin.com/xP3XJyKX)

Firstly, is the file path to the image correct? Secondly, I suggest using LoadEnemyShotData(path/to/shot/definition/sheet). If you never load the shot sheet, Danmakufu will not know that it exists. Simply including the constants doesn't mean anything if they don't refer to anything.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 09, 2017, 05:00:35 AM
Nah, all that's fine. The load function is just called in the constants file (calling it in the script scope happens to be acceptable). The problem is just

#incluce"script/default_system/Extra_ShotConst.txt"
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 09, 2017, 03:03:54 PM
Nah, all that's fine. The load function is just called in the constants file (calling it in the script scope happens to be acceptable). The problem is just

#incluce"script/default_system/Extra_ShotConst.txt"

*facepalms*
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Skilvrel on January 10, 2017, 03:07:20 AM
Nah, all that's fine. The load function is just called in the constants file (calling it in the script scope happens to be acceptable). The problem is just

#incluce"script/default_system/Extra_ShotConst.txt"
Thank you. I can't believe I never saw that fault myself. Now I've got the shot sheet working, which means that I am that much closer to finishing my work. Again, thanks for your help.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BobTheTanuki on January 10, 2017, 03:13:02 PM
Ah,uh
Hello there you guys :derp:
I was wondering how do I spawn bullets in a star like Sanae does
I know it requires trigonometry , but don't even know how to make this work :V
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 11, 2017, 09:09:50 AM
It doesn't "require" trig, but using a bit to know where the star's points are is a good idea. Once you have that, you would just spawn lines of bullets from point A to B, which can be done with the following:

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); // your bullet here
}
}

The n is the number of bullets spawned. For a star with radius r (the distance from center to the points) the point at angle t is going to be (r * cos(t), r * sin(t)). Then you want to draw lines between each point and the point two after it (going clockwise). You end up with this:

Code: [Select]
function star(x, y, r, n){
ascent(i in 0..5){
let x1 = x + r * cos(i * 360/5);
let y1 = y + r * sin(i * 360/5);
let x2 = x + r * cos((i+2) * 360/5);
let y2 = y + r * sin((i+2) * 360/5);
bulletLine(x1, y1, x2, y2, n);
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BobTheTanuki on January 12, 2017, 12:07:29 PM
It doesn't "require" trig, but using a bit to know where the star's points are is a good idea. Once you have that, you would just spawn lines of bullets from point A to B, which can be done with the following:

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); // your bullet here
}
}

The n is the number of bullets spawned. For a star with radius r (the distance from center to the points) the point at angle t is going to be (r * cos(t), r * sin(t)). Then you want to draw lines between each point and the point two after it (going clockwise). You end up with this:

Code: [Select]
function star(x, y, r, n){
ascent(i in 0..5){
let x1 = x + r * cos(i * 360/5);
let y1 = y + r * sin(i * 360/5);
let x2 = x + r * cos((i+2) * 360/5);
let y2 = y + r * sin((i+2) * 360/5);
bulletLine(x1, y1, x2, y2, n);
}
}

Ah,I see,I see
I tried to do that without trig but it was hard xd
Okies,Thanks a lot for that :3
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: stormfire101 on January 12, 2017, 06:55:21 PM
I wanted to know if it is possible to have a texture or png work as a clipping mask like you would have in image editing software? what I'm looking to do is have part of the background be see through and open up to a separately scrolling layer however I also have a pattern on top that covers the blank space I am looking to make, any suggestions?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on January 13, 2017, 09:59:50 PM
Question about writing functions: Can I influence a local variable of an object I have define like in most Object Orientated languages?

Example:
Code: [Select]
function someFunction(number) {
    let obj = CreateObj(etc...
    let value = number;

    <drawing stuff>

    return obj;
}

let someObject = someFunction(1);

// Somewhere I want to retrieve that value and modify it.

Was there a way to retrieve that local variable and set/modify it? Or do I have to work with Obj_Set/GetValues ?

The object for me problem in question is a ObjPrim_Create(OBJ_SPRITE_LIST_2D)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 14, 2017, 06:19:19 AM
That specific pattern would be possible if functions were first-class citizens in the language (i.e. functions can be put in variables, used as arguments, etc), as it would let you create lexical closures (https://en.wikipedia.org/wiki/Closure_(computer_programming)). But you can't do that so no.

Object values are more or less what you want.

I wanted to know if it is possible to have a texture or png work as a clipping mask like you would have in image editing software? what I'm looking to do is have part of the background be see through and open up to a separately scrolling layer however I also have a pattern on top that covers the blank space I am looking to make, any suggestions?
You can, but it requires the use of shaders. Fortunately alpha masks are one of the official samples you already have (SamplePS02) and it should work with minimal tweaking, but in order to have the scrolling behaviour you want you will need to do significantly more work, either by doing some extra shader programming or by using render targets and using the resulting texture as the mask.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on January 14, 2017, 07:59:10 AM
If that is the case then I'll apply plain code duplication for now. Ugly as hell until I find time/effort to refactor.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Trung0246 on January 14, 2017, 09:55:32 PM
Dump question, but can I do these thing?

Code: [Select]
function returnArray(one, two, three) {
    return [one, two, three]; //Return array of value with same type or different type?
}
function returnObj() {
    let data = //Somehow create an object that store value?
    /*
    Like this? (C++, C#, ...)
   
    struct {
        int testOne;
        bool testTwo;
    };
    */
    return data; //And return it?
}

And if it were like this

Code: [Select]
function wait(time) { //Basic yield
    loop (time) {
        yield;
    }
}

//Wait inside another function
function test() {
    wait(45);
}

//Calling test
test(); //What is the behavior now? Pause the script file for 45 frame or what else?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 14, 2017, 10:49:15 PM
Dump question, but can I do these thing?

Code: [Select]
function returnArray(one, two, three) {
    return [one, two, three]; //Return array of value with same type or different type?
}
function returnObj() {
    let data = //Somehow create an object that store value?
    /*
    Like this? (C++, C#, ...)
   
    struct {
        int testOne;
        bool testTwo;
    };
    */
    return data; //And return it?
}

Neither of them are possible. For the latter, you will have to assign object values to another type of object.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 15, 2017, 02:10:48 AM
That use of looping yields would work as you imagine. It's important that both of those are functions and not tasks, as otherwise you'd just be yielding in a new separate thread that would do nothing.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Trung0246 on January 15, 2017, 05:03:54 AM
Neither of them are possible. For the latter, you will have to assign object values to another type of object.

Tutorial on things that you said? Need to read more on it.

And after a look on wiki, I saw CommonData, is that the same as struct, or different, but same, but different, or Obj_SetValue and Obj_GetValue?

Also, I wonder what the data type of Obj ID? String or what?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 15, 2017, 05:24:24 AM
Tutorial on things that you said? Need to read more on it.

And after a look on wiki, I saw CommonData, is that the same as struct, or different, but same, but different, or Obj_SetValue and Obj_GetValue?

Also, I wonder what the data type of Obj ID? String or what?

CommonData is equivalent to global variables shared across all scripts (there are also standard global variables but their scope is limited to within a script and included files). Obj_SetValue and Obj_GetValue are used to store custom fields in objects.

The data of object IDs are integers, I think. Usually you refer to the variable referring to an object and pass that in as a parameter.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Trung0246 on January 15, 2017, 07:57:39 AM
Obj_SetValue and Obj_GetValue are used to store custom fields in objects.

Hm.. so that is the only way... maybe I have to create fake bullet just for storing data (no drawing, invisible, no hitbox...)

Or I should just use CommonData like SetCommonData(Obj{private scope name goes here}_{key name}, value)

MKM should add Obj_Create() to create new plain object like struct just like in many major programming language :\

And btw what the hell is Primitive Object?

The data of object IDs are integers, I think. Usually you refer to the variable referring to an object and pass that in as a parameter.

Have to test on this... You should include these in your tutorial for god sake :p

Btw do you or anyone else have the list of all constant in PH3?

And what are the different between remainder and modc? (I know how to use %) Wiki didn't explain clearly to me much...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 15, 2017, 11:49:00 AM
If you're familiar with hash tables (or map data structures in general) already, Common Data areas are essentially hash tables taking strings as input, that are accessible throughout all running scripts.
SetCommonData(key, value) will map the string key to arbitrary value, and GetCommonData(key) pulls from the table. Using those functions uses the default Common Data area, which has the id "" (empty string). You can create more Areas for more tables; essentially there is just one overarching structure that is ultimately a hash table (that takes the area id string as key) of hash tables (the common data areas).

Each "object" also has its own table, which is what you access using Obj_SetValue / GetValue. But unlike Common Data which is engine-global, object values require the object IDs to access. Object IDs are indeed just integers.
Do not use Common Data to store individual object data; this is very bad practice due to their global nature.

I definitely agree there should be an empty object, but there isn't, so yes one thing to do would be to create a dummy Shot or Enemy object. Stuff like this is totally valid and doesn't seem to cause unwanted issues:
Code: [Select]
let bla = ObjShot_Create(OBJ_SHOT);
Obj_SetValue(bla, "_name", "ghost");
Obj_SetValue(bla, "_hp", 8);
Obj_SetValue(bla, "_attack", 2);
Obj_SetValue(bla, "_pos", [0,0]);

Primitive objects are most drawable objects that use texture and vertex information to be drawn. Sprites are Primitive objects with four vertices placed in a rectangle, but any number of vertices can be placed wherever. Its called Primitive because that's what they're called (https://en.wikipedia.org/wiki/Geometric_primitive) in graphics. If you want to make complex graphics with many vertices, you use the primitive object functions.

There are a lot of predefined variables. I could list most of them but I don't know why you'd need a list of them in the first place; the documentation will list them when necessary.

remainder(a, b) is an alias for a % b . modc(a, b) is the same but retains the C-like behaviour of preserving sign. So -3 % 5 = 2 but modc(-3, 5) = -3.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Trung0246 on January 16, 2017, 02:34:30 AM
There are a lot of predefined variables. I could list most of them but I don't know why you'd need a list of them in the first place; the documentation will list them when necessary.

I need those because I'm currently making a complier for danmakufu (not sure when It will done) on the web so if you can list those I really appreciated :)

Also include variable that scripter can't modify like GetCurrentScriptDirectory?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 16, 2017, 03:12:27 PM
I need those because I'm currently making a complier for danmakufu (not sure when It will done) on the web so if you can list those I really appreciated :)

Also include variable that scripter can't modify like GetCurrentScriptDirectory?

Reserved Keywords: https://sparen.github.io/ph3tutorials/ph3u1l5.html#sub9
Functions: http://dmf.shrinemaiden.org/wiki/Functions_(ph3)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Trung0246 on January 16, 2017, 04:51:18 PM
Reserved Keywords: https://sparen.github.io/ph3tutorials/ph3u1l5.html#sub9
Functions: http://dmf.shrinemaiden.org/wiki/Functions_(ph3)

Hm... thx
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: stormfire101 on January 17, 2017, 09:22:25 PM
I've been lost on the scrolling background with scrolling cutouts a while. I've looked into shaders and create render target but haven't gotten either to work, so what exactly am I missing?
http://pastebin.com/0z1ZxkX9
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on January 21, 2017, 09:47:31 AM
Does somebody knows, if "Blender" can work like "Metasequoa" making 3D objects?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 21, 2017, 03:12:33 PM
Does somebody knows, if "Blender" can work like "Metasequoa" making 3D objects?

Blender is a 3D modeling tool, and you can export Blender projects to DNH-compatible formats.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on January 21, 2017, 07:14:52 PM
Blender is a 3D modeling tool, and you can export Blender projects to DNH-compatible formats.

Hooray! But how can I do it? I tried each format, but it didn't work: .3ds .abc .blend .dae .fbx .mtl .obj .ply .stl .x3d
At first I have always done it with Metasequoa. With .mqo formats.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Uruwi on January 21, 2017, 09:21:46 PM
Hooray! But how can I do it? I tried each format, but it didn't work: .3ds .abc .blend .dae .fbx .mtl .obj .ply .stl .x3d
At first I have always done it with Metasequoa. With .mqo formats.

There's a plugin for .mqo export somewhere.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Skilvrel on January 22, 2017, 12:07:12 AM
More newbie questions from me. Does ph3 have a function for creating armour for a boss? That is, cut the incoming damage a boss takes from shots by a set number? As I understand it, you can use ObjEnemy_SetDamageRate to set a percentage of damage taken from bombs and bullets. But it's not percentage I'm looking for. I want a flat rate, so that an attack with few but high-powered hits will be more effective than an attack with many low-powered hits.

Second. Is there a way to link a boss HP to the stats of their familiars? That is, the boss herself is immune to all damage, but as you destroy familiars, the boss takes damage until she reaches 0 HP. I suppose it's possible through the use of ObjEnemy_AddLife, but will that work on a survival spell? And if so, is it possible to change the upcoming spellcard depending on if the spellcard was beaten by timeout or by defeating familiars?

Thanks in advance.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: lolpudding on January 22, 2017, 12:30:02 AM
Hi again! So realising alot of my issues are mainly on the scoring mechanic of my script, I wanna ask two thing. (If that is not a problem)

One question is that I am trying to render how many points (2,000,000) are needed until something happens. But, I can't seem to get it to go back to 2,000,000 again. Here is the code: http://pastebin.com/5ybgYYuy (http://pastebin.com/5ybgYYuy)

Also, you know how when a spell is cleared or bombed, all the bullets turn into items and increase point item value right? Well, I have the point value system in my script but I don't know how to let bullet-turned-items increase it. I have seem people use custom items to replace the ones in danmakufu, which I tried myself and ended up failing due to my lack of knowledge on creating custom items. Nevermind, turns out that it was because I have not used "StartItemScript" thought Default_System
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 22, 2017, 09:26:21 AM
I've been lost on the scrolling background with scrolling cutouts a while. I've looked into shaders and create render target but haven't gotten either to work, so what exactly am I missing?
It's complicated. If you wanted to use pure shaders, you'd have to write a shader technique that uses a variable to set the position of the texture before it's applied. But that may or may not be more difficult than an alternative.

Because the shaders work on textures and not on what's drawn on screen already, but you want it to scroll, I was suggesting to draw the subtracting texture to a particular position on a render target, and then use that resulting texture with the shader as-is. Implementing either of these options kind of stinks though. I've made it easy for you by spending the time to do it myself.

https://gist.github.com/drakeirving/6694f73f5cb5cdb981a09e310e798250

Code: [Select]
/*----------------
Mask object, for applying alpha masks to specific drawing layers.
Is a 2D Sprite object and requires manual setup of texture and rects.
Applies mask on layers from `layer_min` to `layer_max`.
-----------------*/
function ObjMask_Create(layer_min, layer_max){
let objMask = ObjPrim_Create(OBJ_SPRITE_2D);

// set up render target
CreateRenderTarget("tex_mask");

// set up shader
let mask = ObjShader_Create();
ObjShader_SetShaderF(mask, GetCurrentScriptDirectory() ~ "SamplePS02_HLSL.txt");
ObjShader_SetTechnique(mask, "TecMask");
ObjShader_SetTexture(mask, "textureMask_", "tex_mask");
SetShaderI(mask, layer_min, layer_max);

task run(){
while(!Obj_IsDeleted(objMask)){
// make visible when drawing to render target
ObjRender_SetAlpha(objMask, 255);
RenderToTextureB1("tex_mask", objMask, true);
// otherwise invisible
ObjRender_SetAlpha(objMask, 0);
yield;
}
Obj_Delete(mask);
RemoveTexture("tex_mask");
}
run();

return objMask;
}

Here's an example with a scrolling alpha mask. My `mask.png` texture is 256x256 but that isn't really important.

Code: [Select]
let mask = ObjMask_Create(26, 28); // applies to layers 26~28
ObjPrim_SetTexture(mask, GetCurrentScriptDirectory() ~ "mask.png");
ObjSprite2D_SetSourceRect(mask, 0, 0, 1024, 1024); // looped texture for scrolling
ObjSprite2D_SetDestCenter(mask);

let x = 0;
let y = 0;
loop{
// scroll texture
ObjRender_SetPosition(mask, x, y, 0);
x = (x + 1) % 512;
y = (y + 1) % 256;
yield;
}

Realistically speaking, if you actually had no idea what I've been talking about, you should have dropped the idea altogether. You don't need this effect to make a decent background.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on January 22, 2017, 09:28:07 AM
There's a plugin for .mqo export somewhere.

Thank you! I found this Plugin. There's one more question, is it possible to do 3D animation in ph3?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 22, 2017, 09:35:16 AM
Mesh objects have animation capabilities, as written in the documentation. I have no idea what the specifics are though so just play around with the functions and see what makes sense.


More newbie questions from me. Does ph3 have a function for creating armour for a boss? That is, cut the incoming damage a boss takes from shots by a set number? As I understand it, you can use ObjEnemy_SetDamageRate to set a percentage of damage taken from bombs and bullets. But it's not percentage I'm looking for. I want a flat rate, so that an attack with few but high-powered hits will be more effective than an attack with many low-powered hits.
This seems kind of silly conceptually. Shmups have gone forever without needing this, since it generally comes down to the fact that focused shots are balanced so they cover a narrow area but deal a lot of damage, while spread shots are balanced so they cover a wide area but deal relatively less damage, that is mitigated by having more shots hit. If the difference is instead about the low-powered shots having a high number of hits per second, then just give the "strong" shot more damage or reduce the hit rate of the other shot. Asking for an explicit balancing override seems to ignore the point, but if you really want to you can always set different damage rates based on reading which player it is with GetPlayerID.

Second. Is there a way to link a boss HP to the stats of their familiars? That is, the boss herself is immune to all damage, but as you destroy familiars, the boss takes damage until she reaches 0 HP. I suppose it's possible through the use of ObjEnemy_AddLife, but will that work on a survival spell? And if so, is it possible to change the upcoming spellcard depending on if the spellcard was beaten by timeout or by defeating familiars?
The former is definitely possible just as you think. The latter is a bit more complicated, but it basically amounts to having the single script run different tasks (with the actual contents) based on CommonData (not recommended) or setting an object value with Obj_SetValue on the boss scene object during the script before, and reading it on the relevant script.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 22, 2017, 04:43:38 PM
Second. Is there a way to link a boss HP to the stats of their familiars? That is, the boss herself is immune to all damage, but as you destroy familiars, the boss takes damage until she reaches 0 HP. I suppose it's possible through the use of ObjEnemy_AddLife, but will that work on a survival spell? And if so, is it possible to change the upcoming spellcard depending on if the spellcard was beaten by timeout or by defeating familiars?

Drake has already answered this but I'll add my two cents. Depending on how you implement familiars, it may be practical to add a boss hitbox on the familiars - IE place a hitbox on the familiar that sends damage to the main boss. Alternatively, if you want it to be on a death-only basis, you can, on familiar death, decrease the boss HP by a certain amount by adding negative life to the boss (as Drake stated).

AFAIK changing the upcoming spellcard depending on defeat method is an exceptionally ugly process since boss scenes are pre-loaded. You'd need CommonData at the very least, but since I've never done this myself, I can't really say.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on January 26, 2017, 04:27:44 PM
All this talk of familiars transferring damage to the parent boss reminded me of a question that maybe you all can help answer.

So, a long time ago I made a Yuyuko fight and wanted to implement a hitbox on her fan graphic (like in PCB) where she took reduced damage from. The way I did it (this was back in 0.12m) was to position a bunch of invisible familiar enemies on it that would transfer damage back to Yuyuko (using SetDamageRateEx). This obviously wasn't optimal and I have always wondered if a better way was possible.

With the final stage of my new game, EUB, I want to do a similar thing again for its final boss. Since ph3 doesn't even have an equivalent to SetDamageRateEx, I figured it would be even less effective to use the invisible familiar method. I thought of just using ObjEnemy_SetIntersectionCircleToShot to just position additional instances of the boss's hitbox on the graphic, but that wouldn't produce the reduced damage that I'm looking for (and that's particularly important to limit the effectiveness of spread shottypes). Any ideas?

EDIT: Just curious, does anyone have any actual insight on how precisely ZUN produced this result in PCB and other games?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on January 26, 2017, 08:37:45 PM
As my game revolves around some duo patterns (like Kogasa and Nue) or even an object and boss, I've made this sluggish code:

Code: [Select]
// Test damage for dual partners obj = main boss obj2 = partner.
task shareLifeHandler(obj, obj2) {
// get the HP of the main and store it in var
let mainBossHP = ObjEnemy_GetInfo(obj, INFO_LIFE);

// Set the HP for the partner.
ObjEnemy_SetLife(obj2, mainBossHP);

while(!Obj_IsDeleted(obj)) {
// Only update the HP of the boss if it actually gets hit. This is to prevent the HP from snapping to the main value.
if(ObjEnemy_GetInfo(obj2,INFO_SHOT_HIT_COUNT) > 0) {
    ObjEnemy_SetLife(obj, ObjEnemy_GetInfo(obj2, INFO_LIFE));
               }

// update the HP of the partner continously from the main (shared HP)
ObjEnemy_SetLife(obj2, ObjEnemy_GetInfo(obj, INFO_LIFE));
yield;
}
}

You can probably fit in damage rates functions ObjEnemy_SetDamageRate(obj, valueshots, valuespells); and ObjEnemy_GetInfo(obj, INFO_DAMAGE_RATE_SHOT); and ObjEnemy_GetInfo(obj, INFO_DAMAGE_RATE_SPELL); here to achieve desired effect.

The shareLifeHandler(obj,obj2); I call inside the slave/partner/whatever initialization. Make sure the boss is spawned before.

Btw, If you want to create a shield like effect (i.e.: must kill all familiars before you can damage the boss). Why don't you just spawn a counter or array. Loop a listener that sets damage rate to 0,0 as long as the count of familiars is greater than 0 or the familiar objects are inside the array. And if the boss replenishes familiars, you could add them into the array or count up the variable and voila: boss is immune again.

There are dozens of way to approach it, but I think you're all over-thinking it a bit too much. That is mostly because of the extremely specific wishes, is my guess. The above examples are most straight forward.

Edit:
Forgot to mention: if you want to work with flat rates then you'll need to do overly complicated calculations based on damage done to the familiars then calculated towards the boss. The shareLifeHandler can contain the complex logic if you're persistent to make it work. But as Drake said, it is a bit silly design as the goal remains unclear.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MegamanOmega on January 27, 2017, 06:17:04 AM
Can someone help me here and tell me if I'm screwing up horribly or if this script is busted, cause I can't figure out what's going on here.

So I downloaded this old danmakufu script which is supposed to be a Phantasm Stage of Great Fairy Wars, however I can't seem to get it to run properly.

http://www.mediafire.com/file/rgzb674h8g58agn/%E5%A4%A7%E6%88%A6%E4%BA%89Ph.zip

That is the only version I can find, however it's not quite like the version that was played in the video where I got the download from.

http://www.nicovideo.jp/watch/sm13890048

The game itself skips over the stage portions, the boss fights are notably more difficult, and Cirno's ice mechanics feel much weaker than how the guy's doing it in the video. Can someone who knows danmakufu tell me if I'm doing something wrong when trying to play it or if the script is broken in some way (considering I had to found the download via Internet Archive of the video, the later wouldn't surprise me)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 27, 2017, 11:37:09 AM
The readme says it's different. The stage portion was removed and it was generally made more difficult. There are also two Cirno players, one of which is slightly more strict, so make sure you play the チルノさん one (although they're both terribly unwieldy to use, as described below).

After playing it, the stuff shown in the video doesn't even compare. It's very clearly an order of difficulty harder. The creator probably suffers from make-it-harder-itis. The ice mechanics were likely tested mostly on the previous difficulty, as the recharge is not enough at all for the patterns it throws at you. Considering how fast you accumulate charge for shooting versus how much for grazing, you might even get more charge from the easier versions of the patterns precisely because you need it less. And either way the pattern design sucks for making use of the ice mechanic because the bullets are always so fast and far apart, which makes the freezes sparse and grazing for charge impossible. Finally you don't recharge from freezing bullets which eliminates one of the fundamentals of FW ice mechanics, sending you back to 0% regardless of how many bullets you cancel. If you play FW right now you will notice how you will basically never be left stuck at 0% unless you mess up a freeze. In the real game, the cooldown period is mostly the time it takes to hold the button, whereas here it's the time it takes to charge to the 30% minimum and then also holding the button, which leaves you super vulnerable.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MegamanOmega on January 27, 2017, 05:58:03 PM
Ah, darn. That's what I was afraid of but I figured I'd ask anyways to make sure. It's a damn shame too, the script in the video looked challenging to play, but this script itself just easily crossed over the line into just being unfun.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 03, 2017, 09:19:40 PM
I am failing with loops/ascents to perform the following case:
- Assume I have a stage with 5, 13 and 24 spell cards
> For example for the one with 13 cards, I wish to put the first cards 10 into a 2D array
> Then I wish to put the remaining 3 into the same array, but next element position

So the desired result in my mind is this:
Code: [Select]
array = [
    [card1, card2, ..., card10],
    [card11, card12, card13]
];

However, when there are less than 10 cards. I just wish to perform this loop once so the array contains only one element. Also, If there are 24 cards. Then I need to cycle 2x filling up 10 cards but each inner array may only contain 10 cards.

I know how to concatenate into 2D arrays thanks to Drake, though I fail to put it all together into a loop/ascent. I am guessing I need a loop inside a loop.

Finally, the reason for this all is my wish to implement it for my Spell Practice screen. So I can jump a 'pageNumber' to cycle through the elements in the 2D array and using 'cardNumber' I can cycle through the cards in the highlighted element. Basically a revolving/wrapping list of spell cards.

Here is something I tried but got stuck. Note: This code doesn't work.
Code: [Select]
let cardsInPageArray = [];
totalPages = 0;
let index = 1;
let temporaryArray = [];
ascent(i in 0..totalPages) {
    ascent(j in 0..numberOfCards) {
        let setText = "Spell Card " ~ IntToString(index);
        let textObject = writeGraphicalText(160, 100 + (j*22), 255, 17, [255,255,255], [255,255,255], [42,99,122], 512, setText);
        temporaryArray = temporaryArray ~ [textObject];
        index++;
    }
    cardsInPageArray = cardsInPageArray ~ [temporaryArray];
}

writeGraphicalText is a function that spawns a Text Object. Later on using the arrow keys, the highlighted text object will lit up (animation for selecting cards)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 04, 2017, 12:03:05 AM
So if you want the interface like this

Code: [Select]
Stage 1
└ Page 1
  └ Card 1, [...], Card 5
Stage 2
├ Page 1
│ └ Card 1, [...], Card 10
└ Page 2
  └ Card 11, Card 12, Card 13
Stage 3
├ Page 1
│ └ Card 1, [...], Card 10
├ Page 2
│ └ Card 11, [...], Card 20
└ Page 3
  └ Card 21, [...], Card 24

where you're like pressing left/right or something to scroll pages, I think the easiest way to handle it is to not put them into separate subarrays at all but instead to display the cards from cards[page*10 + 0] to cards[page*10 + 9] and then selecting is cards[page*10 + index].

I think it's also worth looking into how the newer games' Spell Practice UI works (stage -> cards -> difficulty) rather than IN's (stage -> all cards). Splitting it up even more finely into difficulties rather than listing them all is probably better imo. It does make the menu code have more "levels" but makes each section simpler, I guess? You don't have to deal with the page thing at least.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 04, 2017, 07:40:11 AM
Yes that is exactly my desire.

And I was already using DDC's Spell Card Practice menu layout. Currently using Stage -> Card -> Difficulty.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Spacechurro on February 06, 2017, 12:13:40 AM
I'm kinda new to danmakufu, and after finding PH3 currently too complicated, for someone who is new to coding too, decided to use 0.12m instead, which is easier. But in PH3 I could use "#includes", but it doesn't seem to work in 0.12m, but I suspect i'm just using it wrong. This is the code to show whether or not i'm typing it correctly?

Code: [Select]
#include"script/TestNiko/Scripts/Res.txt"
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 06, 2017, 05:26:55 AM
0.12m exclusively requires backslashes for pathnames if I am not failing with my memory. (been such a long time)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 06, 2017, 07:08:40 AM
Besides that, it's #include_function to be used when inside a script_enemy_main (most cases) and #include_script when you're including a script itself.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Spacechurro on February 06, 2017, 07:58:46 PM
Thank you so much! I'm glad I found this thread!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Spacechurro on February 09, 2017, 03:01:20 AM
I apologize for asking another question again, but I am trying to see if I can make a function/task/if statement play a sound affect for each second after the timer gets to "10", much like in Touhou.
The SE plays in any other task, but it won't play at the 10 second mark. I even load it in the if, outside the if in the task, and even outside the task itself, but it refuses to play. Is the if I'm using not working? I don't know, but that's the only function that calls the timer's value (from the danmakufu wiki). Plus, this seems like a pretty trivial problem, but I think it would help me with a lot of other things, too, if I knew it.

Here is an example of the task, assume I have given the location a variable (To), is loaded, and the location is correct, as I have checked in other tasks, AND I call it in Initialize.

Code: [Select]
task timer{
if(GetTimer == 10){
PlaySE(To);
wait(60);
}
if(GetTimer == 0){
StopSE(To);
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 09, 2017, 05:15:28 AM
Your task structure won't work as intended. It just launches, checks the if statements once, then immediately ends. There's no behaviour to make it keep running and actively check things.

Code: [Select]
task timer(){
loop{
if(GetTimer < 10){
PlaySE(To);
}
wait(60);
}
}

This will wait one second every time it checks, and if it's less than 10 seconds left it'll play the sound (so it will play 10 times). Note the loop there so it doesn't just end.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Spacechurro on February 10, 2017, 12:45:11 AM
Thank you, I would like to know which part of that code keeps it checking? is it the "()" in the name?

Also! I really hate to ask so many questions, but my stage script can't seem to interpret my event script. And I basically copied the wiki tutorial for the event "danmakufu intermediate tutorial"
Code: [Select]

task stage{
Wait(120);
CreateEventFromScript(GetCurrentScriptDirectory ~ "Evnt1.txt");
CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Plural.txt", 0, 0, 0, 0, 0);
Wait(60);
Clear;
}

The error says that it's an "unregistered enemy script", I looked at Sparen's error list, but it's pretty vague, and I don't want the script to only switch to the next when the timer runs out, or the enemy is killed by putting it into a "Script_Enemy_Main" script. I'm not sure what else to do about it. I feel like i'm just confused about what the wiki means in the function's parameters by "Path then string" I understand path, but what is the string? I think I might be missing that.

I apologize again for asking so many questions, I'm a baby brain, you see.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 10, 2017, 09:57:00 AM
No, it's the loop. The empty parentheses aren't necessary.

Calling a task launches a separate block of execution. It runs through the code in the task as normal, and when the task finishes, the script's execution will resume from where you called the task.
If you put a yield in the task, it will instead run through the code until the yield, pause the task for later, and resume from where you called the task. On the next frame, the task will resume from where it had yielded and keep going until either it finishes or another yield is hit, in which case it again pauses until the next frame.

So, if you put two yields in a task, it will yield on one frame, and then on the next frame it will immediately hit another yield, effectively waiting for two frames. Likewise, if you loop over a yield with loop(n){ yield; }, the task will wait for n frames before continuing. That's what the wait function does.

Without the loop statement in the task I wrote, all the task will do when called is:
ask if the timer if it's less than ten seconds -> wait 60 frames -> end the task

By putting in the loop statement, instead of the task ending after the wait(60), it loops back to the beginning, checks the timer again, and then once again waits for 60 frames.

It's putting the yields in some sort of loop that makes the task run some behaviour over a period of time. This is very fundamental to learn and understand when writing scripts.



As for the event script, you're supposed to call CreateEventFromScript from inside your enemy script, not the stage (well, maybe it'll work from a stage script? Haven't used 0.12m in forever). Meanwhile, you don't pass the file path as the argument, you pass the name. Your enemy script file should look like
Code: [Select]
script_enemy_main{
  // stuff
  CreateEventFromScript("EventName");
  // stuff
}

script_event EventName{
  // event
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on February 10, 2017, 05:49:18 PM
Help!
When I launch a STG threw a PACKAGE script AND when I press PAUSE, it comes to a black screen. However when I launch this STG alone, all is working properly. Which reason is possible for that? (P. S. reason is 100% not in Pause System).
Thanks in advance!!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 10, 2017, 06:11:14 PM
Help!
When I launch a STG threw a PACKAGE script AND when I press PAUSE, it comes to a black screen. However when I launch this STG alone, all is working properly. Which reason is possible for that? (P. S. reason is 100% not in Pause System).
Thanks in advance!!

What is a "STG"? Please state, step by step, how to reproduce your problem, and which scripts are involved. The way you have written your statement, it's not clear as to what is going on. Are you playing a stage script from within a package, and then pausing?

Please clarify so that we can help you.

Also:
Quote
(P. S. reason is 100% not in Pause System).
You can NEVER, EVER be 100% sure of this. As a game dev, you should know better than to assume that 'X is definitely not the problem'. Oftentimes, you overlook the actual problem when you approach it like this.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on February 10, 2017, 07:02:28 PM
Ok. I try one more time.
There are a full stage and a package script (menu). If I open just a stage script, all works properly. BUT if I open this stage script within the package script and try to run PAUSE SCENE during playing stage it comes to black screen.

I tried to insert other PUASE SCENEs. But problem didn't change. So, I thought that the problem is surely not in the PAUSE SCENE itself.

Question: Possible reasons for that?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 10, 2017, 07:41:45 PM
Ok. I try one more time.
There are a full stage and a package script (menu). If I open just a stage script, all works properly. BUT if I open this stage script within the package script and try to run PAUSE SCENE during playing stage it comes to black screen.

I tried to insert other PUASE SCENEs. But problem didn't change. So, I thought that the problem is surely not in the PAUSE SCENE itself.

Question: Possible reasons for that?

Are you running the pause scene script at all? This is an example from my latest project.

Code: [Select]
//in package stage scene main loop
if(GetVirtualKeyState(VK_PAUSE) == KEY_PUSH) {
            let resPause = RunPauseScene();
            alternative(resPause)
            case(RESULT_RETRY) {
                //Checking what to do
                if(!IsReplay()) {
                    //Retry
                    TerminateStageScene();
                    TStageScene("");
                    return;
                } else {
                    TerminateStageScene();
                    TStageScene(pathReplay);
                    return;
                }
            } case(RESULT_END) {
                TerminateStageScene();
            }
        }

...


function RunPauseScene() {
    RenderSceneToTransitionTexture();
    PauseStageScene(true);

    let pathScript = GetCurrentScriptDirectory() ~ "system/Pause.dnh";

    //Starting pause script and stuff
    let idScript = LoadScript(pathScript);
    StartScript(idScript);

    while(!IsCloseScript(idScript)) {
        yield;
    }

    PauseStageScene(false);

    let res = GetScriptResult(idScript);
    return res;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on February 11, 2017, 08:36:06 PM
Sorry for long answer. It was night and I fell asleep.

Yes I'm running it. I tried the way you did. But when I insert

Code: [Select]
else{
                    TerminateStageScene();
                    TStageScene(pathReplay);
                    return;
         }

occurs an error.

(P.S. when appears black screen, I see only words that are in PAUSE. The END SCENE works properly though. One thing I see clearly, when I open this SCENEs within the package, all look so BLEND_ARGBish. Originally they are not so. Problem in graphics? )
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: sibu12345 on February 13, 2017, 07:17:44 PM
Hi, I'm new to the fanmade games and have recently been trying to play those from BulletForge (http://www.bulletforge.org/) and well, I ran into some Issue I'm not sure where to seek help from.

Ph3 runs fine except it's only playable in 640x480. Any bigger and it just turns to grey. I can still hear it running and myself dying :'). I just can't seem to see anything but grey.
I've tried running it with the given locale link (http://pooi.moe/Locale-Emulator/) from the FAQ (https://www.shrinemaiden.org/forum/index.php/topic,6181.msg345024/topicseen.html#msg345024) thread.

Some scripts are detected by ph3 and some aren't but well I just want to solve this full screen problem first T.T
The only version that fullscreens for me (kinda funnily) is this: Perfect Chicken Flavour (http://www.mediafire.com/?wlqmynznwiy). I've tried putting some scripts in to try run it in full screen that way. That version detects the scripts but refuse to run it. Well, at least I can still play with Ronald Macdonald xD

I'm running on windows 10 by the way. Hopefully someone can enlighten me cause poking around the internet for 2h can't seem to find anything remotely close to an FAQ for pure players (I guess?). Thanks a lot for reading through this. (I'm kinda desperate haha)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Spacechurro on February 18, 2017, 11:04:17 PM
Some scripts not running may be due to the fact that they're either packages, which don't need your own danmakufu to play, you just have the whole folder, and open the executable in it's own folder, or you could are running 0.12m scripts on ph3. In the description of the download places for the scripts usually tells you whether the scripts are ph3, or 12.m
You can probably fix the aspect ratio by clicking the "config.exe", and changing it to whatever you feel like. You could also change it to fullscreen too. If you've already tried this sorry, that's all I can help with...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on February 19, 2017, 03:04:29 PM
I don't need help anymore! I solved my problem.  :D
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on March 03, 2017, 07:21:41 PM
One more question please!
I use @Event (case(EV_PAUSE_ENTER) and case(EV_PAUSE_LEAVE)) to stop and play stage music by running pause in stage. But the problem is that @Event doesn't do same with BOSS music. Whatever I do, all is the same.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 03, 2017, 09:58:38 PM
I need a bit more details on this, I can vaguely remember I had a similar issue with my setup. How exactly are you starting your boss music or your stage music?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on March 03, 2017, 10:13:30 PM
I need a bit more details on this, I can vaguely remember I had a similar issue with my setup. How exactly are you starting your boss music or your stage music?

I start with creating sound objects in the stage and loading it. And then calling functions in @Event system.

Code: [Select]
@Event
...
     case(EV_PAUSE_ENTER){
          ObjSound_SetRestartEnable(music, true);
          ObjSound_Stop(music);
     }
     case(EV_PAUSE_LEAVE){
          ObjSound_Play(music);
          ObjSound_SetRestartEnable(music, false);
     }
...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 04, 2017, 07:05:37 AM
That is quite interesting as I am using none of that in my code it seems. I've checked my custom system script and the EV_PAUSE_ENTER and LEAVE is empty.

What I personally do is first put the song that is playing (boss or stage song) into a variable. In this case a AreaCommonData. Then I have put the Start / Stop commands inside the pause script it self. Example, this is from my own menu_pause.txt

Code: [Select]
// When the script is booted
StopMusic(GetAreaCommonData("sound", "song", 0));
PlayMusic(BGM_PAUSE);

And when the pause is canceled (to return back to game play)
Code: [Select]
case(PSE_CANCEL) {
        . . .
PlayMusic(GetAreaCommonData("sound", "song", 0));
        . . .
}

// before closing the script
StopMusic(BGM_PAUSE);

This is how it works in my game. Try it out.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Spacechurro on March 07, 2017, 01:50:33 AM
I have a weird question, I'm back to using PH3 again, and was wondering something, does ph3 have it's own function for conversation between characters? Or do you have to make your own?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on March 07, 2017, 02:38:19 AM
I have a weird question, I'm back to using PH3 again, and was wondering something, does ph3 have it's own function for conversation between characters? Or do you have to make your own?

You must make your own.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on March 13, 2017, 10:43:34 PM
@Helepolis

I tried to do sound system as u said, but it was way too complicated for me. Could u tell me please how it works more detailed. And how can I put these variables into a AreaCommonData???

Edit: Nevermind, i solved the problem :/
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 16, 2017, 06:34:10 PM
@Helepolis

I tried to do sound system as u said, but it was way too complicated for me. Could u tell me please how it works more detailed. And how can I put these variables into a AreaCommonData???

Edit: Nevermind, i solved the problem :/
Sorry for being unable to respond on time. Lately been quite busy that I even neglected my own game development.

Curious though, what was the final problem and how did you solve it?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on March 17, 2017, 06:24:05 AM
Oh, I see. I understand. Thank you for responding!

Curious though, what was the final problem and how did you solve it?

The problem was in restarting the music after I leave the pause. Music started always from beginning. My mistake was:
Code: [Select]
ObjSound_SetRestartEnable( GetAreaCommonData("sound", "song", 0) ,false) Which is of course wrong, because this common data not a music object itself. The solution was to call this function as I did it with play/stop music object.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on March 20, 2017, 05:12:55 PM
Just to preface this post, I'd like to note that Danmakufu has been my only programming experience. I've had no formal education or experience in any general programming language.

I've been looking for something that I can eventually move to after I'm done with Danmakufu and to this end I've recently been dabbling in a Lua framework called LOVE2D, which has had me learning coding in Lua. It's been stated in the past that Danmakufu's tasks are basically the same as coroutines and it's my dabbling in lua that made me understand exactly why that is correct.

Danmakufu's tasks are not truly running in parallel. This is why the @MainLoop must be yielded in order for tasks to properly run (it's essentially resuming the task coroutine from where it was paused, or yielded, if I'm correct). I understand this now and have started to construct a similar method of programming in lua using coroutines to the tasks that I'm used to using in Danmakufu.

What I don't understand is how Danmakufu runs multiple scripts at the same time. I don't even really get what the scripts even ARE, as each one of them appears to be its own separate thread since they each have their own @MainLoop and tasks. It's been stated before that Danmakufu cannot do multithreading so these scripts can't actually be their own processing threads, unless I'm misunderstanding something.

So, my question is:

How does Danmakufu handle scripts if multiple can be run at the same time?

I'm interested in learning so that I can hopefully construct a programming environment that is similar to Danmakufu, which is what I'm used to. I'm still learning so please correct me if anything I said in this post is incorrect.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 20, 2017, 08:53:07 PM
When it comes to threading, I can tell you my own experience from being a JAVa programmer. Threading in Java is never parallel. The word multi-threading implies parallel execution, but it is not. For the Java programming language, the Java Virtual Machine (Also called JVM) handles the order of execution for any multi-threaded program made in Java.

Example, heavily assume that I launch a java program which creates 3 threads and each thread has a loop which inside simply echoes "Hello I am thread N".

Next, I start the threads in order 1, 2 and 3. Here comes the fun part: The order of these echoes are unsure. I didn't write "never" because that is a false statement. When it comes to threading, all you can claim is that the Threads are started, running and doing their jobs.
"Hello I am thread 1"
"Hello I am thread 2"
"Hello I am thread 1"
"Hello I am thread 3"
"Hello I am thread 3"
"Hello I am thread 1"
"Hello I am thread 3"


The above could be an outcome. Some thread might be even reported four times in a row or perhaps never for a long time. You simply don't know. There is absolutely no guarantee that the threads are echoed in order. So is there a way to control order in Java? Yes, there is. But that requires in-depth knowledge of the Java language. Are other languages similar when it comes to threading. I assume they are, but can't confirm from experience.

So why the example, you might ask. Danmakufu is (guessing) similar. The MainLoop of a script is always initiated by the engine. It can be assumed that the MainLoop in your script isn't actual the Main Loop. No, the Danmakufu engine probably has its own actual MainLoop hard coded which you cannot influence or control. Therefore the script @MainLoop is definitely a thread on its own. Which seems to have highest ultimate priority when not yielded, regardless of any task added in your script. Something that isn't true in Java. Threads in Java can be given a priority, but again there is no guarantee whether it gets a chance to run.

We already know that if you yield; the @MainLoop in your script, the Danmakufu Engine's Main Thread checks whether there are other tasks that can be performed. But it will never stop executing the @MainLoop. The @MainLoop of your script always runs, until it hits that yield. Only then the Engine will allow other threads to "grab their chance" and execute. All of this happens so fast that we humans thing there is parallel process going on. But there isn't.

Experiment
I heavily assume that if you would immediately call 3 bullets tasks with 3 different colours at the same time, the order of the bullet would be different each time the MainLoop hits that yield. So for example:
Code: [Select]
task fireRed() { }
task fireBlue() { }
task fireGreen() { }
The last bullet fired would overlap the previous two (because of Drawing Order). And my bet is that each time the overlapping bullet is a different colour.


Edit:
Asked a C# programmer RL friend about multi-threading. He says that in C# it is the same case as Java when it comes to the order of threads running. Except C# threading is probably influenced directly by the OS / CPU's orchestration. Fun fact, the JVM is actually also influenced by the OS/CPU.

Edit2
Tested the experiment of firing three bullets. It seems that there order of execution for tasks is as displayed in the script. Which, is if I think about it, quite logical. Calling the bullets is either done by a "task" or the @MainLoop. And there is one guarantee when it comes to putting things in loops (threads). The stuff is executed from top to bottom inside it. So my experiment failed because the script itself is probably a single thread. I have no idea how to run three scripts simultaneously.

Edit3:
Wow,  I forgot to answer your question after building up this much of a wall of text. I can only guess the following:

The Danmakufu Engine launches a new thread for every new script started. When you have a Stage Script and a Spell Card script, they are both independent instances, but the Engine's main thread is aware. Each script also launches its own routine called the @MainLoop, which has highest priority unless yielded within the script.

Scripts themselves don't conflict over each other's @MainLoop, that is for sure. But the execution of which script's MainLoop is most likely controlled by the Engine's main thread.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on March 21, 2017, 04:09:09 AM
Thanks Helepolis, that was a very insightful read and makes a lot of sense. I think you're definitely right about multithreading not having perfectly simultaneous processes.

I have no idea how to run three scripts simultaneously.
You can actually use LoadScript and StartScript to start any number of scripts. I actually do this to start special scripts for effect rendering and sound management in my game. They listen for Event signals from other scripts to perform visual effects like concentrations and explosions and play sound effects without worrying about being interrupted by the ending of a single script.

Edit3:
Wow,  I forgot to answer your question after building up this much of a wall of text. I can only guess the following:

The Danmakufu Engine launches a new thread for every new script started. When you have a Stage Script and a Spell Card script, they are both independent instances, but the Engine's main thread is aware. Each script also launches its own routine called the @MainLoop, which has highest priority unless yielded within the script.

Scripts themselves don't conflict over each other's @MainLoop, that is for sure. But the execution of which script's MainLoop is most likely controlled by the Engine's main thread.
My guess was that each new script was actually a task of sorts running from the hidden 'true' MainLoop. The hidden MainLoop would yield to the new script's MainLoop which would then in turn yield to any running tasks in that script. This begs the question of whether I can have coroutines start other coroutines which is something I had not considered.

Are we sure that scripts are definitely separate processing threads and not like tasks? I had imagined that if that were the case, then each script would be able to take advantage of a different core of a multi-core CPU, but my understanding on that is very limited and I'm probably wrong about it. I was under the impression that because Danmakufu only ever uses one CPU core it isn't truely utilizing multithreading, at least in that sense. I'm probably babbling about nonsense that I don't fully understand. Someone please clarify, if that is the case.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 21, 2017, 05:49:47 AM
Within a script, there are the predefined routines like @Initialize, @MainLoop, etc. These are predefined because they have special behaviour relating to that running script that is hardcoded as part of the engine. The actual execution flow of a "script" will start by doing some internal initialization stuff, interpreting and running @Initialize and @Loading, then when done will run @MainLoop once per frame, and also once per frame internally checking if conditions to run @Finalize are met. A global event scheduler (I'm assuming it's global) likely also takes the whole stack of events being triggered and messages the event data to the relevant scripts, and on that frame, that script's @Event will be run once for every new event put in that script's event stack. (That or there's another mechanism for scripts to add events to all other scripts' event stacks somehow. Or, all events are done together outside of the individual script flow, but I doubt that.)

If the programmer starts a task in @Initialize, which is likely, that starts a coroutine. Once it yields or ends, the context switches back to where the task was called; in @Initialize, which again is part of the main execution flow of the "script". If the task started more tasks the same applies and it just builds a tree of new coroutines and eventually winds back to the initial context. The "tree"-ness of calling tasks from tasks only really matters when they're first called; once a task yields, that coroutine is just set up in a queue for the next frame. Once @Initialize is over, and I assume it's starting on the next frame, @MainLoop runs. @MainLoop will have some stuff in it, and importantly it (should) yield, which lets the context yield back to the first task queued in the task scheduler. Once that task yields (or ends) again, context switches to the next in the queue, and so on until it reaches the end of the queued tasks for that frame, and finally context comes back to @MainLoop, which maybe runs some more stuff and then ends.

If you're clever, you might notice that if you don't put a yield in your @MainLoop, you get a few interesting pieces of information: 1) @MainLoop does not halt, and will keep running once per frame; and 2) only the coroutines relevant to the script are never yielded back to. Because of this it can be concluded that task/coroutine scheduling is divided on the script-level and is not a global scheduler. Tasks "belong" to a script.

Now, I've been writing "script" in quotations here because as far as I can tell, scripts are structures that have similar organization to coroutines, but are one step up the chain, and ultimately do many more things. I'm fairly sure that Danmakufu doesn't particularly do any multithreading with this, and that scripts are simply run in order similarly to how coroutines are scheduled per task, but done in a more global fashion. Danmakufu does run more than one thread for running in general though.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 21, 2017, 08:07:08 PM
All I can suspect from the LogWindow is that the Danmakufu Engine is scheduling its own coroutines/threads. (See attachment). The extra tasks/threads appeared when I was transitioning between Dnh's own Main Menu and Package Menu.

Looking at the ETaskManager at the top, is this perhaps the global "Manager" which handles all the coroutines for the engine?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Spacechurro on March 25, 2017, 04:13:18 AM
Hello, Just a quick question, that's probably a lot simpler than I think it is, but here it is:
So I've been trying to make my own Library for the typical touhou dialogue between characters (And hopefully branch off from there)
I've tried to make a task for the text like one would make a bullet object, that kind of seems to work, almost. The text shows up and everything, but I'm having a problem with how I move dialogue along, using the shoot button. I'm trying to do it in mainloop of the single I want it to appear in itself, but I can't seem to tell it to delete itself after the variable "ef" is upped a number (Or after the next text appears), eventually lagging the game after holding down the shoot button, especially since I'm not sure how to delete the text object outside it's task, and I can't assign them variables since they're not objects.

--I deleted the code to not take up so much room--

Hope someone can help, I'm not an expert at coding, so I hope that I don't look like a fool right now, heh.

P.S. Does this look too advanced for me, or is it not as advanced as it seems?

EDIT:

I was able to fix my problem by letting the TextOut task be an individual function inside the script itself, makes it less flexible or reusable, but it works!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Asthmagician on March 28, 2017, 12:04:49 PM
Hello, I've been following Sparen's (written) danmakufu tutorial, and I've run into an issue.
When I try to save a replay, I get an error: "replay information not found"
Am I missing something obvious?
I can post links to my code, if necessary

P.S I am using a custom package

EDIT: Code Removed, problem is solved
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on March 28, 2017, 01:12:47 PM
If this is in regards to the Replay Save File Guide (http://sparen.github.io/ph3tutorials/ph3u2l21.html), be aware that it hasn't been reviewed, so there may be issues with it that I have not yet found.

Otherwise, please provide code and the screenshot of the error. That will assist in the debugging process and if there's incorrect information in the tutorial, it will help in correcting that incorrect information.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Asthmagician on March 28, 2017, 02:33:58 PM
I forgot to mention, I'm using a custom package so I may be missing something there
I updated my post with pastebin links.

UPDATE: I am a dumb  :blush:
I forgot to add FinalizeStageScene in package script.
I added it, now it works.

P.S the danmakufu tutorials (especially the replay guide) are very helpful, thank you for writing them.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on April 05, 2017, 03:51:50 PM
Could somebody help me please to understand this function
Code: [Select]
ObjSound_SetLoopSampleCount What means one sample count, and how can I measure it?

Many thanks in advance!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on April 05, 2017, 05:09:41 PM
Could somebody help me please to understand this function
Code: [Select]
ObjSound_SetLoopSampleCount What means one sample count, and how can I measure it?

Many thanks in advance!
Sample count you can measure using for example Audacity. See this screenshot:

(http://i.imgur.com/XkpOoNl.jpg)

Press on the arrow button as shown to open the various timings. Select samples and you'll notice that the values have changed. Next, you can use those values to loop through specific section of your BGM. It is much much more accurate than for example seconds (unless using milliseconds). So this would result in the following usage:
Code: [Select]
ObjSound_SetLoopSampleCount(<object>, 647932, 1479241);
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on April 07, 2017, 05:31:31 PM
Sorry for being annoying with many questions. I'm sure I wont ask long time after solving this problem.
I have 2 stage-tasks in [Package] script. One for a normal stage. And second for a Spellcard Practice. The problem is in replaying them. Sometimes script can't find the path to a replay. Or even replay of the first stage will play on the second stage. How do I tell to a replay to play a right stage?

Solved.

I have a general question. I don't know if that fit to this topic, but how do I record and edit danmakufu videos in a best quality. Which videorecorders/editors do you normally use?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Spacechurro on April 11, 2017, 12:26:32 AM
Lightworks is a nice "free" video editor (Quotes on free cause it's a trial version, but there's no time limit, and you can still export and save videos, they're just not as quality as one would want), other than that all I use is windows movie maker (Booing in the distance)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Spacechurro on April 14, 2017, 08:13:07 PM
I have a small question,

What is the name for the item that appears and hones hen a boss shot is deleted? I want to make it play a sound effect when the player collects it. Like how there is "ITEM_POINT" or "ITEM_SPELL", is there one for the deleted shots?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 15, 2017, 04:12:51 AM
As far as I can tell you can't. The constants for different default items like ITEM_POWER just hold integers (item ids) ranging from -65536 to -66629. Maybe you would guess the star item is like these and just undocumented, but trying to spawn items -65537 or -65528 crashes DNH. What's an even bigger indicator of uselessness is that collecting the star items doesn't even trigger the EV_GET_ITEM event (or any player event at all), meaning it isn't even handled like an item by the engine and you wouldn't be able to trigger sounds even if there was a usable id.

The intention really is to create an item script yourself (in order to handle things like item collecting and generating) and to disable the default star item (with SetDefaultBonusItemEnable(false)).
In fact the example (http://www.geocities.co.jp/SiliconValley-Oakland/9951/pre/th_dnh_help_v3_data/description.html#ItemScript) in the official documentation is exactly that.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Spacechurro on April 19, 2017, 02:03:31 AM
I'm sorry that I appear on here a lot, but you guys are the only people I know who use danmakufu, or even program. This is going to be a bit lengthy (I'll delete the code when the problem is solved) , and I'm sorry if I missed something obvious, but nowadays, I don't do that as much, cause I wait a little more before asking for help, but this problem randomly occurs.

Anyways, I'm having a very strange problem, I'm not sure if it involves something i'm doing wrong, or a glitch in danmakufu, but this has happened three separate times. One in 0.12m, and two in ph3.
I don't have the 0.12m one anymore, I "fixed" it (Meaning I'm not sure how, and I can't repeat the problem, but)

It has to do with the if statements regarding "<" and ">". Basically It's doing a thing where it does the opposite of what the code says, or is somehow confused in the difference between "<" and ">"

For example, I would write this code (a similar one to the countdown code I had trouble with a while ago in 0.12m)

Code: [Select]
task TimeCheck{
while(ObjEnemyBossScene_GetInfo(bossObj,INFO_TIMER)<=10){
TimerOut;
wait(60);
}
}
It would countdown endlessly, even before it got to 10. I've tried it in an if statement, and in the mainloop, but it wasn't working, oh well...
Code: [Select]
     while(ObjEnemyBossScene_GetInfo(bossObj,INFO_TIMER)>=10)
So, just see what was happening, or to see if it was the path. But the path was fine... Except, it wouldn't countdown at all.

I guessed that I just was using the wrong variable, and ignored this problem... Until it happened again in my player script

Code: [Select]
if(ObjMove_GetY(obj)<10){Obj_Delete(obj);}

When I say (Y<10), it deletes it outright no matter where it is, but with (Y>10), it never deletes and the game lags

I need to specify to delete at that coordinate, hoping to solve ANOTHER gosh-darn problem, where the game keeps lagging after I use the spellcard effect.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on April 19, 2017, 03:13:09 AM

Firstly, what is the code that calls TimeCheck()? Please provide it so that we have more information to work on. Also note that ObjEnemyBossScene_GetInfo takes a BOSS SCENE OBJECT as its parameter, not a boss enemy object.

Secondly, remember that for Y values, 0 is at the top of the playing field and GetStgFrameHeight (default 448) is the bottom. Your provided code will make a bullet delete if it goes above the enemy lifebar in this screenshot.

(https://puu.sh/voVcN/d2a39c0f1d.png)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 19, 2017, 03:18:11 AM
It's really no problem. We go through long periods of inactivity and sudden spurts of activity just depending on who shows up.

With the timer code, you've mistaken what is going to happen. If your loop is while(time<10), and you're calling it (presumably) when the timer starts, the time will probably not be <10, so the condition will fail and the loop exits; the task then finishes. That's why it will just keep counting down; the task is already over.

I'm not sure what your TimerOut function is supposed to do, but if you want your task to wait for the timer to get down to 10, and then do something every second afterwards, it would look more like this:

Code: [Select]
task TimeCheck{
while(ObjEnemyBossScene_GetInfo(scene, INFO_TIMER) >= 10){
yield;
}
while(ObjEnemyBossScene_GetInfo(scene, INFO_TIMER) < 10){
TimerOut;
wait(60);
}
}
Except if you only need to check every second to see if it's under 10, swapping that yield for another wait(60) is a better idea.

EDIT: Actually, Sparen pointed out what the immediate problem is. If you're using the boss object (and not the scene object) as the first argument to GetInfo, GetInfo will just return 0. Because of this when you're checking for <10 the condition will always be true and when you check for >10 the condition is always false so it never ticks. However, even if you fixed this you'd run into the problem I described above anyway, so my advice is still valid.


I need to see more of the spellcard effect in order to see what you're actually telling it to do. The problem is likely not the if statement itself (it looks fine) but how it's set up. It might also be related to why you're getting lag, depending on what the underlying issue is.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Spacechurro on April 20, 2017, 07:02:51 AM
Quote
what is the code that calls TimeCheck()?
I put in in different places, but the code in written in a library, and I tried to call it in another code in the library that render's the boss's sprite, instead I made another task in the library "DoAll", and put in all the initialize of the singles. (The point of DoAll is to have a control of every Initialize script that applies to every single without having to change EVERY script), I only have TimeCheck; in it right now.
Code: [Select]
task DoAll{
TimeCheck;
}
and yes, I'm trying to make the graphic of the effect delete at the top in case it's not deleting at all and is accumulating.

Quote
I need to see more of the spellcard effect in order to see what you're actually telling it to do.

Oki doki, (and TimerOut is just a pre-loaded sound effect)

Code: [Select]
task SpellGraphic(frames,amount){
let frame = 0;

loop(frames){
if(frame==amount){
BEAMs;
frame=0;
}
frame++;
yield;
}
}

task BEAMs{
let r = rand(100,300);
let X = rand(0,2);
let movex = rand(-1,1);
let movexx = 0;
let move = 0;
let xx = GetPlayerX;
let yy = GetPlayerY-dist;
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj,SpellBall);
Obj_SetRenderPriorityI(obj,40);
ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
ObjRender_SetAngleXYZ(obj,0,0,0);
ObjRender_SetColor(obj,50,150,225);
ObjSprite2D_SetSourceRect(obj,0,0,100,100);
ObjSprite2D_SetDestRect(obj,-50,-50,50,50);
ObjRender_SetPosition(obj,GetPlayerX,GetPlayerY,0);

while(!Obj_IsDeleted(obj)){
ObjRender_SetPosition(obj,xx+movexx,yy,0);
ObjRender_SetScaleXYZ(obj,X,X,0);
yy-=15;
movexx+=movex;
X+=0.01;
if(ObjMove_GetY(obj)<10){Obj_Delete(obj);}
yield;
}
}

With the SpellCard task itself, I tested to see what was causing it by deleting the SpellGraphic tasks, and it stopped lagging, so I know it's that. But, each bomb makes it drop 10 fps, and it doesn't bump back up after the spellcard is over, it remains the same low fps. So that's why I tried to use the Obj_Delete to compensate for a possible accumulation (Still not sure if it's that that's happening or not).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 20, 2017, 07:24:31 AM
Note your SpellGraphic task can also be written
Code: [Select]
task SpellGraphic(num, amount){ // number of loops instead of frames
loop(num){
wait(amount);
BEAMs;
}
}

Whether you find that more useful or not is up to you.

Your effect code for the most part looks fine. You should be deleting the objects because they would just accumulate.

The problem is simply that you're calling ObjMove_GetY(obj) to check for position. 2D Sprite objects are not considered Move objects, so they cannot use that function. Instead, the function will just return 0 (i.e. the same problem as with checking the timer). Because of this if you're checking for >10, that will never be true, so the objects will not be deleted. Meanwhile if you check for <10 it will always be true, so the objects are immediately deleted. Simply use ObjRender_GetY(obj), or directly use yy.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zelinko on April 20, 2017, 03:52:08 PM
Is there a way to have Danmakufu continue to run itself when not center of attention?

I'm wanting to be able to record it without it being the active window.  Since I'm not wanting to have my computer being useless for 30 minutes while recording a replay.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: netugi on April 30, 2017, 09:54:15 PM
Issue with my custom Item Data script:
Whenever I try to run my game, I get an error: "item_image is not defined" in my item data script. I had a similar issue with shot data and somehow worked it out (not sure how unfortunately, was just playing around with stuff). I've read that "item_image" isn't a variable, so this leads me to believe that Danmakufu isn't recognizing it as an item script, meaning it's treating item_image as an undefined variable. Correct me if I'm wrong though.

This contains: item script, item data, and system script (portion)
https://pastebin.com/iGfLv7dy

Any help would be appreciated  :) 
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 01, 2017, 05:21:56 AM
item_image is not a "variable" because item data sheets aren't scripts to be executed; they're more like configuration files. item_image already has a predefined meaning and the program just checks for the line that says it.

Which should reveal what the problem is. You can't just plop GetCurrentScriptDirectory() in there because it isn't a script to be executed. The text "GetCurrentScriptDirectory()" makes no sense there. It should be something like
Code: [Select]
#UserItemData

item_image = "./filename.png"

ItemData{ //...

In filesystems a single dot . refers to the current directory and two .. refers to the parent directory.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: netugi on May 01, 2017, 06:54:29 PM
item_image is not a "variable" because item data sheets aren't scripts to be executed; they're more like configuration files. item_image already has a predefined meaning and the program just checks for the line that says it.

Which should reveal what the problem is. You can't just plop GetCurrentScriptDirectory() in there because it isn't a script to be executed. The text "GetCurrentScriptDirectory()" makes no sense there. It should be something like
Code: [Select]
#UserItemData

item_image = "./filename.png"

ItemData{ //...

In filesystems a single dot . refers to the current directory and two .. refers to the parent directory.

I think I was using ./ before and it wasn't working, which is why I switched to GCSD. I played around a bit more and the cause of my error was that I used #include [item data directory] in the stage script I was testing on. When I commented that out, it worked. However I'll stick with your advice in using ./ instead of GCSD, might save me headaches in the future. Thanks!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on May 05, 2017, 10:23:59 AM
So, uh, hi. This is my first post in this section. I'll probably tinker more with danmakufu over the next few weeks.

Right now, I'm trying to make a boss rush patch for Riverbed Soul Saver for someone on the discord channel. I'm just removing all of the stage portions, but keeping the midbosses.
It seems to work perfectly for the first, second, final, extra and phantasm stage, but for some reason, from stages 3-5, the stage will initiate the end animation after dialogue sections.
I'm not too sure what's causing this, which is why I'm posting here.

Here is a link to the patch, it replaced the Road files and just comments out the stage portions.
https://www.dropbox.com/s/e7bdbgk45ytiwtl/broken%20RSS%20boss%20rush.zip?dl=0
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: NLTM on May 11, 2017, 12:16:29 PM
So lemme preface this by saying I've been messing with Danmakufu for about 6 days now.  I have the very basics mostly down, and I've created at least one pattern I'm happy with (https://twitter.com/NLTM_/status/861736995630067713) just by dinking around. But now I'm starting to get in territory I don't quite understand.

The idea here is to count up phase in one loop, then switch to another when it reaches a certain value, and then reset it back to 0 and start it again. But for whatever reason, it never moves onto the second loop, and just does the first one forever. I've tried putting phase++ in different parts of the task, thinking it was just a syntax issue, but no luck. I'm sure there's a more efficient way of accomplishing this too, but I haven't gotten around to learning it yet.

Code: [Select]
task CircleShoot2{
wait(120);
let angleT=0;
let phase=0;

if(phase < 3){
loop{
loop(20){
ascent(i in -2..2){
let shot2 = CreateShotA1(ObjMove_GetX(objBoss) + 30 * sin(angleT), ObjMove_GetY(objBoss) + 30 * cos(angleT), 3, GetAngleToPlayer(objBoss) + i * 20 + 10 , 136, 5);
}
angleT += 360/20;
}
phase++;
wait(45);
yield;
}
}

if(phase >= 3){
loop{
loop(20){
ascent(i in -2..2){
let shot3 = CreateShotA1(ObjMove_GetX(objBoss) + 30 * sin(angleT), ObjMove_GetY(objBoss) + 30 * cos(angleT), 2, GetAngleToPlayer(objBoss) + i * 20 + 10 , 183, 5);
}
angleT += 360/20;
}
phase = 0;
wait(45);
yield;
}
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 11, 2017, 12:25:34 PM

Code: [Select]
loop {} never terminates until you forcefully make it exit via break; or return; I suggest using a while statement.

e.g.
Code: [Select]
while (phase < 3) {/* code */ phase ++;}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: NLTM on May 11, 2017, 12:44:14 PM
Code: [Select]
loop {} never terminates until you forcefully make it exit via break; or return; I suggest using a while statement.

e.g.
Code: [Select]
while (phase < 3) {/* code */ phase ++;}

Alright, got it. Thanks!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on May 11, 2017, 08:51:09 PM
I have a complex question, but I will ask it in a simple example:

Code: [Select]
let speed = 1;
ascent(i in 0..9){
        CreateShotA1( -, -, speed, 45 + i*10, -, -);
}

How do I make first three bullets with speed 1, next three with speed 2, and next three with speed 3.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 11, 2017, 09:06:24 PM
Could just use if statements, but speed = floor(i/3)+1 should do it.

0/3 = 0
1/3 = 0.333 -> 0
2/3 = 0.666 -> 0
3/3 = 1
4/3 = 1.333 -> 1

etc
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on May 11, 2017, 10:20:54 PM
Could just use if statements, but speed = floor(i/3)+1 should do it.

Thank you so much! I solved my problem with floor function, it's really helpful. I just wanted to know how to do this little space after each three numbers in score system. Like this: 000 000 000.

Code: [Select]
ascent(iObj in 0..9){
        ObjRender_SetX(obj, 508 + iObj*10 + floor((iObj)/3)*6);
...
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: NLTM on May 12, 2017, 09:51:51 AM
So the idea here is to have some bullets spew out some more bullets whenever they touch, and it works, but only when they touch the first time (ie when they spawn in) and then never again. I thought it was because a distance of less than or equal to 1 or 10 was too small, but tweaking that doesn't seem to help. Setting it to a high number like 80 or something will have them spawn more bullets for a while longer, but then once they exit that distance, even when they get close again, they won't do anything.

Code: [Select]
task Shoot{
wait(120);
let AngleTRed = 45;
let AngleTBlue = 135;
loop{
let objShotRed = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 3, AngleTRed, BUBBLE_RED, 5);
AngleTRed += rand(85,90);
Reflect(objShotRed);

let objShotBlue = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 3, AngleTBlue, BUBBLE_BLUE, 5);
AngleTBlue += rand(85,90);
Reflect(objShotBlue);

while(GetObjectDistance(objShotRed, objShotBlue) <= 10){
CreateShotA1(ObjMove_GetX(objShotRed), ObjMove_GetY(objShotRed), 1, rand(0,360), DOT_PURPLE, 5);
CreateShotA1(ObjMove_GetX(objShotBlue), ObjMove_GetY(objShotBlue), 1, rand(0,360), DOT_PURPLE, 5);
yield;
}

wait(300);
yield;
}
}

Also, bizarrely, setting up a variable like
Code: [Select]
let Distance = GetObjectDistance(objShotBlue, objShotRed); and then calling that in the while loop just makes the bubbles spew bullets 100% of the time? I mean, I can pretty easily just type out the full GetObjectDistance function, but it was just strange.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 12, 2017, 03:52:59 PM
This is a fairly complex problem and you're underthinking it.

When you call CreateShot, it returns that new object's ID, which is then stored in your objShotRed/Blue variables. You immediately get to the while statement, and because their spawn points are the same the loop executes and you get the bullets. But if for example the spawn points were different, then they would be too far away, and because the while statement is only tried immediately it will fail and they wouldn't even spawn bullets once they touch for the first time.

Okay, so would they at least check for collision again once every 300 frames if they just happened to collide? No. When the loop restarts, the objShotRed/Blue variables are reset with new object IDs, and so the first ones are tossed away and will never be checked again. This is why it currently only happens "once"; because it literally only ever checks on one frame. So now you have the problem where you want to be able to check on every frame whether those bullets are colliding, but you also want to be able to fire more of the colliding bullets at the same time. This can be done without much modification.

I'm not sure why you would store the value of GetObjectDistance in a variable and try to use that instead. The variable represents the value, not the calling of the function. If you set it before the while loop and then asked (distance < 10) it would just always stay true.

The problem gets more complex if you want every red bullet and every blue bullet to be able to collide with each other, rather than just each individual fired pair of red and blue. Is this your intention?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: NLTM on May 12, 2017, 07:10:08 PM
Hmm.... My intention was to have every red and blue bullet be able to collide, but I might drop the idea until I learn a little more, I didn't realize I was in over my head. I appreciate the help!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 12, 2017, 07:48:28 PM
No problem. I actually have an example solution and demonstration of the programming pattern because this shows up every so often:
https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1230565.html#msg1230565
https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1234079.html#msg1234079
https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1234229.html#msg1234229

But whether you can get what's going on here is another thing entirely. Take a peek if you want.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: NLTM on May 12, 2017, 07:56:37 PM
Ah, that does help! My first instinct when you told me what was wrong was to say "maybe I can write each object to an array" so I guess I was on the right track, even if I didn't know exactly how to implement that, which makes me feel a little more confident.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: LunaticRabbit on May 15, 2017, 07:50:00 PM
I've been trying to make a plural, so I have to make sure the singles delete themselves. That should be easy but I have little enemies objects beside the boss running around in the singles. After the single ends, the enemy keeps on moving then fires a little, and then it ends itself, kinda late. I've gotten everything else to delete itself properly except that. When the single ends, I'm not sure how to make the moving enemy object delete itself in time with the rest of the single.

Also, I just want to say these Q&A threads are really nice and helpful.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 16, 2017, 01:08:14 PM
I've been trying to make a plural, so I have to make sure the singles delete themselves. That should be easy but I have little enemies objects beside the boss running around in the singles. After the single ends, the enemy keeps on moving then fires a little, and then it ends itself, kinda late. I've gotten everything else to delete itself properly except that. When the single ends, I'm not sure how to make the moving enemy object delete itself in time with the rest of the single.

Also, I just want to say these Q&A threads are really nice and helpful.

From what I can guess, you have an issue with object deletion.

Your extra enemies, in their main loop/looping task, should have a check to see if the main boss's HP < 0. If the main boss's HP < 0, then they should do whatever they need to do and then delete.

Alternatively, setting object auto delete to true may also work, but you still need to ensure that the enemies behave as you want them to.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on May 17, 2017, 07:10:31 AM
I've gone through all of Sparen's ph3 tutorials, and they are very well written (though I still don't think I can design anything :P).

That said, are there any available resources to learn about stage/package scripts?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 17, 2017, 04:20:53 PM
I've gone through all of Sparen's ph3 tutorials, and they are very well written (though I still don't think I can design anything :P).

That said, are there any available resources to learn about stage/package scripts?

Prod me until I write guides. :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on May 18, 2017, 07:40:06 AM
How can I render
Code: [Select]
OBJ_SPRITE_2D_LIST in
Code: [Select]
OBJ_SPRITE_2D
I tried to use RenderToTextureB1(...); but it didn't help a lot (or I used it wrong).
The main aim is to change alpha of sprite_2d_list in loop{}. ObjRender_SetAlpha(...); doesn't work on sprite lists.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 18, 2017, 09:56:59 AM
Yes it does, you are probably using it incorrectly. Sprite Lists work by having you set up a single sprite, completely, and then adding it to the list of sprites to finalize it. Once you do that you cannot modify the previous sprite by itself anymore. Calling functions to modify the sprite are modifying the next sprite to be added, and anything you don't change (such as the sprite texture, render priority, etc) will also still apply to the next sprite.

Once the whole sprite list is finished, you can then call ObjSpriteList2D_CloseVertex on the object. This finalizes the sprite list, and any following modifications are applied to the whole object.

So to do what you want, you could either call ObjRender_SetAlpha once per sprite before you add them to the list, or call SetAlpha once before adding any sprites to the list so they are all affected, or to modify the whole thing after you build the list you can close the list with CloseVertex and then call SetAlpha once.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Skilvrel on May 21, 2017, 07:24:35 PM
So after tinkering around on my own, I'm still unable to make any sort of dialogue function. I've got the following functions that work to create the sprites and text and display them, but I've no idea how to put it into the stage/plural/single/whichever script I should use. I think I can use while(GetVirtualKeyState(VK_SHOT) != KEY_PUSH) {yield;} to keep the system from displaying the next part of the text and sprite, but I don't know how to make it stop the spellcards from starting.

https://pastebin.com/MCMsMxXx
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 22, 2017, 12:34:22 AM
but I don't know how to make it stop the spellcards from starting.

Use a function or subroutine instead of a task. Those will run in serial and any waits in them will stall whatever called them.

EDIT: To be clear, this is what I mean:

task Stage {

    //Stuff

    Dialogue;

    //Boss, stuff
}

sub Dialogue {
    //Text, dialogue, images, etc.
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Skilvrel on May 22, 2017, 07:10:49 PM
Perfect. Looks like I've got it working almost the way I want it now. There's only one thing I can't seem to find a solution to. Is there a way to make the text automatically linebreak at a space?

Essentially I want

"Here is a whole lot of writing to test width of text function."

To come out

"Here is a whole lot of writing to test
width of text function"

instead of

"Here is a whole lot of writing to test wi
dth of text function"

without having to manually add a [r] for newline at the specific location.

And less important but still a little annoying, how do I make a player character not shoot during dialogue?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 22, 2017, 07:35:59 PM
Perfect. Looks like I've got it working almost the way I want it now. There's only one thing I can't seem to find a solution to. Is there a way to make the text automatically linebreak at a space?
And less important but still a little annoying, how do I make a player character not shoot during dialogue?

First one: afaik no. Additionally, fonts may render differently on different machines, so where you insert a [r] will depend on the font type, font size, and word length.

http://dmf.shrinemaiden.org/wiki/Player_Functions#SetForbidPlayerShot (http://dmf.shrinemaiden.org/wiki/Player_Functions#SetForbidPlayerShot)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 23, 2017, 01:51:26 AM
You can use ObjText_GetTotalWidth to check if a textbox renders beyond a certain length. Then you'd have to check for where you want to split or something.
Anyways here's one solution I scrubbed together. It's only valid for two lines (i.e. one break) because anything more than that requires much more serious thought.

Code: [Select]
function ObjText_SetTextAutoLine(obj, s, len){
ObjText_SetText(obj, s);
let a = [];
ascent(i in 0..length(s)){
if(s[i] == ' '){ a = a ~ [i]; }
}
descent(i in 0..length(a)){
if(ObjText_GetTotalWidth(obj) < len){ return; }
ObjText_SetText(obj, s[0..a[i]] ~ "[r]" ~ s[a[i]..length(s)]);
}
ObjText_SetText(obj, s);
ObjText_SetMaxWidth(obj, len);
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on May 26, 2017, 01:19:38 PM
Hi,I'm new to everything since I only used it not long. I'm using this code,

@Initialize{
     objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
    ObjEnemy_Regist(objBoss);
    let imgShikiekiki = GetCurrentScriptDirectory() ~ "Shikiekiki.png";
    ObjPrim_SetTexture(objBoss, imgShikiekiki);
    ObjSprite2D_SetSourceRect(objBoss, 45, -50, 45, 50);
    ObjSprite2D_SetDestCenter(objBoss);
    ObjMove_SetDestAtFrame(objBoss, GetCenterX(), 60, 60);
    TFinalize;
    MainTask;
}

However, The picture i wanted is not showing up, even i put the picture on the folder  ??? ??? :derp: :derp:
Why and how ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on May 26, 2017, 04:05:33 PM
@Initialize{
    ObjSprite2D_SetSourceRect(objBoss, 45, -50, 45, 50);
}
I am not sure how your Shikiekiki.png looks like, but the coordinates for SetSourceRect is 'top' , 'left',  'bottom' , 'right'.

Basically you're telling the game to draw the image using Y: 45 of your image as top coordinate and Y:45 as bottom coordinate, which results in 0 pixels as height. And I am not sure how -50 to 50 is picked up by the game.

Perhaps take a look at a video tutorial here: https://www.youtube.com/watch?v=dKSe8s9FsAc#t=6m50s
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on May 30, 2017, 01:10:45 PM
The picture graphic is 70x100, it's a png. And by the way, why do images get .txt line in it ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on May 30, 2017, 02:33:59 PM
This is my another question (due last question came from Sparen's code), when im doing exact your tutorial, when i run ph3, they said "}" is neccesary.
This is my code : // texture the boss, set centre as true centre.
                             ObjPrim_SetTexture(bossObj,imgBoss);
                             ObjSprite2D_SetSourceRect(bossObj,0,0,70,100)
                             ObjSprite2D_SetSourceCenter(bossObj);  <--- This is the problem line

Note : The error line will be 19
 
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Badz on May 30, 2017, 06:01:01 PM
This is my another question (due last question came from Sparen's code), when im doing exact your tutorial, when i run ph3, they said "}" is neccesary.
This is my code : // texture the boss, set centre as true centre.
                             ObjPrim_SetTexture(bossObj,imgBoss);
                             ObjSprite2D_SetSourceRect(bossObj,0,0,70,100)
                             ObjSprite2D_SetSourceCenter(bossObj);  <--- This is the problem line

Note : The error line will be 19
The second line is missing a semicolon. I think Danmakufu lets you get away with that if there's a closing bracket right after the line, so that's why it decided on that particular error message.
Danmakufu error messages in general tend to be a bit misleading, so it's usually a good idea to look at the code before the specific line it points out to see if the error could be there.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 30, 2017, 06:54:09 PM
If there are errors in my tutorials, PLEASE PLEASE PLEASE notify me so that I can fix them.

Also, if the error is on my side, please tell me which lesson has the error.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on May 31, 2017, 06:50:32 AM
Thanks, it worked ,but this problem still is on my mind.

let imgBoss = GetCurrentScriptDirectory ~ "Shikiekiki.png";
however, my pic,I told you last time, does not appear
* I named it correctly (pic name is Shikiekiki.png.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on May 31, 2017, 09:08:50 AM
Please show your entire script code through pastebin.com because this isn't working.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on May 31, 2017, 01:49:09 PM
I uploaded it, username is BananaCupcake.
https://pastebin.com/jnUjjxFN
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 31, 2017, 02:20:00 PM
I uploaded it, username is BananaCupcake.

Please include a link to the paste for easy reference. I.E. https://pastebin.com/zhrqhAy7
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on May 31, 2017, 04:26:39 PM
Copy pasted your code and used an image with 70x100 dimensions called Shikiekiki.png. The image is in the same directory as the script and I can see the boss appearing.

Conclusion: What ever is happening on your end has to do with your image. Make sure the image is valid and not faulty.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 01, 2017, 02:00:01 AM
I know you said you named it properly, but just make sure you're even using "Shikiekiki" instead of the actually-correct-name "Shikieiki".
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on June 01, 2017, 03:22:53 AM
I can't use google pics , right ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 01, 2017, 04:50:39 AM
I can't use google pics , right ?

?????

What do you mean by this? It has nothing to do with the filename you assign to your texture assets.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on June 01, 2017, 05:01:01 AM
The pic that is downloaded from google and edited to 70x100.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 01, 2017, 05:14:03 AM
That is fine. Just make sure you had actually saved it as a png, as your filename implies.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on June 01, 2017, 06:35:21 AM
Its a png, never worked....  :ohdear: :ohdear:
It ran safely... but the sprite sucked, its the same stuff  :ohdear: :ohdear:
The sprite never worked ! I did every step correctly(perfect), the sprite did not appear. though
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: strgzrrr on June 01, 2017, 07:19:21 AM
hi, I would like to ask a simple question.

maybe someone could teach me how ObjMove_SetDestAtWeight works?
I know how it pragmatically works, but I hope to know the actual formula. and the known explanations are very vague...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 02, 2017, 06:38:15 AM
It's piecewise. ObjMove_SetDestAtWeight seems to be:
Code: [Select]
if dist < maxspeed * weight :
  speed = dist / weight
else :
  speed = maxspeed

That being said the implementation being used seems to be not super exactly accurate, but it's probably fine for most purposes.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: strgzrrr on June 02, 2017, 06:52:44 AM
It's piecewise. ObjMove_SetDestAtWeight seems to be:
Code: [Select]
if dist < maxspeed * weight :
  speed = dist / weight
else :
  speed = maxspeed

That being said the implementation being used seems to be not super exactly accurate, but it's probably fine for most purposes.

my thanks for your reply. i found it very helpful.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on June 02, 2017, 09:08:43 AM
Ok, I think the graphic must be a problem. 1. how to know its a transparent pic ? 2.Do Transparent pic affect the character appearance ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on June 02, 2017, 10:58:10 AM
Ok, I think the graphic must be a problem. 1. how to know its a transparent pic ? 2.Do Transparent pic affect the character appearance ?
If it is a PNG file and you open it photoshop, gimp or similar programs: the background around the character should be like a checkered board. Pure black (0,0,0) is also transparent. These two things should indicate if a picture has transparency or not. Don't use paint or irfanview.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on June 02, 2017, 02:46:24 PM
Ok, after using GIMP 2 , i saw checkered boxes (it said it was alpha channel) and i knew it was transparent, so it was the script, but why ? where did i did wrongly ? I made a pic that is the same way and it's valid but it didn't loaded it, so i knew that its the scripts fault, but where ? ??? ???
*its the same script , never changed.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 02, 2017, 05:18:21 PM
Ok, after using GIMP 2 , i saw checkered boxes (it said it was alpha channel) and i knew it was transparent, so it was the script, but why ? where did i did wrongly ? I made a pic that is the same way and it's valid but it didn't loaded it, so i knew that its the scripts fault, but where ? ??? ???
*its the same script , never changed.

Let's confirm. You have a file called Shikiekiki.png in the SAME FOLDER as your script (.txt/.dnh/whatever). It is 70x100 and is a png. File extensions are not disabled (i.e. if you look at the folder using Windows, you see the .png extension).

In Danmakufu, the image for the boss does not appear at all, but the shots are still fired from (192, 120).

Is ALL OF THIS correct? If there are any inconsistencies, then your problem may lie there.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on June 02, 2017, 05:20:51 PM
It is not your script. I've already shown it to you here in my post (https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1345135.html#msg1345135) that your code is working fine. You're doing something that we cannot see or judge. Again make sure the following:
- Your filename is correctly written according to the script
- Your image file is in the same folder as your script (because you're using GetCurrentScriptDirectory)
- Your image file is a valid PNG format

Again, it is not your script. If you still cannot manage it, then I am out of ideas/clues.

Edit
Warning - while you were typing a new reply has been posted. You may wish to review your post.
Sparen had similar ideas (posted. I'll post mine either way as extra info.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on June 02, 2017, 09:49:09 PM
How do you make spinning bullets like the ice crystals/petals in this spell? (https://youtu.be/P1wG_1w6Tcw?t=5m27s)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 02, 2017, 10:18:12 PM
How do you make spinning bullets like the ice crystals/petals in this spell? (https://youtu.be/P1wG_1w6Tcw?t=5m27s)

Adjust ObjRender_SetAngleZ in a while(!Obj_IsDeleted(obj)) loop.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on June 03, 2017, 03:14:43 AM
It worked, it was so legit that i forgotten the png, the pic was shikieiki.png , and i forgotten a .png because its a png file too , so. thanks for everything and apologies for my annoyancys :D :3
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on June 03, 2017, 03:19:51 PM
Hmmm hello, I'm still learning danmakufu and I'm trying to create a plural script, but apparently every tutorial I've seen is outdated and the script simply doesn't appear in danmakufu. Someone please link me an updated tutorial?

EDIT: Whoops, apparently I forgot to put quotation marks in the script text... It's working now.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 03, 2017, 04:50:50 PM
Hmmm hello, I'm still learning danmakufu and I'm trying to create a plural script, but apparently every tutorial I've seen is outdated and the script simply doesn't appear in danmakufu. Someone please link me an updated tutorial?

Danmakufu Wiki ph3 Tutorials:
http://dmf.shrinemaiden.org/wiki/Tutorials_(ph3) (http://dmf.shrinemaiden.org/wiki/Tutorials_(ph3))

Make sure you're not confusing 0.12m with ph3.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on June 03, 2017, 05:00:05 PM
It worked, it was so legit that i forgotten the png, the pic was shikieiki.png , and i forgotten a .png because its a png file too , so. thanks for everything and apologies for my annoyancys :D :3
My apologies. To be honest, I didn't understand how you fixed it. But roughly guessing it is like Sparen said with the hidden extensions. You most likely had a file being *.png.png
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on June 03, 2017, 11:18:02 PM
This question is a bit of an odd one. I want to make everything within the playing field (boss, bullets, player, background) continually spin, akin to Change Air Brave. How would I go about doing this? (yes this sounds stupid but please answer)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 04, 2017, 02:57:08 AM
This question is a bit of an odd one. I want to make everything within the playing field (boss, bullets, player, background) continually spin, akin to Change Air Brave. How would I go about doing this? (yes this sounds stupid but please answer)

Just wrote up something for it.

http://sparen.github.io/ph3tutorials/ph3u2l22a.html

Essentially, use Set2DCameraAngleZ in a while loop.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Skyler on June 04, 2017, 09:44:06 PM
I've been trying to get custom sounds to play during spellcard activation and the boss's death using Helepolis's tutorials, but for some reason only the default sounds will play. I've checked the code a bunch of times - even copy&pasted the sound-related parts directly from the example file - but the result is the same every time. Danmakufu doesn't give any errors, the sounds just don't seem to be registering at all.

The .wav files are in the same folder as the script. I'm very new to this & feel like I must be missing something incredibly simple, but I have no idea what it is... :ohdear:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on June 04, 2017, 10:04:27 PM
I've been trying to get custom sounds to play during spellcard activation and the boss's death using Helepolis's tutorials, but for some reason only the default sounds will play. I've checked the code a bunch of times - even copy&pasted the sound-related parts directly from the example file - but the result is the same every time. Danmakufu doesn't give any errors, the sounds just don't seem to be registering at all.

The .wav files are in the same folder as the script. I'm very new to this & feel like I must be missing something incredibly simple, but I have no idea what it is... :ohdear:

Could you please give an example of the code? also make sure you didnt mute danmakufu
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Skyler on June 04, 2017, 10:58:44 PM
Could you please give an example of the code? also make sure you didnt mute danmakufu

https://pastebin.com/F7NPVQVZ This is all the code that has to do with the sounds, I think. (& I didn't mute it lol I can still hear the default stuff)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on June 04, 2017, 11:19:46 PM
https://pastebin.com/F7NPVQVZ This is all the code that has to do with the sounds, I think. (& I didn't mute it lol I can still hear the default stuff)

You said your .wav files are in the same folder as the script itself? The reason it's not playing is because in lines 5 & 6, the "se/" means that its looking for the wav files in a folder called se, which you apparently don't have.

You can fix that by making a folder called "se" in the same folder as your script and dumping your wav files in there, like so
 (http://i.imgur.com/n3q6s9A.png)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 04, 2017, 11:34:11 PM
I've been trying to get custom sounds to play during spellcard activation and the boss's death using Helepolis's tutorials, but for some reason only the default sounds will play. I've checked the code a bunch of times - even copy&pasted the sound-related parts directly from the example file - but the result is the same every time. Danmakufu doesn't give any errors, the sounds just don't seem to be registering at all.

The .wav files are in the same folder as the script. I'm very new to this & feel like I must be missing something incredibly simple, but I have no idea what it is... :ohdear:


~~~

https://pastebin.com/F7NPVQVZ This is all the code that has to do with the sounds, I think. (& I didn't mute it lol I can still hear the default stuff)

~~~

I had this problem for a long time and didn't understand why it happened. There are two issues and a variety of solutions.

Your current issue is that you're trying to load the sound immediately before playing it. The sound effect has no time to load and therefore does not play.

The default plays because the default spell card sound effect is controlled via the EV_START_BOSS_SPELL event in the system script. If you are not using a custom System script, this means that the default will do its job.

To fix, you can either forcefully load the sound effect in advance using @Loading{} (Note: Haven't tried, may not work) or play with System files.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on June 05, 2017, 02:54:11 AM
Sparen finally finished the lesson!

...does that mean you'll write tutorials for stage scripts now :V
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 05, 2017, 12:42:34 PM
Sparen finally finished the lesson!

...does that mean you'll write tutorials for stage scripts now :V

If I can be prodded enough to write at a more frequent pace, yeah. However, the peer review factor has fallen short recently, and I'm entering the area of Danmakufu where there are lots of different ways to achieve the same thing. I'll try but I can't guarantee very much at the moment.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on June 05, 2017, 03:28:24 PM
lel its another stupid question from me.
I try to fire a ring of bullets like the script here https://pastebin.com/yeQg5Dj5 , after i load it, its not defining my mainTask ! Why ?  ???
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 05, 2017, 04:53:19 PM
lel its another stupid question from me.
I try to fire a ring of bullets like the script here https://pastebin.com/yeQg5Dj5 , after i load it, its not defining my mainTask ! Why ?  ???

Hint: Do your { and } match up? Take a good look at @Event.

EDIT: Also take a good look at @Finalize.

In general, if there is a 'X not defined' error and it's definitely defined, you have an error with your { blocks }. It is highly recommended that you use a text editor that shows you whether or not your parenthesis and braces are matching, and when in doubt do a Ctrl-F to see if the number of { is the same as the number of }. If they aren't, you have a problem and you should check your code carefully.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on June 06, 2017, 12:26:11 PM
Hello!
I've been using danmakufu for a while now, but I was wondering if anyone could tell me how to create a triangle or a square (or other things like that) in danmakufu. I've been trying to create shapes other than circles and diamonds, but I have no idea what to do.  :ohdear:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 06, 2017, 02:10:28 PM
Hello!
I've been using danmakufu for a while now, but I was wondering if anyone could tell me how to create a triangle or a square (or other things like that) in danmakufu. I've been trying to create shapes other than circles and diamonds, but I have no idea what to do.  :ohdear:

This question is asked like every few months. Honestly someone should just compile the methods and post it on the Wiki. :|
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 07, 2017, 08:01:47 AM
Getting to shoot shapes isn't even that good for making decent bullet patterns but everyone wants to know anyway lol

This (https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1235583.html#msg1235583) was the last version I remember writing? Reposting here. Explanation and math (https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1235405.html#msg1235405) was also a few posts above.

Code: [Select]
function CreateShotShapeOA1(obj, sides, gap, speed, angle_off, graphic, delay){
let x = ObjMove_GetX(obj);
let y = ObjMove_GetY(obj);
let t = 0;
while(t < 360){
let r = cos(180/sides) / cos(((t - angle_off) % (360/sides)) - (180/sides));
CreateShotA1(x, y, r * speed, t, graphic, delay);
t += gap;
}
}

When shooting a shape outwards, you can interpret the "radius" of a point in a shape as a speed value, multiplying it for a faster shape. Basically "increase the radius of the shape by speed each frame".

Meanwhile spawning the shape at a location and size is also a matter of multiplying ("give the shape a certain radius size") and converting back to x,y coordinates, so

Code: [Select]
CreateShotA1(x + size*r*cos(t), y + size*r*sin(t), s, a, g, d);
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on June 07, 2017, 03:08:53 PM
Hello!
Does anyone know how to make triangles or squares in danmakufu?

Edit:
(Oops, didn't know this was already answered. Don't mind the other message I sent).
Is there a way to do this without resorting to functions? Sure, it'll be much easier to control and such but I'm just wondering.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on June 07, 2017, 04:19:27 PM
I know this is a stupid question , so that after i finished the script , (its the same script) however, i didn't realize that i forgotten the finalizing .
I tried every way to do it but it seems its not even working, So, how to do the finalize the most convenient and easiest way ? :3
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on June 07, 2017, 05:20:03 PM
Hello!
Does anyone know how to make triangles or squares in danmakufu?

Edit:
(Oops, didn't know this was already answered. Don't mind the other message I sent).
Is there a way to do this without resorting to functions? Sure, it'll be much easier to control and such but I'm just wondering.
Probably there is, though, why would you try to make your life more difficult?


I know this is a stupid question , so that after i finished the script , (its the same script) however, i didn't realize that i forgotten the finalizing .
I tried every way to do it but it seems its not even working, So, how to do the finalize the most convenient and easiest way ? :3
I am having trouble understanding your question, but do you mean your script doesn't close? Are you using the CloseScript function to close your script? Also, forgive me for sounding rude but I would highly recommend you to follow either the video tutorials or written tutorials. These questions are really covered in those.

OT: Curious though, where are you from? Could it be that English isn't the common language for you?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 07, 2017, 10:45:43 PM
Is there a way to do this without resorting to functions? Sure, it'll be much easier to control and such but I'm just wondering.
wat

that question doesn't even make sense, please explain
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on June 08, 2017, 12:14:20 PM
a. I'm not sure about it, because I compared to the script that is almost the same on your tutorial 4 (I didn't put BGM's). Here https://pastebin.com/8Z1VdYhu.
b.Your not rude :)
c. Its right, mine English sucks,  :blush: :blush: I came from Southeast Asia so I didn't communicate with English with my family and friends .

*The script says TEnd; its not defined.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 08, 2017, 12:32:33 PM
*The script says TEnd; its not defined.

If it's not defined, then define it. :|
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on June 08, 2017, 12:38:59 PM
a. I'm not sure about it, because I compared to the script that is almost the same on your tutorial 4 (I didn't put BGM's). Here https://pastebin.com/8Z1VdYhu.
b.Your not rude :)
c. Its right, mine English sucks,  :blush: :blush: I came from Southeast Asia so I didn't communicate with English with my family and friends .

*The script says TEnd; its not defined.
a. >> I doubt you're doing the same, because otherwise you wouldn't get that error. Defining tasks or functions is done using:  task nameOfYourTask { } or function nameOfYourFunction{ }. You can't just call TEnd if you never defined it. That goes for any task / function or sub routine.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on June 08, 2017, 02:00:54 PM
I still don't understand . its the maintask or the task TEnd ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on June 08, 2017, 06:23:17 PM
I still don't understand . its the maintask or the task TEnd ?
To be honest, I have no idea what you're asking me and also I have no idea how to even explain this better than the tutorials.

Please read Sparen's tutorial about "How do I close the script" (http://sparen.github.io/ph3tutorials/ph3u1l6.html#sub7)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 10, 2017, 07:19:25 AM
Looking at the pastebin, BananaCupcakey is missing a closing curly bracket } at the end of the `fire` task.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: TheTeff007 on June 10, 2017, 08:13:14 AM
What would be the ph3 equivalent of the ObjEffect_SetVertexXY function?

I'm trying to port my old danmaku script into ph3 but the wiki doesn not provide it's equivalent.

Thanks in advance
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on June 10, 2017, 05:41:40 PM
What would be the ph3 equivalent of the ObjEffect_SetVertexXY function?

I'm trying to port my old danmaku script into ph3 but the wiki doesn not provide it's equivalent.

Thanks in advance

http://dmf.shrinemaiden.org/wiki/Primitive_Object_Functions#ObjPrim_SetVertexUV

i think it's this, not sure
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on June 10, 2017, 05:43:27 PM
What would be the ph3 equivalent of the ObjEffect_SetVertexXY function?

I'm trying to port my old danmaku script into ph3 but the wiki doesn not provide it's equivalent.

Thanks in advance
If I didn't misunderstood, I believe for vertex position it is ObjPrim_SetVertexPosition and for setting its textures it is ObjPrim_SetVertexUVT. You'll have to use ObjPrim_Create(OBJ_PRIMITIVE_2D); and choose a ObjPrim_SetPrimitiveType though.

Edit: Oh lollipop was before me.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Satorioshi on June 11, 2017, 10:30:06 AM
I'm currently working on an English Patch for the fangame Touhou Riverbed Soulsaver.
I'm currently doing the Phantasm stage. After defeating the Midboss Ruri, this message appears.

Code: [Select]
_NextChar:すでに文字列終端です
I'm not sure what this is supposed to mean. This message appears with all three characters at the same point. The only code I have changed was the text in the dialog.

So, does anyone have an idea what causes this kind of Error?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on June 11, 2017, 10:44:49 AM
I'm currently working on an English Patch for the fangame Touhou Riverbed Soulsaver.
I'm currently doing the Phantasm stage. After defeating the Midboss Ruri, this message appears.

Code: [Select]
_NextChar:すでに文字列終端です
I'm not sure what this is supposed to mean. This message appears with all three characters at the same point. The only code I have changed was the text in the dialog.

So, does anyone have an idea what causes this kind of Error?
Memory is fuzzy, I remember running into this problem with my own game. Most likely you're breaking the commenting code such as // or /* causing the script to mess up major. Or you broke the file by saving it without Japanese font support (encoding such as SHIFT JIS or UTF-8).

Back tracking this error is nearly impossible unless the game is giving you a file name or line number.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 11, 2017, 11:05:46 AM
There is no dialogue after the midboss, so that was a bit confusing. Looking into the scripts, the stage script immediately starts loading the following boss:

Code: [Select]
// 次ボスロード開始
compile_file_h[1] = LoadScriptInThread(plural[1]);
LoadBossScript(compile_file_h[1]);

Considering this, something is probably going wrong in the boss script's dialogue instead (if you're only modifying those). Look in that direction.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Satorioshi on June 11, 2017, 11:11:27 AM
Whoa, thanks for the quick help.
I found the problem. RSS has this method of little overtexts, that appear in some dialogs, to add a second meaning to the text.
Not sure if that's understandable. But by cutting those out, I was able to make it run properly.
So it's working now.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 11, 2017, 11:48:40 AM
Oh, that's just rubytext. It would be good to know how to format this, considering it's part of the dialogue. Did this not come up previously?

A rubytext string should look like "text [ruby rb=\"bottom\" rt=\"top\"] more text"
You should make sure the formatting there is all correct; the bolded parts are necessary.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gregory on June 12, 2017, 06:24:58 AM
a question, how can I make Reimu's boundary field ?

TIA
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on June 12, 2017, 07:45:09 AM
a question, how can I make Reimu's boundary field ?

TIA
To be honest, this question is in my opinion way to generic and in the same league as: "Please make this spell card for me".

Could you be a bit more specific what exactly you want to know in order to simulate one of her spell cards?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gregory on June 12, 2017, 09:35:02 AM
To be honest, this question is in my opinion way to generic and in the same league as: "Please make this spell card for me".

Could you be a bit more specific what exactly you want to know in order to simulate one of her spell cards?

sorry, I mean how's the mechanic works, because I'm still new to danmakufu so I want to see how the mechanic looks like
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 12, 2017, 12:15:17 PM
sorry, I mean how's the mechanic works, because I'm still new to danmakufu so I want to see how the mechanic looks like

There are going to be a variety of different implementations. Personally I would assign each bullet a value and using that value, determine which boundary the bullet is in. Depending on the value, I would move the bullet to a different position when they are in a certain part of the screen, and change angle/etc. accordingly.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on June 13, 2017, 10:41:00 AM
How do I make a bullet glow?
When tinkering with various shotsheets and RSS, I could spawn "glow orbs" but they didn't glow. I assume it's done with bullet draw functions, but I couldn't figure out how to do it or where the 'glowing' code was.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on June 13, 2017, 10:44:14 AM
using pure black background (rgb 0,0,0) (not necessary required) and ADDITIVE rendering will make the bullets appear glowy. The way the bullet is designed also helps in enhancing this look.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on June 13, 2017, 12:38:02 PM
using pure black background (rgb 0,0,0) (not necessary required) and ADDITIVE rendering will make the bullets appear glowy. The way the bullet is designed also helps in enhancing this look.

Do you mind explaining which functions I should use? I don't really understand how it works.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 13, 2017, 01:09:43 PM
Do you mind explaining which functions I should use? I don't really understand how it works.

There are two options: You can define the bullets to be ADD_ARGB or ADD_RGB in the shot sheet (ARGB if your bullet graphic uses alpha for glow and RGB is your bullet graphic has a black background) or in-game, by using ObjRender_SetBlendType.

What are the Properties of a Shot in a Shotsheet? (http://sparen.github.io/ph3tutorials/ph3u1l8.html#sub3)
Utilizing Blend Types in Danmakufu (http://sparen.github.io/ph3tutorials/ph3u2l14.html)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on June 13, 2017, 03:23:21 PM
Ah, thanks for the help. I'd thought I needed to supply values to a function or something, but using the blend type makes it a lot easier.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: stormfire101 on June 14, 2017, 04:30:30 PM
I've run into a situation... I wanted to try and do a detailed background split up into three sections. I used 3d sprite objects split up by tiles roughly 3 to a section(so I can easily have it loop) and layers and create them all at the start, however looking at the object count  and the frame that I think is caused by it in the end I feel like I feel like I'm missing something... I'm using SetCameraPerspectiveClip to try and control how many things I render but is there some way to use 2dspritelist or something to combine the all the tile sections and still display them in 3d... or is there some other trick I'm missing, any help would be much appreciated.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 14, 2017, 05:04:45 PM
I've run into a situation... I wanted to try and do a detailed background split up into three sections. I used 3d sprite objects split up by tiles roughly 3 to a section(so I can easily have it loop) and layers and create them all at the start, however looking at the object count  and the frame that I think is caused by it in the end I feel like I feel like I'm missing something... I'm using SetCameraPerspectiveClip to try and control how many things I render but is there some way to use 2dspritelist or something to combine the all the tile sections and still display them in 3d... or is there some other trick I'm missing, any help would be much appreciated.

If you can provide screenshots so that we can see what you are trying to do, we may be able to provide a better option. Additionally, please provide the code you currently have for reference.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: lolpudding on June 15, 2017, 01:13:53 AM
Hello again! So I was wondering if it was possible to implement a life extend for every 2,000,000 points. I vaguely remember seeing a post about this before but I am not sure.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 15, 2017, 02:28:28 AM
Hello again! So I was wondering if it was possible to implement a life extend for every 2,000,000 points. I vaguely remember seeing a post about this before but I am not sure.

It's possible. In your System script (or wherever you choose to keep track), set up a task to track score. If currscore > threshold, add extend and increase threshold by 2m.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: lolpudding on June 15, 2017, 07:39:41 PM
It's possible. In your System script (or wherever you choose to keep track), set up a task to track score. If currscore > threshold, add extend and increase threshold by 2m.

Ah, okay thank you.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on June 17, 2017, 08:03:21 AM
I'm working on a script, and one of my spells seems to crash randomly when the spell ends, whether or not it's a capture. It's not replicable all the time, but I think it's caused by these two tasks.

https://pastebin.com/35vRnyVN
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 17, 2017, 11:39:05 AM
Does the script stop crashing if you remove these? They seem pretty innocuous.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on June 17, 2017, 01:15:42 PM
Does the script stop crashing if you remove these? They seem pretty innocuous.

After some more testing, I managed to crash the script while the tasks were commented out. Here's the other tasks:

https://pastebin.com/X8qh9R0p
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 17, 2017, 01:59:39 PM
After some more testing, I managed to crash the script while the tasks were commented out. Here's the other tasks:

To confirm, Danmakufu downright CRASHES - it does not freeze/etc.

Can you pastebin the entire thing for quick reference?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on June 17, 2017, 02:44:59 PM
To confirm, Danmakufu downright CRASHES - it does not freeze/etc.

Can you pastebin the entire thing for quick reference?

https://pastebin.com/680XWj08

Danmakufu first freezes, then brings up the 'not responding' window, then closes.
Again, the attack isn't always problematic; sometimes it ends perfectly fine, but every now and then it causes the problem.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 18, 2017, 05:27:43 AM
https://pastebin.com/680XWj08

Danmakufu first freezes, then brings up the 'not responding' window, then closes.

That means it's technically not a crash - it's an infinite loop somewhere in your code, most likely.

The only thing I can think of us using break; instead of return; when checking enemy life, as break generally executes the rest of the stuff after the loop (including the other waits, etc. in your case).
I'll need to take a closer look at the code to be sure though.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 18, 2017, 06:26:06 AM
Break statements will break out of the closest loop, switch, or function. A break in an if statement will break outside of it; in this case they're either functions or the loop is at the end of the function, so there is no problem. (You should use returns instead though)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on June 18, 2017, 08:02:02 AM
Thanks for the advice. Of course, since break and return served the same purpose here the freeze still occurs.
The freeze always happens after all the bullets turn into star items, and when the player is autocollecting them.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 18, 2017, 02:43:57 PM
Thanks for the advice. Of course, since break and return served the same purpose here the freeze still occurs.
The freeze always happens after all the bullets turn into star items, and when the player is autocollecting them.

If this is the case, you're stating that the freeze happens AFTER the attack? Are you running this as a standalone Single, as part of a Plural, or as part of a Stage?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on June 18, 2017, 02:48:12 PM
If this is the case, you're stating that the freeze happens AFTER the attack? Are you running this as a standalone Single, as part of a Plural, or as part of a Stage?

Yes, the freeze happens after the attack, when run as a Single and as part of a Plural.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 19, 2017, 08:33:52 AM
This is incredibly peculiar. I copied your script to run for myself, and after a bunch of testing and getting more and more precise (stupidly precise) with finding what crashes, I think I've found the root cause.

The core issue is that this appears to be a bug related to tasks, how they are managed internally, and breaking inside of tasks. The most barebones, fundamental example I can give is the following:

Code: [Select]
#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["test"]

@Initialize{
A;
}

task A{
loop(2){
B;
}
}

task B{
yield;
break;
}

@MainLoop{
yield;
}

@Event{
alternative(GetEventType())
case(EV_REQUEST_LIFE){
SetScriptResult(1);
}
}

This script should just instantly crash. Important pieces are that there are multiple instances of B running that were called from inside a loop, B yields, and then B breaks.
If it returns it's fine, if you just write B;B; it's fine, if there's no yield or otherwise if you space the B calls for longer than B takes to run it's fine. Generally the more instances there are the easier it is to crash, and mashing ctrl also seems to help it along.


This relates back to the actual problem script, I promise, I just dug really deep to get it this compact. The script executes this sort of behavior by running multiple instances of AmuletShoot, which each wait for a bit, and then break if the boss has 0 life, which is why it happens once the boss is defeated. If you remove the life condition and simply break, the script will crash most of the time. The reason why it seemed sporadic probably comes down to when each task started and when the boss died.

To be clear, if you replace your breaks here with returns, that should fix the problem.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on June 19, 2017, 09:05:16 AM
Thanks so much for taking all this time to fix my issue. I'll be using return in the place of break in the future.

It's certainly odd how tasks don't work properly when breaking, but since the workaround is fairly simple it's not a huge problem.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 19, 2017, 09:09:07 AM
Yeah honestly it took me like 30 minutes to figure it was the break statements (mostly because I thought it was something else first), but then I spent several hours trying to refine what exactly the bug was and whether it was a bug at all lol
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ramcat1313 on June 23, 2017, 12:28:33 PM
Hi I'm trying to put BGM in my stage script using this function:

function StageBGM(obj, ID) {
    ObjSound_SetSoundDivision(obj, SOUND_BGM);
    ObjSound_SetRestartEnable(obj, true);
    ObjSound_SetLoopEnable(obj, true);
    ObjSound_SetLoopTime(obj, 0, 300);

    if(ID == 1){ObjSound_SetLoopTime(obj, 0, 96);}
    if(ID == 2){ObjSound_SetLoopTime(obj, 0, 58);}

    return obj;
}

But it won't play with ObjSound_Play(bgm,1). I've checked my directory paths to my sound files. And they're all correct.
I'm not receiving any error messages.

The only way I can add BGMs right now is with #BGM and that works fine.
But I need to use this function to switch my Boss Music.

Any help out there please?  ???
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 23, 2017, 07:55:58 PM
Hi I'm trying to put BGM in my stage script using this function:

function StageBGM(obj, ID) {
    ObjSound_SetSoundDivision(obj, SOUND_BGM);
    ObjSound_SetRestartEnable(obj, true);
    ObjSound_SetLoopEnable(obj, true);
    ObjSound_SetLoopTime(obj, 0, 300);

    if(ID == 1){ObjSound_SetLoopTime(obj, 0, 96);}
    if(ID == 2){ObjSound_SetLoopTime(obj, 0, 58);}

    return obj;
}

But it won't play with ObjSound_Play(bgm,1). I've checked my directory paths to my sound files. And they're all correct.
I'm not receiving any error messages.

The only way I can add BGMs right now is with #BGM and that works fine.
But I need to use this function to switch my Boss Music.

Any help out there please?  ???

I assume you are using the code I provided in http://sparen.github.io/ph3tutorials/ph3u3l23.html#sub5

You stated that the paths are OK and it won't play. Firstly, did you create the actual sound objects themselves? You need to pass a valid Sound Object as a parameter to this function. Secondly, if the above doesn't work, please post the code where you call this function, as it will be necessary for us to see your code.

If there are any problems with my guide (which afaik has not been reviewed for accuracy, since I just found an error in the code I provided a few seconds ago), please inform me so that I can correct the errors.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ramcat1313 on June 24, 2017, 01:02:54 AM
Hi thanks for the reply,

Yes, I did create the actual sound object. This is the task where I called out the function.
It's in a script where I could test out this functon and switching between bgms.

task TStage {

    bgm2 = ObjSound_Create();
    ObjSound_Load(bgm2, bossMpath);
    StageBGM(bgm2, 2);

    bgm = ObjSound_Create();
    ObjSound_Load(bgm, BGMpath);
    StageBGM(bgm, 1);

    ObjSound_Play(bgm);
   loop(60*10) {yield;}
   ObjSound_Stop(bgm);
   ObjSound_Play(bgm2);
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ramcat1313 on June 24, 2017, 02:39:09 AM
PS.

Audio functions also don't work for some reason.

I tried loading the file path with LoadSound and PlayBGM but they don't work.

The only way I can add bgm right now is through the #BGM Header.

Should I try a format other than .ogg?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 24, 2017, 04:08:23 AM
Please actually show how your path is defined, both when not working and in your #BGM header. If you are using something like "./folder/track.ogg" as you would in the #BGM header, that is not entirely how you would do it in-script. Using backslashes \ is also valid only in the headers and will fail in-script. Everything you're describing is strongly indicative that your path is defined incorrectly.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ramcat1313 on June 24, 2017, 07:28:35 AM
Ok here's how I do the path:

------------------------------------------------------------------
let dir = GetCurrentScriptDirectory();

let BGMpath = dir ~ "..libgmStageSong.ogg";
let bossMpath = dir ~ "..libgmBossSong.ogg";

----------------------------------------------------------------------
and here's the header

#BGM["./../../lib/bgm/StageSong.ogg"]
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 24, 2017, 07:45:08 AM
So like I said, backslashes will not work. Besides this, the path you point to in #BGM is different from the others, as it goes up two parent directories.

Change to dir ~ "../../lib/bgm/StageSong.ogg" and it should work.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ramcat1313 on June 24, 2017, 08:31:10 AM
Ok. It works now.

Thank you so much.

I can't believe it was just a matter between forward and back slashes
 :D
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 24, 2017, 12:13:48 PM
Phew. I thought I had screwed up somewhere in the tutorial's code.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Trung0246 on June 26, 2017, 09:56:12 PM
Anyone know what are reimu, marisa, sanae, ... movement speed (in pixels) with and without hold shift across from touhou 10-12 and 13-16 ?

Edit: found the link http://thwiki.cc/%E6%B8%B8%E6%88%8F%E6%94%BB%E7%95%A5/STG%E6%9C%BA%E4%BD%93%E8%AF%B4%E6%98%8E
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JayRS on June 26, 2017, 11:06:54 PM
Why does this code make the amulets go out from the boss and then ... straight down?
Code: [Select]
task TAmuletChain(dir)
{
loop(20)
{
let ex = ObjMove_GetX(objEnemy);
let ey = ObjMove_GetY(objEnemy);
let shotObj = CreateShotA1(ex, ey, 1, 270 + (85 * dir), 156, 10);
ObjMove_AddPatternA1(shotObj, 60, 2, GetAngleToPlayer(shotObj));
wait(5);
}
}

In case you're wondering, my intention is to have them go toward the player.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on June 27, 2017, 11:59:41 AM
So because im using a mix of tutorials so it won't might work. So instead i did only 1 point, but here's the real problem : After I created this script https://pastebin.com/TF8xTbik it says GetCenterX is not defined.   ??? Why
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 27, 2017, 01:44:24 PM
Why does this code make the amulets go out from the boss and then ... straight down?
Code: [Select]
task TAmuletChain(dir)
{
loop(20)
{
let ex = ObjMove_GetX(objEnemy);
let ey = ObjMove_GetY(objEnemy);
let shotObj = CreateShotA1(ex, ey, 1, 270 + (85 * dir), 156, 10);
ObjMove_AddPatternA1(shotObj, 60, 2, GetAngleToPlayer(shotObj));
wait(5);
}
}

In case you're wondering, my intention is to have them go toward the player.

The player is directly below the boss, most likely. GetAngleToPlayer(shotObj) will execute IMMEDIATELY, so the bullet will, at 60 frames, face whatever angle the player was at relative to the boss 60 frames prior. So if the player remains below the boss, the bullet will go straight down at the player. If the player moves 60 pixels to the side after the bullet has been fired but before the 60 frames are up, the old angle (270 degrees) will have already been calculated, and the bullet will go straight down.

A fix would be to have an Object task, say BulletCommands(shotObj), and in this task, wait(60); ObjMove_SetSpeed(shotObj, 2); ObjMove_SetAngle(shotObj, GetAngleToPlayer(shotObj));

I assume that you want the bullets to move in their given speed and angle for 60 frames, then aim at the player.

So because im using a mix of tutorials so it won't might work. So instead i did only 1 point, but here's the real problem : After I created this script https://pastebin.com/TF8xTbik it says GetCenterX is not defined.   ??? Why

You have a few syntax errors in your script. See Line 42.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on June 27, 2017, 03:21:47 PM
It solved, but I can't solve this problem https://pastebin.com/0MWfFa3v (It's the same problem and it says its at the 30th line) . I think there's no problem for it but it still failed... and I'm not sure about the laser part, am i right ? or not ?  ??? ??? ???
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 27, 2017, 05:12:20 PM
It solved, but I can't solve this problem https://pastebin.com/0MWfFa3v (It's the same problem and it says its at the 30th line) . I think there's no problem for it but it still failed... and I'm not sure about the laser part, am i right ? or not ?  ??? ??? ???

You can use Ctrl-F to 'find' certain words and phrases. Before posting to this thread, ensure that all of your braces, brackets and parentheses line up.

If you are unsure how to use Ctrl-F to determine this:

Ctrl-F {
Ctrl-F }

The above numbers (for number of times each character was present in your script) should be the same. For your script, your braces do not match, therefore causing the 'is not defined' error. This syntax error can be easily mitigated by using a Text Editor such as Notepad ++ or Sublime that comes with the ability to collapse and expand blocks of code (blocks referring to code contained within { } in this case).

I also highly suggest using tabs and/or spaces to properly indent your code blocks. This makes it easier to find missing { and }, and will save you a great deal of time in the future.

NOTE: Take a very good look at lines 44-45. It's very obvious that there's something wrong with your code there.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JayRS on June 27, 2017, 07:33:27 PM
Why is this script making a LOT of noise but spawning no bullets?

https://pastebin.com/ac9vCS09 (https://pastebin.com/ac9vCS09)

EDIT: WOW I'm retarded. Yeah, including the actual bullet file would help, wouldn't it...

OK, new problem. WTF does it mean when my console log is spammed with token messages and my stage script doesn't show up?

EDIT: Also solved. I missed a quotation mark. x.x

Problem number 3...  Why is my bomb image not showing up? It's functioning perfectly except for that.
https://pastebin.com/S2Qi3xhh (https://pastebin.com/S2Qi3xhh)

Aaaaaand, problem number four, perhaps more significant. My bgm is skipping around right when the midboss is called and several times shortly after. I'm fairly sure the problem lies in the stage script (https://pastebin.com/6CUBCupS).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on June 29, 2017, 11:56:34 AM
I'm trying to create a spell card where the boss shoots 3 randomly aimed bullets that stop when they hit the walls. Then I wait 90 frames and I want to move the three bullets to the circuncenter of the triangle formed by the three of them, but I have no idea how to calculate that... Help?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JayRS on June 29, 2017, 08:54:12 PM
OK this music skipping problem is driving me crazy... It happens every time around the midboss. See above post for text files.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 30, 2017, 04:01:33 AM
Problem number 3...  Why is my bomb image not showing up? It's functioning perfectly except for that.
https://pastebin.com/S2Qi3xhh (https://pastebin.com/S2Qi3xhh)
(http://i.imgur.com/jKNajPq.png)

Spell objects are not 2D Sprite objects, nor are they Move objects. You will have to use alternatives for the functions you're trying to call.

Aaaaaand, problem number four, perhaps more significant. My bgm is skipping around right when the midboss is called and several times shortly after. I'm fairly sure the problem lies in the stage script (https://pastebin.com/6CUBCupS).
Is the skipping consistent at exactly the same times? If you delay the midboss does the skipping delay in time, or does it still skip at the same points in the music? Have you tried other music to see if that also skips? It could just not like the file you're using.

As far as I'm aware loading issues should mostly affect the running script, not cause music to skip. It also seems unlikely a small script should cause a significant issue, but there are ways to distribute the loading if necessary.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on June 30, 2017, 03:48:23 PM
So i finished the delay laser, but when i made the MainTask like this in the script https://pastebin.com/aK8Dcfq0 , the shot data is this :
  ShotData{
   id = 157
   rect = ( 105, 431, 129, 459 )
   delay_color = ( 63, 255, 255 )

It worked, but after like 10 seconds, a very big (coverment 70%) shot flew, not was i expected.
Why ?
Or my MainTask is wrong ???  ??? ??? ???
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 30, 2017, 03:57:19 PM
So i finished the delay laser, but when i made the MainTask like this in the script https://pastebin.com/aK8Dcfq0 , the shot data is this :
  ShotData{
   id = 157
   rect = ( 105, 431, 129, 459 )
   delay_color = ( 63, 255, 255 )

It worked, but after like 10 seconds, a very big (coverment 70%) shot flew, not was i expected.
Why ?
Or my MainTask is wrong ???  ??? ??? ???

Since you defined your laser to be 398 pixels wide, of course it's going to cover most of the screen :|
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on June 30, 2017, 04:02:16 PM
But i wanted only loose lasers from it, im not sure about the shot data though ...
I wanted this DS_BEAM_SKY as loose laser (? im not sure it works?)
It's annoying to read the shot sheets due im really poor at japanese......
SO which is the most suitable for it  ??? ???
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 30, 2017, 10:45:24 PM
Again, that is a loose laser. It just looks like a bullet because you swapped the length and width parameters.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: lolpudding on July 03, 2017, 05:37:03 PM
Hello again, I would like to ask for advice about how to avoid creating broken replays? I haven't tested the replay function for my small project yet, but I would like to try and decrease the chances of creating a ruined replay.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on July 03, 2017, 06:08:49 PM
This may be a dumb question, but I'm trying to find a way to prevent spawning in (0,0) when a single finishes and another one starts, my plan is to create a function in my library that ends the task where it is called. Is there any kind of command to "end" a task before it finishes?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on July 03, 2017, 06:38:10 PM
So I'm trying to use 2D arrays to hold references to several rings of "orreries" (think PC-98 Marisa) - o[0][0..4] holds the "planets", and o[1..5][0..4] hold the "moons". This is modified from a single with a single ring of orreries, with references held in 1D arrays, which works.

When I try to assign to the 2D array, however, I get the error ""=" is nessasary. (sic)"

The error points to line 4 of the following:

Code: [Select]
//Task for each orrery to update its position and angle
task TOrrery(let arr, let id, let offset, let color, let center) {
let orrery = CreateOrrery(color);
o[arr][id] = orrery; //add the orrery to the global array of orreries         //<----- Error points here
while(true) {
let cx = ObjMove_GetX(center); let cy = ObjMove_GetY(center);
let pos = rot[arr]+offset;
ox[arr][id] = cx+r[arr]*cos(pos); oy[arr][id] = cy+r[arr]*sin(pos);
ObjMove_SetPosition(orrery, ox[arr][id], oy[arr][id]);
let angle = atan2(oy[arr][id] - cy, ox[arr][id] - cx) + angoffset;
ObjMove_SetAngle(orrery,angle+0); //point orrery at center
oa[arr][id] = angle;

yield;
}
}

One instance of this task is run per orrery - another task is responsible for controlling the values in the arrays, which are declared globally (in the header). In this modified version, one version of the "controller" task is run for each ring of orreries, one with the boss given as the center and one with each "planet" as the center. Other tasks are responsible for firing bullets from orreries (not currently called in this single) and making harmless lasers between orreries (because I can't get magic circles to work except when they randomly decide to appear). These tasks are run one per ring, same as the controller task.

The arrays are also initialized in the header as 2D arrays of 0s or references to a dummy bullet as appropriate, as previously I had been getting complaints about "using a variable that has not been set yet". CreateOrrery is a function that simply creates a bullet, sets its blend mode and such, and returns the bullet.

Since as far as I can tell there is in fact an "=" there, I assume the problem is something to do with the syntax of multidimensional arrays.

Edit: My next best guess is that it has to do with the arrays being global, but I didn't have any problems using them globally when they were one-dimensional.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 04, 2017, 07:19:02 AM
This may be a dumb question, but I'm trying to find a way to prevent spawning in (0,0) when a single finishes and another one starts, my plan is to create a function in my library that ends the task where it is called. Is there any kind of command to "end" a task before it finishes?
You can return from a task and that ends it just as it would a function, but you shouldn't be relying on this because you will start breaking things even more severely due to the timing-based nature of tasks, and it is harder to find those issues and solve them. Spawning at (0,0) is basically always the same easy problem where the tasks keep trying to do things at the enemy position after the enemy is deleted (or in general, anything that keeps referring to an object that's been deleted). All you have to do is properly wrap your relevant tasks in life checks or enemy deletion checks; whichever is more appropriate.


So I'm trying to use 2D arrays to hold references to several rings of "orreries" (think PC-98 Marisa) - o[0][0..4] holds the "planets", and o[1..5][0..4] hold the "moons". This is modified from a single with a single ring of orreries, with references held in 1D arrays, which works.
You can't fully index into multidimensional arrays to set values, unfortunately. You can only set values of the first dimension, so e.g.
Code: [Select]
a = [[0,1,2],[3,4,5],[6,7,8]]
a[1][2]         #=> 5
a[1][2] = 9     #=> error
a[1] = [3,4,9]  #=> ok

If you really want to be able to do this you have to temporarily make a copy of the first index in, set the value on that copy, then put it back in the full array, like
Code: [Select]
temp = a[1]
temp[2] = 9
a[1] = temp
If you want to go deeper than two dimensions you then have to do this recursively.

I've already made a solution for this previously, which you can find here:
https://gist.github.com/drakeirving/0456b9437b4f8a995e8f714b1b131800

All that being said, I still don't think this is the best way to approach your problem. Having 2D arrays of object IDs is generally fine if you aren't changing those values all the time, since to manipulate the objects you only need to get the object IDs from the arrays, which is fine. But the global 2d array of positions and angles don't seem to make sense when you only immediately use them to then set the object properties; presumably you also refer to those arrays elsewhere but you shouldn't need to do that when you can already get each object and then use GetX/Y/Angle. You also seem to have radius and a rotation array but I'm not convinced that can't easily be avoided.

This rearrangement might help, since many people don't seem to know you can do this:

Code: [Select]
function CreateOrrery(let arr, let id, let offset, let color, let center) {
let orrery = // insert all the stuff you'd put in the original CreateOrrery function

task TOrrery(){
while(!Obj_IsDeleted(orrery)) {
let cx = ObjMove_GetX(center); let cy = ObjMove_GetY(center);
let pos = rot[arr]+offset;
ox[arr][id] = cx+r[arr]*cos(pos); oy[arr][id] = cy+r[arr]*sin(pos);
ObjMove_SetPosition(orrery, ox[arr][id], oy[arr][id]);
let angle = atan2(oy[arr][id] - cy, ox[arr][id] - cx) + angoffset;
ObjMove_SetAngle(orrery,angle+0); //point orrery at center
oa[arr][id] = angle;

yield;
}
}
TOrrery();
return orrery;
}

This way you can say let bla = CreateOrrery(...) to be able to keep the object ID and the task will already be started. I'm guessing that the main reason you're saving a bunch of global arrays and using various tasks to control those arrays and cross-reference everywhere is because you didn't know you could do this.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: QuirkyTurtle on July 04, 2017, 01:29:40 PM
Right, so i was in the middle of following a tutorial to learn the basics and i was thinking i might as well test if it shows up. I save the script, launch danmakufu and... Nothing. I don't see my script, only the basic samples and EX-Rumia that come with the download. I have checked, double checked and triple checked that my header is written right and there doesen't seem to be any problem. The code obviously isn't complete yet and lacks any sort of bullets but i don't see why i shouldnt be able to even see it?

https://pastebin.com/VrZbi5ma


Moved code to pastebin. Please put large blocks of code in pastebin links to avoid unnecessary scrolling.  --Hele
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Alrysc on July 04, 2017, 06:34:59 PM
I've recently finished some tutorials and decided to try some things out for myself, but, of course, I've run into a few things I don't understand and a few things that shouldn't be happening.  Here's my code: https://pastebin.com/CFqhiiKt (https://pastebin.com/CFqhiiKt) At the bottom of the script is a link to some screenshots. I think the problems are from line 171 onward.  What I wanted this to do was for the blue stream of bullets to circle around the boss, then, after a second, the other colors would join in. The other colored bullets, task shoot, should start firing once count reaches 60, so one second. Instead, it takes about 26 seconds for them to fire. As shown in the fourth screenshot, once the boss dies, the bullets continue to fire from the top left corner of the screen for a second before the script closes. I don't get why the blue bullets speed up after the 26 seconds, either (though that is what I wanted it to do), or why any of the bullets end up on top of each other so often. There are also some gaps in the pattern, but that might be due to a wait.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 04, 2017, 09:06:55 PM
Right, so i was in the middle of following a tutorial to learn the basics and i was thinking i might as well test if it shows up. I save the script, launch danmakufu and... Nothing. I don't see my script, only the basic samples and EX-Rumia that come with the download. I have checked, double checked and triple checked that my header is written right and there doesen't seem to be any problem. The code obviously isn't complete yet and lacks any sort of bullets but i don't see why i shouldnt be able to even see it?
#BGM header needs quotes to show it's a string #BGM["./rss_4boss"]. When a header fails the parser gives up, so nothing will show up.

I've recently finished some tutorials and decided to try some things out for myself, but, of course, I've run into a few things I don't understand and a few things that shouldn't be happening.  Here's my code: https://pastebin.com/CFqhiiKt (https://pastebin.com/CFqhiiKt) At the bottom of the script is a link to some screenshots. I think the problems are from line 171 onward.  What I wanted this to do was for the blue stream of bullets to circle around the boss, then, after a second, the other colors would join in. The other colored bullets, task shoot, should start firing once count reaches 60, so one second. Instead, it takes about 26 seconds for them to fire. As shown in the fourth screenshot, once the boss dies, the bullets continue to fire from the top left corner of the screen for a second before the script closes. I don't get why the blue bullets speed up after the 26 seconds, either (though that is what I wanted it to do), or why any of the bullets end up on top of each other so often. There are also some gaps in the pattern, but that might be due to a wait.
First of all, the reason the bullets keep spawning in the corner is what I just mentioned to GenoCraft. The boss is dead, and soon deleted, but you haven't set it up to stop firing. If the boss dies after you call fire() but before shoot(), shoot will still run, and additionally if that instance of fire hasn't ended it will keep shooting bullets as well. So you have to  be more careful with your zero-life checks.

As for the rest, you're mainly being confused by the asynchronous nature of running tasks, and also probably by your usage of global variables. The other bullets take so long to fire because while you do count from 0 up to 60, you have a yield and a wait(25) between each time, so 26 frames between each increment, which overall will take 1560 frames to reach 60, i.e. 26 seconds.

The blue bullets also speed up at that point because their spin is determined by the global variable count2, which you also start increasing in shoot. Other weird side effects of the global variables is that eventually count would get reset back to 0 which would cause shoot to stop being run and you'd just have the blue bullets again.

Basically you should keep working on getting familiar with how tasks work. Keep experimenting, but maybe try something with fewer moving parts so it's easier to keep track of.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on July 04, 2017, 10:08:35 PM
This way you can say let bla = CreateOrrery(...) to be able to keep the object ID and the task will already be started. I'm guessing that the main reason you're saving a bunch of global arrays and using various tasks to control those arrays and cross-reference everywhere is because you didn't know you could do this.

Oh thank god, I can code in ways that make sense again. No more trying to juggle things in global arrays just to pass back a reference!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on July 05, 2017, 10:44:11 AM
I don't know if I can ask this here, but it's somehow related to Danmakufu and I'm desperate...
Apparently ever since yesterday I can't open Danmakufu wiki anymore because of this error:
[attach=1]
I tried to search how to install whatever component this requires yesterday, but I really couldn't. Help, I won't be able to finish my RaNGE 17 entry without the wiki  :ohdear:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: niektory on July 05, 2017, 11:56:13 AM
The wiki is down. Nothing you can do about it. Try using the archived version until it's fixed: https://web.archive.org/web/20170625051804/http://dmf.shrinemaiden.org/wiki/Main_Page
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on July 05, 2017, 12:24:14 PM
The wiki is down. Nothing you can do about it. Try using the archived version until it's fixed: https://web.archive.org/web/20170625051804/http://dmf.shrinemaiden.org/wiki/Main_Page
Oh, I see, Thank you.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on July 05, 2017, 12:29:09 PM
I've reported the bug to forum, now just wait.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 05, 2017, 01:00:15 PM
Keep in mind that the Japanese documentation is still available at http://www.geocities.co.jp/SiliconValley-Oakland/9951/pre/th_dnh_help_v3.html (http://www.geocities.co.jp/SiliconValley-Oakland/9951/pre/th_dnh_help_v3.html)

Additionally, there are a number of external resources (such as tutorials) that may contain information on some of the various functions.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: QuirkyTurtle on July 05, 2017, 01:19:06 PM
Right so the script is showing up in danmakufu now, thanks. However, i'm getting a strange error when i open it up. it says i need a } at line 26 but i don't see why i should.

Here's the script: https://pastebin.com/j4b6UnGh
And the error message: https://pastebin.com/CYPzceR1
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 05, 2017, 01:25:12 PM
Right so the script is showing up in danmakufu now, thanks. However, i'm getting a strange error when i open it up. it says i need a } at line 26 but i don't see why i should.

Here's the script: https://pastebin.com/j4b6UnGh
And the error message: https://pastebin.com/CYPzceR1

You're missing a ; on line 25
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on July 05, 2017, 04:38:16 PM
So out of nowhere I started getting error messages that I was trying to use a variable that hasn't been set yet every time anything referenced my boss object. No clue what I did to cause it, so I ended up making several improvements to how I handle spawning the boss that, while they made my code much cleaner, did not (fully?) resolve the problem. (Now instead of manually creating a boss, I have a function in another file that checks if there's a boss stored in common data, if so returns that, and if not creates a new one, stores it in common data, and returns it.)

Anyway, I currently get no problems if I try to load only a few singles, but adding more results in an error saying only "_NextChar:すでに文字列終端です", which Google translates as "It is already a string termination".

That message is very unhelpful, but I have been able to gather some information from the log. First, the error occurs at the very end of the plural registering scenes. Second, it doesn't seem to come from the plural itself, as the plural is able to keep going long enough to write to the log that it's done registering scenes. Third, the function to create/fetch and return the boss goes on to execute, meaning the first single got far enough to call it.

While I'm posting, I'll go ahead and mention my other outstanding bugs in case anyone has any ideas.

*Spell circles not displaying properly/at all
   -Task definitely being run but not getting drawn
   -Static spell circles that stay there for the rest of the fight
*Spellcard bonuses displaying as 0 or 1 instead of actual bonus
   -Bonuses set in EV_REQUEST_SPELL_SCORE and score added in system script
*Game sometimes freezes (not responding) upon starting plural until I comment out all spellcards and re-add them one by one
   -May simply be taking a long time to load scenes; has not yet occurred since enabling the log window
*Player can bomb during Wait singles (my lazy way of adding delays between singles and spawning items)
   -ForbidPlayerSpell is being set but gets ignored?
*No timer noises until the last three
   -The obvious answer is that I've got the wrong name for the first tick SE but I've checked that several times
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 05, 2017, 06:41:29 PM

You have a lot of stuff here, and it seems you have systematic problems. I'll go one by one.

I started getting error messages that I was trying to use a variable that hasn't been set yet every time anything referenced my boss object.

Ensure that the variable holding your boss object has been declared e.g. let objBoss;, and is in each and every single containing a boss.

Now instead of manually creating a boss, I have a function in another file that checks if there's a boss stored in common data, if so returns that, and if not creates a new one, stores it in common data, and returns it.

This is what Boss Scenes are for. Each Single should create its own boss, and should delete the boss at the end of the Single.

You should be doing the following in each Single:
Code: [Select]
    let objBoss;
    let objScene=GetEnemyBossSceneObjectID(); //For spell cards

...

@Initialize {
    ...
    objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
ObjEnemy_Regist(objBoss);
        ObjEnemyBossScene_StartSpell(objScene); //For spell cards
    ...
}

And in each Plural:
Code: [Select]
task TPluralR{
    let dir = GetCurrentScriptDirectory();
    let obj = ObjEnemyBossScene_Create();
    //Add your singles here, e.g. ObjEnemyBossScene_Add(obj, 0, dir ~ "./S6BNS1.txt");
    ObjEnemyBossScene_LoadInThread(obj);
    ObjEnemyBossScene_Regist(obj);
    while(!Obj_IsDeleted(obj)){
        yield;
    }
    CloseScript(GetOwnScriptID());
}

I don't know what you're doing, but it's definitely not what Danmakufu expects.

adding more results in an error saying only "_NextChar:すでに文字列終端です"

Ensure you have no weird symbols, i.e. no ????ł??? stuff in your scripts.

*Spell circles not displaying properly/at all
   -Task definitely being run but not getting drawn
   -Static spell circles that stay there for the rest of the fight

Depends on you you handle these. Remember that objects are not deleted at the end of a script unless you use object auto deletion or manually delete. Remember to yield; your main loop as well.

*Game sometimes freezes (not responding) upon starting plural until I comment out all spellcards and re-add them one by one
   -May simply be taking a long time to load scenes; has not yet occurred since enabling the log window

Expect some delay before a plural is loaded.

Player can bomb during Wait singles (my lazy way of adding delays between singles and spawning items)
   -ForbidPlayerSpell is being set but gets ignored?

Ensure that you are calling everything in the proper block. You'll have to provide some code for this one.

I hope this helps somewhat. If you have further problems, please post your code. Additionally, I recommend looking at the sample ExRumia boss. Get a feel for Danmakufu's script structure and how it expects you to work with Singles, Plurals, and Stages.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on July 05, 2017, 08:34:30 PM
You have a lot of stuff here, and it seems you have systematic problems.

Yep, I'm sort of in the middle of reworking a lot of things that I hacked together before learning the "right" way to do them, so there are plenty of issues.

Ensure that the variable holding your boss object has been declared e.g. let objBoss;, and is in each and every single containing a boss.

Yep, every single has it declared in the header and initialized in @Initialize (using the value returned by the function I mentioned).

You should be doing the following in each Single:
And in each Plural:

That's pretty much what the function does, and I haven't actually removed the code to delete the boss at the end of each single, so I don't think it's causing additional problems. I'll strip out the common data stuff, though, since it sounds like that doesn't work.

Ensure you have no weird symbols, i.e. no ????ł??? stuff in your scripts.

No mojibake that I've found, although there were kanji in a few places. Removing the kanji didn't fix it.

Depends on you you handle these. Remember that objects are not deleted at the end of a script unless you use object auto deletion or manually delete. Remember to yield; your main loop as well.

I actually went through every single while loop in my code (with Notepad++'s Find All in All Opened Documents) and checked to make sure every single one had a yield (or terminated). I don't think there are currently any tasks getting another copy called every frame due to extra yields - although that has happened at least once, it's definitely not the cause of the current issues.

I'm trying to use the default magic circle script, so I assumed it would clean up after itself, but I'll look through it again to make sure.

Ensure that you are calling everything in the proper block. You'll have to provide some code for this one.

Went ahead and zipped up the folder (https://www.dropbox.com/s/u0ldfpl9fv47lbp/test.zip?dl=0). Spells and nonspells are named with fruits and numbers (I've mostly been working with the Peaches and Kiwi series), everything else is named something that makes sense. Plural is called Plural.dnh, functions are in Resources.txt.

Sorry to make you sift through this mess - if I had any idea where the problem was I'd narrow it down.

Get a feel for Danmakufu's script structure and how it expects you to work with Singles, Plurals, and Stages.

I'll admit, I basically have no idea what the difference between a plural and a stage is. I'll get to that when I get to it, though. Wait, that's exactly the sort of thing that led to me hacking things together not knowing that you're supposed to use a thing I hadn't read about yet...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 05, 2017, 10:40:19 PM

I took a brief look at some of your code - note that this is not a thorough code review. I'll just dump what I found here:

Plural.txt
-SetPlayerRebirthLossFrame() is usually used in Player Scripts, and is generally not done in single/plural/stage scripts.
-CloseStgScene() is generally not used in Plural Scripts. If you had placed it anywhere other than the very last line of execution, things may have gone horribly wrong (then again, don't know, don't exactly need to know).
-SetCommonData("scene",obj); - Get rid of this. You can get the boss scene using a function - GetEnemyBossSceneObjectID();
-Your #Background script #Background["./system/Background_Stars.txt"] does not exist

Resources.txt
-SetScore, etc. confuse the heck out of me. I have no idea what you're trying to do.

Start.dnh
-You run ObjSound_Load(music,CSD ~ "./bgm.ogg") outside of a routine. Since loading the resource should be blocking, I suggest placing the loading in a routine, preferably @Loading.
-You register new boss objects twice in the same script - once in @Initialize and once in @MainLoop at frame 0. Given that you are only supposed to be able to have one in existence at any given time, this may cause problems (then again, never tested so don't know the repercussions, if there are any to begin with)
-Your entire frame = 0 block makes no sense given that @Initialize runs immediately before the first run of @MainLoop. DRY - Don't Repeat Yourself
-Honestly, just terminate the script when the frame >= 90 instead of doing a workaround of using the boss's health.
-Your @MainLoop is not yielded. Literally everything in this script will crash and burn.

In general:
-None of your wait scripts are properly yield;ed so all of them will suffer from the same problems as the Start script.
-In all of your attack singles, your including of Resources.txt followed by blatant DRY violation with the definition of the same functions over and over again in your MainLoops worries me. Functions are limited by scope, but if you are using the same functions over and over again, just put them in your function library once and include the library. This will make your code cleaner and easier to read.
-Your redeclaration of the global constants cx and cy as local variables everywhere in your code only impedes readability.

I'm not meaning to be harsh, but if you do some code cleanup, it will be MUCH easier to find the actual errors in your script. Since the wiki is down, I suggest looking at other starter scripts (scripts where it was the second or third time someone made a proper script) - these will provide a good reference without being too bogged down in custom systems. Choose ones that are simple in scope, like some of the former contest entries that scored in the upper two-thirds.

Hope this helps.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on July 05, 2017, 10:48:08 PM
Back here with a somewhat complicated issue I'm trying to deal with:

So, what I've been wanting to make is: spawning multiple familiars on the boss and them have them move in a circular path around her while they keep going outward and then stop at a certain distance from her. At that moment, they should start shooting bullets towards the boss.

I'm using two while-loops, one in another, with the inner one to control the familiars' movement before they reach the specified distance from the boss, and the outer (main) one to control their movement once they reached the specified distance until the script closes. Both loops are being yielded. The familiars should remain idle before reaching that distance and only start shooting once the inner loop is completed. I've inserted the task for shooting these bullets within the outer loop, so it could keep track of the exact distance between the familiars and the boss, because: once the bullets traversed that distance, they should each spawn a new bullet with the same movement angle as its parents, with the latter being deleted immediately after the spawning.

The problem I have herewith is, when the familiars reach the firstly mentioned distance from the boss, only one of the familiars starts shooting, no matter how many I spawn. On top of that, I somehow can't influence the delay between the shots. The parent bullets do spawn the child bullets at the desired location.

No error messages, freezes, and crashes.

Here's the script (https://pastebin.com/2dyAy5k9) and a screencap for closer looks since my description could be inaccurate.

[attach=1]


Any idea where I could've flopped?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 06, 2017, 12:17:23 AM

I personally have tasks for each familiar. Each gets passed an ID (so if there are 6 familiars, the IDs are 0..5). That ID determines their angle offset.

Start with radius 0. In the main familiar loop, while radius < x, radius ++. Also give the familiar task a counter, which goes up each frame.

If radius > x && objcount % number == 0, fire bullet at boss (which will be at angle ID * 360/numinring + 180 + objcount*rotation, probably). Something like that.

EX:

Code: [Select]
task Familiar(ID, numinring, targetradius, timetotargetradius, rotation) {
    let objcount = 0;
    let radius = 0;
    //Create the familiar
    ObjMove_SetPosition(obj, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss));
    while (!Obj_IsDeleted(objBoss)) {
        if (radius < targetradius) {radius += targetradius/timetotargetradius;}
        let ang = ID * 360/numinring + objcount * rotation;
        ObjMove_SetPosition(obj, ObjMove_GetX(objBoss) + radius*cos(ang), ObjMove_GetY(objBoss) + radius*sin(ang));
        if (radius >= targetradius && objcount % 6 == 0) {
            //Bullets.
        }
        objcount += 1;
        yield;
    }
}

This assumes rotating familiars. I haven't actually run it, so it might be buggy.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on July 06, 2017, 12:46:56 AM
-Your #Background script #Background["./system/Background_Stars.txt"] does not exist

Well, it's been working, so I'm fairly sure it exists. You might have been looking in default_system instead of system.

-SetScore, etc. confuse the heck out of me. I have no idea what you're trying to do.
Yeah, I have no idea how those are supposed to work either, they're from the script I started working from (Junko teaches Danmakufu). At first glance they look like they're intended to replace some of the cases in @Event, but then you look closer and it doesn't make any sense.

-You run ObjSound_Load(music,CSD ~ "./bgm.ogg") outside of a routine. Since loading the resource should be blocking, I suggest placing the loading in a routine, preferably @Loading.

Is there documentation on these routines anywhere? I haven't been able to find any.

-You register new boss objects twice in the same script - once in @Initialize and once in @MainLoop at frame 0. Given that you are only supposed to be able to have one in existence at any given time, this may cause problems (then again, never tested so don't know the repercussions, if there are any to begin with)
That was a janky attempt to make sure it was definitely defined. The function checks if there's already a boss before making a new one, so it wasn't causing extra problems, but it didn't work so I was going to remove it later anyway.

-Your entire frame = 0 block makes no sense given that @Initialize runs immediately before the first run of @MainLoop. DRY - Don't Repeat Yourself
I thought that seemed weird, but some tutorial or other had it that way and mentioned that tasks execute parallel with what called them, so I shrugged and did it that way, since I couldn't find documentation on exactly how those routines work.

-Your @MainLoop is not yielded. Literally everything in this script will crash and burn.

WOW okay when did that happen. There definitely used to be a yield there. I'm not sure what specifically I was doing at the time but I'm guessing it got removed at some point when I was replacing some unnecessary thing or other down there from a bunch of singles. Now that that's fixed I'm back to getting a nice, friendly "you are using a variable that has not been set yet".

-In all of your attack singles, your including of Resources.txt followed by blatant DRY violation with the definition of the same functions over and over again in your MainLoops worries me. Functions are limited by scope, but if you are using the same functions over and over again, just put them in your function library once and include the library. This will make your code cleaner and easier to read.
-Your redeclaration of the global constants cx and cy as local variables everywhere in your code only impedes readability.
If you do some code cleanup, it will be MUCH easier to find the actual errors in your script.

Yeah, I've been in the bad habit of making a copy of another single and working from that, which has led to "some" redundancy. Don't worry, I know how awful it is, that's a large part of the overhauls I mentioned.

Since the wiki is down, I suggest looking at other starter scripts (scripts where it was the second or third time someone made a proper script) - these will provide a good reference without being too bogged down in custom systems. Choose ones that are simple in scope, like some of the former contest entries that scored in the upper two-thirds.
I've just been using the archived (https://web.archive.org/web/20170625051804/http://dmf.shrinemaiden.org/wiki/Main_Page) version of the wiki. I have been working off of a few such scripts, but I'll look into some more. Where would I go to find former contest entries like you mentioned?

Random question - where do I edit my signature on this site? "Literally everything in this script will crash and burn" seems like a very appropriate sig.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 06, 2017, 07:12:56 AM
Back here with a somewhat complicated issue I'm trying to deal with:

So, what I've been wanting to make is: spawning multiple familiars on the boss and them have them move in a circular path around her while they keep going outward and then stop at a certain distance from her. At that moment, they should start shooting bullets towards the boss.

I'm using two while-loops, one in another, with the inner one to control the familiars' movement before they reach the specified distance from the boss, and the outer (main) one to control their movement once they reached the specified distance until the script closes. Both loops are being yielded. The familiars should remain idle before reaching that distance and only start shooting once the inner loop is completed. I've inserted the task for shooting these bullets within the outer loop, so it could keep track of the exact distance between the familiars and the boss, because: once the bullets traversed that distance, they should each spawn a new bullet with the same movement angle as its parents, with the latter being deleted immediately after the spawning.

The problem I have herewith is, when the familiars reach the firstly mentioned distance from the boss, only one of the familiars starts shooting, no matter how many I spawn. On top of that, I somehow can't influence the delay between the shots. The parent bullets do spawn the child bullets at the desired location.
First thing, you shouldn't model this as a nested while loop. The whole point of what you're trying to do is have [some behaviour] until a condition, then maybe some transition, then [some other behaviour]. All you need is one while loop and then the other; the way it is now isn't immediately breaking anything, but it easily could.

The cause of the problem is likely due to the GetObjDistance and CoordToBoss functions, along with the object type RenderFamiliar returns. If GetObjDistance fails, dist is set oddly which means sdelay is also. Relatedly, if your fam objects are Render-only objects (like 2D Sprites), using functions such as ObjMove_GetX will fail, and so things in FShot that do this (such as CoordToBoss) will definitely behave wrong. Basically I wager that these sorts of things are what's screwing your idea up.

Whatever the issue is, you have clearly written too much in a short span of time without properly testing. In the future please try to test changes whenever possible so things don't end up "not working" after a slew of additions that you can't possibly keep track of.

Side note, you can avoid using Common Data to store boss crap by simply using GetEnemyBossObjectID in the necessary scripts and keep things clean.

[...] mentioned that tasks execute parallel with what called them, so I shrugged and did it that way, since I couldn't find documentation on exactly how those routines work.
Here's a post I wrote a few pages back trying to precisely (yet not formally) summarize the flow of a script:

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

This won't necessarily tell you exactly what each routine does, but knowing when they're called is more relevant since they all do basically the same thing but are used in different contexts.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on July 06, 2017, 09:29:18 AM
I personally have tasks for each familiar. Each gets passed an ID (so if there are 6 familiars, the IDs are 0..5). That ID determines their angle offset.

Start with radius 0. In the main familiar loop, while radius < x, radius ++. Also give the familiar task a counter, which goes up each frame.

If radius > x && objcount % number == 0, fire bullet at boss (which will be at angle ID * 360/numinring + 180 + objcount*rotation, probably). Something like that.

EX:

...

This assumes rotating familiars. I haven't actually run it, so it might be buggy.
First thing, you shouldn't model this as a nested while loop. The whole point of what you're trying to do is have [some behaviour] until a condition, then maybe some transition, then [some other behaviour]. All you need is one while loop and then the other; the way it is now isn't immediately breaking anything, but it easily could.

The cause of the problem is likely due to the GetObjDistance and CoordToBoss functions, along with the object type RenderFamiliar returns. If GetObjDistance fails, dist is set oddly which means sdelay is also. Relatedly, if your fam objects are Render-only objects (like 2D Sprites), using functions such as ObjMove_GetX will fail, and so things in FShot that do this (such as CoordToBoss) will definitely behave wrong. Basically I wager that these sorts of things are what's screwing your idea up.

I've originally declared/registered the familiars as enemy objects, so the mixed use between the ObjMove and ObjRender functions both for the familiar object are most likely the cause of the issue. Changed ObjRender_SetPosition to ObjMove_SetPosition inside the main loop and replaced the nested loop with two if-conditions. With the counter Sparen suggested, manually setting the delay between each shot now works too.

Code: [Select]
task FamiliarControl(type,angle,dir) {
let dist = 0;
let cdist = 0;
let fdist = 160;
let pdist = 0.7;
let speed = 2.5;
let sspeed = 2;
let count = 0;
let pos = [ObjMove_GetX(Boss),ObjMove_GetY(Boss)];
let fam = RenderFamiliar(Boss,type,pos[0],pos[1],120,[0,0],true,1);

while(!Obj_IsDeleted(Boss)){
if(cdist<fdist){
cdist += pdist;
}
if(cdist >= fdist && speed > 1.25 && pdist > 0.01){
speed -= 1.25/30;
pdist -= 0.69/30;
}
if(cdist >= fdist && count%16==0){
dist = GetObjDistance(fam,Boss);
FShot(fam,dir,sspeed,(dist/sspeed));
}
count++;
cdist += pdist;
angle += speed*dir;
ObjMove_SetPosition(fam,pos[0]+cdist*cos(angle),pos[1]+cdist*sin(angle));

yield;
}
}

Thanks a bunch!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 06, 2017, 01:22:36 PM
Well, it's been working, so I'm fairly sure it exists. You might have been looking in default_system instead of system.
Oh, sorry. Yeah, I looked in default_system instead.

Where would I go to find former contest entries like you mentioned?
They're all on Bulletforge, for the most part. All of the "Official Thread" links on http://sparen.github.io/projects/contestdatabase.html will point to the MotK thread for each contest. All MotK contests require submitting via post in the contest thread.

Random question - where do I edit my signature on this site? "Literally everything in this script will crash and burn" seems like a very appropriate sig.
It should be in Profile, at the top of each page. You MAY need a certain number of posts to unlock the feature but I do not know the specifics.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on July 06, 2017, 05:06:27 PM
You MAY need a certain number of posts to unlock the feature but I do not know the specifics.
Ah, that would be it. Looked through the rules thread and it's ten, so I'll probably hit that after the next round of crashing and burning.

...Well, technically I still haven't stopped crashing and burning. It seems like something in Peaches6, the one with the janky nested orreries, was somehow responsible for the boss not being defined, no idea how, but although the game does run now, the boss just vanishes after Start without moving on to the next single. But that's a much less serious issue - probably something to do with how I moved the stuff from the boss life check to the frame==90. The other waits work fine, so worst case I can just copy one of them and strip out the spell break SE again.

Edit: Another random question, how do I get the ID of the primitive used in player scripts to draw the player? I've been playing with a card that intermittently turns everything black and white, but setting the color, blend mode, etc. of the player does nothing because that's not the object being rendered.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 06, 2017, 08:09:21 PM
Edit: Another random question, how do I get the ID of the primitive used in player scripts to draw the player? I've been playing with a card that intermittently turns everything black and white, but setting the color, blend mode, etc. of the player does nothing because that's not the object being rendered.

GetPlayerObjectID() returns the player object. Use ObjRender functions on it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on July 06, 2017, 09:27:04 PM
GetPlayerObjectID() returns the player object. Use ObjRender functions on it.
That's what I've been doing, so I think it's a problem with the player script (I've been using the Mokou player from here (http://www.bulletforge.org/u/python/p/human-inferno-range-14-entry-by-python)). Tested it with some others and it works with some but not all.

Another random question - I've been meaning to start using SetAutoDeleteObject, but whenever I add it the music stops playing after the first single. Presumably this is because it's deleting the sound object, but I was under the impression that it would only delete objects created in that single, rather than in the plural. How does that work/how do I stop it?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 07, 2017, 05:19:17 AM
You can't really rely on every player being drawn with only the Player object. Some scripts will just have other drawn parts and you won't be able to get those. In Python's case he seems to have created a different 2D Sprite object and draws the player using that rather than the actual Player object, for no obvious reason, but it means what you want to do is impossible.

You can accomplish the grayscale effect using shaders, but that's getting complicated.

I've been meaning to start using SetAutoDeleteObject, but whenever I add it the music stops playing after the first single.
That shouldn't happen, as long as you're not uh handling the music inside the Single.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on July 07, 2017, 06:01:22 PM
That shouldn't happen, as long as you're not uh handling the music inside the Single.
I've been doing it in both the single and the plural, so I don't get treated to silence whenever I'm testing a new single. Is there really no way to have it both ways?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 07, 2017, 07:05:00 PM
I've been doing it in both the single and the plural, so I don't get treated to silence whenever I'm testing a new single. Is there really no way to have it both ways?

My workaround is to use #BGM for Singles and have the music play properly with Sound Objects, etc. in the Stage.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: netugi on July 07, 2017, 07:25:00 PM
This isn't quite a problem with Danmakufu itself, but rather the dmf wiki (I hope I'm posting this in the right place)
Basically I'm getting this whenever I try to go to the wiki: https://puu.sh/wE2Hs/34731e8785.png

Am I the only one getting this?
I was looking up what this php mbstring stuff was, and it all looks like server-side issues (correct me if I'm wrong). Do I just need to wait for the people who run the servers to fix the issue?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on July 07, 2017, 08:09:10 PM
This isn't quite a problem with Danmakufu itself, but rather the dmf wiki (I hope I'm posting this in the right place)
Basically I'm getting this whenever I try to go to the wiki: https://puu.sh/wE2Hs/34731e8785.png

Am I the only one getting this?
I was looking up what this php mbstring stuff was, and it all looks like server-side issues (correct me if I'm wrong). Do I just need to wait for the people who run the servers to fix the issue?

I'm fairly sure the wiki itself is down. Wait until someone fixes it, i guess  :V
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: netugi on July 07, 2017, 08:44:03 PM
I'm fairly sure the wiki itself is down. Wait until someone fixes it, i guess  :V

Figured as such. Was just a bit confusing because it seemed like it wanted me to install those things lol. I was trying to do that and I found a rabbit hole of server gibberish...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 08, 2017, 03:31:57 AM
So I have a question in regards to loose laser hitboxes and the 'correct' way to change the direction of a loose laser.

I have observed that using ObjMove_SetAngle on a loose laser does not correctly configure the hitbox - after using the function, you can and will get hit by parts of the laser that are, well, not a part of the laser. More correctly, it would seem that the laser graphic does not match up with the hitbox.

So my question is, what is the proper way to change the angle of a loose laser in order to preserve the integrity of the hitbox as to realign with the new angle of the laser? Or is the only option to create a new laser at the point where the angle change is needed?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on July 08, 2017, 04:03:06 AM
So I have a question in regards to loose laser hitboxes and the 'correct' way to change the direction of a loose laser.

I have observed that using ObjMove_SetAngle on a loose laser does not correctly configure the hitbox - after using the function, you can and will get hit by parts of the laser that are, well, not a part of the laser. More correctly, it would seem that the laser graphic does not match up with the hitbox.

So my question is, what is the proper way to change the angle of a loose laser in order to preserve the integrity of the hitbox as to realign with the new angle of the laser? Or is the only option to create a new laser at the point where the angle change is needed?

I don't have an answer to this, but in the same vein, how would I spin the laser but not change its movement?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 08, 2017, 04:25:58 AM
I don't have an answer to this, but in the same vein, how would I spin the laser but not change its movement?

Firstly, what kind of laser (loose, straight, curve), and secondly, what do you mean by 'not change its movement'? Do you mean static base straight lasers rotating around their base?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on July 08, 2017, 04:48:58 AM
Basically I'm getting this whenever I try to go to the wiki
Until it's fixed, you can use an archived version (https://web.archive.org/web/20150315061956/http://dmf.shrinemaiden.org:80/wiki/Functions_(ph3)) of the wiki.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on July 08, 2017, 07:11:51 AM
Firstly, what kind of laser (loose, straight, curve), and secondly, what do you mean by 'not change its movement'? Do you mean static base straight lasers rotating around their base?

I'm making a loose laser that acts like Sese's bones in Lenen: they spin about their center, but their movement isn't dependent on the 'angle' of the laser.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 08, 2017, 07:19:53 AM
So I have a question in regards to loose laser hitboxes and the 'correct' way to change the direction of a loose laser.

I have observed that using ObjMove_SetAngle on a loose laser does not correctly configure the hitbox - after using the function, you can and will get hit by parts of the laser that are, well, not a part of the laser. More correctly, it would seem that the laser graphic does not match up with the hitbox.

So my question is, what is the proper way to change the angle of a loose laser in order to preserve the integrity of the hitbox as to realign with the new angle of the laser? Or is the only option to create a new laser at the point where the angle change is needed?
Do you have a minimal working example? I'm not really sure what the problem is since I've never really run into this.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on July 08, 2017, 09:58:25 AM
My my.... this is very anooying......
I am creating some curve lasers in this script     :     https://pastebin.com/HMqXPpbr
So i'm using this shot sheet     :    Expanded shotdata ZUN style PH3, by Ozzy (ZUN original sprites)
but it didn't even looked like a curvy laser ! It's only straight ones, looked like half transparent.
But if i used all the README said the directory of #include, the script will won't appear.
I can't use the curvy laser  :( :( any help ? :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on July 08, 2017, 11:06:05 AM
My my.... this is very anooying......
I am creating some curve lasers in this script     :     https://pastebin.com/HMqXPpbr
So i'm using this shot sheet     :    Expanded shotdata ZUN style PH3, by Ozzy (ZUN original sprites)
but it didn't even looked like a curvy laser ! It's only straight ones, looked like half transparent.
But if i used all the README said the directory of #include, the script will won't appear.
I can't use the curvy laser  :( :( any help ? :)
You need to use ObjMove_SetAngularVelocity(obj, agv) on the curvy laser object, otherwise it will just behave like an ordinary loose laser.
The second parameter is what makes that laser curve. I'd recommend you to use values between -0.5 and 0.5 if you don't want the laser to curve too much, but this of course is entirely up to you to decide.

Also, yielding a loop (the while-loop in your MainTask here) with an implemented delay (the wait-function) can mess up the timing of when a laser is shot. If you remove the yield there, your boss will fire a curved laser every 80 frames. Removing the wait, however, would cause Danmakufu to crash, because with the yield, your boss will fire a laser every single frame which just overloads the program (that was my experience, at least). It's better to remove the yield and use wait to set the delay between each laser.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on July 08, 2017, 11:12:48 AM
My my.... this is very anooying......
I am creating some curve lasers in this script     :     https://pastebin.com/HMqXPpbr
So i'm using this shot sheet     :    Expanded shotdata ZUN style PH3, by Ozzy (ZUN original sprites)
but it didn't even looked like a curvy laser ! It's only straight ones, looked like half transparent.
But if i used all the README said the directory of #include, the script will won't appear.
I can't use the curvy laser  :( :( any help ? :)

Also for the half-transparency you can solve it by setting ObjCrLaser_SetTipDecrement(laser,0.1).
In future, maybe refer to Sparen's tutorials and the danmakufu wiki before asking here.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on July 08, 2017, 01:21:22 PM
I'm making a loose laser that acts like Sese's bones in Lenen: they spin about their center, but their movement isn't dependent on the 'angle' of the laser.
One possibility might be to define it in your shotsheet. For example, Marisa's stars spin like you described. Their definition looks like this:
Code: [Select]
ShotData{ id=661 rect=(240,153,255,168) render=ADD_ARGB fixed_angle=false angular_velocity = 2 delay_color= (255,255,255) }The relevant bits being the "fixed_angle=false" and "angular_velocity = 2".
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 08, 2017, 02:29:25 PM
Do you have a minimal working example? I'm not really sure what the problem is since I've never really run into this.

I ended up just creating new lasers. I was having loose lasers bounce off of the edges - I am under the assumption that upon direction change, the alignment of the hitbox remained the same (IE the vector representing the hitbox did not rotate, only the graphic), or that there was some other issue when they bounced off the sides. The workaround I used seems to look fine.

The code was essentially:
wait until you hit an edge
change your x coordinate
change angle of laser

Also for the half-transparency you can solve it by setting ObjCrLaser_SetTipDecrement(laser,0.1).
In future, maybe refer to Sparen's tutorials and the danmakufu wiki before asking here.

In general, most people choose to set the tip decrement to 0, but it's up to the scripter.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 09, 2017, 02:39:57 AM
I ended up just creating new lasers. I was having loose lasers bounce off of the edges - I am under the assumption that upon direction change, the alignment of the hitbox remained the same (IE the vector representing the hitbox did not rotate, only the graphic), or that there was some other issue when they bounced off the sides. The workaround I used seems to look fine.
That's sort of why I'm confused because that shouldn't happen unless maybe you accidentally use ObjRender_SetAngle instead. If you have a solution then whatever though.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Trung0246 on July 12, 2017, 06:11:23 AM
How to get delay cloud color? ...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 12, 2017, 08:27:25 AM
GetShotDataInfoA1(shot_id, TARGET_ENEMY, INFO_DELAY_COLOR)
Returns color as an array [r, g, b]
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Trung0246 on July 14, 2017, 02:31:18 AM
How to disable the number show up when player collect item ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on July 14, 2017, 07:30:10 AM
How do i aim a straight laser to a certain object?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on July 14, 2017, 10:01:49 AM
How to disable the number show up when player collect item ?
Use ObjItem_SetRenderScoreEnable(item,bool) and put false as the second parameter.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on July 15, 2017, 06:42:52 AM
How do i aim a straight laser to a certain object?
To aim it at a desired object, you need to calculate the angle from the straight laser source to the object using atan2.
Code: [Select]
let laserAngle = atan2(y1-y2,x1-x2);
xy1 for the laser position and xy2 for the object position.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on July 17, 2017, 01:55:23 PM
So I am wondering.... that how to make bullets act/shoot like Hina's last spell (Pain Flow) and bullets curves like gengetsu's last attack ?
*its not gengetsu rape time
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on July 17, 2017, 04:17:48 PM
So I am wondering.... that how to make bullets act/shoot like Hina's last spell (Pain Flow) and bullets curves like gengetsu's last attack ?
*its not gengetsu rape time

Here. (https://pastebin.com/hmr6tCn3)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on July 17, 2017, 05:18:09 PM
I want to make a spell card background that works like Sagume's, how can I create that effect?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 18, 2017, 02:20:08 AM
What part of it? The blending or the motion? If it's the latter, it works the same as Junko's, for which I have a writeup here:
https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1257975.html#msg1257975
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on July 18, 2017, 12:34:56 PM
Soon after i edited, it said angleToPlayer is not defined, I'm not so sure about where to make it defined, any ideas ? https://pastebin.com/qNb1FTts
*if you don't mind, send the full script and i'l try to observe :3
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on July 18, 2017, 12:36:44 PM
the function is GetAngleToPlayer(objBoss)
the script here uses a custom function which I assume does the same thing
just change it and you should be good
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on July 18, 2017, 12:50:23 PM
Soon after i edited, it said angleToPlayer is not defined, I'm not so sure about where to make it defined, any ideas ? https://pastebin.com/qNb1FTts
*if you don't mind, send the full script and i'l try to observe :3
Yep, angleToPlayer is a custom function that I took from Helepolis' tutorials quite a time ago and pretty much kept it unaltered. I wrote it in one of the #include files of the script I took the task from.

PS: I'm currently not home and thus on my mobile, will edit this post and provide pastes of the relevant files as soon as I've returned.


EDIT: Here's the script (https://pastebin.com/JXcQ0EFt) where that task is from (it's called Shot1 there) and my library of miscellaneous functions (https://pastebin.com/6i1DL78z) that contains angleToPlayer.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on July 18, 2017, 01:28:06 PM
What part of it? The blending or the motion? If it's the latter, it works the same as Junko's, for which I have a writeup here:
https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1257975.html#msg1257975
It's the latter, thank you!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Axyo on July 21, 2017, 09:55:06 PM
    Hey guys! I am new in the scripting world, just began this week and I have some problems with a pattern :(. I fact, I don't understand why it does something like that :ohdear:, I need someone to try it and tell me why it does something like that, and how you would fix it :blush::

https://drive.google.com/drive/folders/0Bwf7GLCc6Z9JbWh3NjF3YTlfdW8?usp=sharing

    As you can see, the problem resides in the delay laser. I want my big stars to explode only when hitting the delay laser, but when the laser hits the bottom of the screen and teleport to the top, everything explode, I really don't get it ???.
    I think it's because of the fact that the laser doesn't actually warp to the top, but goes really fast to the top while hitting the stars, which cause the stars to explode, but why? I've set the laser to teleport to the top, it shouldn't do something like that... :ohdear:

    Actually, I was able to fix it, but in a weird way that I don't understand, so I still need someone to tell me how he/she would do :D.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on July 22, 2017, 07:14:21 AM
It's quiet weird while the bullets shoot from the ceiling,haha, what have i done ? https://pastebin.com/2PntFf07
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 22, 2017, 08:43:16 AM
You fire around BossX and BossY. You set these both to be 10 at the start of the file, but never change them. You want to use ObjMove_GetX(objBoss) and ObjMove_GetY(objBoss).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on July 22, 2017, 12:24:29 PM
When i change intersection circle of a shot via ObjShot_SetIntersectionCircleA1 it doesnt intersect with any other objects, making IsIntersected_Obj_Obj impossible to use, while if i dont change the intersection circle, it works fine. Is there any other way to register the intersection of 2 objects except for IsIntersected_Obj_Obj?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on July 22, 2017, 02:32:37 PM
And, .... how to replicate Mishaguji-sama ? :3
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on July 22, 2017, 03:04:49 PM
And, .... how to replicate Mishaguji-sama ? :3

Create two  bullet rings and set opposite angular velocities.

When i change intersection circle of a shot via ObjShot_SetIntersectionCircleA1 it doesnt intersect with any other objects, making IsIntersected_Obj_Obj impossible to use, while if i dont change the intersection circle, it works fine. Is there any other way to register the intersection of 2 objects except for IsIntersected_Obj_Obj?

ObjShot_SetIntersectionCircleA1
Parameters:
 1) object ID (real)
 2) hitbox radius (real)
Creates a hitbox of specified radius for collision detection of the shot object. In order to maintain the hitbox, it must be set every frame. There can be multiple hitboxes set for one shot object.

In other words, set the hitbox every frame and it should work as intended.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on July 22, 2017, 03:16:52 PM
ObjShot_SetIntersectionCircleA1
Parameters:
 1) object ID (real)
 2) hitbox radius (real)
Creates a hitbox of specified radius for collision detection of the shot object. In order to maintain the hitbox, it must be set every frame. There can be multiple hitboxes set for one shot object.

In other words, set the hitbox every frame and it should work as intended.

Yes, i already did make the task to set it every frame, but that still doesnt work, the hitbox changes only for player intersection, and other shots just dont react to that object
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on July 22, 2017, 03:34:09 PM
 while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){
        let angleT = GetAngleToPlayer(objBoss);
        loop(13){
            ascent(i in 0..1){
            CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2.5 - i/3, angleT, 406, 5);
            }
         ObjMove_SetAngularVelocity(obj, -10) ;
            angleT += 360/12;
        }
        wait(50);
    }

any ideas ? it doesn't spin like it...  ???
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Axyo on July 22, 2017, 03:54:05 PM
while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){
        let angleT = GetAngleToPlayer(objBoss);
        loop(13){
            ascent(i in 0..1){
            CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2.5 - i/3, angleT, 406, 5);
            }
         ObjMove_SetAngularVelocity(obj, -10) ;
            angleT += 360/12;
        }
        wait(50);
    }

any ideas ? it doesn't spin like it...  ???

You have to declare your "obj" before assigning your function to it, otherwise it won't do anything. And, your angular velocity is way too high, -10 will make your bullets spin so fast that they won't go anywhere, try something like -0.2. If I was you, I would do:

 while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){
        let angleT = GetAngleToPlayer(objBoss);
        loop(13){
            ascent(i in 0..1){
                 let obj = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2.5 - i/3, angleT, 406, 5);
                 let obj2 = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2.5 - i/3, angleT, 406, 5);
       }
         ObjMove_SetAngularVelocity(obj, -0.2) ;
         ObjMove_SetAngularVelocity(obj2, 0.2);
            angleT += 360/12;
        }
        wait(50);
    }

    I am sure of nothing though. I don't get why you used an "ascent", if you wanna slowdown the speed of your bullets, you can simply use "CreateShotA2".
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on July 22, 2017, 04:18:23 PM
https://pastebin.com/eLFp9uZ0
can obj be 0 ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Axyo on July 22, 2017, 04:33:42 PM
https://pastebin.com/eLFp9uZ0
can obj be 0 ?

Well, if your "obj" is equal to 0, it won't do anything. Think it this way:
your function "ObjMove_SetAngularVelocity" is assigned to who? No one, but to a random "0" that isn't an object or something. Between your parentheses, you have 2 parameters: The first one is the object ID which you wanna assign to your function, the other one is the angular velocity.
     The object ID is your bullet, right? You want say that you want your bullet to have this angular velocity, not a random 0 to have angular velocity, because it means nothing, 0 isn't an object or something. But how to do it? It's simple, you want to declare your bullet as the object to have this angular velocity, to do so you simply write what I wrote:

let obj = CreateShotA1 etc....

What it is going to do, is declare a new local variable, which is obj (you don't need the other one) and will tell to the script that your obj is assigned to your shot. Once you've written this, you can affect your shot by putting your new variable inside your function, I don't know if I was clear enough, my english is quite bad, sorry for this.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on July 22, 2017, 09:00:52 PM
How can I get and object's alpha? I can't find a function that does that.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on July 22, 2017, 09:32:59 PM
How can I get and object's alpha? I can't find a function that does that.
Unfortunately, there is no function for that. If you want to track an objects alpha, you can try to use Get/Set Values (https://dmf.shrinemaiden.org/wiki/Object_Functions#Obj_SetValue) and pass the alpha value through. That way you can some sort of track an object's alpha.

Example:
Code: [Select]
function someObject() {
let obj = ...
let alpha = 200;

Obj_SetValue(obj, "alphaValue", alpha);

return obj;
}

task testRetrieveAlpha() {
let testObject = someObject();

let retrievedValue = Obj_GetValue(testObject, "alphaValue");

<generic text object prints 'retrievedValue'>
}
If the text object is produced, it should report 200. Above can be turned into more "object orientated" methods/functions, but I tried to keep it simple here.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on July 23, 2017, 01:51:37 AM
After i let "let obj = CreateShotA1;", then it says that it's not the correct parameters , any ideas ? .-.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on July 23, 2017, 02:23:40 AM
After i let "let obj = CreateShotA1;", then it says that it's not the correct parameters , any ideas ? .-.

facepalm

Tell me, how many parameters are needed in creating a shot using CreateShotA1?
When you assign to obj and use the CreateShotA1 function, you are creating a bullet and assigning the bullet ID to obj.
So create a shot as normal, and obj will be the ID of the shot.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 23, 2017, 03:44:07 AM
Banana, I would really recommend to go back through tutorials until your basic understanding of scripting improves. Your past few problems have essentially been you typing things in without understanding what it's actually doing. You can't just keep typing whatever and then asking for help when it inevitably doesn't work.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Axyo on July 23, 2017, 11:08:38 AM
    Hey guys! I am new in the scripting world, just began this week and I have some problems with a pattern :(. I fact, I don't understand why it does something like that :ohdear:, I need someone to try it and tell me why it does something like that, and how you would fix it :blush::

https://drive.google.com/drive/folders/0Bwf7GLCc6Z9JbWh3NjF3YTlfdW8?usp=sharing

    As you can see, the problem resides in the delay laser. I want my big stars to explode only when hitting the delay laser, but when the laser hits the bottom of the screen and teleport to the top, everything explode, I really don't get it ???.
    I think it's because of the fact that the laser doesn't actually warp to the top, but goes really fast to the top while hitting the stars, which cause the stars to explode, but why? I've set the laser to teleport to the top, it shouldn't do something like that... :ohdear:

    Actually, I was able to fix it, but in a weird way that I don't understand, so I still need someone to tell me how he/she would do :D.

   Well, I guess no one's going to help me like that so let's be more specific: When I fix this problem, I have some random stars popping out from the top left corner of my screen. I tried all sort of things like cancel the function that make my stars explode when the laser teleport to the top, or deleting all explosion outside from the screen thinking that the small stars were stacking outside from the screen and reappearing at the top left corner, and trying out other things. The conclusion to this would be that all the stars that explode from hitting the delay laser stack for reappearing later, but I didn't ask for this, I don't get it, can someone help me?
    This is a recurrent problem since in my other scripts, I have the same problem with random stuff popping out from the top left corner of my screen. I thought it was because danmakufu could't interpret functions outside from the screen so to fix that it would make them happen at X=0 and Y=0 but now I am lost.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Infy♫ on July 23, 2017, 07:51:36 PM
I'm wondering if there's a ph3 thread for useful code snippets, and/or a library of extra functions to make life easier?

I am currently collecting my own and others' old 0.12m functions and porting them to ph3 to make a wholesome library. If someone did this already, it would be rather useless!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: spexguy718 on July 24, 2017, 01:16:22 AM
Greetings fellow scripters and aspiring scripters! I'm KIND of new to Danmakufu and I'm using Sparen's Danmakufu Tutorial website in order to learn Ph3. However, I'm stuck in this one question and no matter how much I read Part 3 of Lesson 5, it doesn't seem to get into my head. Now I love answering the questions with a little explanation so I can put it in my notes for future reference, but I'm not able to do that since I can't make heads or tails of this question.

Image link to the question: https://ibb.co/gi6R4k

Now it tells me that the answer is B. Now do any one of you know why? I would really appreciate a nice juicy answer from you guys and I thought it would be best to ask this question in the Danmakufu Q&A~
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Axyo on July 24, 2017, 06:37:01 AM
Greetings fellow scripters and aspiring scripters! I'm KIND of new to Danmakufu and I'm using Sparen's Danmakufu Tutorial website in order to learn Ph3. However, I'm stuck in this one question and no matter how much I read Part 3 of Lesson 5, it doesn't seem to get into my head. Now I love answering the questions with a little explanation so I can put it in my notes for future reference, but I'm not able to do that since I can't make heads or tails of this question.

Image link to the question: https://ibb.co/gi6R4k

Now it tells me that the answer is B. Now do any one of you know why? I would really appreciate a nice juicy answer from you guys and I thought it would be best to ask this question in the Danmakufu Q&A~

   It is because ascent loop doesn't actually reach 23, but stops at 23-1, so x = i / 22.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 24, 2017, 06:53:58 AM
Greetings fellow scripters and aspiring scripters! I'm KIND of new to Danmakufu and I'm using Sparen's Danmakufu Tutorial website in order to learn Ph3. However, I'm stuck in this one question and no matter how much I read Part 3 of Lesson 5, it doesn't seem to get into my head. Now I love answering the questions with a little explanation so I can put it in my notes for future reference, but I'm not able to do that since I can't make heads or tails of this question.

It was supposed to say Part 4, which covers loop based control statements. The typo has been fixed. I apologize for the confusion.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 24, 2017, 08:02:00 AM
Now it tells me that the answer is B. Now do any one of you know why? I would really appreciate a nice juicy answer from you guys and I thought it would be best to ask this question in the Danmakufu Q&A~
The minimum value you give ascent/descent is inclusive, while the maximum value is exclusive. The first time the loop runs i = 6, and the last time has i = 22.

I'm wondering if there's a ph3 thread for useful code snippets, and/or a library of extra functions to make life easier?
Not exactly. There are a lot more people scripting now and there are a lot of people rolling their own various systems. At this point you just kind of have to communicate with people and find scripts with useful snippets or bigger libraries that allow reuse.

stuff
Right off the bat: Please, please write and test your code in smaller chunks. Part of why it's difficult to respond to this is because there isn't just one problem to point at; you've written a lot at once and now instead of a simple answer there are a bunch of things to look at.

- The main problem is the line while(ObjMove_GetY(n) < x){yield;}. You want the star to travel along until the value of x passes the star, and then it spawns the bullets, so the correct line is the while(ObjMove_GetY(n) > x){yield;}. What happens here is that when x starts below the stars, the first while condition is true (ObjMove_GetY(n) > x). Then maybe at some point x passes the star, so that breaks the while loop and then next one starts, but that one is (ObjMove_GetY(n) < x) which is now true, so it will continue to wait. Once x hits the end of the screen and resets, the loop then breaks because the condition is suddenly false, and the explosion happens. But it's like this for every star so they just all explode at the same time.

- The reason why your added line "fixes" the problem is the same as why things are spawning in the corner. When things start spawning in the corner, that typically means something is referencing an object that has already been deleted. Using something like ObjMove_GetX on a deleted object will return 0. What your if(x > GetStgFrameHeight - 200){wait(180);} line does is check if x is low enough on the screen and then wait three seconds. When this happens, the star bullets are probably going to fly off the screen and be deleted before that time is up, so ObjMove_GetX(n) returns 0. Eventually x will be below 0 (like -30) and later above 0, and after both of these the explosion will trigger. But this is completely different to what you actually want, so it only "looks" like it fixes the problem.

- Your laser task creates a new laser every three frames. It creates a laser, then waits one frame, then deletes it, waits another frame, and then loops. This is definitely not what you want; by the sound of it you want to just create one laser, and just have it continually move down and then teleport back to the top. Getting rid of the Obj_Delete(obj) will fix this. You also shouldn't need the outer loop with the boss life check at all.

- Minor note: You should move the stuff controlling the x variable into its own task rather than putting it in the MainLoop, or even move it into the laser task. Partially because it's cleaner, but also because you can then control when it begins and ends.

- Minor note: The line if(ObjMove_GetY(obj3) > GetStgFrameHeight){Obj_IsDeleted(obj3)} (also the obj2 one) won't do anything. You want Obj_Delete(obj3) instead.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on July 24, 2017, 01:59:09 PM
   Well, I guess no one's going to help me like that so let's be more specific: When I fix this problem, I have some random stars popping out from the top left corner of my screen. I tried all sort of things like cancel the function that make my stars explode when the laser teleport to the top, or deleting all explosion outside from the screen thinking that the small stars were stacking outside from the screen and reappearing at the top left corner, and trying out other things. The conclusion to this would be that all the stars that explode from hitting the delay laser stack for reappearing later, but I didn't ask for this, I don't get it, can someone help me?
    This is a recurrent problem since in my other scripts, I have the same problem with random stuff popping out from the top left corner of my screen. I thought it was because danmakufu could't interpret functions outside from the screen so to fix that it would make them happen at X=0 and Y=0 but now I am lost.

Check this: http://sparen.github.io/ph3tutorials/ph3u2l16.html
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on July 25, 2017, 05:53:23 AM
Axyo, Crested might have posted the link to Sparen's tutorial to solve his specific scenario, but it doesn't explain the underlying problem. In the summary however it does report something important: "Avoid spawning bullets from nonexistent or deleted enemies". Not just enemies, objects more specifically as enemies are objects. Stuff spawning at 0,0 (top left corner) is 99,99% of the time a programming error.

First you should know is that Danmakufu is perfectly capable of spawning things beyond the visible playing field. Regular bullets however will be auto-deleted if they exceed the auto-delete boundaries for bullets. Objects on the other hand, just like in 0.12m, will ignore this.

The underlying problem I explained here answering ombsik33's problem which is similar issue just different scenario: https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1298751.html#msg1298751


Edit:
Your mention about all stars exploding when hitting your delay laser might be due to all stars being "linked" to the same laser or sharing the same object or variable reference for each bullet. Doesn't seem to sound as if each star bullet object has individual behaviour.

Edit2:
I've checked your SP2.cs script and I can see that it doesn't. What you need to do is create an object bullet (star) and put in the behaviour that if the star interacts with the laser, then it will explode itself. Right now you're referencing each new CreateShotA1 to the same variable and passing that to explosion(n) task. You need something like this:

Code: [Select]
task starBullet(x,y,velocity,angle,bulletType,delay) {
let obj = ...

while(!Obj_IsDeleted) {
if(I interact with the laser complicated statement code) {
explosion(obj);
Obj_Delete(obj);  // <--  if explosion is a task and not a tunction then 0,0 spawning issue might occur.
}
}
}

function explosion(obj) {
// do whatever new explosion stars you want to create here using CreateShotA1
}

Now each starBullet you spawn has its own individual behaviour and will only delete/explode itself when the statement is true.

There is one important thing to keep in mind here. If you intend to delay creation of new bullets in explosion(obj) then don't delete the starBullet in its own while loop but at the end of the function. Why? Because the next line of code is Obj_Delete. Which will delete the starBullet. So any new bullets being spawned after deletion will result in spawning at 0,0. You could merge the explosion behaviour within the while loop and safely delete the object afterwards. You could move the Obj_Delete to the function as well. That is all up to you.

Edit3:
So many edits. I have to correct my statement about Obj_Delete. In case of functions, it is not a parallel event. If I am not mistaking, even if you delay the code in the function, Obj_Delete won't be executed until the function has finished all its own code. Only if this were to be a task, then Obj_Delete would be executed as tasks are executed parallel, hence the whole "multi tasking/threading". I've used strike through to edit out the text, but it is in my opinion still valuable knowledge.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Axyo on July 25, 2017, 04:10:48 PM
   First of all, thanks to everyone who answered to my problem, I didn't expect anyone to do it x). You are all great!

< snip >

   I always check if my code works after adding few lines, but when I am facing problem like this one,  I happen to try a bunch of things but indeed, I've let all those things stack up unecessarily so it may looks like I don't often try my code.

    - If I get rid of while(ObjMove_GetY(n) < x){yield}", the problem will just be worst as the stars will directly explode when they spawn. What this line does is it prevents the stars to explode directly, because I want my stars to only explode when they reach x. But, I think you are kinda wrong in your reasoning without willing to be pretentious, because what my line does is see if the stars are above x, and then only if it becomes false see if the stars and under x and only then reading the next part of my task. The explosion doesn't occur as long as those 2 conditions aren't false. That's what I think anyway, I might be wrong as I am still new.
    - For if(x > GetStgFrameHeight - 200){wait(180);}, I couldn't think of another way to "solve" the problem because all my stars kept exploding at the same time when the laser was teleporting to the top, but now thanks to you I know the reason of why random stars pop at (0;0) so thanks :D (I still can't figure out how to solve my problems though.)
    - For my lasers, if I get rid of Obj_Delete(obj) it will be problematic, as the laser will eventually reach the end of its delay and spawn as enemy projectiles, and that's not what I want. I only want a delay laser. The first idea was to make interact the spawned laser with stars, but I couldn't find a way to do it so it ended only using my delay laser.
    - Well, for shifting my "x" to the laser's loop instead of keeping it in my mainloop, I don't see an efficient way to easily do it and I wanna limit the amount of occurring problems, so I won't do it for now. If I move it to laser's loop, it will make things harder as x won't progress independently from the task, so it will create new problems that I will probably struggle a lot to fix, that's the reason why it is not in the laser's loop.
    -For  if(ObjMove_GetY(obj3) > GetStgFrameHeight){Obj_IsDeleted(obj3)} (and with obj2), I have to agree with you, those lines are useless.


< snip >

   Ok, it took me a long time but I wrote back all the code for shooting my stars in your way. As conclusion to this, I've found that even if I've changed the behaviour of all my stars to make them independent through your method, it doesn't work (sorry, I tried my best but it still doesn't work). Here's my code:

https://pastebin.com/EXLvcTjZ

   As Drake mentionned it earlier, the problem resides in fact in my conditions line when my stars hit x. Indeed, my stars don't interact with my lasers but with x, because I couldn't figure out how to make them interact. The problem is right here:
while(ObjMove_GetY(obj2) > x){yield;}
while(ObjMove_GetY(obj2) < x){yield;}

   I can't find a way to write it as an "if" condition, so I end up with those two "while". With your method, the problem is only shifted from the "explosion" function to the task "starBullet" :/. There are few things that I didn't understand in what you said:
   -The behaviour of the bullet has to be independent for each bullet. What will this do? In my way to right things, I decided to do this in my ascent and descent loops by deleting them, so when each star reach x they delete.
   - Even if I use "explosion" as a function, stars keep popping out from (0;0), so I don't know anymore x).

edit: I guess I am still not good enough to make things like this, I probably should give up for now and come back later when I'll have more materials to work with. I am out of idea for this :/
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: RyanPrice on July 25, 2017, 04:59:57 PM
Hi guys,

how do I change the colour of the bullet when it goes through a moving laser?

!!Do not approve. I think I have found solution!!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 26, 2017, 04:00:58 AM
I was trying to lead you to the right idea because you're like 90% of the way to the answer. Here's a picture showing from spawn to explosion:

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

This should illustrate why writing those conditions in that order will not work as you intend.


As for the delay laser, I just didn't realize you wanted it to be like that. This is way more easily done either by:
Code: [Select]
let b = CreateStraightLaserA1(200, 100, 90, 512, 2, 0, SHOT_RING_RED, 10000);or
Code: [Select]
let b = CreateStraightLaserA1(200, 100, 90, 512, 2, 10000, SHOT_RING_RED, 0);
ObjShot_SetIntersectionEnable(b, false);
And maybe making it resistant to bullet cancels or something if you need to.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Axyo on July 26, 2017, 10:08:08 AM
stuff

   Okay, I now fully understand what's wrong in my way of thinking. I thought the 2 while had to be false at the same time for the script to continue to read what's next.
   But, even if I try to write it as while(ObjMove_GetY(obj2) ==  x ){stuff} or while(ObjMove_GetY(obj2) != x){yield;} nothing happens. The only explanation I see to this is because this never happens as the stars can't detect 1pixel of height, to experimment if it's true or not I don't know how to transform x to an interval (ex: x = [x - 1 ; x + 1]). Another explanation would be that if I set the speed of the stars to 3, they move 3 pixels by 3  so they have 33% chance to touch x if they move perpendicularly compared to x, but it's kinda dumb as nothing explode (even if I set the speed to 0.5).
   I tried if(ObjMove_GetY(obj2) == x){stuff} too but it's the same each time, nothing seams to happen when the stars pass through x.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 26, 2017, 11:10:06 AM
The only explanation I see to this is because this never happens as the stars can't detect 1pixel of height
Well, basically. That will only work if the two numbers are actually equal, which is probably not going to ever happen when you're using random angles and velocities that will cause the bullet's y-position to rarely be exact integers. In general you shouldn't be looking for exact equality with something like this because of how unpredictable the numbers are.

It's good that you're considering "being inside of a range" because that's also a good approach. I'll just give you the solutions here because you're close enough.

If you swapped the two while conditions, i.e.
Code: [Select]
while(ObjMove_GetY(obj2) < x){yield;}
while(ObjMove_GetY(obj2) > x){yield;}
it would work as intended. If you look at the picture I posted and work out what would happen when the conditions are swapped, you would find that for the same reason the current way fails (the second condition only checks once you finish the first one), this way would succeed.

As for the range check approach, this is essentially a kind of distance calculation.
Code: [Select]
if( (|ObjMove_GetY(obj2) - x|) < 4){ explode(); }Where 4 here is just the range, and the (| |) are for taking the absolute value. For example, if the bullet's y-position is 200, and x is 198, then |200 - 198| = 2, which is less than 4. And if x were 203, then |200 - 203| = 3. So this way would also work fine.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Axyo on July 26, 2017, 11:31:25 AM
stuff
   Oh my god, I completely forgot that danmakufu doesn't only read integer numbers but can also read infinitesimal numbers, so indeed, the odds to have the same numbers is null. And for if( (|ObjMove_GetY(obj2) - x|) < 4){ explode(); }, I would never have thought of this, it's quite clever. For the "while" solution, I feel dumb too x)
  Anyway, thanks a lot for taking the time to explain everything to me and make me work on it!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on August 06, 2017, 01:21:03 PM
https://pastebin.com/3cAWuCQ2
Sorry for breaking the silence, but this is the problem i wanted to solve very much and a very long time ago...

I wanted to make this magic circle so I replicated some and observed it , it can run, but a few seconds later this happened.
*some of them are added on my desire

Variables of different types are being compared
(型が違う値同士を比較しようとしました)
I:/th_dnh_ph3/script/test MC/test.txt
test.txt line(行)=74


   if(type==true){
   ObjRender_SetScaleXYZ(obj,size+0.2*sin(spin),size+0.2*sin(spin),2);
   }
   ObjMove_SetPosition(obj,ObjMove_GetX(objBoss), ObjMove_GetY(objBoss));
   yield;
   }
   Obj_Delete(obj);
   }

task txt{
   let objText = ObjText_Create();
    O
~~~

Edit : Even this thread have answers, but post it here 1 more time if you all don't mind, it's like more notes to me

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on August 06, 2017, 02:55:14 PM
Variables of different types are being compared
(型が違う値同士を比較しようとしました)
I:/th_dnh_ph3/script/test MC/test.txt
test.txt line(行)=74


   if(type==true){

In your code (Line 13):
let type = 0;

0 cannot be compared to true in Danmakufu.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on August 08, 2017, 12:27:06 PM
Need help here!

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

As I have seen on Nezu Akitsu's |Hoshikami (Star Fox) "Akitsu Nebula"| from Tri Focuser, I might have a grasp difficulty while I'm thinking of creating a shaped laser in a radius like the one with a triangle picture spinning.

Anyone who have knowledge to do about spinning shape lasers? Please Respond!

I've been waiting till December for one of my first complete scripts to be done! :ohdear: :ohdear:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on August 08, 2017, 12:44:44 PM
Need help here!

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

As I have seen on Nezu Akitsu's |Hoshikami (Star Fox) "Akitsu Nebula"| from Tri Focuser, I might have a grasp difficulty while I'm thinking of creating a shaped laser in a radius like the one with a triangle picture spinning.

Anyone who have knowledge to do about spinning shape lasers? Please Respond!

I've been waiting till December for one of my first complete scripts to be done! :ohdear: :ohdear:
What is exactly your question?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on August 08, 2017, 12:51:48 PM
I think he wants to know how to make a spinning shape made of lasers.

HumanReploidJP you're not a native speaker, are you?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on August 08, 2017, 12:58:30 PM
I think he wants to know how to make a spinning shape made of lasers.

HumanReploidJP you're not a native speaker, are you?
I am aware what the user wishes/desires, but no specific question was stated. It doesn't really helps to increase font size, change colours and bold out things. Mark up is useful when used proper. Not like this.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on August 15, 2017, 12:00:05 PM
Oh. sorry about that. My bad.

I'll have to keep that in mind as usual for regular text, not the changed ones.

By the way, I'm not a speaker.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: TheTeff007 on August 17, 2017, 11:05:05 AM
So I'm having a little issue with a code. Works, just not as I expected: https://pastebin.com/g9cXaTK4

The player will be filling that bar as they get the corresponding item. However, the bar graphic extends from both sides instead of from down-to-above, leading to this effect: (gauge effect purposefully put on the middle to show full effect, otherwise it will just show a half-full meter) http://imgur.com/a/JpUdB

Since I'm porting my code from an old 0.12m script of mine, the codes don't really translate well. How could I get around this?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on August 17, 2017, 12:18:46 PM
If you use SetDestCenter on an object so it is always drawn centered, then keep making the object taller, what is going to happen?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: TheTeff007 on August 17, 2017, 11:49:01 PM
So since the size of the image is: ObjSprite2D_SetSourceRect(obj1, 0, 0, 16, 111);

Then the solution is: ObjSprite2D_SetDestRect(obj1, -55, -8, 55, 8);

Or what should I do to fix it?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on August 18, 2017, 12:38:16 AM
Say the object has a y-position of 400. If the rectangle is (-8, -50, 8, 50), the top of the graphic will be at y=350 and the bottom is at y=450. If you make the rectangle bigger on both ends it will keep stretching outwards on both ends; the object is still centered at 400. If you want the bottom of the rectangle to stay at 400 but have the top go up to 300, the box will have to be (-8, -100, 8, 0). To make the rectangle larger only in one direction you only need to make that one direction extend.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: TheTeff007 on August 18, 2017, 08:58:59 AM
Worked as Intended. Thanks Drake!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Trung0246 on August 26, 2017, 11:53:36 PM
When I try
Code: [Select]
WriteLog((16.1 - 16) == 0.1); it return
Code: [Select]
false while
Code: [Select]
WriteLog(ator(16.1 - 16) == 0.1); return
Code: [Select]
trueAnyone know why?

I guess it some kind of memory related issue, as my current OS is Window 10 64 bit

It also did the same behavior with 15.1 - 15, 14.1 - 14, ...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on August 27, 2017, 01:42:02 AM
http://en.wikipedia.org/wiki/Floating_point
http://stackoverflow.com/questions/588004/is-floating-point-math-broken
Also https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1168873.html#msg1168873

It isn't a problem, it's just a natural consequence of how computers store numbers.

You shouldn't be relying on testing non-integer values for precise equality anyways (integer calculations work perfectly fine, though), especially if it's a number like a position or angle that's constantly changing, so really this whole thing should never be an issue anywhere to begin with.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on August 31, 2017, 07:14:02 AM
Hi again from my very stupid questions
1. So I made a magic circle but I think it was unstable and it moves not in the center but pushing left and right ...
it looks weird so I ask it, this is the code:
task magiccircle(objBoss,size,type){
   let obj=ObjPrim_Create(OBJ_SPRITE_2D);
   let GCSD = GetCurrentScriptDirectory;
   let img=GCSD~"MG (2).png";
   let spin = 0;
   let s = 0;
   LoadTexture(img);
   ObjPrim_SetTexture(obj,img);
   ObjSprite2D_SetSourceRect(obj,0,0,256,256);
   ObjSprite2D_SetDestCenter(obj);
   ObjRender_SetScaleXYZ(obj,size,size,size);
   ObjRender_SetAlpha(obj,230);
   Obj_SetRenderPriority(obj,0.35);
   while(!Obj_IsDeleted(objBoss)){
   spin += 3;
   ObjRender_SetAngleXYZ(obj,0,0,-spin*1.5);
   ObjRender_SetPosition(obj,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),0);
   if(type==true){
   ObjRender_SetScaleXYZ(obj,size+0.2*sin(spin),size+0.2*sin(spin),0);
   }
   ObjMove_SetPosition(obj,ObjMove_GetX(objBoss), ObjMove_GetY(objBoss));
   yield;
   }
   Obj_Delete(obj);
}

2. I like scripting but i really suck at cut-in's, so if you all dont mind help me as well thanks so much :3 https://pastebin.com/BNQEF2VA
and i run the script  this happened  :ohdear: :ohdear:  (sorry for interruption but i suck doing these..)
Variables of different types are being compared
(型が違う値同士を比較しようとしました)
I:/th_dnh_ph3/script/function_cutin.txt
function_cutin.txt line(行)=67


   if(type == 0) { x = GetClipMaxX; y = GetCenterY+10; }
   if(type == 1) { x = GetClipMaxX+256; y = GetCenterY-120; }
   if(type == 2) { x = GetClipMinX-256; y = GetCenterY; }

   // handlers
   summontext;
   summonhexagon;
   cutinEffect_Alphret(obj,as,alphre
~~~
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on August 31, 2017, 07:05:32 PM
About #2, it seems you're trying to use my cutin script and I have no idea why that error shows up. It points at the function_cutin.txt script for some reason. Did you edit any thing in there?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on August 31, 2017, 10:10:20 PM
2. I like scripting but i really suck at cut-in's, so if you all dont mind help me as well thanks so much :3 https://pastebin.com/BNQEF2VA
and i run the script  this happened  :ohdear: :ohdear:  (sorry for interruption but i suck doing these..)
Variables of different types are being compared
(型が違う値同士を比較しようとしました)
I:/th_dnh_ph3/script/function_cutin.txt
function_cutin.txt line(行)=67


   if(type == 0) { x = GetClipMaxX; y = GetCenterY+10; }
   if(type == 1) { x = GetClipMaxX+256; y = GetCenterY-120; }
   if(type == 2) { x = GetClipMinX-256; y = GetCenterY; }

   // handlers
   summontext;
   summonhexagon;
   cutinEffect_Alphret(obj,as,alphre
~~~
You have the wrong number of arguments for the cutin function. It requires (type,spellcardname,cutinImg,left,top,right,bottom). You're missing the spell card name. I imagine that the error has resulted from argument 3, cutinImg, being a number instead of a file path string like it's supposed to be. Danmakufu's error messages are not always very good at pinpointing the precise location of the error.

Edit: Actually, if it was just the wrong number of arguments then Danmakufu would have complained about that (I think). There might be more wrong than there seem to be but that's definitely a problem nonetheless.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on August 31, 2017, 10:43:19 PM
Hi again from my very stupid questions
1. So I made a magic circle but I think it was unstable and it moves not in the center but pushing left and right ...
it looks weird so I ask it, this is the code:
task magiccircle(objBoss,size,type){
   let obj=ObjPrim_Create(OBJ_SPRITE_2D);
   let GCSD = GetCurrentScriptDirectory;
   let img=GCSD~"MG (2).png";
   let spin = 0;
   let s = 0;
   LoadTexture(img);
   ObjPrim_SetTexture(obj,img);
   ObjSprite2D_SetSourceRect(obj,0,0,256,256);
   ObjSprite2D_SetDestCenter(obj);
   ObjRender_SetScaleXYZ(obj,size,size,size);
   ObjRender_SetAlpha(obj,230);
   Obj_SetRenderPriority(obj,0.35);
   while(!Obj_IsDeleted(objBoss)){
   spin += 3;
   ObjRender_SetAngleXYZ(obj,0,0,-spin*1.5);
   ObjRender_SetPosition(obj,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),0);
   if(type==true){
   ObjRender_SetScaleXYZ(obj,size+0.2*sin(spin),size+0.2*sin(spin),0);
   }
   ObjMove_SetPosition(obj,ObjMove_GetX(objBoss), ObjMove_GetY(objBoss));
   yield;
   }
   Obj_Delete(obj);
}
Just tested your code out and it works actually perfectly fine. Perhaps the graphic you're using isn't precisely centered, causing the circle to behave strangely (as you've described).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on September 01, 2017, 08:00:11 AM
Thanks so much for all your help, I'm so happy right now  :) :) (well question no 2 is solved)
I found out the cut function worked out just fine, but its only without Backgrounds https://pastebin.com/rEHEszEK
with the backgrounds the cut in is failed to show, what is happening to the BG ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 01, 2017, 01:18:38 PM
I found out the cut function worked out just fine, but its only without Backgrounds https://pastebin.com/rEHEszEK
with the backgrounds the cut in is failed to show, what is happening to the BG ?

Consider this:

In one test, you clarified that the cutin function worked fine without the background task running, correct? Now, when you begin running the background task as well, it seems that the 'cutin fails to show' - but what exactly does this mean? Does the spell name show? Spell history? Cutin image? Cutin sound effect? See what does and does not perform as expected.

If only the image does not render, then check your render priorities. If the entirety of the cutin script fails to run, then perhaps your error is more fundamental.

Quick and effective debugging is an important skill. Make use of RaiseError() and other debug functions to figure out what code is running and what code is simply having its effects rendered invisible by another piece of code.

Additionally, I recommend background scripts for backgrounds.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Haedes on September 03, 2017, 07:35:16 PM
I've been reading Sparen's tutorials (great thanks, Sparen, they are awesome!) and saw something here (http://sparen.github.io/ph3tutorials/ph3u2l19.html):
Quote
The assigned rects are SCREEN_WIDTH and SCREEN_HEIGHT, or 640 and 480 respectively (depending on what was set in your def file, if you use one).
I have the following in my th_dnf.def:
Code: