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

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1740 on: April 05, 2019, 07:54:43 AM »
The keyword for the image file is shot_image. That might be the only thing wrong.

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1741 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
« Last Edit: April 09, 2019, 04:24:56 AM by Helepolis »

Drake

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

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1743 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
« Last Edit: April 09, 2019, 04:25:30 AM by Helepolis »

Drake

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

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

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

Drake

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

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 #1747 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

What can I do in these cases?

Player link: 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
« Last Edit: April 14, 2019, 07:33:54 AM by Helepolis »

tsunami3000

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

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

tsunami3000

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

Drake

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

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

tsunami3000

  • Touhou is cool i guess
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1752 on: April 15, 2019, 10:05:31 AM »
Alright, I understand, I need an item script then. Thanks to you two, Drake and Twizzy!
some day i'll finally beat UFO... some day

Tad Marx Barba

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

What can I do in these cases?

Player link: 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 :'(

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1754 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.
« Last Edit: April 16, 2019, 07:55:56 AM by Drake »

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

tsunami3000

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

Sparen

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

tsunami3000

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1758 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 ?
« Last Edit: April 23, 2019, 10:07:10 AM by BananaCupcakey »
Just keep it neutral :3

Sparen

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

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1760 on: April 23, 2019, 01:38:46 PM »
What are the main differences between LoadScript() and LoadScriptInThread()?

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1761 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.
« Last Edit: August 22, 2019, 03:28:27 PM by BananaCupcakey »
Just keep it neutral :3

Sparen

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

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

Sparen

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

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1765 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?
« Last Edit: May 01, 2019, 07:37:33 AM by Drake »

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

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

Sparen

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

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1768 on: May 02, 2019, 11:23:34 AM »
For the functions LoadScript() and LoadTexture(), compared to LoadScriptInThread() and LoadTextureInLoadThread(), what are the differences?

Tad Marx Barba

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

Link to my System: OneDrive

(By the way, I forgot to thank Drake for help me in my player script  :P)
« Last Edit: May 05, 2019, 06:04:29 PM by Tad Marx Barba »