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

Sparen

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #391 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
Lunatic 1CCs: PCB, IN, PoFV, HSiFS
Extra: All except PC-98.

Oh hey look I can do DNH scrips.

Sparen

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

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

Drake

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

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

Drake

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



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.
« Last Edit: November 14, 2016, 07:13:56 AM by Drake »

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

TheTeff007

  • Best Touhou 2015!
  • So much cuteness...!
    • Youtube Channel
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #396 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.
Small Teaser of my upcoming project~

No need to call me Teff007. Teff will do just as well~

FlareDragon

  • Gensokyo's Infernal Hellstorm
  • When will you come to Gensokyo, Satsuki Rin?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #397 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).
Normal 1CC's: SoEW, LLS, MS, EoSD, PCB, IN, PoFV, MoF, SA, UFO, GFW, TD, HM, DDC, ULiL, LoLK(PD), CtC |IaMP|
Hard 1CC's: EoSD, PCB, MoF, IN(B), TD, LoLK(PD), |???|
Lunatic 1CC's: None
Extra 1CC's: SoEW, MS, EoSD, PCB, IN, PoFV, MoF(NB), SA, UFO, GFW, TD, DDC, CtC, LoLK, |???|

Drake

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

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #399 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
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
Anyway, all my scripts have this issue...

Thanks to thoses who will look at this mess.



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

Lunatic 1CCs: PCB, IN, PoFV, HSiFS
Extra: All except PC-98.

Oh hey look I can do DNH scrips.

TheTeff007

  • Best Touhou 2015!
  • So much cuteness...!
    • Youtube Channel
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #401 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!
Small Teaser of my upcoming project~

No need to call me Teff007. Teff will do just as well~

ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #402 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.

Drake

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

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

ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #404 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.

Drake

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



pls test
« Last Edit: November 15, 2016, 12:01:55 PM by Drake »

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

ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #406 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.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #407 on: November 16, 2016, 02:58:33 AM »
Yeah no problem.

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

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

Drake

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

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

Junky

  • Just Another Scripter
  • *external screams*
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #410 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 
« Last Edit: November 26, 2016, 11:14:04 PM by Luigix1122 »
Anyone can be amazing at danmakufu. I believe in you! Push yourself to become the greatest!

(One day I'll become the greatest danmakufu scripter that there ever was.
...
...Got a LOOOOOOOOOOOOOOOOOONG way to go.)

Sparen

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

Drake

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

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

Junky

  • Just Another Scripter
  • *external screams*
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #413 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.
Anyone can be amazing at danmakufu. I believe in you! Push yourself to become the greatest!

(One day I'll become the greatest danmakufu scripter that there ever was.
...
...Got a LOOOOOOOOOOOOOOOOOONG way to go.)

Junky

  • Just Another Scripter
  • *external screams*
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #414 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?
Anyone can be amazing at danmakufu. I believe in you! Push yourself to become the greatest!

(One day I'll become the greatest danmakufu scripter that there ever was.
...
...Got a LOOOOOOOOOOOOOOOOOONG way to go.)

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #415 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!!
« Last Edit: November 27, 2016, 12:39:19 PM by Helepolis »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #416 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.
« Last Edit: November 27, 2016, 12:46:54 PM by Helepolis »

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #417 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? If so, I'll ensure that the examples are clearer.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #418 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!!
« Last Edit: November 27, 2016, 05:50:30 PM by ombsik33 »

Drake

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

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