Author Topic: Danmakufu Q&A/Problem Thread v3  (Read 213422 times)

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread v3
« Reply #540 on: April 02, 2010, 02:01:07 PM »
Is there a way to check if the player was hit/used a bomb while LastSpell is activated and you didn't use SetScore (so there's no using GetSpellCardBonus)? OnPlayerMissed isn't working... and checking if the number of lives/bombs decreased doesn't work either...

You know, you could forbid bombing and give the player a SuperNaturalBorder that lasts for the duration of the entire spell card in the @Initialize{}.

Then, in the @MainLoop{}, you put

Code: [Select]
if(GetTimeOfSuperNaturalBorder==0){
AddLife(-GetLife);

//manipulate the variable or CommonData that gives you the score in the end so that it gives none

}

Hmmm, a small issue may be that you would get the obligatory bullet-to-score bonus, but since that should be nothing more than the score you gain from bombing bullets (and since regular last spells had this effect too, I believe), I think this is acceptable. At least unless you want items to drop during the spell, which would get autocollected through the border.
Old Danmakufu stuff can be found here!

"As the size of an explosion increases, the numbers of social situations it is incapable of solving approaches zero."

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #541 on: April 03, 2010, 09:40:24 AM »
This probably sounds like a weird question, but does anyone know exactly how the SetMovePosition03 function works behind the scenes? I'm trying to imitate the movement functions in Danmakufu with SetX and SetY, but the weight part of 03 is stumping me. I made a script that slows down time if you hold shift and has the boss moving back and forth when you press C to see if I could figure it out myself, but my physics prowess isn't as good as it was in high school...

EDIT: Nevermind figured it out. For those who are interested...

Code: [Select]
function SetMovePosition03(DestinationX, DestinationY, weight, maxspeed){
    let distance = ((GetX-DestinationX)^2 + (GetY-DestinationY)^2)^0.5;
    let angle = atan2(DestinationY - GetY, DestinationX - GetX);
    while(distance > 1){
      let speed = distance/weight;
      if(speed > maxspeed) { speed = maxspeed; }
      SetX(GetX + cos(angle)*speed);
      SetY(GetY + sin(angle)*speed);
      distance -= speed;
      yield;
    }
    SetX(DestinationX);
    SetY(DestinationY);
}
« Last Edit: April 03, 2010, 09:57:18 AM by Blargel »
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread v3
« Reply #542 on: April 03, 2010, 06:24:30 PM »
That's how I figured it always worked man D:

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

Nobu

  • Serendipitous Youkai
  • *
  • i post while naked
    • My Tumblr
Re: Danmakufu Q&A/Problem Thread v3
« Reply #543 on: April 03, 2010, 08:28:13 PM »
Umu.. what's the difference between a task and a function?
Tumblr (sometimes NSFW) | PM for Facebook

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #544 on: April 03, 2010, 08:58:23 PM »
u?.. what's the difference between a task and a function?

Quote Naut:
Quote
In order of processing speed, from fastest to slowest:

sub
function
task

And here's why. A sub is just a routine that you often call that requires no changing whatsoever. So if I wanted to make the same array of shots happen over and over again, but at different places in the script, I could say somewhere in script_enemy_main:

Code: [Select]
sub bullatz{
CreateShot01(GetX, GetY, 3, GetAngleToPlayer - 30, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer - 20, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer - 10, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer + 10, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer + 20, RED02, 0);
CreateShot01(GetX, GetY, 3, GetAngleToPlayer + 30, RED02, 0);
}
And then say bullatz; anywhere in my script and those shots will be fired.

A function is the same thing, except you can edit parameters of the shots as you're calling them. So, to fire a similar array of shots:

Code: [Select]
function bullutz(angle){
CreateShot01(GetX, GetY, 3, angle - 30, RED02, 0);
CreateShot01(GetX, GetY, 3, angle - 20, RED02, 0);
CreateShot01(GetX, GetY, 3, angle - 10, RED02, 0);
CreateShot01(GetX, GetY, 3, angle, RED02, 0);
CreateShot01(GetX, GetY, 3, angle + 10, RED02, 0);
CreateShot01(GetX, GetY, 3, angle + 20, RED02, 0);
CreateShot01(GetX, GetY, 3, angle + 30, RED02, 0);
}
This time, I'll call bullutz(90); to shoot this array of bullets with the updated angle of 90 degrees. I could say bullutz(270); for another direction. And that's what functions are in Danmakufuland. Ah, you can also call more than one paramter in a function, so don't feel limited by only one independent variable.

A task, as you might guess, is an upgraded function, and thus takes the most processing power. With tasks you are basically creating another @MainLoop that you control whenever it's run. To do this, tasks use the magical operator called yield;. yield; allows you to freely switch between processing your task and processing your @MainLoop, so you can list ordered events, and have them only carry out your actions once without repeat, and still edit them. yield; suspends the current task or MainLoop and then carries onto another task until it hits another yield; command, then it goes back to the MainLoop and finishes the frame cycle. It'll continue where it left off the next frame, which makes it very easy to list ordered events. A task is basically a list of events that you want to happen, that you can freely edit at anytime during the script using the same parameters as a function.

And an example of a task:


Code: [Select]
task attack(delay, angle){
CreateShot01(GetX, GetY, 5, GetAngleToPlayer, RED03, delay);
loop(120){yield;}
loop(5){
  CreateShot01(GetX, GetY, 3, GetAngleToPlayer, BLUE01, 0);
  loop(5){yield;}
  }
CreateShot01(GetX, GetY, 2, angle, YELLOW12, 0);
}
So now, I'll call attack(5, 90); somehwere in @MainLoop to fire of a large red shot towards the player with 5 delay, the script will wait two seconds (120 frames, the loop(120){yield;} statement), then fire 5 blue shots in succession but wait 5 frames inbetween each shot, and then finally firing a small yellow shot at 90 degrees.

It should be noted that you MUST include yield; somewhere in your @MainLoop (preferably at the beginning or end, easier to keep track of) and call it every frame to ensure that the yield; command works properly in your tasks.


Anyways, you probably already knew about yield; and crap, but I thought I would be clear with the explanation and include everything, even though this is a very poor description of the yield; command and what it does.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread v3
« Reply #545 on: April 03, 2010, 10:19:03 PM »
Still gotta remember that a function can return a value.

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

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #546 on: April 03, 2010, 11:14:05 PM »
Still gotta remember that a function can return a value.

Yes, and that too.
Code: [Select]
function lol {
return 0;
}
function lol2 {
return true;
}
function lol3 {
return "This is a string";
}

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #547 on: April 09, 2010, 01:27:12 AM »
wow I haven't asked help from this board in a while and a lot has changed since I've last been here.
Anyway on to the question. Is there a function to get a bullet to move in a spiral-like way? I've tried it myself and can make it turn to make a partial spiral but it somehow always ends up coming back, and doing circles around the boss. I think it's because if I put the bullet angleset+=1; the bullet is at a constant speed so it has to always turn back and eventually touch the origin it was fired from.
I don't know the exact function, but I need a spiral and need really want it to be porportional. The bullet must be at a constant speed.
Does anyone know the function for that? Here's the golden spiral, just to point out what I'm looking for.

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: Danmakufu Q&A/Problem Thread v3
« Reply #548 on: April 09, 2010, 02:59:02 AM »
Code: [Select]
while(!Obj_BeDeleted(obj)){
  Obj_SetPosition(obj,centerx+cos(angle)*distance,centery+sin(angle)*distance);
  angle+=4;
  distance+=2;
  yield;
}

Drake

  • *
Re: Danmakufu Q&A/Problem Thread v3
« Reply #549 on: April 09, 2010, 03:01:17 AM »
turn = something;

turn*=0.9;
setangle(getangle+turn);

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

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #550 on: April 09, 2010, 06:36:43 AM »
Thank you. Both worked wonderfully.

ChaoStar

  • Dark History Boy
Re: Danmakufu Q&A/Problem Thread v3
« Reply #551 on: April 12, 2010, 02:17:48 PM »
So uh, how do I make a nice, perfect double helix shape? Like in SA.

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread v3
« Reply #552 on: April 12, 2010, 02:37:57 PM »
So uh, how do I make a nice, perfect double helix shape? Like in SA.

While it is possible to make these with much simpler code, a very flexible script for this kind of waving bullets would be this:
Code: [Select]

    task TWaveBullet(x, y, v, ang, delta, phi, ampli, graph){

       let obj=Obj_Create(OBJ_SHOT);

       Obj_SetPosition(obj, x, y);
       Obj_SetAngle(obj, ang);
       Obj_SetSpeed(obj, 0);
       ObjShot_SetGraphic(obj, graph);
       ObjShot_SetDelay  (obj, 0);

       while(Obj_BeDeleted(obj)==false) {

           delta+=phi;

           Obj_SetX(obj, Obj_GetX(obj) + v*cos(ang) + ampli*sin(delta)*cos(ang+90) );
           Obj_SetY(obj, Obj_GetY(obj) + v*sin(ang) + ampli*sin(delta)*sin(ang+90) );

           Obj_SetAngle(obj, ang+90-atan( v/(ampli*sin(delta)) ) );
           yield;
       }
    }

Then you use these bullets in your helix task:

Code: [Select]
    task THelix(x, y, ang, n, t){
loop(n){
TBullet(GetX, GetY, 2, ang, 90, 5, 2, BLUE11);
TBullet(GetX, GetY, 2, ang, -90, 5, 2, RED11);

loop(t){yield; }
}
    }

Change the variables as you see fit. The delta values of 90 and -90 are necessary for the helix structure, as is the similarity of the values between the two bullets, but other than that you can play around with it to get the exact helix you want.

 ;)
Old Danmakufu stuff can be found here!

"As the size of an explosion increases, the numbers of social situations it is incapable of solving approaches zero."

ChaoStar

  • Dark History Boy
Re: Danmakufu Q&A/Problem Thread v3
« Reply #553 on: April 12, 2010, 05:13:48 PM »
Thank you. ^__^

ChaoStar

  • Dark History Boy
Re: Danmakufu Q&A/Problem Thread v3
« Reply #554 on: April 13, 2010, 03:04:20 PM »
does GetEnemyShotCountEx  detect lasers?

Just wondering.

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #555 on: April 13, 2010, 03:34:24 PM »
Why don't you just check that yourself with the debug window and a boss that purposely spawns a laser on a spot you're checking? I know you can figure out how to do that yourself really easily...  ???

I'm pretty sure it doesn't check, but I guess it's good to make sure.
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

ChaoStar

  • Dark History Boy
Re: Danmakufu Q&A/Problem Thread v3
« Reply #556 on: April 13, 2010, 04:43:37 PM »
Why don't you just check that yourself with the debug window and a boss that purposely spawns a laser on a spot you're checking? I know you can figure out how to do that yourself really easily...  ???

I'm pretty sure it doesn't check, but I guess it's good to make sure.

I'm stuck at work for 9 hours T___T

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: Danmakufu Q&A/Problem Thread v3
« Reply #557 on: April 14, 2010, 03:32:28 AM »
does danmakufu have problems with auto-deletion of player object lasers? cause this piece of code keeps on making it crash when the first laser spawned reaches the auto-delete mark (outside the screen)
Code: [Select]
task aquablast
{
let blastangle=angletoenemy;
let blastangleb=blastangle;
loop(10)
{
blastangle+=7;
PlaySE(GetCurrentScriptDirectory~"Laser1.wav");
aqualaser(GetCenterX+30*cos(blastangle), GetCenterY+30*sin(blastangle), blastangle);
aqualaser(GetCenterX+30*cos(blastangleb-blastangle), GetCenterY+30*sin(blastangleb-blastangle), blastangleb-blastangle);
aqualaser(GetCenterX+30*cos(180+blastangle), GetCenterY+30*sin(180+blastangle), 180+blastangle);
aqualaser(GetCenterX+30*cos(180+blastangleb-blastangle), GetCenterY+30*sin(180+blastangleb-blastangle), 180+blastangleb-blastangle);
loop(5){yield;}
}

task aqualaser(x, y, ang)
{
let count=0;
let startx=GetCommonData("STAGEX");
let starty=GetCommonData("STAGEY");
let obj=Obj_Create(OBJ_LASER);
Obj_SetPosition(obj, x, y);
Obj_SetAngle(obj, ang);
Obj_SetSpeed(obj, 0);
ObjShot_SetGraphic(obj, BLUE01);
ObjShot_SetDamage(obj, 0.5);
ObjShot_SetPenetration(obj, 30000);
ObjLaser_SetLength(obj, 2);
ObjLaser_SetWidth(obj, 15);
ObjLaser_SetSource(obj, false);
while(Obj_BeDeleted(obj)==false)
{
yield;
if(ObjLaser_GetLength(obj)<100){ObjLaser_SetLength(obj, ObjLaser_GetLength(obj)+3);}
if(ObjLaser_GetLength(obj)>100){ObjLaser_SetLength(obj, 100); count=1;}
if(count>=1){Obj_SetX(obj, Obj_GetX(obj)+3*cos(ang)); Obj_SetY(obj, Obj_GetY(obj)+3*sin(ang)); count++;}
if(count>=50){Obj_Delete(obj);}
if(startx!=GetCommonData("STAGEX"))
{
Obj_SetX(obj, Obj_GetX(obj)+(GetCommonData("STAGEX")-startx));
startx=GetCommonData("STAGEX");
}
if(starty!=GetCommonData("STAGEY"))
{
Obj_SetY(obj, Obj_GetY(obj)+(GetCommonData("STAGEY")-starty));
starty=GetCommonData("STAGEY");
}
}
}

}
*angletoenemy is just a function that returns an angle...
« Last Edit: April 14, 2010, 03:38:01 AM by Kylesky »
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #558 on: April 14, 2010, 04:08:24 AM »
The first suggestion I can think of is that your yield in the laser task should go at the end of the while loop instead of the beginning. If that doesn't fix anything I'd guess that your aquablast task is doing something weird. See if moving the yield fixes it first in any case.
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: Danmakufu Q&A/Problem Thread v3
« Reply #559 on: April 14, 2010, 04:19:34 AM »
The first suggestion I can think of is that your yield in the laser task should go at the end of the while loop instead of the beginning. If that doesn't fix anything I'd guess that your aquablast task is doing something weird. See if moving the yield fixes it first in any case.

moving the yield; did fix it... I'm such an idiot T_T
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Nobu

  • Serendipitous Youkai
  • *
  • i post while naked
    • My Tumblr
Re: Danmakufu Q&A/Problem Thread v3
« Reply #560 on: April 14, 2010, 04:28:47 AM »
I swear, Danmakufu is so finicky sometimes. :V
Tumblr (sometimes NSFW) | PM for Facebook

Re: Danmakufu Q&A/Problem Thread v3
« Reply #561 on: April 14, 2010, 04:47:54 AM »
Actually, it's really not. Might as well explain why that worked...

He's got the statement while(!Obj_BeDeleted(obj)){, which obviously checks if the laser is still alive. So it does, then immediately encounters a yield; statement, causing Danmakufu to exit out of that loop for that frame and go off to do other stuff. So then, the next frame, it jumps back into the loop, but starts off at the yield; statement (not checking if the object is still alive), and then proceeds to use a bunch of accessor methods to get information about the laser. Well, what if that laser died that frame? Danmakufu is now trying to get information about a laser that no longer exists, and crashes. Putting the yield; at the very end of the loop means that it will loop back to the while statement and check if the laser is still alive, then encounter the accessor methods in the same frame. If the Obj_BeDeleted(obj) check returns false, then it won't check any accessor methods, and thus Danmakufu won't crash.

Hope that clears up why that fix worked :V

Nobu

  • Serendipitous Youkai
  • *
  • i post while naked
    • My Tumblr
Re: Danmakufu Q&A/Problem Thread v3
« Reply #562 on: April 14, 2010, 05:14:59 AM »
Whoa Naut, that makes complete sense. I think my programmer level just went up.  :ohdear:
Tumblr (sometimes NSFW) | PM for Facebook

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: Danmakufu Q&A/Problem Thread v3
« Reply #563 on: April 14, 2010, 05:45:52 AM »
Hope that clears up why that fix worked :V

I actually thought of that already when blargel told me to move the yield; :V
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #564 on: April 15, 2010, 08:17:08 PM »
So I have another question.
To make things more organized in both scripting and the actual file names, I'm renaming my files. All files will be named as its purpose and number. For example sound effects will be labeled sound01, sound02, sound03, images will be labeled image01, image02, image03.

My question is, how do I plug in so it's only in a few lines of code? With over 50 images and sounds altogether, I don't want to type "let image01=.... letimage02=..." and "loadgraphic(effect01); LoadGraphic(effect02);", flooding my script with mere identification and loading code.

Is there a way to put in a variable in its place? I tried using ascent, but I don't think I did it right. I'd like an example.

Re: Danmakufu Q&A/Problem Thread v3
« Reply #565 on: April 15, 2010, 08:26:39 PM »
ascent(i in 1..21){
      let string = "" ~ ToString(i);
      let number = 0;
      let result = "";
      while(number < length(string) && string[number] != '.'){
             result = result ~ ToString(string[number]);
             number++;
      }
      LoadGraphic(GetCurrentScriptDirectory~"effect"~result~".png");
      LoadGraphic(GetCurrentScriptDirectory~"sound"~result~".wav");
}

Loads effect1.png to effect20.png and sound1.wav to sound20.wav.

look at dem colors
« Last Edit: April 15, 2010, 08:28:24 PM by Naut »

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #566 on: April 15, 2010, 08:39:14 PM »
problemsolved.txt

That's alot of punctuation. I wonder what they all mean? Like "" in       let result = "";
I also thought the brackets were for arrays, I wonder what else you can do with them.

Nobu

  • Serendipitous Youkai
  • *
  • i post while naked
    • My Tumblr
Re: Danmakufu Q&A/Problem Thread v3
« Reply #567 on: April 15, 2010, 08:50:27 PM »
That's alot of punctuation. I wonder what they all mean? Like "" in       let result = "";
I also thought the brackets were for arrays, I wonder what else you can do with them.

The "" in result and string initialize an empty string variable that you can concatenate to.

The brackets used at the end of a string variable(or an array) call the character or item located at that index. So if string = "Naut Rocks", string[5] = 'R'
« Last Edit: April 15, 2010, 08:52:23 PM by Nobu~♪ »
Tumblr (sometimes NSFW) | PM for Facebook

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #568 on: April 15, 2010, 09:06:51 PM »
The "" in result and string initialize an empty string variable that you can concatenate to.

The brackets used at the end of a string variable(or an array) call the character or item located at that index. So if string = "Naut Rocks", string[5] = 'R'


Oh, I see. So if I were to put...

ascent(D in 1..9){

LoadGraphic(image0[D])
}

It would be equivilalent to LoadGraphic(image01); LoadGraphic(image02); ...  ?

That's pretty useful. That leaves one last question. What's the purpose of ~
I used to think it was merely for GetCurrentScriptDirectory~"out-of-game file/document here"

Drake

  • *
Re: Danmakufu Q&A/Problem Thread v3
« Reply #569 on: April 15, 2010, 09:17:08 PM »
No, you have to do

ascent(D in 1..9){
    LoadGraphic("image0" ~ ToString(D) ~ ".png");
}

As you had it, it would have loaded the second to tenth entry in the array/string variable image0, which doesn't exist, nor would it have loaded anything if it did exist.

~ concatenates arrays or strings. As you can see in my example above, it would take "image0", "1" (or other number) and ".png" and have the entire string as "image01.png". Same thing with arrays, it places whatever comes after the ~ to what came before.

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