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

DgBarca

  • Umineko fuck yeah
  • Spoilers ?
Re: Danmakufu Q&A/Problem Thread v3
« Reply #90 on: February 02, 2010, 09:56:56 PM »
assuming the object bullet will be called 'obj', we would do it like this.

Code: [Select]
task bullet{let angle=0; let speed=2;
Bullet
Creation
Code
Goes
Here
Obj_SetAngle(obj,angle);
Obj_SetSpeed(obj,speed);



loop{Obj_SetAngle(obj,angle); Obj_SetSpeed(obj,speed); angle+=1/30; speed+=-0.01; yield;}
}

It doesn't HAVE to be a while(!Obj_BeDeleted(obj)) for it it to work. Loop and Ascent work too.

I don't want the bullet to curve, just change angle like THAT
[21:16] <redacted> dgbarca makes great work
[21:16] <redacted> i hope he'll make a full game once

Re: Danmakufu Q&A/Problem Thread v3
« Reply #91 on: February 02, 2010, 10:23:04 PM »
I don't want the bullet to curve, just change angle like THAT

Modulus, baby!

task blah{
    let obj = ObjCreate(OBJ_SHOT);
    //...

    let counter1 = 0;

    while(!Obj_BeDeleted(obj)){
        counter++;
        if(counter>=30 && counter%15==0 && counter<=150){
            angle+=1/30;
        }
        Obj_SetSpeed(obj, Obj_GetSpeed(obj) - 0.1);
        Obj_SetAngle(obj, angle);
        yield;
    }
}


In general terms, if you want something to do a whole bunch of different things at different times, you can just create a whole bunch of counter variables that increment every loop and reset them all at different times.

task blah{
    let obj = Obj_Create(OBJ_SHOT);
    //...

    let counter1 = 0;
    let counter2 = 0;
    let counter3 = 0;

    while(!Obj_BeDelete(obj)){
        counter1++;
        counter2++;
        counter3++;

        if(counter1==30){
            Obj_SetAngle(obj, Obj_GetAngle(obj) + 3);
            counter1=15;
        }

        if(counter2==64){
            //dosomethingelse;
            counter2=12;
        }

        if(counter3==7){
            //yougetthepoint;
            counter3=3;
        }

        yield;
    }
}



i wanted to make one certain task in a stage script stop playing, but implementing eternal yields in Wait seems to freeze danmakufu. is there any possible way besides filling the task itself with these yields?

I dunno what you're doing, but not putting anything after the all the commands in a task will stop it from playing, since it has ended. If you want a task to stop depending on something you can't predict (like player movement or something), you can just say break;, which will immediately stop that task and never continue it. If you just want something to pause for a long time, looping a couple thousand yield; commands will work, I've done it. If it froze, then your problem lies elsewhere, or you forgot to yield;.

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #92 on: February 03, 2010, 01:32:53 AM »
I dunno what you're doing, but not putting anything after the all the commands in a task will stop it from playing, since it has ended. If you want a task to stop depending on something you can't predict (like player movement or something), you can just say break;, which will immediately stop that task and never continue it. If you just want something to pause for a long time, looping a couple thousand yield; commands will work, I've done it. If it froze, then your problem lies elsewhere, or you forgot to yield;.

Oh you silly people. break; makes it exit out of any current loop. This means any while, ascent, and loop will be exited. If you want to end a FUNCTION -- and I'm including tasks in that term -- prematurely for whatever reason, you're looking for the return; statement. That will make it exit out of the current function that it is called it.

As for ending tasks that loop indefinitely, return; or break; will probably work because return; obviously just kills the task, and break will exit out of the loop that was going to continue indefinitely. If there's nothing after the loop, then break; will pretty much behave the same way as return; anyway.




For doing multiple things at once with one object that have different timings, nested tasking is your best friend. Now many of you may go "wtf" at this, but take a closer look and try to understand it, and you may just find something new and useful to use:


task LolObject {
    let obj = Obj_Create(OBJ_SHOT);
    Obj_SetPosition(obj, GetX, GetY);
    ControlSpeed;
    ControlAngle;
    ControlAlpha;
    ObjShot_SetGraphic(obj, RED01);
    ObjShot_SetDelay(obj, 30);

    // Here's the fun part. Putting a task INTO a task let's you have access to
    // all the variables that were made in the parent task as well. In this case,
    // we now have access to the obj.
    task ControlSpeed {
        Obj_SetSpeed(obj, 5);
        while(!Obj_BeDeleted(obj)){
            Wait(10);
            Obj_SetSpeed(obj, Obj_GetSpeed(obj) - 0.1);
        }
    }

    task ControlAngle {
        Obj_SetAngle(obj, GetAngleToPlayer);
        while(!Obj_BeDeleted(obj)){
            Wait(7);
            Obj_SetAngle(obj, Obj_GetAngle(obj) + 90);
        }
    }

    task ControlAlpha {
        let counter = 0;
        while(!Obj_BeDeleted(obj)){
            Obj_SetAlpha(obj, 128 + sin(counter)*127);
            counter++;
            yield;
        }
    }
}

Obviously this bullet control task is stupid and won't be useful for anything, but it's just an example. If you can understand what's going on, great! If you can't, I can try to clarify what's going on if someone asks.

EDIT: One thing to note is that the tasks/functions/subs that are defined in another task/function/sub cannot be accessed by anything else except the parent task/function/sub. This is similar to how if you make a variable inside one, you cannot access it outside of it either.
« Last Edit: February 03, 2010, 01:53:25 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.

Fetch()tirade

  • serial time-waster
Re: Danmakufu Q&A/Problem Thread v3
« Reply #93 on: February 03, 2010, 02:58:05 AM »
When using a CreateShot or CreateLaser function, does the SetblahData have to be set right next to it always, or can it be a part of a task or something?

What I mean is this:
Quote
CreateblahA(stuff);
SetblahA(more stuff);
FireShot(#);

if(something gets to something){
     SetblahA(different stuff);
}
Is this possible?

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #94 on: February 03, 2010, 03:06:45 AM »
I believe it is. Why don't you test it out and let us know? :V
<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.

Fetch()tirade

  • serial time-waster
Re: Danmakufu Q&A/Problem Thread v3
« Reply #95 on: February 03, 2010, 03:07:32 AM »
Sure, I'll get right on it.

It turns out you can.
The order of Createblah has to be the same, though.
Quote

   task test{
      let dir = rand_int(0,359);

      loop{
         CreateShotA(1,GetCenterX,GetCenterY,10);
         if(GetTimer>15){
            SetShotDataA(1,60,2.5,dir,0,0,2.5,BLUE05);
         }
         if(GetTimer<15){
            SetShotDataA(1,60,2.5,dir,0,0,2.5,BLUE01);
         }
         FireShot(1);
         dir+=5;
         wait(5);
         yield;
      }
   }

« Last Edit: February 03, 2010, 03:29:43 AM by Flashtirade »

Re: Danmakufu Q&A/Problem Thread v3
« Reply #96 on: February 03, 2010, 03:29:27 AM »
As long as you haven't fired the shot yet, you may set data for any shot at any time.

Re: Danmakufu Q&A/Problem Thread v3
« Reply #97 on: February 03, 2010, 03:32:14 AM »
As long as you haven't fired the shot yet, you may set data for any shot at any time.
............crap, that would have made things alot easier....

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #98 on: February 03, 2010, 06:55:55 AM »
Not exactly a question, but I finally learned how atan2 works.
Code: [Select]
///x and y being the points in respect to angle theta
if (x > 0) then
  θ = atan(y / x)   //simple, rise over run so arctangent gives you the angle theta
 if (x < 0) then     
  θ = atan(y / |x|) - π  ///same thing as before, but if x is a negative, get the absolute value of x to use in atan(y/x), then subtract 180 degrees
 else if (x == 0) then   ////y/x   x=0;  this is where tan would mess up, can't divide by zero can we?
 else if (y > 0) then   
    θ = π/2                 ///if x is 0, and Y is greater than 0, theta is 90 degrees
  else if (y < 0) then
    θ = -π/2///if x is 0, and y is less than 0, theta is -90 degrees
  else if (y == 0) then
   
 θ is undefined////     if both x and y is zero, there is no angle to measure
woohoo, I don't have to use danmakufu's messy atan2 anymore  :toot:
« Last Edit: February 03, 2010, 07:04:32 AM by Fujiwara no Mokou »

Re: Danmakufu Q&A/Problem Thread v3
« Reply #99 on: February 03, 2010, 07:17:43 AM »
? ? ? ?

Code: [Select]
function atan2(y, x){
   if(y==0){
      if(x<0){
         return 180
      }else{
         return 0
      }
   }else{
      return 2*atan(((x^2 + y^2)^0.5 - x)/y)
   }
}

:(

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #100 on: February 03, 2010, 07:52:40 AM »
:(

No no, I didn't intend it to be in Danmakufu code, that was just something to get the idea through.

Here, if you want it in code, an example. You'll have to set the target and origin in order for it to work.
EDIT: Sorry about that, I forgot danmakufu doesn't measure angles the standard way. Please wait warmly.

EDIT: Alright, here's the code.
Code: [Select]

/////GetPlayer is target, GetCenter is origin
function atn2{

if(GetPlayerX>GetCenterX){
return atan((GetPlayerY-GetCenterY)/(GetPlayerX-GetCenterX))}

else{return  atan((GetPlayerY-GetCenterY)/(GetPlayerX-GetCenterX))-180}





}


Oh, and to answer your question back there...
When you put in atan(parameters), it automatically ignores the math when it's 1/0.  atan(1/0) automatically becomes 90, and atan(-1/0) becomes -90. That's why it doesn't come out jibberish when you plug something like that as a string other than atan.  It's a function of its own.
« Last Edit: February 03, 2010, 10:30:40 PM by Fujiwara no Mokou »

Re: Danmakufu Q&A/Problem Thread v3
« Reply #101 on: February 03, 2010, 11:33:13 PM »
I am attempting to create a stage (extra-style stage, at that). I have a major problem with enemies, however.

At random times, an enemy will not technically "spawn" (it appears that they do in essence, because whatever sound effect they normally make still occurs, and that loops infinitely due to modulus). The enemy does not appear physically or shoot bullets.

I have no idea why this is happening. This especially occurs after defeating some prior enemies (which I do not believe should share anything at all relating to appearance on the field in their scripts), in which defeating a certain number of enemies before the next wave decreases the number of enemies in the proceeding wave.

Can anybody tell me why this is?

In case the scripts are needed:

Code: [Select]
\\\\\ Floats to the right side of the screen, firing intervals of bullets vertically

script_enemy_main yellowfairy
{
let yf = GetCurrentScriptDirectory ~ "img\enemy.png";

let count = rand_int(0, 30);


#include_script "script\Frazer\Movement for yellow fairy.txt";
 
@Initialize
{
  SetLife(150);
  SetDamageRate(100, 100);
  SetAngle(0);
  SetSpeed(3);

  LoadGraphic(yf);
  SetTexture(yf);
  SetGraphicRect(0,257,32,288);
  LoadUserShotData("script\Frazer\Shot.txt");
  }

@MainLoop
{
SetCollisionA(GetX, GetY, 16);
SetCollisionB(GetX, GetY, 8);

if(count%60 <= 30 && GetX < GetClipMaxX + 10){
PlaySE("script\Frazer\se\Shot7.wav");
CreateShot01(GetX, GetY, 3, 90, 30, 2);
CreateShot01(GetX, GetY, 3, 270, 30, 2);
}

if(GetX > GetClipMaxX + 100){ VanishEnemy; }


count++;

setgraphicmove;
}



@DrawLoop {
DrawGraphic(GetX, GetY);
}

@Finalize {

loop(5){
CreateItem(ITEM_SCORE, GetX + rand(-25, 25), GetY + rand(-25, 25));
}
}
}

Code: [Select]
\\\\\ Appears in an explosion of a perfect ring of bullets, then rises up

script_enemy_main redfairy
{
let rf = GetCurrentScriptDirectory ~ "img\enemy.png";

let count = 0;
let count2 = 0;
let a = rand(0, 360);


#include_script "script\Frazer\Movement for red fairy.txt";
 
@Initialize
{
  SetLife(50);
  SetDamageRate(100, 100);

  LoadGraphic(rf);
  SetTexture(rf);
  SetGraphicRect(0,257,32,288);
  LoadUserShotData("script\Frazer\Shot.txt");
  }

@MainLoop
{
SetCollisionA(GetX, GetY, 16);
SetCollisionB(GetX, GetY, 8);

if(count == 1){
SetMovePosition02(GetX + 100, GetClipMinY + 50, 1);
}

if(count == 2){
loop(30){
CreateShot01(GetX, GetY, 3, a, 51, 5);

a += 12;
}
}

if(count == 60){
SetMovePosition01(GetX + 100, -500, 5);
}

if(GetY < GetClipMinY - 100){ VanishEnemy; }


count++;
count2++;

setgraphicmoverf;
}



@DrawLoop {
DrawGraphic(GetX, GetY);
}

@Finalize {

loop(5){
CreateItem(ITEM_SCORE, GetX + rand(-25, 25), GetY + rand(-25, 25));
}
}
}

Re: Danmakufu Q&A/Problem Thread v3
« Reply #102 on: February 04, 2010, 04:39:56 AM »
I am attempting to create a stage (extra-style stage, at that). I have a major problem with enemies, however.

At random times, an enemy will not technically "spawn" (it appears that they do in essence, because whatever sound effect they normally make still occurs, and that loops infinitely due to modulus). The enemy does not appear physically or shoot bullets.

I have no idea why this is happening. This especially occurs after defeating some prior enemies (which I do not believe should share anything at all relating to appearance on the field in their scripts), in which defeating a certain number of enemies before the next wave decreases the number of enemies in the proceeding wave.

Can anybody tell me why this is?

In case the scripts are needed:

Code: [Select]


script_enemy_main yellowfairy
}
}

Code: [Select]

script_enemy_main redfairy
[/quote]
script_enemy_main does not cannot have another name to them

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #103 on: February 04, 2010, 05:41:08 AM »
script_enemy_main does not cannot have another name to them

Danmaku Nimmt's Mima enemy:
Code: (Mima) [Select]
//==============================================================================
// ★敵表示スクリプト 魅魔
//==============================================================================
// 角度にリフレッシュフラグ、任意値引数にプレイヤー番号を指定
//------------------------------------------------------------------------------
script_enemy_main ComMima{

// ヘッダ
#include_function ".libhedderCom.txt"
#include_function ".libanimeanimeMima.txt"

// 変数
let nChar = CHR_MIMA;
let nAct = ACT_SHOT_A;

// 共通構造
#include_function ".libstructCom.txt"

}

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 #104 on: February 04, 2010, 02:40:55 PM »
Not really a question/problem but...



anyone who can code something like this, and use it like some kind of spear danmaku, in danmakufu is a GOD... it's something called tetration (found it on wikipedia)

0_o brain hurts... blows my mind off...

problem is... even trying this on Geogebra (a graphing software) won't show me how it works, or rather... I don't get how it works... I don't think I'd even wanna try to do this anymore... but it would be cool if someone was able to do something that looks like it... just wanted to show people... :V
« Last Edit: February 04, 2010, 02:42:53 PM by Kylesky »
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Infy♫

  • Demonic★Moe
  • *
Re: Danmakufu Q&A/Problem Thread v3
« Reply #105 on: February 04, 2010, 05:13:57 PM »
I got some functions that make it yield for a given time and i want those functions to check if the script must stop. can i use break; inside those functions?

Drake

  • *
Re: Danmakufu Q&A/Problem Thread v3
« Reply #106 on: February 04, 2010, 06:14:04 PM »
Sure.

loop(n){
    if(bla){break;}
    yield;
}

Why would you need to do that?

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

Infy♫

  • Demonic★Moe
  • *
Re: Danmakufu Q&A/Problem Thread v3
« Reply #107 on: February 04, 2010, 06:22:23 PM »
because my stages are scripted in a task and the stagetask must be stopped once the player loses his lives. he can then choose to redo the stage or quit.
the problem i had in the beginning was, that the Wait function froze when i put a loop{yield;} in it.

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #108 on: February 04, 2010, 06:25:08 PM »
because my stages are scripted in a task and the stagetask must be stopped once the player loses his lives. he can then choose to redo the stage or quit.
the problem i had in the beginning was, that the Wait function froze when i put a loop{yield;} in it.

So basically you want to make a Touhou 10+ continue system thing?

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread v3
« Reply #109 on: February 04, 2010, 08:28:24 PM »
Not really a question/problem but...



anyone who can code something like this, and use it like some kind of spear danmaku, in danmakufu is a GOD... it's something called tetration (found it on wikipedia)

0_o brain hurts... blows my mind off...

problem is... even trying this on Geogebra (a graphing software) won't show me how it works, or rather... I don't get how it works... I don't think I'd even wanna try to do this anymore... but it would be cool if someone was able to do something that looks like it... just wanted to show people... :V

If you understand the math behind the function, it is not that difficult. I understand only halfways, but given the graphical limitations of danmakufu, it is actually pretty easy to come up with a task that creates a spear that looks like you intended:

Code: [Select]
let graph=[RED05, BLUE05, ORANGE05, GREEN05, PURPLE05, AQUA05];

task Mathspear(px, py, v, ang, n, phi, amp, n2){

let way=0;
let exp=0;

loop(n){

ascent(i in 1..(n2+1)){
exp=i;
loop(ceil(way)){ exp=exp^i; }
exp=exp*(exp^(way-ceil(way)));
CreateShot01(px+amp*cos(ang+90)*sin(exp)*way, +amp*sin(ang+90)*sin(exp)*way, v, ang, graph[i], 0);
CreateShot01(px-amp*cos(ang+90)*sin(exp)*way, -amp*sin(ang+90)*sin(exp)*way, v, ang, graph[i], 0);
}

way+=phi;

yield;
}

}
...however, there are obvious problems, as expected. For once, danmakufu will refuse to calculate the math behind the pattern as soon as the numbers reach ludicrous values, and that happens pretty fast. Once this point is reached, danmakufu will simply refuse to execute the command that uses the variable of said value: Instead of crashing, it just doesn't fire the bullet.
Even if that wasn't the case, the math behind this stuff calls for a ludicrous amount of iterations very soon, so even if the bullets still show up, the math alone will cause massive slowdown.

In case you were wondering, the values I used for testing were Mathspear(GetCenterX, 64, 2, 90, 5000, 0.005, 15, 5);
See for yourself.
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."

Re: Danmakufu Q&A/Problem Thread v3
« Reply #110 on: February 04, 2010, 11:18:23 PM »
script_enemy_main does not cannot have another name to them[/code]


I am unsure whether I followed that correctly, but the problem remains unfixed. I have the same result. Destroying enemies in a preceding wave decreases the proceeding enemies spawned.

EDIT: I believe I have discovered the true issue with this. For whatever reason, the enemies randomly choose either to move or not to move. I do not understand why this is. This seems to especially be the case when the movement code is placed under

Can anybody assist me?

Code: [Select]
\\\\\ Appears in an explosion of a perfect ring of bullets, then rises up

script_enemy_main
{
let rf = GetCurrentScriptDirectory ~ "img\enemy.png";

let count = 0;
let count2 = 0;
let a = rand(0, 360);


#include_script "script\Frazer\Movement for red fairy.txt";
 
@Initialize
{
  SetLife(50);
  SetDamageRate(100, 100);

  LoadGraphic(rf);
  SetTexture(rf);
  SetGraphicRect(0,257,32,288);
  LoadUserShotData("script\Frazer\Shot.txt");
  }

@MainLoop
{
SetCollisionA(GetX, GetY, 16);
SetCollisionB(GetX, GetY, 8);

if(count == 1){
SetMovePosition02(GetX + 100, GetClipMinY + 50, 1);
}

if(count == 2){
loop(30){
CreateShot01(GetX, GetY, 3, a, 51, 5);

a += 12;
}
}

if(count == 60){
SetMovePosition01(GetX + 100, -500, 5);
}

if(GetY < GetClipMinY - 100){ VanishEnemy; }


count++;
count2++;

setgraphicmoverf;
}



@DrawLoop {
DrawGraphic(GetX, GetY);
}

@Finalize {

loop(5){
CreateItem(ITEM_SCORE, GetX + rand(-25, 25), GetY + rand(-25, 25));
}
}
}

Code: [Select]

\\\\\ Floats to the right side of the screen, firing intervals of bullets vertically

script_enemy_main
{
let yf = GetCurrentScriptDirectory ~ "img\enemy.png";

let start = rand_int(0, 30);
let count = start;
let alive = 0;


#include_script "script\Frazer\Movement for yellow fairy.txt";
 
@Initialize
{
  SetLife(150);
  SetDamageRate(100, 100);
  SetAngle(0);
  SetSpeed(3);

  LoadGraphic(yf);
  SetTexture(yf);
  SetGraphicRect(0,257,32,288);
  LoadUserShotData("script\Frazer\Shot.txt");
  }

@MainLoop
{
SetCollisionA(GetX, GetY, 16);
SetCollisionB(GetX, GetY, 8);

if(count == start+1){
  SetAngle(0);
  SetSpeed(3);
}

if(count%60 <= 30 && GetX < GetClipMaxX + 10){
PlaySE("script\Frazer\se\Shot7.wav");
CreateShot01(GetX, GetY, 3, 90, 30, 2);
CreateShot01(GetX, GetY, 3, 270, 30, 2);
}

if(GetX > GetClipMaxX + 100){alive=1; VanishEnemy;}


count++;

setgraphicmove;
}



@DrawLoop {
DrawGraphic(GetX, GetY);
}

@Finalize {

if(alive == 0){
loop(5){
CreateItem(ITEM_SCORE, GetX + rand(-25, 25), GetY + rand(-25, 25));
}
}
}
}


Stage script (only for seeing, trying to play it will involve tons of editing):
Code: [Select]
#TouhouDanmakufu[Stage]
#Title[Emotion Stage]
#Text[Frazer/Ilynine]
#ScriptVersion[2]

script_stage_main{

    function Wait( let frame ){ loop( frame ){ yield }; }
    function WaitForZeroEnemy(){
        while(GetEnemyNum() != 0){yield;}
    }

let x = 0;
let CSD = GetCurrentScriptDirectory;

    task StageTask{
if(GetPoint%100 == 1){SuperNaturalBorder(480);}
Wait(0);
PlayMusic(CSD ~ "Universe.mp3");
Wait(150);
loop(5){
Wait(5);
CreateEnemyFromFile(CSD ~ "enemy\Red fairy burst.txt", GetClipMinX + x, GetClipMinY - 100, 3, 0, 0);
x += 50;
}

Wait(420);
CreateEnemyFromFile(CSD ~ "enemy\Yellow fairy side.txt", GetClipMinX + 50, GetClipMinY - 24, 3, 0, 0);
CreateEnemyFromFile(CSD ~ "enemy\Yellow fairy side.txt", GetClipMaxX - 50, GetClipMinY - 24, 3, 0, 0);
Wait(180);
CreateEnemyFromFile(CSD ~ "enemy\Yellow fairy vertical.txt", GetClipMinX - 24, GetClipMinY + 50, 3, 0, 0);
CreateEnemyFromFile(CSD ~ "enemy\Yellow fairy vertical.txt", GetClipMinX - 24, GetClipMaxY - 50, 3, 0, 0);

Wait(6000);
CreateEnemyBossFromFile(CSD~"Emotion Boss.txt",GetCenterX,-50,0,0,0);

WaitForZeroEnemy();
Wait(120);
ClearStage;
      }

@Initialize(){
ExpertEx( true, 0, 3 );
StageTask();
}
@MainLoop(){ yield; }
@Finalize(){}

}
« Last Edit: February 04, 2010, 11:47:44 PM by Frazer »

DarkOverord

  • Damn Red Dragons
  • Aaaaaaaaaaaaaaaaargh
    • Lol YouTube
Re: Danmakufu Q&A/Problem Thread v3
« Reply #111 on: February 05, 2010, 12:13:17 AM »
This, is going to be a VERY stupid question. But hey. I've only been messing around with Danmakufu for a grand total of ~24hours (Including not messing around time)

Now thanks to Helepolis' tutorials I actually know the basics. Heck I actually made a spellcard, scrolling BG the lot. Now. Here's my problem. I'm trying to make lasers. Specifically using CreateLaserA, now I understand the parameters and all but. I seem to keep making this happen:

i.e. It's CONSTANTLY spawning lasers. Now, I realise this is probably something STUPIDLY simple, but I've tried shoving in "wait", loops, if's, nothing work. I'm doing it wrong and I have no idea how :V

I wouldn't mind but I nabbed that from the tutorial so now I'm REALLY confused.
http://www.youtube.com/user/DarkOverord <-- its wat cool ddes do rite :V

Re: Danmakufu Q&A/Problem Thread v3
« Reply #112 on: February 05, 2010, 12:16:30 AM »
This, is going to be a VERY stupid question. But hey. I've only been messing around with Danmakufu for a grand total of ~24hours (Including not messing around time)

Now thanks to Helepolis' tutorials I actually know the basics. Heck I actually made a spellcard, scrolling BG the lot. Now. Here's my problem. I'm trying to make lasers. Specifically using CreateLaserA, now I understand the parameters and all but. I seem to keep making this happen:

i.e. It's CONSTANTLY spawning lasers. Now, I realise this is probably something STUPIDLY simple, but I've tried shoving in "wait", loops, if's, nothing work. I'm doing it wrong and I have no idea how :V

I wouldn't mind but I nabbed that from the tutorial so now I'm REALLY confused.

Can you hand us the script to look at, please?

DarkOverord

  • Damn Red Dragons
  • Aaaaaaaaaaaaaaaaargh
    • Lol YouTube
Re: Danmakufu Q&A/Problem Thread v3
« Reply #113 on: February 05, 2010, 12:22:53 AM »
Can you hand us the script to look at, please?
Sure, it's not all that complicated, I'm only trying to fire 1 laser at a time XD
Code: [Select]
#TouhouDanmakufu
#Title[Dunno yet]
#Text[TEST YAY]
#Player[FREE]
#ScriptVersion[2]
#BGM[.\bgm\BorderofLife.mp3]

script_enemy_main{

let CSD = GetCurrentScriptDirectory;
let imgBoss = CSD ~ "system\boss17.png";
let cut = CSD ~ "system\yuyukocutin.png";
let bg = CSD ~ "system\bg.png";
let lay = CSD ~ "system\overlay.png";

let slide = 0;

let f = 0;
let f2 = 0;

@Initialize{
SetLife(1000);
SetMovePosition01(GetCenterX,120,5);

LoadGraphic(imgBoss);
LoadGraphic(cut);
LoadGraphic(bg);
LoadGraphic(lay);
LoadUserShotData(CSD ~ "system\supershot.txt");
}
@MainLoop{
MainTask;
yield;
}
@DrawLoop{
SetTexture(imgBoss);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);

if(int(GetSpeedX())==0){
if(f<10){SetGraphicRect(0,0,50,80);}
if(f>=10 && f<20){SetGraphicRect(0,80,50,160);}
f2=0;
}

if(int(GetSpeedX())>0){
if(f2<10){SetGraphicRect(50,80,100,160);}
if(f2>=10){SetGraphicRect(100,80,150,160);}
f2++;
}

if(int(GetSpeedX())<0){
SetGraphicAngle(180,0,0);
if(f2<10){SetGraphicRect(50,80,100,160); }
if(f2>=10){SetGraphicRect(100,80,150,160);}
f2++;
}

f++;
if(f==20){f=0;}
DrawGraphic(GetX,GetY);
}
@BackGround{
SetTexture(bg);
SetRenderState(ADD);
SetAlpha(225);
SetGraphicRect(0,0,512,512+slide);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetCenterX,GetCenterY);

slide+=5;

SetTexture(lay);
SetRenderState(ALPHA);
SetAlpha(225);
SetGraphicRect(0,0,512,512);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetCenterX,GetCenterY);
}
@Finalize{
DeleteGraphic(imgBoss);
DeleteGraphic(cut);
DeleteGraphic(bg);
}

task MainTask{
wait(60);
fire;
wait(300);
}

task fire{

CreateLaserA(0, GetX, GetY, 300, 20, 3,0);
SetLaserDataA(0, 0, 0, 2, 0, 0, 0);
SetShotKillTime(0, 90);
FireShot(0);
wait(300);
yield;



}

function wait(w){
loop(w){yield;}
}
}


You might wanna comment out the images, SE and BGM mind. Bonus DO's vain attempts to prevent this.
http://www.youtube.com/user/DarkOverord <-- its wat cool ddes do rite :V

Gc

  • youtu.be/pRZpjlrKM8A
Re: Danmakufu Q&A/Problem Thread v3
« Reply #114 on: February 05, 2010, 12:34:26 AM »
Code: [Select]
@MainLoop{
MainTask;
yield;
}
You start your MainTask every frame

EDIT:
You might also want to loop your MainTask like this :
Code: [Select]
   task MainTask{
      wait(60);
      loop{
         fire;
         wait(300);
      }
   }
« Last Edit: February 05, 2010, 12:41:33 AM by Gamecubic »

DarkOverord

  • Damn Red Dragons
  • Aaaaaaaaaaaaaaaaargh
    • Lol YouTube
Re: Danmakufu Q&A/Problem Thread v3
« Reply #115 on: February 05, 2010, 02:26:40 AM »
You start your MainTask every frame

EDIT:
You might also want to loop your MainTask like this :
Code: [Select]
   task MainTask{
      wait(60);
      loop{
         fire;
         wait(300);
      }
   }
I said it'd be something stupid didn't I? :V It occurred to me on this post, I'd put my call for MainTask in the wrong place.

Sometimes you've gotta make a fool of yourself to learn  8)

EDIT:

Sorry bout this. Another, more INTRIGUING puzzle this time. It's not stupid in my opinion. But it does seem like a potential Maths mishap on my end.

Now that my lasers are actually working, I can do this (Baring in mind the lasers are aimed, the lilac one to the Right of the player is -45degrees)


This is almost perfect, except I want the red laser roughly on that red dot.


But then I get this happen and I'm actually rather confused

CODE:
Code: [Select]
#TouhouDanmakufu
#Title[Dunno yet]
#Text[TEST YAY]
#Player[FREE]
#ScriptVersion[2]
#BGM[.\bgm\BorderofLife.mp3]

script_enemy_main{

let CSD = GetCurrentScriptDirectory;
let imgBoss = CSD ~ "system\boss17.png";
let cut = CSD ~ "system\yuyukocutin.png";
let bg = CSD ~ "system\bg.png";
let lay = CSD ~ "system\overlay.png";

let slide = 0;

let f = 0;
let f2 = 0;

@Initialize{
SetLife(1000);
SetMovePosition01(GetCenterX,120,5);

LoadGraphic(imgBoss);
LoadGraphic(cut);
LoadGraphic(bg);
LoadGraphic(lay);
LoadUserShotData(CSD ~ "system\supershot.txt");

MainTask;
}
@MainLoop{

yield;
}
@DrawLoop{
SetTexture(imgBoss);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);

if(int(GetSpeedX())==0){
if(f<10){SetGraphicRect(0,0,50,80);}
if(f>=10 && f<20){SetGraphicRect(0,80,50,160);}
f2=0;
}

if(int(GetSpeedX())>0){
if(f2<10){SetGraphicRect(50,80,100,160);}
if(f2>=10){SetGraphicRect(100,80,150,160);}
f2++;
}

if(int(GetSpeedX())<0){
SetGraphicAngle(180,0,0);
if(f2<10){SetGraphicRect(50,80,100,160); }
if(f2>=10){SetGraphicRect(100,80,150,160);}
f2++;
}

f++;
if(f==20){f=0;}
DrawGraphic(GetX,GetY);
}
@BackGround{
SetTexture(bg);
SetRenderState(ADD);
SetAlpha(225);
SetGraphicRect(0,0,512,512+slide);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetCenterX,GetCenterY);

slide+=5;

SetTexture(lay);
SetRenderState(ALPHA);
SetAlpha(225);
SetGraphicRect(0,0,512,512);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetCenterX,GetCenterY);
}
@Finalize{
DeleteGraphic(imgBoss);
DeleteGraphic(cut);
DeleteGraphic(bg);
}

task MainTask{
      wait(60);
      loop{
         fire;
         wait(300);
      }
   }

task fire{
let x=0;
let y=3;
let z=0;
loop{
let Angle = GetAngleToPlayer;
let dir = Angle-45;
while(x<4){
if(y==4){y=5}
CreateLaserA(0,GetEnemyX+50*cos(dir),GetEnemyY+50*sin(dir),500,20,y,75);
SetLaserDataA(0,0,Angle-45,0,0,0,0);
SetShotKillTime(0,220);

if(z==0){CreateLaserA(1,GetEnemyX*cos(dir-45),GetEnemyY+50*sin(dir-45),500,15,2,90);
SetLaserDataA(1,0,Angle,0,0,0,0);
SetShotKillTime(1,150);
FireShot(1);}
FireShot(0);

if(y==5){y=2};
y++;
x++;
Angle+=90;
dir+=90;
z++;
}
wait(200);
yield;
}


}

function wait(w){
loop(w){yield;}
}
}
Not complicated again admittedly.
http://www.youtube.com/user/DarkOverord <-- its wat cool ddes do rite :V

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #116 on: February 05, 2010, 11:08:55 AM »



You're using GetAngleToPlayer to aim that laser. Get AngleToPlayer is actually the angle from the boss to the player, not the bullet to the player.
You can fix it by writing it like:
CreateLaserA( stuff );
SetShotDirectionType(PLAYER);
SetLaserDataA( change GetAngleToPlayer to 0 );
SetShotDirectionType(ABSOLUTE);
FireShot( stuff );

SetShotDirectionType(PLAYER) makes an angle of 0 the angle from the bullet to the player.
While keeping it on the standard SetShotDirectionType(ABSOLUTE) makes an angle of 0 always point to the right.
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

DarkOverord

  • Damn Red Dragons
  • Aaaaaaaaaaaaaaaaargh
    • Lol YouTube
Re: Danmakufu Q&A/Problem Thread v3
« Reply #117 on: February 05, 2010, 11:39:07 AM »

You're using GetAngleToPlayer to aim that laser. Get AngleToPlayer is actually the angle from the boss to the player, not the bullet to the player.
You can fix it by writing it like:
CreateLaserA( stuff );
SetShotDirectionType(PLAYER);
SetLaserDataA( change GetAngleToPlayer to 0 );
SetShotDirectionType(ABSOLUTE);
FireShot( stuff );

SetShotDirectionType(PLAYER) makes an angle of 0 the angle from the bullet to the player.
While keeping it on the standard SetShotDirectionType(ABSOLUTE) makes an angle of 0 always point to the right.
Ah thanks. It was also a maths mishap that I've sorted. Just a quick question. Could I use these as object lasers and get them to spawn bullets where they hit the wall? (A Y/N answer would suffice, I'd like to try and do it myself before asking for help on that)
http://www.youtube.com/user/DarkOverord <-- its wat cool ddes do rite :V

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #118 on: February 05, 2010, 11:45:13 AM »
It's possible to do that with object lasers, however, it's rather quite advanced, so I suggest you really don't try that yet for a while :P

Ah thanks. It was also a maths mishap that I've sorted. Just a quick question. Could I use these as object lasers and get them to spawn bullets where they hit the wall? (A Y/N answer would suffice, I'd like to try and do it myself before asking for help on that)
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

DarkOverord

  • Damn Red Dragons
  • Aaaaaaaaaaaaaaaaargh
    • Lol YouTube
Re: Danmakufu Q&A/Problem Thread v3
« Reply #119 on: February 05, 2010, 11:52:52 AM »
It's possible to do that with object lasers, however, it's rather quite advanced, so I suggest you really don't try that yet for a while :P
Curses. That's what I wanted to do :V Just how complicated are we talking or should I just scrap that idea and use an object bullet for now :V?
http://www.youtube.com/user/DarkOverord <-- its wat cool ddes do rite :V