Author Topic: ※ Danmakufu Q&A/Problem thread 3 ※  (Read 586545 times)

Tad Marx Barba

  • Mastermind Behind the Mirror
  • Struggling with my boring life =w=
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1770 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

tsunami3000

  • Touhou is cool i guess
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1771 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 }
some day i'll finally beat UFO... some day

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1772 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.

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

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1773 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?

tsunami3000

  • Touhou is cool i guess
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1774 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!
some day i'll finally beat UFO... some day

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1775 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?

Gregory

  • I draw stuffs
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1776 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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1777 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;
}

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1778 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.

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1779 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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1780 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
Just keep it neutral :3

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1781 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

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1782 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;
}
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Tad Marx Barba

  • Mastermind Behind the Mirror
  • Struggling with my boring life =w=
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1783 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

Please, help me  :3

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1784 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);
}

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

Tad Marx Barba

  • Mastermind Behind the Mirror
  • Struggling with my boring life =w=
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1785 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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1786 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.

Tad Marx Barba

  • Mastermind Behind the Mirror
  • Struggling with my boring life =w=
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1787 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 ::)

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1788 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.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1789 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.

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1790 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 ?
« Last Edit: May 27, 2019, 02:39:13 PM by BananaCupcakey »
Just keep it neutral :3

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1791 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).

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

R. P. Genocraft

  • Craftsman of absolute unpredictability
  • Boundary of productive and lazy
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1792 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?

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1793 on: June 16, 2019, 12:25:17 AM »
It should work. If it doesn't there's something else going on.

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

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1794 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

PyuDi

  • daily touhou~
  • danmakufu!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1795 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 {}?

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1796 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.

PyuDi

  • daily touhou~
  • danmakufu!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1797 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 {}?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1798 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?

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1799 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
« Last Edit: July 29, 2019, 09:25:14 PM by Lapis Lazuli »