Author Topic: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (locked)  (Read 268138 times)

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #930 on: December 26, 2013, 09:10:25 PM »
What is the code to split bullets?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #931 on: December 26, 2013, 10:24:41 PM »
What is the code to split bullets?
What exactly do you mean by 'split bullets'? Do you mean adding bullets to an existing bullet?

Example: Create a bullet and after 60 frames, make it turn right by 30 degrees. At that moment, make another bullet that turns left 30 degrees from the original angle.

Is this what you mean?

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #932 on: December 27, 2013, 05:42:00 AM »
I mean bullets which spawns another bullets and delete the old bullet. I know you can easily do it but what are you doing with this* chunk of code?

Code: [Select]
let i = 0;
while (i < length(bullets)){
if (Obj_IsDeleted(bullets[i])){
// The indexed shot has been deleted.  Remove it from the list
bullets = erase(bullets, i);

// The i-- here counters the i++ below.
// Since we're deleting the item at index i, the next element to check will
// now be at index i.
i--;
}
else
{
*the code itself*
}

         // When you're using this type of code, MAKE SURE that the loop variable is incrememted
         // properly, or the script will hang!!!
         i++;
}

Wouldn't you overwrite some variables?

PhantomSong

  • The Ghost Living through Everyday Life.
  • Eh, it doesn't matter.
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #933 on: December 27, 2013, 05:58:56 AM »
I mean bullets which spawns another bullets and delete the old bullet. I know you can easily do it but what are you doing with this* chunk of code?
Wouldn't you overwrite some variables?

Hmmm could you post , in http://pastebin.com the whole code? I'm not quite sure what's trying to happen.

and you your trying to say like a bullet shoots down, then turns into a ring/circle of bullets?

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #934 on: December 27, 2013, 06:08:02 AM »
It's an array of bullets. It checks if the bullet at each index is deleted, and if it isn't it runs some code. If it is deleted it removes the object id from the array.
Say the array is [a, b, c, d, e, f] where all the entries are object ids. Then the loop runs over each entry and does something. If the object at index 3 has been deleted, erase(bullets, 3) would return [a, b, c, e, f] and then the bullets array is set to this updated array.

This sort of structure really depends on what you intend to use it for. You wouldn't use something like this without some specific reason in mind.

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

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #935 on: December 27, 2013, 10:35:31 AM »
Hmmm could you post , in http://pastebin.com the whole code? I'm not quite sure what's trying to happen.

and you your trying to say like a bullet shoots down, then turns into a ring/circle of bullets?
I got it cleared. However, a new appeared. The bullets which will be spitted are spawned with CreateShotA2. However, of some reason they'll spawn already with their maximal speed insteat of the speed they should spawn. That's the full command: "CreateShotA2(ex, ey, 10, angle, 1/60, 0, DS_BILL_GREEN, 5);" They should spawn with a speed of 10 but they won't move. It also happens on a different number like 1, 20, etc. or with a low acceleration. Can someone explain me why?

ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #936 on: December 27, 2013, 10:45:26 AM »
"CreateShotA2(ex, ey, 10, angle, 1/60, 0, DS_BILL_GREEN, 5);"
The sixth parameter of the CreateShotA2 function is the min/max speed of the bullet. Since you set it to 0 and have a positive acceleration, the bullet's speed can never be greater than 0. I think that the problem here is that you're giving it a positive acceleration. If I'm correctly understanding what you're trying to do, then you would want -1/60 as your acceleration. That way, the bullets will slow down, instead of trying to speed up.

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #937 on: December 27, 2013, 11:20:35 AM »
Oh great, now the bullet move but it moves very fast. Even faster then the starting speed.

Edit: Fail, it worked. 10 is just very fast. :D
« Last Edit: December 27, 2013, 11:28:00 AM by MarioFanGamer659 »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #938 on: December 29, 2013, 11:54:48 AM »
Is there a specific requirement or set of requirements for EV_GAIN_SPELL  to trigger proper?

In my spell card I am calling EV_REQUEST_LIFE, TIMER and SPELL_SCORE. Assuming SCORE is the vital requirement, as Rumia samples have the same set up. However, the EV_GAIN_SPELL won't trigger in a background script which is running next to the plural. I am not using god mode, nor using bombs.

« Last Edit: December 29, 2013, 12:44:12 PM by Helepolis »

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #939 on: December 29, 2013, 02:04:23 PM »
So you don't see anything when you clear a script? Or is the spell score not being added to your total score? 

AddScore(ObjEnemyBossScene_GetInfo(objScene, INFO_SPELL_SCORE));  Throw this line inside of TGainSpell.

If nothing is happening at all then I don't know because everything works fine for me.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #940 on: December 29, 2013, 03:42:38 PM »
No, I was in general speaking of the EV_GAIN_SPELL event trigger. Nothing to do with score. It doesn't seem to respond and I was wondering what the conditions are as explained in my previous post. EV_TIMEOUT EV_START / END all respond proper in my background script.

gtbot

  • Master of ScreenSplit
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #941 on: December 29, 2013, 04:46:28 PM »
Are you activating the spellcard by using ObjEnemyBossScene_StartSpell?

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #942 on: December 29, 2013, 05:30:55 PM »
Are you activating the spellcard by using ObjEnemyBossScene_StartSpell?
Splendid, now that was indeed the missing factor. Silly me. I remember in-depth analysing the magic circle behaviour of ExRumia before but as you dwell down to other areas, you quickly forget such simple things. orz

Thanks!

KuroArashi100

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #943 on: December 31, 2013, 10:26:37 PM »
I've been trying to recreate DDC stage 2's background, but I'm running into some trouble.
If I look at the game, it seems the stage is made up of multiple parts:
Two layers of water, the grass on the side of the road, the road, an empty surface made of stones on the other side of the road, and the dangling parts of willows that appear from above.
I think I've been successful enough in recreating most of the parts so far, except for the willow parts.

In the game, the willow parts seem to bend at certain points, and move randomly around within certain boundaries.
I just have no idea how to achieve that. Does anybody have any idea how I could do this?

If anyone wants to see, this is my current code.
It currently looks like this, and I want to get something like this.
Thanks in advance!

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #944 on: December 31, 2013, 10:51:03 PM »
you would need to use 3D primitives in order to get the willows animated. sine the angle to get them to move back and forth.

I know nothing about primitives since ph3 has obj_sprite_2d.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #945 on: January 09, 2014, 09:30:51 AM »
Returning to a problem which we discussed twice already, but still haven't managed to find a solid solution.

http://www.shrinemaiden.org/forum/index.php/topic,10181.msg1004887.html#msg1004887
http://www.shrinemaiden.org/forum/index.php/topic,10181.msg1021163.html#msg1021163

It is regarding again sound files being loaded into the memory. Yesterday night I noticed a huge drop in frames towards the end of my spell card. TL DR: doing trial & error + monitoring the ph3 log console, I noticed I had 4000 objects for some unknown reason. The sound files weren't deleted.

Logical, as I didn't script anything in there because I didn't want to have MPP-style sfx handling. (See above links). However, it seems the devs of MPP were already unable to figure out this issue so decided to simply delete the sound files after some random period of time. The results are painful and ugly. Sudden cutting off sounds is last thing I want.

So here I was breaking my mind about this. Let us sum up some facts we know so far:
- Sounds need to be loaded in memory first.
- A sound file can be only called once. For example: playing Master Spark sound 3x will simply overwrite each other and eventually the 3rd one will fully play.
- Huge FPS drop can occur if the number of objects are not properly removed (garbage collcting) ((I noticed this specifically with sound files)).

To explain the master spark example. Let us say we have a loop of 3x with a small delay between. Let us claim MasterSpark.wav has duration of 90 frames (to make it easier, I know it is longer).  We have scripted MPP style a delay of 90 frames, then simply call Obj_Delete. This is what will happen:


The 2nd masterspark will overwrite the first, the third the second. However, the third master spark will be cut off by the timer from the first. (Still following this?). This is the major problem we're having.

Do we really have to go MPP style? It is quite sad that the Sound object division doesn't have a function to get the duration of a specific sound file (in samples). That way we could easily make the files auto-delete themselves after a period of time. And I know you can just give a parameter along, ie:  PlaySFX(sound,duration);  and use that to make it "flexible" but it still remains MPP style and the results are extremely ugly.
« Last Edit: January 09, 2014, 10:37:37 AM by Helepolis »

gtbot

  • Master of ScreenSplit
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #946 on: January 09, 2014, 01:55:11 PM »
The way I handled sound was to, at the start of the script, create (and load) a sound object for each of my sounds, store the IDs into an array that's stored into common data, and then pull them out from the common data array whenever I need them. I do this by also have a second common data array that stores their names in the same order as the IDs. I imagine there are better ways to do this, but this might give you some starting ideas.

To cover your second point, playing a sound while it is already playing in this method will stop the previous sound, and start it over.

Edit: Just thought up of a better way; Save all the object IDs into variables (or array, but I think it's better to not use arrays? not sure) in the system script; while in the playing script, make a bunch of incrementing constants (0-number of sound effects), and then use NotifyEvent and EV_USER to pass the constant of the sound you want to play; in the system script, use alternative(argument) and check for which constant was sent, and play the appropriate sound. Kind of hard for me to explain, and I haven't tested it, but I imagine it would work.
« Last Edit: January 09, 2014, 02:07:34 PM by gtbot »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #947 on: January 09, 2014, 03:29:03 PM »
I like your idea, since that way no extra objects need to be created. Because if you use shot-sounds, you're going to automatically have hundreds of them anyway. Since the sound file is indeed just replayed for each time you call it within its ending, there is no reason to keep spawning sound objects. This would also definitely solve loading issues for large sound effects upon use.

I think Blargel had mentioned that arrays were slower, at least in 0.12m he did extensive testing to figure this out. Not sure about ph3, since Blargel hasn't bothered with it.

I didn't quite understand your edit to be honest.

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #948 on: January 09, 2014, 08:01:45 PM »
Not quite sure if I should be putting this here, but this is what I've found. I put in
Code: [Select]
if(sin(bulletAngle) == 0)
{blahblahblah;}
with bulletAngle being 180. Nothing happened so I then tried
Code: [Select]
if(sin(180) == 0)
{blahblahblah;}
and still nothing happened. Thinking maybe I hadn't written something right, I tried
Code: [Select]
if(sin(0) == 0)
{blahblahblah;}
and it worked exactly as I wanted it to. I thought "maybe I'm just being stupid." So I googled the sine of 180 it's 0 or pi radians. Naturally, I tried to see if danmakufu would accept pi, π, 3.14, 3.134159265359, but none of them work. Is this a bug? If yes, is it known?
My name is Tres. It sounds like "Tray". Tressert is "Tray-zurt"; like Tres dessert.
I've cleared every touhou game on Lunatic, and beaten every extra except SoEW.
NMNB: MoF Hard, SA Extra, UFO Extra

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #949 on: January 10, 2014, 01:26:06 AM »
It's an issue with floating point accuracy. In general you should never be checking if a sine or cosine value like that is exactly some number, especially if it's some angle variable that's constantly changing. Your condition is basically equivalent to (bulletAngle == 0 || bulletAngle == 180). But again if bulletAngle is changing, you aren't guaranteed to ever have it hit exactly 0 or 180. Use a different condition entirely, if possible.

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

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #950 on: January 12, 2014, 04:35:15 PM »
UPDATE: ph3 [.1 pre1] has been released!

http://www.geocities.co.jp/SiliconValley-Oakland/9951/pre/th_dnh_ph3.html

Edit: I've created pages for all 3 types of file objects and have updated most of the missing Get functions in ObjRender, etc. There is one new function from ph3 [.1 pre1] that I have not added, but the new ObjText_SetSidePitch has been added.

WARNING: The update may break scripts. A LOT of them. Please be aware that many of your scripts MAY NOT run correctly under pre1.

EDIT: The failure to load scripts, text border issues, and other problems have been confirmed by multiple people. Please DO NOT UPGRADE TO PRE1. If it works for you, that's great, but for most people, pre23 will be much more stable.
« Last Edit: January 12, 2014, 06:38:35 PM by Sparen »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #951 on: January 13, 2014, 02:15:39 PM »
He has retracted his release on his website and is pointing at .0 release.

It is indeed wiser to stay on pre22 or 23 for now.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #952 on: January 14, 2014, 12:12:56 AM »
For those who can't find pre23, I've uploaded a mirror here: http://www.mediafire.com/download/gdd643wxdx4gx10/ph3pre23.zip

I actually don't know the identity of the [.0] release, which is sort of not easily accessible from the Wiki anyways. Please tell me if the mirror I uploaded doesn't unzip or *if I really messed up* has a different version.

Gusano Wornis

  • Member of Team Mystique
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #953 on: January 14, 2014, 06:45:38 PM »
LOCAA is so dead T_T
well, my question is: how to make a triangle like this:
        l
       l l
      l l l
     l l l l
the angle is to the player. its for a explosive spell of my King Pig Boss Battle
carrying dead weight since 2015~

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #954 on: January 14, 2014, 09:18:25 PM »
Off the top of my head, if you fire the triangle at angle a and overall speed s, then each bullet of the triangle fired at angle b should be given a speed of s/cos(b-a).

EDIT: picture explanation

« Last Edit: January 14, 2014, 10:10:49 PM by Drake »

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

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #955 on: January 14, 2014, 11:16:29 PM »
Off the top of my head, if you fire the triangle at angle a and overall speed s, then each bullet of the triangle fired at angle b should be given a speed of s/cos(b-a).

EDIT: picture explanation



P.S. Drake: Gusano is unfamiliar with trigonometry.
Gusano: Are you trying to do something similar to Chen in PCB Stage 2? If so, both Qwerty (RaNGE 10) and I (PDD Extra) should have code that might work.

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #956 on: January 15, 2014, 04:33:10 AM »
Even if he's unfamiliar with trig, I gave the speed necessary. You just need to plug it in. (b-a) is just the offset, so if you did something like
ascent(i in 0..4){
   createshot(x, y, s/cos(i*3), a + i*3, g, d);
   createshot(x, y, s/cos(i*3), a - i*3, g, d);
}
it should be fine.

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

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #957 on: January 21, 2014, 05:27:21 PM »
Ok, so I wrote this:
Code: [Select]
task fireInArc {
let dir = angleToPlayer;
let numShot = 6;
let arc = 180/2;
let arcUp = 180/numShot;
ascent(i in 0..numShot+1)
{ CreateShotA1(bossX,bossY,3,(dir-arc)+(arcUp*i),14,0); }
// ascent(i in 0..numShot)
// { CreateShotA1(bossX,bossY,3,(dir-arc)+(arcUp*(i+1)),14,0); }
}
And it works fine. I get 6 shots (+1) in a perfect 180 arc that angles toward the player. However, I wonder how can I remove that numShot+1 from ascent without breaking the arc (more correctly, making the arc fall short of 180 deg's).

This code also has that problem:
Code: [Select]
task triangleShot2 {
let s = 3; // speed.
let a = GetAngleToPlayer(bossObj)-(180/2); // angle.
let numShot = 6;

loop (numShot) {
ascent(i in 0..4) { // ascends the number of waves.
ascent(ii in 0..i+1) { // ascends the bullets spread(arc).
CreateShotA1(bossX, bossY, s/cos(i*3), (a-i) + (ii*2), 81+i, 0);
}
wait(3)
}
a += 180/numShot;
}
}
But this code, I also want the loop to fire instantly, but when I remove the wait, the Triangles become Bullet Walls. yikes!
« Last Edit: January 21, 2014, 07:16:50 PM by TheScriptwriter »

Shadow

  • Forever waiting for tomorrow
  • ...
Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #958 on: January 22, 2014, 03:15:27 AM »
You probably want to use the formula Arc_Width/(Bullet_Number-1) instead of increasing the number of loops by 1, if that is what you were referring to. If you simply use "numShot" in the ascent with your current angle calculation, it is only going to form 6 bullets without "closing" the arc correctly, as you're calculating the angle interval with one more bullet than you are supposed to.

As for your second problem, it is not /quite/ easily solved as you would need to rework your task logic to simultaneously create the five triangles' tips, wait three frames,  create the second layer of bullets, wait three frames, and so on. You could also make a task with an "angle" parameter, and make it fire a single triangle at that direction. Because tasks always run parallel regardless of scope, you can then call the task five times somewhere else without worrying about timing issues.

Re: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (latest version pre2x)
« Reply #959 on: January 27, 2014, 07:09:40 PM »
I'm a total noob with Danmakufu, so I'm sorry about this question. But how do I spawn an object bullet? From the wiki, it seems that you need a combination of Obj_Shot and Obj_Render commands, but I'm not sure which ones to use. Here's what I'm trying right now:
        ObjShot_Create(OBJ_SHOT);
   ObjRender_SetPosition(sides,bossX,bossY,0);
   ObjRender_SetAngleXYZ(sides,GetAngleToPlayer(bossObj),GetAngleToPlayer(bossObj),0);
   ObjShot_SetGraphic(sides,54);
   ObjShot_Regist(sides);
Normal 1cc's: LLS, MS, EoSD, PCB, IN, MoF, SA, UFO, TD, DDC
Hard 1cc's: EoSD, PCB, IN
Extra Clears: EoSD, PCB + Phantasm, IN, MoF, TD, DDC
Phantasmagoria Trues Clears: Standard Regular
Goals: Phantasmagoria Trues Unseen Standard 1cc, MoF XNM, MoF XNF