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: [Select]
screen.width = 1024
screen.height = 768
But SCREEN_WIDTH/SCREEN_HEIGHT seem to provide old values (640 and 480, respectively) nonetheless. Why do they behave like that? Or should I write something else in .def file in order to get new values from these constants? Haven't seen anything related in this thread and wiki.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 05, 2017, 12:17:02 PM
SCREEN_WIDTH and SCREEN_HEIGHT are constants - they are set to 640 and 480 regardless.

To obtain the CURRENT width and height of the scree, use GetScreenWidth() and GetScreenHeight()
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on September 07, 2017, 11:45:09 AM
When using CreateShotB, can you change the X and Y speed/acceleration after firing the bullet?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 07, 2017, 07:12:17 PM
There is an AddPatternB series just like AddPatternA.

https://dmf.shrinemaiden.org/wiki/Move_Object_Functions#ObjMove_AddPatternB1

That being said, there is no such thing as directly setting "x-speed" and "y-speed" as you would with ObjMove_SetSpeed and SetAngle because CreateShotB and AddPatternB probably just convert into speed and angle anyways. If needed you can calculate this yourself with
Code: [Select]
speed = ( x_speed^2 + y_speed^2 )^0.5
angle = atan( y_speed / x_speed )
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on September 07, 2017, 07:40:25 PM
There is an AddPatternB series just like AddPatternA.

https://dmf.shrinemaiden.org/wiki/Move_Object_Functions#ObjMove_AddPatternB1

That being said, there is no such thing as directly setting "x-speed" and "y-speed" as you would with ObjMove_SetSpeed and SetAngle because CreateShotB and AddPatternB probably just convert into speed and angle anyways. If needed you can calculate this yourself with
Code: [Select]
speed = ( x_speed^2 + y_speed^2 )^0.5
angle = atan( y_speed / x_speed )
Oh, I see. Sometimes I kinda forget AddPattern exists :V
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 07, 2017, 08:08:22 PM
Yeah, but if you didn't want to use it, you could set up a task that changes the x-speed and y-speed by converting it to speed and angle with those formulas, and using ObjMove_SetSpeed and ObjMove_SetAngle instead.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on September 08, 2017, 04:24:26 PM
Hi again from me, my creativity sucks
1。 firing questions, I can't make the style like after the laser spin its trail leaves bullets(and then the bullet falls)
How can I do that ? :
task fireA{
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){
   wait(380);
   let lpcnt = 0;
   loop(4){
   let laser = CreateStraightLaserA1(ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),90*lpcnt,300,10,150,7,200);
   lasercontrol(laser);
   lpcnt++;
   }

  }
}
   
task lasercontrol(laser) {
let lpcnt = 0;
while(!Obj_IsDeleted(laser)){
   ObjStLaser_SetAngle(laser,ObjStLaser_GetAngle(laser)+0.7);
   lpcnt++;
   yield;
   }
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 09, 2017, 04:40:49 PM
So basically you want bullets to spawn along the laser? You would do this by getting the position and angle of the laser, and then spawning bullets offset from that position, in a line along that angle. Conceptually it's the same as making a rings of bullets around a boss, for example, but the "ring" size is the laser length.

Code: [Select]
let x = ObjMove_GetX(laser);
let y = ObjMove_GetY(laser);
let a = ObjStLaser_GetAngle(laser);
let len = ObjLaser_GetLength(laser);
let num = 8;
ascent(i in 0..num){
  let dist = i*len/num;
  let shot = bullet(x + cos(a)*dist, y + sin(a)*dist); // make a bullet, this is just the xy position
  movebullet(shot);
}

task movebullet(shot){
  // do whatever bullet movement
}

Something like this.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on September 10, 2017, 09:05:20 AM
  let shot = bullet(x+cos(a)*(i*len/num), y+sin(a)*(i*len/num)); // this is just the xy position
Sorry I am dumb, May i know what and how is the "bullet" functioned ? I can't make it defined or getting it right
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 10, 2017, 03:59:31 PM
By that I just mean firing a bullet at that position. The x-position is x + cos(a)*dist and the y-position is y + sin(a)*dist; anything else you want (like bullet angle and speed, or if you want to run another task for the bullet's behavior) you can choose yourself.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on September 12, 2017, 12:34:32 AM
Hello!
I have another problem. I was following Sparen's tutorial for making snaking lasers, but the bullets don't appear at all. I'm not sure what to do.
Here is the script:

task MainTaskA{
   
      while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){
      let wait = 180; 
      loop(wait){yield;} 
      fireA;
     
     
   }
   
   task fireA{
   let px = GetPlayerX();
        let py = GetPlayerY();
   let angleT = 0;
   ascent(i in 0..12){
   let obj = CreateCurveLaserA1(bossX, bossY, 4, GetAngleToPlayer(objBoss) + i*360/12, 60, 18, C_LASER_RED, 10);
   SnakePattern(obj, 1);
   }
   
   }
   
   task SnakePattern(obj, dir){
   let wvel = 1*dir;
   ascent(i in 0..12){
   ObjMove_AddPatternA2(obj, i*30, NO_CHANGE, NO_CHANGE, NO_CHANGE, wvel, NO_CHANGE);
   wvel *= -1;
   }
   }
   
   
   
}


Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gregory on September 13, 2017, 04:41:31 AM
Hello!
I have another problem. I was following Sparen's tutorial for making snaking lasers, but the bullets don't appear at all. I'm not sure what to do.
Here is the script:

task MainTaskA{
   
      while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){
      let wait = 180; 
      loop(wait){yield;} 
      fireA;
     
     
   }
   
   task fireA{
   let px = GetPlayerX();
        let py = GetPlayerY();
   let angleT = 0;
   ascent(i in 0..12){
   let obj = CreateCurveLaserA1(bossX, bossY, 4, GetAngleToPlayer(objBoss) + i*360/12, 60, 18, C_LASER_RED, 10);
   SnakePattern(obj, 1);
   }
   
   }
   
   task SnakePattern(obj, dir){
   let wvel = 1*dir;
   ascent(i in 0..12){
   ObjMove_AddPatternA2(obj, i*30, NO_CHANGE, NO_CHANGE, NO_CHANGE, wvel, NO_CHANGE);
   wvel *= -1;
   }
   }
   
   
   
}

I have tried the code in my dmf, it seems the problem is in the AddPatternA2 with Acceleration (5) and MaxSpeed(7) shouldn't be typed "NO_CHANGE" since I switched it to 0, it worked perfectly

ObjMove_AddPatternA2(obj, 30*i, NO_CHANGE, NO_CHANGE, 0, snek, 0);
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on September 14, 2017, 03:23:25 PM
  let shot = bullet(x + cos(a)*dist, y + sin(a)*dist); // this is just the xy position
I regret (probally) from posting this pathetic reply
I'm not sure what happened but i only have weekends to do this ...  https://pastebin.com/7HmveRuf
Problem :
sub and task cannot call in the statement.
(subやtaskは式中で呼べません)
I:/th_dnh_ph3/script/Improvement C11/test.txt
test.txt line(行)=93


    let shot = bullet(x + cos(a)*dist, y + sin(a)*dist); // this is just the xy position
}
   lpcnt++;
   }
  }
}
   
task lasercontrol(laser) {
let lpcnt = 0;
while(!Obj_IsDeleted(laser)){
   ObjStLaser_SetAngle(laser,ObjStLaser_GetAngle(laser)+0.7);

~~~
Now good, I wish i could solve this complicated question because I'm simply too young to understand

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 14, 2017, 05:42:15 PM
Now good, I wish i could solve this complicated question because I'm simply too young to understand

bullet() is a task. Tasks have no return values.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 14, 2017, 10:23:39 PM
Woah, that was actually my fault. I originally had correct statements and then later edited to that, must have been tired.

You either want to keep bullet a task and have both the bullet creation and its running stuff within that task, and remove just the let shot = that expects a return value,
or
You make bullet a function that returns a shot object (or use a CreateShot function), and write a task that works on that object (as I've edited back into my original post).


You've misunderstood what I I want you to do with the bullet() call. I literally just mean fire whatever bullet you want, but at that specific position.
First of all, you should move the code block. The point is to be spawning bullets every so often while the laser is spinning, so you could move it into lasercontrol or make a separate task. Then replace the line
Code: [Select]
let shot = bullet(x + cos(a)*dist, y + sin(a)*dist);with
Code: [Select]
let shot = CreateShotA1(x + cos(a)*dist, y + sin(a)*dist, 2, 90, 45, 10);Just to show what it should be doing. This should spawn individual bullets that just move down, but because they're in that ascent loop there will be eight of them at once.

Here is the fireA task with the above changes: https://pastebin.com/ce7T4PXY
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MitoriKawashiro on September 20, 2017, 02:33:38 PM
Eee, im so new to this scripting stuff can someone tell me, how to make two bosses with hitboxes and its own hp? like yatsuhashi and benben or satono and mai fight? Im using aldryn system btw
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on September 20, 2017, 04:01:55 PM
Eee, im so new to this scripting stuff can someone tell me, how to make two bosses with hitboxes and its own hp? like yatsuhashi and benben or satono and mai fight? Im using aldryn system btw
Making two bosses is done spawning the second boss as a regular enemy. Enemies logically have their own hitbox and life before they "die". See the wiki for the required functions to define these.

I have no idea what an aldryn system is. Google isn't helping me either.

Since you're new to this stuff. What kind of experience do you even have when it comes to Danmakufu?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 20, 2017, 07:15:55 PM
Im using aldryn system btw

If you're using Jan Aldryn Bio's system, then you'll have to ask him how to use it. Nobody except the creator understands their system fully.

Additionally, if you don't understand how his system works on a fundamental level, I highly advise you start from scratch - that way you can learn and master the basics on your own. See https://dmf.shrinemaiden.org/wiki/Tutorials_(ph3) (https://dmf.shrinemaiden.org/wiki/Tutorials_(ph3)) for tutorials
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MitoriKawashiro on September 21, 2017, 12:31:35 AM
Making two bosses is done spawning the second boss as a regular enemy. Enemies logically have their own hitbox and life before they "die". See the wiki for the required functions to define these.

I have no idea what an aldryn system is. Google isn't helping me either.

Since you're new to this stuff. What kind of experience do you even have when it comes to Danmakufu?

Eh, sorry, i mean, with circle lifebar like TD, GFW, DDC, LoLK, HSIFS, etc.

im suddenly addicted with bullet patterns tho, so i only focused in composing such patterns by myself, and im learning from some presets like spell card collection
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on September 21, 2017, 07:30:20 AM
im suddenly addicted with bullet patterns tho, so i only focused in composing such patterns by myself, and im learning from some presets like spell card collection
I was actually wondering about your technical knowledge, such as objects, primitives, sprites, methods and so on. Have you ever created 2D and 3D sprite effects?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MitoriKawashiro on September 21, 2017, 12:34:39 PM
I was actually wondering about your technical knowledge, such as objects, primitives, sprites, methods and so on. Have you ever created 2D and 3D sprite effects?
Mmmno, im using some completed single script and just change the sprite using gizmo's sprite library, i never create such render object before
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on September 21, 2017, 12:53:16 PM
Mmmno, im using some completed single script and just change the sprite using gizmo's sprite library, i never create such render object before
I was afraid of that. Nothing personal, however, explaining things now isn't going to help you. I am not going to program it for you. If somebody else already has such a feature and allowing it to be used then that would be easiest for you. I don't have circular life bars in my own game so my help ends here.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MitoriKawashiro on September 21, 2017, 01:07:02 PM
I was afraid of that. Nothing personal, however, explaining things now isn't going to help you. I am not going to program it for you. If somebody else already has such a feature and allowing it to be used then that would be easiest for you. I don't have circular life bars in my own game so my help ends here.

Oh, My bad

Also, How to make a Ring of bullet that will drops down like CreateShotB2?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gregory on September 21, 2017, 05:14:34 PM
Oh, My bad

Also, How to make a Ring of bullet that will drops down like CreateShotB2?

if you meant it acted like it has gravity then try using ObjMove_AddPatternB2

also, how can I let the script read before going to the plural script, it took like 4 ,5s to read every single script in the plural and that makes all players nervous...

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MitoriKawashiro on September 22, 2017, 05:13:30 AM
if you meant it acted like it has gravity then try using ObjMove_AddPatternB2


yeah but in a default or simple ring before the bullets separated away
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 22, 2017, 05:34:34 AM
http://sparen.github.io/ph3tutorials/ph3u1l11.html
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gregory on September 22, 2017, 06:28:18 AM
yeah but in a default or simple ring before the bullets separated away

uhhh... first you shoot a ring then AddPatternB2 to it, what do you mean by default ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on September 25, 2017, 03:15:05 AM
Hello!
It's Dire again here. The wiki doesn't really have any tips on making a dialogue scene, so how do I do that? How does one go about making a dialogue scene in danmakufu?
Thanks!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Fujiwara no Mokou on September 25, 2017, 03:34:10 AM
Here's a curious question; has MKM fixed the alpha rendering in PH3 so that objects with less transparency in alpha rendering no longer get darker? Internally, in v1.2m, using ObjEffect_SetVertexcolor(obj, idx, rgba) multiplied the rgb by a factor of a. So in the shader, so we'd get something like: color.rgba = (color.a * color.rgb, color.a) // internally, rgba are values of 0-1.

Has this been fixed? I went to great lengths to do the color-correction last time, but I'm not sure if I want to make another minigame if it hasn't.
Also, what about the pixel-perfect issue? PLEASE tell me that was fixed too.
I.e. I want some of my bullets look like this:
(https://image.ibb.co/ngxv4Q/pixel_perfect.png)

And not have the the artifacts like I had in the past when rendering similar bullets:
(https://image.ibb.co/coa4yk/non_pixelperfect.png)

Apologies if these questions seem a bit noobish. I haven't been active in the community for a long, long time.
I'm thinking of making another stage involving Halloween and some of the characters from IN and a haunted part of Eientei and wondering if it's still worth going for.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 25, 2017, 05:01:32 AM
Hello!
It's Dire again here. The wiki doesn't really have any tips on making a dialogue scene, so how do I do that? How does one go about making a dialogue scene in danmakufu?
Thanks!
The wiki won't necessarily have that information because there's no set framework for it. You draw the portraits and boxes and text and everything and that's just how it works. Typically you might set this up inside of a single script that you add to the boss plural as though it were an attack.

Here's a curious question; has MKM fixed the alpha rendering in PH3 so that objects with less transparency in alpha rendering no longer get darker? Internally, in v1.2m, using ObjEffect_SetVertexcolor(obj, idx, rgba) multiplied the rgb by a factor of a. So in the shader, so we'd get something like: color.rgba = (color.a * color.rgb, color.a) // internally, rgba are values of 0-1.
Note that this isn't strictly a mistake. What people expect when declaring alpha values is straight alpha blending, where rgb and alpha are uncorrelated, but vertex color filtering expects premultiplied alpha in order to compose it with other layers. It was a problem because you couldn't get around it just in scripts, whereas any modern API will be doing this for you when you supply the color values.

But yes you can just set alpha values independently now and it's fine.

Also, what about the pixel-perfect issue? PLEASE tell me that was fixed too.
I.e. I want some of my bullets look like this:
(https://image.ibb.co/ngxv4Q/pixel_perfect.png)

And not have the the artifacts like I had in the past when rendering similar bullets:
(https://image.ibb.co/coa4yk/non_pixelperfect.png)
Yes, but I'm not sure to what extent you're looking for. Much of the interpolation issue for bullets is due to being rotated at arbitrary angles; this can be disabled by setting fixed_angle=true in your shot definition. I specifically asked for this to be implemented in order to fix this issue and it definitely helps.

However, there is also interpolation introduced from sprites not being drawn at exact integer bounds ("bounds" because sprites with an odd-sized width/height would have to be drawn at half-pixel positions). This is somewhat unavoidable of a conflict as you trade off precision for smoothness in motion. I have a solution for this if the pixel precision is absolutely needed, but it doesn't work for shot objects because there's no way to tell shot objects to render at a certain position without altering the "actual" position of the object. You can make the shots invisible and draw extra sprites, but obviously that is a very intensive workaround.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Fujiwara no Mokou on September 25, 2017, 05:52:37 AM
It was a problem because you couldn't get around it just in scripts, whereas any modern API will be doing this for you when you supply the color values.

But yes you can just set alpha values independently now and it's fine.
Oh thank goodness! This is great news for me.

Yes, but I'm not sure to what extent you're looking for. Much of the interpolation issue for bullets is due to being rotated at arbitrary angles; this can be disabled by setting fixed_angle=true in your shot definition. I specifically asked for this to be implemented in order to fix this issue and it definitely helps.

However, there is also interpolation introduced from sprites not being drawn at exact integer bounds ("bounds" because sprites with an odd-sized width/height would have to be drawn at half-pixel positions).
Oh wow, thanks for making that suggestion. I remember reaching out to MKM myself... helpful guy, he was nice enough to share the source of of the script-engine in DNH with me (I still have it, if anyone wants... it's good study material for how lexer/parsers work as well as Bytecode and FSMs). But also, that's not the only thing. To have perfect pixel texture mapping, you'd need to map texels to pixels (https://msdn.microsoft.com/en-us/library/windows/desktop/bb219690(v=vs.85).aspx) perfectly. Disabling bullets from rotating about arbitrary angles solves a part of it; the other part involves mapping bullets in such a way that the coordinates map to integer values. I believe in D3DX10+ it's done a little more intuitively (https://msdn.microsoft.com/en-us/library/cc308049(v=vs.85).aspx). In script, this just means changing our code to floor the coord-value, but this is computationally expensive to do in a script environment. Perhaps we could make this suggestion as well? I can see how it can help with the rendering of certain sprites and especially bullets.

Also, good to see you still active, Drake. I wonder if Naut and Nuclear Cheese is still around too?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 25, 2017, 06:55:16 AM
the other part involves mapping bullets in such a way that the coordinates map to integer values. I believe in D3DX10+ it's done a little more intuitively (https://msdn.microsoft.com/en-us/library/cc308049(v=vs.85).aspx). In script, this just means changing our code to floor the coord-value, but this is computationally expensive to do in a script environment. Perhaps we could make this suggestion as well? I can see how it can help with the rendering of certain sprites and especially bullets.
I already knew this was the case when I made the request back then, but despite implementing the fixed angle parameter, he probably didn't realize this wouldn't fix the issue entirely. I didn't want to press the issue when he had just done the work. At this point development has been halted for a while now though; mkm has a family and full-time job and whatnot so we might not see any future updates unless he decides to release the source or have someone take over.

The fix isn't as simple as flooring the values if it requires movement at all, since if you just round the rendering position the object will still be positioned there. You need to decouple the object's real position from where it's being rendered or else the movement will be inaccurate to varying degrees (e.g. if you're moving something less than 0.5px/f it'll stay still because it's always rounded). Additionally if anything about the object uses Move object functions like SetSpeed, SetAngle, etc, you need to correct for this in advance because the movement is applied to the object after the script is done for that frame but before it's rendered.

Also, good to see you still active, Drake. I wonder if Naut and Nuclear Cheese is still around too?
nah lol
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lollipop on September 25, 2017, 08:04:23 PM
is there a way to restrict player movement so that the player cant move for a period of time
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on September 25, 2017, 11:44:45 PM
I see! How do you set up the text boxes in a single script however? How do you insert the portraits and what not?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 26, 2017, 12:38:30 AM
is there a way to restrict player movement so that the player cant move for a period of time

At the start of the time period, log the player's current position (GetPlayerX, GetPlayerY). Then for duration of period force-set the player's position regardless of where they move to that logged position (ObjRender_SetX, ObjRender_SetY). That should do it.

As an example from SeitenTouji Extra Stage:
```
   let pcoord = [GetPlayerX, GetPlayerY];
   loop(180) {
       ObjRender_SetX(GetPlayerObjectID(), pcoord[0]);
       ObjRender_SetY(GetPlayerObjectID(), pcoord[1]);
       yield;
   }
```
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on September 28, 2017, 02:34:43 AM
I managed to set up portraits and what not, but my portraits always end up with a dark opacity. It's never the original opacity. Why is that?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 28, 2017, 03:19:19 AM
Please pastebin your script. Can't really say much without seeing what you're doing.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on September 28, 2017, 12:47:32 PM
Nvm I found out why it's at a dark opacity. The alpha wasn't raised higher. Don't mind this question, I'm just being stupid. 
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: iVAwalys on September 30, 2017, 04:06:26 PM
Okay, I'm having a really dumb and confusing problem here.
My items work as intended, but their graphics aren't showing up. I have double-checked, and both the directory paths and graphic rects are 100% correct:

Code: [Select]
#UserItemData

item_image = "../img/item.png"

ItemData{
id = 1
type = 2
rect = ( 0, 0, 12, 12 )
render = ALPHA
}
ItemData{
id = 2
type = 2
rect = ( 14, 0, 26, 12 )
render = ALPHA
}
ItemData{
id = 3
type = 3
rect = ( 26, 0, 40, 12 )
render = ALPHA
}

Code: [Select]
let HEALTH = 1;
let SPELL = 2;
let POINT = 3;

@Initialize{
    let path = GetCurrentScriptDirectory ~ "./item_data.dnh";
LoadItemData(path);
SetDefaultBonusItemEnable(false);
}

@MainLoop{
    yield;
}

@Event{
alternative(GetEventType)
    case(EV_GET_ITEM){
        let itemtype = GetEventArgument(0);
        if(itemtype == 1){
        if(GetPlayerLife < 250){ SetPlayerLife(GetPlayerLife+1); }
        }
        if(itemtype == 2){
        if(GetPlayerSpell <= 1295){ SetPlayerSpell(GetPlayerSpell+500); }
        }
    }
}

Another strange thing I've noticed is that I get an "x is not defined" error if I replace the item id with "HEALTH" or etc. in CreateItemU1. I clearly defined those in my item constant library!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on October 01, 2017, 10:50:18 AM
I have 2 new questions :3
1. After I called this, the sound "capture" is weirdly cut a lot so I can barely hear very little sound length... (the sound was present)
  while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
    if(ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT)
            +ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) == 0){
        AddScore(ObjEnemyBossScene_GetInfo(objScene, INFO_SPELL_SCORE));
        PlaySound("capture",100,0);
      } else {PlaySound("failed",100,0);}
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL,TYPE_IMMEDIATE);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
    return;

2. How can the shot at TShot01 to TShot08 acts exactly like TShot11 to TShot18 , but spins at the opposite direction ?
    I tried a few ways but I stops at a direction at the end, so....
   https://pastebin.com/H8xEz1yj

I am so grateful for the last comments, didn't say thanks earlier because I don't want to spam the posts so I'll post  in here :)
 
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 01, 2017, 03:59:48 PM
2. How can the shot at TShot01 to TShot08 acts exactly like TShot11 to TShot18 , but spins at the opposite direction ?
    I tried a few ways but I stops at a direction at the end, so....
   https://pastebin.com/H8xEz1yj

dir parameter:
To go in one direction:
dir += blah;

To go in the other direction:
dir -= blah;

What you're doing is adding y to both of these, making the change in dir over time different for 1-8 vs 11-18.

On a side note, I recommend using parameters to functions and tasks. These can greatly decrease the amount of copy-paste in your code and make it easier to debug. For example, the wait time and the bullet shot graphic can be parameterized and instead of having fireA...fireT, you can have a single fire() task that is properly parameterized.

Additionally, you do while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){break;}. I recommend using an approach that does not use break; - break; does NOT behave the same way pass; does in other languages.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 02, 2017, 11:42:11 AM
Okay, I'm having a really dumb and confusing problem here.
My items work as intended, but their graphics aren't showing up. I have double-checked, and both the directory paths and graphic rects are 100% correct:
One quirk that is probably the cause of the graphics screwup is that you seemingly cannot start the item_image path with ../. If you use "./../img/item.png" it might work.

Additionally one thing that should be causing issues is that you have item id 1 set to be item type 2; this can be useful but in your case probably just makes life items act like bomb items since they should both run the itemtype == 2 block.

As for the CreateItemU1 issue I dunno where you're trying to call it. Within the item script it should work fine but anywhere else it would fail unless you're also defining it elsewhere (in which case it's probably that that's failing).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on October 02, 2017, 09:32:38 PM
1. After I called this, the sound "capture" is weirdly cut a lot so I can barely hear very little sound length... (the sound was present)
  while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
    if(ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT)
            +ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) == 0){
        AddScore(ObjEnemyBossScene_GetInfo(objScene, INFO_SPELL_SCORE));
        PlaySound("capture",100,0);
      } else {PlaySound("failed",100,0);}
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL,TYPE_IMMEDIATE);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
    return;

Your script closes immediately after the sound is being played; in other words, there is no delay between the sound task and the end of the script, causing the sound to cut off instantly after it's activated. Adding a delay of 60-120 frames, depending on how long the sound effect lasts, should make the sound play entirely, since that delay makes the script close later.

You could do it like this:
Code: [Select]
while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
    if(ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT)
            +ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) == 0){
        AddScore(ObjEnemyBossScene_GetInfo(objScene, INFO_SPELL_SCORE));
     PlaySound("capture",100,0);
} else {PlaySound("failed",100,0);}
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL,TYPE_IMMEDIATE);
    SetAutoDeleteObject(true);
    loop(120) {      //delays the script closure by 120 frames (120 is an exemplary value here, use one that suits your needs)
        yield;            //or if you have a 'wait'-function, use it here
    }   
    CloseScript(GetOwnScriptID());
    return;
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on October 03, 2017, 08:28:15 PM
Good time of day,

I have a question that is not really relevant to danmakufu. I want to ask about bulletforge. I have one friend, who is already writing on a danmakufu and would really like to upload his projects on that site, but he can't, since bulletforge isn't currently open for registrations. However, I had heard that people, kind of, can write an email to somebody and thus register there... Is that so? Or is there any other solutions?

Thanks in advise!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on October 04, 2017, 06:48:07 AM
Good time of day,

I have a question that is not really relevant to danmakufu. I want to ask about bulletforge. I have one friend, who is already writing on a danmakufu and would really like to upload his projects on that site, but he can't, since bulletforge isn't currently open for registrations. However, I had heard that people, kind of, can write an email to somebody and thus register there... Is that so? Or is there any other solutions?

Thanks in advise!
Contact KimoKeine (aka Blargel, administrator of Bulletforge) at channel #danmakufu on IRC. He can help your friend to get an account.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on October 07, 2017, 11:39:48 AM
I'm trying to use gtbot's cutin function in a script but the spellcard name doesn't disappear in the end for some reason. It was supposed to disappear when the boss is deleted, so I tried to set the boss the same way as the sample script(let objBoss= GetEnemyBossObjectID[0];) but it returns this error: Array index out of bounds. What am I doing wrong?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 07, 2017, 10:09:28 PM
I'm trying to use gtbot's cutin function in a script but the spellcard name doesn't disappear in the end for some reason. It was supposed to disappear when the boss is deleted, so I tried to set the boss the same way as the sample script(let objBoss= GetEnemyBossObjectID[0];) but it returns this error: Array index out of bounds. What am I doing wrong?

The library assumes you have Object Autodelete turned on.

        SetAutoDeleteObject(true);
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on October 08, 2017, 03:51:03 AM
Needed to ask that currently I am frustrated at this problem  :)
How to let bullets reflects at all sides ? https://pastebin.com/DdjzZqB0
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 08, 2017, 04:54:06 AM
Needed to ask that currently I am frustrated at this problem  :)
How to let bullets reflects at all sides ? https://pastebin.com/DdjzZqB0

I don't understand your problem. You already have a task BOINGceiling that handles three of the four sides of the screen. Just add another if/else for the bottom of the screen - the formula for reflection is the same for the top of the screen.

Unless your problem lies elsewhere in which case you'll need to explain what you have already tried and what you are currently experiencing, and how that is different from what you want.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on October 08, 2017, 05:52:30 AM
Well, I tried this solution but the bottom bullets wasn't working correctly in a task :
while(ObjMove_GetX(obj)>0&&ObjMove_GetX(obj)<GetStgFrameWidth&&ObjMove_GetY(obj)>0){yield;}
   if(Obj_IsDeleted(obj)) { return; }
      if(ObjMove_GetX(obj) < 0 || ObjMove_GetX(obj) > GetStgFrameWidth) {
         if(ObjMove_GetX(obj) < 0) { ObjMove_SetX(obj, 0); }
         else { ObjMove_SetX(obj, GetStgFrameWidth); }
         ObjMove_SetAngle(obj, 180 - ObjMove_GetAngle(obj));
      }
      if(ObjMove_GetY(obj) < 0 || ObjMove_GetY(obj) > GetStgFrameHeight) {
         if(ObjMove_GetY(obj) < 0) { ObjMove_SetY(obj, 0); }
         else { ObjMove_SetY(obj, GetStgFrameHeight); }
         ObjMove_SetAngle(obj, -ObjMove_GetAngle(obj));
      }
      yield;
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 08, 2017, 07:37:41 AM
Look at your while condition; you're missing the condition that the bullet stays above the bottom wall. The rest should be fine.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on October 08, 2017, 09:38:16 AM
The library assumes you have Object Autodelete turned on.

        SetAutoDeleteObject(true);
Oh, so that's why it worked in another script. But how can I play the music with Object Autodelete on if it stops after every single?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on October 08, 2017, 12:20:13 PM
missing the condition
Does the condition same as the GetStgFrameWidth... to >0 ? If not what is the condition (I do suck at advance math) ? I can't try it now because I'm going to be busy through all weekdays...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 08, 2017, 02:59:46 PM
Oh, so that's why it worked in another script. But how can I play the music with Object Autodelete on if it stops after every single?

The fact that you're replaying music tracks at the start of every single worries me. I suggest loading and playing music tracks in either a Stage or Plural, whichever you use.

In general, if a task must run for the duration of a boss fight, don't run an abbreviated version at the start of every single if it's going to have a significant effect on the player's experience.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on October 08, 2017, 04:21:08 PM
Does the condition same as the GetStgFrameWidth... to >0 ? If not what is the condition (I do suck at advance math) ? I can't try it now because I'm going to be busy through all weekdays...
To be more specific:
You're missing ObjMove_GetY(obj) < GetStgFrameHeight in the while-loop. Note that you want to make the bullets bounce off the bottom of the STG frame, which is its full height, not width, hence GetStgFrameHeight.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on October 08, 2017, 05:54:30 PM
The fact that you're replaying music tracks at the start of every single worries me. I suggest loading and playing music tracks in either a Stage or Plural, whichever you use.

In general, if a task must run for the duration of a boss fight, don't run an abbreviated version at the start of every single if it's going to have a significant effect on the player's experience.
Oh, I see. I'm new to plural scripts so there's a lot I don't know yet... It worked, thanks!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on October 14, 2017, 12:33:36 PM
So, lately I've been wandering about how to make those glowing laser sources that Clownpiece has, as shown on the picture http://i64.tinypic.com/6ekn09.png
So far, I didn't succed. First issue is that I can't find the required image for it. And second one is that l can't make the lasers blend with any images i find, no matter what blend type i choose. I would be really grateful if someone could help me with recreating those exact lasers.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on October 15, 2017, 04:56:45 AM
I'm making a player script but the sprite doesn't update.
Code: [Select]
task renderPlayer // Render Player
{
ObjPrim_SetTexture(playerObj,playerTex); // Set Texture
Obj_SetRenderPriority(playerObj,31); // Set Render Layer
ObjRender_SetBlendType(playerObj,BLEND_ALPHA);  // Set To Alpha
ObjRender_SetAngleXYZ(playerObj,0,0,0); // Set Rot
ObjRender_SetScaleXYZ(playerObj,1,1,0); // Set Scale
ObjRender_SetAlpha(playerObj,255); // Set Alpha
ObjSprite2D_SetSourceRect(playerObj,0,0,32,54); // Set Rect
ObjSprite2D_SetDestCenter(playerObj); // Set Center
ObjRender_SetPosition(playerObj,GetPlayerX(),GetPlayerY(),0); // Set Player Position

while(!Obj_IsDeleted(playerObj))
{
ObjRender_SetPosition(playerObj,GetPlayerX(),GetPlayerY(),0); // Set Player Position
renderHitbox(GetPlayerX(),GetPlayerY());
if(GetKey(VK_LEFT)) // Going Left
{
ObjRender_SetAngleY(playerObj,0);
}
else if(GetKey(VK_RIGHT)) // Going Right
{
ObjRender_SetAngleY(playerObj,180);
}
else
{
}
yield;
}
}
The code is called on Initialize. I would like some help. Thanks
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on October 15, 2017, 07:38:49 AM
Hi from me again.
https://pastebin.com/qAzMJg27
The code up there summons two bosses.One of them acts fine, but the another one cannot shoot nor move, i tasked them quite correctly. What should I needed to do ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 15, 2017, 03:16:05 PM
Hi from me again.
https://pastebin.com/qAzMJg27
The code up there summons two bosses.One of them acts fine, but the another one cannot shoot nor move, i tasked them quite correctly. What should I needed to do ?

There are multiple problems in your script:

- Assuming they are sharing the same lifebar, you must place a boss collision hitbox on the second boss (objEnemy) or in the case that the second boss is an extra like Yoshika, you must provide the second boss with proper HP. This is most likely the reason why the second boss doesn't shoot - it defaults to 0 HP, and you never set it to something else. If you still have trouble, refer to https://dmf.shrinemaiden.org/wiki/Functions_(ph3)#Enemy_Object_Functions

- In your move task, the second boss never moves because you have an infinite loop running before the second boss's movement block. I suggest two tasks - one for each of the bosses. If you still have trouble, I recommend the following: https://en.wikipedia.org/wiki/Control_flow

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on October 16, 2017, 09:42:48 PM
If i spawn a straight laser from a random position and angle, how do I calculate the spot where it enters in contact with the walls or top of the screen?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 16, 2017, 09:49:12 PM
If i spawn a straight laser from a random position and angle, how do I calculate the spot where it enters in contact with the walls or top of the screen?

https://en.wikipedia.org/wiki/Line?line_intersection (https://en.wikipedia.org/wiki/Line?line_intersection)

You know the two points that mark the start and end of your laser, and you have the four corners of the screen, so using the equations using the formulas of the two lines should be fine.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on October 17, 2017, 06:30:32 PM
https://en.wikipedia.org/wiki/Line?line_intersection (https://en.wikipedia.org/wiki/Line?line_intersection)

You know the two points that mark the start and end of your laser, and you have the four corners of the screen, so using the equations using the formulas of the two lines should be fine.
After reading through that page, I realized I can't undertand anything... Probably because my main language isn't english so I don't understand many of the terms used there as I likely already learned them in another language...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 17, 2017, 06:58:02 PM
There's also this fun solution I worked out that is more specific than the line-line, taking note that you'll always make right triangles with the walls.

Code: [Select]
function GetSTGFrameIntersectPoint(x, y, t){
let wall = [[384,448], [0,448], [0,0], [384,0]][floor(t/90)];
let h = min( (|(wall[0]-x) / cos(t)|), (|(wall[1]-y) / sin(t)|) );
return [x + h*cos(t), y + h*sin(t)];
}

This probably works. Minimums with infinity should play nicely. I don't really want to explain the math and logic behind what exactly I'm doing here lol.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on October 18, 2017, 02:49:05 AM
I'm sorry if this is rude but it seems my question was skipped over. It's the last post in the previous page.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 18, 2017, 04:24:31 AM
Ah, you were just paged after a few hours and nobody noticed.

Immediate first question is, do you have a yield in your MainLoop. If not the task will yield once but never be yielded back to, so nothing will keep running.

If this isn't the problem then I'd ask you to post some more details, because it isn't super clear what you mean by "doesn't update", or whether anything else works, or what the rest of your script looks like.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on October 18, 2017, 06:03:58 PM
There's also this fun solution I worked out that is more specific than the line-line, taking note that you'll always make right triangles with the walls.

Code: [Select]
function GetSTGFrameIntersectPoint(x, y, t){
let wall = [[384,448], [0,448], [0,0], [384,0]][floor(t/90)];
let h = min( (|(wall[0]-x) / cos(t)|), (|(wall[1]-y) / sin(t)|) );
return [x + h*cos(t), y + h*sin(t)];
}

This probably works. Minimums with infinity should play nicely. I don't really want to explain the math and logic behind what exactly I'm doing here lol.
Thank you, that works just fine!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on October 19, 2017, 12:12:43 AM
Immediate first question is, do you have a yield in your MainLoop. If not the task will yield once but never be yielded back to, so nothing will keep running.
Ahh. It turns out I didn't even have the main loop at all, I didn't know It was so essential. Thanks!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 19, 2017, 04:21:54 AM
Task scheduling and yielding work by having the program execute a script until it hits a yield, at which point it stops where it is and "puts it aside" in a queue for later. In most cases, you'll start a bunch of tasks from @Initialize, which only runs once, so the tasks started there will run a bit, yield (or end), and eventually @Initialize finishes. After this the @MainLoop runs once per frame, even if it's empty or you didn't write anything. If you leave it like this without a yield in it, there's nothing to tell the script engine to go back to those other tasks. If you put a yield in, then the MainLoop will hit it, the script engine goes "ok I'll save the MainLoop for later" and puts it at the back of the task queue, picks up at the start of the queue, and goes through all the tasks until it reaches the MainLoop again, which might have some more code left, finishes, and the script waits for the next frame for it to run again.

To explore this, you can try putting two yields in the MainLoop, and all the tasks will run "twice as fast", because the task scheduler will go through the whole queue twice before the MainLoop ends.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on October 19, 2017, 04:25:48 AM
Task scheduling and yielding work by having the program execute a script until it hits a yield, at which point it stops where it is and "puts it aside" in a queue for later. In most cases, you'll start a bunch of tasks from @Initialize, which only runs once, so the tasks started there will run a bit, yield (or end), and eventually @Initialize finishes. After this the @MainLoop runs once per frame, even if it's empty or you didn't write anything. If you leave it like this without a yield in it, there's nothing to tell the script engine to go back to those other tasks. If you put a yield in, then the MainLoop will hit it, the script engine goes "ok I'll save the MainLoop for later" and puts it at the back of the task queue, picks up at the start of the queue, and goes through all the tasks until it reaches the MainLoop again, which might have some more code, finishes, and the script waits for the next frame for it to run again.

To explore this, you can try putting two yields in the MainLoop, and all the tasks will run "twice as fast", because the task scheduler will go through the whole queue twice before the MainLoop ends.
Interesting. But I don't want to clog the thread with our conversation. It's the garage, not the recovery centre. But thanks for sharing!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on October 20, 2017, 03:29:00 AM
I have two problems.

1) I get this error saying: EnemyBossSceneが作成されていません. I have no idea what it means but it probably due to my lack of knowledge on how to make a boss script. script: https://pastebin.com/4VP6srRa
2) It seems my player is displaced, more specifically the sprite is displaced from where the actual object is. I tried changing the boundaries and the sprite is in place but the actual object is not. script: https://pastebin.com/daXa4WsX

Don't feel the need to solve the two simultaneously. It's fine just to do one.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 20, 2017, 04:12:56 AM
I have two problems.

1) I get this error saying: EnemyBossSceneが作成されていません. I have no idea what it means but it probably due to my lack of knowledge on how to make a boss script. script: https://pastebin.com/4VP6srRa

You only need a scene object in single scripts. Your script is a plural. You are also creating a boss object, which makes no sense given that the plural is a container that creates the 'boss battle' itself.

Please refer to: https://sparen.github.io/ph3tutorials/ph3u2l12.html
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 20, 2017, 04:52:53 AM
More specifically, you're using GetEnemyBossSceneObjectID to try and get the boss scene, which isn't created yet (you create it in TPlural). Then you try to StartSpell it when it isn't set up so it errors, but as Sparen says it isn't what you'd be doing in the plural anyways. Get rid of those calls, you don't need or want them. You also don't call TPlural anywhere so that never runs.

As for the second, I dunno why you set up an extra Sprite object to draw the player sprite when Player objects already are one. But your actual problem is just that you use Obj_SetRenderPriority which ranges from 0 to 1 instead of Obj_SetRenderPriorityI which ranges from 0 to 100, so 50 and 31 just max out to 1 and the sprites are drawn above the frame, which makes the origin the top-left of the screen instead of the play area.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on October 20, 2017, 03:39:34 PM
You only need a scene object in single scripts. Your script is a plural. You are also creating a boss object, which makes no sense given that the plural is a container that creates the 'boss battle' itself.

Please refer to: https://sparen.github.io/ph3tutorials/ph3u2l12.html

More specifically, you're using GetEnemyBossSceneObjectID to try and get the boss scene, which isn't created yet (you create it in TPlural). Then you try to StartSpell it when it isn't set up so it errors, but as Sparen says it isn't what you'd be doing in the plural anyways. Get rid of those calls, you don't need or want them. You also don't call TPlural anywhere so that never runs.

As for the second, I dunno why you set up an extra Sprite object to draw the player sprite when Player objects already are one. But your actual problem is just that you use Obj_SetRenderPriority which ranges from 0 to 1 instead of Obj_SetRenderPriorityI which ranges from 0 to 100, so 50 and 31 just max out to 1 and the sprites are drawn above the frame, which makes the origin the top-left of the screen instead of the play area.

Drake) 2) Ah thanks so much. It worked.
Drake & Sparen) 1) Ah It does work... but what do I do for a boss to appear like making a boss in a single script. Do I just make a boss for all the single scripts?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 20, 2017, 04:56:20 PM
Drake) 2) Ah thanks so much. It worked.
Drake & Sparen) 1) Ah It does work... but what do I do for a boss to appear like making a boss in a single script. Do I just make a boss for all the single scripts?

In every single script that is part of a boss scene, create a new boss object. For more information, please read the tutorials.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on October 20, 2017, 05:36:31 PM
In every single script that is part of a boss scene, create a new boss object. For more information, please read the tutorials.
Thanks!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on October 21, 2017, 12:13:11 PM
The fact that you're replaying music tracks at the start of every single worries me. I suggest loading and playing music tracks in either a Stage or Plural, whichever you use.

In general, if a task must run for the duration of a boss fight, don't run an abbreviated version at the start of every single if it's going to have a significant effect on the player's experience.
Still on this, how do I change the music mid-battle? I want a certain song to play for the first 3 singles and then change to another one.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 21, 2017, 01:52:30 PM
Still on this, how do I change the music mid-battle? I want a certain song to play for the first 3 singles and then change to another one.

You can use NotifyEventAll to control the playing and stopping of music tracks (be sure to adjust your pause on and off events too so that they pause the correct music track). Assuming you have a plural/stage user event for playing bgm and stopping bgm, you can call the respective events to stop the old one and start the new one  at the start of the fourth single. You will probably need a CommonData so that the rest of the plural/stage knows that you are using the second bgm instead of the first.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on October 21, 2017, 04:54:56 PM
Code: [Select]
//So I have this problem with GetShotIdInCircleA1 where it's not getting anything!

//wait(60); Commented this out just to test quickly
let bullets = GetShotIdInCircleA1(x,y,99999); // This Should Get every Bullet. I Just set it to 99999 to test it.
ascent(i in 0..length(bullets)) // Foreach bullet in bullets...
{
ObjMove_SetAngle(bullets[i], GetAngleToPlayer(bullets[i])); // Set Bullet Angle to Player
        Obj_Delete(bullets[i]); // Here for debugging purposes
}
Obj_Delete(bullets[0]); // I tried this to try to find why the code dosen't work and It's apparently because the array index is out of range.
// Thanks!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 21, 2017, 06:39:05 PM
Code: [Select]
//So I have this problem with GetShotIdInCircleA1 where it's not getting anything!

//wait(60); Commented this out just to test quickly
let bullets = GetShotIdInCircleA1(x,y,99999); // This Should Get every Bullet. I Just set it to 99999 to test it.
ascent(i in 0..length(bullets)) // Foreach bullet in bullets...
{
ObjMove_SetAngle(bullets[i], GetAngleToPlayer(bullets[i])); // Set Bullet Angle to Player
        Obj_Delete(bullets[i]); // Here for debugging purposes
}
Obj_Delete(bullets[0]); // I tried this to try to find why the code dosen't work and It's apparently because the array index is out of range.
// Thanks!

1. What are you trying to do
2. If run before there are any bullets spawned, it will always fail because bullets[] will be empty - that is likely the cause of your problem
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on October 21, 2017, 06:51:44 PM
1. What are you trying to do
2. If run before there are any bullets spawned, it will always fail because bullets[] will be empty - that is likely the cause of your problem
Sorry if the post wasn't clear, I was experimenting with my post.

So my spell spawn rings of bullets from the boss. She will also occasionally fire curved lasers aiming for the player.
When the laser reaches the target position they will make all the bullets around the area of landing, aim towards the player. The snippet is the function that gets the bullets and makes them aim.

I removed the offending lines of code but it still doesn't work. I'll include more of the script:

Code: [Select]
task fire02
{
while(true)
{
let objLaser = CreateCurveLaserA1(ObjMove_GetX(bossObj), ObjMove_GetY(bossObj), 4, GetAngleToPlayer(bossObj), 60, 18, DS_SCALE_WHITE, 10);
let playerX = GetPlayerX;
let playerY = GetPlayerY;
ObjMove_AddPatternA2(objLaser, 5, 1, NO_CHANGE, 0, 1, 50);
ObjMove_AddPatternA2(objLaser, 25, 1, NO_CHANGE, 0.1, -1, 2);
wait(60);
ObjMove_SetDestAtFrame(objLaser,playerX,playerY,20); // Aim to player
deleteIn(objLaser,120); // Delete in 2 seconds
changeBullets(playerX, playerY) // Affect the bullets
}
}

task changeBullets(x,y)
{
wait(60);
let bullets = GetShotIdInCircleA1(x,y,99999);
ascent(i in 0..length(bullets))
{
ObjMove_SetAngle(bullets[i], GetAngleToPlayer(bullets[i]));
Obj_Delete(bullets[i]);
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 21, 2017, 07:29:25 PM
Sorry if the post wasn't clear, I was experimenting with my post.

So my spell spawn rings of bullets from the boss. She will also occasionally fire curved lasers aiming for the player.
When the laser reaches the target position they will make all the bullets around the area of landing, aim towards the player. The snippet is the function that gets the bullets and makes them aim.

I removed the offending lines of code but it still doesn't work. I'll include more of the script:

Code: [Select]
task fire02
{
while(true)
{
let objLaser = CreateCurveLaserA1(ObjMove_GetX(bossObj), ObjMove_GetY(bossObj), 4, GetAngleToPlayer(bossObj), 60, 18, DS_SCALE_WHITE, 10);
let playerX = GetPlayerX;
let playerY = GetPlayerY;
ObjMove_AddPatternA2(objLaser, 5, 1, NO_CHANGE, 0, 1, 50);
ObjMove_AddPatternA2(objLaser, 25, 1, NO_CHANGE, 0.1, -1, 2);
wait(60);
ObjMove_SetDestAtFrame(objLaser,playerX,playerY,20); // Aim to player
deleteIn(objLaser,120); // Delete in 2 seconds
changeBullets(playerX, playerY) // Affect the bullets
}
}

task changeBullets(x,y)
{
wait(60);
let bullets = GetShotIdInCircleA1(x,y,99999);
ascent(i in 0..length(bullets))
{
ObjMove_SetAngle(bullets[i], GetAngleToPlayer(bullets[i]));
Obj_Delete(bullets[i]);
}
}

Firstly, I recommend reading the description of GetShotIdInCircleA1: https://dmf.shrinemaiden.org/wiki/Shot_Functions#GetShotIdInCircleA1
You should probably use GetShotIdInCircleA2 with TARGET_ENEMY.

Secondly, changeBullets(playerX, playerY) is based on the player's location, not that of the laser. Keep that in mind.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on October 21, 2017, 07:48:22 PM
Firstly, I recommend reading the description of GetShotIdInCircleA1: https://dmf.shrinemaiden.org/wiki/Shot_Functions#GetShotIdInCircleA1
You should probably use GetShotIdInCircleA2 with TARGET_ENEMY.

Secondly, changeBullets(playerX, playerY) is based on the player's location, not that of the laser. Keep that in mind.
It works! Thanks.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on October 22, 2017, 04:40:19 PM
Rawcode Here:

Is there a way to detect what graphic is a bullet. Or better yet some way to "Tag" a bullet and read that tag?
Thanks.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 22, 2017, 05:18:52 PM
Rawcode Here:

Is there a way to detect what graphic is a bullet. Or better yet some way to "Tag" a bullet and read that tag?
Thanks.

What exactly are you trying to do? Both you as the scripter and the players who are playing your game should always be able to know what graphic is a bullet. In your case, you know on a code level because any graphic that's not boss/player/effect/etc. is going to be a bullet (and you as the scripter decide where the bullet are and where they go), while for the player, if they can't distinguish what is and is not a bullet, they're not going to have a fun time playing your script.

In short, you are creating the bullets. Therefore, you always know which graphic is a bullet and which one is not. If you are trying to get the graphic corresponding to a bullet, use https://dmf.shrinemaiden.org/wiki/Shot_Object_Functions#ObjShot_GetImageID

In the future, please refer to the tutorials and wiki function list to see if your question can be answered with an existing function. Also, it is important to state what you are trying to achieve, so that we can assist you more effectively.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on October 22, 2017, 05:56:35 PM
What exactly are you trying to do? Both you as the scripter and the players who are playing your game should always be able to know what graphic is a bullet. In your case, you know on a code level because any graphic that's not boss/player/effect/etc. is going to be a bullet (and you as the scripter decide where the bullet are and where they go), while for the player, if they can't distinguish what is and is not a bullet, they're not going to have a fun time playing your script.

In short, you are creating the bullets. Therefore, you always know which graphic is a bullet and which one is not. If you are trying to get the graphic corresponding to a bullet, use https://dmf.shrinemaiden.org/wiki/Shot_Object_Functions#ObjShot_GetImageID

In the future, please refer to the tutorials and wiki function list to see if your question can be answered with an existing function. Also, it is important to state what you are trying to achieve, so that we can assist you more effectively.
Ah Thanks. And I'm sorry if the lack of information is impairing your ability to help me effectively, Next time I'll state my goal.
Also sorry about not finding the function, I swear I searched the list but I didn't find what I needed.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 23, 2017, 06:39:48 PM
As an aside, if you do for whatever reason need to "tag" individual shot objects with specific information that you couldn't otherwise get already, you can use the Obj_SetValue/GetValue functions to do so.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on October 29, 2017, 07:19:30 PM
It's me Again!
So I'm trying to load the next scene in a Boss Scene object, but my attempts have come up futile. I have no Idea on how to do it. Can you help me?
Code: [Select]
#TouhouDanmakufu[Plural]
#ScriptVersion[3]
#Title["Koishi Komeji"]
#Text["Koishi is acting up again"]

let dir = GetCurrentScriptDirectory();
let obj = ObjEnemyBossScene_Create(); // Make the boss scene object

@Initialize
{
SetCommonData("ScriptID", GetOwnScriptID());
TPlural;
}
@Event
{
alternative(GetEventType)
case(EV_USER)
{
ObjEnemyBossScene_StartSpell(obj);
ObjEnemyBossScene_LoadInThread(obj); // Load
}
}
@MainLoop
{
    yield;
}
task TPlural
{
// Define Scripts
ObjEnemyBossScene_Add(obj, 0, dir ~ "non01.txt");
ObjEnemyBossScene_Add(obj, 0, dir ~ "spell01.txt");

    ObjEnemyBossScene_LoadInThread(obj); // Load
    ObjEnemyBossScene_Regist(obj); // And register

while(!Obj_IsDeleted(obj)){yield}; // yield while the Boss is not deleted
    CloseScript(GetOwnScriptID()); // Close if it the boss died
}

function GetCenterX(){
     return GetStgFrameWidth() / 2;
}
function GetCenterY(){
     return GetStgFrameHeight() / 2;
}

Thanks.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 29, 2017, 07:57:11 PM
It's me Again!
So I'm trying to load the next scene in a Boss Scene object, but my attempts have come up futile. I have no Idea on how to do it. Can you help me?
Code: [Select]

Thanks.

I don't know what exactly you are trying to accomplish here, but here's what I recommend:

Please refer to http://sparen.github.io/ph3tutorials/ph3u2l12.html
You are misusing a number of functions as well. https://dmf.shrinemaiden.org/wiki/Functions_(ph3)#Boss_Scene_Object_Functions

ObjEnemyBossScene_StartSpell is meant to be used in the Single scripts. There is no need to use any fancy notify events since GetEnemyBossSceneObjectID() can be used in a Single script to retrieve the Boss Scene object ID.

If there are issues with my guide (i.e. it's not clear on what to do or there is something missing), please let me know.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on October 30, 2017, 12:32:59 AM
I don't know what exactly you are trying to accomplish here, but here's what I recommend:

Please refer to http://sparen.github.io/ph3tutorials/ph3u2l12.html
You are misusing a number of functions as well. https://dmf.shrinemaiden.org/wiki/Functions_(ph3)#Boss_Scene_Object_Functions

ObjEnemyBossScene_StartSpell is meant to be used in the Single scripts. There is no need to use any fancy notify events since GetEnemyBossSceneObjectID() can be used in a Single script to retrieve the Boss Scene object ID.

If there are issues with my guide (i.e. it's not clear on what to do or there is something missing), please let me know.
Sorry, I thought I clarified more. So I want to load the next stage after the boss's health bar reaches 0. All it did was well... nothing.
I did look at your guide and the functions, but it didn't give me what I need.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on October 30, 2017, 03:23:29 PM
Hello, does anyone know how to make homing player shots, just like Reimu's amulets? I almost did it myself, but i cant find the right way to target the closest enemy, the shots always target the one that spawned first
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on October 30, 2017, 05:19:48 PM
I can't say for sure what's going wrong without seeing at least some of your code, unfortunately. Note that, for Reimu's homing amulets, you probably want a task for each individual bullet where it homes in on the enemy closest to it when it spawned. IIRC, there was a nice example of such a task near the very start of this thread.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on October 30, 2017, 06:23:28 PM
I can't say for sure what's going wrong without seeing at least some of your code, unfortunately. Note that, for Reimu's homing amulets, you probably want a task for each individual bullet where it homes in on the enemy closest to it when it spawned. IIRC, there was a nice example of such a task near the very start of this thread.
Here's all that i used for shots. https://pastebin.com/i2ZH77sZ

I hope that's not too much code in just 1 post.
And i already read the discussion about homing shots in the beggining of the thread, but that didn't help, the shots already home, the only problem is targeting. Also i tried using GetEnemyIntersectionPosition(GetPlayerX, GetPlayerY, 1);, but i can't do anything with the array that it returns
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 30, 2017, 07:13:39 PM
Sorry, I thought I clarified more. So I want to load the next stage after the boss's health bar reaches 0. All it did was well... nothing.
I did look at your guide and the functions, but it didn't give me what I need.

Danmakufu loads new singles automatically if you've added them to the Boss Scene before registering it. Just make sure that your Singles CloseScript(GetOwnScriptID()); after the boss's HP has reached 0 and the boss has deleted itself.

Hello, does anyone know how to make homing player shots, just like Reimu's amulets? I almost did it myself, but i cant find the right way to target the closest enemy, the shots always target the one that spawned first

For each shot, calculate the distance between the shot and the enemies using the Distance Formula, then lock onto the closest one.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on October 31, 2017, 10:46:48 AM
For each shot, calculate the distance between the shot and the enemies using the Distance Formula, then lock onto the closest one.


That was a bit tricky to do, but it helped. Thanks


Mod notice:  Please use pastebin.com for posting large pieces of code :)  this avoids unnecessary scrolling. -Hele
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on November 04, 2017, 12:02:28 AM
Okay, this problem has been driving me crazy. I keep getting this error: 敵ライフを適切に返していません。(d:/Users/Rawcode/Desktop/Home/Programs/DanmanfukuPh3/script/CTCStage6Remake/Scripts/test.txt)
I've translated the Japanese and it something vaguely like Cannot Return Fairy Life or something like that.

I have tried even commenting everything in lib_FairyF but I still get the error:
Code: [Select]
let fairyTex = "././Sprites/spr_Fairy01.png";
let red = 0;

function MakeFairy(life, x, y, colour)
{
let obj = ObjEnemy_Create(OBJ_ENEMY); // Make Fairy
ObjEnemy_Regist(obj); // Start Fairy
ObjEnemy_SetLife(obj, life); // Set Life
ObjEnemy_SetIntersectionCircleToShot(obj, 0, 0, 20); // Set Shot Collision
ObjEnemy_SetIntersectionCircleToPlayer(obj, 0, 0, 20); // Set Player Collision
//FairyLoop(obj, colour); // Start loop
ObjMove_SetPosition(obj,x,y); // Set Fairy Position
return obj;
}

task FairyLoop(fairy, colour)
{
let frame = 0;
let rate = 30;
ObjPrim_SetTexture(fairy,fairyTex); // Set Texture
ObjSprite2D_SetDestRect(fairy,0,0,32,32); // Set Center
ObjSprite2D_SetDestCenter(fairy); // Set Center
while(!Obj_IsDeleted(fairy)) // While Fairy is not Deleted.
{
frame++; // Increment Frame
if(frame < rate) // Frame 1
{
ObjSprite2D_SetSourceRect(fairy, 0, colour, 32, 32 + colour);
}
else if(frame > rate && frame < rate * 2) // Frame 2
{
ObjSprite2D_SetSourceRect(fairy, 32, colour, 64, 32 + colour);
}
else if(frame > rate && frame < rate * 2) // Frame 3
{
ObjSprite2D_SetSourceRect(fairy, 64, colour, 96, 32 + colour);
}
if(frame > rate * 4){frame = 0;} // Loop Frame if...
yield;
}
}

I also have a code snippet from the test.txt script: 
Code: [Select]
#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["testinging"]
#Text["testing"]

#include "./Library/lib_FairyF.dnh"
#include "./Library/lib_Misc.dnh"
#include "script/default_system/Default_ShotConst.txt"

// Default Functions
@Initialize // Called At Start
{
MakeFairy(0,GetCenterX,GetCenterY,0);
mainTask; // Call Main Task
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on November 04, 2017, 02:16:01 AM
Okay, this problem has been driving me crazy. I keep getting this error: 敵ライフを適切に返していません。

(snip)

Why don't you try turning your Single script into a Stage script instead? I'm not sure what goes on in mainTask;, so I can't really say anything else about test.txt for certain, but I'm guessing you may have removed the information from @Event that takes care of the boss's life. With a Stage script, you can handle fairies without necessarily having to handle a boss.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on November 04, 2017, 02:18:16 AM
Okay, this problem has been driving me crazy. I keep getting this error: 敵ライフを適切に返していません。
...
I have tried even commenting everything in lib_FairyF but I still get the error:

Firstly, you're setting the enemy's life to 0, and its hitbox only appears for one frame at the top left corner of the screen.

Secondly, the issue is that you're unable to GET the fairy life. Which line does the error appear at in which script, and how are you trying to access the enemy's life at that location? The fact that you can comment out the entire library and still get the error leads me to believe that the cause of the error is outside the library.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIRawsomeII on November 04, 2017, 04:37:38 AM
Why don't you try turning your Single script into a Stage script instead? I'm not sure what goes on in mainTask;, so I can't really say anything else about test.txt for certain, but I'm guessing you may have removed the information from @Event that takes care of the boss's life. With a Stage script, you can handle fairies without necessarily having to handle a boss.
Firstly, you're setting the enemy's life to 0, and its hitbox only appears for one frame at the top left corner of the screen.

Secondly, the issue is that you're unable to GET the fairy life. Which line does the error appear at in which script, and how are you trying to access the enemy's life at that location? The fact that you can comment out the entire library and still get the error leads me to believe that the cause of the error is outside the library.

So Thanks, Chronojet. It's apparently the fact I need the script to be a stage script. That fixed the problem. mainTask doesn't have anything in it so don't worry. Also, I guess I need boss information if I'm doing a single script without a boss.

Also thanks, Sparen. I forgot to change the life variable. Also thanks for the reminder for the hitbox placement. For your second response, Some of it was answered by Chrono. I didn't try getting the enemy life at all unless Obj_IsDeleted(); counts.

So my fairy graphic doesn't appear but I'll chock that up to the file address. Thank you two for your help.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on December 02, 2017, 06:11:49 PM
Is there any english tutorials on how to make item scripts?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on December 03, 2017, 04:06:18 AM
Not really, but I found a rough explanation for the basic implementation and usage of item scripts I made a while ago: https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1108259.html#msg1108259

Here is an example of a simple item script I'm using:

Code: [Select]
let ITEM_PENDULUM = 1;

@Initialize{
SetDefaultBonusItemEnable(false);
let dir = GetCurrentScriptDirectory();
LoadItemData(dir~"item_data.dnh");
}

@MainLoop{}

@Event{
alternative(GetEventType())
case(EV_USER+72){
let pos = GetEventArgument(0);
if(length(pos) == 2){
TItem(ITEM_PENDULUM, pos[0], pos[1]);
}
}
case(EV_GET_ITEM){
let type = GetEventArgument(0);
let item = GetEventArgument(1);
alternative(type)
case(ITEM_PENDULUM){
SetPlayerSpell(GetPlayerSpell() + 1);
}
}
case(EV_DELETE_SHOT_TO_ITEM){
let shot = GetEventArgument(0);
let pos = GetEventArgument(1);
TItem(ITEM_PENDULUM, pos[0], pos[1]);
}
}

task TItem(type, x, y){
let obj = CreateItemU1(type, x, y, 0);
Obj_SetRenderPriorityI(obj, 60);
}

Which honestly isn't much different than what's posted in the above link, but is filled with actual data. This is also an item script for player-specific items and not connected to a full game with many items, so you should look for other examples (it shouldn't be much different than just having many item cases and extra behaviour).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: PyuDi on December 03, 2017, 06:30:11 AM
Hi. I am trying to play this script, but ph3 always freezes... Anybody know what's the problem? ( I assume that it is related to infinite loop )

https://pastebin.com/DLyLwi8Z




Welcome to our forum. Please put large code like this in pastebin links. I helped you out this time  ;)  -Helepolis
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on December 03, 2017, 07:19:39 AM
Hi. I am trying to play this script, but ph3 always freezes... Anybody know what's the problem? ( I assume that it is related to infinite loop )

https://pastebin.com/DLyLwi8Z
You didn't yield your while loop which starts at line 64
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: PyuDi on December 03, 2017, 07:29:42 AM
You didn't yield your while loop which starts at line 64

Thanks :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on December 03, 2017, 09:38:13 AM
I don't know if I'll be able to explain this right, please bear with me :V
I want to fire a curvy laser at a constant speed and angular velocity(probably 3 and 1 but I might change it) but I want it to go through the player's current position no matter where on the screen. To do that I'd need a way to calculate an angle for it to be fired based on its position, speed, angular velocity and the player's position, how can I do that?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on December 03, 2017, 09:50:18 AM
Not really, but I found a rough explanation for the basic implementation and usage of item scripts I made a while ago: https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1108259.html#msg1108259

Here is an example of a simple item script I'm using:

Which honestly isn't much different than what's posted in the above link, but is filled with actual data. This is also an item script for player-specific items and not connected to a full game with many items, so you should look for other examples (it shouldn't be much different than just having many item cases and extra behaviour).

Thanks, it helped a lot.

I don't know if I'll be able to explain this right, please bear with me :V
I want to fire a curvy laser at a constant speed and angular velocity(probably 3 and 1 but I might change it) but I want it to go through the player's current position no matter where on the screen. To do that I'd need a way to calculate an angle for it to be fired based on its position, speed, angular velocity and the player's position, how can I do that?

If you want the laser to fly only in one direction (like a regular shot) you can set its angle using GetAngleToPlayer, ang then just make it look curvy with another task. But if you want it to follow the player, that would require some complicated calculations, which i dont know
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on December 03, 2017, 10:19:20 AM
If you want the laser to fly only in one direction (like a regular shot) you can set its angle using GetAngleToPlayer, ang then just make it look curvy with another task. But if you want it to follow the player, that would require some complicated calculations, which i dont know
It's pretty crazy, so let me explain again. I want the laser to PASS THROUGH the player's position when it's fired, so that it will hit them directly unless they dodge, no matter where on the screen. The speed and angular velocity will be constant(3 and 1, though I might change them).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on December 03, 2017, 02:58:53 PM
It's pretty crazy, so let me explain again. I want the laser to PASS THROUGH the player's position when it's fired, so that it will hit them directly unless they dodge, no matter where on the screen. The speed and angular velocity will be constant(3 and 1, though I might change them).

The simplest way is to check for when the laser's angle is the same as its angle to the player, then set angular velocity to 0, which causes a sort of unfurling effect.
From your description you want to laser to curve constantly, which actually does make it only possible to hit the player's position from certain angles.
When you have a set angular velocity, think of it as the laser travelling in a set circle, which is angled based off its spawn angle.

If you're willing to change the angular velocity or speed, then it's some very scary mathematics things which varies depending on the pattern you want to make.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on December 03, 2017, 03:24:27 PM
It's me again since I was not very active in danmakufu after my last post until this week...
I know it sounds stupid but how to let bullet shoot from downwards ?
#Edit : And shoot from left and shoot from right are also needed, thanks  :3
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: niektory on December 03, 2017, 04:30:18 PM
I don't know if I'll be able to explain this right, please bear with me :V
I want to fire a curvy laser at a constant speed and angular velocity(probably 3 and 1 but I might change it) but I want it to go through the player's current position no matter where on the screen. To do that I'd need a way to calculate an angle for it to be fired based on its position, speed, angular velocity and the player's position, how can I do that?

I don't know Danmakufu, but the math should look something like this (using degrees as an angle unit):

starting angle = 90? - ( arccos( ( distance / 2 ) / radius  ) )

starting angle is the difference in angle between a straight line shot and the intended arc shot.
distance is the distance between the player and the firing point.
radius is the radius of the arc.

radius = speed / ( angular velocity / 360? ) / 2π

Depending on what units they are in, you might need to multiply speed and/or angular velocity by a constant.

Make sure that radius is greater than half of the maximum possible distance, or the arccos() may blow up on you.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: spexguy718 on December 17, 2017, 03:52:59 AM
Greetings again! I've been doing kind of well with Danmakufu and I've playing around with several patterns. I have two questions to ask for the experts of Danmakufu

1. Since some danmakufu patterns require trigonometry, can you...
?Teach me how to harness the power of trigonometry myself (Note: I already went to Sparen's Danmakufu Tutorial site to figure it out but it seems very hard to pull off if you want to do it yourself, especially if you don't have a graphing calculator or how to plug it into the script itself)
?Give me just few examples of trigonometry in action in Danmakufu (this is optional)

2. I've noticed that Imperishable Night bosses use a lot of spell circle shaped familiars to shoot for them. ESPECIALLY Marisa in stage 4. Can you possibly teach me how to summon said familiars in Danmakufu so I can incorporate it in my own scripts?

Thank you in advance if you manage to help me out~♫
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on December 17, 2017, 05:53:50 AM
1. Since some danmakufu patterns require trigonometry, can you...
?Teach me how to harness the power of trigonometry myself (Note: I already went to Sparen's Danmakufu Tutorial site to figure it out but it seems very hard to pull off if you want to do it yourself, especially if you don't have a graphing calculator or how to plug it into the script itself)
?Give me just few examples of trigonometry in action in Danmakufu (this is optional)
I'm just going to post a bunch of links for this one
?Khan Academy (learning trig in case you are unfamiliar with the basics)
https://www.khanacademy.org/math/trigonometry
?Parametric Equations and various curves (Example equations, etc)
https://sites.math.washington.edu/~aloveles/Math124Fall2017/m124ParametricEquationsIntro.pdf
http://www-history.mcs.st-and.ac.uk/Curves/Curves.html

2. I've noticed that Imperishable Night bosses use a lot of spell circle shaped familiars to shoot for them. ESPECIALLY Marisa in stage 4. Can you possibly teach me how to summon said familiars in Danmakufu so I can incorporate it in my own scripts?

You can either create additional enemies or you can use render objects. If they need a hitbox, I recommend using additional enemies. Essentially, create enemies the same was as with a boss, but set the health, etc. manually. Refer to https://dmf.shrinemaiden.org/wiki/Enemy_Object_Functions
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on December 17, 2017, 05:56:23 AM
1.

The trigonometry I use most often boils down to the following:
-Using atan2 to get angles from arbitrary points is the big one (https://dmf.shrinemaiden.org/wiki/Math_Functions#atan2)
-You can do some cool things with the oscillatory properties of sin and cos. Its worth noting that you can apply them to things other then angle or position, so you could have a bullet pattern where the velocity or density went back and forth.
-Spawning bullets in a circle. It essentially works like this:
CreateShotA1(X+radius*cos(angle),Y+radius*sin(angle),otherparametersthatareirrelevanthere)
Where X and Y are the X and Y coordinates of the center of the circle and angle is the angle from the center of the circle to the bullet.

I'm sure there are other clever uses for trigonometry, like drawing stars Sanae style or making interesting curves with parametric equations, but the above are the vast majority of what I do with trigonometry.
2.

Basically, familiars work by creating and registering an enemy object. Then you can have them move around just like a boss or a bullet would and use stuff like CreateShotOA1 to spawn bullets at their position. You could use a render object if you don't need them to take damage, but then you can't use the helpful Move Object functions on them. By default, they'll be invulnerable, but you can give them a hitbox[Again, in much the same way as you would give a boss at hitbox] if you want them to be destroyable. If you want them to be destroyable only if the player is focussed, like in Imperishable Night, then you'll have to have a way to detect whether the player is focussed or not. I don't believe Sparen's tutorials yet extend to how virtual keys work, but Helepolis' player tutorial (https://www.youtube.com/watch?v=Dtn5EtPsJjc&index=9&list=PLsqimF6_OUHBNeOrp_k2t9bPk5Q6PsB_P) has a relevant section on detecting player focus state at around 7:45. As for the spell circle itself, you should just be able to set their graphic to be that of a spell circle, just like when rendering a boss.  This site (http://danmakufu.wiki.fc2.com/wiki/%E7%B4%A0%E6%9D%90%E3%83%AA%E3%83%B3%E3%82%AF) has some useful assets in general, including nice looking spell circles in a variety of colours[You want the link that leads to th3_7008].
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: spexguy718 on December 17, 2017, 08:44:32 PM
I'm just going to post a bunch of links for this one
?Khan Academy (learning trig in case you are unfamiliar with the basics)
https://www.khanacademy.org/math/trigonometry
?Parametric Equations and various curves (Example equations, etc)
https://sites.math.washington.edu/~aloveles/Math124Fall2017/m124ParametricEquationsIntro.pdf
http://www-history.mcs.st-and.ac.uk/Curves/Curves.html

Well you answered my second question quite nicely, but I was wondering how to actually PLUG IN the equations in a Danmakufu script. Say I would want to implement the Devil's Curve pattern for my shots (http://www-history.mcs.st-and.ac.uk/Curves/Devils.html) how would I go about that?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on December 18, 2017, 01:09:12 AM
Well you answered my second question quite nicely, but I was wondering how to actually PLUG IN the equations in a Danmakufu script. Say I would want to implement the Devil's Curve pattern for my shots (http://www-history.mcs.st-and.ac.uk/Curves/Devils.html) how would I go about that?

For parametric equations such as the Lissajous curve, you simply parameterize with the target coordinate as origin:
e.g.
Code: [Select]
CreateShotA1(GetEnemyX(objBoss)+120*cos(angleT*3), GetEnemyY(objBoss)+90*sin(angleT*5), 1, angleT*3, graph, 0);
The Devil's Curve has the following parametric representation, according to Wolfram Mathworld:
x = cos(t)*sqrt((a^2*sin(t)^2 - b^2*cos(t)^2)/(sin(t)^2 - cos(t)^2)
y = sin(t)*sqrt((a^2*sin(t)^2 - b^2*cos(t)^2)/(sin(t)^2 - cos(t)^2)

Therefore, you could do the following in Danmakufu:
Code: [Select]
task DevilCurve{
        let t = 0;
        // Control the curve parameters
        let a2 = 1;
        let b2 = 2;
        // Control the scaling parameters
        let scalex = 64;
        let scaley = 64;
        while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
            let s_num = a2*sin(t)*sin(t) - b2*cos(t)*cos(t);
            let s_denom = sin(t)*sin(t) - cos(t)*cos(t);
            let s_all = (s_num/s_denom)^0.5;
            CreateShotA2(ObjMove_GetX(objBoss) + scalex*cos(t)*s_all, ObjMove_GetY(objBoss) + scaley*sin(t)*s_all, 0, t*2, 0.01, 3, DS_BALL_BS_SKY, 10);
            t++;
            yield;
        }
    }
Above, I've used three variables (s_num, s_denom, and s_all) for sanity purposes, as the mess under the square root is hard to check for errors

I've attached a working example. Note that I've added a loop and some other stuff to showcase the drawing of the curve itself.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on December 20, 2017, 11:11:16 AM
My objective is to create a shape and move that shape like is was a bullet (without deforming), but I don't know an easier way (or an obvious way) to do that.  ???

PS: My level of knowledge is pretty basic, please be patient with me.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on December 20, 2017, 10:38:43 PM
It depends on what the shape is. This is not an easy problem and involves some thinking and math, but we do have some existing implementations lying around.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on December 20, 2017, 11:14:46 PM
Generally, the best way to do that is to have a bunch of bullets defined around a central point in such a way that they form a shape and then fire the bullets at an angle calculated from that central point. If you wanted to do more then just fire the shape, like having it rotate after firing or something, then its probably best to have a task that maintain's the shape's formation relative to the central bullet of the shape.

The actually hard part is forming a shape. Circles are definitely easiest. Triangles and squares aren't that bad either, although I've had a bit of a hard time making the corners look nice. Sanae-style stars are more difficult.

Code: [Select]
function BulletCircle(X, Y, angle, radius, numBullets) {
    let increment = 360/numBullets;
    ascent(i in 0..numBullets){
if(Obj_IsDeleted(bossObj)){return;} //Prevents bullets from spawning after the script finishes
        let obj = CreateShotA1(X+radius*cos(i*increment),Y+radius*sin(i*increment),3,angle,DS_RICE_S_YELLOW,30);
    }
}

Here's an example of how firing a circle as a single bullet would work. The important part is firing all the bullets in the same direction, but from different starting locations.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on December 21, 2017, 11:24:59 AM
Here's my repost of a repost on shooting regular polygons, read all the links for more info

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

And the obligatory code tweaking

Code: [Select]
function CreateShotShapeA1(x, y, shape_sides, shape_gap, shape_radius, shape_angle, speed, angle, graphic, delay){
let shots = [];
let t = 0;
while(t < 360){
let r = cos(180/shape_sides) / cos(((t - shape_angle) % (360/shape_sides)) - (180/shape_sides));
if(shape_radius == 0 && angle == 0){
// expand shape from center
shots = shots ~ [CreateShotA1(x, y, r * speed, t, graphic, delay)];
}else{
// fire shape in direction
shots = shots ~ [CreateShotA1(x + shape_radius*r*cos(t), y + shape_radius*r*sin(t), speed, angle, graphic, delay)];
}
t += shape_gap;
}
return shots;
}

Try

Code: [Select]
// expand
CreateShotShapeA1(192, 150, 5, 4, 0, 90, 2, 0, SHOT_RING_RED, 10);
// shoot
CreateShotShapeA1(192, 150, 4, 4, 80, 115, 2, 70, SHOT_RING_RED, 10);
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on December 22, 2017, 12:24:59 AM
Both of them work perfectly, and I'll both of them(in case I want to mix the codes)
Code: [Select]
function BulletCircle(X, Y, angle, radius, speed, numBullets, graph, del) {
    let increment = 360/numBullets;
    ascent(i in 0..numBullets){
if(Obj_IsDeleted(objBoss)){return;} //Prevents bullets from spawning after the script finishes
        let obj = CreateShotA1(X+radius*cos(i*increment),Y+radius*sin(i*increment),speed,angle,graph,del);
    }
}
I actually changed a bit of Arc's code so I can mess with the speed, delay and graphic.

Thanks for the support :D
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on December 24, 2017, 01:51:43 AM
I have another request, I want to LEARN (NOT JUST PASTE THE CODE) how to make Non-Directional Lasers like Alice in SWR/Soku
Crimson Sign "Holland Doll"


I know that Sparenoflria alrady did a tutorial of how to make Non-Directional Lasers, but it almays ended doing 4-way lasers
Plz help
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on December 24, 2017, 06:37:49 AM
I have another request, I want to LEARN (NOT JUST PASTE THE CODE) how to make Non-Directional Lasers like Alice in SWR/Soku
Crimson Sign "Holland Doll"


I know that Sparenoflria alrady did a tutorial of how to make Non-Directional Lasers, but it almays ended doing 4-way lasers
Plz help

I'm not too familiar with Soku as it's been a while since I've last played it, but have you tried pointing all of the lasers in the same direction? If you already have non-directional lasers Marisa/Patchouli-style, all you need to do is change one variable to the same value for each iteration of the code (i.e each laser).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on December 24, 2017, 09:30:05 AM
Is this the tutorial you mean?
http://sparen.github.io/ph3tutorials/ph3u1l9.html#sub7

This goes further than what you say, with 12 lasers and spawning in a circle around the boss position. This should be plenty to get you started.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on December 25, 2017, 11:04:12 AM
It's ok, when I saw my idea it was actually pretty basic... And I kinda gave up on it  It's not anyone's fault OK

How do I use multiple BGM in a Plural Script like AJS did on the Satori script (Recollection of  a Scripter's Past) ? :V
Plz help
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on December 25, 2017, 05:35:47 PM
Basically, you define multiple sound objects in the plural script itself and then run a task in that script that detects which phase the boss fight is on and changes which sound object is playing accordingly. You probably want to fade out the old music instead of just having it end abruptly.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on December 26, 2017, 12:06:11 AM
Basically, you define multiple sound objects in the plural script itself and then run a task in that script that detects which phase the boss fight is on and changes which sound object is playing accordingly. You probably want to fade out the old music instead of just having it end abruptly.

Could you explain it with codes, beacuse it's confusing for me to understand.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Fujiwara no Mokou on December 26, 2017, 06:10:30 AM
Could you explain it with codes, beacuse it's confusing for me to understand.

Think of Danmakufu as a low-level, dumb language where you'd have to spell it out on how to adjust even the simplest things, like sound.
You are given a set of tools to manupulate sound, outline here: https://dmf.shrinemaiden.org/wiki/Sound_Object_Functions

If you want to, say, make the sound fade, you'd have to lower the volume over some period of time. You can do it like this:
Code: [Select]
let cur_music = "";  // globally (or high-level) scoped
objSound_Music = ObjSound_Create();
ObjSound_SetSoundDivision( objSound_Music, SOUND_BGM );

// Play the music, fading the previous in fade_time seconds
task PlayMusic( let path_to_music, let fade_time )
{
if( cur_music != path_to_music ) // applies only when changing music
{
let cur_volume = ObjSound_GetVolumeRate( objSound_Music );
let fade = -cur_volume / fade_time;
ObjSound_SetFade( objSound_Music, fade );
while( ObjSound_GetVolumeRate( objSound_Music ) > 0 ){ yield; } // wait until fade is done before proceeding
cur_music = path_to_music;
ObjSound_Load( objSound_Music, path_to_music );
ObjSound_SetVolumeRate( objSound_Music, 100 );
ObjSound_Play( objSound_Music );
}
}

This is just a high-level briefing. The code above may not actually work, but it should help get into the mindset of how things should get done.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Ilw0 on December 30, 2017, 01:05:06 AM
Talking about sounds, is there a way to restart a sound object that's normally supposed to continue after ObjSound_Stop? For example, boss music when you restart a fight should restart as well, while after pausing/unpausing it should just continue playing normally.
Problem is, when you use ObjSound_SetRestartEnable(obj, true) after ObjSound_SetRestartEnable(obj, false), playback starts from the previous stop point and not from the beginning. (adding Plays and Stops between those didn't seem to help either)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on December 30, 2017, 02:43:49 AM
You can set a BGM sound object restarting to true by default and play it normally, and then when you need to start from the beginning you can set restarting to false, Play, and set it back to true again. You could make it a function like

Code: [Select]
function ObjSound_PlayForceRestart(obj){
  ObjSound_SetRestartEnable(obj, false);
  ObjSound_Play(obj);
  ObjSound_SetRestartEnable(obj, true);
}

Unfortunately you can't get what the setting was to begin with so you would have to assume it was initially set to true.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 01, 2018, 04:14:08 AM
Two simple questions that doesn't need any code:
(1) How do I pack my script, in .dat?
(2) How do I undo that?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on January 01, 2018, 06:01:44 PM
Danmakufu comes with a built-in tool for doing that. Sparen has a tutorial (http://sparen.github.io/ph3tutorials/ph3uXl3.html) for it here.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 02, 2018, 12:00:33 PM
Please be patient
http://www.bulletforge.org/u/darkwalker247/p/stellar-effects-library (http://www.bulletforge.org/u/darkwalker247/p/stellar-effects-library) - Stellar FX
http://www.bulletforge.org/u/darkwalker247/p/bloom-effects-library-now-events-based (http://www.bulletforge.org/u/darkwalker247/p/bloom-effects-library-now-events-based) - BFX
----------------------------------------------------------------------------------------------------------------------------------------------------
Both of them are/have functions to make your script more serious (I would say), putting effects and Magic Circles around the boss...

I only have three questions:
(1) Which one is the easiest?
(2) Is there any tutorial about this on any site?
(3) If there isn't or it's not updated anyone could someone explain how to do this?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Ilw0 on January 02, 2018, 02:28:47 PM
You can set a BGM sound object restarting to true by default and play it normally, and then when you need to start from the beginning you can set restarting to false, Play, and set it back to true again. You could make it a function like

Code: [Select]
function ObjSound_PlayForceRestart(obj){
  ObjSound_SetRestartEnable(obj, false);
  ObjSound_Play(obj);
  ObjSound_SetRestartEnable(obj, true);
}

Unfortunately you can't get what the setting was to begin with so you would have to assume it was initially set to true.
This has worked indeed. And that's what I've been doing, but my problem was that I tried to use something similar while stopping music (so that I could simply use ObjSound_Play the next time).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 02, 2018, 02:42:05 PM
Please be patient
http://www.bulletforge.org/u/darkwalker247/p/stellar-effects-library (http://www.bulletforge.org/u/darkwalker247/p/stellar-effects-library) - Stellar FX
http://www.bulletforge.org/u/darkwalker247/p/bloom-effects-library-now-events-based (http://www.bulletforge.org/u/darkwalker247/p/bloom-effects-library-now-events-based) - BFX
----------------------------------------------------------------------------------------------------------------------------------------------------
Both of them are/have functions to make your script more serious (I would say), putting effects and Magic Circles around the boss...

I only have three questions:
(1) Which one is the easiest?
(2) Is there any tutorial about this on any site?
(3) If there isn't or it's not updated anyone could someone explain how to do this?

They are function libraries - include what you need to and use what you want to. There are no tutorials since the instructions on Bulletforge explain what you need to do to use the library - #include what you need to, call the functions you want to call.

For example, if I wanted to use the former, I'd #include Stellar.dnh at the top of my Single script, and in @Initialize I would call Stellar_Init(). Afterwards, I would call whatever function I wanted to.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 02, 2018, 11:32:16 PM
They are function libraries - include what you need to and use what you want to. There are no tutorials since the instructions on Bulletforge explain what you need to do to use the library - #include what you need to, call the functions you want to call.

For example, if I wanted to use the former, I'd #include Stellar.dnh at the top of my Single script, and in @Initialize I would call Stellar_Init(). Afterwards, I would call whatever function I wanted to.
My question was how to use it the library, beacuse I couldn't know what was I doing(what value should I use, what this variable do, the range I should put, etc.)
Help plz
Code: [Select]
Stellar_Init() --Call this once before all other functions.

Stellar_ParticleTexture(path) --Set the texture to use for particles; this can be changed at any point without affecting particles already out so it's okay to change texture a lot.
Stellar_AuraTexture(path) --Set the texture to use for the "aura" effect; this can be changed at any point as well.
Stellar_MagicCircleTexture(path) --Set the texture to use for magic circles; this can be changed at any point as well.

Stellar_AuraPriority(priority) --Set the render priority for the "aura" effect; an integer between 0 and 100.
Stellar_MagicCirclePriority(priority) --Set the render priority for the magic circle effect; an integer between 0 and 100.

Stellar_Explosion(object,time,particlescale,blending,hue) --Create a 3D explosion effect with particles.
Stellar_Charge(object,time,particlescale,blending,hue) --Create a 3D charge effect with particles.
Stellar_Aura(object,radius,wavelength,rotspeed,fadetime,blending,hue,saturation) --Create an "aura" effect that is a warping rotating textured circle around the object.
Stellar_Emitter(object,time,scale,speed,firepitch,fireyaw,spread,life,numperframe,blending,hue,saturation,alpha) --Create a 3D particle emitter on an object.
Stellar_MagicCircle(object,scale,fadetime,pulseamount,pulsespeed,angvel,blending,hue,saturation,alpha) --Create a magic circle on an object.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 03, 2018, 05:00:23 AM
If you really can't understand what you should be doing even when you're given a library to use, you should probably not bother with fancy effects for the time being. You would really just be better off working on things that you can actually learn with.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 03, 2018, 10:37:50 AM
How do I upload my scripts?

I can't register to the BulletForge, so I want to know if that problem is my fault, or if is the site's fault.
(And how to solve this)

If it's my fault = What's the problem? My country? My net? My browser?
If it's the site's fault  = What should I do then? Contact the author?Poste it in another site?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on January 03, 2018, 01:20:27 PM
How do I upload my scripts?

I can't register to the BulletForge, so I want to know if that problem is my fault, or if is the site's fault.
(And how to solve this)

If it's my fault = What's the problem? My country? My net? My browser?
If it's the site's fault  = What should I do then? Contact the author?Poste it in another site?

From what I've heard Bulletforge has closed signups so you'd need to contact the owner to get an account.
In the meantime just upload to any file sharing site (preferably one that isn't a scam) and share the link.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 03, 2018, 09:13:07 PM
From what I've heard Bulletforge has closed signups so you'd need to contact the owner to get an account.
In the meantime just upload to any file sharing site (preferably one that isn't a scam) and share the link.

Good examples: Mediafire, Mega.co.nz (AKA MEGA)
Other examples: DropBox, GitHub (for advanced users), etc.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 06, 2018, 09:25:29 AM
Two questions:

How can I make the bullets transforms to score(that gray squares that add to your score)?

What are the AnimationData arguments? (I couldn't find it on dmf wiki)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on January 06, 2018, 02:10:44 PM
So, I want to reveal parts of background only in certain places and shapes, kinda like Doremy's occult attack in AoCF (http://tinypic.com/r/33m9b2d/9), how do I do it? I tried using render targets, but it's too complicated and difficult to use without a tutorial.

Btw, how do I attach images to my posts?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on January 06, 2018, 02:35:51 PM
How can I make the bullets transforms to score(that gray squares that add to your score)?
use DeleteShotAll( ,TYPE_ITEM)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on January 07, 2018, 08:24:36 AM
So, I want to reveal parts of background only in certain places and shapes, kinda like Doremy's occult attack in AoCF (http://tinypic.com/r/33m9b2d/9), how do I do it? I tried using render targets, but it's too complicated and difficult to use without a tutorial.

Btw, how do I attach images to my posts?

While it's actually pretty easy (or not, depending on how much setup you're comfortable with doing from scratch) to grab simple shapes from a texture and draw them in Danmakufu, the same may not hold true if you want to take the transparency of the edges of the shapes into account, in order to preserve a more natural-looking portal effect as is done in the example from Antinomy of Common Flowers that you had provided.

You're better off creating an alpha mask and using HLSL to display part of an image with the transparency dictated by the alpha mask. If you want to display an animated image, you may also try passing the name of a render target to the shader, since a render target may be updated without having to reset the texture taken by the objects that use said render target each frame.

There is an example in the script/sample folder that demonstrates just that. I think it's shader example #2, but my memory could be failing me. Please consult them -- the simple act of (methodical) experimentation and learning through trial and error will prove to be very useful.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on January 07, 2018, 09:50:32 AM
While it's actually pretty easy (or not, depending on how much setup you're comfortable with doing from scratch) to grab simple shapes from a texture and draw them in Danmakufu, the same may not hold true if you want to take the transparency of the edges of the shapes into account, in order to preserve a more natural-looking portal effect as is done in the example from Antinomy of Common Flowers that you had provided.

You're better off creating an alpha mask and using HLSL to display part of an image with the transparency dictated by the alpha mask. If you want to display an animated image, you may also try passing the name of a render target to the shader, since a render target may be updated without having to reset the texture taken by the objects that use said render target each frame.

There is an example in the script/sample folder that demonstrates just that. I think it's shader example #2, but my memory could be failing me. Please consult them -- the simple act of (methodical) experimentation and learning through trial and error will prove to be very useful.

I followed your advise and used 2nd sample, but now I have even more problems. Using different images as masks and applying them to different render priorities is ok, but I don't know how to manipulate the masks (change their scale, etc.), and I don't know neither how shaders work in danmakufu nor HSLS programing, and that makes it really hard for me. Is there any tutorials on danmakufu shaders and maybe HLSL that doesn't require deep C++ knowledge?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 07, 2018, 10:03:06 AM
Is there a function for making the screen shake like Master Spark?
...
If there isn't, how could I do it?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 07, 2018, 11:28:52 AM
How can I make the bullets transforms to score(that gray squares that add to your score)?
use DeleteShotAll( ,TYPE_ITEM)
Or DeleteShotInCircle.

Additionally you can use the ObjShot_ToItem function which is more useful for fine control if you have the object IDs, and also ObjShot_SetItemChange to set whether bullets are deleted to items or not.

What are the AnimationData arguments? (I couldn't find it on dmf wiki)
(num_frames, left, top, right, bottom)

Is there a function for making the screen shake like Master Spark?
You can use Set2DCameraFocusX and Set2DCameraFocusY to shift the 2D camera around. Then you would write something that uses those to move the camera rapidly.

I followed your advise and used 2nd sample, but now I have even more problems. Using different images as masks and applying them to different render priorities is ok, but I don't know how to manipulate the masks (change their scale, etc.), and I don't know neither how shaders work in danmakufu nor HSLS programing, and that makes it really hard for me. Is there any tutorials on danmakufu shaders and maybe HLSL that doesn't require deep C++ knowledge?
Shader objects are Render objects and so you can use things like ObjRender_SetScaleXYZ as you would anything else.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on January 07, 2018, 12:02:38 PM
Shader objects are Render objects and so you can use things like ObjRender_SetScaleXYZ as you would anything else.

Here's all the code that I use (https://pastebin.com/YzMNJQ1j - danmakufu code; https://pastebin.com/wuCby6mg - HLSL code), but none of the ObjRender functions work on objShader. Maybe I'm missing something?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on January 09, 2018, 11:44:57 PM
I'm playing around with making gaps that warp bullets from one to another, and I've got them working for the most part, though they still need improvement. However, now I'm encountering a strange issue where Danmakufu freezes after warping shots through the gaps - but not until the single ends.

My guess would be that it has something to do with cleaning up the gaps at the end, but it still happens when then there aren't any gaps left at the end, and it doesn't happen if no shots have been warped through gaps.

Gap functions: https://pastebin.com/YuBEVpnQ
Test single: https://pastebin.com/x3ZiGAgQ
Finalize task: https://pastebin.com/M1jBXNzf

Any ideas?

Edit: It didn't happen when I stopped creating gaps well before the end of the script, so I'm guessing it's to do with them being deleted at the end after all. It's not just something being null unexpectedly, though, since that would throw an exception rather than "th_dnh.exe has stopped working".
Edit2: It only happens when the spell times out, not when the boss is shot down.

Edit3: It still froze when I replaced the "in" gap with an "out" gap, which do nothing on their own, thus preventing any bullets from being warped. (It didn't freeze earlier when I stopped the shots being fired at all, leading me to think it only happened when shots had been warped.)

So now I think it's something to do with the task I was using to fire a "wedge" of shots (like Seiran). I wrote it the other day but hadn't yet actually used it in anything aside from testing (used it here because it's an easy way to check how deformed the pattern gets), so I'm not too surprised I hadn't noticed it yet.

Wedge shot task: https://pastebin.com/yGUZDFrc

Edit4: Found the problem. Turns out it was completely unrelated to the gaps. To make it easier to get a reference to all the shots in a wedge, the wedge task adds each new shot to an array stored in the dictionary of an invisible dummy bullet, which the function returns. The dummy bullet was deleted when the single ended, but the task had just enough time before the script closed to try to add one more row. Since the dummy bullet had been deleted, the script crashed when it tried to use it.

Still not sure why that caused Danmakufu to freeze instead of just throwing an exception, though. Something to do with the script being in the process of ending, maybe?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 10, 2018, 02:34:26 AM
Relevantly, the fact that you're deleting the dummy shot from its own task should clue you in that you don't really need the dummy at all. The main benefit that returning a dummy shot object carrying the shot array has over just returning the shot array is that, if you want to change the array over time from an internal task, you can't just pass the array reference (because arrays are not mutable), so you use the mutable object instead. But in your case you aren't using the returned object at all, nor is the object being used in the task because it's just a dummy anyways. So really "Shots" and "IsNewShots" should just be variables.

Also it crashes because trying to access a nonexistent object value will crash. You typically use GetValueD everywhere which is safe but you can't get around SetValue without first checking if the object exists.


Here's all the code that I use (https://pastebin.com/YzMNJQ1j - danmakufu code; https://pastebin.com/wuCby6mg - HLSL code), but none of the ObjRender functions work on objShader. Maybe I'm missing something?
Haven't forgotten about this, but yes in order to do what you want you need some extra stuff. I have a test background I did this with, but there's a lot of unrelated code so it's a bit tricky to extract just the parts needed to explain what to do, so hang on.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on January 10, 2018, 03:35:06 AM
Relevantly, the fact that you're deleting the dummy shot from its own task should clue you in that you don't really need the dummy at all. The main benefit that returning a dummy shot object carrying the shot array has over just returning the shot array is that, if you want to change the array over time from an internal task, you can't just pass the array reference (because arrays are not mutable), so you use the mutable object instead. But in your case you aren't using the returned object at all, nor is the object being used in the task because it's just a dummy anyways. So really "Shots" and "IsNewShots" should just be variables.
Normally I would just return the shot array, yes, but in this case not all the bullets are created immediately, so I'd only get an array containing the first bullet and not be able to get a reference to the others. By doing it like this I can come back and grab the references once all the shots have been created, or handle the new ones as they're created. I'm not using it for anything at the moment, but I almost certainly will at some point, so it's there when I need it.
Deleting it from the task is just to make sure it gets deleted, since it's not autodelete and isn't moving anyway - the idea is I'd copy the final array before it's deleted - but now that I look at it again there are better ways of ensuring that.

Haven't forgotten about this, but yes in order to do what you want you need some extra stuff. I have a test background I did this with, but there's a lot of unrelated code so it's a bit tricky to extract just the parts needed to explain what to do, so hang on.
You mean the gaps? They're shaping up pretty nicely, actually. Here's the current code: https://pastebin.com/VgTfDrTz
I still need to do some stuff like warping shots when they hit the back and making sure the edge detection works at all angles (currently it's near-perfect at 90/270 and a bit weird otherwise), but the main part is looking pretty solid.
Edit: Greatly improved after swapping around a few things so it checks where the edge actually is and not where the edge would be if the whole thing was mirrored: https://pastebin.com/p7qycsBU
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 10, 2018, 04:51:28 AM
Normally I would just return the shot array, yes, but in this case not all the bullets are created immediately, so I'd only get an array containing the first bullet and not be able to get a reference to the others. By doing it like this I can come back and grab the references once all the shots have been created, or handle the new ones as they're created. Deleting it from the task is just to make sure it gets deleted, since it's not autodelete and isn't moving anyway - the idea is I'd copy the final array before it's deleted - but now that I look at it again there are better ways of ensuring that.
Well like I said, you don't actually seem to be using the return value for anything. Even if you did want to use the returned dummy object, you delete it, making it useless.

If you plan to actually use the array outside of the task, what you can do instead is to not use CreateShotA1, but create and set up the shots manually, all at once, but have each row of bullets call ObjShot_Regist (i.e. fire them) after a different number of frames. This way all the objects are created and can fill the array which you can then return.

Here's my implementation: https://gist.github.com/drakeirving/36aac5ad8ddcc504525a983d56a3e2ea

You mean the gaps?
I quoted somebody else, if you missed that ;P
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on January 10, 2018, 10:00:34 PM
Well like I said, you don't actually seem to be using the return value for anything. Even if you did want to use the returned dummy object, you delete it, making it useless.
It waits a few seconds after creating all the bullets to delete it, so I can grab a new reference before then. It is a bit silly, though, I'll probably rework it before actually using it.

If you plan to actually use the array outside of the task, what you can do instead is to not use CreateShotA1, but create and set up the shots manually, all at once, but have each row of bullets call ObjShot_Regist (i.e. fire them) after a different number of frames. This way all the objects are created and can fill the array which you can then return.
Ah, so that's what that's for! I kept seeing those and not quite getting why I would use them instead of the CreateShot functions. I'll have to mess around a bit with that, then.

Here's my implementation: https://gist.github.com/drakeirving/36aac5ad8ddcc504525a983d56a3e2ea
Random question, is there any particular reason you're allocating space for the reference to the shot in the loop itself? I usually put let shot, etc before the loop, so I can reuse the same variable and in theory save time on memory allocation.
On the other hand, I hadn't realized that you can avoid passing things in as arguments to those internal tasks like that, at least inside a loop. I always passed in i manually. Does the task need to be defined inside the loop to do that?

I quoted somebody else, if you missed that ;P
Ah, whoops. I hit quote and was looking at that when typing out my response.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 11, 2018, 03:39:24 AM
Random question, is there any particular reason you're allocating space for the reference to the shot in the loop itself? I usually put let shot, etc before the loop, so I can reuse the same variable and in theory save time on memory allocation.
On the other hand, I hadn't realized that you can avoid passing things in as arguments to those internal tasks like that, at least inside a loop. I always passed in i manually. Does the task need to be defined inside the loop to do that?
Nah, no particular reason. Garbage collection works fine; it isn't as though the actual objects are allocated differently either; the ID is just a number. When it has a coding advantage I'll typically opt for it.

The task thing works precisely because the task is defined inside that scope. It acts like any other scope; it has access to the outer scope variables, any variables defined within do not exist outside the task (of course), and the task name only exists inside the scope it was defined in.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 12, 2018, 12:36:38 PM
How am I supossed to do this in real code:
Code: [Select]
task TPlural{
        if(first_bosslife == 0) {
             create(second_boss);
             change(bgm1 to bgm2);
         }
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 12, 2018, 01:05:36 PM
If you wanted to fight two bosses back-to-back you would make a stage with two plural scripts. A plural script generally (but doesn't have to) contains one boss.
Also see http://sparen.github.io/ph3tutorials/ph3u3l23.html
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 12, 2018, 05:00:33 PM
If you wanted to fight two bosses back-to-back you would make a stage with two plural scripts. A plural script generally (but doesn't have to) contains one boss.
Also see http://sparen.github.io/ph3tutorials/ph3u3l23.html

Threw together an example of two plural scripts in the same stage at the end of the guide.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: saisengen on January 13, 2018, 06:33:59 AM
After recent drivers update, all Danmakufu ph3 based games, includind ido games from MPP to BSM, became crash on start. Debugging shows that the problem is in the amd64 driver. Does anyone except me has such problem?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 13, 2018, 12:07:01 PM
Threw together an example of two plural scripts in the same stage at the end of the guide.
Thank you for this adding this.

If you wanted to fight two bosses back-to-back you would make a stage with two plural scripts. A plural script generally (but doesn't have to) contains one boss.
Also see http://sparen.github.io/ph3tutorials/ph3u3l23.html
It worked perfectly and I thank you very much, but I'm having problem with the background and exiting (before reaching the boss - "you are using a variable that has not been set yet")

https://pastebin.com/Fsc1YgLy


Large code pastes go into pastebin links --Helepolis
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on January 13, 2018, 09:58:08 PM
The problem seems to be that stagepart isn't set to a value when its created, but can be checked by @Event before it gets a value assigned to it. If you changed  line 7 from "let stagepart" to "let stagepart = 0", then it should probably work fine.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Trickysticks on January 13, 2018, 10:16:35 PM
After recent drivers update, all Danmakufu ph3 based games, includind ido games from MPP to BSM, became crash on start. Debugging shows that the problem is in the amd64 driver. Does anyone except me has such problem?

When I updated the drivers for my AMD card that happened to me too. I tried restarting and other things but could only fix it by reverting my driver to the previous version.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: saisengen on January 14, 2018, 04:17:21 AM
How you revert driver to older version?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 14, 2018, 09:49:32 AM
The problem seems to be that stagepart isn't set to a value when its created, but can be checked by @Event before it gets a value assigned to it. If you changed  line 7 from "let stagepart" to "let stagepart = 0", then it should probably work fine.
The error is gone, thanks for the help :D
But... the background is still black...and I don't know why
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on January 14, 2018, 05:33:53 PM
The error is gone, thanks for the help :D
But... the background is still black...and I don't know why

There's nothing in the code you pasted about a background, so I'm not sure about exactly what's wrong. Based on my own experiences with backgrounds though, the most likely thing that's wrong is filepaths. Its possible that either your stage script is referring to the wrong file with its #Background or your background script is referring to the wrong image.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: PyuDi on January 15, 2018, 07:22:11 AM
I was wondering how to add the ?note? bullets from DDC. If there are, please tell me it.
However, I think there is none, so I will make it.
But the question is: how do I make the collision only in the head of the note bullet? +Is there any note bullet script?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 15, 2018, 10:00:14 AM
You can use the collision parameter in the shot definition to move the hitbox to the head. It should look like collision = (r, x, y) where r is the radius and x,y is the relative position of the hitbox from the center.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 15, 2018, 12:51:18 PM
Here is my Background script (https://pastebin.com/9qXdR9Tq) and my Stage script (https://pastebin.com/iw78zw2e) (For anyone to see this and try to see the problem)
For me it's ok, but the background is black still...soooooo there is a problem! :blush:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 15, 2018, 01:57:35 PM
Almost definitely the problem is that you start it immediately with TCallBg which checks while(!Obj_IsDeleted(GetEnemyBossSceneObjectID())). In a Single or Plural, the boss scene object will exist before your script even starts (because it's created in the "default" stage script), but in a Stage script it won't exist until you start a plural script where you make the scene object. So the while loop condition fails immediately and your background is never created.

You can fix this by changing TCallBg to something else that makes sense for the stage. How it's set up right now (draw a normal bg until a spell starts, then draw the spell bg until it stops, and loop as long as the boss exists) is clearly meant for a boss fight, but if you actually had stuff before or after the boss, this doesn't make sense anymore.

Because your MainLoop already does the checking for an existing boss scene and spell (and puts the result in bSpell), you can actually make it simpler:
Code: [Select]
task TCallBg{
    loop{
        TNormalBackground;
        while(bSpell==false){ yield; }
        TSpellBackground;
        while(bSpell==true){ yield; }
    }
}


(For anyone else reading, there are reasons why you shouldn't quite do it this way, and there are better ways to set this up, but for the sake of this answer and simplicity it's better off ignoring all that)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on January 16, 2018, 01:59:14 AM
I'm trying to write a function to safely check if a variable is null, deleted, or otherwise shouldn't be dereferenced. It can check both of those fine, but doing so 100% safely is out of reach unless I can find a way to check if it's been set.

Code: [Select]
function isnull(obj){                        //is this safe to use?
//do something              //if it hasn't been set
if(!obj){return true;}               //if it's null
if(Obj_IsDeleted(obj)){return true;} //if it's been deleted
return false;                        //we're good
}

Is there any possible way to check if a variable has been set without crashing the script? Exception handling, awful hacks, anything?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 16, 2018, 02:12:10 AM
Almost definitely the problem is that you start it immediately with TCallBg which checks while(!Obj_IsDeleted(GetEnemyBossSceneObjectID())). In a Single or Plural, the boss scene object will exist before your script even starts (because it's created in the "default" stage script), but in a Stage script it won't exist until you start a plural script where you make the scene object. So the while loop condition fails immediately and your background is never created.

You can fix this by changing TCallBg to something else that makes sense for the stage. How it's set up right now (draw a normal bg until a spell starts, then draw the spell bg until it stops, and loop as long as the boss exists) is clearly meant for a boss fight, but if you actually had stuff before or after the boss, this doesn't make sense anymore.

Because your MainLoop already does the checking for an existing boss scene and spell (and puts the result in bSpell), you can actually make it simpler:
Code: [Select]
task TCallBg{
    loop{
        TNormalBackground;
        while(bSpell==false){ yield; }
        TSpellBackground;
        while(bSpell==true){ yield; }
    }
}

Thank you so much! It works perfectly :3 :3
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 16, 2018, 03:21:33 AM
I'm trying to write a function to safely check if a variable is null, deleted, or otherwise shouldn't be dereferenced. It can check both of those fine, but doing so 100% safely is out of reach unless I can find a way to check if it's been set.

Is there any possible way to check if a variable has been set without crashing the script? Exception handling, awful hacks, anything?
I don't think this is ever possible. If your intended use is to set up variables meant to store object IDs but have them potentially empty, or want to empty them, and still have all processing work consistently, you should be setting the values to ID_INVALID, which is just -1.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 16, 2018, 09:24:08 AM
I know it's really simple to do these desires, but I can't figure it out how to do them:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 16, 2018, 03:24:46 PM
I know it's really simple to do these desires, but I can't figure it out how to do them:
  • Write the name of the boss below the lifebar
  • Have an difficulty written (not with CommonData)
  • Have pretty effects(like charge, death, explode)

https://dmf.shrinemaiden.org/wiki/Text_Object_Functions
https://dmf.shrinemaiden.org/wiki/Primitive_Object_Functions
https://dmf.shrinemaiden.org/wiki/Render_Object_Functions

Everything you are trying to do can be done using Text objects and Render objects.
I suggest having a blank single script where you experiment with these and try to get them working the way you want.
For moving render objects, simply calculate their positions using trigonometry: current position = original position + time elapsed*speed, so currx = origx + time*speed*cos(angle), curry = origy + time*speed*sin(angle)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on January 16, 2018, 05:24:57 PM
Its also worth noting that the 0.12m tutorials (https://dmf.shrinemaiden.org/wiki/Tutorials_(0.12m)) are mostly still applicable to drawing stuff. The only big difference I noticed was that effect objects are now primitive objects in ph3.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 17, 2018, 01:26:54 AM
About fonts
I have a file named "reve.ttf" which font is Revue...but...
Which example should I use?
Code: [Select]
ObjText_SetFontType(text, "./reve.ttf");
//or
ObjText_SetFontType(text, Revue);
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 17, 2018, 01:35:36 AM
About fonts
I have a file named "reve.ttf" which font is Revue...but...
Which example should I use?
Code: [Select]
ObjText_SetFontType(text, "./reve.ttf");
//or
ObjText_SetFontType(text, Revue);

The font name is Revue. Use Revue.

...I guess I should directly spell this out in my tutorial, huh.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 17, 2018, 01:43:12 AM
The font name is Revue. Use Revue.

...I guess I should directly spell this out in my tutorial, huh.
oops forgot InstallFont
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 17, 2018, 10:51:20 PM
Is there a way to extract archives from .dat files?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 17, 2018, 11:11:53 PM
Is there a way to extract archives from .dat files?

If a creator decides to package their files so that they cannot be accessed by other people, please respect their decision to protect their assets.

If you want to rip their resources with complete disregard to their wishes, feel free to use Google search or the forum's search feature.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 19, 2018, 01:48:36 AM
If a creator decides to package their files so that they cannot be accessed by other people, please respect their decision to protect their assets.

If you want to rip their resources with complete disregard to their wishes, feel free to use Google search or the forum's search feature.

 :blush: :blush: You said in such a disappointed way... I feel embaresed now :blush: :blush:
And I can't even delete this
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 19, 2018, 03:12:23 AM
It's fine, we just need to tell people to make it known that it's frowned upon and so that people aren't unintentionally being disrespectful.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 19, 2018, 12:32:20 PM
How can I recreate Reisen's effect/illusion?
("one" bullet turns to two in differents angles - First Spell)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MugenCC on January 19, 2018, 09:41:15 PM
Hello. I'm trying to make a spell that releases Bills which explode into bullets. The bullets are large balls with 10 tiny balls which circle around each.

Code: [Select]
task MainTask {
Wait(60); //Time for the Boss to get in position
while(ObjEnemy_GetInfo(objBoss,INFO_LIFE) > 0){
let bomb = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 0, 90, DS_BILL_BLUE, 5); //Creates "Bombs"
ObjMove_SetDestAtFrame(bomb, GetPlayerX(), GetPlayerY(), 60); //Moves the "Bomb" to the Player's previous position
Wait(60); //Wait until the bomb gets in position
let thetaT = rand(0,36);
ascent(i in 0..10){
let bull = CreateShotA1(ObjMove_GetX(bomb), ObjMove_GetY(bomb), 4, thetaT+36*i, DS_BALL_M_A_SKY, 5); //Creates the "shrapnel"
ObjMove_SetAngularVelocity(bull, 0.45);
ascent(j in 0..10){
let orb = CreateShotA1(ObjMove_GetX(bull)+20*cos(36*i), ObjMove_GetY(bull)+20*sin(36*i), 0,36*j, DS_BALL_SS_SKY, 5); //Creates bullets that circle around the shrapnel
Orbit(bull,orb,36*j);
}
}
Obj_Delete(bomb); //Deletes the bomb
Wait(7);
}
}

task Orbit(bull,orb,ang) {
let tim = 0;
while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){
ObjMove_SetPosition(orb,ObjMove_GetX(bull)+4.3*cos(ObjMove_GetAngle(bull))+20*cos(ang+tim), ObjMove_GetY(bull)+4.3*sin(ObjMove_GetAngle(bull))+20*sin(ang+tim)); //Keeps the bullets around the shrapnel
tim += 3; //Causes the bullets to rotate around the shrapnel
yield;
}
}
The problem I'm having is that tiny bullets keep appearing in the top-left corner. I think it's the SetPosition command in the Orbit task that's causing this, but I don't know how to fix it.

PS: I am VERY new to Danmakufu.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 20, 2018, 11:59:06 AM
I wanted to make an overlay that moves/scroll above the spell bg...
How I do that?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 20, 2018, 03:31:17 PM
I wanted to make an overlay that moves/scroll above the spell bg...
How I do that?

Make an Overlay, and then move it across the spell bg using ObjRender_SetPosition()?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on January 20, 2018, 05:47:00 PM
How can I recreate Reisen's effect/illusion?
("one" bullet turns to two in differents angles - First Spell)

Copying bullets isn't too hard when you know exactly what kind of bullets you'll be copying - just make another with the same parameters and no delay on top of the original shot. A generalized version is harder, since there aren't getters for a lot of things (like acceleration, angular velocity...), so you'd need to either pass the inaccessible properties in as parameters, or store them in the shot's dictionary when you set them (i.e. Obj_SetValue(shot,"Acceleration",0.05); ).

As for the other part (the shots turning transparent/non-colliding), what you'll want is a task that sets the shot's alpha (ObjRender_SetAlpha) and makes it non-colliding (ObjShot_SetIntersectionEnable), moves it how you want, and then sets its alpha and collision back how they were. To preserve its motion after releasing it and prevent it turning to face the direction you're moving it in, set its position and angle each frame instead of using speed/angle.

If the shot has acceleration, you'll also want to note its speed at the beginning and set it back to that at the end, so that it doesn't accelerate while being moved. You might also need to set its speed to zero while moving it, not sure if that'll cause problems.

As for moving it from a to b by setting its position, here are some functions to simplify the matter:
Code: [Select]
function lerp(start,end,t){return (1-t)*start+t*end;}
function blerp(x0,y0,x1,y1,t){return [lerp(x0,x1,t),lerp(y0,y1,t)];}
These are functions for [bi]linear interpolation, which just means "get a point xx% of the way along this line". The first is for a single value (such as x, y, or angle); the second finds a point in 2D coordinates. t is a ratio (0-1) of how far along to get the point from.

A few more helpful functions:
Code: [Select]
//Ultima
function NormalizeAngle(angle){ angle %= 360; if(angle<0){angle += 360;} return angle; }
//Blargel
function GetAngularDistance(angle1, angle2){ let distance = NormalizeAngle(angle2 - angle1); if(distance>180){ distance-=360; } return distance; }
These help avoid things behaving weirdly when, say, one angle is 15 degrees and the other is 330 degrees. If you just subtract the angles normally it'll probably end up going all the way around - this way you can easily determine the shorter way to turn.

So the code to move the shot would look something like this:
Code: [Select]
task MoveShot(shot,startx,starty,endx,endy,startang,endang,time){
    ObjRender_SetAlpha(shot,128); ObjShot_SetIntersectionEnable(shot,false); let origspd = ObjMove_GetSpeed(shot);
    let dA = GetAngularDistance(startang,endang);
    let pos; let ang;
    ascent(i in 0..time){
        pos = blerp(startx,starty,endx,endy,  i/time);
        ang = startang + lerp(0,dA, i/time);
        ObjMove_SetPosition(shot, pos[0],pos[1]);
        ObjMove_SetAngle(shot,ang);
        yield;
    }
    ObjRender_SetAlpha(shot,255); ObjShot_SetIntersectionEnable(shot,true); ObjMove_SetSpeed(shot,origspd);
}
You'd call that on both the original shot and the copied shot, adjusting their parameters as desired.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on January 20, 2018, 06:03:54 PM
Code: [Select]
while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){
ObjMove_SetPosition(orb,ObjMove_GetX(bull)+etc, ObjMove_GetY(bull)+etc);
yield;
}
The problem here is that you aren't checking if the central bullet has been deleted. The central shot gets deleted, the task keeps going, and it continues setting the orbiting shots' position. Since the central shot is deleted, trying to get its position gives 0,0, and so that's where they rotate around. Rather than while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){...}, use while(!Obj_IsDeleted(bull)){...}.

Everything created by the single gets deleted at the end anyway (assuming you set SetAutoDeleteObject(true);, which you should), so no need to keep checking the boss' life everywhere. Even for stuff that doesn't depend on a central bullet/etc, I just check the boss' life once per frame in @MainLoop and use while(!Obj_IsDeleted(boss)){...} elsewhere.


Ah, right, I originally came here to ask a question of my own.
I've got (among other things) a 2D sprite that goes on top of another 2D sprite, and a task setting its position to the position of the first one. When I move the first one around, though, the second lags behind by a frame, presumably due to the order things are being executed in each frame. Any way I can synchronize them aside from moving both of them every time?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 20, 2018, 09:04:48 PM
Make an Overlay, and then move it across the spell bg using ObjRender_SetPosition()?
Don't worry, I got it working with "your" help (your github site)

So the code to move the shot would look something like this:
Code: [Select]
task MoveShot(shot,startx,starty,endx,endy,startang,endang,time){
    ObjRender_SetAlpha(shot,128); ObjShot_SetIntersectionEnable(shot,false); let origspd = ObjMove_GetSpeed(shot);
    let dA = GetAngularDistance(startang,endang);
    let pos; let ang;
    ascent(i in 0..time){
        pos = blerp(startx,starty,endx,endy,  i/time);
        ang = startang + lerp(0,dA, i/time);
        ObjMove_SetPosition(shot, pos[0],pos[1]);
        ObjMove_SetAngle(shot,ang);
        yield;
    }
    ObjRender_SetAlpha(shot,255); ObjShot_SetIntersectionEnable(shot,true); ObjMove_SetSpeed(shot,origspd);
}
Thank you very much for this, that was too complex for me to think about alone, but how I do this in a circle?
The result is only one bullet(or 60 in one position?)
MoveShot(s, ObjMove_GetX(s), ObjMove_GetY(s), ObjMove_GetX(s) - 50, ObjMove_GetY(s), 0, 0, 60);
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 21, 2018, 02:44:15 PM
Ah, right, I originally came here to ask a question of my own.
I've got (among other things) a 2D sprite that goes on top of another 2D sprite, and a task setting its position to the position of the first one. When I move the first one around, though, the second lags behind by a frame, presumably due to the order things are being executed in each frame. Any way I can synchronize them aside from moving both of them every time?
You'll have the frame of difference if the second object position is set before the first object moves (generally because the tasks were started and yielded in that order), or if the first object moves using SetAngle/Speed or similar functions, which only updates positions after the frame is over but before rendering (not that this is relevant for Sprite objects). If it's the first and you can't guarantee execution order, you could use an auxiliary position variable that both objects will move to.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: PyuDi on January 24, 2018, 02:13:25 AM
My mind was just tangled with if statements and the frame.
What I was trying to do was below:

frame 0 ~ 600: do A
frame 600: yield 60x
frame 660 ~ 1200: do B
frame 1200: yield 60times
frame 1260 ~ 1800: do A
...and so on.
in short, (x=variable)
until frame 600x, do A
when frame 600x, yield 60times
until frame 1200x, do B

in words,
do A, yield, do B, yield, do A, ...and so on.

How can I implement this thing with codes?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on January 24, 2018, 03:53:12 AM
Thank you very much for this, that was too complex for me to think about alone, but how I do this in a circle?
If you mean moving the shot in (part of) a circle, you'll want to pick a center point to rotate around, and use lerp for the angle from the center. Something like:
Code: [Select]
rad=getdist(cx,cy,startx,starty); startarc=getangle(cx,cy,startx,starty); endarc=getangle(cx,cy,destx,desty);
arc=lerp(startarc,endarc,i/time); x=cx+rad*cos(arc); y=cy+rad*sin(arc);
function getangle(x0,y0,x1,y1){return atan2(y1-y0,x1-x0);}
function getdist(x0,y0,x1,y1){return ((x0-x1)^2 + (y0-y1)^2)^0.5;}
I don't think that's what you meant, so I crunched it up to save space, but it's there if you did mean that. Grab those functions either way if you haven't got them, though.

If, as I think you do, you mean making a bunch of shots come out of the original shot in a circle, things are a bit easier.
The result is only one bullet(or 60 in one position?)
MoveShot(s, ObjMove_GetX(s), ObjMove_GetY(s), ObjMove_GetX(s) - 50, ObjMove_GetY(s), 0, 0, 60);
Er, yes, you call that on each copy of the original shot, it doesn't make the copies. Try this instead:
Code: [Select]
let N=60; let radius=50;
ascent(i in 0..N){
    s = CopyShot(origshot); //or whatever you're doing to copy them
    MoveShot(s, ObjMove_GetX(s), ObjMove_GetY(s), ObjMove_GetX(s)+radius*cos(i*360/N), ObjMove_GetY(s)+radius*sin(i*360/N), ObjMove_GetAngle(s), ObjMove_GetAngle(s), 60);
}
Here's the function I use to copy shots (https://pastebin.com/vbseDHzt), or you can just create the same kind of shot with the original shot's position/angle/etc.

Andi: You're definitely talking too high-level there, just saying. You might not be able to help much.
Whoops, tried to tone it down a bit.


do A, yield, do B, yield, do A, ...and so on.
How can I implement this thing with codes?
Code: [Select]
loop(600){ do A; yield; }
wait(60);
loop(540){ do B; yield; }
wait(60);
Or how I usually do it:
Code: [Select]
let thingtodo=A;
task TdoA { while(thingtodo==A){ do A; yield; } wait(60); TdoB; }
task TdoB { while(thingtodo==B){ do B; yield; } wait(60); TdoA; }
task ChangeThingToDo{
    TdoA;
    loop{
         wait(540); if(thingtodo==A){thingtodo=B;}else{thingtodo=A;}
    }
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 24, 2018, 03:55:09 AM
Andi: You're definitely talking too high-level there, just saying. You might not be able to help much.

My mind was just tangled with if statements and the frame.
What I was trying to do was below:
You already have the logic fine. I'm not entirely sure what's troubling you.

Code: [Select]
loop{ // or while(something), etc
  loop(600){
    // A
    yield;
  }
  loop(60){ yield; }
  loop(540){
    // B
    yield;
  }
}

Assuming you actually want to be doing A and B for every frame there, which is what you described.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: PyuDi on January 25, 2018, 07:24:20 AM
Came with another question.
How can I make a bullet A which erases bullet Bs when A is collided with B?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 25, 2018, 07:43:14 AM
That problem starts easy enough but can get really complicated depending on what you actually want. If you just want A bullets that erases all other bullets on contact, you can set up A bullets like this:

Code: [Select]
task BulletA{
  // make the bullet here
  ObjShot_SetSpellResist(obj, true);
  while(!Obj_IsDeleted(obj)){
    DeleteShotInCircle(TYPE_SHOT, TYPE_IMMEDIATE, ObjMove_GetX(obj), ObjMove_GetY(obj), deletion_radius);
    yield;
  }
}

Check the parameters for DeleteShotInCircle for more information. This deletes bullets that are not spell-resistant, and sets itself as spell-resistant so it doesn't delete itself.
If you're also adding other bullets into the mix that needs some extra work.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on January 25, 2018, 08:19:53 AM
I just noticed my framerate counter is locked at 60, even when frames are definitely being dropped. It's also being displayed in the menu even before loading a script. Messing with the display code in the system script I'm using manipulates the right text, without leaving another one floating there or something, but it's still locked at 60, meaning it's getting 60 back from GetCurrentFps.

Any idea what's causing this/how to fix it?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: PyuDi on January 26, 2018, 01:34:44 AM
That problem starts easy enough but can get really complicated depending on what you actually want. If you just want A bullets that erases all other bullets on contact, you can set up A bullets like this:

Code: [Select]
task BulletA{
  // make the bullet here
  ObjShot_SetSpellResist(obj, true);
  while(!Obj_IsDeleted(obj)){
    DeleteShotInCircle(TYPE_SHOT, TYPE_IMMEDIATE, ObjMove_GetX(obj), ObjMove_GetY(obj), deletion_radius);
    yield;
  }
}

Check the parameters for DeleteShotInCircle for more information. This deletes bullets that are not spell-resistant, and sets itself as spell-resistant so it doesn't delete itself.
If you're also adding other bullets into the mix that needs some extra work.

Thanks for giving help, I understood. But looks like I need some extra work.
My code is this (https://pastebin.com/Ke3MU1gU), while Yellow bullets turned into green bullets, at the same time, I want newly fired yellow bullets to erase the green bullets. Tried putting KagomeKagome; (and other needed ones) at //make the bullet here, but failed.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 26, 2018, 06:40:06 PM
That would be the CreateShotA1 call. Set up the way you have it, you would run a second task alongside the Kagome one that does the DeleteShot while loop and stuff. So like

Code: [Select]
let obj = CreateShotA1(ex, ey, 3, randa, DS_BALL_L_YELLOW, 2);
task SetDeleteShotEnable(obj){
  ObjShot_SetSpellResist(obj, true);
  while(!Obj_IsDeleted(obj)){
    DeleteShotInCircle(TYPE_SHOT, TYPE_IMMEDIATE, ObjMove_GetX(obj), ObjMove_GetY(obj), deletion_radius);
    yield;
  }
}
SetDeleteShotEnable(obj);
KagomeKagome(obj);
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on January 26, 2018, 11:21:25 PM
How do I get the filepath of a single from within that single? I'm trying to retrieve the contents of #Title so I only need to change it in one place, but GetScriptInfoA1 takes a filepath, and GetOwnScriptID gives an id number rather than the filepath.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 29, 2018, 08:53:50 PM
I've been crunching that problem for a while now and there is really no simple solution as far as I can see. The "best" solution might be the simplest -- to just keep a global variable with the script's filename -- but considering your issue is that you want to eliminate redundancy this is questionable.

That being said, I do have a complex solution. In the past day I've brewed up a system that wraps around script management as well as some boss scene management. I've been wanting to do the script wrapping for a while because it has extra uses but your problem piqued my interest and what I ended up implementing happens to solve most cases. The boss scene stuff is necessary because the script stuff alone can't handle scripts that are loaded through boss scenes, which does not expose the script IDs themselves and you have to do some silly messaging between plural and single.

If you're interested I could touch it up and post what I have, but you would have to commit to using the API in your scripts; it isn't incredibly intrusive but it would be a change.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on January 31, 2018, 12:07:26 AM
How could I re-create Marisa's nonspells?
I'm talking about the pentagon around her and the pattern.

Edit:
My overlay keeps appearing even when the spell is over
My BG script (https://pastebin.com/XkC9wnpu) is here for everyone to see
[attach=1]
[attach=2]
[attach=3]
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on January 31, 2018, 12:44:51 AM
If you're interested I could touch it up and post what I have, but you would have to commit to using the API in your scripts; it isn't incredibly intrusive but it would be a change.
If it works when running individual singles, I wouldn't mind having a look at least.

Oh, and my fps counter is still locked at 60. I know this isn't much to go on, but I have no idea where to start looking for the problems. I've noticed two different issues, which I can only hope are related:
-FPS counter is displayed in menu. Which system script is most likely to be causing this? I commented out the line calling TCurrentFps in script/default_system/Default_System.txt, so it shouldn't be that one, but I'm not sure where else it could be since it shows up before even selecting a script.
-GetCurrentFps() always returns 60. What the heck? How does that even happen? It's definitely returning 60 every time, I've tested it by writing the output directly to the log once per frame after creating 10,000 bullets. I would definitely get an error message if there was something like function GetCurrentFps{return 60;} tucked away somewhere, right? ...What the heck?!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 31, 2018, 01:37:05 AM
If it works when running individual singles
Yeah nope ;P
You aren't going to be able to do that. You can definitely get the list of files in the directory but unless you make a folder structure that's just one script per folder (lmao) there's no way to disambiguate. You need some sort of access to whatever is getting the script to run, and because you can't get access to the default plural script you can't even fiddle around with the defaults to get it to work.

And yeah you can't redefine functions. I'm not really sure what's up there; does it happen with all scripts? Does it happen with a fresh DNH copy? Different computer, if you have access to one? There has to be a difference somewhere.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on January 31, 2018, 09:49:17 AM
My overlay keeps appearing even when the spell is over
My BG script (https://pastebin.com/XkC9wnpu) is here for everyone to see
This is insufficient to judge what you're doing. Needs the full script. Currently all I can assume is you're not cleaning up/deleting your objects when the script ends.

Unrelated to your question but out of curiosity: What script am I looking at? Sort of "system" script or something? Which decides to load/unload the BG depending on whether it is a spell card or not?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 31, 2018, 07:14:51 PM
Sort of, they probably just run the script from the plural.


The issue is just that you don't stop/delete the backgrounds when they should be inactive. Check for bSpell within the background tasks and either delete the backgrounds and end the task, or otherwise make them invisible, or something. Right now there's no reason they shouldn't stay visible.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on February 01, 2018, 01:02:48 AM
I finally got it working now :D
The problem that the bg was laying upon other and since my moon had(need) a render priority higher than the rest it was overlaying in the non spell
This (https://pastebin.com/bmFvnnSU) is what I have to put to make it work
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 01, 2018, 12:17:16 PM
Yea so basically hiding it with w/e useful function is present. Some set the Alpha to 0. Some make it visible/invisible using that function and some move it even outside the visible game field.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jean Fox on February 03, 2018, 05:01:26 PM
Good day.
May I, kind of, ask a simple question? Is it possible to earn money by creating own projects on Danmakufu (using my own sprites, music, ect.). In generall, entirely unique project, but just using Danmakufu engine to create it. If no, is there any evidence of that?
Thanks in advance.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 03, 2018, 05:14:10 PM
Good day.
May I, kind of, ask a simple question? Is it possible to earn money by creating own projects on Danmakufu (using my own sprites, music, ect.). In generall, entirely unique project, but just using Danmakufu engine to create it. If no, is there any evidence of that?
Thanks in advance.

It is perfectly fine to sell games made with Danmakufu. However, the precedents have tended to only sell the games to recoup the convention fees, printing costs, and other costs associated with game production and not selling directly for profit.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on February 04, 2018, 10:34:59 AM
Can someone provide me with an example of how to implement History for spell cards? I've been trying to do it with Common data, but I just end up failing, the numbers are always incorrect and don't differ depending on the spell name.

Also, lately I returned to one of my latest issues
So, I want to reveal parts of background only in certain places and shapes, kinda like Doremy's occult attack in AoCF (http://tinypic.com/r/33m9b2d/9), how do I do it? I tried using render targets, but it's too complicated and difficult to use without a tutorial.
The only progress I had is that I could change the scale of the mask, but after it reaches the certain point, it just copies itself(something you would see if you put SourceRect of the sprite to 512 when it's original size is 256). So, I would really appreciate the help on this topic, since I don't know anything about HLSL.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 04, 2018, 04:05:57 PM
Can someone provide me with an example of how to implement History for spell cards? I've been trying to do it with Common data, but I just end up failing, the numbers are always incorrect and don't differ depending on the spell name.

How are you currently handling spell card attempt/capture history? Naturally, you will want to distinguish between each spell, so I assume you are trying some kind of standardized unique ID system with your Area Common Data.

The way I currently do it is as follows:
1. In @Initialize, call your cutin library with a unique ID for the spell card. For example, Spell # 125 uses the following:
CutIn(objBoss, "GEN", "Prob. S. \"Hypergeometric Waltz of the Forgotten Kitten (X)\"", 125, BossCutIn, 0, 1, 384, 384);
Where 125 is the unique spell ID.

In my Cutin library (based off of GTBot's), I do the following:
Code: [Select]
task CutIn(EnemyObject, CutType, CutSpellName, SpellID, CutSpellImage, CutX1, CutY1, CutX2, CutY2){
    yield;
    let SpellDataAttempt = IntToString(SpellID) ~ GetPlayerID ~ "Attempt"; //name of commondata
    let SpellDataGet = IntToString(SpellID) ~ GetPlayerID ~ "Get"; //name of commondata
    let SpellValueAttempt = GetAreaCommonData("SpellFunctions", SpellDataAttempt, 0);
    let SpellValueGet = GetAreaCommonData("SpellFunctions", SpellDataGet, 0);

    //misc code

    if(IsReplay == false){
        SpellValueAttempt++;
        SetAreaCommonData("SpellFunctions", SpellDataAttempt, SpellValueAttempt);
        SetAreaCommonData("SpellFunctions", SpellDataGet, SpellValueGet);
        SaveCommonDataAreaA1("SpellFunctions");
    }

    //etc.
}
By using a unique spell ID for each Single, I end up with unique common data names depending on the player, the spell ID, and whether it's attempt or capture.

Now, you mentioned earlier that 'the numbers are always incorrect and don't differ depending on the spell name'

In your current setup, I assume that you are either not passing some kind of unique ID or are passing the same spell name for multiple difficulties. Of course, without seeing your setup I can't provide a concrete answer, but I hope my example above is of use.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 04, 2018, 05:28:53 PM
AreaCommonData is the key here indeed. Here are a few snippets from my game.


I save all data for spell cards in a AreaCommonData with the following structure. As you can see I keep separate tracking for Stage game play and Spell Practise.
Code: [Select]
// Spell practise core. Array for the spell cards to track value
// Structure [ state, captureStage, historyStage, capturePrac, historyPrac, scoreBorder, scoreMagic, scoreReimu, scoreYukari, scoreMarisa, scoreAlice ]
// State 0 = unseen/disabled. 1 = Seen. 2 = Captured.
// Number of captures and tries is as they are.

// 01 spell cards
SetAreaCommonData("core","pierre01hard",[0,0,0,0,0,0,0,0,0,0,0]);

I personally utilize the EVENT system of Danmakufu to detect a spell card start or capturing a spell card. All my spell cards utilize the EVENT section using custom user event:
Code: [Select]
@Event {
alternative(GetEventType())
case(EV_USER+9999) {
SetCommonData("spellcardID","pierre01hard");
}
}
pierre01hard is a unique value I have given for this spell card. It basically means "Pierre boss" - "Spell card #01" - "Hard mode"

This is inside my "system" script which is launched when the game starts and keeps running in the background. It listens to the default Danmakufu Events.
Code: [Select]
@Event {
case(EV_START_BOSS_SPELL) {
updateCardHistory();
}

case(EV_GAIN_SPELL) {
updateCardCapture();
}
}

The updateCardHistory and updateCardCapture are functions I wrote myself. It looks roughly like this:
Code: [Select]
task updateCardHistory() {
let spellScriptID = GetCommonData("spellScriptID", 0);
NotifyEvent(spellScriptID, EV_USER+9999, 0);
getResultCard = GetCommonData("spellcardID", "NULL");
let getCommonSpellCardData = [];
getCommonSpellCardData = GetAreaCommonData("core", getResultCard, [0,0,0,0,0,0,0,0,0,0,0]);

// Do stuff with the values and save it back to the AreaCommonData
}
History value is updated when the spell begins and the capture value is updated when the card is obviously captured. It is a bit code-duplication (ugly), but hey it works.

The flow would be:
- System script is launched and running + listening to events
- System script triggers event on spell card start and gain
- Update function is called which calls the EVENT from the Spell Card script
- Spell Card uniqueID is retrieved and stored
- Values are modified as pleased
- Modified values are saved back

Hope Sparen's and my method gives you some thing to work with.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on February 04, 2018, 06:21:39 PM
And yeah you can't redefine functions. I'm not really sure what's up there; does it happen with all scripts? Does it happen with a fresh DNH copy? Different computer, if you have access to one? There has to be a difference somewhere.

I just checked running a completely independent package and it's still locked at 60. I... have no idea what's causing this, but it isn't just in Danmakufu's directory.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 05, 2018, 06:29:42 AM
The only progress I had is that I could change the scale of the mask, but after it reaches the certain point, it just copies itself(something you would see if you put SourceRect of the sprite to 512 when it's original size is 256). So, I would really appreciate the help on this topic, since I don't know anything about HLSL.
Sorry about that, did forget. Here's a thing I wrote to easily handle stuff like masks, along with an example to showcase.

https://gist.github.com/drakeirving/6694f73f5cb5cdb981a09e310e798250

Using a Shader object by itself and trying to apply it to a texture is not very useful for this kind of work for various reasons. You basically don't need to touch the provided HLSL. What you've been missing is that you need to use render targets to render what you want as a texture and then use that as the texture that the shader uses as a base. The shader then interacts with whatever layers you specify. This way you can handle masking multiple things at the same time as well as changing it over time instead of keeping it a static texture. The code I have written is much more than you need for a minimal working example, though.

In the example, I have an image of a white pixel I use for a canvas, and a 256x256 image of a white circle on black background. I stretch the white pixel to 1024x512 (the render target size), and then repeatedly add copies of the circle texture with subtract blending. So the render target becomes a texture that is mostly white with a bunch of random black circles. Meanwhile, some background is drawn on layers 26 to 28. The Shader object applies the masking shader technique, using the render target as the applied texture, to the layers 26 to 28, which results in the background appearing as though there are holes in it that scroll across the screen.

EDIT: Made some massive improvements to previous code for generalizability, and changed the example to be close to what's being requested.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on February 05, 2018, 02:22:36 PM
Thanks everyone for the help. The history is now working, the way I was passing the ID for the spell was completely wrong, so now it's solved. Also, what are CutIns? Even thought I've heard of them, I don't know what they are.

As for the shaders, now I kinda get how it works, though there are parts that I still don't understand. For instance, the most troublesome part is that the shader cuts off a bit of bottom and right parts of the background, as if it's left top corner was placed at [0,0] coordinates of the screen, and I can't change that at all, is there any way to do so?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 05, 2018, 06:30:02 PM
Also, what are CutIns? Even thought I've heard of them, I don't know what they are.

See gtbot's video:
https://www.youtube.com/watch?v=6o3X5QWzDus
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 05, 2018, 09:42:20 PM
As for the shaders, now I kinda get how it works, though there are parts that I still don't understand. For instance, the most troublesome part is that the shader cuts off a bit of bottom and right parts of the background, as if it's left top corner was placed at [0,0] coordinates of the screen, and I can't change that at all, is there any way to do so?
They are placed at (0,0) firstly because when drawing to a render target, you are literally drawing a new 1024x512 texture so of course the top-left is (0,0), and secondly because past a certain drawing layer the origin is set to (0,0) relative to the window rather than (32,16) like with the STG frame (this applies to everything, it isn't a render target or shader thing).

So I'm guessing that the reason it's clipping for you is because you only draw 384x448 on the upper background layer. The bottom one looks sufficiently sized. You could also just move it to (32, 16) but really just make it bigger.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on February 06, 2018, 01:32:23 AM
I'm just starting to mess with stage scripts, and there's significant lag when starting a plural (even if it was already loaded), more depending on the number of singles. I haven't noticed this in other people's stage scripts, so presumably there's some way around it.

I've tried a little bit to figure out how to add more singles to an already-running plural, in order to just load the first single to begin with and load the rest while that one is going. Is that a reasonable way to go about this?

In the meantime, I'm looking at all the random crap I'm #including in every single (from an index file) and wondering how much of the lag is caused by that. My guess is most of it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on February 06, 2018, 02:47:40 AM
IIRC, you can fix the lag on starting a script by handling the loading in the @Loading of the "outside" script. The lag is still there, but its all front-loaded towards the very beginning of the script, which is fine.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on February 06, 2018, 03:41:40 PM
They are placed at (0,0) firstly because when drawing to a render target, you are literally drawing a new 1024x512 texture so of course the top-left is (0,0), and secondly because past a certain drawing layer the origin is set to (0,0) relative to the window rather than (32,16) like with the STG frame (this applies to everything, it isn't a render target or shader thing).

So I'm guessing that the reason it's clipping for you is because you only draw 384x448 on the upper background layer. The bottom one looks sufficiently sized. You could also just move it to (32, 16) but really just make it bigger.
I tried changing scales and positions of litteraly everything, but it still clips, also tried changing the white circle picture a little bit (the circle remains the same size, but there's more black background and it's 512x512), but that didn't affect anything. I may be not noticing something really obvious, so please be patient.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 06, 2018, 06:11:10 PM
Ooook this is my bad for forgetting to include something.

Like I said earlier, render targets are 1024x512 in size, probably so it's the closest power of 2 to the screen size, which is 640x480. In the HLSL code, by default at the top it declares constants SCREEN_WIDTH and SCREEN_HEIGHT to 640x480. However the reason for this is just because the texture the sample script uses for its mask is 640x480. In fact it's commented "screen size (mask texture size)" in Japanese. So what's happening is that when it gets to the pixel sampling code, it does In.vPos.x/SCREEN_WIDTH to get texture coordinates (which are ratios, from 0 to 1), so e.g. it would try to get texture x-coordinate 1024/640 = 1.6, which isn't valid. It will just clip after it reaches (640,480), and that result is of course squashed, ending up at (640/1024)*640 by (480/512)*480, or 400x450. You can actually notice that your circle isn't actually circular either; this is because the divisions aren't equal ratios: 480/512 > 640/1024.

The solution is simple, just change the constants in the HLSL to 1024 and 512. I also rename them to RENDER_WIDTH/HEIGHT instead for clarity.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on February 06, 2018, 07:04:19 PM
Ooook this is my bad for forgetting to include something.

Like I said earlier, render targets are 1024x512 in size, probably so it's the closest power of 2 to the screen size, which is 640x480. In the HLSL code, by default at the top it declares constants SCREEN_WIDTH and SCREEN_HEIGHT to 640x480. However the reason for this is just because the texture the sample script uses for its mask is 640x480. In fact it's commented "screen size (mask texture size)" in Japanese. So what's happening is that when it gets to the pixel sampling code, it does In.vPos.x/SCREEN_WIDTH to get texture coordinates (which are ratios, from 0 to 1), so e.g. it would try to get texture x-coordinate 1024/640 = 1.6, which isn't valid. It will just clip after it reaches (640,480), and that result is of course squashed, ending up at (640/1024)*640 by (480/512)*480, or 400x450. You can actually notice that your circle isn't actually circular either; this is because the divisions aren't equal ratios: 480/512 > 640/1024.

The solution is simple, just change the constants in the HLSL to 1024 and 512. I also rename them to RENDER_WIDTH/HEIGHT instead for clarity.
Thanks, that's exactly what I need, now the struggle is finaly over. Also, is there any tutorials on render targets, etc.? I didn't understand some parts of your code, and that may be useful for me in the future.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 07, 2018, 05:52:11 AM
Render targets are sort of virtual canvases that you can draw things on. Rather than drawing something on the game window, you draw it onto the virtual space. Then you can use the render target itself as a texture for further work, just as though it was a texture you were loading from a file. If you test out how they work, and use the SaveRenderedTextureA1 function, you should be able to see what's happening.

You can draw onto a render target using either RenderToTextureA1, which takes a specified range of drawing layers and draws them onto the render target, or RenderToTextureB1, which draws specific objects onto the target. Both of these functions also have a "clear" argument, which if true will wipe whatever's currently on the render target. If you don't, whatever is on the render target will persist, even going into further frames. This is why in the code I wrote, each frame I use (i==0) to evaluate to true only when processing the first object to be drawn, because I want to clear what was drawn on the previous frame, but keep drawing the other objects without clearing. Additionally, I use Obj_SetVisible to draw the objects onto the render texture, but make them invisible afterward so that they aren't also drawn normally to the game window.

For a simple render target example, you can do something like

Code: [Select]
let obj1 = ObjPrim_Create(OBJ_SPRITE_2D);
// set up and position obj1
let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
// set up and position obj2
let obj3 = ObjPrim_Create(OBJ_SPRITE_2D);
// set up and position obj3

CreateRenderTarget("example_texture");
RenderToTextureB1("example_texture", obj1, false); Obj_Delete(obj1);
RenderToTextureB1("example_texture", obj2, false); Obj_Delete(obj2);
RenderToTextureB1("example_texture", obj3, false); Obj_Delete(obj3);
// "example_texture" now has three objects drawn on it, despite the objects being deleted now

let obj4 = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj4, "example_texture");     // use the render target as texture
ObjSprite2D_SetSourceRect(obj4, 0, 0, 256, 256); // for example
ObjSprite2D_SetDestRect(obj4, 0, 0, 256, 256);
ObjRender_SetPosition(obj4, 192, 224);
// spin it
let t = 0;
loop{
  ObjRender_SetAngleZ(obj4, t);
  t = (t+3) % 360;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on February 08, 2018, 02:58:21 AM
I've suddenly got a bunch of free time and thought to at least make something in Danmakufu, so I settled on a Mai and Satono fight.
That said, I've no idea how to go about spawning two bosses onscreen, since Danmakufu only allows one boss to be registered.
So, uh... how can I go about doing that?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 08, 2018, 04:17:45 AM
You can use a regular enemy for the second boss, and either have "shared life" by adding an extra ObjEnemy_SetIntersectionCircleToShot on the second boss coordinates, or have the two enemies have their own life counters as normal and add extra logic to your life checks to handle the cases where one enemy runs out of life before the other. Boss enemies are still just Enemy objects; creating them as OBJ_ENEMY_BOSS just connects them to the Boss Scene object and doesn't actually do a huge amount.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on February 09, 2018, 03:44:52 PM
How do I make the player stop moving in a Sakuya-like timestop?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 09, 2018, 04:54:15 PM
How do I make the player stop moving in a Sakuya-like timestop?
There is no function to disable player control looking at the wiki. Never implemented this myself, but brainstorming here are few things you can try to experiment with:
- Drop player movement to 0 and restore it post time stop
- Lock and force X Y location of player and release post time stop
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 09, 2018, 05:08:36 PM
There is no function to disable player control looking at the wiki. Never implemented this myself, but brainstorming here are few things you can try to experiment with:
- Drop player movement to 0 and restore it post time stop
- Lock and force X Y location of player and release post time stop

If you do the former, make sure to restore player movement in your Single Finalize task if the boss dies during the time stop. In the Artifact 3 contest, some people neglected to restore player movement, resulting in an inability to continue gameplay until the next time stop.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on February 12, 2018, 11:17:43 PM
How can I fix the cutin, the lifebar and the timer?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 13, 2018, 01:19:55 AM
How can I fix the cutin, the lifebar and the timer?

What are you trying to do, what are you currently doing, and what code are you using?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 13, 2018, 01:30:39 AM
If you want to be using the whole screen width, then realize that whatever code you're using from other people isn't necessarily going to be adjusted for that. You need to get in there and change the positions or lengths as needed.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: PyuDi on February 13, 2018, 10:09:21 AM
How can I make the danmakufu .exe file that runs only specified script? (As in touhou FFF - th_dnh_fff.exe)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 13, 2018, 10:20:30 AM
The th_dnh.def file is a config file that lets you run a specific package script. You must actually use a package script.
Code: [Select]
// Example th_dnh.def
package.script.main = script/path/to/package.dnh
window.title = some title
screen.width = 640
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on February 14, 2018, 12:01:06 AM
I'm trying to do the following:
Code: [Select]
if(PlayerDying){
    dont;
}
That is, interrupt the player's rebirth frames, like if they'd counter-bombed.

What actually stops the player dying when they counter-bomb?

Also, I'm trying to do something weird where the player controls another thing and the actual player object stays in place. I've got the controlling it part handled, but I'm running into difficulties with giving it a hitbox, since ObjPlayer_AddIntersectionCircleA1 is meant to be set once rather than each frame.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on February 14, 2018, 12:01:34 AM
What are you trying to do, what are you currently doing, and what code are you using?
I'm using gtBot cutin and the default system lifebar
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on February 14, 2018, 04:04:51 AM
I'm trying to do the following:
Code: [Select]
if(PlayerDying){
    dont;
}
That is, interrupt the player's rebirth frames, like if they'd counter-bombed.

What actually stops the player dying when they counter-bomb?
I have no idea. It seems like Danmakufu itself just seems to be hard-coded to stop the death process if a bomb is initiated (this can also be done with the CallSpell function). This basically means that forcing the player to bomb upon getting hit is the only way to keep them alive. Fortunately, all the system needs is to recognize that a bomb has been activated. It doesn't have to actually do anything. In order for it to accept it as a valid bomb, I believe you simply need to have to call SetScriptResult(true); in the EV_REQUEST_SPELL block to signal to the system that the bomb has been activated. Following that, I think you just need to call Obj_Delete(GetSpellManageObject); to make sure the bomb ends as soon as it activates so it's doesn't do anything but save you from death. You may need to add some invincibility frames though, just to make sure the player isn't immediately hit again.

Also, I'm trying to do something weird where the player controls another thing and the actual player object stays in place. I've got the controlling it part handled, but I'm running into difficulties with giving it a hitbox, since ObjPlayer_AddIntersectionCircleA1 is meant to be set once rather than each frame.
It looks like you can use ObjPlayer_AddIntersectionCircleA1 to add any number of player hitboxes, but the location of them seems to be forced to be relative to the player object's location and not independently controllable. You might have to do something hacky to make that work, like make the player's true object location be different from where it appears to be or to manually code an independent hitbox yourself.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 14, 2018, 07:32:34 AM
If it's relative to the player location you can set it to (-player_x + hitbox_x, -player_y + hitbox_y) for an absolute position, if that's an issue. You can also start with ObjPlayer_ClearIntersection(player) followed by the hitbox additions to set them every frame, even though that's pretty janky.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on February 14, 2018, 06:45:13 PM
If it's relative to the player location you can set it to (-player_x + hitbox_x, -player_y + hitbox_y) for an absolute position, if that's an issue. You can also start with ObjPlayer_ClearIntersection(player) followed by the hitbox additions to set them every frame, even though that's pretty janky.
I tried it like this already, but somehow the hitbox just stays on the player. The old one gets cleared and replaced with the new one (based on size), but it's still in the same place.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 16, 2018, 09:35:14 AM
I tested a very basic example and didn't have any problems, but when trying to implement this exactly I found what the problem here is. There is a bug when using ObjPlayer_AddIntersectionCircleA1 then ObjPlayer_ClearIntersection followed by another AddIntersection. No matter how many hitboxes you add initially, once you clear them, if you use AddIntersection again it will "ignore" the new hitbox you specify. Instead, it will recreate each hitbox that was previously set, one at a time. Following this, it will create the hitboxes specified after the clear, in order, even if it was "ignored" at first to put in one of the previous ones. Additionally, I found that if you use AddIntersectionCircleA2 to set only a grazebox, clear hitboxes, then add a hitbox, it will recreate the grazebox as a hitbox instead (with the hitbox size of the newly specified one), and this is where it gets really spicy.

I'd like to illustrate this better soon because I'm basically trying to reverse-engineer the behaviour through testing, but I don't quite yet have enough testing info to say what exactly is going on internally. The grazebox stuff is potentially useful information but gets really complicated once you start poking it.


But long story short you won't be able to do the shikigami-like behaviour this way. What I would suggest to do instead is to not use the Player object to draw the player sprite, but use a separate Sprite object that just follows the player position. But only conditionally, instead having the sprite stay put when the shikigami effect happens (and switching to another sprite on top of the player). No hitbox shenanigans.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on February 17, 2018, 01:44:52 AM
Is there a collection of useful functions in one txt/dnh file?
For me, useful funcs is:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: PyuDi on February 17, 2018, 03:39:55 AM
Is there a way to create a bullet polygons (square, pentagon, ?etc) and stars?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 17, 2018, 04:13:42 AM
echo, echo, echo, echo, echo, echo

https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1375135.html#msg1375135
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 17, 2018, 03:07:24 PM
echo, echo, echo, echo, echo, echo

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

I swear this is the 5th? 6th? time I've seen it requested lol. Might as well just slap it on the Danmakufu Wiki under tutorials and hope people go there first?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 18, 2018, 04:01:37 AM
The thing is that one shape is pretty easy to make and can have multiple ways to go about it, but as soon as people want general purpose stuff and both being able to shoot shapes as a large object and also expand shapes outwards, you need a more appropriate solution. I can't really make it a "tutorial" per se because the math for the general case is complicated enough that it isn't very useful to even explain.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 18, 2018, 08:15:59 AM
Is there a collection of useful functions in one txt/dnh file?
There isn't. You will need to make your own or check out the code snippet thread where people post these. Some have been posted even in this thread.

I swear this is the 5th? 6th? time I've seen it requested lol. Might as well just slap it on the Danmakufu Wiki under tutorials and hope people go there first?
Sounds like a good idea. A separate wiki page posting code snippets + a screenshot of the result.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gregory on February 19, 2018, 02:06:08 PM
Is there a discord group specific in danmakufu ? since I saw python's video there's a secret santa's scripts so I'm really curious
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tom on February 19, 2018, 07:49:42 PM
Does anyone know the bullet cap in danmakufu?  Or other caps like sprite/object/enemy etc
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 20, 2018, 04:38:19 AM
Is there a discord group specific in danmakufu ? since I saw python's video there's a secret santa's scripts so I'm really curious

There are a few Danmakufu-specific groups (such as the Land of Codes and Apertures) and a number of servers with danmaku channels (such as the main Len'en Discord Server)

Does anyone know the bullet cap in danmakufu?  Or other caps like sprite/object/enemy etc

There may be a hard bullet cap but if there is, you're probably lagging down to single digit FPS values anyways. There is no limit on graphical objects such as sprites. As for enemies, there can be only one boss enemy on screen at a given time, but you can have any number of standard enemies.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gregory on February 20, 2018, 05:19:42 AM
There are a few Danmakufu-specific groups (such as the Land of Codes and Apertures) and a number of servers with danmaku channels (such as the main Len'en Discord Server)

There may be a hard bullet cap but if there is, you're probably lagging down to single digit FPS values anyways. There is no limit on graphical objects such as sprites. As for enemies, there can be only one boss enemy on screen at a given time, but you can have any number of standard enemies.

Ah, I see. Then how can I apply/join the Discord group ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tom on February 20, 2018, 12:06:58 PM
There may be a hard bullet cap but if there is, you're probably lagging down to single digit FPS values anyways. There is no limit on graphical objects such as sprites. As for enemies, there can be only one boss enemy on screen at a given time, but you can have any number of standard enemies.
What is a generally accepted bullet limit that works well on low end PCs and is under what most scripts use? 1024?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 20, 2018, 01:43:44 PM
Please be aware that a lot of things can impact performance on low end PCs. Not just bullets. Effects, sounds, number of enemies, the number of tasks/loops running.

But it is a good thing to start with the bullets.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on February 20, 2018, 10:02:15 PM
Ah, I see. Then how can I apply/join the Discord group ?
I would like to join it too :D
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Trung0246 on February 21, 2018, 12:05:21 AM
I would like to join it too :D
3 of us !
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on March 03, 2018, 12:09:43 AM
How can I make multi phased Nonspells and Spells?
and
Can I put two shotsheets in one plural script?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on March 03, 2018, 03:57:30 AM
How can I make multi phased Nonspells and Spells?
and
Can I put two shotsheets in one plural script?

Multi-phased: Have multiple tasks. Not all tasks need to run while the boss is alive either. You can have a task that does one thing for x frames, then does another thing for y frames, etc.

Shotsheets: Yes. However, the numbers used for the constants must be different between the two. Otherwise the second one you load will override the numbers for the first shot sheet.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on March 03, 2018, 11:58:18 PM
Multi-phased: Have multiple tasks. Not all tasks need to run while the boss is alive either. You can have a task that does one thing for x frames, then does another thing for y frames, etc.
Can you give an example, because I can't understand clearly.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on March 04, 2018, 12:43:04 AM
Can you give an example, because I can't understand clearly.
Code: [Select]
task mainTask {
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
        //Phase 1
        loop(6) {
            ascent(i in 0..36) {
                ascent(j in 0..4) {
                    CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2 + j/4, GetAngleToPlayer(objBoss) + 360/36*i, 4, 5);
                }
            }
            wait(20);
        }
        wait(120);
        //Phase 2
        let randangle = rand(0, 360);
        ascent(i in 0..120) {
            loop(4) {
                CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 1 + i/30, randangle, 6, 5);
                randangle += 360/4;
            }
            randangle += 7.1 + i/30;
            wait(2);
        }
        wait(120);
    }
}

In this case, Phase 1 is designated under "//Phase 1" while Phase 2 is designated under "//Phase 2". You could alternatively use tasks.

With tasks the contents of each phase would be in a task, and you would wait the appropriate amount of time in the main task. Like so:

Code: [Select]
task mainTask {
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
        //Phase 1
        taskA;
        wait(120); //time for taskA to run
        wait(120);
        //Phase 2
        taskB;
        wait(240); //time for taskB to run
        wait(120);
    }
}

task taskA {
    loop(6) {
        ascent(i in 0..36) {
            ascent(j in 0..4) {
                CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2 + j/4, GetAngleToPlayer(objBoss) + 360/36*i, 4, 5);
            }
        }
        wait(20);
    }
}

task taskB {
    let randangle = rand(0, 360);
    ascent(i in 0..120) {
        loop(4) {
            CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 1 + i/30, randangle, 6, 5);
            randangle += 360/4;
        }
        randangle += 7.1 + i/30;
        wait(2);
    }
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on March 04, 2018, 01:46:34 AM
If you want to make the phases of the attack move onwards when bosshp reaches a certain threshold, then just put each phase in a loop while the bosses' health is above a certain threshold.
 
Working from Sparen's earlier example:

Code: [Select]
task mainTask {
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
//Phase 1 last until the boss's life gets below 3000
        while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 3000) {
            loop(6) {
                ascent(i in 0..36) {
                    ascent(j in 0..4) {
                        CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2 + j/4, GetAngleToPlayer(objBoss) + 360/36*i, 4, 5);
                    }
                }
                wait(20);
            }
}
        wait(120);
        //Phase 2
       //If there were a third phase when the boss got to, say, 1500 health, you'd just put a similar while loop around Phase 2 as well
        let randangle = rand(0, 360);
        ascent(i in 0..120) {
            loop(4) {
                CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 1 + i/30, randangle, 6, 5);
                randangle += 360/4;
            }
            randangle += 7.1 + i/30;
            wait(2);
        }
        wait(120);
    }
}

Its also usually a good idea to have the pattern skip straight to the last phase if the player takes too long to clear it, like how Boundary of Life and Death works if you try to time it out. That can be accomplished by just adding a time condition to each phase's while loop.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on March 04, 2018, 02:27:37 PM
Thank you Sparen and Arcvasti, you really helped me! :D
I really like the tasking style (it's simple and looks organized):
Code: [Select]
task mainTask {
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
        //Phase 1
        taskA;
        wait(120); //time for taskA to run
        wait(120);
        //Phase 2
        taskB;
        wait(240); //time for taskB to run
        wait(120);
    }
}
Just to note, I already knew about the division by the boss health, I made "First and Nameless Danmaku" with my old Mamizou script (the first) --- but thanks anyways ;)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 05, 2018, 07:06:32 AM
Note that if you make taskA and taskB functions instead of tasks you don't have to repeat your code and manually wait, because then waiting in the function waits the parent task instead. This also works fine with the life method.
Here's also an addition you might want for checking boss life in the middle of patterns rather than just when the loop restarts.

Code: [Select]
task mainTask(){
    phaseA(3000);
    wait(120);
    phaseB(0);
    wait(120);
}

function phaseA(life_t){
    while(check_life(life_t)){
        loop(60){
            // shoot bullet
            if(!wait_check_life(3, life_t)){ return; }
        }
        if(!wait_check_life(120, life_t)){ return; }
    }
}

function phaseB(life_t){
    while(check_life(life_t)) {
        // do stuff
        if(!wait_check_life(120, life_t)){ return; }
        // do stuff
        if(!wait_check_life(120, life_t)){ return; }
    }
}

function check_life(life_t){
    return (ObjEnemy_GetInfo(objBoss, INFO_LIFE) > life_t);
}

function wait_check_life(n, life_t){
    loop(n){
        if(check_life(life_t)){ yield; }
        else{ return false; }
    }
    return true;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on March 10, 2018, 12:42:02 AM
What is wrong with this (its repeating but it isn't ending the task)?
https://pastebin.com/5n90wMCJ
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on March 10, 2018, 02:06:26 AM
I can think of two reasons why, off the top of my head:

1: The balls task has what seems to be an infinite loop inside it. This is probably the immediate culprit.
2: The condition for ending the while loop in timeline won't trigger if the boss's health goes below zero. I can't remember if that's possible or not, but it seems plausible.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 10, 2018, 01:26:29 PM
That's right. Each call of ball looks like it's meant to shoot a new pattern, not supposed to be a running loop, so get rid of the outer loop. I would also use life <= 0 instead of life != 0 for semantic purposes, even if it's effectively the same.

Also, I would recommend putting the if(ObjEnemy_GetInfo(objBoss, INFO_LIFE) <= 0){return;} in the timeline loop before each pattern call instead, that way timeline can end immediately instead of having to wait a couple seconds to be over.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 11, 2018, 04:38:50 AM
How do item scripts work? I haven't been able to find a good resource. More specifically, how do I change the graphics used for items? The defaults are... ugly. ...Where are the default item graphics even stored, for that matter?

I'm currently digging around in TresserT's Reisen from RaNGE 14 (the first I tried that had non-default item graphics), but I can't find... I just found it, he skipped using items entirely and made his own out of primitives. Is changing the item graphics really so hard as to drive someone to do that?

Random question: Where do I change nicknames on here? I don't see it in forum profile with the rest.

Another question: How big is the potential performance difference between if statements and alternatives in Danmakufu? I'm finally getting around to reworking my UI, and I keep trying to optimize everything. And one of the things I've been trying to avoid is unnecessary branching, so I've been using alternatives instead of ifs, since they do fancy shit with tables to be faster. But now I have it stuck in my head that alternative==faster and I keep using it even when there's only one condition I want to check.
Worse, I keep doing stuff like
Code: [Select]
n = i-whole;
alternative( floor(n/((|n|)+1)) - floor(-n/((|-n|)+1)) ) //sign(n)
case(-1){ x = 5; }
case( 0){ x = pieces; }
case( 1){ x = 0; }
when I could very easily just go
Code: [Select]
if(i<whole){       x = 5; }
else if(i==whole){ x = pieces; }
else {             x = 0; }
and long story short I need someone to tell me to stop.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on March 11, 2018, 06:00:57 AM
The default item graphics are stored in th_dnh_ph3/resource/img. Changing that would probably be a poor plan unless you're distributing your own package script[Maybe even then?], since it'd also affect the item graphics for every other script. There's probably a better way to make item scripts work, but I sure don't know what it is.

re: Changing nicknames:

I think that this might be one of those forums where you have to PM an admin and they'll change your username for you[Assuming it isn't an awful awful username, of course]? Not really sure.


EDIT: Disregard above, I misread nickname as username. And also got that wrong.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 11, 2018, 05:53:32 PM
How do item scripts work? I haven't been able to find a good resource. More specifically, how do I change the graphics used for items? The defaults are... ugly. ...Where are the default item graphics even stored, for that matter?
You can't change the default item handling; they're probably just packaged right into the game. Rather, even if you could change the defaults it wouldn't be a good idea. Defining your own items instead is just the better course of action.

Here's a blurb (+linked blurb) that might be good enough:
https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1373257.html#msg1373257

Another question: How big is the potential performance difference between if statements and alternatives in Danmakufu?
If this were a compiled language there could be optimizations done with jump tables, depending on the context, the compiler, settings used, etc, but it also just as easily can compile to literally the same thing as if you used if statements. More than that though, this is an interpreted language running on an engine and such specific optimizations can't even be applied, it depends entirely on how the engine handles it. The difference between ifs and switches is extremely negligible, if it's even different at all here, and is greatly overwhelmed by like, everything else. There is no way that branching is going to impact performance in meaningful ways and I would recommend not focusing too hard on it because that is definitely not where your heaviest parts are going to be. I highly anticipate that the extra massaging you do to get the cases you want would end up outweighing any potential benefits, if they even exist.

Random question: Where do I change nicknames on here? I don't see it in forum profile with the rest.
Display names are changed in Account Settings. "Nicknames" are intentionally static and can only be changed by admins.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 11, 2018, 07:16:45 PM
Here's a blurb (+linked blurb) that might be good enough:
https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1373257.html#msg1373257
Thanks! Is there anything on what to put in the item data file? Or just point me at a script that uses it to dig through?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: VYCM on March 11, 2018, 08:13:54 PM
It works pretty similarly to shot data files and stuff. Here's what the beginning of an item data file could look like if, say, you want item 1 to be a point item and item 2 to be a power item:

Code: [Select]
#UserItemData

item_image = "./img/item.png"

//Point item
ItemData{
id = 1
rect = (208, 0, 224, 16)
out = (208, 16, 224, 32)
render = ALPHA
alpha = 255
}

//Power item
ItemData{
id = 2
rect = (192, 0, 208, 16)
out = (192, 16, 208, 32)
render = ALPHA
alpha = 255
}

item_image is the image containing the item graphics. rect is the image coordinates for the item. out is the image coordinates for the arrow that's displayed at the top of the playing field when the item flies above bounds. render and alpha are self-explanatory; you probably don't even need to put them in there but you can if you want/need. You might even be able to use some of the other properties you can define in the shot data file, but I haven't played around much with that.

For more items, just keep adding more of these with different IDs.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on March 11, 2018, 08:38:54 PM
Is there a way to check what kind of object an object is? Like, a task that checks if an object is a laser and does something different if it isn't.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on March 11, 2018, 09:21:25 PM
Is there a way to check what kind of object an object is? Like, a task that checks if an object is a laser and does something different if it isn't.

Yes, there is Obj_GetType (https://dmf.shrinemaiden.org/wiki/Object_Functions#Obj_GetType), which should be exactly what you're looking for.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 14, 2018, 01:07:53 AM
So I'm trying to implement continues, and the main difficulty I'm having is the part where the game actually... you know... continues. I assume what I need to do is start a script manually, rather than using the end scene script... Something more like how the pause script works?

I tried manually loading (both regular and in thread) and starting the end scene script from the main loop of the stage script and waiting for it to finish before deciding whether to close the stage scene, which froze the game. Mucked about with that for a while before concluding that I wasn't going to accomplish much fumbling around with no idea what I'm doing.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: SusiKette on March 14, 2018, 06:49:40 PM
My question is about shot sheet hitboxes. If I'm not mistaken, using collision = 2 creates a round hitbox with radius (not diameter) of 2. However, I once saw something like this collision = (3, 0, 0, 0). What are the rest of these optional(?) parameters? One other thing I've been wondering is how big is the default hitbox size if you don't use collision in shot data? One of Sparen's tutorials state " By default, the hitbox is a percentage of the bullet graphic (in a circle)", but doesn't state how much. Also, is there a way to get other hitbox shapes besides circles? Like rectangles and ellipses? If so, how does one define these? Best case scenario would be that I'd be able to create some sort of overlay that would visualize the hitbox for me when I'm actually making the bullet graphic.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 14, 2018, 10:59:58 PM
collision = (r, x, y) creates a hitbox of radius r positioned (x, y) from the bullet center.

After some testing, the formula for default hitbox radius given a bullet of size m*n is
Code: [Select]
max(3, floor((min(m, n) - 12) / 3))So it takes the smaller dimension (say n), then for n<21 all hitboxes are radius 3, and n>=21 it increases by 1 every 3 pixels.


If you need a truly rectangular hitbox you would have to code that manually, but typically this is not necessary. You can specify multiple hitboxes for a bullet, so if you e.g. have a large square bullet you can use circles to approximate the square. You can do this in different ways; many people might opt for just evenly spacing the whole way (example 1), but a more efficient way would be finding space-filling circles (example 2):

(https://i.imgur.com/dU6J5uD.png) (https://i.imgur.com/YlPjafL.png)

As for the last bit about displaying hitboxes, I made a thing to do this a while back:
https://gist.github.com/drakeirving/c4c12533fd7814d405e1
If you save an image of a white circle (example (https://i.imgur.com/4y349t6.png)) as eff_circle.png and run TDrawHitboxes() in your system script (or I guess anywhere works) you can toggle hitbox visibility by pressing the H key.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 15, 2018, 10:10:37 AM
So I'm trying to implement continues, and the main difficulty I'm having is the part where the game actually... you know... continues. I assume what I need to do is start a script manually, rather than using the end scene script... Something more like how the pause script works?

I tried manually loading (both regular and in thread) and starting the end scene script from the main loop of the stage script and waiting for it to finish before deciding whether to close the stage scene, which froze the game. Mucked about with that for a while before concluding that I wasn't going to accomplish much fumbling around with no idea what I'm doing.
Actually, implementing a continue system is way more complicated than this. First of all, you need to provide us more details about your current setup. What are you currently using? A regular set of scripts in a plural? Stage scripts? Package scripts?

Edit:
In the mean while I am trying to find the posts where we've discussed this topic before except cannot seem to find this yet.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: SusiKette on March 15, 2018, 11:34:45 AM
collision = (r, x, y) creates a hitbox of radius r positioned (x, y) from the bullet center.

After some testing, the formula for default hitbox radius given a bullet of size m*n is
Code: [Select]
max(3, floor((min(m, n) - 12) / 3))So it takes the smaller dimension (say n), then for n<21 all hitboxes are radius 3, and n>=21 it increases by 1 every 3 pixels.

As for the last bit about displaying hitboxes, I made a thing to do this a while back:
https://gist.github.com/drakeirving/c4c12533fd7814d405e1
If you save an image of a white circle (example (https://i.imgur.com/4y349t6.png)) as eff_circle.png and run TDrawHitboxes() in your system script (or I guess anywhere works) you can toggle hitbox visibility by pressing the H key.

Thanks :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on March 17, 2018, 01:36:58 PM
I need help for stopping time like Sakuya, is there a handy task/post here?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on March 17, 2018, 07:22:28 PM
Time stops need to set up by hand, there really isn't a way to do it with one simple task/function. Really, time stops are composed of three parts:
1: Stopping all the bullets
2: Stopping the player from moving
3: The boss does something interesting
4: Starting the bullets moving again

Stopping all the bullets is fairly easy: Get an array with all the bullets in it and then set their speeds/accelerations/angular velocities to zero. You also usually want to store the old values in the bullet using Obj_SetValue, so you can start them again afterwards.

Stopping the player is more difficult. You can stop them from moving by continously setting their location to where they were when the timestop started while the timestop lasts, but this doesn't look very pretty[The player can still jerk around]. The other way is by implementing an event in the player script that sets their focussed and unfocussed movement values to zero[Remember to restores them afterward!], which works best with a custom player script.

Step three is where you actually do interesting stuff. This depends on what you want to accomplish with your timestop. General advice: Make sure that any bullets fired in this stage also start out timestopped.

Starting the bullets again is just step one, but in reverse. Here's where storing their previous speed values becomes important.

None of this is very complex to implement, although you do have to account for some potentially hairy edge cases[What if a bullet is destroyed during the timestop, what if the timestop ends prematurely, what if the player dies during the timestop, etc]. Timestopping can be very messy if something does go wrong, so playtest it thoroughly.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 17, 2018, 11:34:58 PM
Actually, implementing a continue system is way more complicated than this. First of all, you need to provide us more details about your current setup. What are you currently using? A regular set of scripts in a plural? Stage scripts? Package scripts?
Oh, boy. Currently I'm up to stage scripts, but I intend to move to a package script at some point soon, since the intent is to make a full game (since I've found myself leading a group project this semester and nobody else had any ideas). If you need more detail, here (https://github.com/JonAjuhan/cs401Project/tree/master/th_dnh_ph3/script/_Dev)'s our github.

If the continue system will have to be reworked when I move to a package I'll probably try to do that first and then implement continues - though, I haven't had much luck finding examples for packages.

Oh, random question: Can you use SplitString to split on multiple delimiters? Like, "+" or "-"?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 18, 2018, 06:26:34 AM
Originally I thought not (and you could code it by hand) but after testing it splits on every character in the delimiter string. Nice.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on March 18, 2018, 09:26:51 PM
Is there a tutorial or handy post about Custom players?
I'm having some ideas for spells and shots that would be cool to have... :wat:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 18, 2018, 11:51:31 PM
Is there a tutorial or handy post about Custom players?
I'm having some ideas for spells and shots that would be cool to have... :wat:
It's fairly straightforward for the most part. I recommend starting off by modifying an existing player script - maybe look at several made by different people and pick whichever one whose structure seems the most intuitive to you.
Each player script does have its own shotsheet, which works basically the same as the usual ones but generally only has a few shot types. You can modify it the usual way, by adding shot graphics to the image and defining a shot type using them in the shotsheet.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on March 19, 2018, 01:52:25 AM
Is there a tutorial or handy post about Custom players?
I'm having some ideas for spells and shots that would be cool to have... :wat:

Helepolis did one here (https://www.youtube.com/watch?v=Dtn5EtPsJjc&index=9&list=PLsqimF6_OUHBNeOrp_k2t9bPk5Q6PsB_P). Its not finished[Might never be finished?]. There's also this old tutorial (https://www.shrinemaiden.org/forum/index.php?topic=210.0). This second one is for 0.12m, but I still found it pretty helpful.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: SusiKette on March 19, 2018, 08:52:50 AM
Are there any tutorials for making shaders? Mainly I want to try to make one that creates the background distortion around the boss, but I don't want to steal someone else's code and trying to make any sense out of the shader scripts is almost impossible without any documentation, since they differ from all the other scripts.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on March 19, 2018, 01:31:10 PM
Are there any tutorials for making shaders? Mainly I want to try to make one that creates the background distortion around the boss, but I don't want to steal someone else's code and trying to make any sense out of the shader scripts is almost impossible without any documentation, since they differ from all the other scripts.

https://msdn.microsoft.com/en-us/library/windows/desktop/bb509635(v=vs.85).aspx

I just googled this, so I can't be sure if Microsoft's official tutorial is worth anything. But just googling "HLSL tutorial" should probably bring up some decent guides.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on March 19, 2018, 11:11:30 PM
Does anyone know the cause for the get_center_x not defined error when trying to recreate spell cards using Sparens guide?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 20, 2018, 04:32:07 AM
That being said,
but I don't want to steal someone else's code
This is typically something not many people will have issue with, especially since I'm sure most people just copied stuff straight from the sample script that does this (SamplePS03_HLSL). The only thing you might even need to change from the sample script is adding color.a = 1; before setting Out.color = color. The main reason you don't see much documentation about shaders in the context of DNH is that most people don't use it for much.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 20, 2018, 03:57:35 PM
So my stage scripts are still freezing up for a while when they start a plural, despite loading the plural earlier. I just had the idea to start the plural immediately, and in the plural script load all the singles and then wait for common data or an event before starting them.

Is this a good idea, or a terrible one?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on March 21, 2018, 11:22:01 PM
Translate to danmakufu code plz:
Code: [Select]
while(TaskA_IsRunning and !TaskB_IsRunning){
shoot_that;
}
while(!TaskA_IsRunning and TaskB_IsRunning){
shoot_this;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 22, 2018, 12:09:39 AM
So my stage scripts are still freezing up for a while when they start a plural, despite loading the plural earlier. I just had the idea to start the plural immediately, and in the plural script load all the singles and then wait for common data or an event before starting them.

Is this a good idea, or a terrible one?
If this is about script compilation, you should wait both after compiling the plural and starting it from the stage, and waiting after setting up and compiling the boss scene before starting it.

Like you say, you could do this by waiting a bit before starting the plural, but waiting for a trigger to start the boss scene. This is what several games do (at least ido games and FFF), but I still don't think it's a super clean approach. Is there any discernible reason things don't load fast enough? If it's resources rather than script compilation doing this might not even fix the issue.

Translate to danmakufu code plz:
Why are you splitting it into tasks if you're only running one at a time?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 22, 2018, 06:44:04 AM
wait both after compiling the plural and starting it from the stage, and waiting after setting up and compiling the boss scene before starting it.
Run that by me again? Not 100% sure I'm parsing that right.
What I'm currently doing is:
Code: [Select]

Stage: Load plural; Start plural; other stuff; Notify plural; Wait for plural to close
Plural: Add singles to boss scene; Load boss scene in thread; Wait for event; Register boss scene; Wait for boss scene to end
Which seems to be working pretty well. It still hangs for a few moments, but not nearly as much as before.

I still don't think it's a super clean approach.
Is there a cleaner approach? How do you deal with it?

Is there any discernible reason things don't load fast enough? If it's resources rather than script compilation doing this might not even fix the issue.
I think the bulk of it is script compilation, and the remaining bit is resources. I would go through watching the log to make sure, but my computer just BSOD'd and I need to be getting to bed.

Translate to danmakufu code plz:
I'm not sure why you wouldn't just do it in the respective tasks, but:
Code: [Select]
let numA=0; let numB=0;
task TaskA{
    numA++;
    do_that;
    if(numB==0){ shoot_that; } //the sane way
    numA--;
}
task TaskB{
    numB++;
    do_this;
    if(numA==0){ shoot_this; } //the sane way
    numB--;
}
task TaskC{
    loop{
        if(numA>0 && numB==0){ shoot_that; }
        else if(numB>0){ shoot_this; }
        yield;
    }
}
You can't directly check if a task is running like that, so you'd need to keep track of it manually as above.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 22, 2018, 07:33:25 AM
The point is that you need to wait a bit between loading a script (which compiles it along with any included scripts) and actually starting it. When you say Load plural -> Start plural, you should have a short time between those to wait for it to compile or it'll block execution (causing the stall) until it's done. Meanwhile if you're loading the boss scene in your plural and then waiting until a trigger that's more than enough time so script compilation shouldn't be an issue when starting the boss scene.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 22, 2018, 02:41:41 PM
When you say Load plural -> Start plural, you should have a short time between those to wait for it to compile or it'll block execution (causing the stall) until it's done.
Oh, I see. Tried putting it in a task with a wait(600) and it definitely started faster, yeah.

Another question: Is there any way to collect only a specific item? There's CollectItemsByType and CollectItemsInCircle, but I don't see a way to filter both at once.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 22, 2018, 09:17:45 PM
You would probably deal with this in the item script, and you can use ObjItem_SetDefinedMovePatternA1(item, ITEM_MOVE_TOPLAYER) to autocollect an item.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 24, 2018, 07:12:28 AM
Does anyone know the cause for the get_center_x not defined error when trying to recreate spell cards using Sparens guide?
Insufficient information provided to help out. Wild question: Did you create such a function first?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on March 24, 2018, 01:28:28 PM
Does anyone know the cause for the get_center_x not defined error when trying to recreate spell cards using Sparens guide?

Which guide was it in (i.e. #23, etc)? I may have forgotten to manually inline the function in an example, or I may have forgotten to provide an appropriate function definition.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on March 25, 2018, 02:39:35 AM
Is there a tutorial for Dialogue?(Cutin or textbox type)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on March 25, 2018, 02:51:51 AM
Not really. Dialogue isn't difficult, per se, but it can be tedious aligning all the images and text objects properly. The part that I remember having the most trouble with was having the dialogue pause until you pressed "Z". Here's my implementation of it:

Code: [Select]
        let count = 0;
loop{
                count += 1;
if(GetVirtualKeyState(VK_SHOT) == KEY_PUSH || count >= 60*15){
break;
}
yield;
}

This will halt the task it is placed in until either fifteen seconds pass or the player presses "Z". This should be used as a break in between displaying each segment of dialogue. Actually displaying the dialogue shouldn't be much different then messing with the HUD or the background.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 25, 2018, 03:11:26 AM
similarly

Code: [Select]
function wait_for_ok(n){
  if(n > 0){
    loop(n){
      if(GetVirtualKeyState(VK_OK) == KEY_PUSH){ break; }
      yield;
    }
  }else{
    while(GetVirtualKeyState(VK_OK) != KEY_PUSH){ yield; }
  }
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 25, 2018, 03:29:38 AM
The part that I remember having the most trouble with was having the dialogue pause until you pressed "Z".
Here's a slightly better implementation if some players are still shooting when you advance dialogue:
Code: [Select]
let count = 0;
while(GetVirtualKeyState(VK_OK)!=KEY_PUSH && count < 60*15){
SetVirtualKeyState(VK_SHOT, KEY_FREE);
yield; count++;
}
VK_OK and VK_SHOT are distinct despite sharing the same key, so you can not only wait for the player to press Z but forcibly prevent the player from shooting, even if the player script doesn't properly respect SetForbidPlayerShot. Might not be necessary, but it's a problem I've had in the past.

Is there a tutorial for Dialogue?(Cutin or textbox type)
I don't know about a tutorial, but there are various libraries floating around. I got mine from one of Python's scripts (like this one (http://www.bulletforge.org/u/python/p/sumireko-doremy-dream-team-locaa-11-entry)), though I'm not 100% sure whether they wrote it or got it from someone else. The one in the linked script uses a dialogue box, though I've also seen versions of the same library modified to use text bubbles.


And another question of my own: Various enemy textures are being repeatedly unloaded, even though I'm not removing them. Are they removed automatically? How do I prevent them from being unloaded?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 26, 2018, 01:56:55 AM
Textures are unloaded when there aren't any more references to them. If you only load textures automatically by assigning them to objects, once the objects using them are deleted the texture is unloaded, so it'll have to be reloaded if you use it again. This is done so unused textures don't waste memory. If you load textures in a script using LoadTexture, then the reference to the texture lives until the script is finished.

This doesn't mean the best solution is to always preload every asset globally, of course, since that removes the whole point of unloading unused assets.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 26, 2018, 06:20:11 AM
I'm finally venturing into the wonderful world of packages and have a basic main menu set up (though everything but "Game Start", "Option", and "Quit" is nonfunctional for now). I considered trying to just snag one from some other script to work off of, but couldn't find one that wasn't huge (most of them) and/or horrifying (TresserT's bracket placement). Ended up just doing my own from scratch, looking at Book of Star Mythology for reference when necessary. At this point you can select a difficulty and player and start the game, and mostly everything works. The exception is pausing, which does not happen.

I'm guessing starting the pause script is normally handled by the default package, so I need to do it manually? And same with the end scene? Is there anything else like that that I haven't noticed yet?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on March 26, 2018, 12:02:41 PM
It was extra recollection 1, eternal meek. After I add the wait in the code it gives me an error of a bracket missing when there are none missing, but if I add a bracket that's when it gives me a get_center_x not defined error.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 26, 2018, 12:21:52 PM
Bracket mismatches can be caused by many things. It's likely you've misplaced a semicolon somewhere.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on March 26, 2018, 01:28:35 PM
It was extra recollection 1, eternal meek. After I add the wait in the code it gives me an error of a bracket missing when there are none missing, but if I add a bracket that's when it gives me a get_center_x not defined error.

First and foremost, the guides on my website are meant to be done in order - that is, there are things explained in earlier lessons that are used in later ones.

I highly suggest reviewing the first few guides (3-7) to review Danmakufu's syntax and to be acquainted with the helper functions that I assume you have access to. This should help with syntax errors like the one you are having as well as general variable/function naming and debugging.

In the future, I recommend usage of Ctrl-F. If the number of { does not equal the number of }, you typically have a problem somewhere in your script. Good text editors for programming typically show you where your parentheses (), brackets [], and braces {} match.

Finally, if you show us your code, we can figure out what is going wrong.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on March 26, 2018, 02:14:27 PM
https://pastebin.com/hagSLxcM
My attempt at coding eternal meek.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 26, 2018, 03:04:29 PM
As said, you're missing the closing bracket for rand_int, and also are missing the semicolon in its return round(rand(min, max)). Following this you've also typo'd both in GetCenterU and GetStgFrameHeighr.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on March 27, 2018, 12:43:47 AM
Very sorry to ask again, but even when I made the modifications to the script I still got an error for brackets even though I ran through it multiple times and couldn't find one missing.

Here is the error.
http://tinypic.com/r/243l25j/9
Here is the code.
https://pastebin.com/NVCXSXub
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 27, 2018, 02:19:07 AM
Semicolon missing at line 38. However, if I run the script I'm getting the expected error of missing brackets, not an undefined function. You shouldn't be getting the error posted unless you modified it further. Once the semicolon was added the script works.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on March 27, 2018, 03:55:49 AM
Thank you Drake.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: spexguy718 on March 27, 2018, 05:38:06 AM
I'm back again and I have to thank you for helping me last time. After trying out the different aspects of Danmakufu, it seems like I enjoy making player scripts the most. With that in mind I must pose a question.

1.I've been successful making player shots for my player, but I can never get the options (sub shooters, or whatever they're called) to shoot because I really don't know how to plug in that sort of thing. Here's some code I made for the option. Mind you that I'm not the most experienced so explain to me the process as if I'm a child. In short, try to dumb it down for me.

https://pastebin.com/MRC4ryCU

2. I've wanted to make NINE options for my player circling the player in the same fashion as Reimu's TH11 Yukari shot type. As you can see from the code, I've been successful in not only making the option, but mimicking the movement behavior of orbiting the player as well. The only thing I want to know is if there is a simple way of adding 8 more of the same options orbiting the player and how can I do it. Like I said in the first question, try to dumb it down for me.

If you need more information or context, just request it and I'll be sure to answer YOUR question about this question.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 27, 2018, 07:21:36 AM
So for the movement, the 50 refers to the radius, or distance between the player and the option, while the cos(angle) refers to the displacement in x-position at that angle. Similarly sin(angle) is the displacement in y-position at that angle. (Speaking of this, your cos and sin are swapped, but in this case it doesn't really matter, it's just as though the angle is moved 90 degrees.)

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

Given this, if you wanted another option, you would have to set them to a different position around the player, but all you need for that is a different angle (note that the current option moves by change in the angle around the player). So calling another rendernightmare but using angle+something instead would be enough. If you want nine of them, and all evenly spaced, you can divide the 360 degrees into 9 (40 degrees between each). You can do this automatically with an ascent loop:
Code: [Select]
let num_options = 9;
ascent(i in 0..num_options){
  rendernightmare(i * 360/num_options);
}
Then giving rendernightmare the angle as a parameter instead of making the initial angle random.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: spexguy718 on March 27, 2018, 08:50:29 AM
So for the movement, the 50 refers to the radius, or distance between the player and the option, while the cos(angle) refers to the displacement in x-position at that angle. Similarly sin(angle) is the displacement in y-position at that angle. (Speaking of this, your cos and sin are swapped, but in this case it doesn't really matter, it's just as though the angle is moved 90 degrees.)

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

Given this, if you wanted another option, you would have to set them to a different position around the player, but all you need for that is a different angle (note that the current option moves by change in the angle around the player). So calling another rendernightmare but using angle+something instead would be enough. If you want nine of them, and all evenly spaced, you can divide the 360 degrees into 9 (40 degrees between each). You can do this automatically with an ascent loop:
Code: [Select]
let num_options = 9;
ascent(i in 0..num_options){
  rendernightmare(i * 360/num_options);
}
Then giving rendernightmare the angle as a parameter instead of making the initial angle random.


It seems I have trouble plugging it in. Perhaps I'm missing something? Also, I can never understand harnessing the power of parameters.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 27, 2018, 10:55:26 AM
Whereever you're calling rendernightmare, you would put that blurb instead. You'd then give the task itself an angle parameter, like task rendernightmare(angle), and remove the part in the code where you initialize it as a random angle. If you don't really get how parameters work you should probably go over tutorials.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: spexguy718 on March 27, 2018, 11:00:52 AM
Whereever you're calling rendernightmare, you would put that blurb instead. You'd then give the task itself an angle parameter, like task rendernightmare(angle), and remove the part in the code where you initialize it as a random angle. If you don't really get how parameters work you should probably go over tutorials.

Thing is that I have gone over the tutorials and there is only one little snippet that I found that covers parameters  and it's fairly short to the point where I still dont get it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on March 27, 2018, 10:12:10 PM
How can I grow bullets, and their hitbox?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Aka Kyuketsuki on March 27, 2018, 10:58:24 PM
How can I grow bullets, and their hitbox?

First, put your bullet in a pot of nice, moist soil. Sprinkle water at room temperature on a regular basis. Larger bullets need less water. Remember to keep your pot in a place where sunlight shines frequently, such as near a window. In about three weeks or so, your bullet will have become about three times bigger, and have sprouted a hitbox about a third of its size. It will be harder to tell for irregularly-shaped bullets, but in general, they should reach from the center halfway towards the transparent part of their graphic.

You do this by running a while loop, setting a custom hitbox each frame on the position of the bullet. This while loop terminates when your bullet is deleted.

Please refer to these functions for what you should call to set the custom hitbox.

As for expanding the graphic, please refer to these functions.

It may not be necessary to use all of the listed functions, but please use whatever is needed.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on March 28, 2018, 01:22:45 AM
First, put your bullet in a pot of nice, moist soil. Sprinkle water at room temperature on a regular basis. Larger bullets need less water. Remember to keep your pot in a place where sunlight shines frequently, such as near a window. In about three weeks or so, your bullet will have become about three times bigger, and have sprouted a hitbox about a third of its size. It will be harder to tell for irregularly-shaped bullets, but in general, they should reach from the center halfway towards the transparent part of their graphic.

Truly quality shitposting. But the true solution is to sprinkle them with POWERBULLET (https://www.youtube.com/watch?v=ica7PQ0BWzc) :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ILS on March 28, 2018, 02:26:05 PM
For danmakufu ph3, it is not possible to set more vitual keys  for recording in replay, right?
Making one more fake player that can shot and be hit is simple, but the limiting vitual keys is clearly not enough for something, like a double-play stage or so. I hate when I have to cut the replay part when creating such script. :wat:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on March 29, 2018, 05:21:01 PM
For danmakufu ph3, it is not possible to set more vitual keys  for recording in replay, right?
Making one more fake player that can shot and be hit is simple, but the limiting vitual keys is clearly not enough for something, like a double-play stage or so. I hate when I have to cut the replay part when creating such script. :wat:

Please refer to https://dmf.shrinemaiden.org/wiki/Input_Functions
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ILS on March 30, 2018, 02:31:56 AM
Please refer to https://dmf.shrinemaiden.org/wiki/Input_Functions

AddVirtualKey(...) can only map key to a defined virtual key, like VK_LEFT, VK_RIGNT, etc. as shown in wiki (otherwise the program will report an error).
While argument of AddReplayTargetVirtualKey(...) should be a key registered with AddVirtualKey(...) (unregisted key crashes the program in the beginning of replay ).
Which means I can but only record these vitual keys already defined in ph3, not even one more.
Existing vitual keys are:
VK_LEFT VK_RIGHT VK_UP VK_DOWN VK_SHOT VK_BOMB VK_SLOWMOVE VK_USER1 VK_USER2 VK_OK VK_CANCEL VK_PAUSE

Clearly too short in number for two players both have movement, slow, bomb and shot.
Now I use GetKeyState(...) to utilize more keys. But like I said, the replay would fail to record them.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 30, 2018, 06:06:09 AM
That documentation is poor. It ignores the main functionality of AddVirtualKey which is exactly what you're looking for.

There are predefined ranges of potential virtual key codes that can be used; there is the range VK_USER_ID_STAGE to VK_USER_ID_STAGE + 255 and the range VK_USER_ID_PLAYER to VK_USER_ID_PLAYER + 255. These are all possible virtual keys you can add. For example, if you wanted a Player 2 shot button you could do
Code: [Select]
let VK_SHOT_P2 = VK_USER_ID_PLAYER + VK_SHOT;
AddVirtualKey(VK_SHOT_P2, KEY_Y, KEY_INVALID);
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on March 30, 2018, 09:11:43 AM
I'm currently wrapping up on production of a Junko boss fight, but I'm now running into problems with bullets randomly not spawning in the later attacks, usually starting 9/10 attacks into the plural. Does anyone know what causes this?
(I'm also using Ultima's DDC ReimuB as the player.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 30, 2018, 09:32:04 AM
By "randomly" do you mean actually randomly, intermittently, or suddenly stopping altogether? What does the log window say about the shot count? Do spawning effects still occur? Have you confirmed this with other player scripts, even though that is likely not the issue?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on March 30, 2018, 03:02:50 PM
By "randomly" do you mean actually randomly, intermittently, or suddenly stopping altogether? What does the log window say about the shot count? Do spawning effects still occur? Have you confirmed this with other player scripts, even though that is likely not the issue?

I don't have any spawning effects for my script, but bullets that don't spawn are actually randomly not spawning (like 2-4 bullets in a ring not necessarily in a row) and they're not just invisible since there's no hitbox where they should be. I tried other shots and they don't appear to cause this...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on March 30, 2018, 03:07:39 PM
I don't have any spawning effects for my script, but bullets that don't spawn are actually randomly not spawning (like 2-4 bullets in a ring not necessarily in a row) and they're not just invisible since there's no hitbox where they should be. I tried other shots and they don't appear to cause this...

Can you provide some code snippets and more details about your coding environment, libraries, etc? Are you using multiple shot sheets?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on March 30, 2018, 03:42:04 PM
Can you provide some code snippets and more details about your coding environment, libraries, etc? Are you using multiple shot sheets?
https://www.dropbox.com/s/4kyjx2fxxqy87hf/_generic%20junko.zip?dl=0
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on March 30, 2018, 04:29:22 PM
https://www.dropbox.com/s/4kyjx2fxxqy87hf/_generic%20junko.zip?dl=0

Unable to replicate your issue. My best guess is that your computer's hardware is not capable of handling over 8000 ADD rendered bullets at once and something went wrong with Danmakufu.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on March 30, 2018, 04:33:10 PM
Unable to replicate your issue. My best guess is that your computer's hardware is not capable of handling over 8000 ADD rendered bullets at once and something went wrong with Danmakufu.

Given that I've only been experiencing this issue (not just with this script btw) with Ultima's DDC ReimuB I'll pin the blame on that, and just use another player then. Thanks for the help.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on March 30, 2018, 06:33:27 PM
Given that I've only been experiencing this issue (not just with this script btw) with Ultima's DDC ReimuB I'll pin the blame on that, and just use another player then. Thanks for the help.

It's rare for Player Scripts to interfere with a non-player script and vice versa. The only example I can think of is Mr. Blue's Reimu including the DNH Default shot sheet and messing up shot constants in scripts.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on March 30, 2018, 11:11:53 PM
How do you check how many variables an array has?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on March 31, 2018, 12:19:53 AM
length(array) returns how many items there are in an array.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 31, 2018, 07:42:40 AM
Given that I've only been experiencing this issue (not just with this script btw) with Ultima's DDC ReimuB I'll pin the blame on that, and just use another player then. Thanks for the help.
maybe you should not try throwing 8000 bullets on the screen regardless

Here are some concerns I found:

- In spell4.dnh, CheckHitWall will return null if the bullet is deleted somehow, leading to angle being unset when you use it, throwing an error. You might not have seen this error but it happened on my first run.
- In functions.txt, for PlaySound you do something like if(str == "Shot1"){ObjSound_Load(s,MainSTG~"sound/Shot1.wav");} but like 30 times, which means:
  - You aren't using else-ifs so as to not compare against every string
  - You aren't using alternative-case which is what you should be doing instead, given you want to choose between all these string comparisons
  - Note that you can replace all this boilerplate with ObjSound_Load(s,MainSTG~"sound/"~str~".wav"); given that all the strings being called are also the filenames
- You don't delete the sound objects after you create them, but you create a new object for every call, so you'll have a gazillion of them quickly.

This last one will cause your issue, as the number of objects will grow endlessly and start causing memory leaks or whatever else. If you're using sounds in your original script, which is what I suspect, this is almost surely the cause.

If this is the case, I would guess that the reason you see it with that particular player script could be that with other player scripts you end the fight sooner and don't have enough time for the problem to build to critical levels.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on March 31, 2018, 09:35:20 AM
maybe you should not try throwing 8000 bullets on the screen regardless

Here are some concerns I found:

- In spell4.dnh, CheckHitWall will return null if the bullet is deleted somehow, leading to angle being unset when you use it, throwing an error. You might not have seen this error but it happened on my first run.
- In functions.txt, for PlaySound you do something like if(str == "Shot1"){ObjSound_Load(s,MainSTG~"sound/Shot1.wav");} but like 30 times, which means:
  - You aren't using else-ifs so as to not compare against every string
  - You aren't using alternative-case which is what you should be doing instead, given you want to choose between all these string comparisons
  - Note that you can replace all this boilerplate with ObjSound_Load(s,MainSTG~"sound/"~str~".wav"); given that all the strings being called are also the filenames
- You don't delete the sound objects after you create them, but you create a new object for every call, so you'll have a gazillion of them quickly.

This last one will cause your issue, as the number of objects will grow endlessly and start causing memory leaks or whatever else. If you're using sounds in your original script, which is what I suspect, this is almost surely the cause.

If this is the case, I would guess that the reason you see it with that particular player script could be that with other player scripts you end the fight sooner and don't have enough time for the problem to build to critical levels.

Thanks for the analysis. I don't actually have any sound effects in my scripts, so I'll just remove those from the functions.txt; I've also fixed spell4.dnh now.
The final script'll just use another Reimu shot that doesn't have the issues but kills everything at roughly the same time.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 31, 2018, 10:50:13 AM
Unrelated to CrestedPeak9's problem but general advise to all Danmakufu programmers: Keep the Log window open when analysing problems with performance and other weird behaviour. There is lots of information given in the log window and trivial things such as potential slowdowns can be easily detected. The Log windows is easily enabled from config.exe -> option -> show log file.

Edit
@ CrestedPeak9, I've downloaded your junko script and checked. Tested using default Rumia with god mode then tested with Ultimate's DDC ReimuB. All bullets were appearing fine, but there was 15 FPS slow down on the 9th Spell Card because over 8000 bullets on the screen.

Aside from your problems, this is very bad design and you should avoid this at all costs.

Now about your problem:
You're not reading into what people are answering. Even now in your last post you keep mentioning the player script. There is nothing wrong with it in combination with your script. When three people conclude this by testing then obviously your problem is something else which you aren't clearly communicating or showing us.

I highly suggest you stop assuming things and upload your entire Dnh folder without stripping anything.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 31, 2018, 11:05:27 AM
The final script'll just use another Reimu shot that doesn't have the issues but kills everything at roughly the same time.
That... doesn't solve the issue though. You're claiming that it's the player script, but even if Ultima's script has some minor problems with resource usage it shouldn't be as significant as throwing so many bullets on screen. If it is a problem with Ultima's script, then it would be good to find out what the problem is and get it fixed, not just ignore it. I've also spent a good deal of time going through both of your scripts, so I would like some closure here. Can you replicate the problem while giving more information? If you replicate the bug but have the log window open (as Hele just posted how to do) and post screenshots that could help tremendously in pinpointing the issue.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on April 01, 2018, 03:12:39 AM
Sorry to everyone; I didn't mean to be presumptuous, but I was rushing to get the script out for a contest outside of this community, and one of my playtesters also encountered the same issues that I did. When I switched to another Reimu script I just wanted to get the boss fight ready.

In the meantime however, I'll look into changing spell6 to use white lasers for the obscuring effect, and I'll post logs when I get the time to.
This is the dnh folder I was using with all other scripts cleaned out: http://bit.ly/2pT8ZXJ

Edit: It just occured to me that I did modify Ultima's player script slightly in changing the grazebox, so I've uploaded my modified player script and a replay with the issue (at least on my PC).
https://www.dropbox.com/s/kq824xvw9f6pvfm/package2.zip?dl=0
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on April 01, 2018, 04:09:08 AM
Edit: It just occured to me that I did modify Ultima's player script slightly in changing the grazebox, so I've uploaded my modified player script and a replay with the issue (at least on my PC).
https://www.dropbox.com/s/kq824xvw9f6pvfm/package2.zip?dl=0

From what I can see, on death Ultima's player starts approx. 60 nonterminating tasks. When I tested with my own player, the extra tasks did not appear. Currently looking into it; might not find an answer due to the terrible formatting on the player script.

Update: Yeah I have no idea where the problem is. Sorry about that. I will recommend using another player.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on April 01, 2018, 06:02:32 AM
...This is the dnh folder I was using...
...Edit: It just occured to me that I did modify Ultima's player script slightly in changing the grazebox,..
This makes absolutely no sense. Why did you upload your entire dnh folder but then removed the player script and now are separately uploading it because you thought you modified the player script? You were suppose to upload your entire Dnh folder without cleaning up anything. I explicitly requested this.

Edit:
There are four difficulty levels. Which one of these are causing the issue?

Edit2
Your replay is not functioning because it throws me the error "自機スクリプトが見つかりません:[ReimuH.dnh]" which basically means the replay was unable to find the player script.

We seriously cannot help you if you keep doing things you were not told to do.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on April 01, 2018, 06:15:13 AM
This makes absolutely no sense. Why did you uploaded your entire dnh folder but then removed the player script and now are separately uploading it because you thought you modified the player script? You were suppose to upload your entire Dnh folder without cleaning up anything. I explicitly requested this.

That folder I uploaded was the one I released for the external contest. Sorry about that, I was trying to minimize the download size since I had a lot of other scripts.
https://www.dropbox.com/s/d3phs0k07ut79py/danmakufu%20ph3%20pre6a.zip?dl=0


Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on April 01, 2018, 07:04:58 AM
That folder I uploaded was the one I released for the external contest. Sorry about that, I was trying to minimize the download size since I had a lot of other scripts.
https://www.dropbox.com/s/d3phs0k07ut79py/danmakufu%20ph3%20pre6a.zip?dl=0
This dnh folder does not function. Booting it spits out this massive 1.45mb log. Here is a snip:  https://pastebin.com/6584Dk5u

Once loaded, I am missing all player scripts except Reimu MoF.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on April 01, 2018, 10:17:26 AM
This dnh folder does not function. Booting it spits out this massive 1.45mb log. Here is a snip:  https://pastebin.com/6584Dk5u

Once loaded, I am missing all player scripts except Reimu MoF.

I'm not sure what happened. I've uploaded it again.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 01, 2018, 10:42:03 AM
Found it. In Ultima's player script, on EV_HIT it calls DestructionA1 which calls Cherry a bunch of times, which does not end once the expected conditions are met. This by itself is not so much of a problem, but first I have to explain parallel universes object IDs.

Object IDs are just integers that index into a table of all objects. When you create an object with a function like ObjPrim_Create or CreateShotA1, it returns the object ID, which is just an integer that the engine will use to look up where the actual object is stored in memory. The table of object IDs range from 0 to 65535 (a range of 2^16). As you create objects the next ID number available just goes up one by one, so you create object 0, 1, 2, etc. However once the next ID passes 65535 it wraps back around to 0. This is generally fine, because even though the next ID resets to 0, any IDs with existing objects are skipped over until the next available one.

Here in the Cherry task, the ora variable decreases per frame and once it hits 0 the cherry object is deleted. Once the cherry objects are deleted, their IDs are free to be assigned new objects again. The tasks keep going and continue to keep calling Obj_Delete(obj). Meanwhile, the boss script is constantly spewing out tons of bullets, and motors through the available object IDs quickly. It hits 65535, wraps back around, and eventually reaches the object IDs that are still stored by the cherry object variables, which have long since been deleted but are still just integers so whatever. Then it deletes the new objects with Obj_Delete(obj). This happens for 60 object IDs, so that's 60 objects later being spontaneously deleted, but this is for every time that function is triggered, which is when you get hit. So the more you get hit, the more often this happens and the more object IDs get set up to be deleted, which also wouldn't be obvious if not for the infinite lives given allowing you to die a kajillion times.

So it's a big combination of crap. Only with both of your combined crap could you get so much crap it would cause this issue.


Despite that explanation, literally the only thing needed to "fix" this really is to replace the raw infinite loop with a while-not-deleted loop or anything else that lets the task end properly. But this also really only shows up (and in a noticeable way) because of the unreasonable quantity of bullets being put out by the boss script (which is not exactly a good thing itself) and the infinite lives.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on April 01, 2018, 12:58:11 PM
Thanks a lot, Drake. I'll get to fixing two of those three things, but I can't really change the dying a lot part.

I do have another issue though. In all variants of spell5, occasionally, the second phase with the green bullets won't trigger and nothing spawns except for the red wall. I tried cleaning up the script and make the health a global variable, then have mainloop update it every frame, but it still fails to trigger sometimes. Is there someone wrong I'm doing with the conditionals?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on April 01, 2018, 01:00:02 PM
I know that 0.12m is a old version, but I really want to try to make something...
The problem is: Danmakufu keeps crashing without the menu(with AppLocale and LocaleEmulator),
when I open naturally it opens the menu, but when I select ExRumia (directory) *crash*
Plz Help mee
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on April 01, 2018, 01:57:42 PM
I know that 0.12m is a old version, but I really want to try to make something...
The problem is: Danmakufu keeps crashing without the menu(with AppLocale and LocaleEmulator),
when I open naturally it opens the menu, but when I select ExRumia (directory) *crash*
Plz Help mee
As moderator I need to alert you of the following: It is not encouraged to make anything in 0.12m. I've written in the FAQ about this. The only things that should be supported is getting old scripts to work for research/playing purposes. Seeing that you aren't trying to get someone else's script to work but actually attempting a creation I suggest to do it in ph3.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 02, 2018, 05:03:29 AM
I do have another issue though. In all variants of spell5, occasionally, the second phase with the green bullets won't trigger and nothing spawns except for the red wall. I tried cleaning up the script and make the health a global variable, then have mainloop update it every frame, but it still fails to trigger sometimes. Is there someone wrong I'm doing with the conditionals?
Can't replicate after like 10 attempts. Have a replay? Preferably of just the spell?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on April 02, 2018, 06:06:23 AM
Can't replicate after like 10 attempts. Have a replay? Preferably of just the spell?

https://cdn.discordapp.com/attachments/428716490653696000/430102399646957574/Junko3_replay03.dat
Unfortunately I couldn't replicate it either, but here's a replay with the issue occuring during a Lunatic plural run that one of my testers submitted.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 02, 2018, 07:13:59 AM
The break statement is used to exit loops, not functions. If you use break in a function or task, it will end it immediately and cascade down the function call chain until it does find something to break out of.
Code: [Select]
function a{
  b;
}

task b{
  loop(10){
    c;
    yield;
  }
  break;
}

function c{
  break;
}
In the above example: a calls b; b starts a loop and calls c; c breaks, cascades back to b, and breaks the loop; b then breaks after the loop, cascades back to a, breaks a, then keeps cascading break to whatever a's context was.

In your case, the big blue bullet is deleted by hitting 5000 life before it hits the wall, triggering if(Obj_IsDeleted(blue)){break;} which ends the BlueHelix task, cascades back through the Main task and then breaks out of the while (life > 0) loop, ending the rest of the pattern.

Always use return to end a function or task. I suggest fixing anywhere in your code that breaks instead of returning.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on April 02, 2018, 09:11:22 AM
Always use return to end a function or task. I suggest fixing anywhere in your code that breaks instead of returning.
I suddenly have a sense of deja vu...
Thanks for the help. I'll need to, uh, break this bad habit of mine.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on April 08, 2018, 10:05:00 PM
(Whoops, double-checked and I wasn't deleting my ObjSounds when I was done with them either. No wonder I was having some fps issues.)

So, I know Danmakufu is kinda bad about arrays. What I'm not sure of is the relative speed of common data and object dictionaries. My guess is it's at least somewhat slower than just using a variable, but I'm unsure how it compares to arrays.

Specifically, how stupid of an idea would it be to forgo arrays entirely and use SetCommonData("arrname"~itoa(i),v);, Obj_SetValue(arrobj,itoa(i),v);, or SetAreaCommonData("arrname",itoa(i),v); instead?

Testing with a single that does nothing but increment members of an "array" 10000 times per frame - that is:
Code: [Select]
let size=10; arr=Arr_Init(size,0);
let ops_per_frame = 10000;
loop{
loop(ops_per_frame){
let v = Arr_Get(arr,i);
Arr_Set(arr,i,v+1);
i=(i+1)%size;
}
yield;
}
With the methods using an alternative on a global to determine which type of "array" to use. (Here's the code (https://pastebin.com/qwRGdDyg) for the methods.)
Here are the FPS values I recorded for each test:
Code: [Select]
V:    | 27 |    | 33    single variable (ignoring index)
v: 13 |    | 13 | 12    10 variables w/alternative
n: 09 | 24 | 21 | 19    normal array
o: 14 | 16 | 16 | 15    object dictionary
c: 09 | 11 | 10 | 10    common data
a: 09 | 11 | 11 | 10    area common data
It seems like none of them are faster than normal arrays, aside from in the first set of tests. It also seems that the alternatives for working with the individual variables are actually slower than just using an arrays.

Thoughts? Second opinions?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Magikrow on April 10, 2018, 12:46:16 PM
So I was wondering how people get the boss's health bar to be a red circle around the boss instead of on the top of the screen. To add to this, could anyone help me with spellcard pictures? Like whenever a spellcard is declared, usually a picture of the boss hovers over the screen for a second. How do I do this?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on April 10, 2018, 12:51:06 PM
So I was wondering how people get the boss's health bar to be a red circle around the boss instead of on the top of the screen. To add to this, could anyone help me with spellcard pictures? Like whenever a spellcard is declared, usually a picture of the boss hovers over the screen for a second. How do I do this?
The hovering of the boss and such is called often a ' cutin '. It is nothing else than drawing a texture on the screen and then moving it around in a sequence. You can code it yourself or download ready made scripts. Have you checked the sticky Information thread (https://www.shrinemaiden.org/forum/index.php/topic,6181.0.html)?

The circular life bar I am unsure whether it was mentioned here or not. Need some extra reply on this one.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Magikrow on April 10, 2018, 12:56:54 PM
The hovering of the boss and such is called often a ' cutin '. It is nothing else than drawing a texture on the screen and then moving it around in a sequence. You can code it yourself or download ready made scripts. Have you checked the sticky Information thread (https://www.shrinemaiden.org/forum/index.php/topic,6181.0.html)?

The circular life bar I am unsure whether it was mentioned here or not. Need some extra reply on this one.
Thank you, this will help a lot! While I'm here could I ask if there are any ready made scripts to make dialogue? If not, what is an easy way to create a dialogue function/system?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on April 10, 2018, 02:09:13 PM
Thank you, this will help a lot! While I'm here could I ask if there are any ready made scripts to make dialogue? If not, what is an easy way to create a dialogue function/system?
There are various libraries floating around. Here (http://www.bulletforge.org/u/python/p/sumireko-doremy-dream-team-locaa-11-entry)'s one of Python's scripts using one.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Magikrow on April 10, 2018, 02:50:26 PM
There are various libraries floating around. Here (http://www.bulletforge.org/u/python/p/sumireko-doremy-dream-team-locaa-11-entry)'s one of Python's scripts using one.
Sorry I'm not that experienced, but I found the Dialogue file but I can't seem to find him using it anywhere in the game. How would I use this file with it's functions?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on April 10, 2018, 03:32:37 PM
Sorry I'm not that experienced, but I found the Dialogue file but I can't seem to find him using it anywhere in the game. How would I use this file with it's functions?
Something like this (https://pastebin.com/teNkfkvX), usually in a separate single. (Ignore SetBGM and ShowEnemyTitle, those aren't part of the library.)

how people get the boss's health bar to be a red circle around the boss instead of on the top of the screen
Here (https://pastebin.com/ptXVX62h)'s a task I grabbed from somewhere to do it. (You'll probably need to change the filepaths.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Magikrow on April 11, 2018, 12:38:47 PM
Something like this (https://pastebin.com/teNkfkvX), usually in a separate single. (Ignore SetBGM and ShowEnemyTitle, those aren't part of the library.)
Here (https://pastebin.com/ptXVX62h)'s a task I grabbed from somewhere to do it. (You'll probably need to change the filepaths.)
Thank you so much!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Magikrow on April 11, 2018, 01:05:40 PM
Something like this (https://pastebin.com/teNkfkvX), usually in a separate single. (Ignore SetBGM and ShowEnemyTitle, those aren't part of the library.)
Here (https://pastebin.com/ptXVX62h)'s a task I grabbed from somewhere to do it. (You'll probably need to change the filepaths.)
Sorry, just one more question. Every time I try to use the Dialogue pastebin you gave me, the entire program crashes. (yes I changed the images to my own)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on April 11, 2018, 03:15:42 PM
Sorry, just one more question. Every time I try to use the Dialogue pastebin you gave me, the entire program crashes. (yes I changed the images to my own)
Could you copy-paste the error messages you get, or does your program freeze and not respond?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Magikrow on April 11, 2018, 03:22:19 PM
Could you copy-paste the error messages you get, or does your program freeze and not respond?
It freezes and doesn't respond
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on April 11, 2018, 04:55:29 PM
Magikrow, I am suspecting that you're very new to Danmakufu in general and you're already attempting to use someone else's code without actually understanding what you're doing. Dialogues and circular lifebars are intermediate to expert level scripting effects. Unless they are really dummy-proof prepared and offered, you're not going to get it right.

That dialogue code paste is never going to work because it is incomplete. It is an example, not a ready to use script. The initial dialogue you got is a playable script from Python's. The author probably integrated the dialogue functionality it into its own work. He/she already understands how to work it out.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Magikrow on April 12, 2018, 12:42:26 AM
Magikrow, I am suspecting that you're very new to Danmakufu in general and you're already attempting to use someone else's code without actually understanding what you're doing. Dialogues and circular lifebars are intermediate to expert level scripting effects. Unless they are really dummy-proof prepared and offered, you're not going to get it right.

That dialogue code paste is never going to work because it is incomplete. It is an example, not a ready to use script. The initial dialogue you got is a playable script from Python's. The author probably integrated the dialogue functionality it into its own work. He/she already understands how to work it out.
Yes I am very new, however I did get the circular lifebar to work. Dialogue really seems to be the only thing I've had a big struggle with working with danmakufu. Is there somewhere I can learn more about it?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on April 12, 2018, 06:06:56 AM
Everybody can get eventually something to work by lots of trying, that still doesn't though makes you understand what is exactly going on. Well, that is eventually up to you whether you're fine with that or not.

Dialogues are a combination of 2D Sprites, drawing/manipulating these and utilizing Tasks/Function. These topics are covered in Sparen's Danmakufu ph3 tutorials (also listed in the information thread). My suggestion would be to go through these topics to get a better understanding of what you're doing and when something fails to work, you understand what is/might be causing it.

Of course you're always free to ask for help here. But when you do, you need to provide us information such as the error message. And if something freezes, then we need to see your script files. You can post these in Pastebin.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 15, 2018, 05:35:25 AM
So, I know Danmakufu is kinda bad about arrays. What I'm not sure of is the relative speed of common data and object dictionaries. My guess is it's at least somewhat slower than just using a variable, but I'm unsure how it compares to arrays.
Warning, incoming wall

You're essentially asking if using a hash table to mimic an array is better than using an array for array-like operations. Maybe if there were something actually problematic with the array implementation, but there isn't any huge problem like that. Arrays aren't slow. They're O(1) access as expected. There are still some lingering misconceptions about this because back in 0.12m arrays were not O(1) access.

Meanwhile, hash tables are often internally implemented using arrays to begin with. There would have to be some additional factors in play for a straightforward array implementation to be worse than a hash table mimicking an array. Moreover, this ignores any extra work that has to be done to shape the input. ObjVals and CommonData both map from strings only, so at the very minimum you have to convert the numbers to strings which is at least O(k) in the number of digits k.

CommonData in particular would be a bad idea for namespace reasons alone. This is equivalent to using global variables everywhere and is incredibly bad practice. Additionally, if you use CommonData to work with large pseudo-arrays and try to use the debug window you may be met with screaming lag.


I think it can be assumed that DNH doesn't use dynamically-sized arrays due to having no mechanism to grow/shrink freely. Instead you just concatenate arrays, which (probably) means when you do a concatenation you're allocating memory for the new array then copying them over. If you have any code that grows an array element-by-element this will be very inefficient. However, because you can't instantiate arrays of a given size (which might have to do with them being of variable type and structure until assigned) all you can do is use a better algorithm, like the following (which is O(log n) rather than O(n) in time and wastes O(n) space instead of O(n2)):

Code: [Select]
function array(size, value){
let a = [value];

while(length(a) < size * 2){
a = a ~ a;
}

return a[0..size];
}

Also, because you can use this method to instantiate arrays of a certain size, but cannot do so with a hash table, creating a hash table mimicking an array of a fixed size will be significantly slower even ignoring the overhead explained above.

What hash tables do have over arrays in this sense is their variable size, but hash tables still have to resize internally when filled up a certain amount, and you can just as well do this with arrays in order to create dynamic arrays, but I'm not going to get into that.

Anyways, the majority of latency people tend to find with arrays in DNH is from them trying to create and manipulate arrays as though they are dynamic when they are not. If you ignore the fact that you can't simply instantiate an array with a given size they are just fine.



Now for some problems with your tests. First is that you have no proper control tests. You don't factor in what could be overhead and what is inherent to the method used. Not only does this mean you can't tell what is/isn't overhead, but also you can't properly measure and compare each method.

You use FPS to measure. While I've done this previously, this is a bad measure because it stays at 60 until it slows down and is not necessarily linear decreasing past that. It's not a very reliable way to compare, especially for reasons I'll give later.

You use only arrays of length 10. Although theoretically, if you assume all of the test method accesses are O(1) but with different constant factors, the size of the structures shouldn't be important. However, not only should you not assume this to begin with, but as explained above, the pseudo-array hash table access will take O(k) time for the digit length k. So with a pseudo-array of length 20000, accessing element 10000 will take slightly longer than element 0 because of the string conversion.

You use ObjVal on the empty string. I'm not sure why you did this but I really hope you don't use that in any other code. Strings are not objects that you can use these functions on. While it might appear that it's working successfully, what is happening is that putting a string in place of the object ID ends up falling back to the value 0 instead. So you are actually manipulating the object values of object ID 0. Check this example:

Code: [Select]
let a = "a";
Obj_SetValue(a, "key", "a:val");
let b = "b";
Obj_SetValue(b, "key", "b:val");
Obj_GetValueD(a, "key", "a:null"); // => "b:val"
Obj_GetValueD(b, "key", "b:null"); // => "b:val"
Obj_GetValueD(0, "key", "0:null"); // => "b:val"

Lastly you're doing a hell of a lot of branching unnecessarily by using Arr_Set/Get for every single iteration. This is going to inflate times and the differences between each method will become muddy, especially considering you don't have controls that would expose the overhead. This is further compounded by all the extra stuff you're doing for each iteration: access the variables arr and i, create a variable v and set it, access all three of those again, add 1, (do a set op), access i and size, add 1, do a modulo operation, and set i again. This is a lot of overhead that you're introducing for each iteration that will likely dominate runtime.



So basically this got me invested enough, when I've done these tests similar to this in the past, that I went back and refined them even more.

Here is the code: https://gist.github.com/drakeirving/a99d768beca4c69d7c44050620777b2f (https://gist.github.com/drakeirving/a99d768beca4c69d7c44050620777b2f)

Here are some results:

https://drive.google.com/file/d/1QmxcjFVENOtCjK8cxksA-N1K0WTjZvVr/view (https://drive.google.com/file/d/1QmxcjFVENOtCjK8cxksA-N1K0WTjZvVr/view)

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

Notes:

As I comment in the code, for a given number of iterations, putting in more iterations per frame asymptotically speeds up the process. So what you were doing, where you have a certain number of iterations per frame, each frame you wait to update the screen increases runtime. With the same number of iterations, as you perform more iterations per frame while decreasing the number of frames to run, it gets faster and faster. So, the optimal way to test is to not yield whatsoever and only update the screen when the run is done.

DNH gives you the GetStageTime function to work in milliseconds. You can easily just time using this and it's much more accurate than checking FPS values; plus it is cumulative so it represents the whole test while tracking FPS has to be sampled at certain points in time. Doing it this way also allows you to test without needing to update the screen.

AddScore() has less overhead than incrementing a variable, so I use this. It's the operation with the least overhead I bothered testing that demonstrably does something.

Using CommonData has more overhead than AreaCommonData because of the extra string concatenation, but as shown by the controls, the actual access is the same. Meanwhile, ObjVals are inherently faster, but still far slower than array access even when ignoring the overhead.



tl;dr use arrays when you want to use arrays. Use efficient methods if you need to make arrays of a certain size rather than just concatenating each element.

And use ObjVals over CommonData when you need to use dictionaries unless you actually need to use the global properties of CommonData.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on April 18, 2018, 06:19:11 PM
How do you get info of a bullet ID such as delay color from within the script?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on April 18, 2018, 07:37:49 PM
How do you get info of a bullet ID such as delay color from within the script?
You can use the GetShotDataInfoA1 (https://dmf.shrinemaiden.org/wiki/Shot_Functions#GetShotDataInfoA1) function. It needs the shot graphic id that you want to look up, and the type of information you're looking for. In your case that would be INFO_DELAY_COLOR.

So something like this:
let RGB_array = GetShotDataInfoA1(1,INFO_DELAY_COLOR);
Just replace 1 with whatever shotsheet graphic id you want the info for.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 19, 2018, 12:25:03 AM
Note there are three arguments e.g. GetShotDataInfoA1(id, TARGET_ENEMY, INFO_DELAY_COLOR) where you distinguish between player and enemy shot graphics.
You can also get the shot graphic ID with ObjShot_GetImageID(obj).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on April 20, 2018, 01:56:32 AM
There are still some lingering misconceptions about this because back in 0.12m arrays were not O(1) access.
So THAT's why I was thinking they were slow. I must have heard that somewhere and not realized it was outdated.
Now for some problems with your tests.
Yeah... Well, they weren't really intended to be exhaustive, just trying to get a general idea, but you're right, it was pretty slapdash.
(The empty string thing was just to see what would happen, and since it didn't break anything I forgot to change it back.)
AddScore() has less overhead than incrementing a variable, so I use this. It's the operation with the least overhead I bothered testing that demonstrably does something.
Huh. How does that work? I would have thought it would still just be incrementing a variable.



So the distortion effect in SampleE02, is there a way to do that with a shader instead of breaking the image up into a spritelist? ...Preferably with working example because I'm still just beginning to fumble my way through figuring out HLSL.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Fujiwara no Mokou on April 20, 2018, 04:12:33 AM
Huh. How does that work? I would have thought it would still just be incrementing a variable.

If it weren't being done in a virtual machine, you'd be right. But that's not the case here. Danmakufu uses an abstract data type to store script data. This data type must first be deduced in runtime by the virtual machine and operations such as addition must be done in that script environment as well. To do this, it must allocate a new abstract datatype and assign your to it in the stack, before performing a callback function that does the addition operation. Then the 'adding' variable must be freed from the VM stack each time you do something as simple as that. Oh, and since you're doing this in a VM, there is an array of instructions and a pointer that is iterated to perform all of this each step of the way.
The addScore() function uses a different scheme, however. Since it's a native function, the operation is likely done in pure C/C++ with a true integer at some point, and the number of (assembly-language) instructions to actually increment it is far fewer.

TLDR; C++ is faster than Danmakufu.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 21, 2018, 08:28:47 AM
So the distortion effect in SampleE02, is there a way to do that with a shader instead of breaking the image up into a spritelist? ...Preferably with working example because I'm still just beginning to fumble my way through figuring out HLSL.
What part of it? If it's just the distortion, then SamplePS03 already does mostly that. The darkness thing also wouldn't be too difficult, it would just require modifying the pixel colors to be the regular color minus a function of distance from the center, which SamplePS03 already uses.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on April 21, 2018, 07:04:33 PM
If it's just the distortion, then SamplePS03 already does mostly that.
Whoops, I remembered there was something to do that in the samples and stopped checking when I found one in E02. Never mind!


Every so often when I go to start a script, it just hangs with the log saying nothing but
Code: [Select]
2018/04/21 18:37:37.842 読み込み完了待機(ScriptManager):(something like "waiting to finish reading") every few seconds.
Why does this happen and is there anything I can do about it? Is it some inherent issue with Danmakufu, an issue with the default package, something I'm doing?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on April 22, 2018, 01:16:13 PM
How can I make multiphased nos and spells? Like Reimu in CtC
I know I've already asked this but I didnt understand it, and also lost he post... :blush:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on April 22, 2018, 03:23:42 PM
How can I make multiphased nos and spells? Like Reimu in CtC
I know I've already asked this but I didnt understand it, and also lost he post... :blush:

There are three steps to multiphased attacks.
1) Check boss health remaining. You can do this with ObjEnemy_GetInfo(objBoss, INFO_LIFE).
2) (If necessary) cancel previous phases by checking if health is below a certain threshold. Do something like if(health>threshold){Shoot;}
3) Fire added phases by checking if health is below a certain threshold. Do something like if(health<threshold){Shoot;}

You can also do this with spell timers to create timeout phases/multiphased timeout spells, by doing ObjEnemyBossScene_GetInfo(objScene, INFO_TIMER).

People might get angry at me, but I like to set health/time as a global variable and set it per frame in MainLoop.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on April 22, 2018, 07:10:02 PM
I'm trying to clear up some of the clutter/bugs in my environment regarding magic circles, spellcard bonuses, etc. In the process of doing so, I've discovered that I apparently don't actually know how to use GetScriptResult properly. I tried looking through the code for examples, but I couldn't actually find anywhere it was being used.
Here's the function I'm working on to serve as a one-stop shop for all my notifying needs:
Code: [Select]
function Notify(type,event,args){
let id = GetScriptID(type);
if(id==ID_INVALID || type==SCRIPT_ALL || ((type==SCRIPT_PACKAGE)!=(GetOwnScriptID==GetScriptID(SCRIPT_PACKAGE))) ) {
NotifyEventAll(event,args);
}
else{
NotifyEvent(id,event,args);
return GetScriptResult(id);
}
}
Currently, it does not work. Specifically, it doesn't return anything, and I get a "trying to use a variable that has not been set" when I try to use the result.
The same thing happens when I try doing it without the function:
Code: [Select]
NotifyEvent(GetOwnScriptID,EV_REQUEST_IS_DURABLE_SPELL,[]);
let foo = GetScriptResult(GetOwnScriptID);
WriteLog(foo); //errors
Yielding between notifying the event and getting the result didn't help. I also tried notifying a different script (I added a case to my system script to test) with the same result.

So, I guess my question is "how the heck do I actually get something back from GetScriptResult?"
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Spacechurro on April 22, 2018, 09:16:43 PM
Hey guys, it's been a long while since I've been here, you probably don't even remember me but, I've gotten back into the roll of danmaku making and was having trouble with rolling a text that tells the player what the name of the spell is being cast. The Image works fine, but the text doesn't even appear. DanmakufuPH3

Code: [Select]
task SpellCast(Text){

let slideX = GetScreenWidth;
let slideY = 0;
let slidetxtX = 0;
let slidetxtY = GetScreenHeight/2;
let SpAnFr = 0;
let Alpha = 0;
let ZAngle = 0;
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
let txtobj = ObjText_Create();
//==========================================
ObjText_SetFontBorderType(txtobj,BORDER_FULL);
ObjText_SetFontSize(txtobj,10);
Obj_SetRenderPriority(txtobj,1);
ObjRender_SetX(txtobj,slidetxtX);
ObjRender_SetY(txtobj,slidetxtY);
ObjText_SetFontColorTop(txtobj,0,255,0);
ObjText_SetFontColorBottom(txtobj,0,255,0);
ObjText_SetFontBorderColor(txtobj,1,100,1);
ObjText_SetHorizontalAlignment(txtobj,ALIGNMENT_CENTER);
ObjText_SetSyntacticAnalysis(txtobj,true);
ObjText_SetAutoTransCenter(txtobj,true);
ObjText_SetFontBorderWidth(txtobj,2);
ObjText_SetText(txtobj,Text);
//============================================
ObjPrim_SetTexture(obj,imgSpell1);
ObjSprite2D_SetSourceRect(obj,0,0,1000,1000);
ObjSprite2D_SetDestCenter(obj);
ObjRender_SetBlendType(obj,BLEND_ALPHA);
ObjRender_SetAlpha(obj,Alpha);
ObjSprite2D_SetDestRect(obj, -500, -500, 500, 500);
ObjRender_SetScaleXYZ(obj,0.5,0.5,0);
ObjRender_SetAngleXYZ(obj,0,0,ZAngle);
Obj_SetRenderPriority(obj,0.95);
ObjRender_SetX(obj,slideX);
ObjRender_SetY(obj,slideY);

while(!Obj_IsDeleted(txtobj)){

ObjRender_SetX(obj,slideX);
ObjRender_SetY(obj,slideY);
ObjRender_SetX(txtobj,slidetxtX);
ObjRender_SetY(txtobj,slidetxtY);
ObjRender_SetAlpha(obj,Alpha);
ObjRender_SetAngleXYZ(obj,0,0,ZAngle);

if(SpAnFr<30){
slideX-=10;
slideY+=8;
slidetxtX+=(GetScreenWidth/2)/30;
Alpha+=255/30;
ZAngle-=(360/30);
}
if(SpAnFr>30&&SpAnFr<120){
slidetxtX+=0.1;
ZAngle-=0.2;
slideX-=0.1;
slideY+=0.1;
}
if(SpAnFr>120){
slidetxtX+=((GetScreenWidth/2)/30)-30;
slidetxtY-=((GetScreenHeight/2)/30)-30;
slideX-=10;
slideY+=8;
Alpha-=255/30;
ZAngle-=(360/30);
}
if(SpAnFr>300){
Obj_Delete(obj);
}
if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){Obj_Delete(txtobj);}
SpAnFr++;
yield;
}

}


The plan is that I can reuse it and plant whatever text I what appearing there. It's been a while since I've programmed so i'm probably missing some obvious stuff.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on April 22, 2018, 10:48:48 PM
The Image works fine, but the text doesn't even appear.
In order to use a horizontal alignment other than ALIGNMENT_LEFT, you need to use ObjText_SetMaxWidth first. Otherwise it doesn't know where the right boundary is, so how can it center it between the left and right boundaries?

Also, I would recommend putting that in a library instead of duplicating the code like it sounds like you're planning. Just put it in a file somewhere and put #include "./Library/Cutin.txt" (or whatever the path is) in any file you want to be able to use it.

Or better yet, instead of including it directly make one file that includes it, and include that file.
Index.txt:
Code: [Select]
#include "./Library/Cutin.txt"
#include "./Library/Resources.txt" //et
#include "./Library/Functions.txt" // cetera
Other_Script.dnh:
Code: [Select]
#include "./Index.txt"This way you can change what you're #including all in one place and you don't have to clutter up your scripts with a dozen #includes each.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 22, 2018, 11:45:57 PM
Hi people!
I want to make or understand a lot of things present in danmakufu, like:
Can some of you help me with that stuff?
(Already found the answer for the boss life)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on April 23, 2018, 02:21:53 AM
Hello!
I have just a simple question. How would you make danmaku with a zig-zaggy pattern?
Thanks!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on April 23, 2018, 03:08:42 AM
2. how to make life and spell piece
So there are a few different parts to that:
3. How to scale up the "out" of a item
I think you'd have to scale it up in the actual image.



I have just a simple question. How would you make danmaku with a zig-zaggy pattern?
Depends what you mean by "zig-zaggy". If you mean zig-zaggy like, say, Nue's snakes, you could do something like:
Code: [Select]
let dir = 1;
while(!Obj_IsDeleted(shot)){
ObjMove_SetAngularVelocity(shot,0.1*dir);
//or ObjMove_SetAngle(shot,a0+45*dir);
wait(30); dir*=-1;
}



Drake/Sparen/Helepolis/etc, I posted a few questions earlier - they've kind of been swallowed up by these other questions, so I figured I should say something or you probably wouldn't see them.

Actually, I've got another one as well. When you set the render scale of a shot, that doesn't change its hitbox, right? How do you change its hitbox when you scale it?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on April 23, 2018, 03:46:49 AM
@Andi Thank you! I'll keep that code in note but I meant danmaku that changes directions (like from left to right) continuously.  An example would be something like this:
https://i.ytimg.com/vi/oJZPZ6gETbQ/maxresdefault.jpg
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Spacechurro on April 23, 2018, 04:57:18 AM
@Andi Thank you! I'll keep that code in note but I meant danmaku that changes directions (like from left to right) continuously.  An example would be something like this:
https://i.ytimg.com/vi/oJZPZ6gETbQ/maxresdefault.jpg

If you want a way to move your object it's good to look at stuff like graphs in math. If you want something to "float" I usually add something with a cos or sin along with frame for example:
Code: [Select]
task example{
    let Frame=0;
    let y=12;
    loop(){
        Set_ObjY(obj,y);
        y+=sin(Frame);
        Frame++;
        wait(1);
    }
}
This doesn't reflect any existing functions in danmakufu and is just an example of using sin or cos to move an object up and down or left to right smoothly and repetitively.
But it really helps to figure loops out by doing calculations on graphs.
But also, that's for smooth movement.

If you want quit jaggered movements, you can just use x+=1;
and then when enough frames passes you can change it to x-=1 in another if statement.
Example:
Code: [Select]
task shoot{
    let Frame=0;
    let a=12;
    while(!Obj_IsDeleted(obj)){
        Set_Angle(obj,a);
        if(Frame<60){a+=1;}   //adding angle addition for current bullet
        if(Frame>60&&Frame<120){a-=1;}   //switching angle addition for current bullet
        if(Frame>120){Frame=0;}  //Resetting frame count
        Frame++;
        yield;
    }
}

Sparen's got a lot of very helpful tuts on here:
http://sparen.github.io/ph3tutorials/ph3tutorials.html

almost a whole directory and is still being updated.

I hope I helped!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 23, 2018, 10:14:58 AM
@Andi Thank you! I'll keep that code in note but I meant danmaku that changes directions (like from left to right) continuously.  An example would be something like this:
https://i.ytimg.com/vi/oJZPZ6gETbQ/maxresdefault.jpg
That pattern from Shuusou Gyoku doesn't have bullets that change direction, it's the firing angle that changes direction, and the bullets themselves just go straight but decelerate. If you can fire bullets with the angle increasing, you can do the same while decreasing it instead, and alternate between them for the intended effect. Here's an implementation of this, but note I took a shortcut for increasing/decreasing the angle.

Code: [Select]
let num_waves = 4;
let num_lines = 11;
let min = 0;
let max = 30;
let inc = 3;
let shots_per_wave = (max-min) / inc;
let z = min;
loop(num_waves){
  loop(shots_per_wave){
    ascent(i in 0..num_lines){
      CreateShotA2(192, 200, 4, (i*360/num_lines) + z, -0.1, 1.5, SHOT_RING_RED, 0);
    }
    z += inc;
    if(z <= min || z >= max){ inc *= -1; }
    loop(6){yield;}
  }
}

(Really this showcases cleaner pattern design than trying to do something fancier with complex bullet movement, since the unfolding of the danmaku and how the player will experience it is what is important, but that's an aside)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 23, 2018, 10:20:12 AM
Actually, I've got another one as well. When you set the render scale of a shot, that doesn't change its hitbox, right? How do you change its hitbox when you scale it?
Would have to do it manually. You can use ObjShot_GetImageID to get the shot graphic ID, GetShotDataInfoA1 to get the collision, and ObjShot_SetIntersectionCircleA1 (or A2 if necessary) to set the hitbox each frame. If you wanted to you could neatly package that all up into its own function like ObjShot_SetScale but I'm too lazy to do it right now.


GetScriptResult
The first trap is that you expect GetScriptResult to obtain the value that you've set with SetScriptResult as though it were returning from a function. If you're unaware of how the event scheduler works, when you trigger an event, it doesn't just run the script's event loop at that moment. (Note, the following is my interpretation) Instead, notifying an event adds the relevant information to a large queue of all events. On a given frame, a global event scheduler (I'm assuming it's global) takes the whole queue of events being triggered and messages the event data to the relevant scripts, and on that frame, that script's @Event routine will be run once for every new event put in that script's event queue. (That or there's another mechanism for scripts to add events to all other scripts' event queues somehow. Or, all events are done together outside of the individual script flow, but I doubt that.)

Because this is how event scheduling works, obviously if you use NotifyEvent somewhere, there is nothing to come back from GetScriptResult, as no events have actually been handled yet. Meanwhile, you could also question how you would get any useful information set with SetScriptResult; wouldn't two SetScriptResult calls overwrite each other? The answer is yes, if you do SetScriptResult(10); SetScriptResult(20);  then GetScriptResult(id) will return 20. That being said, as far as events go it doesn't even matter, because using SetScriptResult in @Event will not affect the value of GetScriptResult outside of @Event! I don't really know why, because script results do persist over time, but that's how it is. In other words, the second trap is expecting that SetScriptResult does anything useful for user events at all.

Note that the predefined events that make use of SetScriptResult to set values like life and the timer are only triggered at the beginning of the script load (not run) so clearly they have some special processing.

What you can do though, is use GetScriptResult(A) from a script B, even if A was closed. So more like the name suggests, it can be used as a "return value" for whole scripts. This is useful for game structure, and is already used for things like pause scenes and end scenes.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 23, 2018, 05:54:42 PM
So there are a few different parts to that:
  • Making the actual item that will add a life/spell piece. Probably the easiest part, it sounds like you've got that covered already based on your (3).
  • Making life/spell pieces actually function (add a life/spell after collecting enough). This is also relatively easy. There are a few approaches; I just add a fraction of a life/bomb (and multiply/round/divide by the number of pieces per life/spell to avoid floating point errors) and check if the integer part increased to decide which sound effect to play. Others use common data instead of the actual life/spell count.
  • Display life/spell pieces nicely. This is probably the hardest part if you haven't already set up your system script to display lives/bombs as sprites instead of numbers. If you have, it's a matter of displaying a different sprite for the fractional part. Here (https://pastebin.com/i4PnD012)'s the code I use to do it; your Default_System.png won't have the images I'm using so you'll need to mess with that.
I think you'd have to scale it up in the actual image.
Thanks Andi! You've helped me a lot with this post.
The code that you've posted took me some to figure out what to do to make that the life/spell appears correctly, but when I discovered what was going on I was like  :o .
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 23, 2018, 11:53:21 PM
Also, when I collect a life item, it doesn't add a life.
Here is the code:
Code: [Select]
case(EV_GET_ITEM){
if(GetEventArgument(0)==ITEM_LIFE_B_P){//life piece
SetPlayerLife(GetPlayerLife+1);
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 26, 2018, 12:42:42 AM
I don't really get much information from that snippet, especially when items have several places with relevant code. How have you defined the item type? Are you using an item script or just CreateItemU1?
You should test things in order:
1) Does the item appear
2) Does EV_GET_ITEM trigger
3) What is the item ID and what is ITEM_LIFE_B_P

I imagine the problem is at step 2?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 26, 2018, 01:25:40 AM
I don't really get much information from that snippet, especially when items have several places with relevant code. How have you defined the item type? Are you using an item script or just CreateItemU1?
You should test things in order:
1) Does the item appear
2) Does EV_GET_ITEM trigger
3) What is the item ID and what is ITEM_LIFE_B_P

I imagine the problem is at step 2?
I'm using CreateItemU1 in a task (to make that the item spawns like the newer games and does a y-angle spin).
I've made the item script just like a shot sheet, with a item data script (https://pastebin.com/kUVUmydv), item constant script (https://pastebin.com/aA0QBG6W) and a  item task script (https://pastebin.com/8faVvnmY), and that code snippet is in the player script (the only part that has item and EV_GET_ITEM involved)(2).
ITEM_LIFE_B_P is a life piece item that should add a common data to add a life piece, but to test purposes, I've made it to give a life(3).
I can spawn the item and it adds the score when I collect it (1)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 26, 2018, 02:22:48 AM
See https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1108259.html#msg1108259
Also https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1373257.html#msg1373257

This is why I asked if you were using an item script, and why I figured tests would fail at EV_GET_ITEM. What you have isn't an actual item script, it's an include with a bunch of tasks. In order to have user-defined items work properly you need to write an item script for them, rather than try to define the item behaviour in a player script.

If you really needed some player-specific behaviour on top of the regular item behaviour you could trigger extra events from the item script and handle that event in the player script, or manipulate ObjVals on the player object, or otherwise make fake items. But that doesn't seem to be the case here.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 26, 2018, 04:47:29 PM
See https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1108259.html#msg1108259
Also https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1373257.html#msg1373257

This is why I asked if you were using an item script, and why I figured tests would fail at EV_GET_ITEM. What you have isn't an actual item script, it's an include with a bunch of tasks. In order to have user-defined items work properly you need to write an item script for them, rather than try to define the item behaviour in a player script.

If you really needed some player-specific behaviour on top of the regular item behaviour you could trigger extra events from the item script and handle that event in the player script, or manipulate ObjVals on the player object, or otherwise make fake items. But that doesn't seem to be the case here.
I've read your tutorials, and merged both the Item Task and Item Const in a single script, and made some code to apply my tasks and item collection with events, as seen here (https://pastebin.com/FMktY3E7), but my item graphics are not appearing (but the "out" is).

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on April 26, 2018, 06:04:24 PM
if you use NotifyEvent somewhere, there is nothing to come back from GetScriptResult, as no events have actually been handled yet.
...
wouldn't two SetScriptResult calls overwrite each other?
I guessed at these issues, but yielding didn't seem to help so I put the first off (but still kept using yields when testing) and figured I'd deal with the second when I managed to get anything back at all.
That being said, as far as events go it doesn't even matter, because using SetScriptResult in @Event will not affect the value of GetScriptResult outside of @Event! I don't really know why, because script results do persist over time, but that's how it is. In other words, the second trap is expecting that SetScriptResult does anything useful for user events at all.
Oh. ...I do so love Danmakufu.

Alright, then. New way:
Code: [Select]
function Notify(type,event,args){
let id = GetScriptID(type);
let hash = GetNextHash(); //nothing fancy atm, just increments and returns an int
args = args ~ [ hash ];
if(id==ID_INVALID || type==SCRIPT_ALL || ((type==SCRIPT_PACKAGE)!=(GetOwnScriptID==GetScriptID(SCRIPT_PACKAGE))) ) {
NotifyEventAll(event,args);
}
else{
NotifyEvent(id,event,args);
}
return hash;
}
function SetEventResult(hash,result){
SetCommonData("EventResult"~itoa(hash), result);
yield; yield;
DeleteCommonData("EventResult"~itoa(hash));
}
function GetEventResult(hash){
let result = GetCommonData("EventResult"~itoa(hash), NULL);
DeleteCommonData("EventResult"~itoa(hash));
return result;
}

task SomeTask{
let evhash = Notify(SCRIPT_ITEM, EV_SPAWN_ITEM, [ I_EXTEND, ex,ey, ex,ey-30 ];
yield;
let item = GetEventResult(evhash);
ObjRender_SetAngleZ(item,180);
}
That seems to work.

Oh, random question. How the heck do I put a backslash in a char? '\' escapes the close ', '\\' throws an exception for being too long to go in a char, and let temp="\\"; temp[0] throws an exception as well.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 27, 2018, 05:42:57 PM
I've read your tutorials, and merged both the Item Task and Item Const in a single script, and made some code to apply my tasks and item collection with events, as seen here (https://pastebin.com/FMktY3E7), but my item graphics are not appearing (but the "out" is).
Discovered the bug, but I can't fix it.
It happens when I set the item as a variable like:
Code: [Select]
let obj = CreateItemU1(things);
How can I fix it?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on April 28, 2018, 01:06:33 AM
How can I make bullet trails?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 28, 2018, 02:25:06 AM
How can I make bullet trails?
I've seen a example of the kind of code that you want here (https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1295356.html#msg1295356).
You maybe will have to see some post before this one.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 28, 2018, 04:09:37 AM
Oh, random question. How the heck do I put a backslash in a char? '\' escapes the close ', '\\' throws an exception for being too long to go in a char, and let temp="\\"; temp[0] throws an exception as well.
Code: [Select]
"\\ "[0] ?
lol
If you need it for comparison purposes or something you can also cast characters into integers by char+0.

Discovered the bug, but I can't fix it.
It happens when I set the item as a variable like:
Code: [Select]
let obj = CreateItemU1(things);
How can I fix it?
Code: [Select]
ObjRender_SetScaleXYZ(obj,0.1,0.1,0)You set the z-scale for everything to 0 which like any other dimension makes it 0 length. It should be 1.
It only "bugs" when you assign the ID to a variable because otherwise the function doesn't act on it, of course.

Also you have a heck of a lot of code duplication.  You could very easily make it a lot more compact with
Code: [Select]
task SpawnItem(type,x,y,score,delay){
    loop(delay){yield;}
    let h1 = 0;
    let obj = CreateItemU1(type,x,y,score);
    let objRZAngle = ObjRender_GetAngleZ(obj);
    let objRYAngle = ObjRender_GetAngleY(obj);
    let objRXAngle = ObjRender_GetAngleX(obj);
    ObjRender_SetScaleXYZ(obj,0.1,0.1,1);
    ascent(i in 0..60){
        ObjRender_SetAngleZ(obj,objRZAngle+i*720/60+12);
        ObjRender_SetScaleXYZ(obj,(1.7/30)*i/2,(1.7/30)*i/2,1);
        yield;
    }
    loop{
        yield;
        ObjRender_SetAngleY(obj,objRYAngle+h1*6);
        h1++;
    }
}
// and then optionally
function SpawnLife(x,y,score,delay){
    SpawnItem(ITEM_LIFE_B,x,y,score,delay);
}
function SpawnSpell(x,y,score,delay){
    SpawnItem(ITEM_SPELL_B,x,y,score,delay);
}
// etc
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 29, 2018, 02:14:50 AM
Code: [Select]
ObjRender_SetScaleXYZ(obj,0.1,0.1,0)You set the z-scale for everything to 0 which like any other dimension makes it 0 length. It should be 1.
It only "bugs" when you assign the ID to a variable because otherwise the function doesn't act on it, of course.

Also you have a heck of a lot of code duplication.  You could very easily make it a lot more compact with
Code: [Select]
code
The bug was still in action when I do the let obj = CreateItemU1 OUTSIDE of the task, and when I change the Z-scale to 1, the outside of the stage(the frame) is turned to black.
Before I actually made a item script, I still had that bunch of tasks, and everything worked correctly. The problem started when I transferred the tasks into the item script.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 29, 2018, 07:01:03 AM
and when I change the Z-scale to 1, the outside of the stage(the frame) is turned to black.
wat

Can you just upload your folder or something, this is too strange for me to speculate about.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: SusiKette on April 29, 2018, 02:48:44 PM
I got this error message and I haven't found any place that explains what it means:

敵ライフを適切に返していません。(D:/th_dnh_ph3/script/test_script/Spell01.txt)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 29, 2018, 02:57:17 PM
wat

Can you just upload your folder or something, this is too strange for me to speculate about.
Here (http://www.mediafire.com/file/dyles51lbo37y6x/Tenshi_Hinanawi_Boss_Fight_by_Zino.rar)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: SusiKette on April 29, 2018, 03:00:15 PM
Never mind about my last post. Its not an issue for now. My next question is how do I store the shot id of the previously created shot?
Apparently this doesn't work.
Code: [Select]
CreateShotA1(BossX, BossY, 2, AimPlayer(), DS_BALL_S_RED, 10);
shot_id = return;
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on April 29, 2018, 04:25:30 PM
Code: [Select]
let shot_id = CreateShotA1(BossX, BossY, 2, AimPlayer(), DS_BALL_S_RED, 10);
CreateShotA1 is a built-in function that returns an Integer (Object ID) as a return type. You can store this return value in a variable.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: SusiKette on April 29, 2018, 04:38:36 PM
I guess I thought that using return; would be the value of the last thing a function returned.
My next question is that how you can make a bullet fly in a wavy motion? I know I need to use ObjMove_SetAngularVelocity(id, r);. I was hoping to make it so that the wavy motion started small and as the bullet travels further, the it would start waving further to each side.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 29, 2018, 05:38:03 PM
I guess I thought that using return; would be the value of the last thing a function returned.
My next question is that how you can make a bullet fly in a wavy motion? I know I need to use ObjMove_SetAngularVelocity(id, r);. I was hoping to make it so that the wavy motion started small and as the bullet travels further, the it would start waving further to each side.
You can make a task that plays a descent loop, and make that the bullet have a angular velocity, then wait, then have the same angular velocity, but negative.
You can increase the "waving" motion with the descent loop variable, like this:
Code: [Select]
task Waving(obj){
descent(i in 0..100){//a really big number to make things to not stop waving(number of times the bullet will wave)
ObjMove_SetAngularVelocity(obj,i/10);
loop(180/(i/10)){yield;}
ObjMove_SetAngularVelocity(obj,i/-10);
loop(180/(i/10)){yield;}
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on April 29, 2018, 10:10:26 PM
How would I add a sprite for a boss that is in a sprite sheet?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on April 29, 2018, 11:43:17 PM
I guess I thought that using return; would be the value of the last thing a function returned.
My next question is that how you can make a bullet fly in a wavy motion? I know I need to use ObjMove_SetAngularVelocity(id, r);. I was hoping to make it so that the wavy motion started small and as the bullet travels further, the it would start waving further to each side.

You should make the change angular velocity as well as the time between shifts dependent on time. I would have a descent loop that waits the number of frames in the loop constant, with the angular velocity likewise being dependent on the constant.

EDIT: Didn't realize there was already a code-based answer

How would I add a sprite for a boss that is in a sprite sheet?

What are you trying to do? If you have a sprite sheet and want to animate the boss, then you'll need to determine the dimensions of each sprite, then change the source rect in your Render Object depending on how much time has passed.

Below is an example the code I use. I have 4 128x128 sprites in a row that form the animation, and four states to represent idle/left/right/cast (the first row is idle, the second is left, etc). I've removed the cast/attack animation logic from the snippet below to make it shorter.

Code: [Select]
    let TDRAWSTATE_IDLE = 0;
    let TDRAWSTATE_LEFT = 1;
    let TDRAWSTATE_RGHT = 2;

    task TDrawLoop(path){
        let animframe = 1;
        let movestate = TDRAWSTATE_IDLE;
        ObjPrim_SetTexture(objBoss, path);
        ObjRender_SetScaleXYZ(objBoss, 1, 1, 1);
        let bossAngle = ObjMove_GetAngle(objBoss);
        let bossSpeed = ObjMove_GetSpeed(objBoss);
        ObjSprite2D_SetSourceRect(objBoss, 0, 0, 128, 128);
        ObjSprite2D_SetDestCenter(objBoss);
        while(!Obj_IsDeleted(objBoss)){
            bossAngle = ObjMove_GetAngle(objBoss) % 360;
            bossSpeed = ObjMove_GetSpeed(objBoss);

            if(bossSpeed > 0){ //below three cases require if statement to prevent reset of animframe.
                if((bossAngle > 270 || bossAngle < 90) && movestate != TDRAWSTATE_RGHT){
                    movestate = TDRAWSTATE_RGHT;
                    animframe = 0;
                }else if((bossAngle > 90 && bossAngle < 270) && movestate != TDRAWSTATE_LEFT){
                    movestate = TDRAWSTATE_LEFT;
                    animframe = 0;
                }else if((bossAngle == 90 || bossAngle == 270) && movestate != TDRAWSTATE_IDLE){
                    movestate = TDRAWSTATE_IDLE;
                    animframe = 0;
                }
            }else if(movestate != TDRAWSTATE_IDLE){ //if transitioning back to idle (speed = 0)
                movestate = TDRAWSTATE_IDLE;
                animframe = 0;
            }

            ObjSprite2D_SetSourceRect(objBoss, 0+floor(animframe/9)*128, 0 + 128*movestate, 128 + floor(animframe/9)*128, 128 + 128*movestate);

            animframe++;
            if(animframe >= 36){
                if(movestate == TDRAWSTATE_IDLE){ //animframe reset for idle
                    animframe = 0;
                }else{ //keep in current position if moving.
                    animframe = 35;
                }
            }
            yield;
        }
    }

Essentially, we have 128x128 sprites and the one we choose is dependent on animframe (9 frames per image, 4 images = 36 frames before we reset the idle animation). For my left and right movement, I keep the animation in the last image after the opening sequence plays, hence maintaining animframe at 35 at the end. If the boss is not moving, then they will not be kept in a movement state.

The line that handles choosing which sprite to use is the following:
ObjSprite2D_SetSourceRect(objBoss, 0+floor(animframe/9)*128, 0 + 128*movestate, 128 + floor(animframe/9)*128, 128 + 128*movestate);

floor(animframe/9)*128 represents which frame to use (first, second, third, or fourth) in the spreadsheet, while 128*movestate represents which animation to use (idle, left, right, or cast).

I hope this gives you a better sense of how to animate your sprite sheet.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on April 30, 2018, 01:26:49 AM
Yes that was exactly what i needed, thank you. This is going to sound like a dumb question ,but are the (path) parts referring to the path to the image or the TDRAWSTATES?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 30, 2018, 01:31:11 AM
Yes that was exactly what i needed, thank you. This is going to sound like a dumb question ,but are the (path) parts referring to the path to the image or the TDRAWSTATES?
To the path to image.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 30, 2018, 05:32:19 AM
And I have one more problem.
I have a function that spawns a enemy object like a bullet, and I can set the life, the angle, etc. like a bullet.
But when I set the life and shoot it, the life seems do not go down.
Here (https://pastebin.com/KXQ9djEq) is the link to the functions.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mellow on April 30, 2018, 05:42:55 AM
I'm having problem with finding my script in general.

I have a folder called "mine" in the scripts folder, and my .txt file script in "mine"
when i launch ph3, my .txt file doesn't show. i think i'm doing something wrong, but I don't know what...  :matsuriscowl:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on April 30, 2018, 05:43:57 AM
Do the bullets go through the enemy or stop at it?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 30, 2018, 05:55:02 AM
Do the bullets go through the enemy or stop at it?
They stop.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 30, 2018, 06:47:06 AM
Here (http://www.mediafire.com/file/dyles51lbo37y6x/Tenshi_Hinanawi_Boss_Fight_by_Zino.rar)
First, you write let obj = 0; and then proceed to manipulate obj. 0 is the ID of an object; it isn't just nothing! Use -1 if you want to use a dummy value for referencing objects. This is why you're getting the bad STG frame.

Second, the reason your stuff wouldn't work properly once you put the item object in the variable is because you have no MainLoop in the item script and therefore no yield in your MainLoop, so none of your tasks will progress.

Third, as a precaution using loop is bad here because there is no way to exit and so the tasks will live as long as the script does.

Here is a small rewrite, including the suggestion I made earlier (add a yielded MainLoop):
Code: [Select]
task SpawnItem(type, x, y, score, delay){
loop(delay){yield;}
let obj = CreateItemU1(type, x, y, score);
ascent(i in 0..60){
ObjRender_SetAngleZ(obj, 2*(720/60)*i);
ObjRender_SetScaleXYZ(obj, 0.1+(0.9/60)*i, 0.1+(0.9/60)*i, 1);
yield;
}
ObjRender_SetAngleZ(obj, 0);
ObjRender_SetScaleXYZ(obj, 1, 1, 1);
let h1 = 0;
while(!Obj_IsDeleted(obj)){
ObjRender_SetAngleY(obj, h1*6);
h1++;
yield;
}
}
function SpawnLife(x, y, score, delay){
SpawnItem(ITEM_LIFE_B, x, y, score, delay);
}
function SpawnLifePiece(x, y, score, delay){
SpawnItem(ITEM_LIFE_B_P, x, y, score, delay);
}
function SpawnSpell(x, y, score, delay){
SpawnItem(ITEM_SPELL_B, x, y, score, delay);
}
function SpawnSpellPiece(x, y, score, delay){
SpawnItem(ITEM_SPELL_B_P, x, y, score, delay);
}
You could then also trim your event cases with
Code: [Select]
case(EV_USER+1000){ // Spawn Item event
let args = GetEventArgument(0);
SpawnItem(args[0], args[1], args[2], args[3], args[4]); // type, x, y, score, delay
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 30, 2018, 07:18:10 AM
And I have one more problem.
I have a function that spawns a enemy object like a bullet, and I can set the life, the angle, etc. like a bullet.
But when I set the life and shoot it, the life seems do not go down.
Here[url] is the link to the functions.
 (https://pastebin.com/KXQ9djEq)
The delete-when-0-life task just checks once and then immediately ends. Should be
Code: [Select]
task DeleteEnemyWhenLife0(obj){
while(ObjEnemy_GetInfo(obj,INFO_LIFE) > 0){ yield; }
Obj_Delete(obj);
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: SusiKette on April 30, 2018, 10:23:32 AM
You can make a task that plays a descent loop, and make that the bullet have a angular velocity, then wait, then have the same angular velocity, but negative.
You can increase the "waving" motion with the descent loop variable, like this:
Code: [Select]
task Waving(obj){
descent(i in 0..100){//a really big number to make things to not stop waving(number of times the bullet will wave)
ObjMove_SetAngularVelocity(obj,i/10);
loop(180/(i/10)){yield;}
ObjMove_SetAngularVelocity(obj,i/-10);
loop(180/(i/10)){yield;}
}
}

The bullet is doing a wavy motion, but its I don't see a change in the interval the motion is reversed. I tried changing the values but I'm not able to get it to work that way either.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on April 30, 2018, 01:43:58 PM
Still having problems with multi phased nonspells/spells, it doesn't work....
Here (https://pastebin.com/aXKkAnjh) is a part of my script
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on April 30, 2018, 02:04:06 PM
Still having problems with multi phased nonspells/spells, it doesn't work....
Here (https://pastebin.com/aXKkAnjh) is a part of my script

I see literally nothing in that script that compares boss health against a constant except for preventing 0,0 spawning...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on April 30, 2018, 02:20:29 PM
I see literally nothing in that script that compares boss health against a constant except for preventing 0,0 spawning...
I don't get it, what should I do?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 30, 2018, 03:02:06 PM
First, you write let obj = 0; and then proceed to manipulate obj. 0 is the ID of an object; it isn't just nothing! Use -1 if you want to use a dummy value for referencing objects. This is why you're getting the bad STG frame.

Second, the reason your stuff wouldn't work properly once you put the item object in the variable is because you have no MainLoop in the item script and therefore no yield in your MainLoop, so none of your tasks will progress.

Third, as a precaution using loop is bad here because there is no way to exit and so the tasks will live as long as the script does.

Here is a small rewrite, including the suggestion I made earlier (add a yielded MainLoop):
Code: [Select]
task SpawnItem(type, x, y, score, delay){
loop(delay){yield;}
let obj = CreateItemU1(type, x, y, score);
ascent(i in 0..60){
ObjRender_SetAngleZ(obj, 2*(720/60)*i);
ObjRender_SetScaleXYZ(obj, 0.1+(0.9/60)*i, 0.1+(0.9/60)*i, 1);
yield;
}
ObjRender_SetAngleZ(obj, 0);
ObjRender_SetScaleXYZ(obj, 1, 1, 1);
let h1 = 0;
while(!Obj_IsDeleted(obj)){
ObjRender_SetAngleY(obj, h1*6);
h1++;
yield;
}
}
function SpawnLife(x, y, score, delay){
SpawnItem(ITEM_LIFE_B, x, y, score, delay);
}
function SpawnLifePiece(x, y, score, delay){
SpawnItem(ITEM_LIFE_B_P, x, y, score, delay);
}
function SpawnSpell(x, y, score, delay){
SpawnItem(ITEM_SPELL_B, x, y, score, delay);
}
function SpawnSpellPiece(x, y, score, delay){
SpawnItem(ITEM_SPELL_B_P, x, y, score, delay);
}
You could then also trim your event cases with
Code: [Select]
case(EV_USER+1000){ // Spawn Item event
let args = GetEventArgument(0);
SpawnItem(args[0], args[1], args[2], args[3], args[4]); // type, x, y, score, delay
}
Oh, now I understand, and I don't get why your SpawnLife/Spell is a function. Can't it be a task?
And I've completely forgot about the MainLoop.
Now the code works correctly.
Thank you.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gregory on April 30, 2018, 04:31:41 PM
I don't get it, what should I do?

you should write a more specific health check from the Boss that does something from A to B  and if it passes the 1st threshold it will do the next from B to C
Code: [Select]
while(ObjEnemy_GetInfo(enm,INFO_LIFE)>=7000){

yield;}

while(ObjEnemy_GetInfo(enm,INFO_LIFE)<=7000 && ObjEnemy_GetInfo(enm,INFO_LIFE)>= 4500){

yield;}

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on April 30, 2018, 06:53:39 PM
I am trying to recreate something similar to Mokou's first non-spell, to create the rows of bullets would you use ascent loops and loose lasers or is there a better way to do that.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on April 30, 2018, 09:36:41 PM
you should write a more specific health check from the Boss that does something from A to B  and if it passes the 1st threshold it will do the next from B to C
That's not what I want; what I'm looking for is nons/spells like this (https://www.youtube.com/watch?v=NYmDX8IyLXY)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 30, 2018, 10:04:40 PM
Oh, now I understand, and I don't get why your SpawnLife/Spell is a function. Can't it be a task?
They're pretty minor reasons. I really just did it for the semantics difference, it isn't important. The most significant thing for general use is that you can return values from functions but not tasks, so while I don't do it there you could restructure SpawnItem a bit to be a function that runs an internal task and returns the item object ID, then return that ID again from e.g. SpawnLife. That way you'd have access to the item object inside the event call if you needed it for whatever reason.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on April 30, 2018, 11:41:54 PM
Where I can learn how to make a package script?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on May 01, 2018, 01:30:28 AM
I don't think there are any tutorials on them yet, but there's an example package script that comes included with Danmakufu. Looking at that and the relevant functions (https://dmf.shrinemaiden.org/wiki/Package_Functions) is generally enough to make a serviceable package script.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on May 01, 2018, 06:54:13 AM
That's not what I want; what I'm looking for is nons/spells like this (https://www.youtube.com/watch?v=NYmDX8IyLXY)

task Main {
    while (health>0){
        A; wait(180):
        B; wait(270);
        etc
    }
}

then have tasks A/B etc
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on May 02, 2018, 06:52:16 PM
Anyone mind helping me try to replicate some spells and nonspells so I can understand how they work?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 02, 2018, 10:45:59 PM
Is there a way to disable the item score?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 02, 2018, 10:48:53 PM
Anyone mind helping me try to replicate some spells and nonspells so I can understand how they work?
I can help you with some things, but I'm not an expert
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on May 02, 2018, 11:20:40 PM
I am trying to figure out the best way to replicate something similar to Mokou's first non-spell, yet I can't seem to see if loose lasers or bullets are better to create the effect. Then if it would be better to use ascent loops or just to use regular loops. I still can't figure out how to make the bullets rotate in just one direction and not oscillate.
I can help you with some things, but I'm not an expert
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 03, 2018, 12:15:20 AM
Is there a way to disable the item score?
I don't know what you mean by this.

I am trying to figure out the best way to replicate something similar to Mokou's first non-spell, yet I can't seem to see if loose lasers or bullets are better to create the effect. Then if it would be better to use ascent loops or just to use regular loops. I still can't figure out how to make the bullets rotate in just one direction and not oscillate.
Mokou's first non-spell? Why are you thinking about lasers; there are no lasers involved. The bullets also don't rotate? It's the firing angle that rotates. I don't know which pattern you're referring to with that description.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 03, 2018, 12:30:52 AM
I don't know what you mean by this.
Like take out the score that the item gives you, because if I set to 0, it still appears near the character.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 03, 2018, 01:31:21 AM
Replace the stuff in resource/img/System_Stg_Digit.png with just black. I'm not sure if it's possible to overwrite the system resources on a script-by-script basis.

EDIT: ↓ wow i'm dumb
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 03, 2018, 02:13:47 AM
Is there a way to disable the item score?

Are you referring to the actual score or just the text? If it's just the text, refer to:
https://dmf.shrinemaiden.org/wiki/Item_Object_Functions#ObjItem_SetRenderScoreEnable

I use this function in order to use my own custom text styling for item scoring
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on May 03, 2018, 01:53:32 PM
This is the non spell I was talking about,(https://youtu.be/xl17uhqSuqc). What I meant was, I cannot figure out if I used CreateShotA1, how to get it to replicate similar effects to how it rotates around the boss and has multiple rows of bullets coming from three points.
I don't know what you mean by this.
Mokou's first non-spell? Why are you thinking about lasers; there are no lasers involved. The bullets also don't rotate? It's the firing angle that rotates. I don't know which pattern you're referring to with that description.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 03, 2018, 02:02:16 PM
This is the non spell I was talking about,(https://youtu.be/xl17uhqSuqc). What I meant was, I cannot figure out if I used CreateShotA1, how to get it to replicate similar effects to how it rotates around the boss and has multiple rows of bullets coming from three points.

I recommend reading http://sparen.github.io/ph3tutorials/ph3u1l7.html

The caveat is that Mokou's lines of bullets aren't all the same angle but I'm confident that you can figure out how to make those adjustments in the nested loop structure :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 03, 2018, 06:47:20 PM
How can I change the width (the actual width, not the render one) of a laser object (I'm using the objshot create and regist method).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 03, 2018, 06:51:33 PM
How can I change the width (the actual width, not the render one) of a laser object (I'm using the objshot create and regist method).

Please refer to https://dmf.shrinemaiden.org/wiki/Functions_(ph3)#Shot_Object_Functions where you should find a function that does exactly that.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 03, 2018, 09:27:53 PM
I'm making a player script but the laser damage jus keep adding up unintentionally.
Here is the code:
Code: [Select]
task ShotU1{
while(true){
let las = -1;
if(Shooting){
let angleT= 270-2.5;
ascent(i in 0..2){
las = ObjShot_Create(OBJ_STRAIGHT_LASER);
ObjShot_Regist(las);
ObjShot_SetAutoDelete(las, false);
ObjShot_SetGraphic(las, 3);
ObjShot_SetDamage(las, 0.01);
ObjShot_SetPenetration(las, 3);
ObjLaser_SetLength(las, 512);
ObjLaser_SetRenderWidth(las,8);
ObjStLaser_SetAngle(las,angleT);
KeepAtObj(las,playerID);
angleT+=5;
deleteinloop(las);
}
yield;
}
yield;
}
}
task deleteinloop(las){
while(!Obj_IsDeleted(las)){
if(!Shooting){
Obj_Delete(las);
}yield;
}
}
task KeepAtObj(obj,obj1){
while(!Obj_IsDeleted(obj)){
ObjMove_SetPosition(obj,ObjRender_GetX(obj1),ObjRender_GetY(obj1));
yield;
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on May 03, 2018, 10:50:30 PM
I'm not really sure that's a good way to make a laser? If you look closely at, say, Marisa's lasers, they actually consist of small bullets being fired along coloured lines. I didn't even know you COULD make straightlasers that deal damage to enemies. The other problem is that you're creating a laser every single frame while the player is shooting, but only delete the lasers once the player stops shooting. Assuming that your way of making a player laser even works[Its much different then the method I use], you should be able to fix the stacking laser problem by replacing the yield after the ascent loop with while(shooting){yield;}. I'm also not sure why the ascent loop makes two lasers, since they both end up occupying the exact same location. Either make only one laser or have the lasers be in different places.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 03, 2018, 11:24:20 PM
I'm not really sure that's a good way to make a laser? If you look closely at, say, Marisa's lasers, they actually consist of small bullets being fired along coloured lines. I didn't even know you COULD make straightlasers that deal damage to enemies. The other problem is that you're creating a laser every single frame while the player is shooting, but only delete the lasers once the player stops shooting. Assuming that your way of making a player laser even works[Its much different then the method I use], you should be able to fix the stacking laser problem by replacing the yield after the ascent loop with while(shooting){yield;}. I'm also not sure why the ascent loop makes two lasers, since they both end up occupying the exact same location. Either make only one laser or have the lasers be in different places.
I've see this way of laser at the Random Player Generator.
Now I see the problem, I was having it right at the beginning, but a sudden change in code made me think of taking it out.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 04, 2018, 04:33:05 PM
Is there a function to get the ID of the nearest enemy of the player?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on May 04, 2018, 06:33:17 PM
I've got the ascent loops working how I want them to but I can't figure out how the bullets spin around Mokou.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 04, 2018, 08:04:52 PM
Is there a function to get the ID of the nearest enemy of the player?

Use GetAllEnemyID and the Distance Formula.

I've got the ascent loops working how I want them to but I can't figure out how the bullets spin around Mokou.
Hint: increment the angle using the loop variable as a parameter :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 04, 2018, 10:27:41 PM
My player doesn't change the focus shot when I change to unfocus, but changes the unfocus shot when I change to focus (this may be a little hard to understand).
Here is the code:
Code: [Select]
task ShotU1{
while(true){
let las = -1;
let las1 = -1;
if(Shooting){
ascent(i in 0..1){
las = ObjShot_Create(OBJ_STRAIGHT_LASER);
ObjShot_Regist(las);
ObjShot_SetAutoDelete(las, false);
ObjShot_SetGraphic(las, 1016);
ObjShot_SetDamage(las, 5);
ObjShot_SetPenetration(las, 3);
ObjLaser_SetLength(las, 512);
ObjLaser_SetRenderWidth(las,20);
ObjLaser_SetIntersectionWidth(las,20);
ObjStLaser_SetAngle(las,270);
KeepAtObj(las,playerID);
deleteinloop(las);
ObjStLaser_SetSource(las,false);
Obj_SetRenderPriorityI(las,79);
}
while(Shooting&&!isFocus){
let angleT= 270-(360/72)*2;
ascent(i in 0..72/16){
let obj = CreatePlayerShotA1(ObjRender_GetX(ObjOption),ObjRender_GetY(ObjOption),5,angleT,10,1,879);
let obj1 = CreatePlayerShotA1(ObjRender_GetX(ObjOption1),ObjRender_GetY(ObjOption1),5,angleT,10,1,879);
angleT+=360/72;
ObjRender_SetColor(obj,0,0,0);
ObjRender_SetColor(obj1,0,0,0);
}
wait(5);
}
if(Shooting&&isFocus){
ascent(i in 0..1){
las = ObjShot_Create(OBJ_STRAIGHT_LASER);
ObjShot_Regist(las);
ObjShot_SetAutoDelete(las, false);
ObjShot_SetGraphic(las, 1016);
ObjShot_SetDamage(las, 5);
ObjShot_SetPenetration(las, 3);
ObjLaser_SetLength(las, 512+256);
ObjLaser_SetRenderWidth(las,20);
ObjLaser_SetIntersectionWidth(las,20);
KeepAtObj(las,ObjOption);
deleteinloop(las);
ObjStLaser_SetSource(las,false);
Obj_SetRenderPriorityI(las,79);

las1 = ObjShot_Create(OBJ_STRAIGHT_LASER);
ObjShot_Regist(las1);
ObjShot_SetAutoDelete(las1, false);
ObjShot_SetGraphic(las1, 1016);
ObjShot_SetDamage(las1, 5);
ObjShot_SetPenetration(las1, 3);
ObjLaser_SetLength(las1, 512+256);
ObjLaser_SetRenderWidth(las1,20);
ObjLaser_SetIntersectionWidth(las1,20);
KeepAtObj(las1,ObjOption1);
deleteinloop(las1);
ObjStLaser_SetSource(las1,false);
Obj_SetRenderPriorityI(las1,79);
while(!Obj_IsDeleted(las)&&!Obj_IsDeleted(las1)){
let enemy = GetAllEnemyID;
let dist = [];
let nearestID = 0;
let distA2 = [0];
ascent(i in 0..length(enemy)){
let distV = [GetDistance(ObjMove_GetX(enemy[i]),ObjMove_GetY(enemy[i]),GetPlayerX,GetPlayerY)];
dist = dist ~ distV;
}
ascent(i in 0..length(dist)){
let distnrst = min(dist[i],dist[max(i-1,0)]);
let distnrstA = [distnrst];
distA2 = distA2 ~ distnrstA;
if(distA2[i] == distnrst){nearestID++;}
}
ObjStLaser_SetAngle(las,GetAngleToObj(las,enemy[nearestID]));
ObjStLaser_SetAngle(las1,GetAngleToObj(las1,enemy[nearestID]));
yield;
}
}
}
while(Shooting){yield;}
}
yield;
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on May 04, 2018, 11:25:57 PM
Hello;

I have a question regarding Danmakufu's tasks - Is there a performance/processing cost connected to calling tasks recursively, as opposed to repeating said tasks with loops?

Thanks in advance.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on May 04, 2018, 11:37:53 PM
What's the best way to freeze the bonus on spells? Without putting the timer to 999.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 05, 2018, 12:00:04 AM
My player doesn't change the focus shot when I change to unfocus, but changes the unfocus shot when I change to focus (this may be a little hard to understand).
Here is the code:
Code: [Select]

A few things:
First, please pastebin large blobs of code
Second, you have no comments or anything within your code designating your intention or what you are trying to do
Finally, I have no idea where this is being called from, how you are setting variable such as Shooting or isFocus, etc. Please provide more context for your problem.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 05, 2018, 01:00:09 AM
A few things:
First, please pastebin large blobs of code
Second, you have no comments or anything within your code designating your intention or what you are trying to do
Finally, I have no idea where this is being called from, how you are setting variable such as Shooting or isFocus, etc. Please provide more context for your problem.
1.I'm sorry, I didn't realize that it was so big.
2.Here is the code with a hell lot of comments (https://pastebin.com/3tiqEh5h).
3.It is in the comments above.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 05, 2018, 02:36:32 AM
1.I'm sorry, I didn't realize that it was so big.
2.Here is the code with a hell lot of comments (https://pastebin.com/3tiqEh5h).
3.It is in the comments above.

Some brief notes that may help you with your code:
- I suggest using tasks for your lasers, as they all seem to behave similarly and you are duplicating a wall of code
- I suggest reviewing how while loops work, as you do not seem to understand how to properly use them. When you use a while loop, only the code inside the while loop will execute until the condition for the while loop is no longer met or you break; or return; out of the loop. Once again, I will suggest using tasks, as this will allow you to run multiple while loops in parallel.

From what I can see, your logic for determining how to fire is flawed, mainly due to your use of while loops and the way you are handling your code. Once you've moved your laser creating code to a task, it should be possible to view the entirety of your ShotU1 on your computer screen at once. I suggest stepping through your code - suppose the player is currently focusing/unfocusing, and see what loops would execute. Then see what happens when the player changes to the other/stops shooting/etc. You should be able to figure out where your problem is as long as you try out the situations that didn't work and see how your code resulted in the observed behavior.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: PyuDi on May 05, 2018, 02:50:54 AM
How can I make bullets that orbit around the specified circle?
(Ex. https://m.youtube.com/watch?v=FqdWq4QNWto )
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 05, 2018, 07:35:30 AM
In the future note you can append something like #t=5m25s to the end of a Youtube link to timestamp it. Otherwise we have to go through the whole video to find what you're referring to.

Any point around a circle can be described as being at a certain distance (or radius) from the center, and at a certain angle from the center.

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

Note here the point is radius R from the center and at angle A. Like the image shows, you can turn these into x,y coordinates with x = R*cos(A) and y = R*sin(A).

All you really need to do to have a thing orbit a point, then, is to have it at some radius, and have the angle increase or decrease over time. Look at the image and see that if A just keeps increasing while R stays the same, the point will travel along the circle.

This will usually look something like this in code:
Code: [Select]
let x0 = 192; // center x-position
let y0 = 224; // center y-position
let r = 50; // radius
let a = 0; // angle
while(!Obj_IsDeleted(obj)){ // some loop
  ObjMove_SetPosition(obj, x0 + r*cos(a), y0 + r*sin(a));
  a++;
  yield;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on May 05, 2018, 05:07:46 PM
So I just noticed that loose lasers have to "extend" again anytime you set their position. Is there any way around this?
(I've got a sort of "tree" of loose lasers and I'd like to have them shake around a bit before breaking away. Currently I'm just changing their angle, but that makes the "tail" shake much more than the "head". Considering trying to seamlessly swap them out with straight lasers for the shaking around bit, but that wouldn't help if I wanted to actually change its position.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on May 05, 2018, 10:47:14 PM
Is there any place that I can learn how to make Dialogue?Or there is a "universal" template/function in here?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 06, 2018, 01:10:59 AM
So I just noticed that loose lasers have to "extend" again anytime you set their position. Is there any way around this?
(I've got a sort of "tree" of loose lasers and I'd like to have them shake around a bit before breaking away. Currently I'm just changing their angle, but that makes the "tail" shake much more than the "head". Considering trying to seamlessly swap them out with straight lasers for the shaking around bit, but that wouldn't help if I wanted to actually change its position.)
It often makes sense for it to work this way due to the behaviour of the lasers. A bit weird this is mandatory, but I don't really think there's a proper way to get around it. Two options:
1) If you wanted to change its position once at max length, it would make sense to swap into a straight laser.
2) It is possible to set position, set speed to laser length, wait one frame then set speed back to 0, but this is pretty weird and you do need the one frame gap in between each move for the speed calc to apply.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on May 06, 2018, 01:17:43 AM
It often makes sense for this to happen due to the behaviour of the lasers, but I don't really think there's a nice way to do so. Two options:
1) If you wanted to change its position once at max length, it would make sense to swap into a straight laser.
2) It is possible to set position, set speed to laser length, wait one frame then set speed back to 0, but this is pretty weird and you do need the one frame gap in between each move for the speed calc to apply.

Would it work if you had multiple lasers already created in the shaking positions and then toggled visibility between them? I don't know if hitbox detection can be disabled as well for invisible objects, but if they are not generated near to the player would it create the visual effect?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 06, 2018, 03:07:38 PM
Is there any place that I can learn how to make Dialogue?Or there is a "universal" template/function in here?
You can make a dialogue by showing a image and text in a specific timing, and make that the player cannot shoot and can skip it with VK_OK.
Edit to prevent double post:
How do I flip only one part of the camera, like half the screen is flipped?(I mean flip like Seija)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: [INSERT USERNAME HERE] on May 06, 2018, 06:30:53 PM
How can replicate the patterns that fairies shoot in SA Stage 4?
You know, they shoot 30-40 amulets stacked on, some time passes, then they turn a certain amount of degrees, some of them even start going backwards...

Don't kill me plz I'm new to Danmakufu

Edit: Ehh never mind I guess I've found a way to do it. -_-
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on May 06, 2018, 10:59:20 PM
That's probably impossible to do with the basic camera functions. I don't doubt that its possible to do that, but its definitely a far greater undertaking then just flipping the whole screen around.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 06, 2018, 11:58:00 PM
That's probably impossible to do with the basic camera functions. I don't doubt that its possible to do that, but its definitely a far greater undertaking then just flipping the whole screen around.
I think render targets should do it, but it is so complicated to mess with it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 07, 2018, 05:36:44 AM
How do I flip only one part of the camera, like half the screen is flipped?(I mean flip like Seija)

Looking for flipping the screen like with Seija? Look no farther than the Danmakufu ph3 Tutorials (http://sparen.github.io/ph3tutorials/ph3tutorials.html)! For future reference, the topics highlighted in each lesson are bulletpointed on the page.

You will find details on the 2D Camera functions and their usage in Extra Lesson 4 (http://sparen.github.io/ph3tutorials/ph3u2l22a.html).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on May 07, 2018, 06:19:26 AM
Looking for flipping the screen like with Seija?
I think they were actually asking how to do that to only part of the screen.
Pretty sure you'd need to use render targets for that. Maybe look at SampleE02 for an example, that sort of bulges part of the screen instead of flipping it but the concept is similar.



I'm trying to put together some functions to set SpeedX, AccelerationY, etc individually instead of having to spell out every parameter in an AddPatternB*. To do this, I'm using AddPatternB2 with NO_CHANGE for all but the desired property - and, of course, x/y max speed because NO_CHANGE doesn't work on max speed for some reason (why is that, by the way?). For that I use the value stored by my custom versions of built-in functions, or, failing that, 99 times the sign of the relevant speed. I'm having a lot of issues, and until just now had very little idea why. (Well, I had plenty of ideas for things that might not work about what I was doing, but not with the particular results I was getting.)

I've just realized that the point of failure here is probably my OM_Get[X/Y]Speed function, since it only gets stored in the dictionary when I first set it and not when it changes due to acceleration. Now trying to calculate it from time since setting it, but one-half-a-t-squared isn't gonna do the job and I've had no luck incorporating max speed into the formula.

Do you have a formula for how acceleration and maxspeed are applied each frame? Preferably separate ones for SA-style and XY-style movement?
Ones with t (closed-form or otherwise) would be nice as well, but I can probably derive those myself given the per-frame ones if necessary.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on May 07, 2018, 04:26:00 PM
I'm trying to create a Reimu player, but I can't make the player's sprite change when going to left or right.
Here's the player script (https://pastebin.com/sVsgkgkP), the shot data (https://pastebin.com/DKFm4uRb) and a collection of functions (https://pastebin.com/gfhD6vgC)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on May 07, 2018, 06:09:13 PM
I'm trying to create a Reimu player, but I can't make the player's sprite change when going to left or right.
Here's the player script (https://pastebin.com/sVsgkgkP), the shot data (https://pastebin.com/DKFm4uRb) and a collection of functions (https://pastebin.com/gfhD6vgC)
ObjMove_GetAngle isn't going to work for the player. Consider how the controls work: X and Y speed are controlled separately, so it won't work any more than it would for a shot that's been AddPatternB1'd (and there's no function to get X/Y speed, either, which is what I'm currently struggling with). And that's assuming it even uses speeds instead of just setting position.
Instead, use GetVirtualKeyState(VK_LEFT/RIGHT). Something like:
Code: [Select]
let L = GetVirtualKeyState(VK_LEFT )==KEY_HOLD || GetVirtualKeyState(VK_LEFT )==KEY_PUSH);
let R = GetVirtualKeyState(VK_RIGHT)==KEY_HOLD || GetVirtualKeyState(VK_RIGHT)==KEY_PUSH);
if(     L && !R){ AnimLeft;  }
else if(R && !L){ AnimRight; }
else{             AnimStill; }
Other notes:
-Why do you need to mess with YAngle? Is that just a quick patch until you get around to changing which rects are used for which direction?
-You still have her description as "Ordinary Magician".
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 07, 2018, 10:53:50 PM
There is at least one tutorial for player scripts: https://www.youtube.com/watch?v=Dtn5EtPsJjc

And you can look at other player scripts for more direction on what to do.

As a minor detail, your animation is timed slightly off because you use non-integers in the comparisons but increment by integers. Each animation frame will alternate between 7 and 8 frames.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 08, 2018, 01:08:56 AM
Do render targets keep updating? (Like you don't need to create a gazillion render targets to keep it new and fresh)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 08, 2018, 02:56:37 AM
Once you render to the target it stays as that texture until you draw more on top or clear it. If you want it to change every frame you'll need to clear the target every frame to redraw.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on May 08, 2018, 06:52:01 PM
I've tried to make the design I have made spin yet I have not figured out how to make it spin, here is the code
https://pastebin.com/rQBPiaHw
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on May 08, 2018, 09:55:54 PM
Instead, use GetVirtualKeyState(VK_LEFT/RIGHT). Something like:
Code: [Select]
let L = GetVirtualKeyState(VK_LEFT )==KEY_HOLD || GetVirtualKeyState(VK_LEFT )==KEY_PUSH);
let R = GetVirtualKeyState(VK_RIGHT)==KEY_HOLD || GetVirtualKeyState(VK_RIGHT)==KEY_PUSH);
if(     L && !R){ AnimLeft;  }
else if(R && !L){ AnimRight; }
else{             AnimStill; }
It works but the sprite keeps bugging(blinking or out scaling) each time it changes the direction
The player (https://pastebin.com/m6KpyYNb), I didn't change anything else...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on May 09, 2018, 03:51:07 AM
It works but the sprite keeps bugging(blinking or out scaling) each time it changes the direction
Some of your rects are messed up. The second one for left, (35, 50, 59, 141), and the second for right, (35, 98, 59, 93), seem to have their bottom borders swapped.

Another potential issue I noticed: Using the same variable for each direction and only resetting it when going in neither direction, plus not doing anything if it's above 56, means that the player's sprite will stay facing the wrong direction if you release one direction and press the other one frame apart.


Edit to avoid double-posting:
(^Text glow to help this not get lost, since that's happened a few times lately when I ask questions in edits.)
(Speaking of which, I still need those formulae for how acceleration/max speed are applied.)


Today I was working on my package script, minding my own business, when all of a sudden everything between the background and the overlay (not everything in the stage frame - just certain priorities, I think) starts rendering somewhere around GetScreenWidth/2 to the left of where it's supposed to be when I start the game (any mode) through the package.
I'm pretty sure the only things I had been messing with when it started happening were the package (and the two libraries accompanying it), the player script, and (maybe) the pause script. Of those, the only thing I can think of that was really related to render priorities was changing the priorities of some of the effects in the player script in an attempt to fix a bug where the parts that are supposed to be transparent (ADD_RGB) aren't. While doing so I changed them from SetRenderPriority to SetRenderPriorityI, if that matters.

Honestly, though, I basically just have absolutely no idea why this has started happening. Here (https://github.com/JonAjuhan/cs401Project)'s all of the code.

E: Whatever is causing it definitely involves GetScreenWidth. I changed the screen size in th_dnh.def as a test and all affected objects went off the screen entirely.
EE: It seems to return to normal at the end of a stage? Not when the stage scene is closed, but during the dialogue single at the end of the fight, after the boss explodes and is deleted. Happens with both dialogue singles I have to test.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on May 10, 2018, 07:32:58 PM
Every time I try to run my script as a plural script Danmakufu crashes. I can't figure out why it does.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 10, 2018, 08:43:49 PM
Every time I try to run my script as a plural script Danmakufu crashes. I can't figure out why it does.

We have no context. What script are you trying to run, and what do you mean by 'try to run my script as a plural script'? Without this information, it will be hard to help you. :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enderswift117 on May 10, 2018, 09:56:35 PM
We have no context. What script are you trying to run, and what do you mean by 'try to run my script as a plural script'? Without this information, it will be hard to help you. :)
These are the pastebin uploads for all the files, what i meant was transferring the single scripts to a plural script and then running it, but every time I run it Danmakufu crashes.
Attack.txt - https://pastebin.com/VgLW4V66
Eternallight.txt - https://pastebin.com/LGsNvRP3
Testtt.txt - https://pastebin.com/sR8kf6qE
BoWaP.txt - https://pastebin.com/FPrNwnBv
Plural script - https://pastebin.com/XRkhiapL
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on May 10, 2018, 10:12:55 PM
Hello, may I ask this again because it got buried on the last page before it was approved?

I have a question regarding Danmakufu's tasks - Is there a performance/processing cost connected to calling tasks recursively, as opposed to repeating said tasks with loops?

Thanks in advance
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 10, 2018, 10:55:39 PM
These are the pastebin uploads for all the files, what i meant was transferring the single scripts to a plural script and then running it, but every time I run it Danmakufu crashes.
Attack.txt - https://pastebin.com/VgLW4V66
Eternallight.txt - https://pastebin.com/LGsNvRP3
Testtt.txt - https://pastebin.com/sR8kf6qE
BoWaP.txt - https://pastebin.com/FPrNwnBv
Plural script - https://pastebin.com/XRkhiapL

You need to put the contents of #Text and #Title in quotations ""
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on May 11, 2018, 08:14:22 PM
I think I figured out my weird issue with things being drawn GetScreenWidth/2 to the left. I tested exactly which priorities were affected (with a big line of text objects labeled by priority) and found that everything from 20-69 was affected - the same range as the 2D camera. Lo and behold, Set2DCameraFocusX(GetStgFrameWidth/2); fixed the problem. I'm guessing it's getting set to 0 at some point before there is a stage frame? This works as a patch job, but I'd prefer to figure out why it started happening and fix that so input is still appreciated.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 11, 2018, 09:26:17 PM
Hello, may I ask this again because it got buried on the last page before it was approved?

I have a question regarding Danmakufu's tasks - Is there a performance/processing cost connected to calling tasks recursively, as opposed to repeating said tasks with loops?

Thanks in advance
Could you explain why you want to do it recursively in the first place? It shouldn't matter any more than regular recursion, as the tasks spawned recursively don't depend on the calling task once they're in the task scheduler. One main "advantage" to calling tasks in a loop is that you can have the arguments to the task depend on the loop context in some way, and this doesn't invade the task code itself. If you think there's a solid programming benefit to calling them recursively then it's probably fine. I haven't seen any particularly shallow recursion limit in DNH. That being said, recursion in general can be wasteful because you keep building up the call stack until the very end and you have to keep track of all deferred operations (i.e. there is no tail-call optimization).

E: Whatever is causing it definitely involves GetScreenWidth. I changed the screen size in th_dnh.def as a test and all affected objects went off the screen entirely.
My measurements:
640x480: -130, -18
800x600: -210, -78
960x720: -290, -138

It's adding a displacement of (-80, -60) for change in screen width of 160x120, so that's changing by that offset plus width/2. Why (130, 18) though. The STG frame is offset by (32, 16).

EDIT: nvm, it is a displacement of (-ScreenWidth/2 + StgFrameWidth/2, -ScreenHeight/2 + StgFrameHeight2)
You can also reset the camera focal point with Reset2DCamera.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on May 12, 2018, 01:38:03 PM
Could you explain why you want to do it recursively in the first place? It shouldn't matter any more than regular recursion, as the tasks spawned recursively don't depend on the calling task once they're in the task scheduler. One main "advantage" to calling tasks in a loop is that you can have the arguments to the task depend on the loop context in some way, and this doesn't invade the task code itself. If you think there's a solid programming benefit to calling them recursively then it's probably fine. I haven't seen any particularly shallow recursion limit in DNH. That being said, recursion in general can be wasteful because you keep building up the call stack until the very end and you have to keep track of all deferred operations (i.e. there is no tail-call optimization).
Thank you for this insight.

I envisioned that recursion would be useful for a pattern where bullets split or multiply as long as they are still on the screen. Something like this:

task CreateShot(angle, position) {
// Create shot from position with angle
// Wait for 180 frames
// If current bullet is still on screen{
// Get bullet position as 'shotposition'
// Get bullet angle as 'shotangle'
// Call task recursively:
CreateShot(shotangle + 20, shotposition)
CreateShot(shotangle - 20, shotposition)
}
// Delete current shot
}

In theory, this pseudocode should create a scenario where every three seconds a shot splits into two shots that branch off at 40-degree angles from each other until they leave the screen. It is much simpler and more flexible when designed recursively than using ascent loops to calculate spawn points and timings.
But I'm not confident with how well such a program would scale, especially if you wanted the shots to split into more than two, or if you started with more than one shot.

I understand that tail-call optimization isn't possible since tasks can't return a value, but does calling the return on a task remove it from the call stack? Can it do so even if the child tasks are still running?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 12, 2018, 06:14:29 PM
That level of recursion is absolutely fine, you can definitely do that. I'm talking more on a very deep scale. In your example the bullets scale exponentially, but you still shouldn't have any trouble until the number of bullets gets to the point where it's ridiculous on screen anyways.

Using return in a task is just the same as letting the task end. With recursive functions, the call stack can become large with deep recursion because each function has to keep track of the context it was called from and you have to wait for the function to complete to fold back. However like I wrote above, with tasks they only need to know that until they're put in the task scheduler. That is, control returns to the parent context once the task either finishes or yields. After this a task becomes detached from its parent context -- which is also the reason tasks can't return values.

Basically what that means is that for the most part if you're using recursive tasks you don't need to worry much about building up waste unless you're doing the recursion before any yields, which is usually not the case.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on May 12, 2018, 07:48:58 PM
That level of recursion is absolutely fine, you can definitely do that. I'm talking more on a very deep scale. In your example the bullets scale exponentially, but you still shouldn't have any trouble until the number of bullets gets to the point where it's ridiculous on screen anyways.

Using return in a task is just the same as letting the task end. With recursive functions, the call stack can become large with deep recursion because each function has to keep track of the context it was called from and you have to wait for the function to complete to fold back. However like I wrote above, with tasks they only need to know that until they're put in the task scheduler. That is, control returns to the parent context once the task either finishes or yields. After this a task becomes detached from its parent context -- which is also the reason tasks can't return values.

Basically what that means is that for the most part if you're using recursive tasks you don't need to worry much about building up waste unless you're doing the recursion before any yields, which is usually not the case.
Thank you lots and lots: This is a very clear and informative explanation. You've helped a lot! :) :) :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on May 12, 2018, 10:16:00 PM
You can also reset the camera focal point with Reset2DCamera.
You know, I tried that before setting it directly and nothing happened. I think I ran into a similar issue at some point in the past as well.

E: Now I've got another issue: The game crashes instantly upon trying to load my package. And by "instantly", I mean I put WriteLogs everywhere I could think of (including @Loading and global) and none of them got executed. The last thing written to the log is the message that it's trying to load a package script (パッケージスクリプト[path]) and then nothing. Not really sure what's going on, since it neither errors nor actually does anything. Same github (https://github.com/JonAjuhan/cs401Project)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 13, 2018, 02:49:18 PM
E: Now I've got another issue: The game crashes instantly upon trying to load my package. And by "instantly", I mean I put WriteLogs everywhere I could think of (including @Loading and global) and none of them got executed. The last thing written to the log is the message that it's trying to load a package script (パッケージスクリプト[path]) and then nothing. Not really sure what's going on, since it neither errors nor actually does anything. Same github (https://github.com/JonAjuhan/cs401Project)

If it's crashing immediately after selecting it, it is, from my experience, a parsing error in the script - some kind of thing you are doing that Danmakufu cannot comprehend and crashed trying to do so.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on May 13, 2018, 09:32:04 PM
If it's crashing immediately after selecting it, it is, from my experience, a parsing error in the script - some kind of thing you are doing that Danmakufu cannot comprehend and crashed trying to do so.
It was an encoding issue! Apparently it somehow got encoded in UTF-16 (UCS-2 LE BOM). I got my clue when I was investigating why github was saying it was a binary file.
...Except converting it to UTF-8 didn't fix it. It did cause the window to abruptly close instead of not responding, so it was probably a problem, at least.

Alright, guess it's time to systematically uncomment things until it breaks.
...The following crashes the game:   
Code: [Select]
let append = "";
let qux = [0];
...Append is a reserved keyword, isn't it? ...Yep, it is. That was it. God dammit.

Do you/anyone have a user-defined language for Notepad++ with Danmakufu's syntax and keywords? I've been using C syntax highlighting, but it differs in enough cases to sometimes cause problems like this, and I haven't been able to find a way to work off a built-in language to define one myself.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on May 13, 2018, 09:40:47 PM
Do the functions ObjMove_SetDestAtFrame/AtSpeed/AtWeight work on OBJ_ENEMY type objects?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 13, 2018, 10:23:41 PM
It was an encoding issue! Apparently it somehow got encoded in UTF-16 (UCS-2 LE BOM). I got my clue when I was investigating why github was saying it was a binary file.
...Except converting it to UTF-8 didn't fix it. It did cause the window to abruptly close instead of not responding, so it was probably a problem, at least.
Danmakufu actually supports UTF-16 LE w/ BOM, but does not read UTF-8. NPP interpreting UTF-16 as UCS-2 is not entirely correct but they're exactly the same up to a certain point.

Do the functions ObjMove_SetDestAtFrame/AtSpeed/AtWeight work on OBJ_ENEMY type objects?
Enemy objects are a kind of Move object, so yes.
(https://i.imgur.com/bpAsV6U.png)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Twizz on May 14, 2018, 03:55:12 AM
I've had this lag issue with a player I'm making. The longer the player shoots, the slower the game gets (fps drops down to 40fps). It's not noticeable at first but after a while a frame drops, and then 5, and then it's down to 40fps. After extensive testing, I realized it happened the more I would press Z to shoot the basic player shots. I've tried different methods of running the basic shots but they all end up causing lag overtime. I've provided the script in a pastebin to see how I run the basic shots. https://pastebin.com/nAgy8Jg0
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 14, 2018, 06:18:29 AM
This is very commonly due to not properly deleting objects. Looking at what you've provided, I am very confident that the problem is due to your SE_Play function, which probably creates a new Sound object every call and doesn't delete them. Even if you fix this, could you post your player_resource script to check for other possible issues?


As an aside, I noticed you're doing
Code: [Select]
if(GetVirtualKeyState(ShiftKey) == KEY_PUSH || GetVirtualKeyState(ShiftKey) == KEY_HOLD && alive )The && operator has a higher precedence than ||, so a || b && c works as a || (b && c). You need (a || b) && c for the correct behaviour.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Twizz on May 14, 2018, 03:27:57 PM
https://pastebin.com/p9icAKci This is the player resource file. I decided to remove all the SE_Play in the player script and then test it. It has removed the overtime lag. There's still lag whenever there's too many bullets on the screen because these players are a bit resource heavy. :ohdear:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 14, 2018, 11:55:13 PM
What you've shown shouldn't be that resource heavy. Is this all? I don't see GrazePartNum defined anywhere.

The SE_Play function is not good exactly because of what I said, you create an object every time you play a sound effect and don't delete them. If you don't want to change too much, you can just tack this on the end:
Code: [Select]
while(ObjSound_IsPlaying(seobject)){ yield; }
Obj_Delete(seobject);
This isn't the best way to go about things (because it still creates new objects and loads the file every time) but it fixes your immediate problem.

You also shouldn't be calling SE_Play for the same sound 16, 32, etc times in one frame. You do this when you check for player focus; you should move it outside that TexEffect spawning loop.

One other strange thing is that you write
Code: [Select]
if(frame > ShotPerFrame){
  frame = ShotPerFrame;
}
I can't really tell why this part is here because your shooting condition is already frame >= ShotPerFrame and at the end you set frame back to 0. It shouldn't be a problem it just doesn't make much sense.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on May 16, 2018, 02:27:47 AM
Two questions:
Function so far (https://pastebin.com/2qJawaJW)
Test cases (https://pastebin.com/WSYGnvNQ) (6 unique failure cases found)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ramcat1313 on May 16, 2018, 11:50:48 AM
Hi there,

Just a quick question. What does the error: "player not found" mean?

Originally when loading a player script in my Package script, the player script in the default player folder with the same name loads. And when I changed it, the error message comes out.

I tried loading other player scripts from the default folder and they work. But other player scripts from anywhere else I get the message.

Testing out the player script in single and stage menus of Danmakufu work fine. And the player script is located in a folder that is in the same folder as the Package script.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on May 16, 2018, 12:58:58 PM
Hi there,

Just a quick question. What does the error: "player not found" mean?

Originally when loading a player script in my Package script, the player script in the default player folder with the same name loads. And when I changed it, the error message comes out.

I tried loading other player scripts from the default folder and they work. But other player scripts from anywhere else I get the message.

Testing out the player script in single and stage menus of Danmakufu work fine. And the player script is located in a folder that is in the same folder as the Package script.
For package scripts you need to explicitly load the player into the package before being able to call it. A snippet from my own game:

Code: [Select]
task initializeStage {
let pathBorder = "script/player/dcs_player/player_border.txt";

SetStagePlayerScript(pathBorder);

SetStageMainScript("script/thdcs/DanceContestStage.txt");

StartStageScene;
}

Basically my package runs this task, puts the player script in a variable called pathBorder. The key function here obviously is SetStagePlayerScript();  after that proceed as normal. Notice how my player script is located somewhere else, just like your scenario.

I never dived into the reason why the default script works so I cannot shed any light on this part.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on May 16, 2018, 01:09:18 PM
Two questions:
  • I'm finding that I have to restart my package entirely before any changes to whatever script I'm working on actually take effect. How might I go about making sure the script gets reloaded when I run it from my menu, the same way it does when you run a script from the default package?
Short answer: You can't. Restart you must.

Long answer: Once you're testing your game from the package you need to completely restart your entire package for any changes to take effect. It seems package scripts are handled differently compared to testing stuff from single and plural etc where hitting Backspace is sufficient enough to reload the script

Unless you're scripting the core (menu / system etc) or actually the complete game, you have no reason to load your game from package menu in danmakufu. Script your spell cards and boss fights using the single/plural menu. Script the stages with stage menu. And that is it. [/list]
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ramcat1313 on May 17, 2018, 12:30:33 AM
For package scripts you need to explicitly load the player into the package before being able to call it. A snippet from my own game:

Code: [Select]
task initializeStage {
let pathBorder = "script/player/dcs_player/player_border.txt";

SetStagePlayerScript(pathBorder);

SetStageMainScript("script/thdcs/DanceContestStage.txt");

StartStageScene;
}

Basically my package runs this task, puts the player script in a variable called pathBorder. The key function here obviously is SetStagePlayerScript();  after that proceed as normal. Notice how my player script is located somewhere else, just like your scenario.

I never dived into the reason why the default script works so I cannot shed any light on this part.

Thank you for the help. ^^D

I've tried loading the player script, but nothing happened. Then I also discover that apparently you also need to write #Player[playerpath] on the header.

Thank you again for the reply. It was very helpful.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 17, 2018, 04:59:53 AM
Here is an implementation of a typeof function:

https://gist.github.com/drakeirving/b0d0a8400c1cfff80385f95e5d6d9d3e

Some notes:
- Arrays are typed
- Strings are character arrays, i.e. "abc" == ['a','b','c']
- If you type [] inside a script it defaults to a char array
- Empty arrays can be turned into another type of array
- ? Infinity should be treated as valid numbers. NaNs also technically work without errors but have behaviour inconsistent with numbers.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on May 17, 2018, 07:18:14 AM
Thank you for the help. ^^D

I've tried loading the player script, but nothing happened. Then I also discover that apparently you also need to write #Player[playerpath] on the header.

Thank you again for the reply. It was very helpful.
Huh, that is odd. I am checking my own player script and it just reports the following headers: (garbled title/text is because of JP characters not visible on my mac)
Code: [Select]
#TouhouDanmakufu[Player]
#ScriptVersion[3]
#ID["DCS_BORDERTEAM"]
#Title["???E?`?[??"]
#Text["???E?`?[??"]
#ReplayName["BorderTeam"]

Well, I am happy it works for you now. Though curious why that header was exactly needed.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on May 18, 2018, 04:52:13 PM
https://gist.github.com/drakeirving/b0d0a8400c1cfff80385f95e5d6d9d3e (https://gist.github.com/drakeirving/b0d0a8400c1cfff80385f95e5d6d9d3e)
Oooh. That's some good stuff and gives me a lot of insight.
- Arrays are typed
So I've noticed - the big thing I need this for (apart from general use) is figuring out the type of arrays so I can safely append a hash to them before notifying events, which will use the hash to pass back a value through common data.

How deeply are arrays typed? Does a multidimensional array always need to have the same depth in all member arrays? I've been operating under the assumption that they do, but I've been wrong before.

- Strings are character arrays, i.e. "abc" == ['a','b','c']
I knew this was the case in other languages, but didn't want to assume the two were equivalent in Danmakufu. Good to have confirmation that they are.
- If you type [] inside a script it defaults to a char array
- Empty arrays can be turned into another type of array
Does this mean [] and "" are functionally equivalent? If so, does it actually affect anything that they default to char arrays?
I notice you have a case for determining it to be an empty array (rather than an empty string), but typeof([]) still returns TYPE_ARRAY_CHAR?

While I'm at it, is NULL literally just a constant for 0 or is there anything special about it?
- ? Infinity should be treated as valid numbers. NaNs also technically work without errors but have behaviour inconsistent with numbers.
Doesn't ?INF00 also have behavior inconsistent with numbers? I believe anything you do to it can only result in ?INF00, IND00, or QNAN0. Still, I wouldn't want to accidentally skip appending something to an array just because it was divided by zero and end up with weird confusing behavior, so I see the value of treating it as a number.
IND00 is a bit harder to end up with (0/0, sqrt(-n), or INF00*0 are the only ways I've found) and has even weirder behaviors (comparison is all sorts of fucked with it IIRC) so I also see why you wouldn't want to treat that or QNAN0 as numbers. Easy way to get undefined behavior, amirite?

E: Random question, is there a way to do regex in DNF, or would I have to use a function to do it manually? Mainly asking because I'm sure this is another thing that would be fascinating to see your implementation of, if you have one lying around.

EE: Is there a way to cast to char? Other than making an array containing the char for each value and taking that index from it?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 18, 2018, 08:28:46 PM
> Do max and abs work on all types, or are they just being short-circuited by the len==0?

They do. The basic approach was to find how much you could do on all types without stringifying first. Absolute is just for negative numbers.

> I assume that the length of a char or bool would be 0, so it must work on those - I assume it treats chars as numbers, true as 1, and false as 0?

Yes.

> It seems like an array (or string) is never truthy by this definition? That seems contrary to the usual definition, where everything except certain values are truthy.

Arrays end up as 0, so the max is 0, which evaluates to false.

> I didn't realize Danmakufu allowed implicitly evaluating numbers as part of logical expressions. Is that what the !! around it is for?

!! is to force to boolean, but yes you can interpret numbers as logical expressions, hence truthiness. The !! isn't strictly important because of this but I used it for testing (otherwise it outputs a mix of types). max(x,0) && len(x)==0 would also output a boolean but I preferred the short-circuit.

> Is the purpose of x[0..0] instead of x[0] to keep it as an array? ...And then ToString on x[0..0] gives you "" if it's a string? How does that work?

The magic is that ToString formats char arrays as strings and all other arrays with brackets. Slicing 0..0 gives you an empty array but the type remains, so either you get empty string or the string "[]".

> Are there any known inputs that will result in returning TYPE_UNKNOWN, or is that just a failsafe?

The latter.

> How deeply are arrays typed? Does a multidimensional array always need to have the same depth in all member arrays? I've been operating under the assumption that they do, but I've been wrong before.

I don't think I know of a counterexample.

> Does this mean [] and "" are functionally equivalent? If so, does it actually affect anything that they default to char arrays?

[] and "" can both be concatenated with any other values because there are no elements in there to be type-incompatible. Arrays are immutable, so it just makes a new array and copies all the elements over and if there are different typed values it's no good. I assume the new array has the same type as the first array with any elements.
The one consequence (https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1189214.html#msg1189214) I know of is if you're trying to compare arrays; arrays with different types can't be compared even if one is empty. Please do not compare arrays with a literal [].

> I notice you have a case for determining it to be an empty array (rather than an empty string), but typeof([]) still returns TYPE_ARRAY_CHAR?

As said earlier and shown just above, if you type [] in a script, that is a char array (demonstrable by calling ToString on it or by comparing). You can "create" an empty non-char array with something like erase([1], 0) but this doesn't have much practical application.

> While I'm at it, is NULL literally just a constant for 0 or is there anything special about it?

Constant. Basically useless as far as I can tell, but if you try to overwrite DNH constants the program crashes.

> Doesn't ?INF00 also have behavior inconsistent with numbers? I believe anything you do to it can only result in ?INF00, IND00, or QNAN0. Still, I wouldn't want to accidentally skip appending something to an array just because it was divided by zero and end up with weird confusing behavior, so I see the value of treating it as a number.

It makes sense that applying finite arithmetic to it will result in infinities, and they can still be compared sensibly with any other number. Doing stuff like infinity - infinity will give a NaN though.

> E: Random question, is there a way to do regex in DNF, or would I have to use a function to do it manually? Mainly asking because I'm sure this is another thing that would be fascinating to see your implementation of, if you have one lying around.

real regex is hard, look it up
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on May 18, 2018, 10:01:51 PM
The one consequence (https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1189214.html#msg1189214) I know of is if you're trying to compare arrays; arrays with different types can't be compared even if one is empty. Please do not compare arrays with a literal [].
Oh! Ooh! Several errors I've gotten in the past suddenly make sense.
You can "create" an empty non-char array with something like erase([1], 0)
The magic is that ToString formats char arrays as strings and all other arrays with brackets. Slicing 0..0 gives you an empty array but the type remains, so either you get empty string or the string "[]".
Oh, wow. I wasn't even thinking about that. That's one of those things that makes perfect sense but isn't intuitive if you don't already know it.



E: How might I go about getting rid of those ugly gray bars when the game is fullscreened? Or rather, replace the gray bars with black bars? Assuming such a thing is possible without modifying the exe.
(Even then, I know some people have modified the exe for small stuff before (http://www.bulletforge.org/u/kirbio/p/artifact-contest-2-augmented-magic-satori-komeiji-kirbios-entry), so I still wouldn't discount it - I just don't know where to find the relevant parts of the code after decompiling.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 20, 2018, 11:50:23 PM
Is there a danmakufu version that uses ScriptVersion[1]?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 21, 2018, 12:53:02 AM
Is there a danmakufu version that uses ScriptVersion[1]?

Oooh, ancient history. You're talking about stuff from over a decade ago. :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 21, 2018, 05:19:15 PM
Oooh, ancient history. You're talking about stuff from over a decade ago. :)
What? A DECADE ago?
And I thought that 0.12m was old
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tom on May 21, 2018, 10:07:56 PM
Do you mean 0.10a?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 21, 2018, 10:37:36 PM
Same difference. "I thought [version 2] was old".

2003/11/24: 0.00a (first public)
2004/01/26: 0.10a (first script v2)
2006/10/09: 0.12m (last script v2)
2010/05/05: ph3 α1 (first script v3)
2015/01/18: ph3 .1 pre6a (current)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 22, 2018, 01:56:33 AM
Same difference. "I thought [version 2] was old".

2003/11/24: 0.00a (first public)
2004/01/26: 0.10a (first script v2)
2006/10/09: 0.12m (last script v2)
2010/05/05: ph3 α1 (first script v3)
2015/01/18: ph3 .1 pre6a (current)

Holy crap DNH came out when I was 7.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on May 22, 2018, 03:16:16 AM
2003/11/24: 0.00a (first public)
2004/01/26: 0.10a (first script v2)
2006/10/09: 0.12m (last script v2)
2010/05/05: ph3 α1 (first script v3)
2015/01/18: ph3 .1 pre6a (current)
Wow, it's been around for almost 15 years. Has it been the same people working on it the whole time? ...And are those people/anyone still working on it?

(Still wondering about changing the gray bars to black when fullscreened, btw.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Fujiwara no Mokou on May 22, 2018, 03:57:30 AM
Wow, it's been around for almost 15 years. Has it been the same people working on it the whole time? ...And are those people/anyone still working on it?

(Still wondering about changing the gray bars to black when fullscreened, btw.)

Actually, it's been just one person who's been maintaining it. Well, he had some help from the user-base, but he alone has the entire source code.
He'll give you some of it if you ask nicely, though.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on May 22, 2018, 01:23:01 PM
I often hear talk of a "God-Mode Ex-Rumia" around forums that is used for playtesting somehow.

What is it exactly? It's not just the default Rumia player is it?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on May 22, 2018, 08:18:33 PM
He'll give you some of it if you ask nicely, though.
Eh, wait, really? I had thought it was totally closed-source. How much is "some of it"?





Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on May 23, 2018, 11:26:29 PM
Hmm, I was trying to figure it out myself and looking some others scripts for "reference"...  :blush:
Short Long Story : I can't figure dialogue.
Long Story : I know that it has do to do with pictures and frames, but I don't know where to start or any tutorial/easier example of...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tom on May 24, 2018, 07:54:20 AM
SetShotIntersectionCircle/Line might need to be set every frame?

For the gray bars I think it has to do with the fact that danmakufu ph3 does not use "real fullscreen" mode (where the screen changes resolution) and rather makes a window that is full screen and highest priority so it hides the taskbar.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 24, 2018, 04:37:08 PM
Can I use a 3d model like a sprite?(I mean like a boss sprite, with it having animations and etc)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on May 25, 2018, 04:31:31 AM
Hmm, I was trying to figure it out myself and looking some others scripts for "reference"...  :blush:
Short Long Story : I can't figure dialogue.
Long Story : I know that it has do to do with pictures and frames, but I don't know where to start or any tutorial/easier example of...
A dialogue is nothing more than drawing two 2D sprite images on your screen and showing/hiding them depending on the "dialogue". Like 2D sprite A -> Alpha 255 while sprite B is Alpha 55 (transparency).

Why don't you look at the existing 0.12m dialogue functions? If you mimic the behaviour of those functions you should basically have a simple dialogue system already.

Can I use a 3d model like a sprite?(I mean like a boss sprite, with it having animations and etc)
Don't see why you can't. You just need to make sure the 3D model is following the object movement of your "invisible" boss object. (And making sure the collisions are set). About the animations, can't say.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on May 25, 2018, 11:48:26 AM
May I ask what the mathematics of the timing behind ObjMove_SetDestAtWeight() are?
How is it numerically related to the max speed and weight and distance values?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 25, 2018, 09:10:47 PM
https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1345364.html#msg1345364
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on May 25, 2018, 10:32:00 PM
Why I'm being "blocked"?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 26, 2018, 02:42:33 AM
Why I'm being "blocked"?

The Danmakufu Wiki is currently down and not accessible.

For the ph3 official documentation, refer to http://www.geocities.co.jp/SiliconValley-Oakland/9951/pre/th_dnh_help_v3.html
For my incomplete backup, refer to http://sparen.github.io/ph3tutorials/docs.html
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on May 26, 2018, 03:42:33 AM
Or you could just use the Web Archive (https://web.archive.org/details/https://dmf.shrinemaiden.org/wiki/Functions_(ph3)) version of the wiki.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on May 26, 2018, 07:39:19 AM
Going to relay the mediawiki error to TSO.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 27, 2018, 01:37:41 AM
Is Danmakufu considered a difficult language to program compared to others?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 27, 2018, 01:41:08 AM
Is Danmakufu considered a difficult language to program compared to others?

Danmakufu is highly specialized for a certain type of game. It is not comparable to general purpose languages.

For example, if I wanted to write, say, AES in Danmakufu, I would find it drastically harder than in a language such as Go or C++. If I wanted to write a program in Danmakufu that allows you to make a custom GUI by dragging and dropping buttons and exporting it to JSON, I could *technically* do it but it would likely not be worth the effort and would be better done in another language.

So is it difficult? No. Is it practical for non-Danmaku game related programming? Also no.

-----

Now, comparing to other languages/frameworks for making games, I personally have no experience with RPG Maker or Game Maker, but RPG Maker is meant for RPGs while Game Maker is more general purpose. Both are relatively easy to pick up, but when making Danmaku games, neither will be as easy to use as Danmakufu. As for Unity and C#, making a Danmaku game in Unity probably takes 20x longer than making one in Danmakufu.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Amon on May 27, 2018, 08:50:37 AM
Hi there,

I'm currently stuck with two things I want to implement:

First is saving a highscore and spellcard-history. It should be something with CommonData, but I can't figure out how exactly I have to use that.
Second is textboxes. They are basically just pictures and text, some routine that waits for keyinput so the rest of the script can resume, but I can't get it working properly.

Help would be very appreciated, thanks!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 27, 2018, 02:18:43 PM
Hi there,

I'm currently stuck with two things I want to implement:

First is saving a highscore and spellcard-history. It should be something with CommonData, but I can't figure out how exactly I have to use that.
Second is textboxes. They are basically just pictures and text, some routine that waits for keyinput so the rest of the script can resume, but I can't get it working properly.

Help would be very appreciated, thanks!
I can say that the first you are going to use area common data.
For the second, use while(keyinput){yield;}.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on May 27, 2018, 04:19:18 PM
First is saving a highscore and spellcard-history. It should be something with CommonData, but I can't figure out how exactly I have to use that.
Look at 34th page of this thread, I've asked the similar question and the explanations given were pretty easy to understand
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tom on May 27, 2018, 10:00:44 PM
As for Unity and C#, making a Danmaku game in Unity probably takes 20x longer than making one in Danmakufu.
Haha, I can say from experience, making a Danmaku game in Unity is indeed hard... (considering its totally unoptimized for this kind of use)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 28, 2018, 12:45:03 AM
So, I'm helping my friend (jao) to make a Reimu player script.
He doesn't know how to do bombs, so he gave me a copy of the player script to implement a bomb.
All should be working correctely, but Danmakufu tells that the variable is not defined.
I try everything to solve this, but it's no use.
Here's the code:
Code: [Select]
task SpamShot(obj){
let angleT = 90;
while(!Obj_IsDeleted(obj)){
loop(15){
let obj1 = CreatePlayerShotA1(ObjMove_GetX(obj)+64*cos(angleT),ObjMove_GetY(obj)+64*sin(angleT),6,angleT,1,1,5);
let obj2 = CreatePlayerShotA1(ObjMove_GetX(obj)+64*cos(-angleT),ObjMove_GetY(obj)+64*sin(-angleT),6,-angleT,1,1,5);
angleT+=360/15;
Obj_SetRenderPriorityI(obj1,25);
Obj_SetRenderPriorityI(obj2,25);
}
angleT+=2;
wait(2);
}
}
The missing variable is obj1 and obj2.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 28, 2018, 01:19:11 AM
CreatePlayerShotA1 doesn't return an object ID for some reason. Use ObjShot_Create or ObjSpell_Create for control over the object.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 28, 2018, 01:21:11 AM
So, I'm helping my friend (jao) to make a Reimu player script.
He doesn't know how to do bombs, so he gave me a copy of the player script to implement a bomb.
All should be working correctely, but Danmakufu tells that the variable is not defined.
I try everything to solve this, but it's no use.
Here's the code:
Code: [Select]
task SpamShot(obj){
let angleT = 90;
while(!Obj_IsDeleted(obj)){
loop(15){
let obj1 = CreatePlayerShotA1(ObjMove_GetX(obj)+64*cos(angleT),ObjMove_GetY(obj)+64*sin(angleT),6,angleT,1,1,5);
let obj2 = CreatePlayerShotA1(ObjMove_GetX(obj)+64*cos(-angleT),ObjMove_GetY(obj)+64*sin(-angleT),6,-angleT,1,1,5);
angleT+=360/15;
Obj_SetRenderPriorityI(obj1,25);
Obj_SetRenderPriorityI(obj2,25);
}
angleT+=2;
wait(2);
}
}
The missing variable is obj1 and obj2.

It's helpful to have the exact error message (i.e. a screenshot) so we can see what Danmakufu actually output and at what line.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 28, 2018, 01:37:35 AM
It's helpful to have the exact error message (i.e. a screenshot) so we can see what Danmakufu actually output and at what line.
(https://cdn.discordapp.com/attachments/412784674964766720/450472543959384075/unknown.png)
Here is the image with the error.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 28, 2018, 03:32:34 AM
Yep, so it's like I said. CreatePlayerShotA1 doesn't return the player shot object's ID, so the variable remains empty, and reports it as empty when you try to use it as an object ID.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on May 28, 2018, 04:39:49 AM
Yep, so it's like I said. CreatePlayerShotA1 doesn't return the player shot object's ID, so the variable remains empty, and reports it as empty when you try to use it as an object ID.
There's apparently also a CreatePlayerShotObjectA1 that DOES return an object ID. It doesn't seem to be documented anywhere. The arguments are the same: x,y,speed,angle,damage,penetration,graphic.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 28, 2018, 02:12:37 PM
There's apparently also a CreatePlayerShotObjectA1 that DOES return an object ID. It doesn't seem to be documented anywhere. The arguments are the same: x,y,speed,angle,damage,penetration,graphic.
I'll keep a note of this :|

I really wish some of the undocumented but working functions were officially documented by mkm, but... that's asking too much.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on May 28, 2018, 06:27:18 PM
There is more undocumented functions out there? If yes, what functions?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on May 29, 2018, 12:07:38 AM
There's apparently also a CreatePlayerShotObjectA1 that DOES return an object ID. It doesn't seem to be documented anywhere. The arguments are the same: x,y,speed,angle,damage,penetration,graphic.
Was the function implemented?
It's saying that it doesn't exist... grammar check plz?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 29, 2018, 12:51:21 AM
Code: [Select]
function CreatePlayerShotObjectA1(x, y, speed, angle, damage, penetration, graphic){
let obj = ObjShot_Create(OBJ_SHOT);
ObjMove_SetPosition(obj, x, y);
ObjMove_SetSpeed(obj, speed);
ObjMove_SetAngle(obj, angle);
ObjShot_SetDamage(obj, damage);
ObjShot_SetPenetration(obj, penetration);
ObjShot_SetGraphic(obj, graphic);
ObjShot_Regist(obj);
return obj;
}

wau
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: ExPorygon on May 29, 2018, 03:03:47 AM
Code: [Select]
function CreatePlayerShotObjectA1(x, y, speed, angle, damage, penetration, graphic){
let obj = ObjShot_Create(OBJ_SHOT);
ObjMove_SetPosition(obj, x, y);
ObjMove_SetSpeed(obj, speed);
ObjMove_SetAngle(obj, angle);
ObjShot_SetDamage(obj, damage);
ObjShot_SetPenetration(obj, penetration);
ObjShot_SetGraphic(obj, graphic);
ObjShot_Regist(obj);
return obj;
}

wau
I'm very dumb sometimes
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kappa-kun on May 30, 2018, 07:28:12 AM
The wiki has been down for a few days now, any news?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 30, 2018, 02:20:16 PM
The wiki has been down for a few days now, any news?

No news, I'm afraid. :(

Alternatives:
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) (official Japanese docs)
https://web.archive.org/web/20170621193842/http://dmf.shrinemaiden.org:80/wiki/Functions_(ph3) (https://web.archive.org/web/20170621193842/http://dmf.shrinemaiden.org:80/wiki/Functions_(ph3))
https://sparen.github.io/ph3tutorials/docs.html (https://sparen.github.io/ph3tutorials/docs.html) (work in progress; incomplete)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tom on May 30, 2018, 07:28:32 PM
Keep in mind that using the command the returns an object ID might prevent certain optimizations from happening.  Best practice would be to use it only when needed and use the non object command for regular shots.  Player shots unlike enemy shots are designed to be "dumb" as in "fire and forget" since they are spawned in mass quantities and remain on the screen for a small amount of time (since they move fast and either hit or go off screen).

If the command does not return an object ID it relieves itself of the responsibility of maintaining an object ID mapping for that "short term" object.  It can also make several assumptions such as that the object's trajectory will not be modified once its fired, and also that the object can not be deleted prematurely via commands.  Lastly it can rearrange the object's location in memory without worrying about updating references to it (possibly the most important optimization).

I do not know if ph3 actually performs these optimizations however these are a valid reasons for not returning an object ID for a player shot and providing 2 commands (and discouraging the use of the 2nd one by not documenting it).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 31, 2018, 04:15:20 AM
I disagree. If that were the case you would need a separate classification of objects that ignore further access altogether, which is essentially never what you would actually want. Allowing the objects to lock themselves away from any further set and get operations is a bad idea for the programmer, never mind not doing it in a transparent way. And why would it matter whether the object can't be accessed through the script when it can still be modified/etc by the engine itself? Most script functions will translate pretty much directly to functions called by the engine, and if those functions are called besides from the script then there's no point in locking it away from the programmer. Going from object ID to actual reference is also just going to be a table lookup; if the object actually has to readdress that isn't a significant burden on the script side whatsoever.

This also definitely wouldn't be a good reason to not document the other function nor document why you might use the void one in the first place, theoretically speaking. That's actually just dumb.

Anyways we know all this isn't the case because you can always use functions like GetShotIdInCircle to retrieve the object ID even when it would have not been known initially. There does not seem to be any fundamental difference between shot objects with a returned ID and one without.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on May 31, 2018, 04:21:57 AM
The wiki has been down for a few days now, any news?
Seems so.

Last update I had from TSO was that she would look into it. I think it slipped past her again due to busy RL.

Will check with her again.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Smarty0917 on May 31, 2018, 11:39:42 AM
Does anyone have a complete list of ph3 functions, because https://dmf.shrinemaiden.org/wiki/Functions_(ph3) isn't working for me
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 31, 2018, 01:22:34 PM
Does anyone have a complete list of ph3 functions, because https://dmf.shrinemaiden.org/wiki/Functions_(ph3) isn't working for me

Alternatives:
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) (official Japanese docs)
https://web.archive.org/web/20170621193842/http://dmf.shrinemaiden.org:80/wiki/Functions_(ph3) (https://web.archive.org/web/20170621193842/http://dmf.shrinemaiden.org:80/wiki/Functions_(ph3))
https://sparen.github.io/ph3tutorials/docs.html (https://sparen.github.io/ph3tutorials/docs.html) (work in progress; incomplete)

I literally just linked the webarchive version of the wiki four posts ago :|


Hele: Not to mention I even answered another member about it too :V
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Smarty0917 on June 01, 2018, 03:20:00 AM
I literally just linked the webarchive version of the wiki four posts ago :|


Hele: Not to mention I even answered another member about it too :V

Sorry about that I didn't see the previous posts.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on June 02, 2018, 03:04:41 AM
A few questions:
Assuming it's not being looked after by the script, how far can a shot go off the playing field before it gets automatically deleted?

Does this happen immediately if a shot spawns/is teleported outside of this range?

Would there be a way to change this value without altering the size of the playing field?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 02, 2018, 03:26:50 AM
A few questions:
Assuming it's not being looked after by the script, how far can a shot go off the playing field before it gets automatically deleted?

Does this happen immediately if a shot spawns/is teleported outside of this range?

Would there be a way to change this value without altering the size of the playing field?

1) 64 pixels on all sides (See: http://www.geocities.co.jp/SiliconValley-Oakland/9951/pre/th_dnh_help_v3.html )
2) For regular shots, you must set them to not auto delete via ObjShot_SetAutoDelete(obj, false);
3) Refer to SetShotAutoDeleteClip ( https://sparen.github.io/ph3tutorials/docs.html#fxn_SetShotAutoDeleteClip )
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on June 02, 2018, 03:36:14 AM
1) 64 pixels on all sides (See: http://www.geocities.co.jp/SiliconValley-Oakland/9951/pre/th_dnh_help_v3.html )
2) For regular shots, you must set them to not auto delete via ObjShot_SetAutoDelete(obj, false);
3) Refer to SetShotAutoDeleteClip ( https://web.archive.org/web/20170522220913/http://dmf.shrinemaiden.org:80/wiki/Shot_Functions#SetShotAutoDeleteClip )


Thank you, and can this apply for all objects, not just shots?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 02, 2018, 03:54:28 AM

Thank you, and can this apply for all objects, not just shots?

I had trouble getting it working with Curvy Lasers, but it definitely works for all ObjShot instances.

If you're thinking about ObjRender, etc, then no, it will not work.

Note: I hastily threw together a new feature on my website, so the link to the webarchive has been replaced
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 02, 2018, 05:06:58 AM
If you really need it for other kinds of Move objects you could do something like this:

EDIT: use below
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on June 02, 2018, 05:39:17 AM
Please excuse me being confused: For the top and left values, do you have to enter a negative value to create the off-screen buffer? Or is it the magnitude?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 02, 2018, 06:46:03 AM
Negative value, yes. Except now I realize this is inconsistent with SetShotAutoDeleteClip and stuff, so let me make this better:

Code: [Select]
task ObjMove_SetAutoDeleteClip(obj, left, top, right, bottom){
let l = -left;
let t = -top;
let r = GetStgFrameWidth() + right;
let b = GetStgFrameHeight() + bottom;

let x;
let y;
while(!Obj_IsDeleted(obj)){
x = ObjMove_GetX(obj);
y = ObjMove_GetY(obj);
if(x < l || x > r || y < t || y > b){
Obj_Delete(obj);
}
yield;
}
}

This one you could put in (64, 64, 64, 64).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on June 03, 2018, 12:20:48 PM

In the example, I have an image of a white pixel I use for a canvas, and a 256x256 image of a white circle on black background. I stretch the white pixel to 1024x512 (the render target size), and then repeatedly add copies of the circle texture with subtract blending. So the render target becomes a texture that is mostly white with a bunch of random black circles. Meanwhile, some background is drawn on layers 26 to 28. The Shader object applies the masking shader technique, using the render target as the applied texture, to the layers 26 to 28, which results in the background appearing as though there are holes in it that scroll across the screen.

I tried it, but it shows the black circles on a white background instead... what just happened? Also, what is that text "example_mask" as seen on the example you posted?
[attach=1]
Can someone tell me...on the masking shader? I have no sense after I follow this example... Please Respond...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on June 03, 2018, 01:23:40 PM
I tried it, but it shows the black circles on a white background instead... what just happened? Also, what is that text "example_mask" as seen on the example you posted?

Can someone tell me...on the masking shader? I have no sense after I follow this example... Please Respond...
To make the mask always transparent you need to remove Obj_SetVisible(contents, true); from the code below, so it won't be only black circles(atleast that's what I did and it works completely fine)
Code: [Select]
ascent(i in 0..length(contents)){
// Make visible when drawing to render target
Obj_SetVisible(contents[i], true);
RenderToTextureB1(texture_name, contents[i], (i==0));
// Otherwise invisible
Obj_SetVisible(contents[i], false);
}

As for "example_mask" it is just a name for a mask, you don't have to worry about it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on June 04, 2018, 05:02:14 AM
To make the mask always transparent you need to remove Obj_SetVisible(contents, true); from the code below, so it won't be only black circles(atleast that's what I did and it works completely fine)
Code: [Select]
ascent(i in 0..length(contents)){
// Make visible when drawing to render target
Obj_SetVisible(contents[i], true);
RenderToTextureB1(texture_name, contents[i], (i==0));
// Otherwise invisible
Obj_SetVisible(contents[i], false);
}

As for "example_mask" it is just a name for a mask, you don't have to worry about it.

I tried removing it, but still looks like this:
[attach=2]

It's hard to see the code that maybe it's misarranged because of the code. Can you show me an (full) example of it? Please respond.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on June 04, 2018, 06:27:16 AM
I tried removing it, but still looks like this:

It's hard to see the code that maybe it's misarranged because of the code. Can you show me an (full) example of it? Please respond.

So, this is what I'm using. https://pastebin.com/8RNxnMNU There is too much to cover, so just ask me if something is not clear for you. renderStage; and scrollStage; almost don't affect anything but they are involved in couple of things, so I left them in.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 04, 2018, 09:19:28 AM
why don't you post your own code instead of asking others to post more code that you might not even gain any insight from

p o s t y o u r c o d e
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on June 05, 2018, 03:06:49 AM
My computer is warning me that this Forum has a security certificate error. Is this something I should be worried about?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 05, 2018, 03:45:39 AM
My computer is warning me that this Forum has a security certificate error. Is this something I should be worried about?

It happens around this time of year. Don't worry - it'll be addressed... eventually.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tom on June 05, 2018, 08:21:38 PM
1) 64 pixels on all sides (See: http://www.geocities.co.jp/SiliconValley-Oakland/9951/pre/th_dnh_help_v3.html )
64 pixels from the STG frame set via commands or the screen (set via resolution)?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 05, 2018, 11:23:51 PM
It's 64 pixels by default but you can set it globally. If you just change the window scale obviously it doesn't matter but if you're changing the resolution as a package then you're responsible for setting appropriate bounds.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enko on June 06, 2018, 06:41:06 AM
When I try to encode the dnh script as UTF-16 LE with BOM (due to Chinese charactors), the another sciript file will cause a crash called "#Include file is not found".
Actually the file is there but, because the #include code use relative path so it crashed.
If I use the original Shift-JIS code Chinese charactors won't show correctly but this error won't spread out either.
How can I deal with this?
(btw,UTF8 with/without BOM & UTF-16 LE without BOM will crash by encoding problem.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 06, 2018, 08:50:16 AM
Can you show what your script is like and how each file is encoded? I've seen this issue before (https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1180648.html#msg1180648) but I cannot replicate it and don't really know what's happening.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enko on June 06, 2018, 02:55:00 PM
Maybe it's the same problem. e.g.
I re-encoded the file
Code: [Select]
resource\script\lib\lib_value.dnhas UTF-16 LE with BOM,however:
(Pic)
It shows the crash spread out at the Line 282 in lib_Manual.dnh
But actually,there's only 281 lines in the file.
And the code shown is in fact in another file called lib_PauseScene.dnh,with path
Code: [Select]
resource\script\stage\st_system\lib_PauseScene.dnhthe code line
Code: [Select]
#include "./lib_PauseFps.dnh"the Dot should mean "resource\script\stage\st_system" but misunderstood by engine.
However it can be OK if lib_value.dnh uses Shift-JIS code.
And not only this,the error is also spread out at player script (resource\player) and other script that contains relative path including,
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 06, 2018, 10:17:24 PM
I mostly understand what the problem is, but I do not understand your folder structure or what the scripts look like so I don't know how to test this myself.

If I try to make a simple example like this:
Code: [Select]
// test.dnh

#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["test"]

#include "./include.dnh"
#include "./include2.dnh"

@Initialize{}
@MainLoop{}
@Event{
alternative(GetEventType())
case(EV_REQUEST_LIFE){
SetScriptResult(1);
}
}

// include.dnh

function a{
AddScore(1);
RaiseError("东方");
}

// include2.dnh

function b{
AddScore(1);
RaiseError("东方");
}

With everything encoded as UTF-16 LE BOM, it works. So it isn't just the encoding and relative path #includes. Please try to find a way to simply replicate the problem.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enko on June 07, 2018, 06:20:41 AM
Quote
Sorry for long codes,for some reason I cannot access pastebin.
Here's a simple file tree:
Code: [Select]
resource
├bgm                             //BGM
├img                             //Pictures
├player
│├CommonData
│└th12
│  ├pl00                        //Player Script "Reimu"
│  │├pl00_MainShotTask.dnh
│  │├pl00_OptionTask.dnh
│  │├pl00_Player.dnh
│  │├pl00_SpellCard.dnh
│  │└pl00_SubShotTask.dnh
│  ├...
│  ├pl06
│  └CommonBomb.dnh
├script
│├lib
││└lib_value.dnh
│└stage
│  ├bg
│  ├enemy
│  ├scl
│  │└stage1_scl.dnh
│  ├st_system
│  │├lib_PauseScene.dnh
│  │└lib_PauseFps.dnh
│  ├lib_manual.dnh              //Maunal Scene
│  ├lib_MusicRoom.dnh           //MusicRoom Scene
│  └musiccmt.txt                //MusicRoom Comments
└se                             //Sound Effect

All of start is that I encode lib_value.dnh as UTF-16 LE BOM because it contains a string to set the default font of the text drawing in the game,and the name of the font contains chinese words.
Code: [Select]
//  lib_value.dnh, Originally Shift-JIS
let CurrentFont = "飴鞭ゴシック等幅-04";//ゲームの共通フォント(The default font in the game)
let CurrentFontP = "飴鞭ゴシック等幅-04";//スペルカード名の共通フォント(The default font for spellcards' name)
---------->>>
// Saved as UTF-16 LE BOM
let CurrentFont = "黑体";//ゲームの共通フォント(The default font in the game)
let CurrentFontP = "黑体";//スペルカード名の共通フォント(The default font for spellcards' name)

Then I go to MusicRoom and find everything ok,same as SpellPractice Selection scene.(Both contains direct text drawing)
but if I go to Replay Selection the error spread:
Code: [Select]
#Include file is not found[<Game>/resource/script/stage/lib_PauseFps.dnh].
<Game>/resource/script/stage/lib_Manual.dnh
lib_Manual.dnh line(行)=282


#include "./lib_PauseFps.dnh"

lib_Manual.dnh has only 281 lines codes,in fact. The script contains #include "./lib_PauseFps.dnh" is lib_PauseScene.dnh
Code: [Select]
// lib_PauseScene.dnh

#include "resource/script/lib/lib_files.dnh"
#include "resource/script/lib/lib_v0.12m_Effect.dnh"
#include "resource/script/lib/lib_SpellIndex.dnh"
#include "resource/script/stage/lib_SpellResult.dnh"
#include "resource/script/stage/lib_Manual.dnh"
#include "./lib_PauseFps.dnh"
Yeah here cause a problem,it is ok before I encode lib_value.dnh as UTF-16 LE BOM,but crashed after I did it.That's strange.

Sure I can solve by replacing Dot with "resource\script\stage\st_system",turly it works.
However after doing this the game still crashed for another error:
Code: [Select]
#Include file is not found[<Game>/resource/player/CommonData/pl00_MainShotTask.dnh].
<Game>/resource/player/CommonData/GaugeEffectTask.dnh
GaugeEffectTask.dnh line(行)=1588


#include "./pl00_MainShotTask.dnh"
#include "./pl00_OptionTask.dnh"

#include "resource/player/th12/CommonBomb.dnh"
#include "./pl00_SpellCard.dnh"
And the file pl00_Player.dnh
Code: [Select]
// pl00_Player.dnh
#TouhouDanmakufu[Player]
#ScriptVersion[3]
#ID["Reimu"]
#Title["Reimu"]
#ReplayName["Reimu"]

#include "resource/script/lib/lib_usershot_th128.dnh"
#include "resource/script/lib/lib_v0.12m_function.dnh"

#include "resource/script/lib/lib_files.dnh"
#include "resource/script/lib/lib_Event.dnh"
#include "resource/script/lib/lib_ItemConst.dnh"

#include "resource/player/CommonData/LocalData.dnh"
#include "resource/player/CommonData/Spell_back.dnh"
#include "resource/player/CommonData/StatusIrregular.dnh"

#include "resource/player/CommonData/SlowEffectTask.dnh"
#include "resource/player/CommonData/GaugeEffectTask.dnh"

#include "./pl00_MainShotTask.dnh"
#include "./pl00_OptionTask.dnh"

#include "resource/player/th12/CommonBomb.dnh"
#include "./pl00_SpellCard.dnh"

these are just two of the errors.After I solve one by replacing Dot,the another will show up by the same problem of relative path.
And it seems in gaming script(such as background drawing)will cause it,too.
Code: [Select]
#Include file is not found[<Game>/resource/script/bg/bg_st1.dnh].
<Game>/resource/script/stage/lib_StageInclude.dnh
lib_StageInclude.dnh line(行)=270


#include "./../bg/bg_st1.dnh"
#include "./lib_Stage1.dnh"
#include "./../enemy/lib/sp_bg/background_st1.dnh"

Code: [Select]
// stage1_scl.dnh
#TouhouDanmakufu[Stage]
#ScriptVersion[3]
#System["./../st_system/system.dnh"]//ここのシステム呼び出しは必須

#include "./../lib_StageInclude.dnh"
#include "./../bg/bg_st1.dnh"
#include "./lib_Stage1.dnh"
#include "./../enemy/lib/sp_bg/background_st1.dnh"
Here comes interesting thing, lib_StageInclude.dnh is found but bg_st1.dnh cannot found,and just caused by a encoding?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 07, 2018, 08:33:05 AM
Ok, I'm beginning to understand what's happening. The line numbering is not a problem though. How #includes work is that the included scripts are essentially inserted directly to where the #include is. In the example I gave above, the compiled script would look like:

Code: [Select]
[...]
#Title["test"]

function a{
AddScore(1);
RaiseError("东方");
}
function b{
AddScore(1);
RaiseError("东方");
}

@Initialize{}
[...]

What's happening in your problem, is that lib_PauseScene.dnh is being compiled, it #includes some scripts into it, then #includes lib_Manual.dnh. At the end, for some reason Danmakufu does not think the file lib_Manual.dnh has ended, so it thinks the "current script being compiled" is still lib_Manual.dnh and not lib_PauseScene.dnh. Then it continues to read what comes next and tries to #include lib_PauseFps.dnh, which is the next file to include in lib_PauseScene.dnh, but because Danmakufu thinks it's still handling lib_Manual.dnh, it tries to find the file relative to lib_Manual.dnh, which fails because it isn't in the same directory as lib_PauseScene.dnh.

The same happens in the other examples too: it compiles pl00_Player.dnh, which #includes GaugeEffectTask.dnh, doesn't think that file is finished being read, then tries to #include the next script pl00_MainShotTask.dnh relative to GaugeEffectTask.dnh instead of pl00_Player.dnh.

So I think the problem might come from #including a script encoded as UTF-16 LE BOM into a script encoded as SJIS, or vice-versa.

What I'm not sure of is why changing lib_value.dnh causes these particular changes in different scripts. Is lib_value.dnh included at any point in any of these files?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enko on June 07, 2018, 10:38:41 AM
Yes there is sure a file (also the only file) named lib_files.dnh included lib_value.dnh,the full path is resource\script\lib\lib_files.dnh.
This file define the files path the game(or,script) will use and other constants.
Code: [Select]
// lib_files.dnh

//カレントディレクトリ
let DIR_EXE = GetFileDirectory(GetMainPackageScriptPath);
let DIR = DIR_EXE~"resource/";
let FONT_DAT = DIR ~"img/font.dat";
let SyFontPath = DIR ~"img/font/amemuchigothicmono-b.ttf";
let SyFontBPath = SyFontPath;

#include "./lib_value.dnh"
#include "./lib_juicevalue.dnh"
And lib_files.dnh is included by other scripts that for some system-like using (e.g.players, PauseScene.dnh)
however almost all these scripts use absolute path to include lib_files.dnh.
(Btw,maybe encode all scripts to UTF16 is helpless.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: autumnfox98 on June 10, 2018, 01:06:18 AM
Hello, I'd like some help with something I want to do in Touhou Danmakufu 0.12.

I want to make a row of bullets vary more in angle if the player gets closer to the boss. (Think Touhou 6 Stage 5 before the Sakuya Midboss.)
Is this possible? Or should I upgrade to ph3?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 10, 2018, 01:59:02 PM
Hello, I'd like some help with something I want to do in Touhou Danmakufu 0.12.

I want to make a row of bullets vary more in angle if the player gets closer to the boss. (Think Touhou 6 Stage 5 before the Sakuya Midboss.)
Is this possible? Or should I upgrade to ph3?

Is it possible? Yes. Do I remember exactly how to do it and which 0.12m functions to use? Not really. (cough cough please use ph3 - 0.12m is so old that pretty much nobody uses it anymore)

...

Regardless of engine, here's how it would work:

You will need to get the boss's position and the player's position, use the distance formula to calculate the distance between the two, and then utilize that number to control whatever parameters you need. In ph3, that's going to mean GetPlayerX/Y and ObjMove_GetX/Y.

How you scale the angle based on the distance is up to you as a designer.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: autumnfox98 on June 10, 2018, 03:10:13 PM
Is it possible? Yes. Do I remember exactly how to do it and which 0.12m functions to use? Not really. (cough cough please use ph3 - 0.12m is so old that pretty much nobody uses it anymore)

...

Regardless of engine, here's how it would work:

You will need to get the boss's position and the player's position, use the distance formula to calculate the distance between the two, and then utilize that number to control whatever parameters you need. In ph3, that's going to mean GetPlayerX/Y and ObjMove_GetX/Y.

How you scale the angle based on the distance is up to you as a designer.

Uh, I'm not much of a Danmakufu expert, but what code would I need for it to do that?

This is the code I used:
Code: [Select]

if(subattack == 1 && count % 1 == 0 && count >= 0 && count % 240 < 20){
let angle = GetX - GetPlayerY;
let speed = 3;
loop(10){
ascent(i in 0..1){
CreateShotA(2, GetX, GetY, i*4);
SetShotDataA(2, 0, speed, angle, 0, 0, 3, BLUE01);
FireShot(2);
}
angle += 360 / 10;
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Xethos on June 11, 2018, 12:51:02 AM
I'm trying to make a spell card based off of Kage Mimeimas first non-spell, but I cannot figure out how to do the danmakufu.

https://www.youtube.com/watch?v=8SaDXRlBSsU

Any help would be appreciated!  :D
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 11, 2018, 04:06:59 AM
The best person to ask is probably WishMakers (refer to https://www.youtube.com/watch?v=Y-PFoG6FiHg (https://www.youtube.com/watch?v=Y-PFoG6FiHg)).

Essentially, when you create your bullets, you assign them to a parent dummy object with an ID. After a certain amount of time, they aim for their final spot relative to the parent object, which moves.

I've done some similar things in the past, but those aren't exactly the same. I can provide code, but it's probably better for you to try and get it working on your own since you have a better sense of what you want.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Xethos on June 12, 2018, 07:00:34 PM
If you could give the code, it would be much appreciated! I just want to experiment with it until I get a feel, then get it how I want it
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 12, 2018, 07:23:36 PM
It's a little long, but here's the code example (abridged).

Code: [Select]
    task SpawnRings{
let randoffset = rand(0,360);
        let numshiki = [6, 6, 8, 9];
ascent(i in 0..numshiki[diff]){AnchorBullet(randoffset+i*360/numshiki[diff]);}
    }
This task runs numshiki instances of the AnchorBullet task.
Code: [Select]
    task AnchorBullet(ang){
let obj = CreateShotA2Alt(GetEnemyX(objBoss), GetEnemyY(objBoss), 3, ang, -0.05, 0, S_LAURAORB_DARKBLUE + S_AO, 0);
let objcount = 0;
ObjShot_SetSpellResist(obj, true);
while(ObjMove_GetSpeed(obj)>0){yield;}
let randoffset = rand(0,360);
        let numinring = [5, 6, 8, 9];
        let numinline = [2, 3, 5, 6];
ascent(i in 0..numinring[diff]){//greater om higher difficulties.
    if(ObjEnemy_GetInfo(objBoss, INFO_LIFE) <= 0){return;}//Default kill to prevent (0,0) spawning
    ascent(j in 0..numinline[diff]){
                let obj2 = CreateShotA1Alt(GetEnemyX(objBoss), GetEnemyY(objBoss), 0, 0, S_DKSUPP_DARKBLUE, 0);
        BulletCommandsA1(obj2, obj, i, numinring[diff], j, randoffset);
    }
    GS(SFX_WAVE);
    objcount++;
    yield;
}
loop(150){//wait for last suppository to fire
    objcount++;
    yield;
}
Obj_Delete(obj);
    }
This task creates 'parent' bullets. Each parent bullet runs the double ascent loop to create 'child' bullets.
Code: [Select]
    task BulletCommandsA1(obj, parent, ID, numinring, rowID, offset){
ObjMove_SetDestAtFrame(obj, ObjMove_GetX(parent)+30*cos(ID*360/numinring), ObjMove_GetY(parent)+30*sin(ID*360/numinring), 60);
let objcount = offset;
descent(i in 1..60){
    ObjMove_SetDestAtFrame(obj, ObjMove_GetX(parent)+30*cos(ID*360/numinring+objcount), ObjMove_GetY(parent)+30*sin(ID*360/numinring+objcount), i);
    objcount++;
    yield;
}
loop(90){
    ObjMove_SetAngle(obj, ID*360/numinring+objcount);
    ObjMove_SetPosition(obj, ObjMove_GetX(parent)+30*cos(ID*360/numinring+objcount), ObjMove_GetY(parent)+30*sin(ID*360/numinring+objcount));
    objcount++;
    yield;
}
if(ObjEnemy_GetInfo(objBoss, INFO_LIFE) <= 0){return;}//Default kill to prevent (0,0) spawning
ObjMove_SetSpeed(obj, 2+rowID/6);
    }
The 'child' bullets constantly set their destination via ObjMove_SetDestAtFrame to be relative to their parent object. This allows them to spawn from anywhere on the screen and move towards their specified parent object. These particular shots rotate around their parent object for a while before flying off.

For what you want to accomplish, you will likely need to specify a parent object (does not need to be visible and does not need to have a hitbox - just a position) and have children objects gravitate towards + move relative to those parent objects.

If you have any further questions, please ask, although it is best to experiment on your own first.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: autumnfox98 on June 13, 2018, 11:24:36 PM
I'm having issues with having an object shot work.
I tried having it spawn, but nothing happens.
Here's part of the code.

Code: [Select]
    @MainLoop {
        SetCollisionA(GetX, GetY, 24);
        SetCollisionB(GetX, GetY, 24);

task Bullet(x, y, v, angle) {
     let obj = Obj_Create(OBJ_SHOT);
     Obj_SetPosition(obj, x, y);
     Obj_SetAngle(obj, angle);
     Obj_SetSpeed(obj, v);
     ObjShot_SetGraphic(obj, RED01);
     ObjShot_SetDelay(obj, 0);
     ObjShot_SetBombResist(obj, true);
}
if(count == -60){
CutIn(KOUMA, "Wood Sign: Syphlae Horn (Easy)", Rumia, 0, 0, 0, 0);
}
        count++;
        yield;
    }


    @DrawLoop {
        DrawGraphic(GetX, GetY);
    }

    @Finalize {
        DeleteGraphic("script\img\ExRumia.png");
    }
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 14, 2018, 12:52:36 AM
You need to call ObjShot_Regist to activate a shot object.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: autumnfox98 on June 14, 2018, 11:51:36 PM
You need to call ObjShot_Regist to activate a shot object.

How?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 15, 2018, 12:44:04 AM
?

You just use ObjShot_Regist(obj) after you create the object. This "activates" the shot which basically means it's fired.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on June 15, 2018, 01:03:00 AM
How?
?

You just use ObjShot_Regist(obj) after you create the object. This "activates" the shot which basically means it's fired.

I'd like to point out that you're looking for Bullet(x, y, v, angle), where x, y, v, and angle are all variables that you want to replace with actual values. ObjShot_Create in v0.12m, to my knowledge, automatically creates the object in the fired, stationary state with no graphic at the top left.

EDIT
Allow me to explain that.
by writing task Bullet (parameters) { ... }, you're not actually creating anything. You're giving Danmakufu a prototype of a code that it needs to run. It's like giving someone a recipe for baking cookies, but you haven't actually told them to actually do the baking. Calling the task's name along with the list of parameters like you do with CutIn, CreateShot01, etc. is what actually causes Danmakufu to execute what's written in the brackets.

... I would like to further suggest that since you haven't made it excessively far into the world of v0.12m, it might be worth considering learning the ph3 language instead.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 15, 2018, 01:47:47 AM
I missed that they were using 0.12m because they didn't mention it in this post, yeah. I was also assuming they were just calling it somewhere else. Yeah they need to check out some tutorials.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Enko on June 15, 2018, 03:02:32 AM
Encoding problem occured again in 東方潮聖書 ~ Sapphire Panlogism Trail ver. Chinese localization.
UTF-16 LE BOM occurs compiling error.

But this time things different.I've write lot of Chinese charactors in script\title\lib\lib_MusicData.dnh in case(-1), case(0) and case(2) section,and nothing wrong spread out.But here:
Code: [Select]
case(1){
return [
"The Sky Wanders Closer",
"
The stage 1 theme.[r][r]

It's raaaaining. But it's not really a bleak kind of rain.[r]
It's weird to see fairies in Gensokyo with any half-decent intelligence.[r]
But it doesn't make a difference.
"
];
}

I translated it into Chinese and error spread out,however:
Code: [Select]
case(1){
return [
"天空越来越近",
"
The Sky Wanders Closer / 1面主题曲。[r][r]

天's raaaaining. But it's not really a bleak kind of rain.[r]
Nothing happend.

I'd like to translate It's raaaaining to 天上在下??雨, however if I type after the error shows.
but I try another word: (Though that's not destination translation),it should like:
Code: [Select]
天月 raaaaining. But it's not really a bleak kind of rain.Nothing happend again. Even:
Code: [Select]
天在下??雨 But it's not really a bleak kind of rain.Nothing happend,either.

So comes a question,does Danmakufu's "UTF16 support" limit the charactors? e.g.

Edited:These are the translation codes that can spread error:
Code: [Select]
case(1){
return [
"天空越来越近",
"The Sky Wanders Closer / 1面主题曲。[r][r]

天上在下----雨,但并不是那种阴冷的雨。[r]
见到幻想乡的那些还算有点智慧的妖精是不可思议的。[r]
但是这没什么区别。
"
];
}

These are codes work well:
Code: [Select]
case(1){
return [
"天空越来越近",
"The Sky Wanders Closer / 1面主题曲。[r][r]

天在下??雨,但并不是那种阴冷的雨。[r]
见到幻想乡的那些还算有点智慧的妖精是不可思议的。[r]
但是这没什么区别。
"
];
}

A can occur a error?Why??

2nd Edited:Without nothing happend to game.
So what happen to the charactor ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on June 16, 2018, 04:01:54 PM
What do i need to do to get a notification that stage script is closed? I've tried various methods with CommonData, but none of them worked. @Finalize doesn't seem to work in stage scripts at all, since nothing I write there is ever executed. So I've come to the problem of needing a notification upon the closure of the stage, but none of the methods I know work.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 16, 2018, 04:14:32 PM
What do i need to do to get a notification that stage script is closed? I've tried various methods with CommonData, but none of them worked. @Finalize doesn't seem to work in stage scripts at all, since nothing I write there is ever executed. So I've come to the problem of needing a notification upon the closure of the stage, but none of the methods I know work.

Show us what you are currently doing with a MVCE (https://stackoverflow.com/help/mcve). Without seeing your code, it will be difficult to diagnose your problem.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on June 16, 2018, 06:05:10 PM
Show us what you are currently doing with a MVCE (https://stackoverflow.com/help/mcve). Without seeing your code, it will be difficult to diagnose your problem.

So, the amount of code is gonna be quite big, since atleast 3 scripts are connected here. I guess I should explain what am I trying to do first. The main script here is a package (it's main menu to be exact). I've made a mask in that package for some VFX, no problems were detected here. Then there is a background script for a stage, which also uses the same type of mask for similar VFX, and when it comes to using it in the stage itself, it works perfectly fine. However, if I return to the main menu of the package after mask was used in the stage, some bugs are caused. After some testing, I managed to figure out that the cause of the bugs is infact the mask used in stage, and to get rid of them I just have to remove the mask and do some other stuff upon closing the stage. Heres where the main problem kicks in. If I finish the stage, everything works fine, but if I close the stage in the middle of the fight with a boss, the aforementioned bugs occur and I can't find a way to detect the closure of the script.
Here are the scripts I use:
Package (https://pastebin.com/03fTffUQ), StageBackground (https://pastebin.com/hq5wJvNP) and Stage (https://pastebin.com/0DRRTxRm)
I didn't manage to shorten Package and StageBG a lot, since many things there are involved, I hope my coding won't be that confusing. Also, there is a lot of images involved in Package, but I don't think they are gonna be useful to post
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 16, 2018, 09:53:39 PM
So, the amount of code is gonna be quite big, since atleast 3 scripts are connected here. I guess I should explain what am I trying to do first. The main script here is a package (it's main menu to be exact). I've made a mask in that package for some VFX, no problems were detected here. Then there is a background script for a stage, which also uses the same type of mask for similar VFX, and when it comes to using it in the stage itself, it works perfectly fine. However, if I return to the main menu of the package after mask was used in the stage, some bugs are caused. After some testing, I managed to figure out that the cause of the bugs is infact the mask used in stage, and to get rid of them I just have to remove the mask and do some other stuff upon closing the stage. Heres where the main problem kicks in. If I finish the stage, everything works fine, but if I close the stage in the middle of the fight with a boss, the aforementioned bugs occur and I can't find a way to detect the closure of the script.

I don't know what kind of shader you are using, but I have some notes from a quick look at your code:
Firstly, if you are starting a shader in the package and then start the *exact* same shader again in the background, you may be applying it twice - it may be beneficial to have a CommonData flag that notes if the shader has already been started.
Secondly, as long as you can get the Stage script's ID and pass it to the Background script, you may be able to use IsCloseScript() (https://sparen.github.io/ph3tutorials/docs.html#fxn_IsCloseScript).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on June 17, 2018, 08:59:44 AM
Firstly, if you are starting a shader in the package and then start the *exact* same shader again in the background, you may be applying it twice - it may be beneficial to have a CommonData flag that notes if the shader has already been started.
I don't quite understand what do you mean by that.
Secondly, as long as you can get the Stage script's ID and pass it to the Background script, you may be able to use IsCloseScript() (https://sparen.github.io/ph3tutorials/docs.html#fxn_IsCloseScript).
I did already try using IsCloseScript in the background, but for some reason it doesn't work. I have SetCommonData("StageID", GetOwnScriptID()); in the Initialize of stage script and something like this in StageBackground
Code: [Select]
while(!IsCloseScript(GetCommonData("StageID", 0))){
   yield;
}
ClearInvalidRenderPriority();
but the while loop never stops running, even if I close stage script. That ClearInvalidRenderPriority(); is pretty much essential for me, since it needs to be called whenever stage script is closed, but nothing I know works.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 17, 2018, 10:20:30 AM
Can you 100% confirm whether that script ID remains correct and accessing it refers to the correct script once you've closed it? I have a suspicion about the general problem.

Do something like create an event handler in the stage where if triggered it will increment some debug common data you can check. Then in your stage background while-is-not-closed loop, notify that event every frame with NotifyEvent targeting that script ID, so you would expect that the debug value would keep incrementing until you close the script. Also pay attention to what the value of the stage script ID common data is.


Alternatively you could upload your script package and I could take a look at it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on June 17, 2018, 10:41:18 AM
Yes, correct script gets notified, the counter works, but still nothing after the loop is executed
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 17, 2018, 11:22:55 AM
Okay, but does the counter stop once you close the script? Because there are really only a couple outcomes:
1) The event is notified but nothing is handled, which means the script ID was wrong
2) The event is notified every frame and handled by the script, but when the script is closed it can't handle the event anymore and the counter stops increasing; the loop then ends
3) The event is notified every frame and handled by the script and keeps increasing even after it apparently closes, which means it didn't close
4) The event is notified every frame and handled by the script, and when the script closes the counter stops, but the loop continues, meaning either:
4a) the common data holding the script ID becomes wrong (e.g. if it returns the default of 0)
4b) the return value of IsCloseScript is wrong, which you should be able to manually verify (i.e. it returns true despite the argument definitely being the correct script ID)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on June 17, 2018, 11:37:57 AM
The counter does stop, but I don't know if the loop is closed or not (commands after the loop don't work, but the counter in this loop also stops, which isn't supposed to happen)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 17, 2018, 09:09:38 PM
Well I mean either the loop is finished or it isn't lol. If you don't know how to check for what you want to check, zip up your script and put it somewhere so we can look at it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on June 18, 2018, 11:38:30 AM
That's what I mean, the loop stops, but commands after it do not get executed. If that didn't happen there would be no problem in the first place. As for scripts, I did already post them
Here are the scripts I use:
Package (https://pastebin.com/03fTffUQ), StageBackground (https://pastebin.com/hq5wJvNP) and Stage (https://pastebin.com/0DRRTxRm)
I don't think posting them whole would do much, since there are a lot of interconnected scripts and they use a lot of images

Edit: I think I know what happens. The loop does get closed, but so does the background script, so the whole task in background script gets shut down not being completed. But that's just a guess, I don't actualy know how danmakufu behaves in such situations.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on June 18, 2018, 05:01:05 PM
Is the hitbox intersection width of a straight laser always the same as the render width?
What about when using a bullet graphic which has a much smaller hitbox than its sprite?

Thanks in advance
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 18, 2018, 10:25:16 PM
I can't confirm that at the moment, but regardless if needed you can use ObjLaser_SetIntersectionWidth to set it manually.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on June 19, 2018, 09:59:49 AM
I can't confirm that at the moment, but regardless if needed you can use ObjLaser_SetIntersectionWidth to set it manually.

Thanks,

I'm trying to incrementally decrease the width of a straight laser over time, so as an alternative, is there a way to alter the existing intersection width relative to the current hitbox width?

(Or relative to the render width may also work?)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 19, 2018, 01:04:47 PM
Thanks,

I'm trying to incrementally decrease the width of a straight laser over time, so as an alternative, is there a way to alter the existing intersection width relative to the current hitbox width?

(Or relative to the render width may also work?)

As long as the player doesn't get cheapshotted, it's fine :)

You'll probably end up manually set both of the widths each frame in a while loop.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on June 20, 2018, 06:38:10 AM
I'm having trouble with the following lines of code

Code: [Select]
let EatShots = GetShotIdInCircleA2(spawnX+length*cos(angle)/2,spawnY+length*sin(angle)/2,width/2,TARGET_ENEMY);
ascent(i in 0 .. length(EatShots)){
    if(ObjShot_GetImageID(EatShots[i]) == 44){
         Obj_Delete(EatShots[i]);
    }
}

It seems that the second line in that block returns the error:
")" is necessary

Why does this happen, and how can it be fixed?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 20, 2018, 01:04:31 PM
I'm having trouble with the following lines of code

Code: [Select]
let EatShots = GetShotIdInCircleA2(spawnX+length*cos(angle)/2,spawnY+length*sin(angle)/2,width/2,TARGET_ENEMY);
ascent(i in 0 .. length(EatShots)){
    if(ObjShot_GetImageID(EatShots[i]) == 44){
         Obj_Delete(EatShots[i]);
    }
}

It seems that the second line in that block returns the error:
")" is necessary

Why does this happen, and how can it be fixed?

I don't know if this is the solution, but in an ascent loop avoid having spaces before and after the ..?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on June 20, 2018, 01:34:08 PM
I don't know if this is the solution, but in an ascent loop avoid having spaces before and after the ..?

Normally those spaces do not cause a problem, and removing them hasn't resolved issue here.  :(
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 20, 2018, 01:41:01 PM
Normally those spaces do not cause a problem, and removing them hasn't resolved issue here.  :(

Provide the code before the code you just posted. There might be a missing semicolon, or you might be missing a comma somewhere.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on June 20, 2018, 02:17:52 PM
Provide the code before the code you just posted. There might be a missing semicolon, or you might be missing a comma somewhere.

Code: [Select]
task SnakeAnime(spawnX,spawnY,speed,angle){
let count = 0;
let delay = 50;
let startLength = speed*delay/2;
let startWidth = delay/2;
let length = startLength;
let width = startWidth;
let hitbox = startWidth-2;
let obj = CreateStraightLaserA1(spawnX,spawnY,angle,length,width,delay,72,0);
ObjStLaser_SetSource(obj,false);
while(!Obj_IsDeleted(obj)){
ObjLaser_SetLength(obj,length);
ObjLaser_SetRenderWidth(obj,width);
ObjLaser_SetIntersectionWidth(obj,hitbox);
length -= startLength/delay;
width -= startWidth/delay;
hitbox -= (startWidth-2)/delay;
if(count < 4 || width < startWidth/2){
ObjShot_SetIntersectionEnable(obj,false);
}
else{
ObjShot_SetIntersectionEnable(obj,true);
if(count > 4){
let EatShots = GetShotIdInCircleA2(spawnX+length*cos(angle)/2,spawnY+length*sin(angle)/2,width/2,TARGET_ENEMY);
ascent(i in 0..length(EatShots)){
if(ObjShot_GetImageID(EatShots[i]) == 44){
Obj_Delete(EatShots[i]);
}
}
}
}
if(count >= delay || width < 0){
Obj_Delete(obj);
}
count++;
yield;
}
}

This is the task that contains the section. Is this enough, or should I provide the entire script?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 20, 2018, 02:58:47 PM
Code: [Select]

This is the task that contains the section. Is this enough, or should I provide the entire script?

I thought I was hallucinating at that error

The issue is that length is a reserved keyword in Danmakufu, and you are redefining it in the function. Replace all occurrences of your local variable length with something else.

Refer to https://sparen.github.io/ph3tutorials/ph3u1l5.html#sub9 for more info - I'll update the section as well
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on June 20, 2018, 03:25:19 PM
I thought I was hallucinating at that error

The issue is that length is a reserved keyword in Danmakufu, and you are redefining it in the function. Replace all occurrences of your local variable length with something else.

Refer to https://sparen.github.io/ph3tutorials/ph3u1l5.html#sub9 for more info - I'll update the section as well

Ah, Thank you so much!

I totally forgot about that restriction. I'll be more careful regarding that possibility in the future. m(_ _)m


Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Montrek on June 20, 2018, 09:30:33 PM

Hi, sorry if this showing as a reply is just that I'm new in posting stuff in websites like this one.
Is just that I've got a problem that has been bugging me for weeks, you see I'm VERY new at this.
The problem is that every time I'm trying to use this Sparen Style script that I copied while watching the How to make Circles and Ellipses video, plus by following the tutorials of the Danmakufu ph3 tutorial website, when I try it, it always give me the: "GetCenterX is not defined". error.???
https://pastebin.com/rmHmLv8s (https://pastebin.com/rmHmLv8s)

And the same error is on many other codes for example:

Code: [Select]
task ParametricRing(){
  let angleT = 0;
    loop(30){
        CreateShotA1(ObjMove_GetX(objBoss) + 90*cos(angleT), ObjMove_GetY(objBoss) + 90*sin(angleT), 2, angleT, 1, 0);
        angleT += 360/30;
    }

Preventing me from knowing if the codes I'm making have a failure or not.

Can somebody help me please :ohdear:

And I don't wanna bother but can somebody give me a curve laser code as well and tell me why the BGM that I put is not working please.  :(


Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on June 20, 2018, 11:28:13 PM
Where can I find a collection of the "dot" bosses sprites?
Or a link with all of them?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 21, 2018, 12:34:35 AM
Where can I find a collection of the "dot" bosses sprites?
Or a link with all of them?

Are you referring to https://www.shrinemaiden.org/forum/index.php/topic,18433.0.html ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 21, 2018, 02:40:19 AM
"dot" is just a term for pixel art.

You might also be referring to KMAP's stuff, which are linked on the Japanese DNH wiki here under 敵画像:
http://danmakufu.wiki.fc2.com/wiki/素材リンク
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on June 21, 2018, 11:54:29 PM
"dot" is just a term for pixel art.

You might also be referring to KMAP's stuff, which are linked on the Japanese DNH wiki here under 敵画像:
http://danmakufu.wiki.fc2.com/wiki/素材リンク
The main link server is down....
http://coolier.dip.jp:8080/th_up3/file/th3_4065.lzh
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 22, 2018, 04:37:20 AM
Oh. It's just the 8080 port that doesn't work.
http://coolier.dip.jp/th_up3/file/th3_4065.lzh
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: autumnfox98 on June 24, 2018, 06:39:53 PM
How do I make bullets ricochet off of walls only once?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 24, 2018, 07:39:26 PM
How do I make bullets ricochet off of walls only once?

Assuming you've already watched the wall bouncing video tutorial, all you need to make them bounce exactly once is have a task that first waits for the bullet to hit a wall, and then performs the bounce. The task terminates then, and no more bouncing is performed.

Otherwise, refer to the tutorial at https://www.youtube.com/watch?v=eoOlDcWmGjc
Warning: Old tutorial, may contain cringe
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: autumnfox98 on June 24, 2018, 10:14:50 PM
Assuming you've already watched the wall bouncing video tutorial, all you need to make them bounce exactly once is have a task that first waits for the bullet to hit a wall, and then performs the bounce. The task terminates then, and no more bouncing is performed.

Otherwise, refer to the tutorial at https://www.youtube.com/watch?v=eoOlDcWmGjc
Warning: Old tutorial, may contain cringe

Well. I should've mentioned I use 0.12. Sorry. But, nice tutorial though.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 24, 2018, 10:39:42 PM
The logic and structure is the same, you just have to translate which function does what.

You really should just learn ph3 though. You're using a program that's been deprecated for many years.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: autumnfox98 on June 24, 2018, 11:48:02 PM
The logic and structure is the same, you just have to translate which function does what.

You really should just learn ph3 though. You're using a program that's been deprecated for many years.

I'm getting there.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Twizz on June 27, 2018, 01:59:05 AM
I'm working on an Utusho Script and I'm trying to replicate the waves from Stage 5 from SA. I'm not entirely sure how to make the textures wavy. I was looking into Blargel's Utushu script but it's 0.12m and I didn't understand much of it  :ohdear:. But if anyone could show an example on how to do it, it would be great!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 27, 2018, 02:58:05 AM
You should use shaders to accomplish this; I would not recommend looking to Blargel's old script for that. Somebody might have already done this before, but if not you might be out of luck unless you really want to dig into HLSL and program that yourself.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 27, 2018, 07:01:05 PM
I'm currently doing a project in Danmakufu that involves writing to and then reading from file. However, opening the file always fails and I'd like to know why.

First, the code that creates the file:

Code: [Select]
    let outputfile = ObjFile_Create(OBJ_FILE_TEXT);
    let outputfilepath = OUTPUT_DIRECTORY ~ "apmfps-" ~ starttime ~ ".csv";
    ObjFile_OpenNW(outputfile, outputfilepath);
    ...
    // Flush to file
    ObjFileT_AddLine(outputfile, csvlog);
    ObjFile_Store(outputfile);
    WriteLog("APM_StartFPS: Wrote CSV to " ~ outputfilepath);
    Obj_Delete(outputfile);
    // yield once before marking as complete
    yield;
    finished_fps = true;
    WriteLog("APM_StartFPSDEBUG: Finished");

In another function, I wait for this task to finish before proceeding:
Code: [Select]
while (!finished_fps) {yield;} //Wait for file to be written before reading
ObjFileT_AddLine(outputfile, APM_ChartGenFPS);

This is a separate File Object that I am writing to.

APM_ChartGenFPS is implemented as follows:
Code: [Select]
function APM_ChartGenFPS {
    WriteLog("APM_ChartGenFPS: Starting.");
    let svg = SVGChartGen;
    let paths = [];
    let maxfps = 0;
    let filepath = OUTPUT_DIRECTORY ~ "apmfps-" ~ starttime ~ ".csv"; // Current run
    //filepath = OUTPUT_DIRECTORY ~ "apmfps-20180627142126.csv"; //debug
    let datapoints = CSVtoArray(filepath);
    maxfps = maxarr(datapoints);
    WriteLog("APM_ChartGenFPS Debug: Maximum FPS is " ~ ToString(maxfps));
    ...
}

Note that filepath is EXACTLY the same as the output file path from before.

In CSVtoArray, the following is done:
Code: [Select]
function CSVtoArray(filepath) {
    WriteLog("CSVtoArray: Running on " ~ filepath);
    let handle = ObjFile_Create(OBJ_FILE_TEXT);
    let status = ObjFile_Open(handle, filepath);
    while (!status) {
        //WriteLog("CSVtoArray: Reading file " ~ filepath ~ " failed.");
        status = ObjFile_Open(handle, filepath);
        yield;
    }
    WriteLog("CSVtoArray: Successfully read file " ~ filepath ~ ".");

    let toreturn = [];
    ascent(i in 0..ObjFileT_GetLineCount(handle)) { // For every line
        let line = ObjFileT_GetLineText(handle, i + 1); // Recall that lines are 1-indexed
        let split = SplitString(line, ",");
        ascent(j in 0..length(split)) {
            toreturn = toreturn ~ TrimString(split[j]);
        }
    }
    Obj_Delete(handle);
    return toreturn;
}
The code, when run, never gets past the infinite while loop - status is never set to true, the Success message never prints. Even after the file has shown up in my computer and I can open it, ObjFile_Open continues to fail.

Code: [Select]
APM_StartFPS: Wrote CSV to Z:/Users/andrewfan/Desktop/THDNH ph3pre6a/script/ Sparen DNH APM/test/./dnhapm-output/apmfps-20180627144737.csv
2018/06/27 14:47:40.765 APM_StartFPSDEBUG: Finished
2018/06/27 14:47:40.775 APM_ChartGenFPS: Starting.
2018/06/27 14:47:40.787 CSVtoArray: Running on Z:/Users/andrewfan/Desktop/THDNH ph3pre6a/script/ Sparen DNH APM/test/./dnhapm-output/apmfps-20180627144737.csv
2018/06/27 14:47:42.648 force terminate
As you can see in the above, it's *writing* properly, and CSVtoArray is running on the same file path as the file that was written. However, ObjFile_Open fails continuously in the while loop. I can confirm that the file exists locally. And if I hardcode the filepath, ObjFile_Open actually works (see the debug statement in APM_ChartGenFPS).

So my question(s) are:
- Is ObjFile_Store() blocking, as in, if you call it, will the next line of code not execute until the file has been written? (Confirmed blocking)
- Is ObjFile_Open() blocking? (Confirmed blocking)
- Does ObjFile_Open() only know about files that existed when the script was first run, or does it have access to the current files as of function call? If the former is true, is there a way to notify Danmakufu about the current files?
- Are there any standard ASCIIcharacters that cannot be placed in filenames in Danmakufu (spaces, hyphens, /, \)?
- Am I crazy? Is this Danmakufu being weird? Is it a stupid oversight?

Thanks.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 27, 2018, 10:06:44 PM
This minimal example:

Code: [Select]
let file = ObjFile_Create(OBJ_FILE_TEXT);
let path = GetCurrentScriptDirectory() ~ "aaa.txt";
ObjFile_OpenNW(file, path);
ObjFileT_AddLine(file, "aaaaaa");
ObjFile_Store(file);
Obj_Delete(file);
yield;
file = ObjFile_Create(OBJ_FILE_TEXT);
let status = ObjFile_Open(file, path);

Works just fine.

ObjFile_Open, ObjFile_Store, and ObjFileT_AddLine are all blocking (as they should be), easily confirmed by reading/writing large files.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 27, 2018, 11:05:49 PM
Full source available at https://github.com/Sparen/Sparen-DNH-APM/blob/master/SparenDNHAPM.dnh (https://github.com/Sparen/Sparen-DNH-APM/blob/master/SparenDNHAPM.dnh)

I spent so much time trying to fix this that I'm almost certain the bug lies elsewhere, but I can't be sure.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on June 28, 2018, 12:58:15 PM
Is it possible to make a small square in which everything is rotated 180 degrees? Like Seija's spells, but only a fraction of the screen.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 28, 2018, 12:59:37 PM
Is it possible to make a small square in which everything is rotated 180 degrees? Like Seija's spells, but only a fraction of the screen.

You can snap a render target of the screen, set the source and dest rects of a primitive object/2D Sprite to use the square, and then use ObjRender_SetScale to flip the x or y axes.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 28, 2018, 01:31:31 PM
This minimal example:

Code: [Select]
let file = ObjFile_Create(OBJ_FILE_TEXT);
let path = GetCurrentScriptDirectory() ~ "aaa.txt";
ObjFile_OpenNW(file, path);
ObjFileT_AddLine(file, "aaaaaa");
ObjFile_Store(file);
Obj_Delete(file);
yield;
file = ObjFile_Create(OBJ_FILE_TEXT);
let status = ObjFile_Open(file, path);

I did this but with a
Code: [Select]
    if (!status) {
        RaiseError("file not found");
    }
The error was raised.

The thing is that Fluffy8x's iDNH writes to file and then *executes that file as a script* and it works perfectly. However, just opening a file seems to go wrong.

I believe that Koishitale did this and it worked perfectly fine, but I'll give it a quick test and see what the problem is.

Edit: This problem seems to be completely independent of the directory, filename, or file extension. It may have to do with the fact that I'm running this under Wine but Koishitale seems to open and read text files fine (though it only opens, or only reads - not both in the same play through)

Edit 2: I ran GetFilePathList after creating the file and deleting the object but before getting the status via opening the file. The file is definitely there - it's just that ObjFile_Open says it isn't.

I'm going to assume that this is a Wine issue rather than a Danmakufu issue, since it seems that I'm the only one encountering it. I'll find a suitable workaround.

Edit 3: Confirming that when using Wine, ObjFile_Store is not blocking. Changing yield; to loop(180) {yield;} fixes the problem.
To clarify, one yield; between Obj_Delete(file); and file = ObjFile_Create(OBJ_FILE_TEXT); results in the file not being found, while more than one yield allows the file to be accessed without a problem.

Edit 4: Above extra yield; only works if the file is being opened in a task? If I change it to a function, it fails 100% of the time, regardless of how long I wait. KoishiTale seems to use tasks, but iDNH uses a function when creating a new file (to block before next function is run).

Final? Edit: I'm crazy; changing my report generator from a function to a task seems to have done the trick. Sorry for the confusion.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on June 28, 2018, 01:52:58 PM
You can snap a render target of the screen,
What do you mean by that?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on June 30, 2018, 12:31:53 AM
I know it sound a little dumb, but, I can't figure it out what is idle and moving animation...
If you can, please enumered it or tell me the order... :blush: :blush:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gregory on June 30, 2018, 12:37:54 AM
I know it sound a little dumb, but, I can't figure it out what is idle and moving animation...
If you can, please enumered it or tell me the order... :blush: :blush:

this sheet used the column animation. So if I read it correctly, it would be

https://imgur.com/a/lFWRBXR
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on June 30, 2018, 01:02:17 AM
What do you mean by that?

You can use RenderToTextureA1(targetname, start, end, rendertargetclear) (https://sparen.github.io/ph3tutorials/docs_standard.html#fxn_RenderToTextureA1) to save a render target.

That render target can be used as the texture for a Primitive Object such as a 2D Sprite. You can choose which part of the texture to use with source/dest rects.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: spexguy718 on July 01, 2018, 02:00:12 AM
Greetings again,

I'm kind of at my wits end since it took me this long to figure out how to use parameters (and eventually figured it out after a long time struggling), but now I face a new challenge. Remember "rendernightmare"? Well now it's renamed "renderplayer2(angle)" with the same content as render nightmare, but with added stuff such as the parameters.

Link 1 : https://ibb.co/deLp6d
opdup is the thing that you gave me to try to duplicate the options by 9, but it doesn't seem to work as planned, but at least it didn't give me errors.

link 2:https://ibb.co/jaGJzy
Just for more context, I had to declare an angle variable in line 21 since Danmakufu kept nagging me that "angle" was not defined. Since I did it was asked, it ran. However, it's didn't give me the desired result and it seems that it didn't do anything at all but give me just one option.

Before you tell me to look at tutorials, I came here because I looked at the tutorials, tried everything, and I couldn't come up with a solution. Can you please solve this conundrum?

Thank you so much if you do reply to this.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on July 01, 2018, 02:52:05 AM
The problem seems to be that you're calling renderplayer2 nine times in an ascent loop, but without actually using i, which is the whole point of the ascent loop. You're just calling the function with 9/360 as the angle nine times. If you changed it to use i*num_options/360 instead of num_options/360, you should end up with a circle of evenly spaced options.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: spexguy718 on July 01, 2018, 03:10:12 AM
The problem seems to be that you're calling renderplayer2 nine times in an ascent loop, but without actually using i, which is the whole point of the ascent loop. You're just calling the function with 9/360 as the angle nine times. If you changed it to use i*num_options/360 instead of num_options/360, you should end up with a circle of evenly spaced options.

Even though I DID add the i as instructed, it doesnt seem to do anything
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: spexguy718 on July 01, 2018, 03:38:52 AM
Also I did switch things around and still nothing
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 01, 2018, 04:02:13 AM
Greetings again,

I'm kind of at my wits end since it took me this long to figure out how to use parameters (and eventually figured it out after a long time struggling), but now I face a new challenge. Remember "rendernightmare"? Well now it's renamed "renderplayer2(angle)" with the same content as render nightmare, but with added stuff such as the parameters.

Link 1 : https://ibb.co/deLp6d
opdup is the thing that you gave me to try to duplicate the options by 9, but it doesn't seem to work as planned, but at least it didn't give me errors.

link 2:https://ibb.co/jaGJzy
Just for more context, I had to declare an angle variable in line 21 since Danmakufu kept nagging me that "angle" was not defined. Since I did it was asked, it ran. However, it's didn't give me the desired result and it seems that it didn't do anything at all but give me just one option.

Before you tell me to look at tutorials, I came here because I looked at the tutorials, tried everything, and I couldn't come up with a solution. Can you please solve this conundrum?

Thank you so much if you do reply to this.

Please provide a Minimal, Complete, and Verifiable Example (https://stackoverflow.com/help/mcve). As it stands, we don't have enough context to figure out what else you have done, and you haven't explained what your *intended* result is.

Are the two code blocks part of the same script? Are they related?

Now, for specifics:
Part 1: Assuming you want the 9 options to be evenly spaced, use i * 360/9 in the ascent loop. This is because you have 360 degrees in a circle, and you have nine options, so you divide 360 degrees by 9, and multiply by i to get the angle for each familiar.

Part 2: angle is the parameter to the function. Give it the angle that it wants. Unless of course you meant to call opdup instead of renderPlayer2 in your second example.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 01, 2018, 06:04:02 AM
In renderPlayer2 you're manipulating playerObj2. Even if you run renderPlayer2 nine times, it's still just only working with the one object, and you show in the second screenshot it's only one object. You probably want to be working with nine different objects...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on July 01, 2018, 12:23:01 PM
I'm trying to make a spell with seven patterns that come in random order, but the initial order keeps repeating for the duration of the spell. It's not working though, and I can't figure out why:
Code: [Select]
let number = [0,0,0,0,0,0,0];
loop{
while(number[0]==number[1]||number[0]==number[2]||number[0]==number[3]||number[0]==number[4]||number[0]==number[5]||number[0]==number[6]){
number[0] = floor(rand(1,8));
}
fire(number[0]);
number[6] = number[5];
number[5] = number[4];
number[4] = number[3];
number[2] = number[1];
number[1] = number[0];
yield;
}
"fire()" is the function that calls the patterns from 1 to 7.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on July 01, 2018, 01:02:17 PM
So you want every pattern definitely to appear but only once and the order is random each time you boot up the spell card?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on July 01, 2018, 02:29:30 PM
So you want every pattern definitely to appear but only once and the order is random each time you boot up the spell card?
Yes, basically. Sorry if I explained it badly  :V
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Searinox119 on July 01, 2018, 03:42:10 PM
If I understood the problem correctly, it's that there's no number[3] = number[2]; in your script, so it just stops recording values further than the 3rd slot.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on July 01, 2018, 05:10:01 PM
If I understood the problem correctly, it's that there's no number[3] = number[2]; in your script, so it just stops recording values further than the 3rd slot.
...Thanks, it worked. Wow, I feel so dumb now.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 01, 2018, 08:52:32 PM
fisher-yates

Code: [Select]
let number = shuffle([0,1,2,3,4,5,6]);

function shuffle(a){
  let j; let tmp;
  descent(i in 1..length(a)){
    j = floor(rand(0, i+1));
    tmp = a[i]; // swap i and j
    a[i] = a[j];
    a[j] = tmp;
  }
  return a;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gregory on July 02, 2018, 05:21:26 AM
How can I change the icon and an executable th_dnh.exe of my own that's not relevant to the original exe ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: 7636kei on July 03, 2018, 09:21:44 PM
So, is there any clue to why would the history not advance from 00/xx even after I managed to have the spell captured?
Exhibit 1, captured immediately after capturing the spellcard shown in Exhibit 2. (https://i.imgur.com/kCVuH8j.jpg)
Exhibit 2, snapped after the capture, in both sense, that is Exhibit 1. (https://i.imgur.com/pC4ikrh.jpg)
The entire budding work, I guess. (https://mega.nz/#!6s0h2SyS!rt2_2BNZn82aImKz1--0yEhYqvrD-zByF43QIFByj8A)

(BTW, if it gets released, Warusame is meant to stay in the final work. The gist of the plot is that Tsurubami [as in LE's Tsuru], the local admiral, hires the Gensokyan PC as a mercenary for 'questionable operations' to keep their shipgirl's hand clean from said questionable operations. Considering abyssals and danmaku don't [canonically] mix~)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 03, 2018, 11:24:10 PM
So, is there any clue to why would the history not advance from 00/xx even after I managed to have the spell captured?
Exhibit 1, captured immediately after capturing the spellcard shown in Exhibit 2. (https://i.imgur.com/kCVuH8j.jpg)
Exhibit 2, snapped after the capture, in both sense, that is Exhibit 1. (https://i.imgur.com/pC4ikrh.jpg)
The entire budding work, I guess. (https://mega.nz/#!6s0h2SyS!rt2_2BNZn82aImKz1--0yEhYqvrD-zByF43QIFByj8A)

(BTW, if it gets released, Warusame is meant to stay in the final work. The gist of the plot is that Tsurubami [as in LE's Tsuru], the local admiral, hires the Gensokyan PC as a mercenary for 'questionable operations' to keep their shipgirl's hand clean from said questionable operations. Considering abyssals and danmaku don't [canonically] mix~)

Please provide a MINIMAL, complete, and verifiable example (https://stackoverflow.com/help/mcve). What you're asking is not clear at all - what do the two screenshots have to do with spell history? What library are you using?

Additionally, while it's nice that you're enthusiastic about your project, it has nothing to do with your question, so please focus on providing the details of the question rather than whatever your project's plot is.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on July 07, 2018, 08:24:06 AM
If I'm corect, there is some programmes to make 3D backgrounds for danmakufu (like in the sample), but I don't remember the names. What are they? And is there any english tuturials for them?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on July 07, 2018, 01:55:20 PM
Code: [Select]
//Anything Before?

case(EV_REQUEST_IS_LAST_SPELL){
//What I need to do here, to make a LastSpell?
}

//Anything After?

Please explain how to make a Last Spell, like IN (Hit => end)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on July 07, 2018, 02:07:37 PM
How exactly does ObjMove_SetDestAtWeight calculate the slowing down? Is the weight how long it takes to slow down? Or maybe the distance to the destination when it starts to slow down?

Asking this because apparently Danmakufu crashes if you delete bullets while this funtion is active, so I'm going to create my own.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jimmy on July 07, 2018, 05:33:26 PM
Code: [Select]
//Anything Before?

case(EV_REQUEST_IS_LAST_SPELL){
//What I need to do here, to make a LastSpell?
}

//Anything After?

Please explain how to make a Last Spell, like IN (Hit => end)

Just put this code in @Event and insert SetScriptResult(true) and it should work.
Basically, these event types (including survival spells) only need a boolean to be activated.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 07, 2018, 05:51:45 PM
How exactly does ObjMove_SetDestAtWeight calculate the slowing down? Is the weight how long it takes to slow down? Or maybe the distance to the destination when it starts to slow down?

Asking this because apparently Danmakufu crashes if you delete bullets while this funtion is active, so I'm going to create my own.
The algorithm for ObjMove_SetDestAtWeight is
Code: [Select]
if dist < maxspeed * weight :
  speed = dist / weight
else :
  speed = maxspeed
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 07, 2018, 09:04:15 PM
If I'm corect, there is some programmes to make 3D backgrounds for danmakufu (like in the sample), but I don't remember the names. What are they? And is there any english tuturials for them?

If you're talking about the meshes, then it's Metasequoia (mqo) and Elfreina (.elem) for making them - both are Japanese, but some programs (Blender?) may be able to export to mqo.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on July 08, 2018, 06:40:52 AM
Ok, thanks
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on July 08, 2018, 04:13:56 PM
Hi,

What's the best way to get the ID's of shot objects within a rectangular area?
This is assuming that the rectangle is of any orientation, but the coordinates of the corners of the rectangle are known.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: 7636kei on July 09, 2018, 11:07:58 PM
Please provide a MINIMAL, complete, and verifiable example (https://stackoverflow.com/help/mcve). What you're asking is not clear at all - what do the two screenshots have to do with spell history? What library are you using?

Alright, here goes (https://mega.nz/#!e1t0gCQR!CfHB0_aiOB-IOBPe2Ii-4bVIg53i_JK-BpFmg7hXXM8): minimum known working, trimmed off gtbot's sample script, and minimum known borking, trimmed off my card. (I used gtbot's cutin script on both fullscale and minimum knowns, btw. Also, it appears to me that the cutin script have trouble tracking survivals.)

(Having said that, most of the delay was from recovering out of borked HDD :(
I was bloody lucky I uploaded my entire script to mega, even if it ends up criticised because it's certainly not a minimal example. Mostly because the zip contains pretty much my personal custom (mostly mathematical and movement-task) lib.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 10, 2018, 01:48:59 AM
What's the best way to get the ID's of shot objects within a rectangular area?
This is assuming that the rectangle is of any orientation, but the coordinates of the corners of the rectangle are known.
What is the context? There is a general-purpose answer but it might be simpler based on what you're actually trying to do.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on July 10, 2018, 02:54:20 AM
Hi,

What's the best way to get the ID's of shot objects within a rectangular area?
This is assuming that the rectangle is of any orientation, but the coordinates of the corners of the rectangle are known.

What is the context? There is a general-purpose answer but it might be simpler based on what you're actually trying to do.

I'm supposing creating a StB-like engine. I don't have the exact math on me as I post this, but:
Assuming you don't need to take the radii of bullets into consideration (i.e that you simply wish to detect whether the center of a certain bullet is inside a rectangular area), since that requires the logic easiest to figure out, you'd need the following procedure:
(http://puu.sh/ATP8f/2f2e2ff62a.png)

Suppose ma and mb are the midpoints of a1 and a2, and of b1 and b2, respectively. Then M is the midpoint of ma and mb, thus being the center of the rectangle in question.
So then, you'd have an infinite line marked in red (it's not shown on the diagram, but let's call it L) intersecting ma and mb, and point P2 is the point on L that is closest to P, which is your bullet.

To check whether the bullet is in the rectangular area, check for two things:

There's probably an error somewhere in there, but hopefully someone will have detected it before I get home.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on July 10, 2018, 07:09:30 AM
What is the context? There is a general-purpose answer but it might be simpler based on what you're actually trying to do.

The context is in fact a replication of StB-like behaviour, specifically looking at spell cards in the Sp Stage of Double Spoiler. In other words, I'd like to immediately delete the enemy bullets that happen to be within the rectangle at a given moment.

That said, I'm also interested in extending this concept to changing a bullet's property (eg: aim) when it is caught within this rectangle at a specified frame. The lasers used by the Prismriver Sisters come to mind as a hypothetical example.

I'm supposing creating a StB-like engine. I don't have the exact math on me as I post this, but:
Assuming you don't need to take the radii of bullets into consideration (i.e that you simply wish to detect whether the center of a certain bullet is inside a rectangular area), since that requires the logic easiest to figure out, you'd need the following procedure:
(http://puu.sh/ATP8f/2f2e2ff62a.png)

Suppose ma and mb are the midpoints of a1 and a2, and of b1 and b2, respectively. Then M is the midpoint of ma and mb, thus being the center of the rectangle in question.
So then, you'd have an infinite line marked in red (it's not shown on the diagram, but let's call it L) intersecting ma and mb, and point P2 is the point on L that is closest to P, which is your bullet.

To check whether the bullet is in the rectangular area, check for two things:
  • that the distance between P and P2 is no more than the distance between ma and a1 (or a2 -- they're the same, as well as mb and b1 or b2)
  • that the distance between P2 and M is no more than the distance between M and ma (or mb.)

There's probably an error somewhere in there, but hopefully someone will have detected it before I get home.

Thank you.

From my understanding of this method, it seems that this is simulating a rotational transformation of the rectangle so that x and y displacement can be measured independently. Given that the rotational offset of the rectangle is known, is there a way to get the distances |P-P2| and |P2-M| as trigonometric expressions of the coordinates of P, relative to M, without calculating the coordinates of P2?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 14, 2018, 01:44:03 AM
I'm going to just drop a bunch of stuff because I wanted to explain it all and implement it myself.

The general point in polygon problem has a bunch of different solutions. Here is one based on the winding number; the number of times a curve wraps around a point. Basically, if you look at any polygon in terms of a bunch of edges going in a sequence and wrapping back to the first point, you can say a point is inside the polygon by counting the winding number. If it's 0, the point is outside. This used to be computed by taking angles from the point to each of the polygon's vertices, adding them up, and if it's 360 then it's inside (winding number of 1). But this is expensive because of trig functions and stuff. Instead you can do the following:

(https://i.imgur.com/4u7l1gM.png)

Here you look at an imaginary ray coming from the point, and check where it hits the edges of the polygon. If the edge (moving clockwise around the polygon) is going upwards when the ray crosses it (i.e. the point is on the left-hand side of the edge) the winding number decreases, and if it's going downwards when the ray crosses it (the point is on the right-hand side of the edge) the number increases. Note by left-hand and right-hand I mean relative to the edge in the direction it's "moving". You can see in the picture what's happening, and it's pretty simple here because it's just a rectangle. The same thing applies; if the winding number isn't 0 the point is inside.

Code: [Select]
// `poly` is an array of points like [[x1,y1], [x2,y2], [x3,y3], [x4,y4]] where edges connect between two adjacent points
function is_collided_polygon(x, y, poly){
  let wn = 0;
  poly = poly ~ [poly[0]]; // connect edge from last to first vertex
  ascent(i in 0..length(poly)-1){
    if(poly[i][1] > y){
      if(poly[i+1][1] <= y){ // ascending edge crossing point
        if(point_edge_side(x, y, poly[i][0], poly[i][1], poly[i+1][0], poly[i+1][1]) < 0){ // point left-hand of edge
          wn--;
        }
      }
    }else{
      if(poly[i+1][1] > y){ // descending edge crossing point
        if(point_edge_side(x, y, poly[i][0], poly[i][1], poly[i+1][0], poly[i+1][1]) > 0){ // point right-hand of edge
          wn++;
        }
      }
    }
  }
  // winding number of 0 iff point outside polygon
  return (wn != 0);

  function point_edge_side(px, py, ax, ay, bx, by){
    // AB.x * AP.y - AB.y * AP.x
    return ( (bx - ax) * (py - ay) - (by - ay) * (px - ax) );
  }
}

Calculating which side the point is relative to an edge is done with the perpendicular dot product which is just some multiplication. Look into it yourself if you want to know how that works.



So this works for checking collision just fine, but this was a general solution for polygons with however many sides and doesn't take advantage of the fact that you're using a rectangle. So you can do better.

The next solution is a modified version of a sort-of-common collision algorithm for checking polygon-polygon collision that is based on SAT, the Separating Axis Theorem. You can read more about this algorithm here (http://www.metanetsoftware.com/technique/tutorialA.html) or here (http://www.dyn4j.org/2010/01/sat/). Essentially the gist is that if you can fit a line anywhere between the two polygons they aren't collided. This is then equivalent to finding that if you have imaginary axes parallel to all the polygons' edges, and if any of the projections (like shadows) of the polygons on each of those axes aren't overlapping, they aren't collided, and if they are overlapping on each projection they are collided. Check the above links for some extra visual examples.

The main benefit to this here is that 1) you can simplify one of the polygons to a point which has no axes to check, and 2) the other polygon is a rectangle where the opposing sides would have the same axes, and so you only have to check two.

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

See that here the red lines are the projections the rectangle makes on its own axes. The green point's projection is within the rectangle's projection on both axes (so it's collided), but the blue point fails on one of them (so it isn't collided).

Code: [Select]
function is_collided_rect(x, y, poly){
  return is_point_projected_line(x, y, poly[0][0], poly[0][1], poly[1][0], poly[1][1])
      && is_point_projected_line(x, y, poly[1][0], poly[1][1], poly[2][0], poly[2][1]);

  function is_point_projected_line(px, py, ax, ay, bx, by){
    let abx = bx-ax;
    let aby = by-ay;
    let proj = (px-ax)*abx + (py-ay)*aby;
    let magn = abx*abx + aby*aby;
    return (proj > 0 && proj < magn);
  }
}

How exactly this is done is by checking if the length of those projected lines is between 0 and the rectangle's own projection. Doing the vector projection can be read about here (http://www.sunshine2k.de/coding/java/PointOnLine/PointOnLine.html#step4) and here (https://en.wikipedia.org/wiki/Vector_projection), again requiring some dot products. One other optimization is that while you want to be checking for 0 < (AP . AB) / |AB| < |AB|, getting the magnitude of AB needs a square root so it's better to compute 0 < (AP . AB) < |AB|^2 instead, or 0 < (AP . AB) < (AB . AB) as done in the code.



One last thing is that for both of these methods you can try to cut down the number of times this specific collision checking occurs by only checking points that are within the smallest bounding box that surrounds the rectangle. You only have to compute what the bounding box is once and then use it for all the other checks so it speeds things up by a lot.

You can get all the complete code for these two methods here. (https://gist.github.com/drakeirving/0c82e6a8f9e8239f87900e1bb1e2ac24)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on July 14, 2018, 08:21:54 PM

I'm going to just drop a bunch of stuff because I wanted to explain it all and implement it myself...


Thank you very much for taking the time to share this. It shows some very interesting methods and is a real eye-opener.

So to follow up with a question which I suspect has a relatively straightforward answer:
I notice that you use an array to store the vertices of your polygon, whereas I am currently defining variables within a function to store the vertices, angle and size of the rectangle. Is it preferable to use an array?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 15, 2018, 06:42:29 AM
I use an array here partially because the first method generalizes to polygons with however many vertices, and partially because I didn't want the function call to have a ton of extra coordinate parameters. Some more things to consider:

After looking at it again, you can optimize the SAT method further because a bunch of the values can be precomputed (the AB components and AB ∙ AB). This looks really ugly but cuts computation down enough to be useful. You can then pass these precomputed values in as more parameters, but this method is basically efficient enough that the copying of the function's arguments done when calling the function ("passing by value") bogs down the gains. So it's best to leave them out of the function definition and let the scope take care of things.

Relatedly, this probably meshes just a bit better with the existing stuff you have since you're already computing all the other stuff about the rectangle.

Then, last thing is that I dunno what you're doing to get the list of bullets to check against. In testing I just used raw points; this would be as though I already have a list of all bullets to run through. Because DNH doesn't have something to do that, and I assume you don't have your own bullet management system, you might be tempted to use GetShotIdInCircle over the whole screen or something. What you can do instead, or what you might have already thought of, is to find the half-length of the rectangle's diagonal (sqrt(width^2 + height^2)/2) and then only retrieve the bullets in that radius around the rectangle (the circle circumscribing the rectangle). This pass is basically the same step as the bounding box thing, and if you were already going to use GetShotIdInCircle over the screen anyways and then try to cut that down further, the choice is obvious. In the code below I instead define the rectangle around that size, but that isn't really important.

Here's a complete setup that does basically everything; you can adjust to your setup if you want:

https://gist.github.com/drakeirving/98b64b6023f9e7bec02e60e308ead131
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on July 16, 2018, 08:55:35 PM
I use an array here partially because the first method generalizes to polygons with however many vertices, and partially because I didn't want the function call to have a ton of extra coordinate parameters. Some more things to consider...


Thanks for the explanation and advice.
If there is no benefit for this particular case, I'll probably stick to the way I'm doing it for this script, just to keep all my functions consistent for now. For my case, the measurement only happens once, and the rectangle has fixed size and dimensions. Hence you could say that I'm using 'magic values' that are defined within the function rather than inputting them as parameters. This practice is not frowned upon within the danmakufu community is it? (^_^; )

As for getting the list of bullets, I do in fact use GetShotIdInCircle() at the centre of the shape where the diameter is equivalent to the long diagonal on the rectangle, which seemed easiest for my case, wherein the size is constant but the angle is variable. I can think of other ways to do it, but since they all have to make use of GetShotIdInCircle() at some stage, they always must be more complex. The only other method I can think of is adding bullets to a global list at the time they are fired, which feels like something of overkill for my needs. Is there another method that is useful to know?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on July 16, 2018, 09:59:11 PM
Is there a way to scale the image of a bullet, in a custom shotsheet, without having to change the original picture?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 16, 2018, 10:12:14 PM
All that's fine; whether you use this stuff yourself or not isn't really important. I defined the rectangle in terms of that length mostly because it's already the radius of the bounding circle, and I assume for purposes like StB-style photos the size of the rectangle might be whatever.

Yes, for the broad-phase detection there is that tradeoff between using a circle and a bounding box, as the circle detection is more expensive but the bounding box can sometimes have more to check if the angle is right. But like we both realize if you have to use GetShotIdInCircle anyways there's no reason not to piggyback off of that.

Unfortunately yeah the other main option is to manage the shot IDs yourself. This isn't super difficult at its most basic, but managing a list of objects that might be deleted at any time, and doing so efficiently, can be troublesome, and usually not really worth the effort unless you want to really really do it.

Is there a way to scale the image of a bullet, in a custom shotsheet, without having to change the original picture?
No. Is there any reason you want to do this, when you can just resize the image in a graphics editing program?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on July 17, 2018, 03:40:03 AM
So I've seen either of these videos: https://youtu.be/geTVIgDEO-Y?t=369 (https://youtu.be/geTVIgDEO-Y?t=369) -/- https://youtu.be/oDJpkTZQOiA?t=916 (https://youtu.be/oDJpkTZQOiA?t=916) , and I want to know what implements the slashing effect that cuts off the screen/stage frame and even the bullets (kinda like Yaorochi's sword cutting off the screen during the true final spell scard from Len'en 2).

Can you give me a detail and how is it implemented in coding? I want to know so that I can learn it.

Anyone out there, please respond, thank you.  :wat:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 17, 2018, 04:05:24 AM
So I've seen either of these videos: https://youtu.be/geTVIgDEO-Y?t=369 (https://youtu.be/geTVIgDEO-Y?t=369) -/- https://youtu.be/oDJpkTZQOiA?t=916 (https://youtu.be/oDJpkTZQOiA?t=916) , and I want to know what implements the slashing effect that cuts off the screen/stage frame and even the bullets (kinda like Yaorochi's sword cutting off the screen during the true final spell scard from Len'en 2).

Can you give me a detail and how is it implemented in coding? I want to know so that I can learn it.

Anyone out there, please respond, thank you.  :wat:

You snap a render target of the background layers and turn it into two primitive objects that you move in opposing directions. You will want to put a layer of black underneath the sliding primitive objects to cover the original background, which will need to transition to the original background afterwards.

Note: For reference, I think gtbot did this sometime a few years back along with a replica of Yabusame's bomb effect.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on July 17, 2018, 01:27:45 PM
You snap a render target of the background layers and turn it into two primitive objects that you move in opposing directions. You will want to put a layer of black underneath the sliding primitive objects to cover the original background, which will need to transition to the original background afterwards.

Note: For reference, I think gtbot did this sometime a few years back along with a replica of Yabusame's bomb effect.

(Update) Oh... I get it now. Thanks.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on July 19, 2018, 12:28:01 PM
Hmm... How about... a detail of implementing a code that consists a black hole that sucks/pulls the player towards it (like Utsuho/Okuu's "Artificial Sun")?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on July 19, 2018, 05:01:55 PM
That's pretty easy, actually. You just need a task that looks something like this.

Code: [Select]
task gravity(){
    while(!Obj_IsDeleted(bossObj)){
        ObjMove_SetPosition(GetPlayerObjectID,GetPlayerX+cos(GetAngleToPlayer(bossObj)+180),GetPlayerY+sin(GetAngleToPlayer(bossObj)+180));
        wait(2) //wait(1) might also work
    }
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on July 21, 2018, 07:17:04 AM
That is one way to do it, except it lacks the control over the strength of the 'gravitational pull'. Here is a snippet from my own game which is based on 'strength' (velocity)

Code: [Select]
while(!Obj_IsDeleted(bossObj)) {
x = GetPlayerX;
y = GetPlayerY;

dir = GetPointToPointAngle(GetEnemyX, GetEnemyY, GetPlayerX, GetPlayerY);
ObjMove_SetAngle(locPlayerID, dir);
vx = v * cos(dir);
vy = v * sin(dir);

ObjRender_SetPosition(locPlayerID, x + vx, y + vy, 0);

yield;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on July 24, 2018, 06:25:20 PM
I'm trying to make bullets that bounce off the wall once and then go throught players position (boss shoots at the wall, bullet reflects to the position player was at the moment that bullet was shot) but I'm having trouble calculating the initial angle for the bullet. Can anyone help with this?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on July 24, 2018, 08:56:30 PM
I'm trying to make bullets that bounce off the wall once and then go throught players position (boss shoots at the wall, bullet reflects to the position player was at the moment that bullet was shot) but I'm having trouble calculating the initial angle for the bullet. Can anyone help with this?
Store the player's X and Y position at the moment the bullet is fired, when it hits the wall calculate the angle between the bullet and said position: let angle= atan2(Y2-Y1,X2-X1); X2 and Y2 being the player's stored position, X1 and Y1 the bullet's current position.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on July 25, 2018, 12:54:05 AM
The above is a sensible approach, I'm just wondering why phrase it as though you need an initial angle for the bullets. If the method you would be using to reflect the bullets is a static change in angle, then there is only one possible initial angle to shoot at for a given player position and wall.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on July 25, 2018, 05:52:44 AM
Well, I'm not that good at english, so i probably didn't explain properly. ObjMove_SetAngle(obj, (180 - ObjMove_GetAngle(obj))); this is a formula that i use to reflect the bullets off the right and left walls. I want a bullet to reflect using that formula, but still hit the player. The problem is calculating an angle which boss has to shoot at.

But I actualy figured it out already, so nvm. Still, thanks for the help.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: tkon on August 06, 2018, 12:45:32 AM
Hello, I'm currently working on stages but I'm having a problem with hitboxes.

When I try to get the position of an enemy sprite i created, the playing field is used as referential, which means that  (0, 0) is located at (32,16) on the full game screen (see SetStgFrame() default parameters).
So to get my rect hitbox right, i need to shift it by (-32,-16) in order to be centered with the rendered sprite.

I'm using a function as a fix for the moment but i'd like to know if there is way to make sure the same referential is used everywhere : full game screen or playing field only.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on August 06, 2018, 08:37:03 AM
The thing is that it's done like that as a convenience for the programmer, as you probably shouldn't be doing game-relevant stuff in a context where (0, 0) is the origin, and shouldn't be doing non-game-relevant stuff in the context where (32, 16) is. There's probably an issue with how you're attempting to tackle a problem that's making this more complicated than it should be.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: tkon on August 06, 2018, 10:01:13 AM
The thing is I'm setting the hitbox position just after setting the sprite position :

Code: [Select]
ObjSprite2D_SetDestCenter(objEnemy);
ObjEnemy_SetIntersectionCircleToShot(objEnemy, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 32);
ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 8);

Both functions use a different referential and i don't get why it is actually the case.
Maybe I'm using the wrong function to set it up. The radius has an effect ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on August 06, 2018, 10:17:56 AM
Hi,

Is there a way to change the length of a loose laser while it is moving, such that it becomes shorter?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on August 06, 2018, 01:03:57 PM
Hi,

Is there a way to change the length of a loose laser while it is moving, such that it becomes shorter?

There's ObjLaser_SetLength (https://dmf.shrinemaiden.org/wiki/Shot_Object_Functions#ObjLaser_SetLength) but you'll need to experiment a bit since I think it will shrink from the tip towards the base.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on August 06, 2018, 10:21:27 PM
The thing is I'm setting the hitbox position just after setting the sprite position :

Code: [Select]
ObjSprite2D_SetDestCenter(objEnemy);
ObjEnemy_SetIntersectionCircleToShot(objEnemy, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 32);
ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 8);

Both functions use a different referential and i don't get why it is actually the case.
Maybe I'm using the wrong function to set it up. The radius has an effect ?
Yes, but I'm saying that your sprite shouldn't be centered at (0, 0) of the whole window under normal circumstances. The most common reason you'd have this is if you were drawing the enemy at a render priority considered outside the bounds of gameplay, i.e. outside the range 20~80.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on August 07, 2018, 11:21:32 AM
There's ObjLaser_SetLength (https://dmf.shrinemaiden.org/wiki/Shot_Object_Functions#ObjLaser_SetLength) but you'll need to experiment a bit since I think it will shrink from the tip towards the base.

When I tried this before, it essentially had no visual effect. Both the sprite and the hitbox don't seem to get any shorter, or at least not at the rate that I intended.
I've sidestepped the problem by manually moving a straight laser with the same graphic and dimensions. Nonetheless, it would be nice to know how to implement it with a loose laser for future reference.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: tkon on August 11, 2018, 10:32:36 AM
Yes, but I'm saying that your sprite shouldn't be centered at (0, 0) of the whole window under normal circumstances. The most common reason you'd have this is if you were drawing the enemy at a render priority considered outside the bounds of gameplay, i.e. outside the range 20~80.

Thanks, you're right it fixed it. I increased priority to keep track of mobs after they leave the screen.

I'm wondering, is there a way to reduce frame drop ? When i call the mid boss, in the middle of my stage, FPS tends to halve for few frames before coming back to normal.  Is there a way to preload the boss/mobs to reduce this effect ?

Code: [Select]
task TStage
{
    let dir = GetCurrentScriptDirectory();
    let path = dir ~ "Stage 1/Plural_midBoss.dnh";
    let idScript = LoadScriptInThread(path);
    .
    . my stage
    .
    StartScript(idScript);
    while(!IsCloseScript(idScript) && GetPlayerState() != STATE_END)
    {
        yield;
    }

    .
    . my stage again
    .

    CloseStgScene();
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on August 13, 2018, 02:11:43 PM
Thinking about the spinning straight lasers, I wonder if there's a code that the rotation of a spinning laser is decelerated to 0 (like Yuyuko lasers during the final spell: https://youtu.be/PuU9Rxi_vyY?t=8) before it fires... If  there's one solution, then let me know.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gregory on August 14, 2018, 06:38:43 AM
Thinking about the spinning straight lasers, I wonder if there's a code that the rotation of a spinning laser is decelerated to 0 (like Yuyuko lasers during the final spell: https://youtu.be/PuU9Rxi_vyY?t=8) before it fires... If  there's one solution, then let me know.

Non-directional laser can be spined by using ObjMove_SetPosition around of the boss
For example:
Code: [Select]
ObjMove_SetPosition(obj, ObjMove_GetX(BossObj)+r*cos(ang),ObjMove_GetY(BossObj)+r*sin(ang),ang);
ObjStLaser_SetAngle(obj, numofhowmanylasertobespined);
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on August 14, 2018, 12:55:30 PM
I'm trying to recreate the movement of ObjMove_SetDestAtWeight(); I am using a task that sets the position of the object every frame until it reaches its destination, but I'm having trouble with one part.

It seems that the original command cancels the movement if another ObjMove operation is applied to the object in question. How can I implement this feature?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on August 19, 2018, 11:40:35 PM
How can I make difficulties like Easy, Normal, Hard and Lunatic? (without having to make 4 plurals, since it takes too much space and time?)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on August 20, 2018, 02:16:41 AM
How can I make difficulties like Easy, Normal, Hard and Lunatic? (without having to make 4 plurals, since it takes too much space and time?)

I recommend using CommonData. Refer to https://sparen.github.io/ph3tutorials/ph3u3l24.html
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: CrestedPeak9 on August 20, 2018, 04:34:12 AM
How can I make difficulties like Easy, Normal, Hard and Lunatic? (without having to make 4 plurals, since it takes too much space and time?)

Aside from Sparen's suggestion, I'd also advice you look at how Danmakufu fangames utilize common data to simplify difficulty implementation; I personally like BoSM's pattern difficulty which is coded with arrays containing data for bullet speed, types, shot ways, etc.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: WelshRabbit on August 22, 2018, 06:46:31 PM
I have been wondering how you make aimed player shots (as in, CreatePlayerShotA1(blabla)), I have some kind of idea with GetEnemyBossObjID() (and similar) but I dont think that is enough, and I tried some stuff, it didn't work, does anybody know how to make them?


Edit: nvm I made it
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on August 26, 2018, 02:15:02 AM
Hi, how can I do the humming sound when hitting a boss?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on August 26, 2018, 03:19:22 AM
Hi, how can I do the humming sound when hitting a boss?

The boss can run a loop that keeps track of HP. If HP changes during a frame, then play the sound effect.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on August 26, 2018, 02:47:46 PM
How can I do this effect?(the green aura)
(https://cdn.discordapp.com/attachments/412784674964766720/483286136119361536/unknown.png)
(image taken from the kirbio's Range 15 script, Koishitale)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: AlexKerb on August 26, 2018, 04:37:31 PM
How can I increase playing field's size using camera zoom without changing STG frame?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on August 26, 2018, 04:56:18 PM
Basically you have a task that constantly creates coloured copies of the boss sprite and then enlarges their scale and lowers their alpha, deleting them when the alpha lowers below zero. You might need to mess around with blend types a little to make the aura look nice.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on August 26, 2018, 05:49:22 PM
Basically you have a task that constantly creates coloured copies of the boss sprite and then enlarges their scale and lowers their alpha, deleting them when the alpha lowers below zero. You might need to mess around with blend types a little to make the aura look nice.
Wouldn't it cause some good amount of lag?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on August 26, 2018, 06:26:30 PM
Wouldn't it cause some good amount of lag?

Depends on how many are in existence at any given time as well as other factors. Make sure that you test our your implementation on a proper attack so you can see what the FPS will be *with* bullets and other effects.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on August 26, 2018, 07:04:56 PM
And which function can I use to make the alpha of the boss texture white? (I mean to make the boss all white, but with the opacity)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on August 26, 2018, 07:45:38 PM
And which function can I use to make the alpha of the boss texture white? (I mean to make the boss all white, but with the opacity)

I recommend taking a render target of the boss, and applying a shader that sets every pixel to your desired color while maintaining the alpha channel value
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on August 26, 2018, 07:52:36 PM
I recommend taking a render target of the boss, and applying a shader that sets every pixel to your desired color while maintaining the alpha channel value
How can I do that?(I don't know about neither shaders nor render targets)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on August 26, 2018, 08:45:55 PM
How can I increase playing field's size using camera zoom without changing STG frame?
Not sure if this is possible. There is no "zoom out" for 2D cam afaik.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: FlareDragon on August 27, 2018, 12:26:42 AM
How can I increase playing field's size using camera zoom without changing STG frame?
Not sure if this is possible. There is no "zoom out" for 2D cam afaik.
While it is possible to zoom in and out using Set2DCameraRatio (https://dmf.shrinemaiden.org/wiki/2D_Camera_Functions#Set2DCameraRatio) (or using Set2DCameraRatioX or Set2DCameraRatioY), it doesn't affect the playing field (I think you'd have to use SetStgFrame (https://dmf.shrinemaiden.org/wiki/System_Functions#SetStgFrame) somehow). Haven't been able to figure it quite out, but I'm sure it's there somewhere.

EDIT: So I was playing around with it, and I've gotten somewhere with it: Code for zooming task (https://pastebin.com/gEnveuT2)
Biggest issues I'm having so far, though, is it doesn't seem to quite render the frame properly (though the collision is certainly working properly).

Images: Default Zoom(1) (https://puu.sh/Bl06h/ee25863b39.jpg), Zoomed Out(0.75) (https://puu.sh/Bl0aj/0dd5908a17.jpg), Zoomed In(1.2) (http://puu.sh/Bl0cV/226de5834f.jpg)

Any idea why?
(Also, default collision for shots seem to stop working beyond a certain x- and y-postion, though boss collision definitely works. Seemed interesting enough to note)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: AlexKerb on August 27, 2018, 07:25:22 AM
Maybe with some workarounds and improvements it will work properly? Anyway, thanks for help. And yes, with some workarounds I made 0.7 zoom and it works quite good (no hitbox bugs, just little issues with vision, playable).
https://pastebin.com/t9LPeX8B (https://pastebin.com/t9LPeX8B).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on August 27, 2018, 04:58:23 PM
There is a tutorial explaining render targets? Where can I found it?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on August 27, 2018, 05:29:20 PM
There's one here (https://dmf.shrinemaiden.org/wiki/Render_Targets), but it might be outdated now. You don't need to use render targets or shaders for the aura effect at all, just normal 2D sprite objects and the ObjRender_SetColor function.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on August 27, 2018, 05:31:27 PM
So, I'm trying to implement a continue system. I made a menu appear after pleyer's last life, and after pressing "continue" the game continues, player gets 3 additional lives, but still doesn't revive. It seems that player's state is still at STATE_END and doesn't change even after gaining new lives. What can I do?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on August 27, 2018, 10:07:08 PM
So, I'm trying to implement a continue system. I made a menu appear after pleyer's last life, and after pressing "continue" the game continues, player gets 3 additional lives, but still doesn't revive. It seems that player's state is still at STATE_END and doesn't change even after gaining new lives. What can I do?

You just never let the player lose all their lives. :)

This is what I do:
Code: [Select]
    case(EV_PLAYER_SHOOTDOWN){ //To disable continue system, block comment this case.
            if(GetPlayerLife < 0){ //If equals 0, still have a life left (IE using last life)
                SetPlayerLife(0.123); //Copied from Arby, should prevent STATE_END.
                ContinueSystem;
            }
    }
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on August 28, 2018, 01:29:40 AM
I've managed to learn how to use render targets, and I need to know if I can transform a black image to a white image (I've set the HSV color 0,0,0 and that make the texture black)

Edit:Nevermind, learned how to make a shader.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on August 28, 2018, 02:53:05 AM
HSV (0,0,0) is black and (0,0,100) is white.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on August 28, 2018, 01:52:18 PM
Hm, I never thought you can use anything but integers in life value. Thanks for the help
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on August 28, 2018, 02:07:31 PM
Hm, I never thought you can use anything but integers in life value. Thanks for the help

No problem. It's not intuitive, but it works.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on August 28, 2018, 04:18:39 PM
I've created the aura effect, but now the aura keeps 'escaping' the boss. What can I do to prevent this?
https://pastebin.com/y5jAuUzP
edit:Nevermind again, I was setting the source rect just once.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: AlexKerb on August 31, 2018, 01:12:42 PM
How can I receive x and y coordinates of the laser's end?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on August 31, 2018, 01:19:14 PM
How can I receive x and y coordinates of the laser's end?

One end of the laser is at ObjMove_GetX/Y. The other can be calculated using the length and angle of the laser just as you would do any other radial position calculation: X + length*cos(angle), Y + length*sin(angle).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on September 02, 2018, 01:32:21 PM
Can someone provide me with a working example of replaye save scene? I tried using the default one without any changes, but after I enter the name of replay and press "done"(or whatever this means 終了) error on the first picture appears. Than I tried to change the default script a bit, and I end up with error on second picture and I don't even know what it means. After some manual change in texts that appear, I managed to surpass that problem (just kinda. I made it go away, but the intended result is also unreachable that way), but the first one still appears after that. Here is my replay save script, which is almost fully copied default version https://pastebin.com/nZBKDhAM
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 02, 2018, 01:35:52 PM
Can someone provide me with a working example of replaye save scene? I tried using the default one without any changes, but after I enter the name of replay and press "done"(or whatever this means 終了) error on the first picture appears. Than I tried to change the default script a bit, and I end up with error on second picture and I don't even know what it means. After some manual change in texts that appear, I managed to surpass that problem (just kinda. I made it go away, but the intended result is also unreachable that way), but the first one still appears after that. Here is my replay save script, which is almost fully copied default version https://pastebin.com/nZBKDhAM

I see that you are using "[" and "]"

I recommend escaping these ("[osb]" and "[csb]"? "&osb;" and "&csb;"?) to avoid Danmakufu trying to execute them.

Refer to https://sparen.github.io/ph3tutorials/ph3u2l21.html
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on September 04, 2018, 11:12:28 PM
How can I stop the player from retrying a script with the backspace button?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on September 05, 2018, 02:59:25 AM
I'm getting some kind of error code on the log window when I try to output calculated values:

1.#INF00 for a number
-1.#IND00 for a different number
1.#QNAN0 for a trigonometric function that essentially takes the sum of the above numbers

What do these warnings mean, and what is likely the problem?

Thanks in advance
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 05, 2018, 03:01:03 AM
I'm getting some kind of error code on the log window when I try to output calculated values:

#INF00 for a number
#IND00 for a different number
#QNAN0 for a trigonometric function that essentially takes the sum of the above numbers

What do these warning mean, and what is likely the problem?

Thanks in advance

Please provide the code you are using, the actual error, and more context.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on September 05, 2018, 03:10:20 AM
Please provide the code you are using, the actual error, and more context.

The first number is intended to be angular acceleration of a bullet, calculated by the function

function CalcAngleAccel1(a1,a2,l1,l2,g,m1,m2,a_v1,a_v2){
      let part1 = -1*g*(2*m1 + m2)*sin(a1);
      let part2 = -1*m2*g*sin(a1 - 2*a2);
      let part3 = -2*sin(a1 - a2)*m2;
      let part4 = a_v2*a_v2*l2 + a_v1*a_v1*l1*cos(a1 - a2);
      let part5 = l1*(2*m1 + m2 - m2*cos(2*a1 - 2*a2));
      let ans = (part1 + part2 + part3*part4)/part5;
      WriteLog(ans);
      return ans;
   }
In which a1 and a2 are a set of angles, a_v1 and a_v2 are those angles' respective angular velocities in the previous frame, and l, g and m are constant variables.

This value is then added to the angular velocity (a_v1), which is then added to the angle (a1).
WriteLog(a1) gives the second value.

The third value is provided by WriteLog(sin(-a1))

The intention is to make a bullet follow a path dictated by polar coordinates using this angle, imitating the movement of a double pendulum. At present, the bullet appears to follow an incorrect path, and then vanish (perhaps moving to (0,0)?) when these errors appear.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on September 05, 2018, 03:14:10 AM
Oh, and prior to this, the three numbers begin spiralling out of control, with respect to their magnitudes.

The very last frame before these errors appear also returns a value less than -1 for the trigonometric expression as well.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 05, 2018, 03:35:25 AM
EDIT: Oops; read l as |. @Kinedyme: Please use the [ code ] [ / code] tags (no spaces)

I'm getting some kind of error code on the log window when I try to output calculated values:

1.#INF00 for a number
-1.#IND00 for a different number
1.#QNAN0 for a trigonometric function that essentially takes the sum of the above numbers

What do these warnings mean, and what is likely the problem?

Refer to:
https://stackoverflow.com/questions/347920/what-do-1-inf00-1-ind00-and-1-ind-mean
https://stackoverflow.com/questions/29210975/1-qnan0-output-when-calculating-standard-deviation-c
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on September 05, 2018, 03:50:08 AM
Okay, I'll remember that next time

Thank you, I'll try to add a limit onto the angular acceleration.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 05, 2018, 12:40:18 PM
Okay, I'll remember that next time

Thank you, I'll try to add a limit onto the angular acceleration.

If you angles are the ones exploding, it may help to normalize (angle = angle % 360)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MugenCC on September 05, 2018, 08:07:56 PM
I've tried to use variable pointers the way they're used in C/C++ but it doesn't work. Is there any way to use them in Danmakufu?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 05, 2018, 09:30:20 PM
Definitely not, unfortunately. Objects are not accessed by pointer, but by an integer ID that Danmakufu will then manage internally. Arguments to functions are also passed by value, not by reference.
Are there other particular use cases that you were considering?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MugenCC on September 05, 2018, 09:44:26 PM
I was thinking of functions that used the variables themselves as parameters, as opposed to the values the variables hold at the time.  For example, I wanted to try to make a "Wait until" function, so instead of writing
Code: [Select]
while(!boolean){yield;}, I'd write
Code: [Select]
WaitUntil(boolean);.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 05, 2018, 10:36:17 PM
Yeah, no can do. Technically you can use scope to accomplish this in some sense, i.e.

Code: [Select]
task a(){
  let bool = false;
  function WaitUntilFlag(){
    while(!bool){ yield; }
  }

  task b(){
    // stuff
    bool = true;
  }
  b();

  WaitUntilFlag();

  // finish
}

But that isn't quite the same.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Zinochan on September 07, 2018, 05:08:53 PM
I'm trying to render a Mitori to a script, but when I mirror the scale/angle, the sprite bugs.
https://pastebin.com/tvn4KtZR (code)
Edit:I've managed to correct it and thanks for Sparen for pointing out my linking error
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 07, 2018, 09:45:01 PM
I'm trying to render a Mitori to a script, but when I mirror the scale/angle, the sprite bugs.
https://pastebin.com/tvn4KtZR(code)

You have a malformed URL. Please add a space after your URL (IE separate (code)) to ensure that the link works properly.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on September 08, 2018, 08:26:34 AM
Do shots created by CreateShotB1() and CreateShotB2() output the correct values when called with the functions ObjMove_GetSpeed() and ObjMove_GetAngle() ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Crescendo on September 08, 2018, 09:20:47 PM
I'm trying to replicate a spell card (for practice purposes) and all is going well until:

https://imgur.com/D69b2Za (https://imgur.com/D69b2Za)

...I need a curly bracket? After a wait?

And even if I do add it, it just springs to another problem (movement not defined, CenterX() something, etc.).

Normally I'd just think I messed up since I'm still a coding newbie, but every code I made beforehand worked fine. The only difference between this and previous codes is what the bullets are doing.

Can an extra set of eyes help me out? I'm honestly stumped at this point.

Full code:  https://pastebin.com/aKH9vHMH (https://pastebin.com/aKH9vHMH)

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on September 09, 2018, 04:27:23 AM
Yes. I think it's likely that internally the engine just does a transform into angle/velocity and there's no real difference between bullets created from A or B.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: FlareDragon on September 09, 2018, 12:35:53 PM
I'm trying to replicate a spell card (for practice purposes) and all is going well until:

https://imgur.com/D69b2Za (https://imgur.com/D69b2Za)

...I need a curly bracket? After a wait?

And even if I do add it, it just springs to another problem (movement not defined, CenterX() something, etc.).

Normally I'd just think I messed up since I'm still a coding newbie, but every code I made beforehand worked fine. The only difference between this and previous codes is what the bullets are doing.

Can an extra set of eyes help me out? I'm honestly stumped at this point.

Full code:  https://pastebin.com/aKH9vHMH (https://pastebin.com/aKH9vHMH)
A quick glance show me a missing semi-colon:
ObjMove_SetDestAtFrame(objBoss, GetCenterX(), 112, 60);
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Crescendo on September 09, 2018, 01:26:49 PM
A quick glance show me a missing semi-colon:
ObjMove_SetDestAtFrame(objBoss, GetCenterX(), 112, 60);

*facepalms* Darn you semicolons....

On a serious note though, thank you for your time! I checked the brackets but somehow semicolons slipped my mind.

 I'll keep this in mind for future issues. Thanks again for your time.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on September 11, 2018, 12:16:43 AM
Code: [Select]
The laser generated by the following code appears to have no hitbox detection.
Can somebody please explain to me what's going wrong?

[code>]
laserObj = CreateStraightLaserA1(xPos,yPos,aim,512,5,5,graphic,0);
ObjShot_SetIntersectionEnable(laserObj,true);
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on September 11, 2018, 01:38:09 AM
If you check the documentation (https://dmf.shrinemaiden.org/wiki/Shot_Functions#CreateStraightLaserA1), then you'll see that the sixth parameter is how many frames that the laser exists for before disappearing. You've set that to 5, which means your laser exists for a fraction of a second before disappearing, which isn't enough time for it to impact anything. I also really suggest moving the delay and length up to at least 30 and 20 respectively.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on September 11, 2018, 11:29:03 AM
If you check the documentation (https://dmf.shrinemaiden.org/wiki/Shot_Functions#CreateStraightLaserA1), then you'll see that the sixth parameter is how many frames that the laser exists for before disappearing. You've set that to 5, which means your laser exists for a fraction of a second before disappearing, which isn't enough time for it to impact anything. I also really suggest moving the delay and length up to at least 30 and 20 respectively.

Okay,
So does this mean that it takes time for the laser's hitbox to form? If the laser is aimed directly at the player and is not dodged, then I would expect it to be able to kill the player in that instant, if only for a 12th of a second, given that there is zero delay.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on September 17, 2018, 11:16:47 PM
A few questions about the HUD Frame and System files:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 18, 2018, 02:30:43 AM
A few questions about the HUD Frame and System files:
  • What I need to use to make a Highscore gimmick?
  • How can I make one? Or are there any scripts for research?
  • Should I use a image or Danmakufu's text funcs? (EX: Score, Lives, Difficulty, etc)
  • Help with the Player's Hearts and Stars?
  • Should I use ZUN's HUD rips or try to make a new one?

1: CommonData Areas
2: Pretty much any script that saves High Score data uses Common Data Areas to do so.
3: Images are usually better
4: Depends on what you mean. What kind of system do you want (Life/Bomb fragments? Fairies of Sorcery style? Fairy Wars style?)
5: Do not use ZUN's.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on September 18, 2018, 11:03:58 PM
4: Depends on what you mean. What kind of system do you want (Life/Bomb fragments? Fairies of Sorcery style? Fairy Wars style?)

The old style, without the pieces/fragments ^^
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Ruuriru on September 22, 2018, 08:12:28 PM
Hi!

I'm completely new to Danmakufu, but I've been keeping up with a lot of tutorials from both Helepolis and Sparen when it comes to making scripts.

However, I have had trouble looking for any resources concerning player scripts and I'm left completely in the dust when it comes to this. The one big question I have for this is:

How can I create the little options/familiars that are present with the player? Like Reimu's yin-yang orbs or Marisa's lasers.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 23, 2018, 12:09:52 AM
Hi!

I'm completely new to Danmakufu, but I've been keeping up with a lot of tutorials from both Helepolis and Sparen when it comes to making scripts.

However, I have had trouble looking for any resources concerning player scripts and I'm left completely in the dust when it comes to this. The one big question I have for this is:

How can I create the little options/familiars that are present with the player? Like Reimu's yin-yang orbs or Marisa's lasers.

A familiar is essentially a Render Object with a position relative to GetPlayerX/Y, that just happens to fire player bullets.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on September 23, 2018, 12:42:33 AM
Help, I don't what to put about AreaCommonData to make it a true HiScore...

https://pastebin.com/FGFYdR48
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Ruuriru on September 27, 2018, 04:02:07 PM
i'm now trying parametric equations with my danmaku to make a heart but my issue is that the heart only spawns in one direction regardless of angle

Code: [Select]
task TFire (loopNum, speed, angle, shotID, delay) {
let hx;
let hy;
loop (loopNum) {
hx = (13 * cos(angle)) - (5 * cos(2 * angle)) - (2 * cos(3 * angle)) - cos(4 * angle);
hy = 16 * sin(angle)^3;
CreateShotA1(bossX + (2 * hx), bossY + (2 * hy), speed, angle, shotID, delay);
angle += 360/loopNum;
}
}

is there any way i can fix this to change the direction the heart is pointing? its always pointing at a 180 degree angle
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on September 27, 2018, 04:41:38 PM
i'm now trying parametric equations with my danmaku to make a heart but my issue is that the heart only spawns in one direction regardless of angle

is there any way i can fix this to change the direction the heart is pointing? its always pointing at a 180 degree angle

I recommend researching rotation matrices. They will allow you to rotate a parametric equation arbitrarily and you will not be constrained to the specific curve.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Crescendo on September 30, 2018, 10:59:34 PM
 ̶e̶l̶l̶o̶ ̶s̶e̶m̶i̶-̶c̶o̶l̶l̶o̶n̶ ̶n̶e̶w̶b̶ ̶i̶s̶ ̶b̶a̶c̶k̶ :V

I've been messing with parametric stuff and I want to use tricuspoids (deltoids) for a spellcard I'm making. (http://www-history.mcs.st-and.ac.uk/Curves/Tricuspoid.html (http://www-history.mcs.st-and.ac.uk/Curves/Tricuspoid.html))

...Though I'm definitely doing something wrong as it's coming out as a spiral instead. I've stalked the site a little bit to see if I could piece it together myself, but no luck. How do I fix that?

Code: [Select]
task phantomPrism{
//loop and speed is set weird to make sure it's shaped correctly
let angleT = 90;
PlaySE(charge);
BFX_Charge(ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),150,60);
wait(60);
loop(500){
if(ObjEnemy_GetInfo(objBoss, INFO_LIFE) <= 0){return;}
let obj = CreateShotA1(ObjMove_GetX(objBoss) + (2*cos(angleT) + cos(angleT*2)), ObjMove_GetY(objBoss) + (2*sin(angleT) - sin(angleT*2)), 0, angleT, 204, 0);
angleT += 360/60;
yield;
        }
//ObjMove_SetDestAtFrame(objBoss, rand(GetCenterX -120, GetCenterX + 120), rand(GetCenterY - 100, GetCenterY - 170), 60);
}

Also side question (you don't have to answer this), but general things to keep in mind when putting parametric equations into Danmakufu code? There might be a time when I need more complex equations and I don't want to get into this situation again (especially if the answer turns out to be super obvious)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 01, 2018, 01:23:51 AM
Code: [Select]
let obj = CreateShotA1(ObjMove_GetX(objBoss) + (2*cos(angleT) + cos(angleT*2)), ObjMove_GetY(objBoss) + (2*sin(angleT) + sin(angleT*2)), 0, angleT, 204, 0);

Quote
x = a(2cos(t) + cos(2t)), y = a(2sin(t) - sin(2t))

In your y component you're doing 2sin(t) + sin(2t) instead of 2sin(t) - sin(2t)?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Crescendo on October 01, 2018, 01:55:50 AM
In your y component you're doing 2sin(t) + sin(2t) instead of 2sin(t) - sin(2t)?

Actually saw that earlier and tried that, but it still spirals. Just spawns a little differently.
Now why I didn't put that in when I pasted it here idek. I'll update that.
Even took a leap and changed the first + in the y into a - also, but its still spiraling. 

I know trig is a tricky section, but it's still kinda weird. 

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 01, 2018, 02:48:09 AM
Actually saw that earlier and tried that, but it still spirals. Just spawns a little differently.
Now why I didn't put that in when I pasted it here idek. I'll update that.
Even took a leap and changed the first + in the y into a - also, but its still spiraling. 

I know trig is a tricky section, but it's still kinda weird.

I copy-pasted your code in Danmakufu, multiplied the x and y components by 64 so that you can see the pattern, and it's working perfectly.
[attach=1]
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on October 01, 2018, 06:56:00 AM
I'm just trying to put random curves in Danmakufu to train my math skills (which are horrible lol)

The page of the Rhodonea curve doesn't have the parametric way...
http://www-history.mcs.st-and.ac.uk/Curves/Rhodonea.html (http://www-history.mcs.st-and.ac.uk/Curves/Rhodonea.html)

Code: [Select]
Polar form: r = a sin(kθ)
Cartesian form: (x^2+ y^2)^3 = 4 a^2x^2y^2

I don't even know where to start to transform it :V
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 01, 2018, 01:30:57 PM
Polar form: r = a sin(kθ)
Cartesian form: (x^2+ y^2)^3 = 4 a^2x^2y^2

You can convert polar coordinates to parametric coordinates quite easily. Recall that r = effective radius. Therefore, you can take the sine and cosine to get the y and x components of the radius.

Code: [Select]
task Rhodonea{
        let t = 0;
        let numflowers = 5;
        let radius = 128;
        while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
            loop(5) {
                let effectiverad = radius * sin(numflowers * t);
                let obj = CreateShotA1(ObjMove_GetX(objBoss) + effectiverad*cos(t), ObjMove_GetY(objBoss) + effectiverad*sin(t), 0, 0, DS_BALL_BS_SKY, 10);
                Obj_DeleteAtFrame(obj, 120);
                t += 360/5;
            }
            t += 0.5;
            yield;
        }
    }

[attach=1]

For more references, refer to:
https://sparen.github.io/ph3tutorials/ph3u1l11.html
https://sites.google.com/site/sparensdanmakufututorials/danmakufu-0-12m-tutorials-part-2/008-scripting-createshota-and-trigonometry#TOC-008-07:-Polar-Equations-in-Danmakufu

(And yes, I am referring you to the 0.12m tutorial on polar equations in Danmakufu. This is probably the first time it has ever been relevant in half a decade.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Crescendo on October 01, 2018, 09:21:16 PM
I copy-pasted your code in Danmakufu, multiplied the x and y components by 64 so that you can see the pattern, and it's working perfectly.
Oh wow! Thanks. T̶h̶o̶u̶g̶h̶ ̶I̶ ̶k̶i̶n̶d̶a̶ ̶d̶o̶n̶'̶t̶ ̶u̶n̶d̶e̶r̶s̶t̶a̶n̶d̶ ̶w̶h̶y̶ ̶a̶ ̶6̶4̶ ̶w̶a̶s̶ ̶n̶e̶e̶d̶e̶d̶ ̶i̶n̶ ̶t̶h̶e̶ ̶f̶i̶r̶s̶t̶ ̶p̶l̶a̶c̶e̶.̶.̶.̶ ̶d̶a̶n̶m̶a̶k̶u̶f̶u̶ ̶t̶h̶i̶n̶g̶s̶,̶ ̶I̶ ̶g̶u̶e̶s̶s̶?̶ Nevermind I figured that out. It's for size. There's my error's origin then  :V
Off with experimenting I go.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Jaykin on October 09, 2018, 12:43:45 PM
Hi, i have a problem with my code, the sprite is just not showing up. Its a 32 by 32 sprite.

https://pastebin.com/gaVzrub0

Image:
https://imgur.com/a/iK7RJXK

the sprite's a 32 x 32
Please help me take a look at it.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on October 10, 2018, 04:33:06 PM
Hello, everyone. I'm trying to implement a replay system, but this error on the picture always pops up when i finish writing the name. I use default replay script as the base. It resulted in the same error even before I reworked it. What could be the issue?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 10, 2018, 05:14:55 PM
Hello, everyone. I'm trying to implement a replay system, but this error on the picture always pops up when i finish writing the name. I use default replay script as the base. It resulted in the same error even before I reworked it. What could be the issue?

Please provide a Minimal, Complete, and Verifiable example (https://stackoverflow.com/help/mcve) that includes your code so that we can try to find the problem and work out a solution.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on October 10, 2018, 05:30:52 PM
Hi, i have a problem with my code, the sprite is just not showing up. Its a 32 by 32 sprite.

https://pastebin.com/gaVzrub0

Image:
https://imgur.com/a/iK7RJXK

the sprite's a 32 x 32
Please help me take a look at it.
You're setting the scale of the image to 0,0,0. Take a look at line #89. The scale is set specifically to zero when speed is equal to 0 or when the boss is "moving". No idea why you're doing this.

I think you're using the wrong functions. You're probably looking for ObjRender_SetAngleXYZ because that flips the image around.

Edit:
Another thing for you to consider: Why are you working with animations when you're using a single-frame sprite as boss image? You shouldn't worry at this stage about rendering animations. Just draw the boss sprite and that is about it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on October 11, 2018, 11:46:01 AM
Here's replay scirpt (https://pastebin.com/W8fUSVC1) and part of the package (https://pastebin.com/mQ3SNdtE) I call it in. Hope, that's enought
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on October 11, 2018, 07:00:32 PM
I'm thinking about drawing a boss sprite sheet.
What is a good number of animation frames for idle/movement poses, and what rate is it good for these frames to be cycled?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 11, 2018, 10:05:43 PM
That really just art. The framerate is going to depend on how many frames you draw in order for it to look as intended. The number of frames you draw are going to depend on how smooth or varied you want the animation to be versus the amount of effort. Look for examples of animations you like and just try things.



Reminder there's an unanswered question from the previous page:
Hello, everyone. I'm trying to implement a replay system, but this error on the picture always pops up when i finish writing the name. I use default replay script as the base. It resulted in the same error even before I reworked it. What could be the issue?
Here's replay scirpt (https://pastebin.com/W8fUSVC1) and part of the package (https://pastebin.com/mQ3SNdtE) I call it in. Hope, that's enought
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on October 20, 2018, 07:21:54 AM
How do you create beams of the type that are seen in the Extra of Great Fairy Wars?
So far, I have tried using lasers, but they are very bright, and are bullet-shaped. I would ideally prefer something in a cone or triangular shape.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Crescendo on October 20, 2018, 10:36:48 PM
Is there any simple background scripts I can look at? I'm trying to make one to reference later, but I keep running into problems that turn into another problem once I fix it.  (One moment the brightness increases every non-spell, and next the effect won't even show up, etc. etc. )

The default isn't really helping me, and I'm starting to get a bit of a headache from it  :ohdear:.

if you actually want to look at the mess, here you go https://pastebin.com/sAHLmt8J (https://pastebin.com/sAHLmt8J)
Quick edit: yes, Textures is spelled wrong. I was lazy and kept it for now
Edit: I can't specify to save my life, the current issue is an effect won't appear. The moon is on it's own, so there's no way it's covering it up.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on October 21, 2018, 01:15:30 AM
How do you create beams of the type that are seen in the Extra of Great Fairy Wars?
So far, I have tried using lasers, but they are very bright, and are bullet-shaped. I would ideally prefer something in a cone or triangular shape.

You could probably make it work with lasers if you turned their alpha down and made cones or triangles out of a bunch of small lasers. Probably not the most efficient method though.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 21, 2018, 03:27:55 AM
if you actually want to look at the mess, here you go https://pastebin.com/sAHLmt8J (https://pastebin.com/sAHLmt8J)
This seems more or less fine for something simple. What is the current problem? Are you only running the script once at the start of a stage, or are you starting it on every pattern? That would be my guess as to why things are getting brighter.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Crescendo on October 21, 2018, 03:56:23 AM
This seems more or less fine for something simple. What is the current problem? Are you only running the script once at the start of a stage, or are you starting it on every pattern? That would be my guess as to why things are getting brighter.
I forgot to specify (will I ever learn  :V) that this scripts problem is the effect not showing up (in this case, the fog.)for the basic(nonspell?) background. That's on my end, sorry.

Glad to know it isn't an obvious issue, though (not yet at least, I have a weird feeling it is though). It's just the moon (which is small) and the fog, so it can't be covering it up.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 21, 2018, 06:14:45 AM
Surprise, it is ;P
In the nonspell part you imply that if a spell is active, make those objects visible, rather than invisible. The moon is showing up because you never wrote a line for Obj_SetVisible(obj2, alpha > 0) so it isn't being set to invisible to begin with.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Crescendo on October 21, 2018, 03:07:01 PM
Surprise, it is ;P
In the nonspell part you imply that if a spell is active, make those objects visible, rather than invisible. The moon is showing up because you never wrote a line for Obj_SetVisible(obj2, alpha > 0) so it isn't being set to invisible to begin with.
hahahaha  :V

While you got it the other way around (I wanted both to show, the fog was being invisible (I hope I'm making sense)), that was the source.  I didn't know what it did so I didn't touch it...

One more thing though:

It's taking a long time to load the stage. 5-10 seconds too long. Is this normal? Is there things in a background that affect loading time? How can I avoid that?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 21, 2018, 09:14:41 PM
I know the fog was invisible, I'm saying that the moon being visible is actually accidental because you forgot a line of code. What you wanted to do is add the other Obj_SetVisible and then swap where you say alpha=255 and alpha=0.

alpha > 0 is an expression like you'd put in an if statement that resolves to either true or false. So you can use it directly like that instead of doing if(alpha > 0){ Obj_SetVisible(obj, true); }else{ Obj_SetVisible(obj, false); }

Or really you could just make everything more clear in the code by removing all the `alpha` stuff and have it be like

Code: [Select]
let frame = 0;
   
loop {
    Obj_SetVisible(obj1, !bSpell); // Visible only when spell not active
    Obj_SetVisible(obj2, !bSpell); // Visible only when spell not active
    ObjSprite2D_SetSourceRect(obj1, 0, 0 + (frame*2) % -512, -512, -512 + (frame*2) % -512);
    frame++;
    yield;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Crescendo on October 21, 2018, 10:15:48 PM
stuff
Ah, I see. I was just confusing myself then. Thank you!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on October 22, 2018, 06:53:17 AM
You could probably make it work with lasers if you turned their alpha down and made cones or triangles out of a bunch of small lasers. Probably not the most efficient method though.

This method is okay, but the beam's colour then fades as it gets further away from the source, since the lasers are spreading apart. Is there some way to vary their alpha along the length of each laser to counterbalance this effect?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Keegster2 on October 25, 2018, 08:05:03 AM
I use Windows 10, and Danmakfu's window is really weird. When the window is expanded, the actual game covers only a portion of the window; the rest is just gray space. When not expanded, only part of the game is visible, meaning I can only really play with the former. The config program doesn't work, either. I can't close the program in any way but shutting it down with Task Manager. Is this a problem with Windows 10 in general, or is it specific to how I'm using Danmakufu? (For the record, I do not have AppLocale. I have no idea if these problems are all connected to me not having it.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 25, 2018, 05:16:45 PM
I use Windows 10, and Danmakfu's window is really weird. When the window is expanded, the actual game covers only a portion of the window; the rest is just gray space. When not expanded, only part of the game is visible, meaning I can only really play with the former. The config program doesn't work, either. I can't close the program in any way but shutting it down with Task Manager. Is this a problem with Windows 10 in general, or is it specific to how I'm using Danmakufu? (For the record, I do not have AppLocale. I have no idea if these problems are all connected to me not having it.)

Danmakufu 0.12m or ph3?

If it's ph3, the window size is fixed, but it should run regardless of locale.

If it's 0.12m, you MUST use Japanese Locale to avoid a crash.

Are you attempting to fullscreen the window or something? It may also help to provide a screenshot so that we can better understand your problem.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Keegster2 on October 25, 2018, 07:27:10 PM
Danmakufu 0.12m or ph3?

If it's ph3, the window size is fixed, but it should run regardless of locale.

If it's 0.12m, you MUST use Japanese Locale to avoid a crash.

Are you attempting to fullscreen the window or something? It may also help to provide a screenshot so that we can better understand your problem.
Dang it, I forgot to mention my version. It's ph3. Here's some photos of what the window looks like in both sizes.

[attach=1] [attach=2]
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 25, 2018, 10:30:49 PM
This seems like some sort of odd graphics card issue. The window not expanding to fit fullscreen is not uncommon, and usually there's an option in one's graphics card settings to change how fullscreen behaves. The game size seems to be 800x600 in both cases, but your window size is the default 640x480 (hence the clipping), so that's uh quite strange.

I've attached a config file with default settings, can you plop this in your folder and see if this changes anything? Also, can you describe what you mean by the config.exe not working?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Keegster2 on October 26, 2018, 12:15:03 AM
I've attached a config file with default settings, can you plop this in your folder and see if this changes anything? Also, can you describe what you mean by the config.exe not working?
I can change the window style settings in config.exe just fine, but I can't change the screen refresh rate to 1/2 or back to 1/1, if I change it to 1/3 or Flexible. The close, Start Game, OK, and Cancel buttons don't do anything when I click on them. The Exit command located in the File(F) button in the taskbar does nothing, either, even when I press Alt + F4. In addition, despite the window style being set to a window, the window size section is completely blank.
The Danmakufu Wiki says to set my compatibility mode to Windows 2000 in order to get it working, but Windows 10 doesn't have that as an option. I've tried setting it to the earliest version available, Windows 95, but that didn't work.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 26, 2018, 01:39:47 AM
That is very wrong, there aren't the tabs for Device/Key/Option either. Have you tried using the config.dat file I provided? Is this a fresh download? If not, can you try redownloading from the main site (http://www.geocities.co.jp/SiliconValley-Oakland/9951/pre/th_dnh_ph3.html)?

To be clear, this should not strictly have anything to do with W10; people use DNH fine with it without any compatibility settings, including myself. If you're asking because this is a new computer, it could be any number of things, but I see this is a laptop so my suspicion is immediately with the graphics.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Keegster2 on October 26, 2018, 01:45:41 AM
I have no idea how to use the .dat. Do you just place it in the same folder as config.exe?
I'm 100% sure I'm using the latest version from the original site. I tried uninstalling it previously, but it didn't fix any of my problems. (And for the record, this is not a new laptop. I've had it since last year.)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 26, 2018, 02:00:41 AM
Yes, just place it in the folder and overwrite the old one, that's where the settings are saved that you'd modify with config.exe, so I'm just getting around the program not working for you.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on October 26, 2018, 12:36:52 PM
How does one pass a value to a task by reference?

Specifically, I'd like to pass an array containing shot object ids, which can be managed by three separate shot-generating tasks at once.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 26, 2018, 02:10:05 PM
There are two methods I can think of to achieve what you are trying to do:

One is to make the array global. There will be no race conditions due to the single threaded execution, but you will need to maintain the array properly.

The other is to forcefully 'pass by reference' (not really passing by reference) using Obj_SetValue. In this case, you have an object whose ID is passed to the tasks, and the Object has a value set to the array. Any changes to the array within a task will be consistent across the tasks.

In both cases, be aware that the order of execution for the tasks is not predictable, so you cannot expect the array to be updated by certain tasks in a certain order.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on October 26, 2018, 05:07:32 PM
Forgive me, but I've never used this function before, and I'm not completely clear on what it's doing from the documentation alone.
Is it creating a pointer with a character ID?

It also seems to be suggested that I may have to clean up after finishing with the 'key' by using Obj_DeleteValue(), is this correct?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 26, 2018, 05:14:15 PM
Forgive me, but I've never used this function before, and I'm not completely clear on what it's doing from the documentation alone.
Is it creating a pointer with a character ID?

It also seems to be suggested that I may have to clean up after finishing with the 'key' by using Obj_DeleteValue(), is this correct?

Object Values are like extra attributes.

Obj_SetValue(obj, "New_Field", <value>) uses the integer Object ID to locate the object instance, then adds the attribute "New_Field" to the instance. The type of "New_Field" is defined to be the type of the value.

Note that the attribute is local to the instance of the object. When the object is deleted, all its attributes are deleted as well.

I would not use the term pointer in this case since Danmakufu doesn't have Pass By Reference at all.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on October 26, 2018, 05:37:55 PM
Object Values are like extra attributes.

Obj_SetValue(obj, "New_Field", <value>) uses the integer Object ID to locate the object instance, then adds the attribute "New_Field" to the instance. The type of "New_Field" is defined to be the type of the value.

Note that the attribute is local to the instance of the object. When the object is deleted, all its attributes are deleted as well.

I would not use the term pointer in this case since Danmakufu doesn't have Pass By Reference at all.

Um... So it's defining a type?
How exactly is this used to reference obj from a task?
And is this different from the what would be returned by making a variable '= obj' ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 26, 2018, 06:55:13 PM
Um... So it's defining a type?
How exactly is this used to reference obj from a task?
And is this different from the what would be returned by making a variable '= obj' ?

Danmakufu doesn't require explicit type declarations.

As long as you have an object ID, you can access the object from any location as long as it has not been deleted.
Object IDs can be passed as parameters to a task or function.

I don't quite understand what you mean by '= obj'.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on October 26, 2018, 07:27:33 PM
Danmakufu doesn't require explicit type declarations.

As long as you have an object ID, you can access the object from any location as long as it has not been deleted.
Object IDs can be passed as parameters to a task or function.

I don't quite understand what you mean by '= obj'.

My last question was querying if there would be a difference between using:

let objID = obj;
Task(objID)

...as opposed to:

Obj_SetValue(obj,"New_Field",<value>);
let objID = "New_Field";
Task(objID)

Incidentally, is this the right way to use this function for the purpose I'm intending?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on October 26, 2018, 08:42:59 PM
No, that isn't correct.

Object value tables are essentially dictionaries (https://en.wikipedia.org/wiki/Associative_array) mapping strings to arbitrary values, and the table is attached to an object. Common Data are exactly the same thing, but are program-global instead of object-local.

Code: [Select]
let obj = Obj*_Create();
Obj_SetValue(obj, "field", value);
let x = Obj_GetValue(obj, "field"); //-> x = value

Sparen is suggesting that something like this is possible:

Code: [Select]
let obj = Obj*_Create();
Obj_SetValue(obj, "shots", shot_array);
Task1(obj);
Task2(obj);
task Task1(){
  let local_shot_array = Obj_GetValue(obj, "shots");
  // modify local_shot_array
  Obj_SetValue(obj, "shots", local_shot_array);
}
task Task2(){
  let local_shot_array = Obj_GetValue(obj, "shots");
  // modify local_shot_array
  Obj_SetValue(obj, "shots", local_shot_array);
}

Personally I don't think there's much reason in this case not to just use the function scope here unless we're given more info:

Code: [Select]
let shot_array = bla;
Task1();
Task2();
task Task1(){
  // access shot_array directly
}
task Task2(){
  // access shot_array directly
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on October 28, 2018, 02:24:11 PM
So as I put an opening bracket in the save replay, this error pops up.

[attach=1]

Is there anything than can help? Let me know if there's one.

Please Respond! :wat: Thank you.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on October 29, 2018, 02:09:34 PM
So as I put an opening bracket in the save replay, this error pops up.
Is there anything than can help? Let me know if there's one.

Please Respond! :wat: Thank you.

What do you mean by 'I put an opening bracket in the save replay'? Please walk us through your code and the steps taken to generate the error. It may be a case where you need to use osb/csb or disable Syntactic Analysis on a Text Object, since [ and ] have historically been fickle in regards to replays.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Earlh21 on November 05, 2018, 07:55:38 PM
I'm trying to render a simple sprite in Danmakufu ph3, but am having problems. Trying to render this sprite: (https://i.postimg.cc/s2qPckKN/brokenheart.png) gives me this: (https://i.postimg.cc/sgS3xSqG/Untitled.png), with this code run every frame:
Code: [Select]
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
Obj_SetRenderPriority(obj, 1);
ObjPrim_SetTexture(obj,GetCurrentScriptDirectory()~"brokenheart.png");
ObjSprite2D_SetSourceRect(obj,0,0,20,16);
ObjSprite2D_SetDestCenter(obj);
ObjRender_SetPosition(obj,floor(x),floor(y),1);
The image I'm trying to render is 20x16. Rendering a 16x16 image this way works perfectly - the image appears very crisp: (https://i.postimg.cc/3JFPcBsB/Untitled.png). Any ideas?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on November 06, 2018, 06:32:37 PM
I'm trying to render a simple sprite in Danmakufu ph3, but am having problems. Trying to render this sprite: (https://i.postimg.cc/s2qPckKN/brokenheart.png) gives me this: (https://i.postimg.cc/sgS3xSqG/Untitled.png), with this code run every frame:
Code: [Select]
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
Obj_SetRenderPriority(obj, 1);
ObjPrim_SetTexture(obj,GetCurrentScriptDirectory()~"brokenheart.png");
ObjSprite2D_SetSourceRect(obj,0,0,20,16);
ObjSprite2D_SetDestCenter(obj);
ObjRender_SetPosition(obj,floor(x),floor(y),1);
The image I'm trying to render is 20x16. Rendering a 16x16 image this way works perfectly - the image appears very crisp: (https://i.postimg.cc/3JFPcBsB/Untitled.png). Any ideas?

Can you provide more context? Please include the sprite itself (as an attachment/link) and some additional code around the code you provided.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Earlh21 on November 06, 2018, 07:13:14 PM
I can't find where to attach files. Full code for the script is here: https://pastebin.com/raw/8nTtsfz3. The sprite I'm trying to render can be downloaded here: https://postimg.cc/tY4MXTd5.

I changed the rendering a bit so that the sprite no longer stacks up every frame, solving the issue somewhat. The image is still blurry, however: (https://i.postimg.cc/x1Gf8FvN/Untitled.png). It's supposed to be rendered like this: (https://i.postimg.cc/k5cg1hDP/Untitled.png) (this screenshot is from Undertale). The purpose of this is for a player script. I have the same code in my player script with the same issues; I'm using this single script just to test it. Here's a copy of the same script but without references to anything but the image I'm trying to render: https://pastebin.com/raw/TzrbBuJ4.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on November 06, 2018, 07:44:29 PM
The image is still blurry, however: (https://i.postimg.cc/x1Gf8FvN/Untitled.png).

You must use a multiple of 2 for your image dimensions or directX will blue the image. I recommend just adding padding on the right and bottom of your image s.t. it becomes 32x32
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Earlh21 on November 07, 2018, 02:22:16 AM
This works, thank you.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 07, 2018, 06:12:34 AM
By the way, I highly recommend restructuring how you render the sprite. You don't have to create a new sprite every frame at some coordinate and then immediately delete it to simulate movement. Also, I'm not too sure why you're using add blend over alpha blend, but if that is your intention you should be using BLEND_ADD_ARGB instead, which is for images that have transparency.

If you're using it as the player sprite, the player object has the same properties as any other 2D sprite object, so you can even just do this:

Code: [Select]
let objPlayer = GetPlayerObjectID();
task RenderPlayer(){
ObjRender_SetBlendType(objPlayer, BLEND_ADD_ARGB);
ObjPrim_SetTexture(objPlayer, GetCurrentScriptDirectory() ~ "brokenheart.png");
ObjSprite2D_SetSourceRect(objPlayer, 0, 0, 20, 16);
ObjSprite2D_SetDestCenter(objPlayer);
}

And then run RenderPlayer() in @Initialize.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Earlh21 on November 07, 2018, 02:53:45 PM
I can't just set the texture to the player because decimal coordinates cause the image to be blurry. I tried flooring the player's position every frame, but that ended up causing movement problems. Rendering the image as its own sprite with floored coordinates works. I used a new sprite every frame because it gave me more control over rendering, but I think a continuous task would be more concise.

How would I go about removing the default boss health bar?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on November 07, 2018, 03:06:42 PM
How would I go about removing the default boss health bar?

The default health bar is defined with TBossLife? in the system script. For more information on System scripts, refer to
https://sparen.github.io/ph3tutorials/ph3u2l19.html

In addition, if your aim is Undertale style gameplay, there *is* an engine for that specifically (Unitale?). I haven't heard much about it recently since its hype went down with the rest of the game over time, but it may be a better option depending on what your aim is.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 08, 2018, 08:49:16 AM
I can't just set the texture to the player because decimal coordinates cause the image to be blurry. I tried flooring the player's position every frame, but that ended up causing movement problems. Rendering the image as its own sprite with floored coordinates works. I used a new sprite every frame because it gave me more control over rendering, but I think a continuous task would be more concise.
Ah you already got to that; I was going to save that for the next step because I figured you'd have an issue with that. It's done pretty much as you think it is:

Code: [Select]
task DrawHeart(){
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj, dir~"brokenheart.png");
ObjSprite2D_SetSourceRect(obj, 0, 0, 20, 16);
ObjSprite2D_SetDestCenter(obj);

while(!Obj_IsDeleted(objPlayer)){
ObjRender_SetPosition(obj, floor(ObjMove_GetX(objPlayer)), floor(ObjMove_GetY(objPlayer)), 0);
yield;
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on November 09, 2018, 02:31:51 PM
Can the rendering angle (on the Z-axis) be set for the vertex of a 2D_SPRITE_LIST object?

And a follow up question, if the answer to the above is yes, can a different angle be set for different vertices of the same object?

Thanks in advance.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 09, 2018, 10:57:30 PM
Yes and yes. You would set up the angle change before adding each sprite, just as you would for any other property. Example:

Code: [Select]
let obj = ObjPrim_Create(OBJ_SPRITE_LIST_2D);
ObjPrim_SetTexture(obj, dir~"enm_test.png");
ObjSpriteList2D_SetSourceRect(obj, 0, 0, 32, 32);
ObjSpriteList2D_SetDestCenter(obj);
ascent(i in 0..10){
ObjRender_SetPosition(obj, 100+i*20, 100+i*20, 0);
ObjRender_SetAngleZ(obj, i*36);
ObjSpriteList2D_AddVertex(obj);
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on November 13, 2018, 06:09:47 PM
Does the event EV_HIT get called before the counter bomb period set by SetPlayerRebirthFrame() ?
If yes, is there an event that is called after? If no, is there an event that is called before?

I have similar queries regarding the EV_PLAYER_SHOOTDOWN event.

Thanks in advance.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 14, 2018, 02:37:43 AM
I don't really know what you mean by "before" or why this is important. EV_HIT is called the frame you are hit, and the counterbomb period also naturally starts the frame you are hit. There is no real order of execution here because either you're pressing bomb or you aren't. Your question is unclear.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on November 14, 2018, 08:08:38 AM
Ah, so for example, I have code executed upon EV_HIT that does stuff like create a death explosion, delete options and set the alpha of the player sprite to zero; thence if EV_HIT is called upon being hit, and then a few frames later the player successfully counter bombs, then the player seems to respawn, but with an invisible sprite and no options.

So it would subsequently be useful if there was a way to delay the necessary actions until after the counterbomb period is exhausted, or to insead link them to an event that is called only when the player is completely dead.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on November 14, 2018, 10:22:49 AM
To me it sounds you're trying something very unstable and complex or your order of execution is faulty. My guess is a combination of both.

You should not handle any logic in EV_HIT because it is as you describe, called upon hit. It will conflict with countercomb periods and other things. A player isn't "dead" upon hit. It is when the counterbomb timer kicks in. Only after the counterbomb timer ended, the player state will be set to really dead. Meaning you cannot even counterbomb if you tried to.

Are you aware of EV_PLAYER_SHOOTDOWN and EV_PLAYER_REBIRTH ? Because those last two are the events you should handle logic such as remove / spawn objects etc etc.

Snippet from my own game:
Code: [Select]
case(EV_PLAYER_SHOOTDOWN) {
pichuunHandler;
PlaySFX(SFX_PLDEAD01);
DeleteShotAllEX(TYPE_SHOT,TYPE_IMMEDIATE,GetPlayerX,GetPlayerY);
}
case(EV_PLAYER_REBIRTH) {
SetPlayerSpell(2);
SetPlayerInvincibilityFrame(240);
invincEffect(240);
SetForbidPlayerShot(false);
SetForbidPlayerSpell(false);
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on November 15, 2018, 08:19:26 AM
I take it that this means that EV_PLAYER_SHOOTDOWN is the one that is only called after the player is actually dead then?

I'll use that in this case.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on November 15, 2018, 09:16:39 AM
I take it that this means that EV_PLAYER_SHOOTDOWN is the one that is only called after the player is actually dead then?

I'll use that in this case.
If you want to be really sure, output a debug text on screen and modify the value inside EV_HIT and EV_PLAYER_SHOOTDOWN and EV_PLAYER_REBIRTH. Counterbomb when hit and monitor what the value becomes. Then you will see/understand the flow of "pichuun"
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: DichotomousCreator on November 15, 2018, 12:54:46 PM
Okay, so I am working on a Plural script and have somehow managed to break whatever Danmakufu does to end the script. After defeating the boss, they disappear as normal, health bar goes away, etc, but the EndScript script is never called so you don't get the option to save replays and so on.

I've narrowed it down to this standard block of code not clearing:

Code: [Select]
task TPlural {
    let obj = ObjEnemyBossScene_Create();
    //Singles added to boss scene here...
    ObjEnemyBossScene_LoadInThread(obj);
    ObjEnemyBossScene_Regist(obj);
    while(!Obj_IsDeleted(obj)){
    yield;
    }
    //Execution never reaches this point
    CloseScript(GetOwnScriptID());
}

TPlural is present in the Plural script, and is called by @Initialize as normal

From what I can tell from the logs, the while statement runs basically once per boss phase and the idea is that after the last boss phase the plural notices that the boss scene has been deleted due to lacking any further single scripts and closes itself. This then ends the whole script if you're running the Plural in isolation. However, by putting a WriteLog in the while statement I've found that it doesn't seem to be executing after the last boss phase at all! As a result, the last time Obj_IsDeleted(obj) is checked it returns false, it's never checked after it becomes true (if indeed it IS becoming true...), CloseScript(GetOwnScriptID()) never executes, and the script fails to terminate. Instead, the player just flies around on an empty screen endlessly and pointlessly.

My current hypothesis is that something I did somewhere else is somehow not "returning" execution to the Plural and is just spinning forever, but I have no idea how Danmakufu normally handles this stuff and thus no idea what change might have busted it, and it seems weird that the Plural would be successfully checking after every script BUT the last one (something I verified with writeLog). To compound the problem, I only discovered the issue after a LOT of changes to the script since I was not playing it all the way through while editing it! Additionally, the problem isn't specific to any one single as I have tried using several different singles by themselves and the script still fails to end after the single is defeated.

I don't expect anyone to be able to solve the problem based on this admittedly terrible diagnostic information, so all I really want is to know what determines when the while statement in the standard TPlural task is checked (i.e. when the TPlural task gets to execute a frame, as it is clearly not just "on every frame") and maybe some theories on what could cause it to not execute after the EnemyBossScene has been deleted. I think with that I can probably go figure out which change is causing the check to not occur. The script has some custom events and visual effects, but otherwise nothing too fancy I didn't think.

EDIT: Okay, so I compared to an old test script and found that the TPlural task SHOULD be running every frame, but for some reason isn't. This is likely the cause of the issue, as it's simply not running on any frame where the script is over. However, I have no idea what could have caused this.

EDIT: Alright, I've commented out so much of the script that it literally just displays a black screen and all you can do is shoot or bomb the boss (which is at 0, 0 with no animation) to kill it. This STILL fails to end the script, and WriteLog shows that tasks in the Plural are still stopping executing. I think that means it has to be a problem with the player script.

EDIT: ...
...
...
I deleted the @MainLoop in my plural
I have no idea when or how this happened
Somehow the only symptom this led to was the script not ending properly
I remember thinking it was weird that stuff I was putting in the Plural wasn't happening every frame a while back, so it must have been before then
I will leave this post up as a monument to my idiocy
(seriously I even misread the logging and didn't understand what it was doing, and basically stumbled upon the problem by sheer luck)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: GhostPhanom on November 15, 2018, 05:10:10 PM
I want to display the filepath of a script but Windows uses '\' instead of '/' and they are displayed as ? instead of '\'.
Is there a easy way to retrieve the position of a '\' within a string so i can replace it with a '/'?
I know that '\' is the escape character. So code like below returns an error.
"The length of a character type value is only 1"
Code: [Select]
let index = SearchChar(Text, 0, '\');
function SearchChar(Text, startindex, Char)
{
let index = -1;
ascent(i in startindex..length(Text))
{
if(Text[i] == Char){index = i;break;}
}
return index;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: DichotomousCreator on November 16, 2018, 03:02:59 AM
I want to display the filepath of a script but Windows uses '\' instead of '/' and they are displayed as ? instead of '\'.
Is there a easy way to retrieve the position of a '\' within a string so i can replace it with a '/'?
I know that '\' is the escape character. So code like below returns an error.
"The length of a character type value is only 1"
Code: [Select]
let index = SearchChar(Text, 0, '\');
function SearchChar(Text, startindex, Char)
{
let index = -1;
ascent(i in startindex..length(Text))
{
if(Text[i] == Char){index = i;break;}
}
return index;
}

I'm not 100% positive this is how it works in Danmakufu, but usually the way you can do this is you can in fact escape the escape character itself. So you'd want:

Code: [Select]
let index = SearchChar(Text, 0, '\\');

This would then be seen as a single backslash character, as the first backslash escapes the second one.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 16, 2018, 06:42:36 AM
The problem is that DNH itself handles the character fine, but the script interpreter is faulty in that it only sees that there are two characters being wrapped by single quotes, so it throws the error before it tries to parse what the contents are. If you're performing comparison, you can use char+0 to force characters into their numerical representations (backslash is 92), but you can also get the character indirectly with something like
Code: [Select]
"\\ "[0]
Note that some of DNH's path functions already use forward slashes, it's just some of them that use backslashes, like GetModuleDirectory.

Code: [Select]
function replace(str, a, b){
ascent(i in 0..length(str)){
if(str[i] == a){
str[i] = b;
}
}
return str;
}

let fixedpath = replace(path, "\\ "[0], '/');
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: GhostPhanom on November 16, 2018, 02:51:24 PM
''+0 does not work but "\ "
Thank you for your assistance.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 17, 2018, 02:08:31 AM
Yeah, for the former I meant something like this:
Code: [Select]
let path = GetSomeKindOfPath(); // returns "C:\Users\Name\Desktop\"
ascent(i in 0..length(path){
  if(path[i]+0 == 92){
    path[i] = '/';
  }
}
print(path); // => "C:/Users/Name/Desktop/"
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on November 19, 2018, 01:55:55 PM
Where is the ideal place to put the code for dialogue before a boss battle?
Should it be part of the stage script, plural, attached to the first single script, or in a single of its own?

Same question applies to post-battle dialogue, in the event that the answers are different.

Thanks in advance
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gregory on November 19, 2018, 05:04:10 PM
Where is the ideal place to put the code for dialogue before a boss battle?
Should it be part of the stage script, plural, attached to the first single script, or in a single of its own?

Same question applies to post-battle dialogue, in the event that the answers are different.

Thanks in advance

depends, but I put it on the single and after the dialogue, you set the hp to 0 to initiate the first non-spell
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on November 20, 2018, 01:54:46 AM
The most common way you'll see is to have the first entry in the plural be a script just for the dialogue. This makes some things easier because the boss enemy object stays consistent and it transitions pretty smoothly into the first pattern.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on November 29, 2018, 10:50:35 PM
What does the 'DnhViewer.exe' program in the top danmakufu directory do?

Is there a manual somewhere for how it works? Preferably one in English?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tad Marx Barba on December 01, 2018, 04:29:47 AM
Hello Everyone here... I need youy help with a player script (URL: https://www6.zippyshare.com/v/HA2PPec6/file.html (https://www6.zippyshare.com/v/HA2PPec6/file.html))

This player script is almost completed, but, I found a strange thing that occurs when I put the lines
Code: [Select]
SetForbidPlayerShot(true);
SetForbidPlayerSpell(true);
and the spell's lasers are gone. The things that happens are Darken Screen and the Sound Effect of my player's bomb are visible, but lasers are missing.

Can you teach me how to do complex player bombs?
Talk me in private or in my Facebook Account: https://www.facebook.com/tzury.van.heltz (https://www.facebook.com/tzury.van.heltz)

I would greatly appreciate it!  ::) ::) ::)


My other player script: https://www62.zippyshare.com/v/Vr78Viu4/file.html (https://www62.zippyshare.com/v/Vr78Viu4/file.html)
I need a review of this script...Please comment EVERYTHING that I'm need to improve in player scripts

Sound effects and sprites are not my responsibility,
credits to the intellectual authors of the material used in this player scripts
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on December 03, 2018, 12:49:32 AM
If you have SetForbidPlayerSpell set, you can't trigger EV_REQUEST_SPELL, so your bomb will not activate. It's structured correctly.

If SetForbidPlayerShot is set during the bomb, before the lasers appear, they won't appear because shots are disabled. This should be pretty normal behaviour though, why is this a problem?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tad Marx Barba on December 03, 2018, 06:40:57 AM
If you have SetForbidPlayerSpell set, you can't trigger EV_REQUEST_SPELL, so your bomb will not activate. It's structured correctly.

The bomb activate in the correct form, but the lasers are gone when I put the line
Code: [Select]
SetForbidPlayerShot(true);What can I do in this case? Or how could do that bomb in other way?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on December 03, 2018, 08:54:23 AM
The lasers are also player shots, so if you forbid player shots they will not fire. Why are you trying to forbid player shots? Do you just want to stop the player from firing while the spell card is active?

If this is what you want, you can add if(!IsPlayerSpellActive()) as a condition to fire your main player shots. You should also add some kind of wait before you delete the spell manager object, since that's the signal to say the spell is finished.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tad Marx Barba on December 03, 2018, 07:22:48 PM
The lasers are also player shots, so if you forbid player shots they will not fire. Why are you trying to forbid player shots? Do you just want to stop the player from firing while the spell card is active?

Yes, I'm trying to forbid the player shots from firing during the spellcard.

If this is what you want, you can add if(!IsPlayerSpellActive()) as a condition to fire your main player shots. You should also add some kind of wait before you delete the spell manager object, since that's the signal to say the spell is finished.
Is that so easy to do? (sorry I'm new in creating player scripts, I want create MY OWN PLAYER SCRIPTS in order to quit using the player scripts that others made, I'm not comfortable using scripts that aren't mine)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on December 03, 2018, 08:21:27 PM
Is that so easy to do? (sorry I'm new in creating player scripts, I want create MY OWN PLAYER SCRIPTS in order to quit using the player scripts that others made, I'm not comfortable using scripts that aren't mine)
If that is the case, then it is highly suggested to read and follow tutorials so you will be making your own player scripts.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tad Marx Barba on December 03, 2018, 10:25:33 PM
If that is the case, then it is highly suggested to read and follow tutorials so you will be making your own player scripts.
Where I search that tutorials? I need to improve my skills in creating player scripts!  :D :D :D :D

But I still have that question, How to use IsPlayerSpellActive ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on December 04, 2018, 02:07:56 AM
In your foxShot task, you would add the condition before firing your player shots:

Code: [Select]
while(!Obj_IsDeleted(ID))
{
if(!IsPlayerSpellActive){
if(GetVirtualKeyState(VK_SHOT) == KEY_PUSH||[...]
[...]
}
wait(5);
}

If you only change this, it will seem like it doesn't do anything. This is because in your spell you delete the spell manager object right after you fire all the lasers:

Code: [Select]
task Bloody_Laser(frame, num, amnt)
{
[...]
// loop firing lasers
OSCURECER_PANTALLA(GetPlayerX(), GetPlayerY(), 40, [50, 110, 255], 405);
Blink;
Obj_Delete(man);
}

Which ends the spell after only a couple frames, even though the effects and lasers will still exist. You can see this if you try spamming bombs; you will get three of them overlapping at once.

If you add a delay before you delete the spell manager object, to mark where the spell should end, it will fix this issue:

Code: [Select]
task Bloody_Laser(frame, num, amnt)
{
[...]
// loop firing lasers
OSCURECER_PANTALLA(GetPlayerX(), GetPlayerY(), 40, [50, 110, 255], 405);
Blink;
wait(300);
Obj_Delete(man);
}

These two changes will be enough to stop the player from firing during the spell.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tad Marx Barba on December 04, 2018, 03:14:08 AM
So much Thanks Drake! I still learning how to do somethings in player script, 'cause I'm new in that

After take a bath, I couldn't stop thinking what was I've to do in that, I thought that putting the if conditional then the while loop of the player shot could be a way to correct the problem with the line
Code: [Select]
SetForbidPlayerShot(true);
But I couldn't thought that I have to put a wait before the spell manager erased. Thank you very much, Drake!  :blush: ::) ::)

I'll credit you for your help!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on December 05, 2018, 12:24:55 PM
I've noticed that when a text object inserts a line break in a string due to it hitting max length, the line break can be added in the middle of a word. Is there a way to stop this behaviour, short of manually specifying all line breaks?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on December 05, 2018, 02:39:26 PM
I've noticed that when a text object inserts a line break in a string due to it hitting max length, the line break can be added in the middle of a word. Is there a way to stop this behaviour, short of manually specifying all line breaks?

I wrote a library for this.

https://github.com/Sparen/Sparen-DNH-STL/blob/master/lib_autoformat.dnh
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kappapa on December 05, 2018, 09:24:00 PM
Hello everyone, this is my first post here and I really hope that someone can help me :)

So! Recently I got into Danmakufu, more than once I tried to script in the past, but I always gave up until now. I already created a Spell Card for Yuyuko, Ringo and Sagume, just as a practice. Now I'm creating another one for a random character, but there is something that is bugging me:

Basically the Spell Card is about many blue and red bullets that go towards the upper part of the screen (in a "Geyser style") and when they reach a random section of the upper part they are supposed to aim at the player (or a random section where the player is) as if there was no gravity and with a different graphic. I've been able to recreate the first part of the Spell, but I really can't get past the second one.

I don't know how to change the bullets graphic and their direction.
I tried Booleans as well, but maybe I typed something wrong since I still have to understand them?
Anyway I hope someone can help. If you need the script, just ask and I'll send it privately.
And sorry for my bad English!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: [INSERT USERNAME HERE] on December 07, 2018, 02:33:41 PM
Basically the Spell Card is about many blue and red bullets that go towards the upper part of the screen (in a "Geyser style") and when they reach a random section of the upper part they are supposed to aim at the player (or a random section where the player is) as if there was no gravity and with a different graphic. I've been able to recreate the first part of the Spell, but I really can't get past the second one.
Have you tried using "ObjMove_AddPatternA3"? You can use it to change the bullets' angle, speed, etc., and the bullet graphic.
If you want to change their direction in a random section on the upper part, you can try to make the code that's going to change the bullets' way/graphic get executed when they reach a certain y coordinate (for example 60), and make the code wait for random time (for example 20-60 frames).

AKA something like this:
Code: [Select]
//Shooting bullet(s), assuming they're defined to an object called "bullet"

//. . .

TBulletChange(bullet);

//. .​ .

task TBulletChange(obj){
if(ObjMove_GetY(obj) == 60){
ObjMove_AddPatternA3(obj, rand(25, 60), NO_CHANGE, GetAngletoPlayer(obj), NO_CHANGE, NO_CHANGE, ObjMove_GetSpeed(obj), "Bullet graphic ID you want to change into");
}
}
And I doubt it's the easiest way to do it, I just do it like this myself.
And sorry for my bad English!
Ah shush, your English isn't bad. ^-^

Note: If you're using CreateShotB2 to create bullets, the code above wouldn't work, and you need to find a different way to make bullets face to the player, which I don't know, sorry.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kappapa on December 08, 2018, 01:15:34 AM
Have you tried using "ObjMove_AddPatternA3"? You can use it to change the bullets' angle, speed, etc., and the bullet graphic.
If you want to change their direction in a random section on the upper part, you can try to make the code that's going to change the bullets' way/graphic get executed when they reach a certain y coordinate (for example 60), and make the code wait for random time (for example 20-60 frames).

AKA something like this:
Code: [Select]
//Shooting bullet(s), assuming they're defined to an object called "bullet"

//. . .

TBulletChange(bullet);

//. .​ .

task TBulletChange(obj){
if(ObjMove_GetY(obj) == 60){
ObjMove_AddPatternA3(obj, rand(25, 60), NO_CHANGE, GetAngletoPlayer(obj), NO_CHANGE, NO_CHANGE, ObjMove_GetSpeed(obj), "Bullet graphic ID you want to change into");
}
}
And I doubt it's the easiest way to do it, I just do it like this myself.Ah shush, your English isn't bad. ^-^

Note: If you're using CreateShotB2 to create bullets, the code above wouldn't work, and you need to find a different way to make bullets face to the player, which I don't know, sorry.


Ahhh thank you a lot, after a while I managed to do it and I'm quite pleased with the effect despite the difficulty ahah. I used AddPatternA3, but instead of creating another task I put it in the task with the current fired bullet so that after a couple frame they could have changed their graphic and angolation :D
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on December 10, 2018, 11:47:16 AM
What are the differences between Common Data and Area Common Data functions?

The documentation seems to imply that Area Common Data is a case of Common Data where you manually assign the location of the memory (indexed array?). If so, where is the regular Common Data stored?

And from a practical standpoint, which is easier/faster/safer to use?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on December 10, 2018, 12:12:59 PM
Common Data Areas are groups of Common Data. If you have a lot of Common Data for related things (as would probably pop up in a large project), you might want to put them into areas to categorize them. The CommonData functions are a shortcut for the special case where the area name is "" (empty string), which is automatically created by default.

Fundamentally, a Common Data table is a dictionary (https://en.wikipedia.org/wiki/Associative_array) structure, where you have strings as keys that map to arbitrary values. The Common Data Area table is also a dictionary, where strings (the area names) map to different Common Data tables.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on December 11, 2018, 05:35:34 AM
Additionally, CommonDataArea can be saved to a file and thus become "persistent" data. CommonData is cleared once the game ends. Useful if you want to store progress (spellcard history etc.) / configuration settings and such of a player

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on December 11, 2018, 09:29:49 AM
Additionally, CommonDataArea can be saved to a file and thus become "persistent" data. CommonData is cleared once the game ends. Useful if you want to store progress (spellcard history etc.) / configuration settings and such of a player

Is this to say that the default CommonData area "" cannot be converted to persistent memory?
I also take it that this method of storing progress is recommended above the use of writing to file objects with ObjFile_OpenNW?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on December 11, 2018, 02:31:14 PM
I discussed this with Drake on IRC. To be honest, I am not exactly sure what happens if you call SaveCommonDataArea without providing a value for the "area". The guess is that it will generate a file containing the commondata values. But I have never tried this thus one way to find out for you.

- Write a script that creates a CommonData with a key value pair and save it with empty string value as you wrote.
- Also write somewhere where the commondata is loaded and the data is read.
- Close the script/game
- Reboot game and see what happens.[/li][/list]

Do report your findings, I would say
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on December 12, 2018, 08:25:41 AM
- Write a script that creates a CommonData with a key value pair and save it with empty string value as you wrote.
- Also write somewhere where the commondata is loaded and the data is read.
- Close the script/game
- Reboot game and see what happens.[/li][/list]

Do report your findings, I would say

It is as you say: A file "data/Filename_common_.dat" is created with the values of the default common data area are created.
However, I've had inconsistent results when I try to load this data file using LoadCommonDataAreaA1() with an empty string parameter - The function sometimes fails.
More consistent so far, I've found, is to use LoadCommonDataAreaA2(), and to load into a different CommonData area, which seems to work fine.

I do feel like the latter method seems to be a roundabout way of storing data, which could be accomplished in fashion that's easier to read by using a Common data area with a consistent key. I might see this as advantageous if using a default CommonData area has less overhead than a custom one. Would that be true?

On a side note, using SaveCommonDataAreaA2() on a previously made data file instead of letting one be generated automatically also seems to work fine.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on December 12, 2018, 08:30:46 AM
If the data is important enough to save to file it should probably be in its own area and not the default one.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tad Marx Barba on December 15, 2018, 11:04:04 PM
Hi Guys! I need to do a gravity bullet vortex, how I could do that?  :smokedcheese:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on December 16, 2018, 01:36:55 AM
Hi Guys! I need to do a gravity bullet vortex, how I could do that?  :smokedcheese:

Please describe what a gravity bullet vortex is first :)

Once you have described what you're trying to do in detail, it will be much easier to understand what you want to make.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tad Marx Barba on December 16, 2018, 10:48:00 PM
Please describe what a gravity bullet vortex is first :)

The bullets are spawned from a certain point upwards, and then it fells simulating a whirlpool effect or something
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on December 28, 2018, 06:28:46 AM
So I tried creating my own simple dialogue system like the touhou games from 6-11.

As I put my variable 'g_obj_boss' for local format, as follows:

Stage part:

-At Plural Script 1, I set the boss variable to an object enemy boss.
when the boss health reaches to 0, the boss's position automatically sets to 0-0 coordinates as it proceeds to the next plural part (the Dialogue) where I created the variable boss as enemy.

-After the dialogue, the boss object's position automatically resets to 0-0 coordinates as it proceeds to the next plural part (the boss part). Still I'm running out of time before New Year...

Anyone can help explain this if you watch it and read it. Please Respond. ty.
===========================================================================================================================================
Edit: I assume why. As I misunderstood...

So I was creating a system for the dialogue event, and I might've ran into it so... here's what I did:

This is what the code for the stage looks like:
Code: [Select]
task TStage
{
wait(60);

StartScript(idScriptA);SetAreaCommonData("System", "BossInspiration", r[3]);
while(!IsCloseScript(idScriptA))   //Run plural-stg00e-mid.dnh - midboss event
{
yield;
}

StartScript(idScriptB);SetAreaCommonData("System", "BossInspiration", r[3]);
while(!IsCloseScript(idScriptB))   //Run plural-stg00e-talk.dnh - the dialogue event
{
yield;
}

wait(240);
CloseStgScene();
}

The idScriptA, which is the Midboss Event, as shown in the code above. I put the codes to initialize the boss to appear:

This is the variable for the boss object for format in (lib_variables_boss.dnh):

Code: [Select]
let g_obj_boss;    //This is the variable to set to Enemy Boss in scripts.
Code: [Select]
@Initialize{
SetShotAutoDeleteClip(480,480,480,480);
g_obj_boss = ObjEnemy_Create(OBJ_ENEMY_BOSS);   //The object as an Enemy Boss
ObjEnemy_Regist(g_obj_boss);
//Init_Boss_Aura(g_obj_boss,32,176,255,32,64,255,1);
Render_Boss_Anim(g_obj_boss,anim_HBKT);ObjEnemy_SetDamageRate(g_obj_boss, 0, 0);
        ObjMove_SetDestAtFrame(g_obj_boss, trunc(GetCenterX()+rand(-96,96)), trunc((GetCenterY()/2)+rand(-16,16)), 30);   //The coordinates of the Boss Object

StartSpell;
init_phase1;

TFinalize;
}

Then, the idScriptB, which is the Dialogue Event. I put the codes to initialize the boss to appear:

Code: [Select]
@Initialize{
g_obj_boss = ObjEnemy_Create(OBJ_ENEMY);   //The object as an enemy during the dialogue. Still a boss.
ObjEnemy_Regist(g_obj_boss);
//Init_Boss_Aura(g_obj_boss,32,176,255,32,64,255,1);
ObjMove_SetDestAtFrame(g_obj_boss, trunc(GetCenterX()), trunc((GetCenterY()/2)+rand(-16,16)), 60);    //The coordinates of the enemy object after the boss dies before the event dialogue.
Render_Boss_Anim(g_obj_boss,anim_Hika);ObjEnemy_SetDamageRate(g_obj_boss, 0, 0);

SetCommonData("event_dialogue",true);
SetShotAutoDeleteClip(480,480,480,480);

SetTalk;
CheckEventDia;
}

@MainLoop{
yield;
}

//Create Anything, heheh.
task SetTalk
{
wait(90);
DrawBorder;
SetText_Simple(chartype[1],charcolor_ubkt[0],charcolor_ubkt[1],charcolor_ubkt[2],"My...");
SetText_Simple(chartype[1],charcolor_ubkt[0],charcolor_ubkt[1],charcolor_ubkt[2],"I've been hardly noticed...");

SetText_Simple(chartype[0],charcolor_nemuno[0],charcolor_nemuno[1],charcolor_nemuno[2],"Well, not a bad problem.");
        ... ... ...
        ...
}

The Main Problem for the object as an enemy boss, which last time I rushed out to explain, is the Coordinates of the Enemy Boss object.

at idScriptA, the Coordinates for the boss at the start are (0,0) and the object will move to (GetCenterX(), ((GetCenterY()/2)+rand(-16,16)).

Then, as the boss dies (TFinalize), the idScriptA is closed and idScriptB is next (Dialogue). This time, the coordinates for the Enemy Object are automatically (0,0) and the object will move to (GetCenterX(), ((GetCenterY()/2)+rand(-16,16)).

Still... but why...?

And if I'm not mistaken... Here's the video based on the coordination problem: https://www.youtube.com/watch?v=d9mNMiH1wx4 (https://www.youtube.com/watch?v=d9mNMiH1wx4)

Please respond immediately. ty. :X
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on December 28, 2018, 03:50:12 PM
So I tried creating my own simple dialogue system like the touhou games from 6-11.

As I put my variable 'g_obj_boss' for local format, as follows:

Stage part:

-At Plural Script 1, I set the boss variable to an object enemy boss.
when the boss health reaches to 0, the boss's position automatically sets to 0-0 coordinates as it proceeds to the next plural part (the Dialogue) where I created the variable boss as enemy.

-After the dialogue, the boss object's position automatically resets to 0-0 coordinates as it proceeds to the next plural part (the boss part). Still I'm running out of time before New Year...

Anyone can help explain this if you watch it and read it. Please Respond. ty.

It is difficult to understand what your question/your problem is just by reading your description. Consider reading https://stackoverflow.com/help/mcve (https://stackoverflow.com/help/mcve). tl;dr you haven't explained what your problem is, haven't stated what you actually *want* to happen, and haven't produced enough context/code to tell where each component is being called.

Assuming that your issue is that the boss position is not being maintained between consecutive scripts:
Ensure that communication between scripts is being done via Common Data. Setting the position of an enemy you will delete and recreate will not be sufficient for setting a position between different scripts. Refer to https://sparen.github.io/ph3tutorials/ph3u3l24.html (https://sparen.github.io/ph3tutorials/ph3u3l24.html)

Assuming that your issue is confusion between Boss Enemy Objects and Boss Scene Objects:
Refer to https://sparen.github.io/ph3tutorials/ph3u2l12.html (https://sparen.github.io/ph3tutorials/ph3u2l12.html) and https://sparen.github.io/ph3tutorials/ph3u3l23.html (https://sparen.github.io/ph3tutorials/ph3u3l23.html)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on December 29, 2018, 12:17:06 AM
It is difficult to understand what your question/your problem is just by reading your description. Consider reading https://stackoverflow.com/help/mcve (https://stackoverflow.com/help/mcve). tl;dr you haven't explained what your problem is, haven't stated what you actually *want* to happen, and haven't produced enough context/code to tell where each component is being called.

Assuming that your issue is that the boss position is not being maintained between consecutive scripts:
Ensure that communication between scripts is being done via Common Data. Setting the position of an enemy you will delete and recreate will not be sufficient for setting a position between different scripts. Refer to https://sparen.github.io/ph3tutorials/ph3u3l24.html (https://sparen.github.io/ph3tutorials/ph3u3l24.html)

Assuming that your issue is confusion between Boss Enemy Objects and Boss Scene Objects:
Refer to https://sparen.github.io/ph3tutorials/ph3u2l12.html (https://sparen.github.io/ph3tutorials/ph3u2l12.html) and https://sparen.github.io/ph3tutorials/ph3u3l23.html (https://sparen.github.io/ph3tutorials/ph3u3l23.html)

I assume why. As I misunderstood...

So I was creating a system for the dialogue event, and I might've ran into it so... here's what I did:

This is what the code for the stage looks like:
Code: [Select]
task TStage
{
wait(60);

StartScript(idScriptA);SetAreaCommonData("System", "BossInspiration", r[3]);
while(!IsCloseScript(idScriptA))   //Run plural-stg00e-mid.dnh - midboss event
{
yield;
}

StartScript(idScriptB);SetAreaCommonData("System", "BossInspiration", r[3]);
while(!IsCloseScript(idScriptB))   //Run plural-stg00e-talk.dnh - the dialogue event
{
yield;
}

wait(240);
CloseStgScene();
}

The idScriptA, which is the Midboss Event, as shown in the code above. I put the codes to initialize the boss to appear:

This is the variable for the boss object for format in (lib_variables_boss.dnh):

Code: [Select]
let g_obj_boss;    //This is the variable to set to Enemy Boss in scripts.
Code: [Select]
@Initialize{
SetShotAutoDeleteClip(480,480,480,480);
g_obj_boss = ObjEnemy_Create(OBJ_ENEMY_BOSS);   //The object as an Enemy Boss
ObjEnemy_Regist(g_obj_boss);
//Init_Boss_Aura(g_obj_boss,32,176,255,32,64,255,1);
Render_Boss_Anim(g_obj_boss,anim_HBKT);ObjEnemy_SetDamageRate(g_obj_boss, 0, 0);
        ObjMove_SetDestAtFrame(g_obj_boss, trunc(GetCenterX()+rand(-96,96)), trunc((GetCenterY()/2)+rand(-16,16)), 30);   //The coordinates of the Boss Object

StartSpell;
init_phase1;

TFinalize;
}

Then, the idScriptB, which is the Dialogue Event. I put the codes to initialize the boss to appear:

Code: [Select]
@Initialize{
g_obj_boss = ObjEnemy_Create(OBJ_ENEMY);   //The object as an enemy during the dialogue. Still a boss.
ObjEnemy_Regist(g_obj_boss);
//Init_Boss_Aura(g_obj_boss,32,176,255,32,64,255,1);
ObjMove_SetDestAtFrame(g_obj_boss, trunc(GetCenterX()), trunc((GetCenterY()/2)+rand(-16,16)), 60);    //The coordinates of the enemy object after the boss dies before the event dialogue.
Render_Boss_Anim(g_obj_boss,anim_Hika);ObjEnemy_SetDamageRate(g_obj_boss, 0, 0);

SetCommonData("event_dialogue",true);
SetShotAutoDeleteClip(480,480,480,480);

SetTalk;
CheckEventDia;
}

@MainLoop{
yield;
}

//Create Anything, heheh.
task SetTalk
{
wait(90);
DrawBorder;
SetText_Simple(chartype[1],charcolor_ubkt[0],charcolor_ubkt[1],charcolor_ubkt[2],"My...");
SetText_Simple(chartype[1],charcolor_ubkt[0],charcolor_ubkt[1],charcolor_ubkt[2],"I've been hardly noticed...");

SetText_Simple(chartype[0],charcolor_nemuno[0],charcolor_nemuno[1],charcolor_nemuno[2],"Well, not a bad problem.");
        ... ... ...
        ...
}

The Main Problem for the object as an enemy boss, which last time I rushed out to explain, is the Coordinates of the Enemy Boss object.

at idScriptA, the Coordinates for the boss at the start are (0,0) and the object will move to (GetCenterX(), ((GetCenterY()/2)+rand(-16,16)).

Then, as the boss dies (TFinalize), the idScriptA is closed and idScriptB is next (Dialogue). This time, the coordinates for the Enemy Object are automatically (0,0) and the object will move to (GetCenterX(), ((GetCenterY()/2)+rand(-16,16)).

Still... but why...?

And if I'm not mistaken... Here's the video based on the coordination problem: https://www.youtube.com/watch?v=d9mNMiH1wx4 (https://www.youtube.com/watch?v=d9mNMiH1wx4)

Please respond immediately. ty. :X
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on December 29, 2018, 01:24:48 AM
It's because you're running this as two different plural scripts. Boss enemy objects aren't going to stay the same in different plural scripts; these are two different bosses. So naturally they're going to not share coordinates.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: KDOXG on January 06, 2019, 05:00:18 AM
I'm with a little doubt, I'm having this problem with the function DeleteShotAll() in @MainLoop (I'm following Sparen's ph3 Tutorial):

Code: [Select]
//This code goes on @MainLoop

if(ObjEnemy_GetInfo(objBoss, INFO_LIFE) <= 0)
{
  Obj_Delete(objBoss);
  DeleteShotAll(TYPE_ALL, TYPE_IMMEDIATE));
  SetAutoDeleteObject(true);
  CloseScript(GetOwnScriptID());
  return;
}

When I run this, Danmakufu gives me an error message saying it should have a "}" at the DeleteShotAll() line. But why? If I comment the entire DeleteShotAll() line, it runs with no error, so it's no brace matching mistake. Also when I use the task method. I thought this was some property of the function, but it doesn't make any sense.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on January 06, 2019, 07:17:42 AM
I'm with a little doubt, I'm having this problem with the function DeleteShotAll() in @MainLoop (I'm following Sparen's ph3 Tutorial):

Code: [Select]
//This code goes on @MainLoop

if(ObjEnemy_GetInfo(objBoss, INFO_LIFE) <= 0)
{
  Obj_Delete(objBoss);
  DeleteShotAll(TYPE_ALL, TYPE_IMMEDIATE));
  SetAutoDeleteObject(true);
  CloseScript(GetOwnScriptID());
  return;
}

When I run this, Danmakufu gives me an error message saying it should have a "}" at the DeleteShotAll() line. But why? If I comment the entire DeleteShotAll() line, it runs with no error, so it's no brace matching mistake. Also when I use the task method. I thought this was some property of the function, but it doesn't make any sense.
You're closing DeleteShotAll with two parentheses.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: KDOXG on January 06, 2019, 08:22:16 AM
You're closing DeleteShotAll with two parentheses.

Oh... that explains it. God, that was awful, I was so precautious about the braces I forgot completely of the parenthesis. I hope nobody would commit this kind of error again.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on January 06, 2019, 07:05:18 PM
Oh... that explains it. God, that was awful, I was so precautious about the braces I forgot completely of the parenthesis -_- I hope nobody would commit this kind of error.
While the actual error description is vague and could come over as misleading, the line number usually tells the truth. There are a few rare conditions I ran into where the line number would trick the reader.

Anyway, keep in mind for the future that if it points at a function/line number, your error is most of the time located there. (misspelling, misplaced parentheses, brackets, curly braces, case sensitive, missing or misplaced semicolon etc)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on January 07, 2019, 12:07:05 PM
I see that some scripts use .txt files and some use .dnh files.
Is there a difference, other than personal preference?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 07, 2019, 03:19:07 PM
I see that some scripts use .txt files and some use .dnh files.
Is there a difference, other than personal preference?

There is no difference functionally. .dnh may be helpful if you use a text editor and want syntax highlighting.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on January 11, 2019, 07:42:39 AM
Is it possible to vary the alpha value of a laser along its length?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 11, 2019, 02:22:56 PM
Is it possible to vary the alpha value of a laser along its length?

You can utilize multiple lasers or apply a shader to achieve this effect.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on January 13, 2019, 12:07:39 AM
Hmm... I have a question.

What's the purpose of a loading system (when you open a pre-packaged danmakufu script)?
Can you describe the loading system? I wanted to know for sure, thank you.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 13, 2019, 03:22:04 AM
Hmm... I have a question.

What's the purpose of a loading system (when you open a pre-packaged danmakufu script)?
Can you describe the loading system? I wanted to know for sure, thank you.

What do you mean by 'loading system'?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on January 13, 2019, 11:10:17 PM
What do you mean by 'loading system'?

This loading system (see picture below i.e.)
[attach=1]
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 14, 2019, 02:08:01 AM

Splash Screens are done typically for graphical effect before the Main Menu. Many games have them in some form.

In Danmakufu, they don't have any specific purpose since they're just a few images rendered before loading the menu. Some scripters may choose to load assets for the menu, etc, but it's not necessarily required.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mr.Ownage on January 16, 2019, 04:16:50 PM
Hi, everyone.

I recently got into Danmakufu scripting, and I feel like I've understood the basics for the most part (including rendering, moving, and giving the boss a hitbox, some nonspells and spells), but I've run into an issue as I was working on an idea for a spell card.

The idea would be : firing 6 curvy lasers from the boss's location at intervals, which leave trails of "soul" bullets (Yuyuko-type butterfly bullets) behind as they travel, which then will randomly begin moving shortly after.

The problem is : I'm unable to find a solution to fire all six lasers and have the trails appear at the same time. I have tried using different variations of loops, ascents, different positioning of curly braces, yields, to no avail. In the recent versions of the code idea, either the lasers appear one after the other, and the rest don't appear until the prior one finishes trailing, or I get a "variable is not defined" error.

Here is the most recent version of the code I've been experimenting with. No other shooting tasks run alongside this one, this task is included in Initialize. I didn't include movement commands for the soul-bullets in this one yet. I'm using the AllStar shotsheet in this example.

Code: [Select]
task lazertime{
let i = 1;
loop{
loop(6){
let obj = CreateCurveLaserA1(ObjMove_GetX(Zataihou), ObjMove_GetY(Zataihou), 5, 120+i*10, 50, 20, 1019, 10); //shoots lasers. "Zataihou" would equal "objBoss" in this code, it itself being a name for an original character of mine. Yes, I'm weird.
i++;
} //if this brace is taken out, the lasers fire sequentially instead of at the same time. If it's in, Danmakufu shows "obj is not defined" error due to the "let souls" line.

loop(20){
wait(1);
let souls = CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,0,294,10);} //would handle spawning of soul bullets along the lasers. No angle and speed set yet for testing. 294 is a Yuyuko-type, blue "butterfly" bullet graphic.
ObjCrLaser_SetTipDecrement(obj,0); //makes laser hitbox fair by removing their invisible parts
ObjMove_SetAngularVelocity(obj,-1); //curves the lasers
yield;}

I've been thinking of making the trailing be handled by a seperate task, but it would likely also bring up a "variable is not defined" error. I've also seen people use arguments in task names, but I don't exactly get what is that used for, or how to make use of it. Any advice regarding these matters is greatly appreciated.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 16, 2019, 05:52:59 PM
The problem is : I'm unable to find a solution to fire all six lasers and have the trails appear at the same time. I have tried using different variations of loops, ascents, different positioning of curly braces, yields, to no avail. In the recent versions of the code idea, either the lasers appear one after the other, and the rest don't appear until the prior one finishes trailing, or I get a "variable is not defined" error.

Here is the most recent version of the code I've been experimenting with. No other shooting tasks run alongside this one, this task is included in Initialize. I didn't include movement commands for the soul-bullets in this one yet. I'm using the AllStar shotsheet in this example.

Code: [Select]
task lazertime{
let i = 1;
loop{
loop(6){
let obj = CreateCurveLaserA1(ObjMove_GetX(Zataihou), ObjMove_GetY(Zataihou), 5, 120+i*10, 50, 20, 1019, 10); //shoots lasers. "Zataihou" would equal "objBoss" in this code, it itself being a name for an original character of mine. Yes, I'm weird.
i++;
} //if this brace is taken out, the lasers fire sequentially instead of at the same time. If it's in, Danmakufu shows "obj is not defined" error due to the "let souls" line.

loop(20){
wait(1);
let souls = CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,0,294,10);} //would handle spawning of soul bullets along the lasers. No angle and speed set yet for testing. 294 is a Yuyuko-type, blue "butterfly" bullet graphic.
ObjCrLaser_SetTipDecrement(obj,0); //makes laser hitbox fair by removing their invisible parts
ObjMove_SetAngularVelocity(obj,-1); //curves the lasers
yield;}

I've been thinking of making the trailing be handled by a seperate task, but it would likely also bring up a "variable is not defined" error. I've also seen people use arguments in task names, but I don't exactly get what is that used for, or how to make use of it. Any advice regarding these matters is greatly appreciated.

Tasks are the perfect solution to your problem, since you want each laser to perform the same task. In this case, you get the ID of each laser, and pass it to a task. In the task, the trails are made.

In other words, your code structure would be as follows:

In lazertime:
- In a loop without waiting (unless you want a delay between lasers), create your lasers, and call a new task, passing the laser ID as a parameter.
- In the new task, handle the trail.

Tasks run parallel to the main routine as long as you are using yield; in your Main Loop.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mr.Ownage on January 16, 2019, 07:06:09 PM
Tasks are the perfect solution to your problem, since you want each laser to perform the same task. In this case, you get the ID of each laser, and pass it to a task. In the task, the trails are made.

In other words, your code structure would be as follows:

In lazertime:
- In a loop without waiting (unless you want a delay between lasers), create your lasers, and call a new task, passing the laser ID as a parameter.
- In the new task, handle the trail.

Tasks run parallel to the main routine as long as you are using yield; in your Main Loop.

Hey, Sparen. It's been a great honor to be helped out by one of the grandfathers of Danmakufu, so to say.
I created a new task to handle the trail as you've advised to do, and sure enough, now each laser leaves a trail correctly, like it was meant to be. And using an if Obj_IsDeleted statement in the trail task also successfully prevented 0,0 spawning (in case a laser went offscreen).
Many thanks for the advice!

A few more questions that came up while experimenting/thinking about spell ideas and how to code them :

-Judging from the example indicated, giving a task an argument (like : trail(obj)) serves to pass the ID of created objects so the "no variable defined" error doesn't come up? Likewise, for shots, its ID is acquired by declaring it as something?

-For more complicated shapes (in my case, a spiderweb comes to mind) it's best to use multiple tasks to handle their creation, right?

-If I want to modify the lasers by modifying their angular velocity at various intervals and values (for example, setting it to 1 after 90 frames, then 2 after 30 frames, then 0 shortly after) via tasking, would that affect even the newly spawned lasers, or would newly spawned ones also only have their velocity modified when they are intended to?

-Danmakufu seems to be faster whenever the player (Reimu) is in a "shotdown" state (before respawning) for some reason, which leads to quite big desyncs at times, mainly in more complicated patters or regarding sound effects. What could be causing this?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on January 16, 2019, 09:13:25 PM
You shouldn't add angular velocity to non-curvy lasers. I've never been able to figure out how danmakufu's curvy lasers are supposed to work, so I just made my own out of a bunch of small straight lasers.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mr.Ownage on January 16, 2019, 10:07:28 PM
You shouldn't add angular velocity to non-curvy lasers. I've never been able to figure out how danmakufu's curvy lasers are supposed to work, so I just made my own out of a bunch of small straight lasers.

Don't worry, I've made sure that they are indeed curvy lasers. I've managed to get them working since.

Now, however, the only problem I have is that I've accidentally overwritten the script with an old version, thus losing a lot of work, and I had to remake it. Something went wrong, though, as bullets from the trail keep spawning at 0,0, even if if/while statements checking for if the parent lasers are deleted are included (and if they are deleted, remove said shots, but some still manage to spawn in 0,0 anyway). Perhaps due to them being spawned via an ascent?

Due to this, I'm using a weird workaround of DeleteShotInCircle aimed at 0,0 with a small radius. It looks wonky, but it works, at least.

And to help you in the curvy laser regard : you need to use ObjMove_SetAngularVelocity on your lasers to have them curve. Though first, declare them as something so you'll be able to refer them via that variable through the command.

For example, if you name your laser obj, it would look like this :
let obj = CreateCurveLaserA1(xcoord, ycoord, speed, angle, length, width, graphic, delay);
ObjMove_SetAngularVelocity(obj,number)

Hope this helps!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on January 16, 2019, 10:58:20 PM
This is the code I'm currently using:

Code: [Select]
let angle = 0;
CreateShotA1(GetCenterX(),GetCenterY(),1,angle,5,5);
{
let angle = 90;
CreateShotA1(GetCenterX(),GetCenterY(),1,angle,5,5);
}

I wrote this as a test in the process of debugging a larger problem. The expected behaviour of this code here is that two bullets will be fired at angle 0 and 90 degrees respectively.

For me, this code does not compile at all, requesting a "}" on the same line as the opening bracket. Removing the curly braces leads to a conflicting declaration of 'angle'.

I'm aware that if I were to represent the latter two lines as a nested task or function I would be able to make use of a local scope for the variable, but since this code only appears once in this location and has no yields, I was wondering if there was a way to define a section of limited, local scope without using a task, function, or something queer-looking like "loop(1){...}" ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 16, 2019, 11:51:25 PM
local{}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 17, 2019, 01:39:21 AM
Hey, Sparen. It's been a great honor to be helped out by one of the grandfathers of Danmakufu, so to say.
:V :V :V :V :V

Something went wrong, though, as bullets from the trail keep spawning at 0,0, even if if/while statements checking for if the parent lasers are deleted are included (and if they are deleted, remove said shots, but some still manage to spawn in 0,0 anyway). Perhaps due to them being spawned via an ascent?

You'll need to post code for us to locate a specific problem. In general, you need to prevent bullets from spawning if their position is based on the position of a deleted object. IE if the player bombs and a bullet that spawns other bullets is deleted, no more bullets should be spawned from that bullet (IE the task should be terminated via return;)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mr.Ownage on January 17, 2019, 07:46:27 AM
Here is the current version of the code I'm using for the card, which, other than the 0,0 spawning post-death, seems to work great by now :

Code: [Select]
task lazertime{
let angle = 100;
wait(60); //One time wait so the cutin can disappear by this time, and the boss can move into position
loop{
while(GetShotCount(Zataihou) > 160){yield;} //If there's many souls on screen, stop creating new lasers and trails. Once again, Zataihou = objBoss in this example.
wait(10);
ascent(i in 1..6){
let obj = CreateCurveLaserA1(ObjMove_GetX(Zataihou), ObjMove_GetY(Zataihou), 12, angle+i*12, 30, 20, 1019, 10); //Handles the lasers
ObjCrLaser_SetTipDecrement(obj,0); //Makes laser hitbox fair
ObjMove_SetAngularVelocity(obj,-7); //Handles the initial curving of the lasers
trail(obj); //Task to spawn trails
straighten(obj); //Task to have the lasers go straight after a short while (so they leave the screen)
angle+=30; //Increment angle to give different laser angles
}
}}

task trail(obj){
while(Obj_IsDeleted(obj)){return;} //Supposed to handle preventing 0,0 spawning, which works until player death, but some souls spawn at 0,0 anyway on respawn.
loop(5){
wait(8);
let souls = CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,0,rand(291,298),10); //Creates the souls
fly(souls);} //Task to wait until there's a certain amount of souls, then let them begin moving
}

task straighten(obj){
ObjMove_AddPatternA2(obj,60,NO_CHANGE,NO_CHANGE,NO_CHANGE,0,11); //Task to straighten the lasers by setting their angular velocity to 0, leaving everything else intact.
}

task fly(souls){
while(GetShotCount(Zataihou) < 150){yield;} //Wait until there's enough souls, then...
ObjMove_AddPatternA2(souls,60,NO_CHANGE,rand(40,150),0.01,0,12); //... let them move around.

I'm assuming that since the lasers are in an ascent loop (which I need to have an incrementing angle, imo this is the easiest way to do so) they get spawned just a tiny bit one after the other, and because of that, since there's at least one obj (laser) on screen by that time, the ones that can spawn at the lasers' x, while the rest spawn in at 0,0?
Then again, this does not happen when the card starts out, only after player respawn. It's... weird.

For me, personally, it's not a big deal to use DeleteShotInCircle aimed at 0,0 as a workaround, but for keen eyes, it really does look wonky regardless.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on January 17, 2019, 08:19:25 AM
Your while(Obj_IsDeleted(obj)){return;} is the culprit I think. Cannot test it as I am at work but you need to enclose this statement around the execution of your trail code.

As in:
Code: [Select]
// As long as the obj IS NOT deleted, executed the code in between. Otherwise, jump over it (thus not executed)
while (!Obj_IsDeleted(obj)) {
// Spawn fancy trail stuff here.
}
You can translate the above code into human language but reading it out loud: "While the object is not deleted, execute the code in between which is CreateShotA etc.

Because, there could be a scenario where the creation of souls could be already running while the original object is perhaps just 1 frame ago deleted. Which results in spawning at 0,0 because the original Obj is gone. And this can be confirmed because you're looping it 5 times. So if indeed the obj got deleted and the program was executing the loop, then it would simply run it 5x.

Edit: However, even if you do it like this there is still a trap in your code. It is the loop(5) and the way you're spreading out the tasks. You should approach it differently imo.

So if I understood your code. Your use case is this, right?
- Boss keeps firing number of shots on screen
- It also spawns these lasers (shots) on screen
- If the shotcount exceeds a certain number, stop spawning lasers
- Respawn lasers/shots if the number drops under this said threshold

So for this case, you will need something like this:
Code: [Select]
task fireCurvyLaser() {
  // While the boss IS alive AND the number of shots IS BELOW 160, execute the code.
  while (!Obj_IsDeleted(Zataihou) && GetShotCount(Zataihou) < 160) {
    let obj = CreateCurveLaserA1(...);
    // ... laser related stuff etc
    spawnLaserTrail(obj);
    wait(10);
  }
}

task spawnLaserTrail(obj) {
  // Loop 5x, but keep checking each loop whether the obj (laser) is NOT deleted. If the laser is "alive", spawn a soul (createShotA1)
  loop(5) {
    if (!Obj_IsDeleted(obj)) {
      let soul = CreateShotA1(...);
    }
    wait(8);
  }
}

Above code will do the following:
- Add extra lasers up to your given threshold (160 in this case)
- Prevent the laser from spawning more souls if it is "dead"
- A more compact and maintainable code

Imagine if the curvy was deleted exactly the moment when spawnLaserTrail was executing loop #3. This code will immediately prevent the spawn of future souls. This is exactly the type of control you want. Always verify the existence of the obj. When working with objects, the only reason something spawns at 0,0 is the fact that the original reference object is gone.

So why might wonder now why your code spawning things at 0,0 when the player went pichuun? (post death as you mentioned)
In your original code, your script is executing loops without verifying whether its reference object is still alive. So once the loop started running, it would just do what you told it to do: Spawn souls. But the souls used the obj as its reference for its x/y position. As the player dies, it clears the entire screen of bullets (by default). Clearing the screen means all objects (bullets) are deleted. With the objects gone, its x/y is destroyed. But your loop was probably running at that moment and thus the 0,0 spawning occurs for that specific task.

Conclusion is that you didn't check/verify or control your code. A common mistake made by many beginner and intermediate danmakufu scripters.

Hope this helps out.


Edits, spelling/grammar correction
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mr.Ownage on January 17, 2019, 09:20:23 AM
Not sure if this is exactly how you meant it, but I did this (enclosing the trail task in a while statement) :

Code: [Select]
task trail(obj){
while(!Obj_IsDeleted(obj)){ //Supposed to handle preventing 0,0 spawning
loop(5){
wait(8);
let souls = CreateShotA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,0,rand(291,298),10); //Creates the souls
fly(souls);} //Task to wait until there's a certain amount of souls, then let them begin moving
}}

But it only made it worse : as soon as a laser leaves the screen, "souls" begin spawning at 0,0 in greater amounts.
One thing to note is that I'm using this code in @MainLoop to delete bullets on player death, could it be a potential culprit?

Code: [Select]
if(GetPlayerState == STATE_DOWN){
DeleteShotAll(TYPE_ALL, TYPE_FADE);

Setting the down state time to 30 frames via SetPlayerDownStateFrame (from the default 2-3 seconds) also helped alleviate the problem a LOT, but there are still rare cases of 0,0 spawning even with it.  This is all assuming the original version of the code is being used (instead of enclosing the task in a while(!Obj_IsDeleted) statement, while(Obj_IsDeleted(obj)){return;} is used) and does not occur when a bomb is used.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on January 17, 2019, 09:28:12 AM
I edited my post while you were probably trying it out. See my edited post, I am pretty sure it will work out.

Edit:
I have no idea why you're calling a DeleteShotAll because it is default being done when the player dies. All bullets, which aren't resistant to deletion, will be deleted. Pure objects (sprites, effects, etc) obviously won't.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mr.Ownage on January 17, 2019, 10:10:50 AM
Alright, the issue was found and fixed at last!

The problem was, for one, that the check for the parent laser existing was, as you've mentioned, incorrect. Rewriting it using an if(!Obj_IsDeleted(obj)) statement as you've mentioned helped do the trick.

But for the most part, I assume the problem was that I included the wait( 8 ); function inside the check statement, which would make it wait 8 frames before running the check to see if the lasers are still existing (in other words, the check wouldn't be running every frame, but rather every 8 frames). Enough time for souls to try spawning, and end up spawning at 0,0.

With these modifications done, and by putting the wait before the if statement (the wait is there to make sure the souls are nicely spread, and so they don't spawn right on the first frame, as in, on the boss), now no souls spawn at 0,0 whatsoever, nor when bombing, nor when the lasers leave the screen, nor after going pichuun.

Thanks a lot for the help so far!

About the DeleteShotAll statement, I included it because the lasers/souls don't seem to delete by default without it. Both the souls and the lasers remain if it's not included (normally, they disappear via bombing).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on January 17, 2019, 11:11:50 AM
Ah yes. This was also a thing in 0.12m. Bullets/danmaku created through Objects (including lasers) were default immune to bombing or player death or even leaving the screen. You indeed have to tell it to be not-immune. I forgot the exact code but it is there on the wifi.

Glad to be of any help and good to see you figured it out.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mr.Ownage on January 21, 2019, 03:32:33 PM
As I've been working on spell card ideas more, I've run into a few roadblocks which I couldn't figure out how would I do them or how would it work :

-I've been experimenting on a spellcard which spawns bullets in triangles randomly around the screen, which worked out well. However, I've been also thinking of a spell which would have bullets incoming from the edges of the screen as a part of it (rather than randomly spawn bullets anywhere on the screen, having them spawn along the edges only). What could be a possible way to implement it? Certainly not rand with values of STGFrame width and height, as it could spawn them anywhere, rather than at the edges only.
Similiarly, how it would be best to create a task that begins spawning bullets from 0,0, then begins "going around" the screen, by going to the maximum x value, then the maximum y value, and so on, spawning bullets as it goes?

-If there are multiple objects spawning multiple objects of the same type sequentially (for example, big bullets labelled as obj, spawning smaller bullets declared as obj2), would the AddPattern function control each bullet (obj2 ones) at the same time, or in a certain order? I think it's the latter from experimenting with a spellcard in which lasers leave bullet trails, but I haven't confirmed it for sure.

-There have been occasions of needing to use an ascent loop inside a loop (mainly for more complex patterns to use the i in the ascent as incrementing values, mainly the angle) for patterns. For example:

Code: [Select]
task example{
loop{
        ascent(i in 1..10){
                               let obj = any create shot function(arguments);
                                     }
                               ObjMove_AddPatternA2(obj,stuff)
                                    }

However, in this case, an error about a non-declared variable would come up in the AddPattern line. I know it's due to the variable being inside the ascent loop, but I can't seem to find a workaround for it. Is there any?

Thanks for replies in advance!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 21, 2019, 04:06:04 PM
-I've been experimenting on a spellcard which spawns bullets in triangles randomly around the screen, which worked out well. However, I've been also thinking of a spell which would have bullets incoming from the edges of the screen as a part of it (rather than randomly spawn bullets anywhere on the screen, having them spawn along the edges only). What could be a possible way to implement it? Certainly not rand with values of STGFrame width and height, as it could spawn them anywhere, rather than at the edges only.
Similiarly, how it would be best to create a task that begins spawning bullets from 0,0, then begins "going around" the screen, by going to the maximum x value, then the maximum y value, and so on, spawning bullets as it goes?
Assuming that you want to utilize the edges of the screen exclusively, you can lock one coordinate and then set the other to be random along the edge.

e.g. task a { loop { CreateShotA1(rand(0, GetStgFrameWidth), 0, 2, 90, 1, 0); yield; } }

-If there are multiple objects spawning multiple objects of the same type sequentially (for example, big bullets labelled as obj, spawning smaller bullets declared as obj2), would the AddPattern function control each bullet (obj2 ones) at the same time, or in a certain order? I think it's the latter from experimenting with a spellcard in which lasers leave bullet trails, but I haven't confirmed it for sure.
AddPattern applies to the object ID you pass to it. The frame you pass as a parameter is what controls the timing of the effect.

-There have been occasions of needing to use an ascent loop inside a loop (mainly for more complex patterns to use the i in the ascent as incrementing values, mainly the angle) for patterns. For example:

Code: [Select]
task example{
loop{
        ascent(i in 1..10){
                               let obj = any create shot function(arguments);
                                     }
                               ObjMove_AddPatternA2(obj,stuff)
                                    }

However, in this case, an error about a non-declared variable would come up in the AddPattern line. I know it's due to the variable being inside the ascent loop, but I can't seem to find a workaround for it. Is there any?

When you define a variable, it only exists in the block it was defined in. You can move the AddPattern inside the ascent, or pass the Object ID to a task that runs the AddPattern.

For more information, refer to the tutorials on the subject: https://sparen.github.io/ph3tutorials/ph3u1l8.html#sub5
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mr.Ownage on January 21, 2019, 05:32:40 PM
Hey there, and thanks for the detailed reply, Sparen! The mentioned information is most definitely very helpful, espicially the part on solving the problem with variables. Despite having such a simple solution, I likely couldn't have figured it out my own. A bit embarrassing, I know.

Thanks once again!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 21, 2019, 05:58:18 PM
Hey there, and thanks for the detailed reply, Sparen! The mentioned information is most definitely very helpful, espicially the part on solving the problem with variables. Despite having such a simple solution, I likely couldn't have figured it out my own. A bit embarrassing, I know.

Thanks once again!

No problem. If you have any further questions, please feel free to ask. We're here to help. :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on January 23, 2019, 08:23:51 AM
Can someone please explain to me what the render functions SetFogEnable() and SetFogParam() are for?
I can't quite work it out from the documentation, and I haven't noticed anything yet by putting them in a script.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 23, 2019, 09:07:43 AM
Fog (https://en.wikipedia.org/wiki/Distance_fog) is used for 3D backgrounds; it's a way for backgrounds to slowly fade away into the distance, typically when you don't want to be drawing things far away and don't want them to just disappear and reappear when they get closer (i.e. clipping (https://en.wikipedia.org/wiki/Clipping_(computer_graphics))).
Hele has a video tutorial (https://www.youtube.com/watch?v=qL4XCwxioRU) briefly talking about how to use it in a script.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on January 23, 2019, 08:21:25 PM
Thanks, that video is helpful.

However, it makes me wonder, if I were to move the camera to an angle, does that mean I would have to recalculate the angles of the all the objects on the screen to control their positions?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on January 23, 2019, 09:18:17 PM
Thanks, that video is helpful.

However, it makes me wonder, if I were to move the camera to an angle, does that mean I would have to recalculate the angles of the all the objects on the screen to control their positions?
No, that is also explained in this video tutorial (https://www.youtube.com/watch?v=jVkIiewpijE).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on January 25, 2019, 01:16:56 PM
I discovered that adding this code causes danmakufu to not detect a .dnh script in its menu.
Code: [Select]

/***********************


************************/


What causes this behaviour? Is "/***" or "***" or "***/" reserved syntax or something?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 25, 2019, 01:38:09 PM
I discovered that adding this code causes danmakufu to not detect a .dnh script in its menu.
Code: [Select]

/***********************


************************/


What causes this behaviour? Is "/***" or "***" or "***/" reserved syntax or something?

If the #TouhouDanmakufu is commented out, then the script will not appear in the Danmakufu menu. I assume this is what you have done (placed #TouhouDanmakufu within the block quotes).

It's a common technique to hide Single scripts you don't want cluttering up the Danmakufu menu + scripts that should not be executed by the player
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on January 25, 2019, 02:22:04 PM
If the #TouhouDanmakufu is commented out, then the script will not appear in the Danmakufu menu. I assume this is what you have done (placed #TouhouDanmakufu within the block quotes).

It's a common technique to hide Single scripts you don't want cluttering up the Danmakufu menu + scripts that should not be executed by the player

I understand this, but this is not what happened. The comment block was midway down the script. Specifically, I was rewriting a piece of code that had been simulating a beam using a laser, this instead using a primitive object.

In other words, the comment itself was 'empty'. Above the comment was my new function (half-written at this point), and below the comment was the old function, which was no longer called in @Initialize.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 25, 2019, 03:14:20 PM
I understand this, but this is not what happened. The comment block was midway down the script. Specifically, I was rewriting a piece of code that had been simulating a beam using a laser, this instead using a primitive object.

In other words, the comment itself was 'empty'. Above the comment was my new function (half-written at this point), and below the comment was the old function, which was no longer called in @Initialize.

Please provide your full code. It may be a different issue altogether (e.g. unrecognized symbol at a weird location, smart quotes, etc)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on January 25, 2019, 03:34:03 PM
Please provide your full code. It may be a different issue altogether (e.g. unrecognized symbol at a weird location, smart quotes, etc)

I can do that, although it's a bit long...
There is a way I'm meant to do this other than sticking the entire file in between [ code ] tags, is that right?

EDIT:
https://pastebin.com/36zG0fXB
Since the script is quite long, I removed a lot of functions that were not relevant to the problem. This script is still representative of what I was doing at the time. I can confirm that this code replicates the problem on my device. Specifically it is the comment at around line 85 that causes the issue, as removing it allows danmakufu to detect the script again.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 25, 2019, 05:17:38 PM
Weird. I have absolutely no idea why Danmakufu doesn't like /**. Well, we have the source code, I guess.

Relevant code?
Parser for comments: https://github.com/UltimaOmega/TouhouDanmakufuRemastered/blob/master/source/GcLib/gstd/Script.cpp#L395
Danmakufu Header parsing: https://github.com/UltimaOmega/TouhouDanmakufuRemastered/blob/master/source/TouhouDanmakufu/Common/DnhCommon.cpp#L26
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mr.Ownage on January 26, 2019, 03:28:11 PM
Hey everyone,

I have been working on a spell which has multiple phases, similiarly to Boundary of Life and Death in a way that additional attacks are added as the opponent's life decreases, which I have been able to script in successfully.

However, I also would like to make it so that, again like BoLaD, once the timer hits a certain point, all of the phases instantly activate (not necessarily sped up like the original, though).

I'm using

Code: [Select]
while(ObjEnemy_GetInfo(objBoss,INFO_LIFE) > 5000){yield};
to handle the "wait until life hits a certain threshold" aspect of the phases. Each phase is in a seperate task.

How could I tell Danmakufu to keep waiting until either the boss reaches certain life thresholds (activating each phase sequentially) or as it reaches a certain time (activate all phases at once)?

On another note, I'd like to know...
-For a plural script, how could I end a single (for example, a spell) and move on to the next attack (for example, a nonspell) in a way so the boss starts out where it was on the previous attack (rather than always teleporting into the starting position)?

-Is there a way to keep track of how many spell cards the player has successfully captured so far? (I'd like to implement a last spell that can only be encountered if x spells have been captured throughout the run).

EDIT : Do multiple sounds played via SE_Play overwrite each other? I haven't exactly tested it throughly yet, but at times it seems that way.

Many thanks for the advice in advance!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on January 26, 2019, 05:04:02 PM
Weird. I have absolutely no idea why Danmakufu doesn't like /**. Well, we have the source code, I guess.

Relevant code?
Parser for comments: https://github.com/UltimaOmega/TouhouDanmakufuRemastered/blob/master/source/GcLib/gstd/Script.cpp#L395
Danmakufu Header parsing: https://github.com/UltimaOmega/TouhouDanmakufuRemastered/blob/master/source/TouhouDanmakufu/Common/DnhCommon.cpp#L26

I haven't been through all the header files, but between Script.cpp and DnhCommon.cpp I can't fathom how a /** can even make it past the parser, let alone interfere with the Danmakufu Header interpretation. Would you happen to know which file includes/calls the parsing process? I can only imagine that if the Danmakufu Header is parsed a second time independent of the rest of the script code, maybe there is a bug associated with the /**.

My only other idea at this stage is that the /** somehow causes the try block in ScriptInformation::CreateScriptInformation to throw an exception, which will cause the function to return a NULL pointer. This might be related to the above, where the /** might cause an incorrect generation of tokens regarding the header or the brackets during the lexing process.

All this said, it does seem to me that this behaviour is a bug rather than a feature. I don't think that danmakufu can (or should) incorporate paths with wildcard characters into the #TouhouDanmakufu Header anyway.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on January 27, 2019, 05:22:30 AM
How could I tell Danmakufu to keep waiting until either the boss reaches certain life thresholds (activating each phase sequentially) or as it reaches a certain time (activate all phases at once)?

Have all the wait loops also end if time gets below a certain amount.

Code: [Select]
while(ObjEnemy_GetInfo(objBoss,INFO_LIFE) > 5000 || ObjEnemyBossScene_GetInfo(sceneObj,INFO_TIMER) < threshold){yield};

Something like that, where sceneObj is the BossScene Object and threshold is how low you want the timer to go before the boss gets mad.

-For a plural script, how could I end a single (for example, a spell) and move on to the next attack (for example, a nonspell) in a way so the boss starts out where it was on the previous attack (rather than always teleporting into the starting position)?

Is there any particular reason you want to do that? I can't think of anything that would really need it. If you do really want to, then you'd store the boss's coordinates with common data (https://dmf.shrinemaiden.org/wiki/Common_Data_Functions) in the single and then have the starting coordinates in their next single be those same coordinates.

-Is there a way to keep track of how many spell cards the player has successfully captured so far? (I'd like to implement a last spell that can only be encountered if x spells have been captured throughout the run).

There's a thing in the system script that runs whenever you capture a spell. Have that increment a common data attribute and check for that attribute when beginning the last spell. Make sure that you're only modifying your script's copy of the system script and not the global danmakufu system script. I'm not sure if there's a pretty way to just not start the spell, but if all else fails you can just end the spell immediately if the attribute isn't where you want it. Requirements like that are pretty annoying though, so I'd suggest making it less stringent or even removing it entirely.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mr.Ownage on January 28, 2019, 04:49:14 PM
Thanks for the reply, Arcvasti! Obviously, regarding the "have the boss start out where it was on the previous attack", I wanted to do that since it looks really wonky to have it teleport back to its original starting position every time an attack is cleared (unless it can be done in a simpler way by not deleting the boss after every attack, of course).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 28, 2019, 07:27:07 PM
Thanks for the reply, Arcvasti! Obviously, regarding the "have the boss start out where it was on the previous attack", I wanted to do that since it looks really wonky to have it teleport back to its original starting position every time an attack is cleared (unless it can be done in a simpler way by not deleting the boss after every attack, of course).

By default, as long as you are using a Plural script with the appropriate ObjEnemyBossScene, the boss should remember its location between Singles. Unless you've done something in your code that prevents that, of course.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mr.Ownage on January 28, 2019, 09:13:34 PM
Thanks for the reply, Sparen! I wasn't in the know that that was actually the case, but after some testing, it indeed is! The issue was that I had included ObjMove_SetPosition (to half the STGFrameX and Y/4) in every Single that was in the Plural, which resulted in the boss being moved to that position every time for the new attack. Removing that piece of code resolved this issue.

Thanks once again!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 29, 2019, 03:23:15 AM
Thanks for the reply, Sparen! I wasn't in the know that that was actually the case, but after some testing, it indeed is! The issue was that I had included ObjMove_SetPosition (to half the STGFrameX and Y/4) in every Single that was in the Plural, which resulted in the boss being moved to that position every time for the new attack. Removing that piece of code resolved this issue.

Thanks once again!

No problem. I had a feeling that it was something like that. Many code issues are hard to spot because you pass by them when reading.

One suggestion is to read out loud what each line of code does. Alternatively, explain your code line by line to a mirror or a rubber duck (https://en.wikipedia.org/wiki/Rubber_duck_debugging). Since you will be explaining and reading your code line by line, you'll pick up on problems you didn't even realize existed.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on January 29, 2019, 07:44:22 AM
Thanks for the reply, Sparen! I wasn't in the know that that was actually the case, but after some testing, it indeed is! The issue was that I had included ObjMove_SetPosition (to half the STGFrameX and Y/4) in every Single that was in the Plural, which resulted in the boss being moved to that position every time for the new attack. Removing that piece of code resolved this issue.

Thanks once again!

You could try using ObjMove_SetDestAtFrame() instead to have the boss move smoothly back to the centre from wherever it was over a specified number of frames. That's what I use to 'reset' all the movement the boss made during each attack.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on January 29, 2019, 07:16:41 PM
ObjMove_SetDestAtFrame works fine for ensuring the boss is in the right place at the right time, but it can look kind of awkward if it moves from very far or very close to the destination. I personally made a function that moves the boss somewhere and then waits until it arrives before continuing with the script.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: [INSERT USERNAME HERE] on January 31, 2019, 01:01:08 PM
The DnhViewer.exe seems to not working in Windows 7 (or at least in my computer in this case, it works without problem in other computers) and I don't really know the problem. Is it like, normal for it to not working on Win7? If not, what the problem might be?  ???
It's just not possible to click on buttons, they don't respond.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on January 31, 2019, 05:27:03 PM
Hi everyone. I already asked the question here, but didn't get the answer, so I just forgot about it. Now though, I stumbled upon this problem one again, and really need to fix it. So, I'm trying to create a package but I'm having issues with saving replays. At the end of the process, the error on the immage appears. I tried using both custom replay saving scripts and the default one, but it's always the same. I also tried manually setting the SaveReplay parameters, but that doesn't work eather.  And at that, I'm all out of ideas on how to fix it, so I need help.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 31, 2019, 07:53:17 PM
Hi everyone. I already asked the question here, but didn't get the answer, so I just forgot about it. Now though, I stumbled upon this problem one again, and really need to fix it. So, I'm trying to create a package but I'm having issues with saving replays. At the end of the process, the error on the immage appears. I tried using both custom replay saving scripts and the default one, but it's always the same. I also tried manually setting the SaveReplay parameters, but that doesn't work eather.  And at that, I'm all out of ideas on how to fix it, so I need help.

Please provide context sufficient enough for us to replicate your issue.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on January 31, 2019, 10:07:42 PM
Can somebody please explain to me how the three angles in ObjRender_SetAngleXYZ(objID, angleX, angleY, angleZ) interact with each other?

In other words, what happens if say, angleY = 45 and angleZ = 90?
What about angleX = 30 and angleY = 180?
What about angleZ = 45 and angleY = 45 and angleZ = 45?
etc...

Alternatively, if this type of manipulation has a name that can yield relevant answers on the Google, that helps too.

Thanks in advance.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 01, 2019, 05:38:10 AM
With the standard 2D camera, the x-axis goes along horizontally, the y-axis goes along vertically, and the z-axis is going into and out of the screen. So for rotating 2D objects as you would expect (clockwise/counter-clockwise), you rotate on the z-axis since that will spin them around. Because the x-axis is horizontal, rotating along that axis will flip the object top to bottom. The y-axis being vertical means rotating along that will spin the object around side to side.

If angleZ = 90 then the object is rotated a quarter-circle around clockwise, and if angleY = 45 then it's spun around an eighth-turn, which on a 2D sprite will look like it's squished by about 70% horizontally. So combined it'll look like the object's top is on the right and the whole thing is squished a bit.

If angleX = 30 a 2D object will look a bit flattened vertically and if angleY = 180 then it will look completely mirrored left to right.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mr.Ownage on February 01, 2019, 01:09:40 PM
Hey, everyone.

With my first script having been done almost completely (which I am really excited about), there's only one problem that remains... a new problem I've run into. Sounds definitely seem to overwrite each other.

I have made a spell which spawns lasers, which leave behind trails of projectiles that begin moving after a short while. It's the same spell I had 0,0 spawning issues with back then, but that was thankfully fixed since.

However, I've run into a new, mainly cosmetic, but still a quite annoying problem. I have made the spell so a laser sound effect is heard whenever the lasers are fired, and a "charge" sound (similiar to the sound heard when the laser cage in Boundary of Humans and Youkai moves around) is heard when the projectiles begin moving.

The problem is... should new lasers be fired at the moment the projectiles move, the lasers' sounds "overwrite" the charge sound, as in, cut it short, which doesn't happen in the original Touhous (think BoHaY again).

Code: [Select]
task lazertime{
let angle = 100;
wait(60); //One time wait so the cutin can disappear by this time, and the boss can move into position
loop{
while(GetShotCount(Zataihou) > 160){yield;} //If there's many souls on screen, stop creating new lasers and trails. Souls are "Yuyuko-type butterflies".
wait(10);
ascent(i in 1..6){
let obj = CreateCurveLaserA1(ObjMove_GetX(Zataihou), ObjMove_GetY(Zataihou), 12, angle+i*12, 30, 20, 1019+i, 10); //Handles the lasers
SE_Play(laser2,70); //laser sound
ObjCrLaser_SetTipDecrement(obj,0); //Makes laser hitbox fair
ObjMove_SetAngularVelocity(obj,-7); //Handles the curving of the lasers
trail(obj); //Task to spawn trails. No issue with this one.
straighten(obj); //Task to have the lasers go straight after a short while (so they leave the screen). No issue here either.
angle+=30; //Increment angle to give different laser angles
}
}}


task fly(souls){
while(GetShotCount(Zataihou) < 150){yield;} //Wait until there's enough souls, then...
ObjMove_AddPatternA2(souls,60,NO_CHANGE,rand(40,150),0.01,0,12); //... let them move around.
SE_Play(charge4,100); //charge sound
}

The SE_Play in the above example is a task that loads, plays, then removes the sound, based on AJS' Praise The Sun (without looking at and analysing his scripts,  I probably wouldn't have been able to start at all, shoutout for his great works!)

Code: [Select]
task SE_Play(let path, let vl){
let seobj = ObjSound_Create;
ObjSound_Load(seobj,path);
ObjSound_Play(seobj);
ObjSound_SetVolumeRate(seobj,vl);
loop(120){yield;}
RemoveSound(path);
}

Could the problem be that both sounds are being handled via SE_Play? What could be possible ways to fix this?
Also, I haven't been able to stop the background music once the script ends (not while paused, I managed to do that). Any ideas about how to do that?
 
Thanks for replies in advance!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: IIe4eNiIIIe on February 01, 2019, 04:19:16 PM
Please provide context sufficient enough for us to replicate your issue.
Package part (https://pastebin.com/D6w07TBN), Continue (https://pastebin.com/Vu4JVpT7) script and ReplaySave (http://ReplaySave) script. The replay script is almost untouched, because i figured it has the main issue. As for replicating the problem, I don't really know how to do it, since I started making the package a while ago, and it has too many scripts connected with it. One thing I noticed tho, is that replayIndex in SaveReplay is somehow incorrect, but I don't know what's wrong with it
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 02, 2019, 09:16:58 AM
Code: [Select]
task SE_Play(let path, let vl){
let seobj = ObjSound_Create;
ObjSound_Load(seobj,path);
ObjSound_Play(seobj);
ObjSound_SetVolumeRate(seobj,vl);
loop(120){yield;}
RemoveSound(path);
}

Could the problem be that both sounds are being handled via SE_Play? What could be possible ways to fix this?
There are a couple problems with this kind of approach. The main issue you have is because the purpose of RemoveSound is to unload the file from memory. If you play a sound once and then try to play it again but the file is unloaded halfway through it'll just stop. It isn't the laser sound interacting with the charge sound, it's the several tasks calling RemoveSound all the time. The laser sounds are also going to be reset after 12 loops (i.e. 120 frames) but you probably won't notice it.

For that matter, you're calling PlaySE for every laser etc so it's creating a new and different sound object each time, so you're going to end up with a bunch of the same sound that starts playing on the same frame. This probably affects how it sounds in some way but I'm not sure. Also important is that you never delete these objects, so even though you're unloading the sound file the objects are going to stick around forever and potentially cause problems.

Ideally you want a single object per sound that can be played, and when you want that sound to be played somewhere you call ObjSound_Play on the same object. Try the following:

Code: [Select]
function SE_Play(path){
ObjSound_Play(SE_GetSoundObject(path));
}
function SE_GetSoundObject(path){
let se_table = GetCommonData("SE_TABLE", ID_INVALID);
if(se_table == ID_INVALID){
se_table = ObjSound_Create();
SetCommonData("SE_TABLE", se_table);
}

if(!Obj_IsValueExists(se_table, path)){
let obj = ObjSound_Create();
ObjSound_Load(obj, path);
Obj_SetValue(se_table, path, obj);
return obj;
}

return Obj_GetValueD(se_table, path, ID_INVALID);
}

What this does is make a table (a dummy sound object) that maps the sound's file path to one sound object, and when you call SE_Play to play the sound at that path it finds the associated object to use. Because the sound table dummy object ID is put into CommonData you can access the same table through different scripts.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on February 06, 2019, 03:10:12 PM
Are you able to vary things like blend types and alpha values between different vertices in a 2D Sprite List?

Assuming the answer is yes, the follow up is; how do these blend/alpha types interact with each other and the environment once you call ObjSpriteList2D_CloseVertex() ?

For example, what would be the final alpha values for Vertex 1 and Vertex 2 after this type of code?

....
ObjRender_SetAlpha(obj, 64);
ObjSpriteList2D_AddVertex(obj); // Vertex 1
?.
ObjRender_SetAlpha(obj, 128);
ObjSpriteList2D_AddVertex(obj); // Vertex 2
ObjSpriteList2D_CloseVertex(obj);
ObjRender_SetAlpha(obj, 255);
....

How do these blend types also interact with each other, especially if different vertices overlap with each other?

Thanks in advance.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mr.Ownage on February 06, 2019, 07:36:55 PM
While working on my script (which is up here now as "Terror of the Underworld"), I have been thinking of implementing a last spell in the style of Eirin (currently playing BGM stops, then, after some delay, the boss re-appears with a seperate lifebar and the spell proceeds from there, with a new BGM), but I wasn't able to figure out how could this exactly be done.

The current Plural script I use to handle the main fight so far :

Code: [Select]
let obj=ObjEnemyBossScene_Create();
ObjEnemyBossScene_Add(obj,0,CSD~"samplenonspell.txt"); //Naturally, these are not the names of the attacks, I just renamed it to this for the sake of simplicity.
ObjEnemyBossScene_Add(obj,0,CSD~"samplespell.txt");
. //the rest of the attacks here, which I didn't include to avoid a huge wall.
        .
        .
ObjEnemyBossScene_Add(obj,10,CSD~"finalspell.txt");
ObjEnemyBossScene_LoadInThread(obj);
ObjEnemyBossScene_Regist(obj);
while(!Obj_IsDeleted(obj))
{
yield;
}
BGMstop; //task to stop BGM after all attacks are done.
CloseScript(GetOwnScriptID());}

One idea I've been thinking of is using a new variable in the form of obj2 in ObjEnemyBossScene_Create and the rest of the Boss Scene commands to handle the creation of a seperate lifebar, but I'm not sure if wait() would work in this case to handle the delay (I'm thinking the lack of a boss for a short while could cause the fight to prematurely end?).

Another idea I've had and tried is to try delaying the creation of ObjEnemy (the boss) by including its spawning in a different task with wait() rather than in Initialize. Needless to say, it failed, and caused Danmakufu to close without showing an error.

Any ideas on how to approach this? Or it wouldn't be possible with more in-depth (and perhaps Common Data) knowledge?
Thank you all for advice in advance :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 06, 2019, 10:43:34 PM
Are you able to vary things like blend types and alpha values between different vertices in a 2D Sprite List?

Assuming the answer is yes, the follow up is; how do these blend/alpha types interact with each other and the environment once you call ObjSpriteList2D_CloseVertex() ?

For example, what would be the final alpha values for Vertex 1 and Vertex 2 after this type of code?

How do these blend types also interact with each other, especially if different vertices overlap with each other?

Thanks in advance.
This is the second post you've written in a row where you seem to already know what's happening and can clearly test things yourself but still want an explanation. If I don't answer this, how will you be able to figure this out? I honestly think you have the capacity to think about this on your own and I don't quite know why you're even asking. If I were teaching a Danmakufu course and you were a student, I would be asking you how to explain this.


One idea I've been thinking of is using a new variable in the form of obj2 in ObjEnemyBossScene_Create and the rest of the Boss Scene commands to handle the creation of a seperate lifebar, but I'm not sure if wait() would work in this case to handle the delay (I'm thinking the lack of a boss for a short while could cause the fight to prematurely end?).
Try it.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on February 07, 2019, 12:48:59 PM
This is the second post you've written in a row where you seem to already know what's happening and can clearly test things yourself but still want an explanation. If I don't answer this, how will you be able to figure this out? I honestly think you have the capacity to think about this on your own and I don't quite know why you're even asking. If I were teaching a Danmakufu course and you were a student, I would be asking you how to explain this.

I'm sorry if it seems that I already know what's going on, (although it also makes me secretly happy if you really think that is the case, o^-^o ) but in reality, I haven't got any idea. I have already tried testing this, but it doesn't make sense to me what's happening with regard to pixel values, which is why I'm here trying to discover what I've missed.
For example, I've tried overlaying two vertices each with alpha values of 128 and blend type BLEND_ALPHA, but the resulting rectangle, which I would expect to be solid, instead seems to have an alpha value of around 190, which I would have thought to be the behaviour if the two layers are BLEND_ADD_ARGB.
Incidentally, if the two layers are given the type BLEND_ADD_ARGB instead, they produce an opaque sprite when overlapping, which is exactly what I was expecting from BLEND_ALPHA (or maybe BLEND_ADD_RGB as well in this case?). So what I wonder is; what is it that I don't understand about alpha compositing that makes this result a surprise for me?

If you didn't answer the question ? ^^; I guess I could try poking around other areas of the internet a bit more, but this is the most logical place to look, and the concept of a '2D Sprite List' doesn't seem to be present in any other language that I know of... If I really needed to, I suppose I could step through the source code looking for where the rendering functions are implemented, but that takes so much time that I was hoping that somebody else might know before I commit myself to that.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Mr.Ownage on February 07, 2019, 04:09:36 PM
It indeed worked just as expected, Drake! I didn't actually expect it to go so easily, so smoothly, but in the end, it did, just as I wanted it to : BGM stopping, some delay, then the boss making a grand re-appearence for its final attack.

Now I have learned that there's no need to be afraid of experimentation. There is nothing to lose and everything to gain, after all.
Thanks for your reply :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 07, 2019, 08:59:45 PM
* snip *
If your goal is to purely analyse, experiment and theorize on the possibilities of Danmakufu functions and its source code then you're pretty much in bad luck. Until now, most of your posts come over as experiments and theory followed by conducting the test. My personal question: For what purpose/goal?

Example your last post question: What would that complex question possibly yield for you or people reading it?

I am getting "science" vibes from your post and we're not exactly science community that conducts research in Danmakufu. At least, not the soul purpose of the Q&A. Most people posting here are seeking a pragmatic way of working and a solution for their problems. Of course we help them also with the artistic part such as music, sounds and effects.


Additionally, you've asked two questions (fog and 3d cameras) which were both covered in two video tutorials. We pour energy and time in those tutorials to make people's life easier. However, from you I am getting the idea of laziness. If I am wrong then my apologies, but I am kind of guessing/basing this on your posting history + no content produced so far over a span of 1 year.

Edit:
My advice would be to stop bothering or breaking your mind too much about these complex things. But if that makes you happy about Danmakufu then that is all fine. But please do keep in mind the purpose of this forum section.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 08, 2019, 12:43:14 AM
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.

You'd be right that "sprite lists" seem to be just a thing with Danmakufu; I'm not really aware of similar things. But essentially sprite lists work as a sort of sprite rendering pipeline. Rather than apply some properties to sprites one at a time you set them up here and make a block of sprites then work with that instead. This is somewhat similar in function to render targets, I guess.

As for the confusion regarding blending modes, consider that if you have two partially transparent things overlapping each other and then something behind those, you will still see some of the thing in the back because that's kind of the point of being partially transparent. Just because there are two things won't make it appear solid.

Mathematically if you have a pixel color value p1 with alpha a1 on top of a pixel color value p2, the result is (p1 * a1 + p2 * a2 * (1 - a1)). The resulting alpha is (a1 + a2 * (1 - a1)) which is just 1 if p2 is opaque. (Also these are normalized to 0~1 instead of 255 so the math looks nice)

So like in your example, with two pixels with 0.5 alpha (or 128) you get a resulting alpha value of 0.5 + 0.5*(1-0.5) = 0.75, or 192 denormalized.

Meanwhile add-blending is literally about adding the pixel values, so add-argb is just (p1 + p2).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on February 08, 2019, 11:18:21 AM
Mathematically if you have a pixel color value p1 with alpha a1 on top of a pixel color value p2, the result is (p1 * a1 + p2 * a2 * (1 - a1)). The resulting alpha is (a1 + a2 * (1 - a1)) which is just 1 if p2 is opaque. (Also these are normalized to 0~1 instead of 255 so the math looks nice)

So like in your example, with two pixels with 0.5 alpha (or 128) you get a resulting alpha value of 0.5 + 0.5*(1-0.5) = 0.75, or 192 denormalized.
That you so much! I see where I went wrong now.
I mistakenly misinterpreted the formula from the wiki documentation: (r1, g1, b1) * a1/255 + (r2, g2, b2) * (1 - (a1/255)) : I wasn't taking into account that the first alpha layer was already blended with the background.

My advice would be to stop bothering or breaking your mind too much about these complex things. But if that makes you happy about Danmakufu then that is all fine. But please do keep in mind the purpose of this forum section.

I understand.
I apologise if I've been causing trouble. Thank you for still so patiently hearing me out.
I will try my best not to be a bother in the future.


Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: tsunami3000 on February 08, 2019, 01:46:29 PM
Hi! I just wanted to ask how I could create a custom life system, specifically a system with life pieces, like SA or UFO. I understand the answer is probably too complex, so I'd be okay with just knowing the general idea behind it, or like, what aspects of danmakufu should I have no problems with before I attempt to code said system.
Also, I haven't been able to find any tutorial on the matter, but if you know one, I'd be happy with just that!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 08, 2019, 10:31:50 PM
Hi! I just wanted to ask how I could create a custom life system, specifically a system with life pieces, like SA or UFO. I understand the answer is probably too complex, so I'd be okay with just knowing the general idea behind it, or like, what aspects of danmakufu should I have no problems with before I attempt to code said system.
Also, I haven't been able to find any tutorial on the matter, but if you know one, I'd be happy with just that!

In general, you will need to utilize CommonData to store information on the life pieces, as well as custom items to support them.

Unfortunately this is a relatively advanced topic. For reference:
https://sparen.github.io/ph3tutorials/ph3u3l24.html (CommonData)
https://sparen.github.io/ph3tutorials/ph3u3l25.html (Events)
https://sparen.github.io/ph3tutorials/ph3u3l26.html (User Events)
https://sparen.github.io/ph3tutorials/ph3u3l27.html (Items)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: tsunami3000 on February 10, 2019, 02:11:48 PM
In general, you will need to utilize CommonData to store information on the life pieces, as well as custom items to support them.

Unfortunately this is a relatively advanced topic. For reference:
https://sparen.github.io/ph3tutorials/ph3u3l24.html (CommonData)
https://sparen.github.io/ph3tutorials/ph3u3l25.html (Events)
https://sparen.github.io/ph3tutorials/ph3u3l26.html (User Events)
https://sparen.github.io/ph3tutorials/ph3u3l27.html (Items)

Thanks a lot!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Crescendo on February 20, 2019, 04:48:22 AM
Hello again.

I've been working on a pretty complex spell recently, but a section is giving me issues. I'll give a simpler version since the actual code is decently big:

Code: [Select]
basicbul(100, 100); //Calls the  "absorption" bullet and it's x/y coordinates.

task basicbul(xa, ya){
              CreateShotA1( xa, ya, 0, GetAngleToPlayer(objBoss), 20, 15); //Absorption bullet's creation
              undefinedFantasticObject(xa, ya); //calls for the bullets being absorbed
}

task undefinedFantasticObject(xa, ya){
let xb = 300; //creates the x/y values for the aborbed bullets
let yb = 100;
let UFO = CreateShotA1( xb, yb, 2, 180, 3, 15);//creates said bullets
if(xa && ya == xb && yb){
Obj_Delete(UFO); //boolean that says "If bullet a's x/y values are the same as bullet b's x/y values, delete bullet b. *What's not working*
       }
}


Essentially, I'm trying to create a bullet that, when another bullet reaches the center of it, the bullet "absorbs" the other bullet and grows a certain amount. I'm trying to let the boolean compare the two x/y values, but no dice. Nothing happens. Strangely, if I switch the xa/ya and xb/yb around, it does the exact opposite and deletes immediately. Even with a wait, it will delete after the wait is over, and nowhere near the absorption bullet.

Granted, it is my first time with booleans in danmakufu, but I've seen it many times before, so I don't believe it's the structure. After looking over it myself and other's script that worked with booleans similarly, I'm not sure if it's the location of the boolean or something's wrong with the variables. Can someone look this over? Thanks in advance.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 20, 2019, 07:16:12 AM
That way of phrasing the position check is incorrect. You want (xa == xb && ya == yb).

Also, xa, ya, xb, yb are just numbers. They aren't going to be updated with the bullet's new positions just because you spawned a bullet at those coordinates. Instead you need to work with the bullet objects you're creating. The ObjMove_GetX/Y functions are what will give you a bullet's current position. You can do something like this:

Code: [Select]
basicbul(100, 100); //Calls the  "absorption" bullet and it's x/y coordinates.

task basicbul(xa, ya){
let absorber = CreateShotA1( xa, ya, 0, GetAngleToPlayer(objBoss), 20, 15);
undefinedFantasticObject(absorber); //calls for the bullets being absorbed
}

task undefinedFantasticObject(absorber){
let UFO = CreateShotA1(300, 100, 2, 180, 3, 15);
if(ObjMove_GetX(absorber) == ObjMove_GetX(UFO) && ObjMove_GetY(absorber) == ObjMove_GetY(UFO)){
Obj_Delete(UFO);
}
}

This will probably have its own problem, but I want to see how much this does first.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Crescendo on February 20, 2019, 10:18:20 PM
That way of phrasing the position check is incorrect. You want (xa == xb && ya == yb).

Also, xa, ya, xb, yb are just numbers. They aren't going to be updated with the bullet's new positions just because you spawned a bullet at those coordinates. Instead you need to work with the bullet objects you're creating. The ObjMove_GetX/Y functions are what will give you a bullet's current position.

Thanks for the variable information! I'll keep that in mind for future uses.

I got it to work, but weirdly I had to throw it in a separate task that looped for it to do it. Earlier I added an else statement to play a noise see if the boolean was even working, and it only went off once. From what I've seen from other scripts, booleans didn't seem to need a separate loop, which kinda weirds me out.

I can work with this, but is the looping part normal? Just want to make sure  :V

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 21, 2019, 01:40:44 AM
Oh uh yes. I'm dumb and didn't put it in. Should wrap the collision check in while(!Obj_IsDeleted(absorber) && !Obj_IsDeleted(UFO)) and toss a yield in there. That way it checks every frame.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Crescendo on February 21, 2019, 02:33:27 AM
Oh uh yes. I'm dumb and didn't put it in. Should wrap the collision check in while(!Obj_IsDeleted(absorber) && !Obj_IsDeleted(UFO)) and toss a yield in there. That way it checks every frame.

No worries! Works like a charm, thank you for your help!

Edit: Ok, so I was trying to implement it into my spell and I have a question. Does randomness mess with the boolean? In the spell, the bullets come from different, randomized angles, yet eventually reach the center of the bullet, so it shouldn't be a big deal. Yet the boolean ignores that and doesn't run unless nothing is random. Can even confirm it's the randomness after a quick test:

Code: [Select]
let x = rand(200,200); //works
let x = rand(200,201); //doesn't work, despite the probability that 50% of the bullets should be deleted.

Sorry if I'm getting annoying at this point, but I'm too stubborn to let this spell concept go  :V I have looked for scripts with similar spells to possibly work from but have yet to find one...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 21, 2019, 09:30:09 AM
If I am not mistaking, rand() uses the entered parameter as a float and not an integer. What happens under the hood is that if you enter 200 as a parameter, it is actually initialized as 200.000000 by the engine.

If you use rand(200,201) the engine will actually generate a random number between 200.00000 and 201.000000. So technically the randomized number could be 200.583921. So there is no 50% :V Awesome aint it?

To solve this in my own game, I've created my own rand_int() function (which used to exist in 0.12m). It is actually quite dirty because it truncates the decimal value. Pretty sure someone else has a better suggestion to this.
Code: [Select]
// 0.12m personal transition for rand_int.
function rand_int(min,max) {
let rand_int_result;
rand_int_result = truncate(rand(min,max));
return rand_int_result;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Crescendo on February 21, 2019, 01:01:55 PM
It never once occurred to me decimals would be involved...  :V

I don't have too much time atm so I'll test this when I do and edit this for results later.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 21, 2019, 02:20:38 PM
It never once occurred to me decimals would be involved...  :V
:V hehehe

When in doubt, debug out

Honestly, generic advice to all danmakufu folks. Whenever you think values or numbers are acting weird: Debug them as text on your screen. It will help you a ton to understand mindbreaking problems you ran into.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Montrek on February 21, 2019, 05:04:49 PM
Hi!, I'm doing a package with only one stage inside of it and for some reason every time I play it in the final main boss part the stage is literally consuming the FPS from 60 to 40, from 40 to 30, from 30 to 18 or less...

I already checked everything, erased stuff, changed the scripts from .dnh to .txt, moved the stage script closer, only used vital effects and placed it all into one single script, didn't cover the whole screen with bullets,in the end I did a big mess inside the main stage, and also checked the player's bomb, bullets, and everything, I dunno what to do there's not much time left, if I cannot fix the FPS I'll be forced to bring this to the public with the only FPS problem due to time issues... :ohdear: :(

Also I'm using a laptop and yes I already checked and did the FPS fix inside it.  Is it due to me using a laptop to make this? :wat: ??? :ohdear:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 21, 2019, 06:28:26 PM
and for some reason every time I play it in the final main boss part the stage is literally consuming the FPS from 60 to 40, from 40 to 30, from 30 to 18 or less...

I've boldfaced your problem for you.

What happens when you play it? What gets loaded? What is unloaded? Are you creating objects that are never deleted? Are you creating tasks that never terminate?

I highly suggest using the built-in Log Window for debugging.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Montrek on February 21, 2019, 09:24:49 PM
What gets loaded is a plural script for the boss containing 1 prebattle dialogue, 2 nonspells, 3 spells, and 1 postbattle dialogue after that everything ends the only problem is the FPS...
Oh there's a task that I put to disappear bullets in patterns like in DDC or HSiFS, however yes I already tried doing it without this task...
There's also the items tasks and events that every enemy including the boss has.
There's also HiScore, Score, Lives, Bombs, graze, power and points, and yes I already tried playing it without a few of this...

And how do I get a Log Windows?

Edit:
Alright I found a LogWindow.dat now what do I do with it? :ohdear:
Unless that's not how it's done and is already inside the danmakufu or I must do it myself or something? :wat: ???
I don't know how it's done I'm new at making packages...   :blush: :wat: :ohdear:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 22, 2019, 06:07:34 AM
And how do I get a Log Windows?
Open config.exe, go to Options and check Show Log Window. Then on launch the log window will appear, and you can check the Info tab for various things.

I agree this is probably a case of objects that continually spawn and are not deleted. You can monitor how many objects exist through the log window and see if they just keep increasing while your script is running.

Ok, so I was trying to implement it into my spell and I have a question. Does randomness mess with the boolean? In the spell, the bullets come from different, randomized angles, yet eventually reach the center of the bullet, so it shouldn't be a big deal.
This goes back to what I said about "this will probably have its own problem". This happens because collisions are more complicated than just position = position. Like Hele says, you could have a position value that is like 200.583921, and that will not be equal to 200. Even if a bullet gets close to the position of the other, the chances they will actually be equal is extremely small unless both bullets are tightly controlled (which is what you saw when you had no randomness and a 180 angle and integer-valued speed).

Instead, collision typically checks if the distance between the two things is less than some amount. You can do this using
if(((x1 - x2)^2 + (y1 - y2)^2)*0.5 < r) or if(GetObjectDistance(obj1, obj2) < r).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Montrek on February 22, 2019, 09:17:43 AM
Interesting..., apparently what seems to keep increasing but without being erased is the obj_count like more than 7000, but I don't really know how to actually decrease or erase all of that... :ohdear: ??? :wat:
What do I do? Is it inside the script and needs a task or function for this or I'll need some kinda special file? :ohdear: ???
Or erase stuff? :wat:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: [INSERT USERNAME HERE] on February 22, 2019, 09:32:56 AM
Interesting..., apparently what seems to keep increasing but without being erased is the obj_count like more than 7000, but I don't really know how to actually decrease or erase all of that... :ohdear: ??? :wat:
What do I do? Is it inside the script and needs a task or function for this or I'll need some kinda special file? :ohdear: ???
Or erase stuff? :wat:
Can you locate which objects are not deleting? Are they a bunch of bullets that go out of screan frame then move to infinty? Are they primitives for various effect that doesn't get deleted? There are a lot of things that could be causing this.
Edit: Oh wait. Shots and other objects are shown separately in LogWindow, sorry.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 22, 2019, 09:34:48 AM
You need to control your objects and proper clean them up when they are no longer needed. Objects (effects, bullets etc) created by you are never auto-deleted. Even if they leave the screen.

The default function call for objects is Obj_Delete

Small code example:
Code: [Select]
task someComplexBullet() {
  let obj = ...

  while (!Obj_IsDeleted) {
    // complex behaviour

    if () {
      Obj_Delete(obj);
    }
  }
}
Basically this task creates an object and is doing things while it is not deleted. This could be anything. You need to decide, as a programmer, when this object should be deleted. In the code example I did it with a if-statement, but it could be anything. The goal is to delete the object.


Edit as moderation note:
Do not double post if your post is the last one in the thread. Edit your original post and append your findings and/or questions.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Arcvasti on February 22, 2019, 08:17:24 PM
Objects (effects, bullets etc) created by you are never auto-deleted. Even if they leave the screen.

That simply isn't the case for bullets. The default settings have bullets deleting themselves when they move 64 pixels outside the stgframe thingy. Which isn't to say that you might not want to turn off autodelete for a particular group of bullets and manually delete them, but simple bullets shouldn't have that problem.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Montrek on February 22, 2019, 10:59:15 PM
Yup it seems like the player shots are not being deleted either, I noticed this cause everytime I shoot into oblivion the obj_count seems to be increasing in a very critical way.
Is there actually something the I can put inside the player? ???
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 23, 2019, 01:01:09 AM
We'll have to see your scripts to get an idea of what you aren't deleting. Player shots should also automatically be deleted going out of bounds, so...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on February 23, 2019, 01:34:27 PM
Hmm... I have a question:

What's the purpose of creating a bullet pattern that goes in a 3D geometric shape (i.e., a 3D sphere, and even this: https://youtu.be/E_ODbJzyqbA?t=360 (https://youtu.be/E_ODbJzyqbA?t=360))?

If you have an example and a formula of it, let me know.
Please respond.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on February 25, 2019, 05:59:40 AM
What's the purpose of creating a bullet pattern that goes in a 3D geometric shape
- Maybe because the author felt like it.
- Maybe because it looks cool.
- Maybe because the author thinks the pattern is part of the character.
- Maybe because geometry is sexy.

This is asking like: What's the purpose of riding a bicycle. (Unless I am missing something).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Montrek on February 26, 2019, 03:21:35 AM
Sorry for the unfortunate delay... :blush:
Here it is...

Code: [Select]
#include "./functions.dnh"
#include "./shotfunctions.dnh"
#include "./soundfunctions.dnh"

task shoot{
let count = 0;
loop{
if(GetVirtualKeyState(VK_SHOT) != KEY_FREE && count%2 == 0){
if(CanShoot && !IsPlayerSpellActive){
//Regular shots
PlaySoundA1(9, 70, 0);
TShotRegular(GetPlayerX + 8, GetPlayerY, 20, 270, 1, damage*1.5);
TShotRegular(GetPlayerX - 8, GetPlayerY, 20, 270, 1, damage*1.5);
}
}
count++;
yield;
    }
}

task option(rads, rads2, starta, aplus){
let objOption = ObjPrim_Create(OBJ_SPRITE_2D);
Obj_SetRenderPriorityI(objOption, 31);
ObjRender_SetBlendType(objOption, BLEND_ALPHA);
ObjPrim_SetTexture(objOption, GetCurrentScriptDirectory ~ "./....shot.png");
ObjSprite2D_SetSourceRect(objOption, 40, 45, 61, 67);
ObjSprite2D_SetDestCenter(objOption);
ObjRender_SetPosition(objOption, GetPlayerX, GetPlayerY, 0);

let destX;
let destY;
let dist;
let dir;

let a = starta;

let count = 0;
let shotAngle = -90;
while(!Obj_IsDeleted(objOption)){
if(!optionAlive){Obj_Delete(objOption);}
if(GetVirtualKeyState(VK_SLOWMOVE) == KEY_FREE){
destX = GetPlayerX + rads[0]*cos(a);
destY = GetPlayerY + rads[1]*sin(a);
}else{
destX = GetPlayerX + rads2[0]*cos(a);
destY = GetPlayerY - 32 + rads2[1]*sin(a);
}

let opX = ObjRender_GetX(objOption);
let opY = ObjRender_GetY(objOption);
dist = GetDist(opX, opY, destX, destY);
dir = GetAngle(opX, opY, destX, destY);
opX += 0.25 * dist * cos(dir);
opY += 0.25 * dist * sin(dir);
ObjRender_SetPosition(objOption, opX, opY, 0);
ObjRender_SetAngleZ(objOption, count * 2);

if(GetVirtualKeyState(VK_SHOT) != KEY_FREE && count%2 == 0){
if(CanShoot && !IsPlayerSpellActive){
PlaySoundA1(6, 60, 0);
if(GetVirtualKeyState(VK_SLOWMOVE) == KEY_FREE){
TShotRegular(opX, opY, 20, 270, 3, damage*1.5);
TShotRegular(opX, opY, 10, 270, 3, damage*1.5);
}else{
TShotRegular(opX, opY, 20, 270, 3, damage*2.5);
TShotRegular(opX, opY, 20, 270, 3, damage*2.5);
}
}
}
count++;
a += aplus;
yield;
}
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 26, 2019, 07:35:36 AM
The issue is likely in PlaySoundA1, and likely because you're creating a new sound object every time you want to play something and not deleting it. Problem could also be in TShotRegular but like we said before player shots are deleted automatically by default.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Infy♫ on February 26, 2019, 11:38:44 AM
If I am not mistaking, rand() uses the entered parameter as a float and not an integer. What happens under the hood is that if you enter 200 as a parameter, it is actually initialized as 200.000000 by the engine.

If you use rand(200,201) the engine will actually generate a random number between 200.00000 and 201.000000. So technically the randomized number could be 200.583921. So there is no 50% :V Awesome aint it?

To solve this in my own game, I've created my own rand_int() function (which used to exist in 0.12m). It is actually quite dirty because it truncates the decimal value. Pretty sure someone else has a better suggestion to this.
Code: [Select]
// 0.12m personal transition for rand_int.
function rand_int(min,max) {
let rand_int_result;
rand_int_result = truncate(rand(min,max));
return rand_int_result;
}


This is an incorrect operationalization of rand_int. truncate rounds your number down, and statistics dictates that the chance of getting exactly 201 is miniscule. This means rand(200,201) will always return 200, while I figure you want a 50/50 distribution here between 200 and 201.

Here's how I did it:

Code: [Select]
function rand_int(low,high) {
 return truncate(rand(low,high+1));
}

Basically the same as what you did, except the upper bound is increased by 1.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on February 26, 2019, 12:35:14 PM
rand() is inclusive on lower and upper bounds, so you can still technically get 201 there. Anyways, the truncate method screws up if you use negative numbers: with your method rand_int(-1, 0) basically always returns 0, and rand_int(-2, -1) has the same problem of almost never returning -2 while also returning 0 half the time which is very wrong.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Infy♫ on February 26, 2019, 01:58:04 PM
rand() is inclusive on lower and upper bounds, so you can still technically get 201 there. Anyways, the truncate method screws up if you use negative numbers: with your method rand_int(-1, 0) basically always returns 0, and rand_int(-2, -1) has the same problem of almost never returning -2 while also returning 0 half the time which is very wrong.
I didn't give the negative number case a thought yet, good point. I suppose what follows now is the better rand_int that I'll be using in my code.

Code: [Select]
function rand_int(low,high){
return round(rand(low-0.49999,high+0.49999));
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Montrek on February 26, 2019, 04:35:08 PM
It seems like the fault was at the enemies all along... :ohdear:
But I don't understand very well, is it bad if I use Jan Aldryn Bio Fairy Functions or is it better if I do my own ???
After all I remember two or three people using this functions other than himself and they worked fine...
edit----------------
Wierd the script it's good all of a sudden... :)
I should still replace the fairies though. :wat:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 27, 2019, 01:50:19 AM
But I don't understand very well, is it bad if I use Jan Aldryn Bio Fairy Functions or is it better if I do my own ???
After all I remember two or three people using this functions other than himself and they worked fine...

Rule #1 of programming: Don't use code you do not understand

If you use someone else's code, you should use it knowing that it may have undocumented issues. Just because other people use it doesn't mean it works the way you think it does. In particular, afaik those libraries have had other problems here on the Q&A threads before.

It is not a matter of whether or not it is 'better' to make your own version. If that code works for you and you are allowed to use it, by all means feel free to use it. But my overall recommendation is to make your own once you have the experience to do so - you'll have finer-grained control of what your code is doing and it will work the way *you* want it to.

P.S.
https://dmf.shrinemaiden.org/wiki/Script_Functions#SetAutoDeleteObject
https://sparen.github.io/ph3tutorials/ph3u2l16.html
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Montrek on February 28, 2019, 06:02:56 AM
I sincerely thank you for all the help :)

Also I noticed some of you make your own music, if so would you mind giving me the name of the app or program you use?  ;)

It would be of great help, since many people like original music! :D
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 06, 2019, 12:40:18 AM
Sup

So I'm playing around with GFW's ice mechanic and a little stuck on how to calculate ice area. I know how to find the combined area of two intersecting circles, but I'm unsure how to generalize that to an arbitrary number of possibly-intersecting circles in a way that will be fast enough to be viable. Any ideas?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 06, 2019, 09:00:28 AM
The first easy approach that comes to mind is to Monte Carlo it. The ice area doesn't need to be exact, and you can balance efficiency versus accuracy. Find the bounding box of the circles, throw a bunch of random points out and check against each circle. The ratio of the points hitting a circle to the total points multiplied by the area of the bounding box is approximately the covered area.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 07, 2019, 03:37:22 AM
The first easy approach that comes to mind is to Monte Carlo it. The ice area doesn't need to be exact, and you can balance efficiency versus accuracy. Find the bounding box of the circles, throw a bunch of random points out and check against each circle. The ratio of the points hitting a circle to the total points multiplied by the area of the bounding box is approximately the covered area.
I suppose that works well enough. After fiddling around a bit I found that trying max(100, min(1000, 1000 / (length(circles)/10)^0.5 ) ) points across the whole screen (too lazy to find a bounding box) seems to give a decent balance of efficiency and accuracy.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 07, 2019, 05:01:26 AM
Another idea I had to speed things up a bit would be to make a grid of the screen and do spatial hashing with cell size R (ice circle radius), where first you go through every circle, check the cell the center is in, then mark the 9 grid cells around it with the circle to make a list of "circles touching this cell". Then instead of checking a point against every circle you'd look up where it is in the grid then only check any circles that were listed for that cell. (i.e. basically just broad-phase collision detection)

that is until i remembered danmakufu can't modify multidimensional arrays any deeper than one level
you can emulate multidim indexing but as if i'm gonna bother with that
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Twizz on March 09, 2019, 02:40:41 AM
Back again with that Stage 5/6 SA Background waves. I'm still trying to figure out how to replicate the waves from stage 5/6 SA background.

It seems to be a basic wave distortion using sine and cosine but I have no idea how to write shaders in HLSL much less how to implement it. Does anyone have any similar examples or an idea how to actually write a shader to replicate the waves? I was looking at the HLSL samples (mainly the SamplePS03) but I didn't get far with that.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 09, 2019, 06:10:47 PM
Is this thread (https://www.shrinemaiden.org/forum/index.php/topic,12207.90.html) still current with regards to Bulletforge registration? I know registration is still disabled, but I'm mainly wondering if new accounts can still be manually created / if anyone will respond if I request one in there. It's been almost 3 years since anyone posted in that thread so hesitant to just poke my head in there.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on March 09, 2019, 07:30:44 PM
Blargel doesn't seem to be roaming IRC or forums any more. His last activity was February 2018. That is a year ago. I am afraid you won't be able to get something registered on bulletforge  :ohdear:
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 09, 2019, 10:05:44 PM
Blargel doesn't seem to be roaming IRC or forums any more. His last activity was February 2018. That is a year ago. I am afraid you won't be able to get something registered on bulletforge  :ohdear:
Bluh

So now I'm playing with StB/DS-esque camera mechanics. I've got the shot-clearing aspect taken care of, but not sure how to approach rendering the captured area to a photo. I know it's probably going to involve RenderToTextureA1 and/or SaveSnapShotA2, but I'm not sure how to then get the correct region for the rotated rectangle of the target area. I have a vague inkling that I might need to rotate the screen before capturing the image?

E: Also, does anyone have the "camera ready" sound effect or a recreation thereof? That's the only one I haven't been able to find.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 10, 2019, 02:12:06 AM
You could use RenderToTexture over the STG frame then using that texture draw a primitive rectangle using the picture corner coordinates as UV vertices (instead of making a sprite like you're probably thinking).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 10, 2019, 03:10:56 AM
You could use RenderToTexture over the STG frame then using that texture draw a primitive rectangle using the picture corner coordinates as UV vertices (instead of making a sprite like you're probably thinking).
Hmm, I'll look into that. For now I got it working using the 2D camera settings and SaveSnapShotA2 - it's not rendering everything perfectly (some stuff in the background has too much alpha, see screenshot) but it seems good enough for now.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 10, 2019, 05:48:45 AM
here's my rough

Code: [Select]
function take_pic(at_x, at_y, to_x, to_y, scale){
let x = at_x+GetStgFrameLeft();
let y = at_y+GetStgFrameTop();
let a = -20;
let w = 200;
let h = w/4*3;
let cam = [
// camera center + corner offsets + rotation
[x + (-w/2*cos(a) - h/2*sin(a)), y + (-w/2*sin(a) + h/2*cos(a))],
[x + ( w/2*cos(a) - h/2*sin(a)), y + ( w/2*sin(a) + h/2*cos(a))],
[x + (-w/2*cos(a) + h/2*sin(a)), y + (-w/2*sin(a) - h/2*cos(a))],
[x + ( w/2*cos(a) + h/2*sin(a)), y + ( w/2*sin(a) - h/2*cos(a))]
];

let pic_id = GetCommonData("CAMERA_PIC_COUNT", 0);
SetCommonData("CAMERA_PIC_COUNT", pic_id + 1);

let tex = "CAMERA_PIC_" ~ rtos("000", pic_id);
CreateRenderTarget(tex);
RenderToTextureA1(tex, 20, 60, true);
let p = ObjPrim_Create(OBJ_PRIMITIVE_2D);
ObjPrim_SetPrimitiveType(p, PRIMITIVE_TRIANGLESTRIP);
ObjPrim_SetVertexCount(p, 4);
ObjPrim_SetTexture(p, tex);
ascent(i in 0..4){
ObjPrim_SetVertexUVT(p, i, cam[i][0], cam[i][1]);
ObjPrim_SetVertexPosition(p, i, cam[i][0]-x, cam[i][1]-y, 0);
}
ObjRender_SetPosition(p, to_x, to_y, 0);
ObjRender_SetScaleXYZ(p, scale, scale, 1);
Obj_SetRenderPriorityI(p, 90);
}

(https://i.imgur.com/NFfZn1A.png)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 12, 2019, 02:27:34 PM
So I've got one of those impossible-to-track-down issues that don't make sense. Danmakufu is now force closing upon loading scripts, and I can't figure out what I might have changed that could be causing this. Just prior to this, it was force closing upon closing scripts, but only certain ones and only under certain conditions; I spent several hours commenting things out trying to pin down what was causing it and concluded that there was no cause and any illusion of cause was completely fake because I literally removed the entire system related to what appeared to be the cause and it still happened, and I couldn't get it to happen at all in scripts that weren't affected, even by rewriting the same exact code as the problematic script. Finally, every script started force closing before they even started, for no discernible reason.

I searched for non-ASCII characters and found none other than the usual leftover Japanese comments. That was my only real hypothesis for something that could cause this. Any ideas?

I would post my code but I have absolutely no idea where the problem is.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 17, 2019, 08:32:04 PM
Okay, I have no idea why but the inexplicable force quit on trying to load any script has stopped, allowing me to go back to tracking down the other bug.
I've determined that it's force closing when it tries to load a common data area. It's used in multiple places so it could already exist or not - I'm in the process of tracking down the exact conditions, but here's the code it's crashing on:
Code: [Select]
if(!IsCommonDataAreaExists("cutin_History")){CreateCommonDataArea("cutin_History");}
LoadCommonDataAreaA1("cutin_History"); // <-- force quits here
I've commented out one of the two places I found this but it still happens; possibly a third place?

(Edit: I checked with find in files and those were the only two places. It still happens if I change the name entirely in one place and remove the others, and still happens with only the second line. It seems like any use of LoadCommonDataAreaA1 is causing it??? Which is weird because while I only recently added that snippet to a second place, it's been hanging out in the cutin function for ages without issue.)

Elsewhere I have this, which has caused no problems, but I'm pretty sure this is the only place I try to load that one:
Code: [Select]
let isconfig = LoadCommonDataAreaA2("CONFIG",dirdat~"config.dat");
if(!isconfig){
CreateCommonDataArea("CONFIG");
SetAreaCommonData("CONFIG","Difficulty",NORMAL);
SetAreaCommonData("CONFIG","MainEquip",EQ_CAMERA);
SaveCommonDataAreaA2("CONFIG",dirdat~"config.dat");
}

I don't really understand under which conditions creating or loading common data areas causes issues; if someone could explain that to me I could probably figure it out from there.

Edit: the following also crashes:
Code: [Select]
let path = dirdat~GetScriptInfoA1(GetMainStgScriptPath, INFO_SCRIPT_ID)~"_common_cutin_History.dat";
LoadCommonDataAreaA2("cutin_History",path);
but THIS doesn't:
Code: [Select]
let path = dirdat~GetScriptInfoA1(GetMainStgScriptPath, INFO_SCRIPT_ID)~"_common_cutin_History_asdf.dat";
LoadCommonDataAreaA2("cutin_History",path);
I don't get it

Edit: I changed the path to use for it everywhere, which made it work once. The second time, after it had already saved the info there, it crashed as usual.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 18, 2019, 03:48:33 AM
What are the contents of the data? Does it still crash if it's empty or has just one value stored? What's the minimal replicating conditions you can find?

I can create, save, and load areas just fine in pretty much whatever order, load multiple times, use create before/after loading, etc. Don't think there's a problem with the basic functionality.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 18, 2019, 12:51:19 PM
What are the contents of the data? Does it still crash if it's empty or has just one value stored? What's the minimal replicating conditions you can find?
Here's the code where the contents are set (not mine):
Code: [Select]
//These are long-looking common data group names
let SpellDataAttempt = SpellName~"|"~CutinDifficulty~"|"~GetPlayerID~"|"~"Attempt";
let SpellDataGet     = SpellName~"|"~CutinDifficulty~"|"~GetPlayerID~"|"~"Get";
//This is actually the common data retrieval
let SpellValueAttempt = GetAreaCommonData("cutin_History", SpellDataAttempt, 0);
let SpellValueGet     = GetAreaCommonData("cutin_History", SpellDataGet,     0);

if(!IsReplay){
SpellValueAttempt++;
SetAreaCommonData("cutin_History", SpellDataAttempt, SpellValueAttempt);
SaveCommonDataAreaA1("cutin_History");
}

And here's what I was trying to add when this whole thing started:
Code: [Select]
if(!IsCommonDataAreaExists("cutin_History")){CreateCommonDataArea("cutin_History");}
LoadCommonDataAreaA1("cutin_History");

let group = CurrentSC~"|"~GetCommonData("Difficulty","Normal")~"|"~GetPlayerID()~"|";
let hiscore = GetAreaCommonData("cutin_History", group~"DecisiveBestShot|Score", 10000);
if(photoScore > hiscore){
SetAreaCommonData("cutin_History",group~"DecisiveBestShot|Score", photoScore);
SetAreaCommonData("cutin_History",group~"DecisiveBestShot|Angle", origAngle);
SetAreaCommonData("cutin_History",group~"DecisiveBestShot|Boni", Obj_GetValueD(photo,"Boni",[])); // <----- wait... is it this?!?!?!

let _CurrentSC = JoinString(SplitString(CurrentSC,"\"/*|<>:? _"),""); //remove characters that can't be in filename
let fname = dirdat~"DecisiveBestShot_"~_CurrentSC~"_"~GetCommonData("Difficulty","Normal")~"_"~GetPlayerID~".png";

LoadTexture(texture); //this is ridiculous but I couldn't find a better way that was actually working
let obj = CreateSprite(0,0,texture,[0,0,GetTextureWidth(texture),GetTextureHeight(texture)], 99);
ObjSprite2D_SetDestRect(obj,0,0,GetTextureWidth(texture),GetTextureHeight(texture));
SaveSnapShotA2( fname, 0,0,GetTextureWidth(texture),GetTextureHeight(texture));
Obj_Delete(obj);
}
let photosTaken = GetAreaCommonData("cutin_History", group~"PhotosTaken", 0);
SetAreaCommonData("cutin_History",group~"PhotosTaken", photosTaken + GetCommonData("PhotosTaken",1));
SaveCommonDataAreaA1("cutin_History");

I just tried deleting the history and trying without saving the array of boni, and it doesn't appear to be happening like that? So... I guess it can't handle loading common data areas with arrays stored in them???
Or... Ah! The boni are actually a 2D array, [["Bonus name", "value"],["Self Shot","x1.2"]], but here I'm defaulting to just []. If I default to [[]] instead...
Oh my god. That was it. Now I understand why this bug seemed so random and nonsensical. I hate how much sense it makes now.

Edit: Wait, fuck, it just happened again
Edit2: Fuck arrays, I'm just storing it as one big string
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 18, 2019, 05:32:34 PM
Okay, separate question: How would you recommend implementing a LoLK-style checkpoint system? Or something like Spell Practice where you restart the card when you get hit?

The latter could technically be done by just reloading the script but that would obviously be extremely slow, plus it would restart the music.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on March 19, 2019, 03:24:13 AM
How would you recommend implementing a LoLK-style checkpoint system?

Oh, boy... Before I do answer this question, let me warn you, it is a huuuuge pain in the butt to do.
I do happen to have a half-finished implementation of it in Shrines;Gate. It has most of the stuff listed below, but because I've been lazy with saving and reloading so many things, I decided to skimp out on a few parts, so it's not 100% accurate. That stuff's for the truly determined, which I'm not.
Anyway:

It's nothing really more than Common Data spamming.

Well, good luck. i only gave a rather barebones outline of what you need to do, so don't be afraid to ask for clarification.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 20, 2019, 12:26:13 AM
Oh, boy... Before I do answer this question, let me warn you, it is a huuuuge pain in the butt to do.

Oof, so I see.
Honestly I'm mostly trying to do StB/DS-type stuff where the spell restarts if you take a hit. So I'm more than willing to abandon saving the whole state and just clear everything out and go back to the beginning.

For now, I added something to my wait function so I can use common data to make it break out of whatever it's doing and essentially fall through to the bottom of the main task, then clear shots, move everything back to its original position, and start over.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on March 21, 2019, 04:55:01 AM
Oof, so I see.
Honestly I'm mostly trying to do StB/DS-type stuff where the spell restarts if you take a hit. So I'm more than willing to abandon saving the whole state and just clear everything out and go back to the beginning.
Ah, uh, if you're making a Spell Card Collection-style or StB/DS-style thing where there's just one attack per scene, then you don't really need anything Pointdevice-like...? Merely restarting everything without regard for what happened at any previous point in time would be totally fine I believe.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 24, 2019, 01:45:31 PM
Ah, uh, if you're making a Spell Card Collection-style or StB/DS-style thing where there's just one attack per scene, then you don't really need anything Pointdevice-like...? Merely restarting everything without regard for what happened at any previous point in time would be totally fine I believe.
Well, yes. But cleaning everything up and restarting without actually reloading the script isn't trivial, either. When I tried to just have my main task return and call it again I was getting a bunch of weird lag. The way I have it now is essentially skipping to the bottom of the main task, spamming DeleteShotAll for a few frames, and resetting the score and graze, along with the boss' life/photos taken.

In any case, I'm not necessarily limiting it to just SCC-style stuff, but... well, it's more like several scenes like that chained together, so it's basically similar but with a little more information saved. I'm experimenting with extending photography-based gameplay beyond singles, basically.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 24, 2019, 06:01:27 PM
So I wound up reworking how I'm taking photos to use a primitive like what Drake posted, but I'm having a hard time getting clean edges when taking pics that overlap the edge of the stage frame. It's wrapping around and capturing stuff from the other side of the screen. My current workaround is drawing a sprite that covers up everything but the capture region, so any wraparound should in theory just be white, but it's having rather inconsistent results. Sometimes it works fine, other times it just doesn't block it at all, other times it blocks part of it but other parts get through. The parts getting through are always triangular, though may be cut off. (See attached screenshot for an example.)

Any suggestions for how to prevent this, or insight into how it might be happening?

I am rotating the primitive to capture a snapshot of it still, if that might have something to do with it.

E: This is pretty weird, actually. It's not just wrapping around to the other side of the stage frame like I thought - it's wrapping back around to somewhere nearby, from some oddball place and angle I don't understand the relation of. In the second attached screenshot you can see it captured the corner of another photo I had taken a moment before, and still see the previous photo in question in the process of fading out.
E2: At this point I've got it masking everything but the region I want to capture, but it sometimes wraps back around and captures part of the same region in that area that should be offscreen. (see third pic, in which Aya herself is visible in two different places in the photo.)
(Also, is there a way to put these pics in a collapsible or something to avoid cluttering up the thread too much?)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on March 25, 2019, 12:59:56 AM
Shouldn't this be entirely solved by drawing only the relevant layers onto the texture? The rest of the resulting texture should be transparent. I used 20 to 60 in my example but you would use whatever layers encompass the stuff in the play area you want to capture.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Chronojet ⚙ Dragon on March 25, 2019, 03:42:12 AM
So I wound up reworking how I'm taking photos to use a primitive like what Drake posted, but I'm having a hard time getting clean edges when taking pics that overlap the edge of the stage frame. It's wrapping around and capturing stuff from the other side of the screen. My current workaround is drawing a sprite that covers up everything but the capture region, so any wraparound should in theory just be white, but it's having rather inconsistent results. Sometimes it works fine, other times it just doesn't block it at all, other times it blocks part of it but other parts get through. The parts getting through are always triangular, though may be cut off. (See attached screenshot for an example.)

Any suggestions for how to prevent this, or insight into how it might be happening?

I actually have like... 20? render targets, 10 for the regular images, another 10 for alpha masks. So nothing's rendered to an actual file in my own case. (Feel free to save files for your own system, maybe?)
So the idea is to keep a list of centers of your images and of the angles at which your viewfinder was tilted when the photo was taken.
So rendering that to an image, and then a white border on top of that, you'd have exactly what you'd see in the first image attached below.
I'd rather not render the entire image, so I use a primitive object with vertices placed where the corners of the viewfinder were located.
It seems you have something of a similar idea? I personally wouldn't rotate the image just to rotate it back again, though I might be totally derping out with my reading - if it turns out you didn't actually do so, then please ignore me lol.

As for what I did to make my photos fade to transparency -
I have a border covering the sidebar so that everything outside of the playing field is black, everything inside is white, and there's a sort of gradient in between just on the inside of the edge. I throw that into an alpha mask shader that interprets value/brightness as transparency. That way none of what's outside the playing screen is visible. See second image for an example.

Pictures of what I had, as mentioned before.
https://imgur.com/a/CdA3zsD

I'm not really as detailed in my explanation as I'd like to be, but honestly speaking it's been a while and looking at my own code now, well... It'd be a miracle to decipher it, even for myself...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 25, 2019, 07:24:51 PM
I personally wouldn't rotate the image just to rotate it back again, though I might be totally derping out with my reading - if it turns out you didn't actually do so, then please ignore me lol.
No no, that's exactly what I'm doing. It's because I want to save the decisive best shot for each scene but can only save a non-rotated rectangle.

So the idea is to keep a list of centers of your images and of the angles at which your viewfinder was tilted when the photo was taken.
So rendering that to an image, and then a white border on top of that, you'd have exactly what you'd see in the first image attached below.
I'd rather not render the entire image, so I use a primitive object with vertices placed where the corners of the viewfinder were located.
It seems you have something of a similar idea?
That is pretty much what I'm doing now, yes. Thing is, it's wrapping around weirdly and I don't know why.

As for what I did to make my photos fade to transparency -
I have a border covering the sidebar so that everything outside of the playing field is black, everything inside is white, and there's a sort of gradient in between just on the inside of the edge. I throw that into an alpha mask shader that interprets value/brightness as transparency. That way none of what's outside the playing screen is visible. See second image for an example.
That's pretty cool, I won't lie. I don't think it would solve my issue, though, since I'm only capturing layers that are inside the stage frame anyway.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Aka Kyuketsuki on March 25, 2019, 07:57:48 PM
I think it should work though. Applying a filter to a small image or a large image will do the same thing so don't worry about that. Save the one as a separate file or render target and apply it over your photo.

For reference, here's an image (https://dl.dropboxusercontent.com/s/w4whjf1qsgrkoua/stg_borderfadeout.png) Chronojet used for applying to the STG frame as a transparency filter.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Andi on March 26, 2019, 11:34:06 PM
I think it should work though. Applying a filter to a small image or a large image will do the same thing so don't worry about that. Save the one as a separate file or render target and apply it over your photo.

For reference, here's an image (https://dl.dropboxusercontent.com/s/w4whjf1qsgrkoua/stg_borderfadeout.png) Chronojet used for applying to the STG frame as a transparency filter.
Ah... Now I see what you're suggesting. I suppose I could try that. Though, for the moment I'm more likely to just throw a white primitive on top of the part of the photo I want to blank out.

E: Ah, I found the problem. Turns out I'm just an idiot and wasn't covering up the stuff below the primitive other than the frame before saving the picture.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on April 03, 2019, 11:28:39 AM
Hi,
What does the ##ReplayName["string"] header in the player scripts do?
Thanks in advance
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 03, 2019, 09:22:01 PM
(https://i.imgur.com/jTIHqOe.png)

The "NazrinA" here. It just serves as a player identifier for replays.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinghidrorah on April 05, 2019, 07:15:27 AM
Hello everyone,

So I have been programming in danmakufu for a little while now and for my next script I would like to include my own type of shots. Unfortunately I am having a great deal of trouble doing this, for reasons that I cannot understand. So for example I would like to use the image attached as a bullet type (I haven't yet made the background transparent but I know how to do that so that's fine). I therefore created a shotsheet with

#UserShotData

shot = "./integ2.png"
delay_rect = (0,0,26,100)

ShotData{id = 450 rect=(0,0,26, 100) render=ALPHA angular_velocity = 0 delay_color= (255,255,255)}

(I understand that doing this would cause the bullet to have the same graphic during the delay period, but I thought danamakufu would dislike it if I didn't include the delay_rect line).

Then I created the shot constant sheet

local {
   let CSD = GetCurrentScriptDirectory;
   let path = CSD ~ "shotInteg.txt";
   LoadEnemyShotData(path);
}

let INT      = 450;

and when I try to make that bullet appear, nothing happens. There isn't even an object there since nothing kills me when I go to where it's supposed to spawn. WHat is the problem here?

PS: Sorry if this seems obvious to some of you, and maybe the solution is already somewhere in this forum. If so, could someone point me to it? Thanks in advance!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 05, 2019, 07:54:43 AM
The keyword for the image file is shot_image. That might be the only thing wrong.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Twizz on April 08, 2019, 11:14:57 PM
Currently making some stage enemies. I'm using sparen's tutorial on it: https://sparen.github.io/ph3tutorials/ph3u3l28.html. However, every time I spawn an enemy and there isn't an enemy on the screen, danmakufu stops for a second (probably trying to run the thing) and continues without any lag. It's noticeable enough to raise some concern. Is there something in the code itself that is causing the pause, or is it the way it's programmed? Also, is there another (and better) way to make stage enemies?

this is the code I have for the enemies:
https://pastebin.com/YV6dvHQz
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 08, 2019, 11:47:33 PM
That kind of lag tends to come from something unloading due to being unused and having to later be reloaded or recompiled, but nothing in particular in here seems like it would make a significant impact. How are you calling this? The script should just be imported into the stage and the Create task called per enemy?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Twizz on April 08, 2019, 11:57:40 PM
I'm calling it through a stage script as a statement. Here's the code for that:
https://pastebin.com/sNPHB8Kh
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 09, 2019, 12:16:51 AM
Yeah, I dunno if I'm missing something here, but unless enemFairy.png is like significantly big I don't see why it would actually stutter. Just to check though,
1) In the log window, check if the texture is pruned after the first wave then reloaded (this should be the case given your description)
2) Move your declaration of objImage outside the task and use LoadImage to preload it. This should keep the texture in memory so even after everything that uses the texture is deleted it persists instead of being unloaded.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Twizz on April 09, 2019, 12:29:03 AM
Yep, I just checked the debugger, and it seems to occur to when it reloads the texture (it doesn't reload it when a fairy is still on screen). Using LoadImage and having it outside the task fixed the lag issue.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 09, 2019, 12:45:42 AM
On a larger scale, this is why games and full stages often preload their resources, and why stages begin compiling their scripts at the start of the stage.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tad Marx Barba on April 12, 2019, 06:32:52 PM
My player script go through a lag that freeze a few seconds Danmakufu and then, render a shield around the player (instead of using TMagicCircle()).

And when the player dies and keep pressing the shot button, this error happens:
https://ibb.co/GsgyB0C (https://ibb.co/GsgyB0C)

What can I do in these cases?

Player link: https://1drv.ms/u/s!AgwNeb6oBlvsgd9U5gYLfol-acAwmA (https://1drv.ms/u/s!AgwNeb6oBlvsgd9U5gYLfol-acAwmA)
I've noticed that I put this post outside of this thread, my apologies  :P

I've removed your other thread, thanks for noticing and posting in the correct thread --Hele
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: tsunami3000 on April 14, 2019, 06:53:40 PM
Hi! I have a small doubt...

When using DeleteShotAll and TYPE_ITEM, all of the bullets on screen are turned into items (little white boxes) which fly towards the player. How could I make it so that a sound is played when the player picks up those items?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Twizz on April 14, 2019, 07:24:48 PM
In the player's @Event section, you can add

Code: [Select]
case(EV_GET_ITEM){
      //statements;
}

and you can add sound effects in there since it will run every time the player gets an item
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: tsunami3000 on April 14, 2019, 07:43:18 PM
In the player's @Event section, you can add

Code: [Select]
case(EV_GET_ITEM){
      //statements;
}

and you can add sound effects in there since it will run every time the player gets an item

So I would need to have a custom player first, then?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 15, 2019, 05:31:24 AM
Either a custom player or a custom item script. It depends on context which is more appropriate; if you want the sound to play when a player would collect some kind of item that way regardless of what script you're playing then you would modify a player script, but it you wanted the sound to play specifically on when a certain kind of item is collected regardless of player then you'd write an item script.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: tsunami3000 on April 15, 2019, 10:05:31 AM
Alright, I understand, I need an item script then. Thanks to you two, Drake and Twizzy!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tad Marx Barba on April 16, 2019, 03:32:02 AM
My player script go through a lag that freeze a few seconds Danmakufu and then, render a shield around the player (instead of using TMagicCircle()).

And when the player dies and keep pressing the shot button, this error happens:
https://ibb.co/GsgyB0C (https://ibb.co/GsgyB0C)

What can I do in these cases?

Player link: https://1drv.ms/u/s!AgwNeb6oBlvsgd9U5gYLfol-acAwmA (https://1drv.ms/u/s!AgwNeb6oBlvsgd9U5gYLfol-acAwmA)
I've noticed that I put this post outside of this thread, my apologies  :P

I've removed your other thread, thanks for noticing and posting in the correct thread --Hele

Someone, help me :'(
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on April 16, 2019, 07:45:59 AM
I don't get any lag. However in your Shield task you do ascent(i in 0..65){ ObjRender_SetScaleXYZ(ielD, sc, sc, 0); } which just does the same thing 65 times.

As for the second thing, I've identified that what's happening is that you are calling CreatePlayerShotA1 in VaniBulletA1 and then are immediately checking its coordinates to set mx and my. This should be fine assuming that CreatePlayerShotA1 actually returns a valid object, but in this case it does not. In fact, it doesn't even return ID_INVALID (-1); it looks like if player shots are forbidden, CreatePlayerShotA1 doesn't return anything, which means the variable ParentShot isn't set to anything at all, leading to errors. That's mkm's mistake.

There's more to this though. When do you forbid player shots? On EV_PLAYER_SHOOTDOWN. Now you would think that VaniBulletA1 shouldn't be run if the player is dead, but that isn't the case; you check Obj_IsDeleted(ID), which is not a check for the player being dead. On top of this, even though your options get deleted when the player is supposed to die, your loop for this is:

Code: [Select]
while(!Obj_IsDeleted(Option)){
  if(!yetAlive){
    Obj_Delete(Option);
  }
  // stuff being run
  yield;
}

So what's happening is that the player gets shot down, yetAlive is set to false in the event, this loop resumes, the option object still exists so it runs the loop, deletes the option because yetAlive is false, then still runs whatever was in the body of the loop, including your player shot logic. So even though the player is dead and shots are forbidden, VaniBulletA1 runs anyway and the above error happens.

There are a couple main things to fix; one is that when you delete your Option object you should end the task immediately with return or do something similar. The other is that even if you changed your condition for player shots to check if the player has died, the error will still occur if the player is ever alive and shots are forbidden. So the condition to shoot should include IsPermitPlayerShot() somewhere.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: tsunami3000 on April 16, 2019, 11:37:10 PM
How could I find the x and y position where a laser collides with the edges of the screen? I want to spawn some bullets on that point, but I can't figure out a way to obtain the coordinates...
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on April 17, 2019, 02:42:55 AM
How could I find the x and y position where a laser collides with the edges of the screen? I want to spawn some bullets on that point, but I can't figure out a way to obtain the coordinates...

Given a laser's starting point and angle, you're trying to find the laser's intersection with one of the edges with the screen. For each edge, you can obtain the perpendicular distance to the edge from the laser's origin using the x/y coordinates of the respective edge and the laser's origin. Then using trigonometry, you can determine the missing coordinate.

For example, the left side of the STG_Frame and the laser being spawned at (64, 128) at 120 degrees. The laser, the edge, and the perpendicular line from the laser origin to the edge form a right triangle, where the angle between the perpendicular line and the laser is 60 degrees. Using the definition of the tangent, we get that tan(60) = opp/adj where adj = 64. Therefore, opp = 64*tan(60) = 110.85. Adding the initial height of 128, we get 238.85.

Therefore, the laser meets the edge at (0, 238.85).

A similar method can be applied for the other edges.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: tsunami3000 on April 17, 2019, 01:16:12 PM
Given a laser's starting point and angle, you're trying to find the laser's intersection with one of the edges with the screen. For each edge, you can obtain the perpendicular distance to the edge from the laser's origin using the x/y coordinates of the respective edge and the laser's origin. Then using trigonometry, you can determine the missing coordinate.

For example, the left side of the STG_Frame and the laser being spawned at (64, 128) at 120 degrees. The laser, the edge, and the perpendicular line from the laser origin to the edge form a right triangle, where the angle between the perpendicular line and the laser is 60 degrees. Using the definition of the tangent, we get that tan(60) = opp/adj where adj = 64. Therefore, opp = 64*tan(60) = 110.85. Adding the initial height of 128, we get 238.85.

Therefore, the laser meets the edge at (0, 238.85).

A similar method can be applied for the other edges.

Thanks, it worked great!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on April 23, 2019, 10:00:55 AM
Hi, doesn't really know if someone actually asked this but how to make a boss move towards the player in a set amount of time ? I've been testing all the time and it wasn't working for me.

Side request, how can I create a laser pillar ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on April 23, 2019, 12:56:29 PM
Hi, doesn't really know if someone actually asked this but how to make a boss move towards the player in a set amount of time ? I've been testing all the time and it wasn't working for me.
Depends on whether or not you want the boss to constantly adapt to the player's position or move to the location of the player at a certain time (regardless of where the player moves afterwards). Regardless, this stuff is in the tutorials. Refer to https://sparen.github.io/ph3tutorials/docs_object.html#sub14 for some hints.

Side request, how can I create a laser pillar ?
What do you mean by a 'laser pillar'? If you mean a Straight Laser, then there are functions to create those. Otherwise, you'll need to be more specific as to what you are trying to create.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on April 23, 2019, 01:38:46 PM
What are the main differences between LoadScript() and LoadScriptInThread()?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on April 23, 2019, 03:04:04 PM
Well apparently I left out the GetPlayerX and Y, no wonder I can't get it right... At least I successfully did it. Thank you so much !

About the laser side request, I want to try to script this in a straight and simple way and not by tasking it one by one.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on April 23, 2019, 03:33:42 PM
Well apparently I left out the GetPlayerX and Y, no wonder I can get it right... At least I successfully did it. Thank you so much !

About the laser side request, I want to try to script this in a straight and simple way and not by tasking it one by one.

If that's what you mean, I'll note the following:
- You can use ascent loops
- For even spacing, given 8 lasers for example, there are SEVEN spaces in between, so they are spaced GetStgFrameWidth/7 pixels apart
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on April 30, 2019, 03:52:01 PM
Hi again, I was wondering how to let all/specified bullets stop on a certain time like Cirno in Perfect Freeze ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 01, 2019, 02:49:34 AM
Hi again, I was wondering how to let all/specified bullets stop on a certain time like Cirno in Perfect Freeze ?

GetShotIdInCircleA1 and GetShotIdInCircleA2 may be helpful for obtaining all bullet IDs in a certain radius. The rest is looping through and setting speed/assigning tasks, etc.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 01, 2019, 07:35:24 AM
I think the best way to approach this is to use a timer or flag variable that sits outside the scope of the task for the bullets and controls them all. That way you only need one.

Code: [Select]
task freeze(){
  let flag = 0;
  loop(180){
    task bullet(){
      // make bullet
      while(!flag){ yield; }
      // freeze
    }
    bullet();
    yield;
  }
  loop(60){yield;}
  flag = true;
}

Something like this?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on May 01, 2019, 11:01:23 AM
So I try to experiment the code but it always gives out this error after a few seconds
A variable was changing it's value type. (File Line : 102)
And it always lagging for the whole period and the error appeared .
How can I fix it ?  ???
https://pastebin.com/BpJff2d6
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 01, 2019, 05:20:35 PM
So I try to experiment the code but it always gives out this error after a few seconds
A variable was changing it's value type. (File Line : 102)
And it always lagging for the whole period and the error appeared .
How can I fix it ?  ???
https://pastebin.com/BpJff2d6

You define flag as an integer 0 and then try to set it to a boolean True. Stick with one or the other.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on May 02, 2019, 11:23:34 AM
For the functions LoadScript() and LoadTexture(), compared to LoadScriptInThread() and LoadTextureInLoadThread(), what are the differences?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tad Marx Barba on May 05, 2019, 06:01:25 PM
Can you help me? My system has a problem...

When the player reach to a certain nonspell, and a certain percentage of vitality comes down, the boss's steps and difficulty indicator are deleted for no apparent reason...
Demo: DANMAKUFU] System Test 01 (https://www.youtube.com/watch?v=pgdkqrREpcY)

Link to my System: OneDrive (https://1drv.ms/u/s!AgwNeb6oBlvsgeEzonrIhmx4CEwoRA)

(By the way, I forgot to thank Drake for help me in my player script  :P)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tad Marx Barba on May 09, 2019, 12:46:54 AM
Can you help me? My system has a problem...

When the player reach to a certain nonspell, and a certain percentage of vitality comes down, the boss's steps and difficulty indicator are deleted for no apparent reason...
I forgot delete
Code: [Select]
Obj_Delete(obj) from my Fade In task, my apologies  :V
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: tsunami3000 on May 09, 2019, 06:19:47 PM
I've been trying to learn how the user-defined item data works by checking how other users' projects. I get the idea due to how similar the code is to custom shots scripts, but I can't figure out what the "out" part is. I know it seems to define an area in the graphics image used for the item (just like "rect"), but I don't know what it is for.

Code: [Select]
ItemData{ id = 2 type = 2 rect = (192, 0, 208, 16) out = ( 194, 14, 205, 25) render = ALPHA }
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 09, 2019, 08:49:30 PM
When a normally-behaving item goes above the top of the screen there's a graphic shown that tells you the item is dropping there; in Touhou games it's a small triangular arrow. The `out` rect is for that graphic.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on May 10, 2019, 01:05:09 PM
How do non-piercing lasers for player scripts calculate their lengths to the target?
My only idea so far is to perform something like ray tracing every frame, but is there a more elegant solution?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: tsunami3000 on May 10, 2019, 01:32:05 PM
When a normally-behaving item goes above the top of the screen there's a graphic shown that tells you the item is dropping there; in Touhou games it's a small triangular arrow. The `out` rect is for that graphic.

Gosh, it's so obvious now that you explained it. Thanks!
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MakiBlank on May 16, 2019, 10:17:38 AM
So I'm new to danmakufu and touhou in general and I've been trying to recreate Border of Wave and Particle. I have this current code setup:
Code: [Select]
task BoWaP{
if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0) {return;}
    let angleT = rand(0, 360);
    let objcount = 0;
    loop{
        loop(5){
            let obj = CreateShotA1(ObjMove_GetX(bossObj), ObjMove_GetY(bossObj), 3, angleT, 52, 5);
            angleT += 360/5;
        }
        angleT += sin(objcount) * cos(objcount) * 12;
        objcount++;
        yield;
    }
}
When I run the code through the game it appears to stack the different patterns that the bullets are producing. Is there anything I have done wrong in the code that causes this?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Gregory on May 17, 2019, 05:56:17 AM
So I'm new to danmakufu and touhou in general and I've been trying to recreate Border of Wave and Particle. I have this current code setup:
Code: [Select]
task BoWaP{
if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0) {return;}
    let angleT = rand(0, 360);
    let objcount = 0;
    loop{
        loop(5){
            let obj = CreateShotA1(ObjMove_GetX(bossObj), ObjMove_GetY(bossObj), 3, angleT, 52, 5);
            angleT += 360/5;
        }
        angleT += sin(objcount) * cos(objcount) * 12;
        objcount++;
        yield;
    }
}
When I run the code through the game it appears to stack the different patterns that the bullets are producing. Is there anything I have done wrong in the code that causes this?

Did you loop the BoWaP task again ? Because it worked fine on me
https://imgur.com/a/V5s2X3l (https://imgur.com/a/V5s2X3l)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MakiBlank on May 17, 2019, 06:45:39 AM
I dont think so, but here's my mainloop if it helps with the problem
Code: [Select]
@MainLoop{
    ObjEnemy_SetIntersectionCircleToShot(bossObj, ObjMove_GetX(bossObj), ObjMove_GetY(bossObj), 32);
    ObjEnemy_SetIntersectionCircleToPlayer(bossObj, ObjMove_GetX(bossObj), ObjMove_GetY(bossObj), 24);
if (count == 0) {
ObjMove_SetDestAtFrame(bossObj, GetCenterX(), 112, 60);
}
if(count % 30 == 0 && count >= 0){
BoWaP;
}
count++;
    yield;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 17, 2019, 06:47:41 AM
This is starting an instance of the BoWaP task every 30 frames, so yes, it's going to keep overlapping the whole thing over and over.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MakiBlank on May 17, 2019, 07:11:49 AM
I just realized this. Fixed now!
I'm still pretty new to coding in general, so I sometimes forget what certain things do :P
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on May 17, 2019, 11:47:08 AM
I was making the bullets to spawn bullets, it works, but the bullets also appeared on the top left of the screen.
How can I overcome this situation ?
https://pastebin.com/R82cpE05
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on May 17, 2019, 03:55:47 PM
I was making the bullets to spawn bullets, it works, but the bullets also appeared on the top left of the screen.
How can I overcome this situation ?
https://pastebin.com/R82cpE05

I haven't taken a look at your code yet but I'm 100% sure it's because you're spawning bullets without checking if the parent bullet still exists.

Only spawn bullets from the parent if the parent has not been deleted.

More information: https://sparen.github.io/ph3tutorials/ph3u2l16.html
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on May 18, 2019, 02:20:14 AM
I was making the bullets to spawn bullets, it works, but the bullets also appeared on the top left of the screen.
How can I overcome this situation ?
https://pastebin.com/R82cpE05

Line 118:
let b = CreateShotA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, obj, 318 , 7);
I suppose that instead of obj it's ObjMove_GetAngle(obj)

also Sparen is correct, you should make sure that it only shoots while the obj isn't deleted, like this code
Code: [Select]
while(!Obj_IsDeleted(obj)){
      //code here;
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tad Marx Barba on May 18, 2019, 11:40:50 PM
Guys, Hello there.
How do I randomize 21 shoot tasks?

I've these bunch of code for my 21 shooting task, but I've no idea how to do that...  ???
Link to my code: Pastebin (https://pastebin.com/TkGM1AjR)

Please, help me  :3
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 19, 2019, 03:01:07 AM
You would generate a random number and then pick based on that using a switch or a bunch of if-elses.
Code: [Select]
function rand_int(min, max){
  return floor(rand(min, max));
}

alternative(rand_int(0, 22))
case(0){
  RING_1();
  wait(32 * 7 + 60);
}case(1){
  RING_2();
  wait(32 * 13);
}case(2){
// ...
}case(21){
  Octo_Fist(fr);
  wait(fr + 1340);
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tad Marx Barba on May 19, 2019, 03:48:54 AM
You would generate a random number and then pick based on that using a switch or a bunch of if-elses.
Thanks Drake! It works!  :3 :D
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: kodaikyatto on May 25, 2019, 09:03:39 PM
Hi! I doubt I'll get a response, but I thought it was worth a shot
I'm new to Danmakufu stuff, and I wanna ask a couple questions:
How do I make it so the spellcard activates when the health is down to a certain point, like in Touhou?
How do I make more lives for the boss?
How do I create dialogue?
Sorry for 3 questions, but I'm just a baby to this stuff and I thought this would be the correct place to ask.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Tad Marx Barba on May 26, 2019, 05:31:37 AM
How to do a difficulty selector for plurals? Can you explain me? I want to do that with pictures instead of using only text ::)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on May 26, 2019, 08:59:20 AM
Hi! I doubt I'll get a response, but I thought it was worth a shot
I'm new to Danmakufu stuff, and I wanna ask a couple questions:
How do I make it so the spellcard activates when the health is down to a certain point, like in Touhou?
How do I make more lives for the boss?
How do I create dialogue?
Sorry for 3 questions, but I'm just a baby to this stuff and I thought this would be the correct place to ask.
Almost all your questions are covered in tutorials. Detailed written tutorials: https://sparen.github.io/ph3tutorials/ph3tutorials.html  and video tutorials: https://www.shrinemaiden.org/forum/index.php?topic=2852.0

Highly suggesting to start with those, especially since you said you're a baby to this.



How to do a difficulty selector for plurals? Can you explain me? I want to do that with pictures instead of using only text ::)
Depends on what your ultimate goal is. If it is just difficulty selection for plural (or single boss fight), then use:
- effect objects to spawn pictures
- use the virtual keys to move between the options
- set the difficulty based on the selection using commondata or your desired way

You can hold off your boss fight with a dummy attack/spell and launch the attacks once the difficulty has been set.

Usually difficulty selection menus are used in combination with full games. Which uses package scripts. Not sure how experienced you are with creating menu systems.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 27, 2019, 05:02:01 AM
You actually don't even need a dummy attack, just don't start (register) the boss scene or whatever else until the difficulty is selected.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on May 27, 2019, 02:35:52 PM
Thanks for the suggestions, it's working well so far.
And yes I eat codes sometimes mostly for testing but I can't get this working correctly

task BExplode(obj){
    wait(50);
   let angle = rand(0,360);
    loop(15){
   if(Obj_IsDeleted(obj)){return;}
       ascent(i in -1..4){
        ascent(j in 0..3){
            let objB = CreateShotA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 3 - j/6, angle + i*3, 320, 5);
         Gravity(objB);
        }
    }
      ObjShot_SetDeleteFrame(obj, 5);
      angle += 360/15;
   }
}

task Gravity(objB){
    wait(50);
   Choosing(objB);
}

task Choosing(objB){
    alternative(rand_int(0, 1))
    case(0){
    ObjMove_SetAngularVelocity(objB,-0.5);
    }
   case(1){
    ObjMove_SetAngularVelocity(objB,0.5);
    }
}

But the rings never set the velocity to 0.5, any ideas ?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on May 28, 2019, 02:09:21 AM
If you're using the rand_int function I wrote above, the maximum is exclusive. If you want to pick either 0 or 1 you need rand_int(0, 2).
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: R. P. Genocraft on June 15, 2019, 09:04:53 PM
Is it normal for ObjMove_SetPosition to not work on the player object? If so, is there an alternative that works?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on June 16, 2019, 12:25:17 AM
It should work. If it doesn't there's something else going on.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Kinedyme on June 24, 2019, 10:12:35 PM
Is there a way to get the number of tasks currently running within a script?

I know that a value is displayed in the log window, but it would be great if I was able to capture that value at a specified point in my code.

Thanks in advance
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: PyuDi on July 06, 2019, 07:54:47 AM
Code: [Select]
if (frame%60==0)
{
   let obj = ShotA(1); //ShotA is any createshot
}
ObjMove_SetX(obj, 0); //error: obj is not defined

And this throws an error. How can I use an variable out of its {}?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on July 06, 2019, 08:21:51 AM
Code: [Select]
if (frame%60==0)
{
   let obj = ShotA(1); //ShotA is any createshot
}
ObjMove_SetX(obj, 0); //error: obj is not defined

And this throws an error. How can I use an variable out of its {}?
Please post code along with the error because we don't know how you exactly programmed this.

I assume this is inside the @MainLoop? Then you should define the variable globally.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: PyuDi on July 06, 2019, 08:38:56 AM
code: https://pastebin.com/Yx1NdbdJ (look for  if (frame%30==0) )

-> How can I use an variable out of its declared {}?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 06, 2019, 01:45:16 PM
code: https://pastebin.com/Yx1NdbdJ (look for  if (frame%30==0) )

-> How can I use an variable out of its declared {}?

Your code is as follows:
Code: [Select]
    loop(8)
            {
                let obj = CreateShotA1(rand(0,fx), 0, rand(1,3), 90+rand(-5,5), DS_BALL_BS_GREEN, 20);
            }
            ObjMove_SetAngle(obj, -90);  // obj is not defined
Your aim is to create eight objects and then set their angle immediately. Therefore, you can do the following:
Code: [Select]
    loop(8)
            {
                let obj = CreateShotA1(rand(0,fx), 0, rand(1,3), 90+rand(-5,5), DS_BALL_BS_GREEN, 20);
                ObjMove_SetAngle(obj, -90);  // obj is not defined
            }
           

Understanding scoping rules is important, but understanding why they exist is also important. I'd take a look at your old code and think about why what you originally wrote would cause problems IF the variables could be accessed from outside of the block. For example, how many of the objects would actually have their speed set?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lapis Lazuli on July 29, 2019, 01:35:27 AM
EDIT: never mind, I found out how to make this work! still, thank you!

heya!!
So uhm, I've been trying to make a danmakufu script and I wanted to make an attack that creates cheeto lasers (you know, the kind of homing curvy laser that Shinki used in her boss fight that made her infamous?). However, I can't get the algorithm that decides whether or not the laser should turn left or right to work properly, and it often flees from the player instead of chasing them like you'd expect. I've looked into a bunch of other scripts that use cheeto lasers (such as a lot of stuff from SCC, or some of Kiyohime's attacks in RSS) and, frankly, I can't parse them. Can someone else help me?

Here's the code and a .gif of a laser that spawned in the middle of the screen, so you can get a good idea of what I'm trying to do. (be warned, it's kind of messy)

Code: [Select]
task summonWolf(wx, wy)
{
    let wa = atan2(GetPlayerY - wy, GetPlayerX - wx);
    let ws = 6;
   
    let wolf = CreateCurveLaserA1(wx, wy, ws, wa, 60, 30, DS_SCALE_WHITE, 0);
    let wolf2 = CreateCurveLaserA1(wx, wy, ws, wa, 60, 30, DS_NEEDLE_WHITE, 0);
    ObjCrLaser_SetTipDecrement(wolf, 0);
    ObjCrLaser_SetTipDecrement(wolf2, 0);
    let accel = 0.07;
    let wvelo = 2;
    ascent (i in 0..10)
    {
        ObjMove_AddPatternA2(wolf, 0 + 120 * i, NO_CHANGE, NO_CHANGE, -accel, 0, -1000);
        ObjMove_AddPatternA2(wolf2, 0 + 120 * i, NO_CHANGE, NO_CHANGE, -accel, 0, -1000);
        ObjMove_AddPatternA2(wolf, 60 + 120 * i, NO_CHANGE, NO_CHANGE, accel, 0, 1000);
        ObjMove_AddPatternA2(wolf2, 60 + 120 * i, NO_CHANGE, NO_CHANGE, accel, 0, 1000);
    }
    //let objText = ObjText_Create();
    //ObjText_SetText(objText, "--> Russell Square Regular <--");
    loop(720)
    {
        let lx = ObjMove_GetX(wolf);
        let ly = ObjMove_GetY(wolf);
        let la = ObjMove_GetAngle(wolf) % 360;
        let la2 = atan2(GetPlayerY - ly, GetPlayerX - lx);
        //ObjText_SetText(objText, la2 - la);
       
        if (la < la2)
        {
            ObjMove_SetAngularVelocity(wolf, wvelo);
            ObjMove_SetAngularVelocity(wolf2, wvelo);
        }
        else
        {
            ObjMove_SetAngularVelocity(wolf, -wvelo);
            ObjMove_SetAngularVelocity(wolf2, -wvelo);
        }
       
        yield;
    }
}

https://cdn.discordapp.com/attachments/436365025339506720/605173240574509077/danmakufu.gif (im sorry, i haven't figured out how to attach it directly as an image! let me know if youre not able to view the link)

thank you!!  :D
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: HumanReploidJP on July 30, 2019, 01:05:58 AM
I have something I didn't know:

You know the one where (2 or 10) bullets are orbiting around the boss or an another bullet, which I saw in most dnh scripts.
Can you explain how  in a way, and give an example code (must be a shot function ObjMove_AddPatternB2).

Let me know.  :)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lapis Lazuli on July 30, 2019, 06:41:31 PM
So, I don't exactly have the spoons to explain how you would do that with ObjMove_AddPatternB2 ALL IN ONE MESSAGE, though I will say that it would likely be much easier to do this by just manually setting the X and Y positions of the bullets. But IDK. We're going to set this up by making a simple pattern where, every 5 seconds, ten bullets are summoned around the boss, will orbit around said boss, and then fire out radially- or at least, how I would do it using ObjMove_AddPatternB2.

Quick warning that this will require not only knowledge of trigonometry, as you would expect, but ALSO calculus. Fortunately, the calculus part isn't THAT difficult to understand, hopefully, so even if you haven't taken a calculus class don't worry too much about it.

The first thing you'd want to do is set some kind of distance variable, for example 100. You're also gonna want to set some starting angle, and maybe make an array of ten (X, Y) points, all around the boss, using some ascent loops and trigonometry. I trust that this is something you're able to do on your own.

Now, one of the first things you'll want to do is make sure to... in a way, rig the bullets such that, no matter what, they are always the same distance from the boss. For the sake of our example, we're gonna have a loop set to run every 300 frames, and each frame it will update the position of all of the bullets. You'll do this with another ascent loop, by getting the angle from each player to the boss. You're gonna want to hold onto this array of angles, it will be helpful later. But then, with this angle, you'll set the position of each of the ten bullets to be equal to (dist * cos(angle) + ObjMove_GetX(objBoss), dist * sin(angle) + ObjMove_GetY(objBoss). Then, you might set it such that this only happens when a certain boolean is true, but you might be able to get around that. I hope you're understanding so far?

Now... for this next part, you're gonna need a bit of calculus. Remember that array of angles from the previous paragraph? Yeah, you need to hold onto them because at each timestep, you're going to want to use ObjMove_AddPatternB2 on each of these bullets, setting the X speed to be equal to dist * sin(angle), and the y speed to be dist * cos(angle). You might be thinking that I've mixed up the sines and cosines here, but in fact, I haven't. We're not using trigonometry to set POSITION, we're using it to set VELOCITY, which means we have to set the X and Y speeds to be equal to the DERIVATIVE of the X and Y positions, which is the X and Y velocities. And, in short...

d/dx(sin(x)) = cos(x), and

d/dx(cos(x)) = sin(x).

This will make it so that the X and Y positions of every bullet will follow a circle. (note: technically, the only reason we need to rig the distance of the bullets is because of the fact that we're doing this on a computer and not in real life, so every differential equation can only be so accurate since they're going in timesteps. It's complicated, but think of it as the bullets being a bit drunk and sorta stepping off the straight line path, so we need to keep them oriented.)

Fortunately, though, this should be aboooout all you'd need to do. I'm gonna post an example of actual code for this in the next post, so give me a moment. In the meantime, feel free to correct or verify anything here if you notice something wrong! ^u^
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lapis Lazuli on July 31, 2019, 12:37:21 AM
Okay, so I found a way to make this work that doesn't use ObjMove_AddPatternB2. Lemme copy and paste it down here.

Code: [Select]
task fire(angle, dir)
{
if(ObjEnemy_GetInfo(objBoss, INFO_LIFE) <= 0){return;}

let dist = 100;
let bulNum = 10;
let time = 240;

let bx = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let by = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let bul = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let ang = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
ascent(i in 0..bulNum)
{
ang[i] = angle + dir * i * 360/bulNum;
bx[i] = dist * cos(ang[i]) + ObjMove_GetX(objBoss);
by[i] = dist * sin(ang[i]) + ObjMove_GetY(objBoss);
bul[i] = CreateShotA1(bx[i], by[i], 2, ang[i], DS_BALL_M_BLUE, 20);
}

loop(time)
{
ascent(i in 0..bulNum)
{
ang[i] = ang[i] + 2 * PHI;
ObjMove_SetPosition(bul[i], dist * cos(ang[i]) + ObjMove_GetX(objBoss), dist * sin(ang[i]) + ObjMove_GetY(objBoss));
ObjMove_SetAngle(bul[i], ang[i]);
}

yield;
}
}

Again, since you said it needed to use ObjMove_AddPatternB2, I can still create a solution that uses it, but I personally think this seems a lot more elegant, and is sort of just how i naturally ended up making the spell. Plus, ObjMove_AddPatternB2 versions of the pattern have the caveat that they need to stay still unless you add the X and Y speed components to the rotating bullets as a vector, which is... I don't even want to get into that. This just seems like a lot less work, but if it's not acceptable for your purposes, let me know.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on July 31, 2019, 02:20:53 PM
If you really just want objects to move relative to another object, you can just keep track of that other object.

e.g. rotate about the boss.

Given n objects rotating:

Code: [Select]
ascent(i in 0..n) {
    CreateRotatingObj(objBoss, i, n, r);
}

task CreateRotatingObj(parent, ID, numinring, radius) {
    let offset = ID * 360/numinring;
    let obj = CreateShotA1(ObjMove_GetX(parent) + radius*cos(offset), ObjMove_GetY(parent) + radius*sin(offset), 0, 0, 0, 0);
    let objcount = 0;
    while(!Obj_IsDeleted(parent)) {
        ObjMove_SetX(obj, ObjMove_GetX(parent) + radius*cos(offset + objcount);
        ObjMove_SetY(obj, ObjMove_GetY(parent) + radius*sin(offset + objcount);
        objcount += 1;
        yield;
    }
    Obj_Delete(obj);
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Lapis Lazuli on August 11, 2019, 02:32:20 AM
Hey, can someone help me?
I've got a bunch of single scripts for a Momiji boss fight, but I'm having trouble stitching them together into a plural script. All eight of the singles work perfectly as intended, but when I run them all as a plural, the game just crashes on me, without even giving so much grace as an error message. Can someone help me find out what's going on?

Here's the code:

Code: [Select]
#TouhouDanmakufu[Plural]
#ScriptVersion[3]
#Title["Momiji Fight"]
#Text["for kiiro"]
@Event
{

}
@Initialize
{
    TPlural;
}
@MainLoop
{
    yield;
}

task TPlural
{
    let dir = GetCurrentScriptDirectory();
    let obj = ObjEnemyBossScene_Create();
    ObjEnemyBossScene_Add(obj, 0, dir ~ "momiji 1.txt");
    ObjEnemyBossScene_Add(obj, 0, dir ~ "momiji spell 1.txt");
    ObjEnemyBossScene_Add(obj, 1, dir ~ "momiji 2.txt");
    ObjEnemyBossScene_Add(obj, 1, dir ~ "momiji spell 2.txt");
    ObjEnemyBossScene_Add(obj, 2, dir ~ "momiji 3.txt");
    ObjEnemyBossScene_Add(obj, 2, dir ~ "momiji spell 3.txt");
    ObjEnemyBossScene_Add(obj, 3, dir ~ "momiji spell 4.txt");
    ObjEnemyBossScene_Add(obj, 4, dir ~ "momiji spell 5.txt");
    ObjEnemyBossScene_LoadInThread(obj);
    ObjEnemyBossScene_Regist(obj);
    while(!Obj_IsDeleted(obj)){
        yield;
    }
    CloseScript(GetOwnScriptID());
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on August 24, 2019, 03:26:18 PM
How to make a function so that the bullet is gradually increasing/decreasing the alpha ? Had no idea how it works, any help is appreciated.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: JDude :3 on August 24, 2019, 11:49:05 PM
How to make a function so that the bullet is gradually increasing/decreasing the alpha ? Had no idea how it works, any help is appreciated.

Code: [Select]
function upAlpha(obj, seconds){
ascent(i in 0..256){
ObjRender_SetAlpha(obj, i);
wait(60*seconds);
}
}

function wait(n){loop(n){yield;}}

Pretty simple, but it works with the time as a parameter: if you do upAlpha(obj, 1.5) the alpha will be increased each 1.5 seconds
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on September 21, 2019, 04:54:01 PM
Hey there! I was just wondering how to make a player shoot bullets. I'm trying to make a player script and I can't for the life of me figure out how to go about doing that. Does anyone have tips to start off doing that at least?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: theSlug on September 21, 2019, 09:05:21 PM
Hey there! I was just wondering how to make a player shoot bullets. I'm trying to make a player script and I can't for the life of me figure out how to go about doing that. Does anyone have tips to start off doing that at least?

I'm not very expirenced with ph3 in general, but for the player script I've made I've followed thesse steps:

The shot data (2) must be something like this:

Code: [Select]
shot_image = "./playershot.png" // image

ShotData {
id = 1
rect = (left,top,right,bottom)
render = ALPHA
alpha = x // 0-255
collision = y // radius of the hitbox
}

ShotData {
id = 2
...

the item (3) it's just store the path of the shotdata in a variable and load it in @initialize
Code: [Select]
let shots = dirCurrent ~ "player_shot.txt";
LoadPlayerShotData(shots);

Now you can use CreatePlayerShotA1 and it shoud work
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on September 25, 2019, 05:27:43 PM
Thank you for the advise! Quick question though do I implement it like this?

task TShoot(){
   CreatePlayerShotA1(GetPlayerX(), GetPlayerY(), 3, 2, 10, 10, 1);
}
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: theSlug on September 25, 2019, 07:53:08 PM
Thank you for the advise! Quick question though do I implement it like this?

task TShoot(){
   CreatePlayerShotA1(GetPlayerX(), GetPlayerY(), 3, 2, 10, 10, 1);
}

there are multiple ways to "call" a player shot (and that's really up to the scripter), but in this case, whenever you call TShoot the player should fire a bullet ( e.g if (VK_SHOT==KEY_HOLD){ TShoot() } )
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on November 15, 2019, 06:07:34 PM
Oh gosh it's been a while but I'm genuinely stumped right now
I was wondering if someone could look through the script and see where I'm going wrong because I'm genuinely unsure of what to do right now
It's still not working and I'm not really sure if I'm going about this the wrong way so feel free to look through it

Thank you for the help though! I appreciate every single advise/tip~



Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on November 16, 2019, 02:43:20 AM
Oh gosh it's been a while but I'm genuinely stumped right now
I was wondering if someone could look through the script and see where I'm going wrong because I'm genuinely unsure of what to do right now
It's still not working and I'm not really sure if I'm going about this the wrong way so feel free to look through it

Thank you for the help though! I appreciate every single advise/tip~

If you think something has gone wrong, tell us what isn't working. Is it a crash? An error? Something's not working the way you want it to?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on November 16, 2019, 02:55:58 AM
The player shots don't really appear :/
The sprite animation seems to be working just fine, it's just the shooting part that's not working

EDIT:

NVM my player shots seem to be working now! I just put in the wrong variable name in the player bullet script ^^;;
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on November 16, 2019, 08:47:57 AM
The player shots don't really appear :/
The sprite animation seems to be working just fine, it's just the shooting part that's not working

EDIT:

NVM my player shots seem to be working now! I just put in the wrong variable name in the player bullet script ^^;;
Ah, a classic mistake. Yea you got to love that strict variable name for the player bullet script :V I remember it took me several minutes of cursing when I had figured it out.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on November 18, 2019, 02:16:00 AM
Hello again!
So the rest of my player script is working fine now but I was just wondering how you would implement something like Reimu's yin-yang balls.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on November 19, 2019, 04:02:39 PM
You mean like a player bomb effect with yin yang balls?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on November 19, 2019, 08:40:39 PM
More like focus and unfocus shots! ^^ (but you know I wouldn't mind learning about that too  :3)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Helepolis on November 20, 2019, 04:22:25 PM
There are tutorials about that by both Sparen and me for making player scripts + spell bombs. Might want to check them out.

About the Yin yang orbs in focus/unfocus: Basically they are just effect objects around the player that fire the player bullet from that position.

Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on November 22, 2019, 11:37:12 PM
There are tutorials about that by both Sparen and me for making player scripts + spell bombs. Might want to check them out.

 :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V :V

...Not yet. It'll be a while before I get to Player Scripts.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: BananaCupcakey on November 30, 2019, 01:54:55 PM
Don't know how to explain this, but I'll try to make it as clear as possible.
1. How to script a trail of straight laser based on random boss movement (rand(n,n)) ? [attach=1]
2. What to script so that the boss can automatically detects and runs into the center of the bullet no matter what position the boss is (directly piercing it) and the bullet will react (like explode etc) [attach=2]
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on November 30, 2019, 03:28:59 PM
Don't know how to explain this, but I'll try to make it as clear as possible.
1. How to script a trail of straight laser based on random boss movement (rand(n,n)) ? [attach=1]
2. What to script so that the boss can automatically detects and runs into the center of the bullet no matter what position the boss is (directly piercing it) and the bullet will react (like explode etc) [attach=2]

1. Track the boss's position over two frames to determine its angle with atan2. Then fire a laser in the opposite direction
2. Store the object IDs of the bullets and use atan2 in order to determine the angle between the boss and the bullet. You can use object-object collision, or you can see if a given object is in a radius of another in order to determine when to react.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MugenCC on January 05, 2020, 01:59:32 AM
I'm having problems rendering transparent images. A grey always appears at the edge of the pictures. Just look at this screenshot.
(https://i.imgur.com/RbzvfKp.png)
The mandala in the middle is a purely black transparent image put on top of the rest of the background, but where opaque meets transparent, the grey appears.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on January 05, 2020, 02:49:29 PM
I'm having problems rendering transparent images. A grey always appears at the edge of the pictures. Just look at this screenshot.
(https://i.imgur.com/RbzvfKp.png)
The mandala in the middle is a purely black transparent image put on top of the rest of the background, but where opaque meets transparent, the grey appears.

Please provide your code so that we can see your render priorities and blend types. Also provide the raw images so that we can see if there are any notable assumptions that were made when writing the code.
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: MugenCC on January 05, 2020, 04:49:01 PM
Please provide your code so that we can see your render priorities and blend types. Also provide the raw images so that we can see if there are any notable assumptions that were made when writing the code.
Code: [Select]
        //The object containing the mandala
let BG = ObjPrim_Create(OBJ_SPRITE_LIST_2D);
ObjPrim_SetTexture(BG,current ~ "BG_Pattern.png");
Obj_SetRenderPriorityI(BG,3);

let BG_Glow = ObjPrim_Create(OBJ_SPRITE_LIST_2D);
ObjPrim_SetTexture(BG_Glow,current ~ "BG_Pattern.png");
Obj_SetRenderPriorityI(BG_Glow,3);
ObjRender_SetBlendType(BG_Glow,BLEND_ADD_RGB);

let BGangle = rand(0,45);
let BGphase = rand(0,360);
let BGalpha = 0;

yield;
Intro;

while(bSpell){
ObjSpriteList2D_ClearVertexCount(BG);

ObjSpriteList2D_SetSourceRect(BG,0,0,800,600);
ObjSpriteList2D_SetDestRect(BG,-320,-240,320,240);
ObjRender_SetAlpha(BG,255*BGalpha);
ObjRender_SetAngleZ(BG,0);
ObjRender_SetColor(BG,255,255,255);
ObjRender_SetPosition(BG,320,240,0);
ObjSpriteList2D_AddVertex(BG);
ObjSpriteList2D_SetSourceRect(BG,800,0,1600,600);
ObjSpriteList2D_SetDestRect(BG,-320,-240,320,240);
ObjRender_SetAlpha(BG,255*sin(BGphase/2)^2*BGalpha);
ObjRender_SetPosition(BG,320,240,0);
ObjSpriteList2D_AddVertex(BG);

//Creating the mandala
ObjSpriteList2D_SetSourceRect(BG,853,601,1278,1026);
ObjSpriteList2D_SetDestRect(BG,-213*0.8,-213*0.8,213*0.8,213*0.8);
ObjRender_SetAlpha(BG,255*BGalpha);
ObjRender_SetAngleZ(BG,BGangle);
ObjRender_SetPosition(BG,320,240,0);
ObjSpriteList2D_AddVertex(BG);

ObjSpriteList2D_CloseVertex(BG);
(https://i.imgur.com/1IpDkN3.png)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Drake on January 05, 2020, 10:40:45 PM
Ok so this was a lot more complicated looking at than it had to be because what you provided does not match your previous picture, and is very hard to parse because of how you've set it up as a sprite list. I would recommend against using a sprite list here as you barely seem to be reusing any properties and the background pieces are clearly distinct objects.

The core of the matter is that you're alpha blending the black transparent image but are also resizing it. When the resizing happens you're at the mercy of the scaling algorithm, which in this case works against you. Danmakufu is technically at fault here but you should avoid scenarios like this. You have two good options:
- Resize the image ahead of time (ok if the image is always rendered at full size)
- Invert the image to be white instead and use subtract-blend rendering

Here is an example of what you get with the subtract-blend setup (background then mandala then glowy part):

(https://i.imgur.com/Kcgy7tX.png)
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Dire29 on February 22, 2020, 02:02:58 AM
Hello! So I got back into doing Danmakufu again and I'm almost there with implementing something like Reimu's Yin Yang balls. I managed to have them move into a different position when I press the shift key but they teleport instead:
Code: [Select]
if(GetVirtualKeyState(VK_SLOWMOVE)==KEY_PUSH || GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD){
ObjRender_SetPosition(extrashot, GetPlayerX-10, GetPlayerY-30, 3);
ObjRender_SetPosition(extrashot2, GetPlayerX+10, GetPlayerY-30, 3);

}
else{
ObjRender_SetPosition(extrashot, GetPlayerX-30, GetPlayerY-30, 3);
ObjRender_SetPosition(extrashot2, GetPlayerX+30, GetPlayerY-30, 3);
}

I know it's because of the SetPosition thing but I'm not sure how to make them NOT teleport. I've tried ObjMove_SetDestAtFrame and other things like that but it doesn't seem to do anything. Is there something else I can try?
Title: Re: ※ Danmakufu Q&A/Problem thread 3 ※
Post by: Sparen on February 22, 2020, 02:01:03 PM
Hello! So I got back into doing Danmakufu again and I'm almost there with implementing something like Reimu's Yin Yang balls. I managed to have them move into a different position when I press the shift key but they teleport instead:
Code: [Select]
if(GetVirtualKeyState(VK_SLOWMOVE)==KEY_PUSH || GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD){
ObjRender_SetPosition(extrashot, GetPlayerX-10, GetPlayerY-30, 3);
ObjRender_SetPosition(extrashot2, GetPlayerX+10, GetPlayerY-30, 3);

}
else{
ObjRender_SetPosition(extrashot, GetPlayerX-30, GetPlayerY-30, 3);
ObjRender_SetPosition(extrashot2, GetPlayerX+30, GetPlayerY-30, 3);
}

I know it's because of the SetPosition thing but I'm not sure how to make them NOT teleport. I've tried ObjMove_SetDestAtFrame and other things like that but it doesn't seem to do anything. Is there something else I can try?

I recommend putting their position into variables, and having a 'target'. If they aren't at the target, each frame move the positions closer to the target. The key thing is to do it over multiple frames, while updating the target relative to the player position.