Maidens of the Kaleidoscope

~Hakurei Shrine~ => Rika and Nitori's Garage Experiments => Topic started by: Chronojet ⚙ Dragon on January 26, 2010, 01:54:13 AM

Title: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on January 26, 2010, 01:54:13 AM
I decided to do something helpful for this place for once, so... OK. So the 2nd thread hit 1000 posts. That was quick. So I'll start a new thread. (Will someone lock the previous thread? Thanks for locking the second thread.)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on January 26, 2010, 02:18:38 AM
Posting for updates
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: puremrz on January 26, 2010, 11:11:40 AM
As a reply to the enemy health problem.
Set the Life of the enemy to, say 1010. Then when it reaches below 1000, activate whatever event you want (such as deleting object effects), and after that set the Life to 0.
With over 1000 health, it won't be possible to kill the enemy in just 1 frame (except maybe with Godrumia :V )
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on January 26, 2010, 11:40:01 AM
As a reply to the enemy health problem.
Set the Life of the enemy to, say 1010. Then when it reaches below 1000, activate whatever event you want (such as deleting object effects), and after that set the Life to 0.
With over 1000 health, it won't be possible to kill the enemy in just 1 frame (except maybe with Godrumia :V )

the problem here is that the health bar at the top would be really weird...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kitsumi on January 26, 2010, 03:12:48 PM
I don't know if this should go here, but is there any way I could run Danmakufu without Applocale (can't install due to restrictions) or without switching to Japanese locale (not able to use a superuser account) in XP?
I want to be able to write and test my scripts when I'm at school.
 Thanks in advance.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on January 26, 2010, 04:31:25 PM
This is what you want. (http://www.mediafire.com/?jy4mmw2wifx)
There's one problem though, but I'm sure you can fix it easily. Every Japanese character of every script needs to be in english in order for it to run properly. If you don't, an error will occur and the program will shut down.

Note: This includes the player scripts. More specifically just the very beginnings of the scripts.
Code: [Select]
#TouhouDanmakufu
#Title[Japanese text usually written here, put it in English]
#Text[the same goes with the text]
#Player[default danmakufu characters(marisa and Reimu) won't bring error. IF you want to use a player made character, make sure that the japanese text is in english as well.]
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on January 26, 2010, 06:16:20 PM
This is what you want. (http://www.mediafire.com/?jy4mmw2wifx)
There's one problem though, but I'm sure you can fix it easily. Every Japanese character of every script needs to be in english in order for it to run properly. If you don't, an error will occur and the program will shut down.

Note: This includes the player scripts. More specifically just the very beginnings of the scripts.
Code: [Select]
#TouhouDanmakufu
#Title[Japanese text usually written here, put it in English]
#Text[the same goes with the text]
#Player[default danmakufu characters(marisa and Reimu) won't bring error. IF you want to use a player made character, make sure that the japanese text is in english as well.]
Ohohoho, This will come in handy, How long has this been existing?!?!?!?!
On another note....Regarding one of my earilier questions,
Error, The same one i've been getting, with Load; and Draw_;In my data.txt I have Load and Draw that loads and draws the boss, If I try to run a plural file with the bosses that have Load and Draw, It crashes
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DgBarca on January 26, 2010, 06:32:09 PM
Just...how to use Obj_SetCollisionToObject  ? Never used it, can we do a collision bullet/laser ?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on January 26, 2010, 09:07:56 PM
Just...how to use Obj_SetCollisionToObject  ? Never used it, can we do a collision bullet/laser ?

Obj_SetCollisionToObject(object1, true); makes the bullet heavier to process but allows you to use Collision_Obj_Obj(object1, object2); to see if the two things are colliding or not. Only the object in the first parameter of Collision_Obj_Obj has to have SetCollisionToObject as true.

This is handy if you want two different bullets to interact with each other in a specific way. For example, if you wanted bullets to bounce of lasers, you could create an array to hold all the IDs for the lasers that will bounced off of. Then, turn on collision in the task that controls the bullets and in the while(!Obj_BeDeleted(obj)) block, you can call

ascent(i in 0..length(LaserArray)){
    if(Collision_Obj_Obj(bullet, LaserArray[ i ]){
        // do stuff if the bullet is touching the laser
    }
}


EDIT: Lol it was treating the no space version of [ i ] as italics...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DgBarca on January 26, 2010, 09:23:02 PM
Obj_SetCollisionToObject(object1, true); makes the bullet heavier to process but allows you to use Collision_Obj_Obj(object1, object2); to see if the two things are colliding or not. Only the object in the first parameter of Collision_Obj_Obj has to have SetCollisionToObject as true.

This is handy if you want two different bullets to interact with each other in a specific way. For example, if you wanted bullets to bounce of lasers, you could create an array to hold all the IDs for the lasers that will bounced off of. Then, turn on collision in the task that controls the bullets and in the while(!Obj_BeDeleted(obj)) block, you can call

ascent(i in 0..length(LaserArray)){
    if(Collision_Obj_Obj(bullet, LaserArray[ i ]){
        // do stuff if the bullet is touching the laser
    }
}


EDIT: Lol it was treating the no space version of [ i ] as italics...

Okay thanks, I will see if it works (I guess it wants to say that the laser and the bullet have to be under the same task, nah ?, it will be long task(BulletX,BulletY,BulletAngle,BulletSpeed,BulletAccAngle,BulletGraphic,BulletDelay,LaserX,LaserY,LaserLenght,LaserWidth,LaserGraphic,Laserblablablabalbalablablbalabl...)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on January 26, 2010, 09:36:45 PM
I guess it wants to say that the laser and the bullet have to be under the same task, nah ?
Not at all.

You will simply have to create the object lasers in the main script and outside of the tasks. That way you can access them without any further problems.
You only have to store the object id in an accessable array, though. This means that you will simply create an empty array and then type a task that creates your object lasers and have it add the id of the laser to that array.

Just have this in your script_enemy_main
Code: [Select]
let obj_a=[Obj_Create(OBJ_LASER)];
Obj_Delete(obj_a[0]);
let obj_b=[];
Then create your usual object laser task, but include this line after the object creation:
Code: [Select]
obj_a[0]=obj;
obj_b=obj_b ~ obj_a;

Then you can simply give each bouncing bullet a bouncer code that runs once for each item in the array obj_b.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on January 26, 2010, 09:40:23 PM
Huh, is this what you are wanting to create, in a way?

Code: [Select]
#東方弾幕風
   #Title[SampleC04]
   #Text[SampleC04:レーザーに当たった弾の軌道を変える]
   #Image[]
   #BackGround[User]
   #ScriptVersion[2]
   
   script_enemy_main
   {
      let count= -90 ;//弾を出す間隔を制御するための変数
      let cx=GetCenterX();//変数cxに中心x座標を代入
      let cy=GetCenterY();//変数cxに中心y座標を代入
      let imgExRumia=GetCurrentScriptDirectory~"imgExRumia.png";
      let arrayLaser=[];//LaserObjectのオブジェクトを保存しておく
      @Initialize()
      {
         SetLife(1000);//敵のライフを1000に設定
         SetGraphicRect(64,1,127,64);//描画元の矩形を(64,1)-(127,64)に設定
         LoadGraphic(imgExRumia);//画像「imgExRumia.png」を読みこむ     
         SetMovePosition02(cx,cy,60);//座標(cx,60)に60フレームで移動
      }
         
      @MainLoop()
      {
         if(count>0 && count%10 == 0)
         {//30フレーム毎に弾をばらまく
            let angle = 0;
            while(angle<360)
            {
               ShotObject(GetX(), GetY(), 3, angle+count*5, AQUA21, 5);
               angle+=10;
            }
         }
         if(count == 60)
         {//弾の軌道を変えるレーザー作成
            LaserObject(0,RED01);
            LaserObject(1,BLUE01);
            LaserObject(2,GREEN01);
         }
         if(count == 360)
         {//レーザー削除
            let i=0;
            loop(length(arrayLaser))
            {
               ObjShot_FadeDelete(arrayLaser);
               i++;
            }           
            count=0;//カウンタを0にする
         }
   
         SetCollisionA(GetX(),GetY(),32);//敵の座標に当たり判定を登録
         SetCollisionB(GetX(),GetY(),24);//敵の座標に当たり判定(体当たり用)を登録
         count++;//1フレーム毎にcountが1増加
         yield;//毎フレームタスク復帰
      }
     
      @DrawLoop()
      {
         SetTexture(imgExRumia);
         DrawGraphic(GetX(),GetY());//敵の座標にExルーミアを描画;
      }
     
      @Finalize()
      {
         DeleteGraphic(imgExRumia);
      }
     
      task LaserObject(let num, let grf)
      {//弾の軌道を変えるレーザー
         //numは0-2のセットで敵を中心に三角形にレーザーを出現させる
         //レーザータスク初期化
         let r=120;
         let angle=210+120*num;
         let obj = Obj_Create(OBJ_LASER);
         arrayLaser = arrayLaser~[obj];//オブジェクトをarrayLaserに登録
         Obj_SetX(obj, GetX() + r*cos(angle-150));
         Obj_SetY(obj, GetY() + r*sin(angle-150));
         Obj_SetAngle(obj, angle);
         ObjShot_SetGraphic(obj, grf);
         ObjShot_SetDelay(obj, 120);//遅延時間:120フレーム
         ObjLaser_SetLength(obj, (3^0.5)*r);//円に内接する正三角形の辺の長さ:√3*r
         ObjLaser_SetWidth(obj, 12);//レーザーの幅:12
         while( !Obj_BeDeleted(obj) )
         {
            angle+=1;//レーザーを回転
            Obj_SetX(obj, GetX() + r*cos(angle-150));
            Obj_SetY(obj, GetY() + r*sin(angle-150));
            Obj_SetAngle(obj, angle);
            yield;
         }
         
         let i=0;
         loop(length(arrayLaser))
         {//オブジェクトを削除
            if(arrayLaser == obj)
            {//配列arrayLaserからi番目の要素を削除
               arrayLaser = erase(arrayLaser, i);
               break;
            }
            i++;
         }
      }
      task ShotObject(let x, let y, let speed, let angle, let grf, let delay)
      {//レーザーに当たったら軌道を変える弾
         //弾タスク初期化
         let obj = Obj_Create(OBJ_SHOT);
         Obj_SetX(obj, x);
         Obj_SetY(obj, y);
         Obj_SetSpeed(obj, speed);
         Obj_SetAngle(obj, angle);
         ObjShot_SetGraphic(obj, grf);
         ObjShot_SetDelay(obj, delay);
         
         while( !Obj_BeDeleted(obj) )
         {//削除されるまでループを実行   
            let i=0;
            loop(length(arrayLaser))
            {//レーザーとの当り判定を調査
               if(Collision_Obj_Obj(arrayLaser, obj))
               {//Laserと接触したら
               //連続で判定されないよう普通の弾と入れ替える
               //角度も変えておく
               //数フレーム触れないようにカウンタで管理してもよいかも
                  x = Obj_GetX(obj);
                  y = Obj_GetY(obj);
                  CreateShot01(x, y, 3, Obj_GetAngle(arrayLaser)-90, grf, 0);
                  Obj_Delete(obj);
                  break;
               }
               i++;
            }     
            yield;
         }
      }   
     
   }
 
it seems if I manually add the code code (lol) that it works, interesting...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on January 27, 2010, 04:32:05 AM
What. It seems you're talking about exactly what I needed.
Yayz, I can finish my extremely referential spell card

---How does one do the thing with the microtext?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on January 27, 2010, 04:51:07 AM
---How does one do the thing with the microtext?
What does that mean?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on January 27, 2010, 04:55:13 AM
---How does one do the thing with the microtext?
You can use
Code: (How to use really small unreadable text.) [Select]
[size=1pt]text test.[/size]
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kitsumi on January 27, 2010, 02:51:41 PM
This is what you want. (http://www.mediafire.com/?jy4mmw2wifx)
There's one problem though, but I'm sure you can fix it easily. Every Japanese character of every script needs to be in english in order for it to run properly. If you don't, an error will occur and the program will shut down.

Note: This includes the player scripts. More specifically just the very beginnings of the scripts.
Code: [Select]
#TouhouDanmakufu
#Title[Japanese text usually written here, put it in English]
#Text[the same goes with the text]
#Player[default danmakufu characters(marisa and Reimu) won't bring error. IF you want to use a player made character, make sure that the japanese text is in english as well.]
I really love you. Now I can do something productive in programming class when I'm done with my other projects.  :V Hopefully I'll get around to finishing some scripts.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on January 27, 2010, 03:07:18 PM
I really love you. Now I can do something productive in programming class when I'm done with my other projects.  :V Hopefully I'll get around to finishing some scripts.

something productive

Danmakufu is something productive? :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on January 27, 2010, 03:23:42 PM
When there is nothing else to do, yes, I was like that last semester in my Word Processing I class, I was done with a half semesters work done in 3 weeks, So I just coded on Notepad and sent them to myself to test at home, But now I can test them at school.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on January 27, 2010, 03:28:23 PM
Danmakufu is lyfe, I lose sleep daily because of it

No seriously

;_;
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on January 27, 2010, 03:45:33 PM
Danmakufu is lyfe, I lose sleep daily because of it

No seriously

;_;

You are not the only one. Sometimes I get really obsessed to finish something and then I realise it is suddenly 2am. FFFF---
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on January 27, 2010, 04:56:45 PM
You are not the only one. Sometimes I get really obsessed to finish something and then I realise it is suddenly 2am. FFFF---
Sometimes I get distracted and I work on my Danmakufu scripts rather than my homework.... Wait, what!? This isn't even a question! Quick! Ask a question!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Hat on January 27, 2010, 08:36:33 PM
Code: [Select]
#TouhouDanmakufu
#Title[Test]
#Text[FUCK FUCK FUCK FUCK FUCK FUCK FUCK]
#Player[FREE]
#ScriptVersion[2]
#BGM[]

script_enemy_main {
#include_function "lib\ExtendedShotDatav4\shot_replace.dnh"
    let ImgBoss = "script\img\ExRumia.png";
let pos_draw_a = GetX;

#include_function "lib\ExtendedShotDatav4\shot_replace.dnh"
    let ImgBoss = "script\img\ExRumia.png";
let pos_draw_a = GetX;
let fgovern = -120;
let up = GetClipMinY; let left = GetClipMinX; let right = GetClipMaxX; let down = GetClipMaxY; let wide = right-left; let long = down-up;
let govern1 = true;
let govern2;
let obja;
let tick1 = 0;
let array = [];
let counter = -1;
let obj1;
//------------------AUTUMN-------------------
task T1{
loop(120){yield;}
let f1 = 0;
T1a;
ascent(f1 in 0..1080){
SetShotAutoDeleteClip(200, 200, 200, 200);
if(f1>=50 && f1%100==0){T1c;}
yield;
}
}
function T1a{
ascent(i in 0..20){
T1b(i);
}
}
task T1b(let i){
let obj = Obj_Create(OBJ_LASER);
Obj_SetPosition(obj, GetClipMaxX, (GetClipMaxY/20)*i);
Obj_SetAngle(obj, 180);
ObjShot_SetGraphic(obj, RED01);
ObjLaser_SetLength(obj, 600);
ObjLaser_SetWidth(obj, 10);
loop{
let l = length(array);
ascent(xad in 0..l){
if(Collision_Obj_Obj(obj, array[xad])){
ObjShot_SetGraphic(obj, BLUE01);
}else{ObjShot_SetGraphic(obj, RED01);}
}
yield;
}
}
task T1c{
//Creates and destroys lasers every turn, while checking for collision.
let ticker = 0;
obj1 = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj1, GetCenterX, GetClipMinY);
Obj_SetAngle(obj1, 90);
Obj_SetSpeed(obj1, 2);
ObjShot_SetGraphic(obj1, WHITE03);
array = array~[obj1];
}

    @Initialize {
        SetLife(2000);
SetInvincibility(60);
        SetTimer(99);
        SetScore(1000000);

        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
        CutIn(YOUMU, "Test Sign "\""Test"\", "", 0, 0, 0, 0);

        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
T1;
ShotInit;
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
//ascent(xbs in 0..length(array)){array[xbs] = array[xbs] + 2;}
yield;
    }

    @DrawLoop {
if(GetX==pos_draw_a){
SetGraphicRect(0, 0, 64, 64);
        DrawGraphic(GetX, GetY);
}
if(GetX<pos_draw_a){
SetGraphicRect(128, 0, 192, 64);
DrawGraphic(GetX, GetY);
}
if(GetX>pos_draw_a){
SetGraphicRect(192, 0, 256, 64);
DrawGraphic(GetX, GetY);
}
pos_draw_a = GetX;
DrawText(ToString(length(array)), GetClipMinX, GetCenterY, 12, 255);
    }

    @Finalize {
        DeleteGraphic(ImgBoss);
    }
}

*screams* Okay, it should be sorta clear what I'm trying to attempt, and what is going wrong. It appears DMF doesn't want to check more than two objects at once. In fact, it seems that ascent function only wants to look at the last entry in the array..... >_< AAAAAH. So tired of working on this...

Though kudos to Naut for the idea of using arrays. :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on January 28, 2010, 12:36:51 AM
Let's take a look at your ascent function. Inside of it, you say "if you are colliding with the current bullet we're checking, set the graphic to BLUE01. If you are not, set the graphic to RED01." Well, it certainly performs all the checks correctly, until another bullet is spawned. The problem is, when the new bullet is spawned, there is a new entry in the very last index of the array, which is the last check it goes through. So it will check if it colliding with the last bullet spawned and say "Am I colliding with this particular bullet? Nope? Okay, change to RED01."

Easy solution was to just implement a counter variable that checks if it has ever changed to BLUE01 that frame, and then ignore all other commands:

Code: [Select]
#TouhouDanmakufu
#Title[Test]
#Text[FUCK FUCK FUCK FUCK FUCK FUCK FUCK]
#Player[FREE]
#ScriptVersion[2]
#BGM[]

script_enemy_main {
    let ImgBoss = "script\img\ExRumia.png";
   let pos_draw_a = GetX;
   
   let fgovern = -120;
   let up = GetClipMinY; let left = GetClipMinX; let right = GetClipMaxX; let down = GetClipMaxY; let wide = right-left; let long = down-up;
   let govern1 = true;
   let govern2;
   let obja;
   let tick1 = 0;
   let array = [];
   let counter = -1;
      //------------------AUTUMN-------------------
   task T1{
      loop(120){yield;}
      let f1 = 0;
      T1a;
      ascent(f1 in 0..1080){
         SetShotAutoDeleteClip(200, 200, 200, 200);
         if(f1>=50 && f1%100==0){T1c;}
         yield;
      }
   }
   function T1a{
   ascent(i in 0..20){
      T1b(i);
   }
   }
   task T1b(let i){
      let obj = Obj_Create(OBJ_LASER);
      Obj_SetPosition(obj, GetClipMaxX, (GetClipMaxY/20)*i);
      Obj_SetAngle(obj, 180);
      ObjShot_SetGraphic(obj, RED01);
      ObjLaser_SetLength(obj, 600);
      ObjLaser_SetWidth(obj, 10);
      loop{
         let l = length(array);
let arbitrarynumber = 0;
         ascent(xad in 0..l){
            if(Collision_Obj_Obj(obj, array[xad])){
               ObjShot_SetGraphic(obj, BLUE01);
       arbitrarynumber++;
}
if(arbitrarynumber==0){ObjShot_SetGraphic(obj, RED01);}
         }
         yield;
      }
   }
   task T1c{
   //Creates and destroys lasers every turn, while checking for collision.
      let obj1 = Obj_Create(OBJ_SHOT);
      Obj_SetPosition(obj1, GetCenterX, GetClipMinY);
      Obj_SetAngle(obj1, 90);
      Obj_SetSpeed(obj1, 2);
      ObjShot_SetGraphic(obj1, WHITE03);
      array = array~[obj1];
   }

    @Initialize {
        SetLife(2000);
      SetInvincibility(60);
        SetTimer(99);
        SetScore(1000000);

        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
        CutIn(YOUMU, "Test Sign "\""Test"\", "", 0, 0, 0, 0);

        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
      T1;
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
      //ascent(xbs in 0..length(array)){array[xbs] = array[xbs] + 2;}
      yield;
    }

    @DrawLoop {
      if(GetX==pos_draw_a){
      SetGraphicRect(0, 0, 64, 64);
        DrawGraphic(GetX, GetY);
      }
      if(GetX<pos_draw_a){
      SetGraphicRect(128, 0, 192, 64);
      DrawGraphic(GetX, GetY);
      }
      if(GetX>pos_draw_a){
      SetGraphicRect(192, 0, 256, 64);
      DrawGraphic(GetX, GetY);
      }
      pos_draw_a = GetX;
      DrawText(ToString(length(array)), GetClipMinX, GetCenterY, 12, 255);
    }

    @Finalize {
        DeleteGraphic(ImgBoss);
    }
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Hat on January 28, 2010, 03:43:45 AM
..........

.............. screw Kanako, you should be the new god of the frickin' Moriya shrine. :V and i shall be your Sanae
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on January 28, 2010, 05:08:09 AM
Huh, is this what you are wanting to create, in a way?

Code: [Select]
#東方弾幕風
   #Title[SampleC04]
   #Text[SampleC04:レーザーに当たった弾の軌道を変える]
   #Image[]
   #BackGround[User]
   #ScriptVersion[2]
   
   script_enemy_main
   {
      let count= -90 ;//弾を出す間隔を制御するための変数
      let cx=GetCenterX();//変数cxに中心x座標を代入
      let cy=GetCenterY();//変数cxに中心y座標を代入
      let imgExRumia=GetCurrentScriptDirectory~"imgExRumia.png";
      let arrayLaser=[];//LaserObjectのオブジェクトを保存しておく
      @Initialize()
      {
         SetLife(1000);//敵のライフを1000に設定
         SetGraphicRect(64,1,127,64);//描画元の矩形を(64,1)-(127,64)に設定
         LoadGraphic(imgExRumia);//画像「imgExRumia.png」を読みこむ     
         SetMovePosition02(cx,cy,60);//座標(cx,60)に60フレームで移動
      }
         
      @MainLoop()
      {
         if(count>0 && count%10 == 0)
         {//30フレーム毎に弾をばらまく
            let angle = 0;
            while(angle<360)
            {
               ShotObject(GetX(), GetY(), 3, angle+count*5, AQUA21, 5);
               angle+=10;
            }
         }
         if(count == 60)
         {//弾の軌道を変えるレーザー作成
            LaserObject(0,RED01);
            LaserObject(1,BLUE01);
            LaserObject(2,GREEN01);
         }
         if(count == 360)
         {//レーザー削除
            let i=0;
            loop(length(arrayLaser))
            {
               ObjShot_FadeDelete(arrayLaser);
               i++;
            }           
            count=0;//カウンタを0にする
         }
   
         SetCollisionA(GetX(),GetY(),32);//敵の座標に当たり判定を登録
         SetCollisionB(GetX(),GetY(),24);//敵の座標に当たり判定(体当たり用)を登録
         count++;//1フレーム毎にcountが1増加
         yield;//毎フレームタスク復帰
      }
     
      @DrawLoop()
      {
         SetTexture(imgExRumia);
         DrawGraphic(GetX(),GetY());//敵の座標にExルーミアを描画;
      }
     
      @Finalize()
      {
         DeleteGraphic(imgExRumia);
      }
     
      task LaserObject(let num, let grf)
      {//弾の軌道を変えるレーザー
         //numは0-2のセットで敵を中心に三角形にレーザーを出現させる
         //レーザータスク初期化
         let r=120;
         let angle=210+120*num;
         let obj = Obj_Create(OBJ_LASER);
         arrayLaser = arrayLaser~[obj];//オブジェクトをarrayLaserに登録
         Obj_SetX(obj, GetX() + r*cos(angle-150));
         Obj_SetY(obj, GetY() + r*sin(angle-150));
         Obj_SetAngle(obj, angle);
         ObjShot_SetGraphic(obj, grf);
         ObjShot_SetDelay(obj, 120);//遅延時間:120フレーム
         ObjLaser_SetLength(obj, (3^0.5)*r);//円に内接する正三角形の辺の長さ:√3*r
         ObjLaser_SetWidth(obj, 12);//レーザーの幅:12
         while( !Obj_BeDeleted(obj) )
         {
            angle+=1;//レーザーを回転
            Obj_SetX(obj, GetX() + r*cos(angle-150));
            Obj_SetY(obj, GetY() + r*sin(angle-150));
            Obj_SetAngle(obj, angle);
            yield;
         }
         
         let i=0;
         loop(length(arrayLaser))
         {//オブジェクトを削除
            if(arrayLaser == obj)
            {//配列arrayLaserからi番目の要素を削除
               arrayLaser = erase(arrayLaser, i);
               break;
            }
            i++;
         }
      }
      task ShotObject(let x, let y, let speed, let angle, let grf, let delay)
      {//レーザーに当たったら軌道を変える弾
         //弾タスク初期化
         let obj = Obj_Create(OBJ_SHOT);
         Obj_SetX(obj, x);
         Obj_SetY(obj, y);
         Obj_SetSpeed(obj, speed);
         Obj_SetAngle(obj, angle);
         ObjShot_SetGraphic(obj, grf);
         ObjShot_SetDelay(obj, delay);
         
         while( !Obj_BeDeleted(obj) )
         {//削除されるまでループを実行   
            let i=0;
            loop(length(arrayLaser))
            {//レーザーとの当り判定を調査
               if(Collision_Obj_Obj(arrayLaser, obj))
               {//Laserと接触したら
               //連続で判定されないよう普通の弾と入れ替える
               //角度も変えておく
               //数フレーム触れないようにカウンタで管理してもよいかも
                  x = Obj_GetX(obj);
                  y = Obj_GetY(obj);
                  CreateShot01(x, y, 3, Obj_GetAngle(arrayLaser)-90, grf, 0);
                  Obj_Delete(obj);
                  break;
               }
               i++;
            }     
            yield;
         }
      }   
     
   }
 
it seems if I manually add the code code (lol) that it works, interesting...

Wait. Does this actually work?
I tried it out and... The lasers aren't doing anything.

Does this mean my computer has been messed up with Danmakufu the whole time? ;_;
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on January 28, 2010, 07:54:43 PM
A quick question: If... wait, no, I just figured out a workaround.

Anyway, different question. Back to the object laser business. Do I have to define them all in an array, or can I do it some other way?

Oh, and another thing: So I've been tweaking Assault Wall, and now I have this...
Code: [Select]
#TouhouDanmakufu
#Title[Assault Wall "Geisterwand"]
#Text[Boxed in by bullets!]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{

let CSD = GetCurrentScriptDirectory;
let imgBoss = CSD ~ "Materials\Graphics\PlaceholderBoss.png";
let spellback = CSD ~ "Materials\Graphics\SpellBack.png";
#include_function CSD ~ "lib\ExpandedShotDatav4\shot_replace.dnh";
let slider = 0;

@Initialize{
SetLife(1000);
SetDamageRate(0,0);
SetTimer(90);
SetScore(1000);
SetMovePosition01(GetCenterX,GetCenterY-90,5);
LoadGraphic(imgBoss);
LoadGraphic(spellback);
ShotInit;
CutIn(KOUMA,"Assault Wall "\""Geisterwand"\","",0,0,0,0);
mainTask;
PlayMusic(CSD ~ "Materials\Music\33.mp3");
}

@MainLoop{
SetCollisionA(GetX,GetY,32);
SetCollisionB(GetX,GetY,16);
yield;
}

@DrawLoop{

SetTexture(imgBoss);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicRect(0,0,64,64);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetX,GetY);

}

@BackGround{

SetTexture(spellback);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicRect(0,0,448,768+slider);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetCenterX,GetCenterY);
slider+=2;

}

@Finalize{

DeleteGraphic(imgBoss);
DeleteGraphic(spellback);

}
task mainTask{
drop;
//randomly choose a type of wall at the start
let walltype = rand_int(1,4);
wait(120);
yield;
//Cast Geisterwand Defense
Ghost;
loop{
alternative(walltype)
case(1){
red;
}
case(2){
yellow;
}
case(3){
blue;
}
case(4){
green;
}
case(5){
white;
}
case(6){
aqua;
}
case(7){
orange;
}
case(8){
purple;
}
others{yield;}
wait(30);
if(GetTimer<=30){yield;
}else{
if(GetTimer<=60){
wait(30);
}else{
wait(60);
}
}
walltype = rand_int(1,4);
if(GetTimer<=4*90/5){
walltype = rand_int(1,5);
}
if(GetTimer<=3*90/5){
walltype = rand_int(1,6);
}
if(GetTimer<=2*90/5){
walltype = rand_int(1,7);
}
if(GetTimer<=90/5){
walltype = rand_int(1,8);
}
yield;
}
}

task blue{
let startside = rand_int(1,3);
alternative(startside)
case(1){
CreateEnemyFromScript("BlueWall",0,rand_int(0,480),0,0,1);
}
case(2){
CreateEnemyFromScript("BlueWall",rand_int(0,448),0,0,0,2);
}
case(3){
CreateEnemyFromScript("BlueWall",448,rand_int(0,480),0,0,1);
}
others{}
yield;
}

task red{
let startside = rand_int(1,3);
alternative(startside)
case(1){
CreateEnemyFromScript("RedWall",0,rand_int(0,480),0,0,1);
}
case(2){
CreateEnemyFromScript("RedWall",rand_int(0,448),0,0,0,2);
}
case(3){
CreateEnemyFromScript("RedWall",448,rand_int(0,480),0,0,3);
}
others{}
yield;
}

task yellow{
let startside = rand_int(1,3);
alternative(startside)
case(1){
CreateEnemyFromScript("YlwWall",0,rand_int(0,480),0,0,1);
}
case(2){
CreateEnemyFromScript("YlwWall",rand_int(0,448),0,0,0,2);
}
case(3){
CreateEnemyFromScript("YlwWall",448,rand_int(0,480),0,0,1);
}
others{}
yield;
}

task green{
let startside = rand_int(1,3);
alternative(startside)
case(1){
CreateEnemyFromScript("GreenWall",0,rand_int(0,480),0,0,1);
}
case(2){
CreateEnemyFromScript("GreenWall",rand_int(0,448),0,0,0,2);
}
case(3){
CreateEnemyFromScript("GreenWall",448,rand_int(0,480),0,0,1);
}
others{}
yield;
}

task white{
let startside = rand_int(1,3);
alternative(startside)
case(1){
CreateEnemyFromScript("WhiteWall",0,rand_int(0,480),0,0,1);
}
case(2){
CreateEnemyFromScript("WhiteWall",rand_int(0,448),0,0,0,2);
}
case(3){
CreateEnemyFromScript("WhiteWall",448,rand_int(0,480),0,0,1);
}
others{}
yield;
}

task aqua{
let startside = rand_int(1,3);
alternative(startside)
case(1){
CreateEnemyFromScript("AquaWall",0,rand_int(0,480),0,0,1);
}
case(2){
CreateEnemyFromScript("AquaWall",rand_int(0,448),0,0,0,2);
}
case(3){
CreateEnemyFromScript("AquaWall",448,rand_int(0,480),0,0,1);
}
others{}
yield;
}

task purple{
let startside = rand_int(1,3);
alternative(startside)
case(1){
CreateEnemyFromScript("PrplWall",0,rand_int(0,480),0,0,1);
}
case(2){
CreateEnemyFromScript("PrplWall",rand_int(0,448),0,0,0,2);
}
case(3){
CreateEnemyFromScript("PrplWall",448,rand_int(0,480),0,0,1);
}
others{}
yield;
}

task orange{
let startside = rand_int(1,3);
alternative(startside)
case(1){
CreateEnemyFromScript("OrangeWall",0,rand_int(0,480),0,0,1);
}
case(2){
CreateEnemyFromScript("OrangeWall",rand_int(0,448),0,0,0,2);
}
case(3){
CreateEnemyFromScript("OrangeWall",448,rand_int(0,480),0,0,1);
}
others{}
yield;
}

sub Ghost{
CreateEnemyFromScript("maceFam",GetEnemyX+50*cos(0),GetEnemyY+50*sin(0),0,0,0);
CreateEnemyFromScript("maceFam",GetEnemyX+50*cos(60),GetEnemyY+50*sin(60),0,0,60);
CreateEnemyFromScript("maceFam",GetEnemyX+50*cos(120),GetEnemyY+50*sin(120),0,0,120);
CreateEnemyFromScript("maceFam",GetEnemyX+50*cos(180),GetEnemyY+50*sin(180),0,0,180);
CreateEnemyFromScript("maceFam",GetEnemyX+50*cos(240),GetEnemyY+50*sin(240),0,0,240);
CreateEnemyFromScript("maceFam",GetEnemyX+50*cos(360),GetEnemyY+50*sin(0),0,0,300);
}

task drop{
yield;
}

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

}

//Travels in a straight line and lays down a wall of bullets
//After 2 seconds, bullets will fly at whatever the player's position was when the bullet was planted
script_enemy BlueWall{

let CSD = GetCurrentScriptDirectory;
let imgFamB = CSD ~ "Materials\Graphics\DMF_fam.png";
#include_function "lib\ExpandedShotDatav4\shot_replace.dnh";
let frame = 0;
let startside = GetArgument;

@Initialize{
SetLife(500);
SetDamageRate(50,0);
LoadGraphic(imgFamB);
ShotInit;
maintask;

}

@MainLoop{
yield;
}

@DrawLoop{
SetTexture(imgFamB);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
SetGraphicRect(8,8,39,39);
DrawGraphic(GetX,GetY);
}

@Finalize{
DeleteGraphic(imgFamB);
}

function wait(n){
loop(n){yield}
}

task maintask{
wall;
alternative(startside)
case(1){
SetMovePosition02(448,rand_int(0,480),90);
}
case(2){
SetMovePosition02(rand_int(0,448),480,90);
}
case(3){
SetMovePosition02(0,rand_int(0,480),90);
}
wait(210);
VanishEnemy;
}

task wall{
while(GetSpeed>0){
CreateShotA(1,GetX,GetY,0);
SetShotDataA(1,0,0,GetAngleToPlayer,0,0,0,BLUE01);
SetShotDataA(1,120,1,NULL,0,0,0,BLUE01);
FireShot(1);
wait(5);
yield;
}
}
}

//Travels in a straight line and lays down a wall of bullets
//After 2 seconds, bullets will fly directly at the player
script_enemy RedWall{

let CSD = GetCurrentScriptDirectory;
let imgFamR = CSD ~ "Materials\Graphics\DMF_fam.png";
#include_function "lib\ExpandedShotDatav4\shot_replace.dnh";
let frame = 0;
let startside = GetArgument;

@Initialize{
SetLife(500);
SetDamageRate(50,0);
LoadGraphic(imgFamR);
ShotInit;
maintask;

}

@MainLoop{
yield;
}

@DrawLoop{
SetTexture(imgFamR);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
SetGraphicRect(56,8,87,39);
DrawGraphic(GetX,GetY);
}

@Finalize{
DeleteGraphic(imgFamR);
}

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

task maintask{
wall;
alternative(startside)
case(1){
SetMovePosition02(448,rand_int(0,480),90);
}
case(2){
SetMovePosition02(rand_int(0,448),480,90);
}
case(3){
SetMovePosition02(0,rand_int(0,480),90);
}
wait(210);
VanishEnemy;
}

task wall{
while(GetSpeed>0){
redshot;
wait(5);
yield;
}
}

task redshot{
let redb = Obj_Create(OBJ_SHOT);
Obj_SetPosition(redb,GetX,GetY);
Obj_SetSpeed(redb,0);
Obj_SetAngle(redb,0);
ObjShot_SetGraphic(redb,RED01);

while(!Obj_BeDeleted(redb)){
wait(120);
Obj_SetAngle(redb,atan2(GetPlayerY-Obj_GetY(redb),GetPlayerX-Obj_GetX(redb)));
Obj_SetSpeed(redb,1);
yield;
}
}
}

//Moves in a straight line and leaves a wall of bullets
//Bullets left by YlwWall split and fly at an angle
script_enemy YlwWall{

let CSD = GetCurrentScriptDirectory;
let imgFamY = CSD ~ "Materials\Graphics\DMF_fam.png";
#include_function "lib\ExpandedShotDatav4\shot_replace.dnh";
let frame = 0;
let startside = GetArgument;

@Initialize{
SetLife(500);
SetDamageRate(50,0);
LoadGraphic(imgFamY);
ShotInit;
maintask;

}

@MainLoop{
yield;
}

@DrawLoop{
SetTexture(imgFamY);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
SetGraphicRect(152,8,183,39);
DrawGraphic(GetX,GetY);
}

@Finalize{
DeleteGraphic(imgFamY);
}

function wait(n){
loop(n){yield}
}

task maintask{
wall;
alternative(startside)
case(1){
SetMovePosition02(448,rand_int(0,480),90);
}
case(2){
SetMovePosition02(rand_int(0,448),480,90);
}
case(3){
SetMovePosition02(0,rand_int(0,480),90);
}
wait(210);
VanishEnemy;
}

task wall{
while(GetSpeed>0){
ylwshot;
wait(5);
yield;
}
}

task ylwshot{
let angle = GetAngle;
PlaySE(CSD ~ "Materials\SoundEffects\shot.wav");
let ylsplit = Obj_Create(OBJ_SHOT);
ObjShot_SetGraphic(ylsplit,YELLOW01);
Obj_SetSpeed(ylsplit,0);
Obj_SetAngle(ylsplit,angle+25);
Obj_SetPosition(ylsplit,GetX,GetY);
while(!Obj_BeDeleted(ylsplit)){
wait(120);
CreateShot01(Obj_GetX(ylsplit),Obj_GetY(ylsplit),1.3,angle-25,YELLOW01,0);
Obj_SetSpeed(ylsplit,1.3);
}
}
}

//Travels in a straight line and leaves a wall of bullets
//After 2 seconds, bullets explode into randomly angled lasers
script_enemy GreenWall{

let CSD = GetCurrentScriptDirectory;
let imgFamG = CSD ~ "Materials\Graphics\DMF_fam.png";
#include_function "lib\ExpandedShotDatav4\shot_replace.dnh";
let frame = 0;
let startside = GetArgument;

@Initialize{
SetLife(500);
SetDamageRate(50,0);
LoadGraphic(imgFamG);
ShotInit;
maintask;

}

@MainLoop{
yield;
}

@DrawLoop{
SetTexture(imgFamG);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
SetGraphicRect(104,8,135,39);
DrawGraphic(GetX,GetY);
}

@Finalize{
DeleteGraphic(imgFamG);
}

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

task maintask{
wall;
alternative(startside)
case(1){
SetMovePosition02(448,rand_int(0,480),90);
}
case(2){
SetMovePosition02(rand_int(0,448),480,90);
}
case(3){
SetMovePosition02(0,rand_int(0,480),90);
}
wait(210);
VanishEnemy;
}

task wall{
while(GetSpeed>0){
greenshot;
wait(5);
yield;
}
}

task greenshot{
let lasangle = rand_int(0,359);
let grn = Obj_Create(OBJ_SHOT);
Obj_SetPosition(grn,GetX,GetY);
Obj_SetAngle(grn,0);
ObjShot_SetGraphic(grn,GREEN01);
ObjShot_SetDelay(grn,0);
while(!Obj_BeDeleted(grn)){
wait(120);
PlaySE(CSD ~ "Materials\SoundEffects\shot.wav");
loop(5){
CreateLaser01(Obj_GetX(grn),Obj_GetY(grn),2,lasangle,20,5,GREEN21,0);
lasangle = rand_int(0,359);
}
Obj_Delete(grn);
}
}
}

//Travels in a straight line and lays down a wall of bullets
//WhiteWall fires lasers perpendicular to the path
script_enemy WhiteWall{

let CSD = GetCurrentScriptDirectory;
let imgFamW = CSD ~ "Materials\Graphics\DMF_faml.png";
#include_function "lib\ExpandedShotDatav4\shot_replace.dnh";
let frame = 0;
let startside = GetArgument;

@Initialize{
SetLife(500);
SetDamageRate(50,0);
LoadGraphic(imgFamW);
ShotInit;
maintask;

}

@MainLoop{
yield;
}

@DrawLoop{
SetTexture(imgFamW);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
SetGraphicRect(8,8,39,39);
DrawGraphic(GetX,GetY);
}

@Finalize{
DeleteGraphic(imgFamW);
}

function wait(n){
loop(n){yield}
}

task maintask{
wall;
alternative(startside)
case(1){
SetMovePosition02(448,rand_int(0,480),90);
}
case(2){
SetMovePosition02(rand_int(0,448),480,90);
}
case(3){
SetMovePosition02(0,rand_int(0,480),90);
}
wait(210);
VanishEnemy;
}

task wall{
while(GetSpeed>0){
white;
wait(5);
yield;
}
}

task white{
let angle = GetAngle;
let wht = Obj_Create(OBJ_SHOT);
Obj_SetPosition(wht,GetX,GetY);
Obj_SetSpeed(wht,0);
ObjShot_SetGraphic(wht,WHITE01);
Obj_SetAngle(wht,0);
ObjShot_SetDelay(wht,0);
while(!Obj_BeDeleted(wht)){
wait(120);
CreateLaserA(1,Obj_GetX(wht),Obj_GetY(wht),500,8,WHITE47,10);
SetLaserDataA(1,0,angle+90,0,0,0,0);
CreateLaserA(2,Obj_GetX(wht),Obj_GetY(wht),500,8,WHITE47,10);
SetLaserDataA(2,0,angle-90,0,0,0,0);
PlaySE(CSD ~ "Materials\SoundEffects\laser.wav");
SetShotKillTime(1,40);
SetShotKillTime(2,40);
FireShot(1);
FireShot(2);
Obj_Delete(wht);
}
}
}

//Travels in a straight line and lays down a wall of bullets
//AquaWall bullets fire in a curved line
script_enemy AquaWall{

let CSD = GetCurrentScriptDirectory;
let imgFamA = CSD ~ "Materials\Graphics\DMF_faml.png";
#include_function "lib\ExpandedShotDatav4\shot_replace.dnh";
let frame = 0;
let startside = GetArgument;

@Initialize{
SetLife(500);
SetDamageRate(50,0);
LoadGraphic(imgFamA);
ShotInit;
maintask;

}

@MainLoop{
yield;
}

@DrawLoop{
SetTexture(imgFamA);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
SetGraphicRect(56,8,87,39);
DrawGraphic(GetX,GetY);
}

@Finalize{
DeleteGraphic(imgFamA);
}

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

task maintask{
wall;
alternative(startside)
case(1){
SetMovePosition02(448,rand_int(0,480),90);
}
case(2){
SetMovePosition02(rand_int(0,448),480,90);
}
case(3){
SetMovePosition02(0,rand_int(0,480),90);
}
wait(210);
VanishEnemy;
}

task wall{
let curvature = 0.1;
while(GetSpeed>0){
aquashot(curvature);
wait(5);
curvature+=0.1;
yield;
}
}

task aquashot(curvature){
CreateShotA(1,GetX,GetY,0);
SetShotDataA(1,0,0,GetAngle,0,0,0,AQUA01);
SetShotDataA(1,120,1,NULL,curvature,0,0,AQUA01);
FireShot(1);
wait(120);
PlaySE(CSD ~ "Materials\SoundEffects\effect.wav");
}
}

//Moves in a straight line and leaves a wall of bullets
//I don't yet know what this will do.
script_enemy PrplWall{

let CSD = GetCurrentScriptDirectory;
let imgFamP = CSD ~ "Materials\Graphics\DMF_faml.png";
#include_function "lib\ExpandedShotDatav4\shot_replace.dnh";
let frame = 0;
let startside = GetArgument;

@Initialize{
SetLife(500);
SetDamageRate(50,0);
LoadGraphic(imgFamP);
ShotInit;
maintask;

}

@MainLoop{
yield;
}

@DrawLoop{
SetTexture(imgFamP);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
SetGraphicRect(152,8,183,39);
DrawGraphic(GetX,GetY);
}

@Finalize{
DeleteGraphic(imgFamP);
}

function wait(n){
loop(n){yield}
}

task maintask{
wall;
alternative(startside)
case(1){
SetMovePosition02(448,rand_int(0,480),90);
}
case(2){
SetMovePosition02(rand_int(0,448),480,90);
}
case(3){
SetMovePosition02(0,rand_int(0,480),90);
}
wait(210);
VanishEnemy;
}

task wall{
let baseangle = 45;
while(GetSpeed>0){
prplshot(baseangle);
wait(5);
baseangle-=3;
yield;
}
}

task prplshot(baseangle){
CreateShotA(1,GetX,GetY,0);
SetShotDataA(1,0,0,GetAngle,0,0,0,PURPLE01);
SetShotKillTime(1,240);
CreateLaserA(2,GetX,GetY,30,8,PURPLE41,5);
SetLaserDataA(2,0,baseangle,0.2,0,0,0);
FireShot(1);
AddShot(115,1,2,0);
wait(120);
PlaySE(CSD ~ "Materials\SoundEffects\laser.wav");
}
}

//Travels in a straight line and leaves a wall of bullets
//Bullets fire a laser that blocks the wall temporarily
script_enemy OrangeWall{

let CSD = GetCurrentScriptDirectory;
let imgFamO = CSD ~ "Materials\Graphics\DMF_faml.png";
#include_function "lib\ExpandedShotDatav4\shot_replace.dnh";
let frame = 0;
let startside = GetArgument;

@Initialize{
SetLife(500);
SetDamageRate(50,0);
LoadGraphic(imgFamO);
ShotInit;
maintask;

}

@MainLoop{
yield;
}

@DrawLoop{
SetTexture(imgFamO);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
SetGraphicRect(104,8,135,39);
DrawGraphic(GetX,GetY);
}

@Finalize{
DeleteGraphic(imgFamO);
}

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

task maintask{
wall;
alternative(startside)
case(1){
SetMovePosition02(448,rand_int(0,480),90);
}
case(2){
SetMovePosition02(rand_int(0,448),480,90);
}
case(3){
SetMovePosition02(0,rand_int(0,480),90);
}
wait(210);
VanishEnemy;
}

task wall{
while(GetSpeed>0){
oranshot;
wait(5);
yield;
}
}

task oranshot{
let lasangle = GetAngle;
let oran = Obj_Create(OBJ_SHOT);
Obj_SetPosition(oran,GetX,GetY);
Obj_SetAngle(oran,GetAngle);
ObjShot_SetGraphic(oran,ORANGE01);
ObjShot_SetDelay(oran,0);
while(!Obj_BeDeleted(oran)){
wait(120);
PlaySE(CSD ~ "Materials\SoundEffects\laser.wav");
CreateLaserA(1,Obj_GetX(oran),Obj_GetY(oran),500,8,ORANGE47,10);
SetLaserDataA(1,0,lasangle,0,0,0,0);
SetShotKillTime(1,40);
FireShot(1);
CreateLaserA(2,Obj_GetX(oran),Obj_GetY(oran),500,8,ORANGE47,10);
SetLaserDataA(2,0,lasangle+180,0,0,0,0);
SetShotKillTime(2,40);
FireShot(2);
wait(20);
Obj_Delete(oran);
}
}
}

//Geisterwand Mace Shield
script_enemy maceFam{

let CSD = GetCurrentScriptDirectory;
let imgFam = CSD ~ "Materials\Graphics\GeisterwandSprite.png";
#include_function "lib\ExpandedShotDatav4\shot_replace.dnh";
let dir = GetArgument;
let r = 50;
let spin = GetArgument+90;
let frame = 0;

@Initialize{
SetLife(1);
SetDamageRate(0,0);
LoadGraphic(imgFam);
ShotInit;
maintask;

}

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

@DrawLoop{
SetTexture(imgFam);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,spin);
SetGraphicRect(0,0,30,31);
DrawGraphic(GetX,GetY);

spin+=5;

}

@Finalize{
DeleteGraphic(imgFam);
}

task maintask{
yield;
move;
}

task move{
loop{
//shoot direction of movement and 30 degrees off every 15 frames
if(frame == 7){
PlaySE(CSD ~ "Materials\SoundEffects\shot.wav");
CreateShot01(GetX,GetY,3,dir+90,WHITE12I,0);
frame = 0;
}
SetMovePosition03(GetEnemyX+3*r*cos(dir),GetEnemyY+3*r*sin(dir),20,10);
dir+=5;
frame++;
r=50+10*sin(frame);
yield;
}
}

function wait(n){
loop(n){yield;}
}
}
There are a couple of problems with this script as it is...
First and foremost: Except for the black bullets from the mace... things (no one seems to agree on just what those are), no bullets show up. Ever. Is GetSpeed incompatible with SetMovePosition02 or something?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on January 28, 2010, 10:38:35 PM
I think you want GetSpeedX
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on January 28, 2010, 11:23:39 PM
I think you want GetSpeedX
There is no GetSpeedX
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on January 28, 2010, 11:42:43 PM
Yes, there is. I like to use while(GetSpeedX!=0) { yield; } to delay my tasks until the boss is done moving.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on January 29, 2010, 12:08:58 AM
Huh. Well the Wiki doesn't have it...

Oh, it was in Enemy Control instead of Mathematical and Information.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on January 29, 2010, 12:16:07 AM
They're right, GetSpeedX exists.

However, GetSpeed gets the exact pixel-per-frame angle-speed of the enemy, whereas GetSpeedX returns -1 as long as it's moving left, returns 1 as long as you're moving right, and 0 if you are not moving whatsoever.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on January 29, 2010, 01:23:29 AM
Okay... Now, about global variables.

I need to have a variable called, say, alltogether, to determine whether or not the effect of the pattern takes place over time or all at once, but the argument is tied up getting the side the familiar is starting on.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on January 29, 2010, 01:25:23 AM
SetCommonData("variablename", alltogether);

And where ever you need to get the variable:

GetCommonData("variablename");
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on January 29, 2010, 03:42:12 AM
Hey guys, just want to let you know something.

Ever notice how when using effect objects, whenever you set them as alpha rendering, whenever you set the alpha value in ObjEffect_SetVertexColor to a lower value, it seams like the RBG colors go down with it?
The truth is, it does! If you set an image in @DrawLoop with half opacity, and the same image using Effect Objects with the same alpha value as the one in @DrawLoop, the object effects seam a bit darker even though the RBG are all 255, don't they?
It seams Danmakufu renders effect objects a little differently than it does in @DrawLoop.
It only took me a few minutes to figure out how to fix this so it doesn't go dark, so here it is.
When drawing the image in effect objects, you'll actually have to make two objects. One in Alpha, and the other in Additive.

The effect object with Additive rendering goes beneath the one with Alpha. Meaning, if you were to put them both on the same ObjEffect_SetLayer, the ADD-rendered one goes in first. This will brighten the layer as much as it's darkened underneath the Alpha-rendered object, leaving the texture itself as bright as it really is, and other textures underneath the two unaffected, without loosing any brightness. Altogether, it makes effect objects look a lot more beautiful. It looks really dull if you use half-transparency using ALPHA rendering and only that one object. The ADD one is kind of needed to stabilize it all. I'll give an example, if someone asks for it.  IMPORTANT NOTE: there must be TWO images loaded. Any transparency will come out white in the ADD-rendered object, so the transparent parts must be black. Sometimes black may show when using Alpha rendering, so there must be two images, one transparent for Alpha, and one black-for-tranparent for ADD.


This is a real NEED if you make custom CutIns. You'll like the result.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on January 29, 2010, 06:13:57 AM
Hey guys, just want to let you know something.

Ever notice how when using effect objects, whenever you set them as alpha rendering, whenever you set the alpha value in ObjEffect_SetVertexColor to a lower value, it seams like the RBG colors go down with it?
The truth is, it does! If you set an image in @DrawLoop with half opacity, and the same image using Effect Objects with the same alpha value as the one in @DrawLoop, the object effects seam a bit darker even though the RBG are all 255, don't they?

This is nothing unknown.

It seams Danmakufu renders effect objects a little differently than it does in @DrawLoop.
It only took me a few minutes to figure out how to fix this so it doesn't go dark, so here it is.
When drawing the image in effect objects, you'll actually have to make two objects. One in Alpha, and the other in Additive.

The effect object with Additive rendering goes beneath the one with Alpha. Meaning, if you were to put them both on the same ObjEffect_SetLayer, the ADD-rendered one goes in first. This will brighten the layer as much as it's darkened underneath the Alpha-rendered object, leaving the texture itself as bright as it really is, and other textures underneath the two unaffected, without loosing any brightness. Altogether, it makes effect objects look a lot more beautiful. It looks really dull if you use half-transparency using ALPHA rendering and only that one object. The ADD one is kind of needed to stabilize it all. I'll give an example, if someone asks for it.  IMPORTANT NOTE: there must be TWO images loaded. Any transparency will come out white in the ADD-rendered object, so the transparent parts must be black. Sometimes black may show when using Alpha rendering, so there must be two images, one transparent for Alpha, and one black-for-tranparent for ADD.


This is a real NEED if you make custom CutIns. You'll like the result.

Nothing new either. And yea here is the problem: it will also brighten already present additive drawn objects/textures on the same layer as well. The method has both advantages and disadvantages.

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on January 29, 2010, 07:41:12 AM
it will also brighten already present additive drawn objects/textures on the same layer as well. The method has both advantages and disadvantages.
Just tested it. This method has no effect on other object or textures on the same layer.  The alpha rendering alone darkens the colors of the layer, and the layers beneath that giving it a silhouette-like effect. The additive drawing beneath that cancels the silhouette effect out and gives it a normal transparency without darkening the texture or any beneath that.

Here's what I got with just 20% transparency.
(http://img713.imageshack.us/img713/2286/thdnh2010012902542197mzsf.png)
(http://img710.imageshack.us/img710/8223/thdnh2010012902553169.png)
(http://img713.imageshack.us/img713/5083/thdnh2010012902555362i.png)

The top is object effect with my method. The one below is an object effect used with only alpha rendering. Notice how it's darker, and it'd get worse the more tansparent it gets, and effects the textures below it. The one below is the same image rendered in @DrawLoop using SetGraphicRect and DrawGraphic. It looks exactly the same as the top, doesn't it? The purpose was to give an alpha blend on a layer above the character's sprite with the same colors as DrawLoop, which doesn't darken the colors.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nuclear Cheese on January 29, 2010, 05:32:39 PM
SetCommonData("variablename", alltogether);

And where ever you need to get the variable:

GetCommonData("variablename");

Quick addendum:

GetCommonDataDefault("variablename", defaultvalue);

returns the value of the "global variable" if it has been defined, but returns the given default value if it has not.  This is useful in some situations, since GetCommonData will bomb your script if the indicated variable hasn't been defined yet.


One example of this - I use common data to pass difficulty parameters between the stage script and the boss script for NTSD.  But the boss script can be run by itself as well, where said difficulty parameters won't be defined (because they're defined in the stage script only).  So, using GetCommonDataDefault, I can allow the boss script to define default parameters so it can run by itself.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on January 29, 2010, 07:10:13 PM
Just tested it. This method has no effect on other object or textures on the same layer.  The alpha rendering alone darkens the colors of the layer, and the layers beneath that giving it a silhouette-like effect. The additive drawing beneath that cancels the silhouette effect out and gives it a normal transparency without darkening the texture or any beneath that.

Here's what I got with just 20% transparency.
screens.jpg

The top is object effect with my method. The one below is an object effect used with only alpha rendering. Notice how it's darker, and it'd get worse the more tansparent it gets, and effects the textures below it. The one below is the same image rendered in @DrawLoop using SetGraphicRect and DrawGraphic. It looks exactly the same as the top, doesn't it? The purpose was to give an alpha blend on a layer above the character's sprite with the same colors as DrawLoop, which doesn't darken the colors.

I tested this on my custom cutin script 3.0. And it messes up the the "spell card attack!" effect objects by making them even more brighter. Because the Cutin portrait effect and spell card text are both on Layer 2. Spellcard attack is drawn on top of the Cutin portrait. And applying the method works for the Cutin, not for the spell card text, because they are drawn later on and thus get affected.

Reversing is the only option, but that would look out of place. And layering them up isn't an option either. Like I said, it has downsides and upsides. Using it for single effects isn't a problem but in these kind of cases, it is.

Also I checked MoF / SA / UFO cutin. Excluding SA/UFO ( because they dont dissapear on screen ) MoF has also somewhat a darkening alike cutin portrait which is barely noticeable tbh. Just a note.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on January 29, 2010, 07:39:40 PM
Silly question but this reminds me-

Is there a 'preferred' size for Cutin graphics? I know it'd ideally have to be smaller than the screen, and that I want it to be .png with the transparent background, but am I missing anything else?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on January 29, 2010, 08:10:02 PM
After fucking around in PoSR with the unusually wide cutins I made, I came to the conclusion that it's better to trim them so that they're not getting in the way while you're trying to PoC the point items or reposition yourself. About 200 pixels should be the max horizontally, any vertical size is fine.

250ish wide should probably be the max for dialogue so they don't overlap too much.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on January 29, 2010, 08:17:04 PM
I just tested it myself on your custom cutin script, and I see no such problem. Have you tried putting the Alpha-rendered layer ATOP the ADD? If you want them both on the same layer, you must call the ADD object first.
If you didn't that would explain why you had that problem.
The ADD is supposed to be in first, and the Alpha on top of that. This way, any of the darkened colors get brightened up an equal amount, canceling the two out and maintaining the true color. For example, if you have 50% transparency, you'd want 255/2 set as the alpha value in both the ADD and ALPHA value in SetVertexColor.
If you want 70% transparency, you'd want 255/100*70 as the alpha value in alpha, and 255/100*30 as the color value in ADD (or alpha, since it works there too in SetVertexColor).
If you want 20% transparency, you'd want 255/100*20 as the alpha and color values of both. The alpha value of the ADD does not surpass the alpha value of ALPHA, or it will glow like you say it does and give that unwanted bright effect.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on January 29, 2010, 08:26:44 PM
I'll double check it as it was early in the morning when I was trying it out.

Edit:

    let cut = "script\DanceContest\system\arapcut.png";  <--- trans bg
    let cut2 = "script\DanceContest\system\arapcut2.png"; <--- black bg

   cutin("KANAKO", "Fever Sign: "\""Disco Grooves"\",cut2,0,0,256,512);  <-- ADD type effect
   cutin2("KANAKO", "Fever Sign: "\""Disco Grooves"\",cut,0,0,256,512); <-- Alpha type effect

Result:

(http://i50.tinypic.com/2rn788i.png)

My eyes =.=
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on January 29, 2010, 08:48:44 PM
Take away the second cutin, and add an alpha object so the function "cutin" needs to be called once.
No wonder why it's bright. You're doubling the Additive blend for the "spellcard attack text" because they're separate functions.


Also, question:
I need a way to change Danmakufu's text to a custom png sheet. Is there one made so that all the letters I call in a function like so- "S-P-E-L-L-C-A-R-D(space)-N-A-M-E", each letter being an object effect with monospacing.
Has such a template been made?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on January 29, 2010, 09:04:08 PM
Take away the second cutin, and add an alpha object so the function "cutin" needs to be called once.
No wonder why it's bright. You're doubling the Additive blend for the "spellcard attack text" because they're separate functions.
I am lost here. According to your post, both an additive and alpha image type ( black and trans ) need to be called at the same time and the ADD has to go first. Meaning I spawn ADD first then the ALPHA.

The cutin function is the effect object and function at the same time. I don't get how you tested it. Start showing code here because you are being not clear and fuzzy. Also if you got something to contribute, do it fully and don't spout stuff like: "If there is demand". It only makes one look arrogant you know.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on January 29, 2010, 09:23:42 PM
Also, question:
I need a way to change Danmakufu's text to a custom png sheet. Is there one made so that all the letters I call in a function like so- "S-P-E-L-L-C-A-R-D(space)-N-A-M-E", each letter being an object effect with monospacing.
Has such a template been made?
http://www.mediafire.com/download.php?nvouhuoxnyy (http://www.mediafire.com/download.php?nvouhuoxnyy)
Play around with it for a bit; if you can't figure out how it works then ask me. It's only fixed-width, but someone in one of the Ijiyatsu threads (Blargel I think, but don't shoot me if I'm wrong) modified it to be variable-width, but that broke the alignment parameter.

Edit: Also, feel free to modify it to your needs. I only uploaded the general-use version - I modified it for my personal uses since then, but didn't release it.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on January 29, 2010, 09:28:00 PM

  cutin("KANAKO", "Fever Sign: "\""Disco Grooves"\",cut2,0,0,256,512);  <-- ADD type effect
 cutin2("KANAKO", "Fever Sign: "\""Disco Grooves"\",cut,0,0,256,512); <-- Alpha type effect
<---NO


  cutin("KANAKO", "Fever Sign: "\""Disco Grooves"\",cut2,0,0,256,512);  <-- ADD type effect<---ALPHA type effect

The add and alpha objects are in the same task.


Code: [Select]
let object image=allyourstuffhere,XYcoordinates etc
let object2=imageallyourstuffhere, XYcoordinates copypasted allyouhavetochangeis ObjEFFECT_SETRENDERSTATE


would be like this....
Code: [Select]
/***************************************************************************************************************
* Script: Cutin script
* Author: Helepolis
* version 3.0
* Types: 1 - MOF    Middle appear -> float to top -> leave top
*              2 - SA/UFO Diagonal right top entrance -> slowmode -> follow path to leave
*        3 - UFO2  Horizontal left entrance -> slowmode -> follow path to leave (Byakuren style)
*
* This script is no longer bound any other scripts or extra functions.
* Full support in one single file.
**************************************************************************************************************/

    // new cutin function eliminates the old commondata style.
    task cutin(type,spellcardname,cutinImg,left,top,right,bottom){
yield;

// Charismatic variables
let obj = Obj_Create(OBJ_EFFECT);
              let obj2=Obj_Create(OBJ_EFFECT);///////////////////second object, this will be your alpha
let alphret = 0;
let as = 0;
let c = 0;
let x = 0;
let y = 0;

    let XYbLR = left + right / 2;
    let XYbTB = top + bottom / 2;

if(type == "KANAKO") { x = GetClipMaxX; y = GetCenterY+10; }
if(type == "NAZRIN") { x = GetClipMaxX+256; y = GetCenterY-120; }
if(type == "BYAKUREN") { x = GetClipMinX-256; y = GetCenterY; }

// Experts attention: you can disable this if you want your own Spellcard text but for common people it is default active.
    CutIn(YOUMU, spellcardname,cutinImg,0,0,0,0);

summontext;
summonhexagon;

Obj_SetPosition(obj,x,y);
Obj_SetPosition(obj2,x,y);////////copypaste but change id
ObjEffect_SetRenderState(obj,ADD);///////add will be on the drawn first
ObjEffect_SetRenderState(obj2,ALPHA);//////alpha drawn last
ObjEffect_SetTexture(obj,cutinImg);
ObjEffect_SetTexture(obj2,cutinImg);//////everything else stays the same
ObjEffect_SetLayer(obj,1);
ObjEffect_SetLayer(obj2,1); //////SetVertexColor included

// this is a special function to handle the cutin alpha modification seperate.
cutinEffect_Alphret(obj,obj2,as,alphret);

// Nifty effect vertex setting ( basically a rectangular using the parameters )
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
        ObjEffect_SetPrimitiveType(obj2, PRIMITIVE_TRIANGLESTRIP);
ObjEffect_CreateVertex(obj, 4);
ObjEffect_CreateVertex(obj2, 4);
ObjEffect_SetVertexXY(obj, 0, -XYbLR, -XYbTB);
ObjEffect_SetVertexXY(obj2, 0, -XYbLR, -XYbTB);
ObjEffect_SetVertexUV(obj, 0, left, top);
ObjEffect_SetVertexUV(obj2, 0, left, top);
ObjEffect_SetVertexXY(obj, 1, XYbLR, -XYbTB);
ObjEffect_SetVertexXY(obj2, 1, XYbLR, -XYbTB);
ObjEffect_SetVertexUV(obj, 1, right, top);
ObjEffect_SetVertexUV(obj2, 1, right, top);
ObjEffect_SetVertexXY(obj, 2, -XYbLR, XYbTB);
ObjEffect_SetVertexXY(obj2, 2, -XYbLR, XYbTB);
ObjEffect_SetVertexUV(obj, 2, left, bottom);
ObjEffect_SetVertexUV(obj2, 2, left, bottom);
ObjEffect_SetVertexXY(obj, 3, XYbLR, XYbTB);
ObjEffect_SetVertexXY(obj2, 3, XYbLR, XYbTB);
ObjEffect_SetVertexUV(obj, 3, right, bottom);
ObjEffect_SetVertexUV(obj2, 3, right, bottom);

// hooray for complex movement path. Depending on the cutin type, perform cutin.
while(! Obj_BeDeleted(obj)){
if(type=="KANAKO"){
if(c<15){x-=10; y+=10}
if(c>=15 && c<45){y-=4;}
if(c>=45){y-=2;}
if(c>120){ Obj_Delete(obj); }
}
if(type=="NAZRIN"){
if(c<21){x-=20; y+=5}
if(c>=21 && c<100){x--; y+=0.5;}
if(c>=100){x-=20; y+=5;}
if(c>120){ Obj_Delete(obj); Obj_Delete(obj2);}
}
if(type=="BYAKUREN"){
if(c<21){x+=20;}
if(c>=21 && c<100){x++;}
if(c>=100){x+=20;}
if(c>120){Obj_Delete(obj); Obj_Delete(obj2);}
}
Obj_SetPosition(obj,x,y); Obj_SetPosition(obj2,x,y);
c++;
yield;
}
    }

    // seperate function to make the fadein and fadeout effect.
    task cutinEffect_Alphret(obj,obj2,as,alphret) {
let c = 0;
loop{
  ObjEffect_SetVertexColor(obj,0,alphret,255,255,255);   ObjEffect_SetVertexColor(obj2,0,alphret,255,255,255);
ObjEffect_SetVertexColor(obj,1,alphret,255,255,255); ObjEffect_SetVertexColor(obj2,1,alphret,255,255,255);
  ObjEffect_SetVertexColor(obj,2,alphret,255,255,255);   ObjEffect_SetVertexColor(obj2,2,alphret,255,255,255);
  ObjEffect_SetVertexColor(obj,3,alphret,255,255,255);   ObjEffect_SetVertexColor(obj2,3,alphret,255,255,255);
if(as==0){alphret+=20; if(alphret>250){as=1;} }
if(as==1){c++; if(c==90){ as=2; } }
if(as==2){alphret-=10; if(alphret<10){as=4;} }
yield;
}
    }
   
    // handler for summoning the diagonal text
    task summontext {
let yyPos = 0;
loop(5){
spellcardtext(GetClipMinX,GetClipMaxY-22-yyPos,1.5);
spellcardtext(GetClipMaxX,GetClipMinY-30+yyPos,-1.5);
yyPos+=54;
yield;
}
    }

    // handler for summoning the hexagons
    task summonhexagon {
let dir = 0;
loop(8){
hexagontext(GetCenterX+100,GetCenterY+150,1.5,dir,1.4,1.4);
hexagontext(GetCenterX+100,GetCenterY+150,1.5,dir,1.2,1.2);
hexagontext(GetCenterX+100,GetCenterY+150,-1.5,-dir,1.0,1.0);
hexagontext(80,100,1.5,dir,0.8,0.8);
dir+=45;
yield;
}
    }

//************************************************************************
// Text animation for spellcard spawn ( HEXAGON STYLE )
//   
// alphret - alpha value
// as - variable acting like a switch
// c - counter variable
//************************************************************************

    let CSD = GetCurrentScriptDirectory;
    let textdata = CSD ~ ".\system\spellcardanm.png";
    LoadGraphic(textdata);

    task hexagontext(x,y,v,draai,sx,sy) {
let obj = Obj_Create(OBJ_EFFECT);
let alphret = 0;
let as = 0;
        let c = 0;
let angle = draai;
let speed = v;

Obj_SetPosition(obj,x,y);
ObjEffect_SetRenderState(obj,ADD);
ObjEffect_SetTexture(obj,textdata);
        ObjEffect_SetScale(obj, sx, sy);
ObjEffect_SetLayer(obj,2);

ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
ObjEffect_CreateVertex(obj, 4);

ObjEffect_SetVertexXY(obj, 0, -48, -128);
ObjEffect_SetVertexUV(obj, 0, 0, 0);
ObjEffect_SetVertexXY(obj, 1, 48, -128);
ObjEffect_SetVertexUV(obj, 1, 128, 0);
ObjEffect_SetVertexXY(obj, 2, -48, -104);
ObjEffect_SetVertexUV(obj, 2, 0, 32);
ObjEffect_SetVertexXY(obj, 3, 48, -104);
ObjEffect_SetVertexUV(obj, 3, 128, 32);

while(! Obj_BeDeleted(obj)){
ObjEffect_SetAngle(obj,0,0,angle);
  ObjEffect_SetVertexColor(obj,0,alphret,255,255,255);
ObjEffect_SetVertexColor(obj,1,alphret,255,255,255);
  ObjEffect_SetVertexColor(obj,2,alphret,255,255,255);
  ObjEffect_SetVertexColor(obj,3,alphret,255,255,255);

if(as==0){alphret+=20; if(alphret>185){as=1;} }
if(as==1){c++; if(c==90){as=2;} }
if(as==2){alphret-=10; if(alphret<0){ Obj_Delete(obj); } }
angle += speed;

yield;
  }
    }

//************************************************************************
// Text animation for spellcard spawn ( Diagonal text )
//   
// alphret - alpha value
// as - variable acting like a switch
// c - counter variable
//************************************************************************
    task spellcardtext(x,y,v) {
let obj = Obj_Create(OBJ_EFFECT);
let alphret = 0;
let as = 0;
        let c = 0;

Obj_SetPosition(obj,x,y);
Obj_SetSpeed(obj,v);
Obj_SetAngle(obj,-35);
ObjEffect_SetAngle(obj,0,0,-35);
ObjEffect_SetRenderState(obj,ADD);
ObjEffect_SetTexture(obj,textdata);
ObjEffect_SetLayer(obj,2);

ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
ObjEffect_CreateVertex(obj, 4);
ObjEffect_SetVertexXY(obj, 0, -1024, -16);
ObjEffect_SetVertexUV(obj, 0, 0, 0);
ObjEffect_SetVertexXY(obj, 1, 1024, -16);
ObjEffect_SetVertexUV(obj, 1, 2048, 0);
ObjEffect_SetVertexXY(obj, 2, -1024, 16);
ObjEffect_SetVertexUV(obj, 2, 0, 32);
ObjEffect_SetVertexXY(obj, 3, 1024, 16);
ObjEffect_SetVertexUV(obj, 3, 2048, 32);

while(! Obj_BeDeleted(obj)){
  ObjEffect_SetVertexColor(obj,0,alphret,255,255,255);
ObjEffect_SetVertexColor(obj,1,alphret,255,255,255);
  ObjEffect_SetVertexColor(obj,2,alphret,255,255,255);
  ObjEffect_SetVertexColor(obj,3,alphret,255,255,255);
if(as==0){alphret+=20; if(alphret>185){as=1;} }
if(as==1){c++; if(c==90){as=2;} }
if(as==2){alphret-=10; if(alphret<0){ Obj_Delete(obj); } }
yield;
}
    }

http://www.mediafire.com/download.php?nvouhuoxnyy (http://www.mediafire.com/download.php?nvouhuoxnyy)
Thanks
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on January 29, 2010, 09:36:22 PM
Now that suddenly explains a lot more. Now indeed it shows the way you shown in your screenshots. =.=

And that brings up to the next thing I wonder which I somehow guess why. Why do two effects in one function work and two effects in separate functions not? I guess it has to do with the yield; as the second effect object spawns after technically a yield. Perhaps this way Danmakufu handles the blending different.

Edit: Fixed engrish. How the hell did I wrote desperate and not separate...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on January 29, 2010, 09:41:43 PM
Now that suddenly explains a lot more. Now indeed it shows the way you shown in your screenshots. =.=

And that brings up to the next thing I wonder which I somehow guess why. Why do two effects in one function work and two effects in desperate functions not? I guess it has to do with the yield; as the second effect object spawns after technically a yield. Perhaps this way Danmakufu handles the blending different.


No, the "Spellcard Attack" png image is called twice because the function is called twice.
I tried to say that earlier /sweatdrop
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on January 29, 2010, 10:02:21 PM
/me headdesks

I totally see the issue now. God I can like smash my head through anything now at this moment. No excuses. That was just poor show.

Edit: well let's say I totally missunderstood this line:

Quote from: Mokou
Take away the second cutin, and add an alpha object so the function "cutin" needs to be called once.
I thought take away second cutin as the line =,= and didn't understood you were pointing at the Textanim and Hexagon functions.

/me goes silently to bed.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on January 30, 2010, 03:58:01 AM
Don't worry Hele it happens to all of us :(
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on January 30, 2010, 05:42:19 AM
Garpakdfjlkdgh
Posting...Please Wait Warmly

Ok, Same Problem, This is the script i'm working with (http://www.mediafire.com/?30gqynnyymm)

Upon playing the Plural File I get two errors, both to do with Data.txt

Code: [Select]
---------------------------
ScriptError「C:\Users\Brandon\Desktop\th_dnh\script\EX_Prisimrivers\Lyrica\Lyrica 01.txt」
---------------------------
未定義部分(Load)があります。
(変数宣言の前後に「;」を忘れている部分がありませんか?)(20行目)

Load;

SetLife(900);

SetMovePosition02(GetCenterX,GetCenterY-60,50);

ShotInit;

}



   @MainLoop{

yield;

frame++;

~~~
---------------------------
OK  
---------------------------


Code: [Select]

---------------------------
ScriptError「C:\Users\Brandon\Desktop\th_dnh\script\EX_Prisimrivers\Lyrica\Lyrica 01.txt」
---------------------------
引数がありません(52行目)

   }@DrawLoop{

Draw_Lyrica;

}

   @Finalize{DeleteGraphic(Lyrica);}

}
~~~
---------------------------
OK  
---------------------------



I DONT GET WHAT I AM DOING WRONG, I HAVE ABSOLUTLY NO ABSOLUTE PATH...PATH.....WHAT EVER!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on January 30, 2010, 06:01:53 AM
Ok, this will sound stupid, but does anyone ever actually translate their errors? >_>

Because for you I get:

---------------------------
ScriptError「C:\Users\Brandon\Desktop\th_dnh\script\EX_Prisimrivers\Lyrica\Lyrica 01.txt」
---------------------------
Undefined portion (Load) there.
(Before and after the variable declaration ";" Do not forget that part?) (Line 20)

Nothing 'bout a data script here.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on January 30, 2010, 06:04:21 AM
#include_function".\..\Data.txt" is in before @initalize

Data.txt contains Load; and Draw_Lyrica; If you run the Single Scripts, it works fine
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on January 30, 2010, 08:08:08 AM
Code: [Select]
---------------------------
ScriptError「C:\Users\Brandon\Desktop\th_dnh\script\EX_Prisimrivers\Lyrica\Lyrica 01.txt」
---------------------------

I'm guessing this is probably not the problem, but there's a slight chance that it might be... Does danmakufu even accept spaces in paths? "Lyrica 01"... try using "Lyrica_01" instead... I thought of this cause... if you're just using single files... then of course it can load it, but since you're using the plural file... maybe there's a problem with it trying to find things when there's spaces? ??? I don't really know, but I hope this helps...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on January 30, 2010, 08:21:20 AM
I'm guessing this is probably not the problem, but there's a slight chance that it might be... Does danmakufu even accept spaces in paths? "Lyrica 01"... try using "Lyrica_01" instead... I thought of this cause... if you're just using single files... then of course it can load it, but since you're using the plural file... maybe there's a problem with it trying to find things when there's spaces? ??? I don't really know, but I hope this helps...
It still raises and error
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Infy♫ on January 30, 2010, 11:41:51 AM
i wonder if there's a way to completely make STG_FRAME dissappear and let the player move through the once covered areas
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on January 30, 2010, 02:14:37 PM
@Demonbman:

Okay. I found the mistake. Apparently you accidentally the line #ScriptVersion[2] in your pluralscripts. This line has to be included in the beginning block of every script that danmakufu can run by itself, otherwise bad stuff happens.

Code: [Select]
#TouhouDanmakufu[Plural]
#Title[Lyrica Boss]
#ScriptVersion[2]

Now the plural works.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on January 30, 2010, 04:38:12 PM
@Demonbman:

Okay. I found the mistake. Apparently you accidentally the line #ScriptVersion[2] in your pluralscripts. This line has to be included in the beginning block of every script that danmakufu can run by itself, otherwise bad stuff happens.

Code: [Select]
#TouhouDanmakufu[Plural]
#Title[Lyrica Boss]
#ScriptVersion[2]

Now the plural works.
What the crap? THANK YOU! MY WEEK LONG PROBLEM HAS BEEN SOLVED!!!!

/
 Lol I accidentallly the line (http://media.photobucket.com/image/walfas/Kitsune_Inari/Touhou/touhou_yukari-yuyuko--01_walfas_I-A.png?o=78)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on January 30, 2010, 06:08:34 PM
I'm going to headdesk right here, if that's alright with you.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on January 30, 2010, 06:14:19 PM
I don't know if this issue (or it's solution) is known already, but here it goes:

On the quest for the proper music for my script, I noticed that danmakufu won't loop ogg files properly. It repeats a short part of the ending of the theme in between the loops, causing the stuff to sound really awkward in most cases. After tinkering around with Audacity (pun very much intended), I noticed why this happens:

Danmakufu will loop the ogg files only at the end of a full second. If the file length in seconds is not (almost) an integer, and it pretty much never is, then the remaining time up to the full second is filled up with the previous second.

The solution was to simply cut the theme so that its length in seconds is a tiny fraction of a second below an integer value, for example, 119.9995 seconds. Depending on the tune you are trying to loop, this may be difficult to do without butchering the transition anyways, but it is possible.

I don't know if the same problem exists with mp3s or other sound files, but I am not in the mood to test that too right now.

~_~
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on January 30, 2010, 08:45:17 PM
I had the same problem with MP3s, except that they seem to get cut a bit short instead of running long. I can't get OGGs to work right at all :V

tl;dr - Danmakufu has awful sound code
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on January 30, 2010, 10:15:30 PM
Iryan I been down that road as well with Audacity + mp3/ogg looping by adding silences and such. I have still no idea how to proper setup the sound file, but I noticed a silence in the beginning of the track ( like a second ) seems to help getting closer.

Plus I have a following up question regarding sounds/music. I have this PlaySE in my stage where a sound file is being loaded and played but it only plays for 1seconds then gets cut off. I tried both wav and mp3.
wav - 4.55mb 0:54s
mp3 - 1.1mb 0:54s

Anybody has any idea ?

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on January 30, 2010, 11:36:14 PM
When I look through the various background image rips from ZUN's games, he's got them all set at 256x256 resolution. How does he manage to get that to draw on a 512x512 screen? :S
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on January 31, 2010, 01:11:36 AM
i wonder if there's a way to completely make STG_FRAME dissappear and let the player move through the once covered areas

There is, IRC if you're interested. It's a fucktonne of work, so I'm not posting it here.

You probably already know how to do it anyway.


Plus I have a following up question regarding sounds/music. I have this PlaySE in my stage where a sound file is being loaded and played but it only plays for 1seconds then gets cut off. I tried both wav and mp3.
wav - 4.55mb 0:54s
mp3 - 1.1mb 0:54s

Anybody has any idea ?

Probably has something to do with why the functions PlaySE and PlayMusic exist seperately.


When I look through the various background image rips from ZUN's games, he's got them all set at 256x256 resolution. How does he manage to get that to draw on a 512x512 screen? :S

The screen is 448x384, he stretches the images. In Danmakufu, this just means setting the parameters of SetGraphicScale(x, y) to something larger than 1 (so the image is expanded). Alternatively, you could use object effects and stretch the image dynamically or to fit the screen exactly.

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on January 31, 2010, 01:13:19 AM
There is, IRC if you're interested. It's a fucktonne of work, so I'm not posting it here.
Wait it's actually possible!?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on January 31, 2010, 01:35:54 AM
Wait it's actually possible!?

What Sonic Rei said.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on January 31, 2010, 01:40:52 AM
(http://lh4.ggpht.com/_aAky_oVcO-Q/S2Te14hQVlI/AAAAAAAAAEs/Hmls8LfNblQ/snapshot001b.jpg)

Code: [Select]
task green{
let randx = rand_int(1,512);
let dir = rand_int(0,180);
let randy = rand_int(0,120);
loop(5){
CreateShotA(1,randx,randy,60);

SetShotDataA(1,20,1,dir,0.6,0.02,4,145);

SetShotKillTime(1,300);

FireShot(1);
yield;
}
loop(60){yield;};
yield;
}
}

Ok, I'm wondering first why my stars are spawning as default red circle bullets? After a second or so they turn into a chain of 5 stars and go on their merry way. I actually have no problem with it- the red glow effect is pretty cool- but gives me an idea, can I make them spawn as a different graphic, such as larger stars?

Edit: Yes I drop yields every other line so that Danmakufu doesn't explode, I'm still new at this. :<
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on January 31, 2010, 02:21:13 AM
You don't set any actions for the bullet on the 0th frame (the status it has when it spawns). You set it at the 20th frame. The bullet has default actions and stati... Statuses... Sta-, whatever, actions that it will perform when you fail to call beginning attributes. Apparently, RED01 is the default graphic everything has.

task green{
      let randx = rand_int(1,512);
      let dir = rand_int(0,180);
      let randy = rand_int(0,120);
      loop(5){
         CreateShotA(1,randx,randy,60);
         SetShotDataA(1,0,1,dir,0.6,0.02,4,145);

         SetShotKillTime(1,300);

         FireShot(1);
         yield;
         }
         loop(60){yield;};
         yield;
      }
}

Wait it's actually possible!?
What Sonic Rei said.

:V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on January 31, 2010, 08:32:52 AM
Probably has something to do with why the functions PlaySE and PlayMusic exist seperately.

You didn't get it :V I don't want to play it as a music. I want to play it as a SFX in the stage. I just tried mp3 format to see if it might work ( because mp3 is smaller filesize )

Also PlaySE or PlayMusic doesn't matter I discovered. It seems it is all about the music channel or something. If you call an mp3 with 'PlaySe' it will cut off the music. Seems like Danmakufu supports 1 channel for mp3/ogg and multiple channels for wav.

So again I'll reask it: Why does my wav file cuts off after 1 second =.=
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on January 31, 2010, 07:12:45 PM
I think PlaySE can only play for up to like 5 seconds or something
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: puremrz on January 31, 2010, 07:21:46 PM
I made an SE play a song of 20 seconds before, so there's no time limit to sounds.
I've experimented a lot, and the cutting off has to do with the way you saved it. Apparently.
I'm not sure what it is exactly, but when I use Power Sound Editor Free to save my wavs, it always works right, but WavePad Sound Editor likes making my sound cut off when I use them in Danmakufu.

Which brings up what Helepolis said: So sounds can overlap? No matter what I do, if a sound is repeated over itself, it just restarts instead of stacks. Got a way/program to fix that, but without having Danmakufu cut off half-played sounds?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on January 31, 2010, 07:31:38 PM
DMF will only cut off the sound if it's the same file, to prevent things like playing the "bullet shot" sound 30 times per second being really annoying. However, if you play two different sound effects one after the other (or on the same frame), they will both overlap. Official Touhou games do the same thing.
If you really need the sounds to overlap (which you usually don't, it almost always sounds really ugly), you could probably save the same file under 3 different names and cycle through them.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on January 31, 2010, 09:55:35 PM
I'll try to edit my wav file tommorow. I have to say I didn't quite build it nicely so I'll retry that. But it is the same way I managed to build the mp3 for my title screen which was the same method. Hmmmm. Will try to let it know tommorow.

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 01, 2010, 12:59:53 AM
You didn't get it :V I don't want to play it as a music.

I did get it (I even know what you're using it for), I wasn't answering your question, I was just speculating as to why it might do that.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on February 01, 2010, 01:24:57 AM
If you play two different sound effects one after the other (or on the same frame), they will both overlap. Official Touhou games do the same thing.

Wasn't Danmakufu once a one of the official game's game engine?
If I had to guess, it was probably PCB's.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 01, 2010, 01:38:19 AM
No, it wasn't. Danmakufu is based off of Touhou, but really has nothing to do with it other than that.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on February 01, 2010, 03:36:24 AM
About the sound issue, I can't contribute much but more data gets us closer to the root of the problem right?

While working on my contest "entry" (lol), the sound effects I got were saved as MP3s, and when Danmakufu played them as sound effects, many of them would be cut off before they finished playing for no apparent reason. After using Audacity to convert them to WAVs with absolutely nothing else changing, Danmakufu played them perfectly fine. At that point, I just assumed that Danmakufu was just terrible at playing MP3s and only knew how to use WAVs correctly. Apparently I'm wrong about that.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on February 01, 2010, 03:38:57 AM
Actaully danmakufu often plays WAVs better than mp3s for me as well :/
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on February 01, 2010, 08:06:49 AM
Hey guys, just want to let you know something.

Ever notice how when using effect objects, whenever you set them as alpha rendering, whenever you set the alpha value in ObjEffect_SetVertexColor to a lower value, it seams like the RBG colors go down with it?
The truth is, it does! If you set an image in @DrawLoop with half opacity, and the same image using Effect Objects with the same alpha value as the one in @DrawLoop, the object effects seam a bit darker even though the RBG are all 255, don't they?
It seams Danmakufu renders effect objects a little differently than it does in @DrawLoop.
It only took me a few minutes to figure out how to fix this so it doesn't go dark, so here it is.
When drawing the image in effect objects, you'll actually have to make two objects. One in Alpha, and the other in Additive.

The effect object with Additive rendering goes beneath the one with Alpha. Meaning, if you were to put them both on the same ObjEffect_SetLayer, the ADD-rendered one goes in first. This will brighten the layer as much as it's darkened underneath the Alpha-rendered object, leaving the texture itself as bright as it really is, and other textures underneath the two unaffected, without loosing any brightness. Altogether, it makes effect objects look a lot more beautiful. It looks really dull if you use half-transparency using ALPHA rendering and only that one object. The ADD one is kind of needed to stabilize it all. I'll give an example, if someone asks for it.  IMPORTANT NOTE: there must be TWO images loaded. Any transparency will come out white in the ADD-rendered object, so the transparent parts must be black. Sometimes black may show when using Alpha rendering, so there must be two images, one transparent for Alpha, and one black-for-tranparent for ADD.


This is a real NEED if you make custom CutIns. You'll like the result.

Just want to say that you are awesome for finding this fault and a fix for it. I'm now using it for some of my effects.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on February 01, 2010, 08:16:44 AM
Actaully danmakufu often plays WAVs better than mp3s for me as well :/
Except you obviously don't want WAVs for BGMs now do you.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on February 01, 2010, 08:18:02 AM
Except you obviously don't want WAVs for BGMs now do you.
I still use em anyways :smug:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on February 01, 2010, 09:28:26 AM
Blargel and I started brainstorming about the WAV issue and we concluded there is a limit to using WAV files as SFX. And the limit is highly suspected < ~2 megabytes.

How did I test this? I used an original ZUN sfx ( se_extend.wav ) and started repeating it few times in audacity so the lenght increases etc. No matter how I lengthened or shortened it from 60 seconds to 30 seconds and so on, the wav file would keep cutting off. Then suddenly at 20 seconds, I got it working but also noticed the file size was relative small. To eliminate this I started testing the filesize differences.

30 seconds - 22khz Stereo 32bit - filesize ~3mb --> Gets cut off
30 seconds - 22khz Mono 16bit - filesize ~1.5mb --> No cutting off
45 seconds - 22khz Stereo 32bit - filesize ~3.4mb --> Gets cut off
45 seconds - 22khz Mono 16bit - filesize ~2.07mb --> Gets cut off  <-- Note, it is just above 2mb


?10:17:34? <Helepolis> original was 45 seconds -> stereo 32bit -> filesize 3.40mb --> cuts off
?10:17:43? <Helepolis> I am suspecting the max filesize = 2mb somehow
?10:17:54? <Helepolis> But I need to produce a wav file that reaches this limit
?10:17:57? <Helepolis> let me continue to test. got now a file 2.07mb
?10:18:46? <Helepolis> and it got cut off, 49 seconds
?10:18:52? <Helepolis> lets see if I can bring it down even further
?10:19:41? <Helepolis> yep it is filesize
?10:19:44? <KimoKeine> we need to figure out what causes mp3s to loop badly too lol
?10:19:53? <Helepolis> Filesize limits WAV usage
?10:19:57? <Helepolis> the limit is suspected 2mb
?10:20:00? <Helepolis> 2.07mb got cutoff
?10:20:03? <KimoKeine> time to post lol
?10:20:04? <Helepolis> anything below not


Finally I made a 49 seconds wav file, 16khz! Mono 16bit, filesize 1.50mb ( below 2 ) and it didn't got cut off. Conclusion: Estimated memory limit for WAV files is ~2mb.

Perhaps this is also the reason why other wav files which are played simultaneously get cut off. I don't know if Danmakufu uses the 2mb as buffer memory or each file is allowed to be < ~2mb.

So yea, there you go folks.

Edit:

Edit. Unfortunate, it is not even 2mb, maybe even less ( atleast what I encountered ). My danmakufu wav file got cut off being 1.97mb. I would advise people to experiment and try to stick as close as possible to 1.50mb
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DgBarca on February 02, 2010, 04:52:02 PM
Code: [Select]
while(!Obj_BeDeleted(obj)){

if(Turn == 0){

loop(30){yield;}
Obj_SetAngle(obj,Obj_GetAngle(obj)+ang*4);
loop(8){
loop(15){yield;}
Obj_SetAngle(obj,Obj_GetAngle(obj)+ang*2);
}
Turn=1;
}

Obj_SetSpeed(obj,Obj_GetSpeed(obj)-0.01);

if(Obj_GetSpeed(obj) <= 0){
//so stuff//
}


yield;
  }

I never knew how to make 2 different things in the while(!ObjBedeleted(obj)) thing for a obj bullet...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on February 02, 2010, 06:52:47 PM

I never knew how to make 2 different things in the while(!ObjBedeleted(obj)) thing for a obj bullet...

Please clarify what you're trying to do.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DgBarca on February 02, 2010, 07:54:24 PM
A bullet that slow down every time, and change angle 1 time after 30 frame after the creation and 8 time with 15 frame of interval.
It's a Yamame Non-spell (just for fun)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Infy♫ on February 02, 2010, 08:46:48 PM
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?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on February 02, 2010, 08:50:44 PM
A bullet that slow down every time, and change angle 1 time after 30 frame after the creation and 8 time with 15 frame of interval.
It's a Yamame Non-spell (just for fun)

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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on February 02, 2010, 08:55:28 PM
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?

Code: [Select]
loop { Wait(1); yield; }

I might be wrong.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on February 02, 2010, 09:03:39 PM
Code: [Select]
loop { Wait(1); yield; }

I might be wrong.



the function wait(1); and yield; are practically the same thing.
that code up there tells it to loop {yield; yield;}

It's no wonder why it would just crash or freeze after that. All it's doing is delaying frames
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nimble on February 02, 2010, 09:47:57 PM
Code: [Select]
task ___ (var)
{
if (freezethistask == 0)
{
do anything this task want to do;
}
else
{
nothing cause freezing state;
}
yield;
}

will this method working?
when you want to freeze it, set freezethistask to 1.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DgBarca 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 (http://img688.imageshack.us/img688/1788/brokenangle.png)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 02, 2010, 10:23:04 PM
I don't want the bullet to curve, just change angle like THAT (http://img688.imageshack.us/img688/1788/brokenangle.png)

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;.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel 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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade 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?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on February 03, 2010, 03:06:45 AM
I believe it is. Why don't you test it out and let us know? :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade 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;
      }
   }

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut 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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman 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....
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou 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:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 03, 2010, 07:17:43 AM
? ? ? ? (http://www.shrinemaiden.org/forum/index.php?topic=3218.msg215581#msg215581)

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)
   }
}

:(
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou 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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Frazer 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));
}
}
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman 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
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon 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"

}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on February 04, 2010, 02:40:55 PM
Not really a question/problem but...

(http://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/2008analuxpFig1d.jpg/400px-2008analuxpFig1d.jpg)

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... (http://en.wikipedia.org/wiki/Tetration)

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
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Infy♫ 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?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on February 04, 2010, 06:14:04 PM
Sure.

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

Why would you need to do that?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Infy♫ 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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon 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?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 04, 2010, 08:28:24 PM
Not really a question/problem but...

(http://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/2008analuxpFig1d.jpg/400px-2008analuxpFig1d.jpg)

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... (http://en.wikipedia.org/wiki/Tetration)

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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Frazer 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(){}

}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DarkOverord 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:
(http://www.majhost.com/gallery/DarkOverord/Other/SS2/Toehoes/notintended.png)
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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Frazer 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:
(http://www.majhost.com/gallery/DarkOverord/Other/SS2/Toehoes/notintended.png)
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?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DarkOverord 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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Gc 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);
      }
   }
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DarkOverord 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)
(http://www.majhost.com/gallery/DarkOverord/Other/SS2/Toehoes/help01.png)

This is almost perfect, except I want the red laser roughly on that red dot.
(http://www.majhost.com/gallery/DarkOverord/Other/SS2/Toehoes/help02.png)(http://www.majhost.com/gallery/DarkOverord/Other/SS2/Toehoes/help03.png)

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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: puremrz on February 05, 2010, 11:08:55 AM
(http://www.majhost.com/gallery/DarkOverord/Other/SS2/Toehoes/help02.png)


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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DarkOverord 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)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: puremrz 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)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DarkOverord 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?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on February 05, 2010, 12:37:36 PM
Advanced enough that you probably won't figure it out without asking a few more questions. If you want to give it a try, I suggest you first try reconstructing what you have right now with object lasers to get an understanding of them. After that, you can try adding the extra and complicated stuff. Once you get the hang of objects though, you can do all sorts of neat stuff. :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DarkOverord on February 05, 2010, 02:17:11 PM
Advanced enough that you probably won't figure it out without asking a few more questions. If you want to give it a try, I suggest you first try reconstructing what you have right now with object lasers to get an understanding of them. After that, you can try adding the extra and complicated stuff. Once you get the hang of objects though, you can do all sorts of neat stuff. :V
I see what you mean....

I can get the lasers themselves to work: Baring in mind that the red laser isn't an object laser, just normal for now (http://www.majhost.com/gallery/DarkOverord/Other/SS2/Toehoes/hooraymk2.png). However. When I add the attempted messy code: It appears to work (http://www.majhost.com/gallery/DarkOverord/Other/SS2/Toehoes/hooraywait.png), then this:
http://www.majhost.com/gallery/DarkOverord/Other/SS2/Toehoes/ohwat.png
This is one of those occasions of I know roughly what's happening. I attempted to use the laser ends and the min/max clips (i.e. < > etc.) However. It seems to dislike the Y direction, I have the same code for all sides, but, the bottom, ooo, if the end goes under the botom, it refuses to die it seems. Wait no it isn't. LET'S TRY AND FIX THIS! Whoops... (http://www.majhost.com/gallery/DarkOverord/Other/SS2/Toehoes/whoops_made_it_worse.png)

Nevermind my issue is getting bullets to spawn and the fact it crashes now >:

Well you did say I'd be asking a few more questions :V
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 g=3;
let z=0;
loop{
let Angle = GetAngleToPlayer;
let dir = Angle-45;
while(x<4){
if(g==4){g=5}
Laser1(GetEnemyX+50*cos(dir),GetEnemyY+50*sin(dir),dir,400,20,g,20);

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

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

task Laser1(x,y,dir,L,W,g,delay){
let obj = Obj_Create(OBJ_LASER);

Obj_SetPosition(obj,x,y);
ObjLaser_SetLength(obj,L);
ObjLaser_SetWidth(obj,W);
ObjShot_SetGraphic(obj,g);
ObjShot_SetDelay(obj,delay);
ObjLaser_SetSource(obj,true);
Obj_SetAngle(obj,dir);

if(ObjLaser_GetEndY(obj) > GetClipMaxY){
let i = 0;
let dir2 = 0;
let g2=0;

if(g==3){g2+=210}
if(g==5){g2+=211}
while(i<6){
CreateShotA(1,ObjLaser_GetEndX(obj)+20*cos(dir2),ObjLaser_GetEndY(obj)+20*cos(dir2),0);
SetShotDataA(1,0,2,dir,0.2,0.1,3.5,g2);
FireShot(1);

dir2+=360/6;
i++;

}
g2+=-g2;
yield;

wait(150);
ObjShot_FadeDelete(obj);
}
if(ObjLaser_GetEndX(obj) > GetClipMaxX){
let i = 0;
let dir2 = 0;
let g2=0;

if(g==3){g2+=210}
if(g==5){g2+=211}
while(i<6){
CreateShotA(1,ObjLaser_GetEndX(obj)+20*cos(dir2),ObjLaser_GetEndY(obj)+20*cos(dir2),0);
SetShotDataA(1,0,2,dir,0.2,0.1,3.5,g2);
FireShot(1);

dir2+=360/6;
i++;

}
g2+=-g2;
yield;

wait(150);
ObjShot_FadeDelete(obj);
}
if(ObjLaser_GetEndY(obj) < GetClipMinY){
let i = 0;
let dir2 = 0;
let g2=0;

if(g==3){g2+=210}
if(g==5){g2+=211}
while(i<6){
CreateShotA(1,ObjLaser_GetEndX(obj)+20*cos(dir2),ObjLaser_GetEndY(obj)+20*cos(dir2),0);
SetShotDataA(1,0,2,dir,0.2,0.1,3.5,g2);
FireShot(1);

dir2+=360/6;
i++;

}
g2+=-g2;
yield;

wait(150);
ObjShot_FadeDelete(obj);
}
if(ObjLaser_GetEndX(obj) < GetClipMinX){
let i = 0;
let dir2 = 0;
let g2=0;

if(g==3){g2+=210}
if(g==5){g2+=211}
while(i<6){
CreateShotA(1,ObjLaser_GetEndX(obj)+20*cos(dir2),ObjLaser_GetEndY(obj)+20*cos(dir2),0);
SetShotDataA(1,0,2,dir,0.2,0.1,3.5,g2);
FireShot(1);

dir2+=360/6;
i++;

}
g2+=-g2;
yield;

wait(150);
ObjShot_FadeDelete(obj);
}



}

function wait(w){
loop(w){yield;}
}
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on February 05, 2010, 02:35:16 PM
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.

Amazing! but unusable for anything in danmakufu due to the massive slowdown caused by it... still... this looks really nice ;D Awesome Iryan!

If I fiddle with this a bit... maybe I could make it not cause too much slowdown...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on February 05, 2010, 06:53:14 PM
I see what you mean....
Nevermind my issue is getting bullets to spawn and the fact it crashes now >:

Well you did say I'd be asking a few more questions :V
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 g=3;
let z=0;
loop{
let Angle = GetAngleToPlayer;
let dir = Angle-45;
while(x<4){
if(g==4){g=5}
Laser1(GetEnemyX+50*cos(dir),GetEnemyY+50*sin(dir),dir,400,20,g,20);

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

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

task Laser1(x,y,dir,L,W,g,delay){
let obj = Obj_Create(OBJ_LASER);

Obj_SetPosition(obj,x,y);
ObjLaser_SetLength(obj,L);
ObjLaser_SetWidth(obj,W);
ObjShot_SetGraphic(obj,g);
ObjShot_SetDelay(obj,delay);
ObjLaser_SetSource(obj,true);
Obj_SetAngle(obj,dir);

if(ObjLaser_GetEndY(obj) > GetClipMaxY){
let i = 0;
let dir2 = 0;
let g2=0;

if(g==3){g2+=210}
if(g==5){g2+=211}
while(i<6){
CreateShotA(1,ObjLaser_GetEndX(obj)+20*cos(dir2),ObjLaser_GetEndY(obj)+20*cos(dir2),0);
SetShotDataA(1,0,2,dir,0.2,0.1,3.5,g2);
FireShot(1);

dir2+=360/6;
i++;

}
g2+=-g2;
yield;

wait(150);
ObjShot_FadeDelete(obj);
}
if(ObjLaser_GetEndX(obj) > GetClipMaxX){
let i = 0;
let dir2 = 0;
let g2=0;

if(g==3){g2+=210}
if(g==5){g2+=211}
while(i<6){
CreateShotA(1,ObjLaser_GetEndX(obj)+20*cos(dir2),ObjLaser_GetEndY(obj)+20*cos(dir2),0);
SetShotDataA(1,0,2,dir,0.2,0.1,3.5,g2);
FireShot(1);

dir2+=360/6;
i++;

}
g2+=-g2;
yield;

wait(150);
ObjShot_FadeDelete(obj);
}
if(ObjLaser_GetEndY(obj) < GetClipMinY){
let i = 0;
let dir2 = 0;
let g2=0;

if(g==3){g2+=210}
if(g==5){g2+=211}
while(i<6){
CreateShotA(1,ObjLaser_GetEndX(obj)+20*cos(dir2),ObjLaser_GetEndY(obj)+20*cos(dir2),0);
SetShotDataA(1,0,2,dir,0.2,0.1,3.5,g2);
FireShot(1);

dir2+=360/6;
i++;

}
g2+=-g2;
yield;

wait(150);
ObjShot_FadeDelete(obj);
}
if(ObjLaser_GetEndX(obj) < GetClipMinX){
let i = 0;
let dir2 = 0;
let g2=0;

if(g==3){g2+=210}
if(g==5){g2+=211}
while(i<6){
CreateShotA(1,ObjLaser_GetEndX(obj)+20*cos(dir2),ObjLaser_GetEndY(obj)+20*cos(dir2),0);
SetShotDataA(1,0,2,dir,0.2,0.1,3.5,g2);
FireShot(1);

dir2+=360/6;
i++;

}
g2+=-g2;
yield;

wait(150);
ObjShot_FadeDelete(obj);
}



}

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

The first thing I see that can be screwing with your code is this in your fire task:

FireShot(1);}
FireShot(0);


I'm pretty sure you didn't mean for that but if you did, then you have epic tabbing and organization skills and no one will ever figure out your scripts. The second thing I noticed is that you are incredibly messy.  :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 05, 2010, 06:57:56 PM
@ Kylesky

There is still the issue with the bullets that danmakufu refuses to spawn due to the huge values calculated. I'd suggest to use a much simpler calculation that doesn't reach these values. Due to the limited drawing capabilities of danmakufu, the optical difference wouldn't be that huge I believe. Something like...

Code: [Select]
   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=way^i;
            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;
      }

   }

If you want the entire spear to spawn at once an then move into a specific direction, I can arrange for that, too, but I'll tell you that you will have to choose between
a) using a comparatively small amount of bullets through which the pattern won't look good
b) using a high amount of bullets so the pattern looks good but the game slows down incredibly around the spawning time of the spear, making the game "lagg".
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DarkOverord on February 05, 2010, 07:29:47 PM
The first thing I see that can be screwing with your code is this in your fire task:

FireShot(1);}
FireShot(0);


I'm pretty sure you didn't mean for that but if you did, then you have epic tabbing and organization skills and no one will ever figure out your scripts. The second thing I noticed is that you are incredibly messy.  :V
Oh wha, whoops,Forgot to get rid of FireShot(0) there :V Though that } is from the If statement earlier.

And yes. I'm VERY messy and I apologise for that. The only neat thing I do is tab align I have to admit. But I seem to have resolved what caused the crashing. My ghetto coded If Statements. I think I might have to ask more questions on this :V That or do the opposite of what I planned (I dunno, have the bullets hit the walls and fire lasers? :V)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on February 05, 2010, 07:31:11 PM
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"

}

This probably uses #include_script
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on February 06, 2010, 02:37:37 AM
Try downloading the DanmakuNimmt script. See if it does.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Infy♫ on February 06, 2010, 03:38:47 PM
this is probably impossible, but how do i convert all bullets to point items or effect objects when a spellcard ends?

nevermind :|
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on February 07, 2010, 02:45:03 AM
Could someone give a very simple script in which bullets pass a laser and change graphic and direction?

This is actually because I'm a bit worried about if my Danmakufu runs weird.
Two scripts I've downloaded before have not worked right, one of which I know for sure had to do with collisions and the like.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on February 07, 2010, 03:49:36 AM
Code: [Select]
#東方弾幕風
#Title[SampleC04]
#Text[SampleC04:レーザーに当たった弾の軌道を変える]
#Image[]
#BackGround[User]
#ScriptVersion[2]

script_enemy_main
{
let count= -90 ;//弾を出す間隔を制御するための変数
let cx=GetCenterX();//変数cxに中心x座標を代入
let cy=GetCenterY();//変数cxに中心y座標を代入
let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";
let arrayLaser=[];//LaserObjectのオブジェクトを保存しておく
@Initialize()
{
SetLife(1000);//敵のライフを1000に設定
SetGraphicRect(64,1,127,64);//描画元の矩形を(64,1)-(127,64)に設定
LoadGraphic(imgExRumia);//画像「img\ExRumia.png」を読みこむ
SetMovePosition02(cx,cy,60);//座標(cx,60)に60フレームで移動
}

@MainLoop()
{
if(count>0 && count%10 == 0)
{//30フレーム毎に弾をばらまく
let angle = 0;
while(angle<360)
{
ShotObject(GetX(), GetY(), 3, angle+count*5, AQUA21, 5);
angle+=10;
}
}
if(count == 60)
{//弾の軌道を変えるレーザー作成
LaserObject(0,RED01);
LaserObject(1,BLUE01);
LaserObject(2,GREEN01);
}
if(count == 360)
{//レーザー削除
let i=0;
loop(length(arrayLaser))
{
ObjShot_FadeDelete(arrayLaser[i]);
i++;
}
count=0;//カウンタを0にする
}

SetCollisionA(GetX(),GetY(),32);//敵の座標に当たり判定を登録
SetCollisionB(GetX(),GetY(),24);//敵の座標に当たり判定(体当たり用)を登録
count++;//1フレーム毎にcountが1増加
yield;//毎フレームタスク復帰
}

@DrawLoop()
{
SetTexture(imgExRumia);
DrawGraphic(GetX(),GetY());//敵の座標にExルーミアを描画;
}

@Finalize()
{
DeleteGraphic(imgExRumia);
}

task LaserObject(let num, let grf)
{//弾の軌道を変えるレーザー
//numは0-2のセットで敵を中心に三角形にレーザーを出現させる
//レーザータスク初期化
let r=120;
let angle=210+120*num;
let obj = Obj_Create(OBJ_LASER);
arrayLaser = arrayLaser~[obj];//オブジェクトをarrayLaserに登録
Obj_SetX(obj, GetX() + r*cos(angle-150));
Obj_SetY(obj, GetY() + r*sin(angle-150));
Obj_SetAngle(obj, angle);
ObjShot_SetGraphic(obj, grf);
ObjShot_SetDelay(obj, 120);//遅延時間:120フレーム
ObjLaser_SetLength(obj, (3^0.5)*r);//円に内接する正三角形の辺の長さ:√3*r
ObjLaser_SetWidth(obj, 12);//レーザーの幅:12
while( !Obj_BeDeleted(obj) )
{
angle+=1;//レーザーを回転
Obj_SetX(obj, GetX() + r*cos(angle-150));
Obj_SetY(obj, GetY() + r*sin(angle-150));
Obj_SetAngle(obj, angle);
yield;
}

let i=0;
loop(length(arrayLaser))
{//オブジェクトを削除
if(arrayLaser[i] == obj)
{//配列arrayLaserからi番目の要素を削除
arrayLaser = erase(arrayLaser, i);
break;
}
i++;
}
}
task ShotObject(let x, let y, let speed, let angle, let grf, let delay)
{//レーザーに当たったら軌道を変える弾
//弾タスク初期化
let obj = Obj_Create(OBJ_SHOT);
Obj_SetX(obj, x);
Obj_SetY(obj, y);
Obj_SetSpeed(obj, speed);
Obj_SetAngle(obj, angle);
ObjShot_SetGraphic(obj, grf);
ObjShot_SetDelay(obj, delay);

while( !Obj_BeDeleted(obj) )
{//削除されるまでループを実行
let i=0;
loop(length(arrayLaser))
{//レーザーとの当り判定を調査
if(Collision_Obj_Obj(arrayLaser[i], obj))
{//Laserと接触したら
//連続で判定されないよう普通の弾と入れ替える
//角度も変えておく
//数フレーム触れないようにカウンタで管理してもよいかも
x = Obj_GetX(obj);
y = Obj_GetY(obj);
CreateShot01(x, y, 3, Obj_GetAngle(arrayLaser[i])+90, grf, 0);
Obj_Delete(obj);
break;
}
i++;
}
yield;
}
}

}
 
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on February 07, 2010, 04:20:53 AM
Mm. It works, so I guess I'm okay! Thanks.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DarkOverord on February 08, 2010, 07:26:32 PM
Yeah I'm still struggling with this Lasers, walls, and bullets shoting from the lasers at the walls. I've tried doing it mathematically (Pythagoras lololololol). But I seem to suck at this :B

I tried using add shot. But it isn't working....as planed. While I could say "lol it's something I'm doing wrong". I honestly think it's more something I'm not doing :V I don't suppose anyone has a crash course or a script I could look at to help me with this? I mean I know ZUN has done it with Nazrin! :B
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 08, 2010, 07:53:17 PM
*cough cough*

Code: [Select]
    task DestructionLaser(x, y, t, type){


let obj = Obj_Create(OBJ_LASER);
Obj_SetPosition(obj, x, y);

let astart;
let aend;

if(type==1){
astart=atan2((GetClipMaxY - Obj_GetY(obj)), (GetClipMinX - Obj_GetX(obj)));
aend=atan2((GetClipMaxY - Obj_GetY(obj)), (GetClipMaxX - Obj_GetX(obj)))+360;
} else{
astart=atan2((GetClipMaxY - Obj_GetY(obj)), (GetClipMaxX - Obj_GetX(obj)))+360;
aend=atan2((GetClipMaxY - Obj_GetY(obj)), (GetClipMinX - Obj_GetX(obj)));
}

let adiff=(aend-astart)/t;

Obj_SetAngle(obj, astart);

ObjShot_SetGraphic(obj, WHITE02);
ObjShot_SetDelay(obj, 60+t);
ObjLaser_SetWidth(obj, 20);
ObjLaser_SetLength(obj, 500);

let destx;
let desty;

let atemp1=atan2((GetClipMinY - Obj_GetY(obj)), (GetClipMinX - Obj_GetX(obj)))+360;
let atemp2=atan2((GetClipMinY - Obj_GetY(obj)), (GetClipMaxX - Obj_GetX(obj)))+360;

loop(t){


if(Obj_GetAngle(obj)<atemp1){
destx=GetClipMinX;
desty=Obj_GetY(obj)+(destx-Obj_GetX(obj))*tan(Obj_GetAngle(obj)-180);
} else{ if(Obj_GetAngle(obj)>atemp2){
destx=GetClipMaxX;
desty=Obj_GetY(obj)+(destx-Obj_GetX(obj))*tan(Obj_GetAngle(obj)-180);
} else{
desty=GetClipMinY;
destx=Obj_GetX(obj)-(desty-Obj_GetY(obj))*tan(Obj_GetAngle(obj)-90);
} }

astart+=adiff;
Obj_SetAngle(obj, astart);

ascent(i in 0..3){
CreateShotA(1, destx, desty, 5);
SetShotDataA_XY(1, 0, rand(-1, 1), rand(-0.5, 0.5), 0, 0.03, 0, 4, colour3[i]);
FireShot(1);
}
yield;
}
Obj_Delete(obj);
    }
This is part of the boss battle I'm currently working on. You can take it as a reference.

For the creation of the bullets, first you check which of the borders of the playing field the laser points at. You do this by comparing the angle of the laser to the angle from the laser source to the corners of the playing field. Keep in mind that Obj_GetAngle gives an angle between 0? and 360? while atan2 gives an angle between -180? and 180?. Danmakufu is really a bitch here.

Then pythagoras is applied according to the border the laser is currently touching to determine the spawning point of the bullets.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DarkOverord on February 08, 2010, 08:40:43 PM
*cough cough*

Code: [Select]
    task DestructionLaser(x, y, t, type){


let obj = Obj_Create(OBJ_LASER);
Obj_SetPosition(obj, x, y);

let astart;
let aend;

if(type==1){
astart=atan2((GetClipMaxY - Obj_GetY(obj)), (GetClipMinX - Obj_GetX(obj)));
aend=atan2((GetClipMaxY - Obj_GetY(obj)), (GetClipMaxX - Obj_GetX(obj)))+360;
} else{
astart=atan2((GetClipMaxY - Obj_GetY(obj)), (GetClipMaxX - Obj_GetX(obj)))+360;
aend=atan2((GetClipMaxY - Obj_GetY(obj)), (GetClipMinX - Obj_GetX(obj)));
}

let adiff=(aend-astart)/t;

Obj_SetAngle(obj, astart);

ObjShot_SetGraphic(obj, WHITE02);
ObjShot_SetDelay(obj, 60+t);
ObjLaser_SetWidth(obj, 20);
ObjLaser_SetLength(obj, 500);

let destx;
let desty;

let atemp1=atan2((GetClipMinY - Obj_GetY(obj)), (GetClipMinX - Obj_GetX(obj)))+360;
let atemp2=atan2((GetClipMinY - Obj_GetY(obj)), (GetClipMaxX - Obj_GetX(obj)))+360;

loop(t){


if(Obj_GetAngle(obj)<atemp1){
destx=GetClipMinX;
desty=Obj_GetY(obj)+(destx-Obj_GetX(obj))*tan(Obj_GetAngle(obj)-180);
} else{ if(Obj_GetAngle(obj)>atemp2){
destx=GetClipMaxX;
desty=Obj_GetY(obj)+(destx-Obj_GetX(obj))*tan(Obj_GetAngle(obj)-180);
} else{
desty=GetClipMinY;
destx=Obj_GetX(obj)-(desty-Obj_GetY(obj))*tan(Obj_GetAngle(obj)-90);
} }

astart+=adiff;
Obj_SetAngle(obj, astart);

ascent(i in 0..3){
CreateShotA(1, destx, desty, 5);
SetShotDataA_XY(1, 0, rand(-1, 1), rand(-0.5, 0.5), 0, 0.03, 0, 4, colour3[i]);
FireShot(1);
}
yield;
}
Obj_Delete(obj);
    }
This is part of the boss battle I'm currently working on. You can take it as a reference.

For the creation of the bullets, first you check which of the borders of the playing field the laser points at. You do this by comparing the angle of the laser to the angle from the laser source to the corners of the playing field. Keep in mind that Obj_GetAngle gives an angle between 0? and 360? while atan2 gives an angle between -180? and 180?. Danmakufu is really a bitch here.

Then pythagoras is applied according to the border the laser is currently touching to determine the spawning point of the bullets.
Oh thanks. And it's nice to see I had the right idea using Pythag, I was sort of on the right trac I see, just no idea how to code it XD. and I figured atan2 would've done that. Most computers using Trig functions normally return values like that (Remembers Pascal argh).

I'll have a lil mess round and see what I manage. But thank you very much Iryan :D
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on February 08, 2010, 09:15:56 PM
I'm having my troubles in getting backgrounds to work.
Well, since I'm new at this concept, spellcard backgrounds in particular.

It seems I can't get it to show up in the @Background loop. If I move the code to @DrawLoop, it works, but then no boss graphic appears.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 08, 2010, 09:45:58 PM
I don't know that much about backgrounds, but I'm fairly certain that @Background only works on stages and spellcards, that is boss enemies that call the SetScore function.

If you have a single (still or linear scrolling) picture for your background image, you can simply use the #BackGround[] block in the top of the script. It will be ignored on any boss attack that has an @Background part, so you can have a simple background for all non-cards and script a special background for your spell cards.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DarkOverord on February 08, 2010, 10:18:16 PM
http://www.youtube.com/watch?v=LNToeEMZz1I

I found this was pretty useful for learning BG's =D. Helepolis explains how to do it rather well
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Gc on February 08, 2010, 10:54:29 PM
How about some more tokenizer error ?

Code: [Select]
#UserShotData
ShotImage = ".\shot.png"

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 01                                                                                                            //
ShotData {id = 1    rect = (0,0,16,16)        render = ALPHA  delay_color = (255,255,255)  angular_velocity = 0} //White
ShotData {id = 2    rect = (128,0,144,16)     render = ALPHA  delay_color = (255,127,127)  angular_velocity = 0} //Red
ShotData {id = 3    rect = (256,0,272,16)     render = ALPHA  delay_color = (255,191,127)  angular_velocity = 0} //Orange
ShotData {id = 4    rect = (384,0,400,16)     render = ALPHA  delay_color = (255,255,127)  angular_velocity = 0} //Yellow
ShotData {id = 5    rect = (0,128,16,144)     render = ALPHA  delay_color = (191,255,127)  angular_velocity = 0} //Lime
ShotData {id = 6    rect = (128,128,144,144)  render = ALPHA  delay_color = (127,255,127)  angular_velocity = 0} //Green
ShotData {id = 7    rect = (256,128,272,144)  render = ALPHA  delay_color = (127,255,191)  angular_velocity = 0} //Teal
ShotData {id = 8    rect = (384,128,400,144)  render = ALPHA  delay_color = (127,255,255)  angular_velocity = 0} //Cyan
ShotData {id = 9    rect = (0,256,16,272)     render = ALPHA  delay_color = (127,191,255)  angular_velocity = 0} //Aqua
ShotData {id = 10   rect = (128,256,144,272)  render = ALPHA  delay_color = (127,127,255)  angular_velocity = 0} //Blue
ShotData {id = 11   rect = (256,256,272,272)  render = ALPHA  delay_color = (191,127,255)  angular_velocity = 0} //Purple
ShotData {id = 12   rect = (384,256,400,272)  render = ALPHA  delay_color = (255,127,255)  angular_velocity = 0} //Magenta
ShotData {id = 13   rect = (0,384,16,400)     render = ALPHA  delay_color = (255,127,191)  angular_velocity = 0} //Pink
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 02                                                                                                            //
ShotData {id = 14   rect = (0,32,24,56)       render = ALPHA  delay_color = (255,255,255)  angular_velocity = 0} //White
ShotData {id = 15   rect = (128,32,152,56)    render = ALPHA  delay_color = (255,127,127)  angular_velocity = 0} //Red
ShotData {id = 16   rect = (256,32,280,56)    render = ALPHA  delay_color = (255,191,127)  angular_velocity = 0} //Orange
ShotData {id = 17   rect = (384,32,408,56)    render = ALPHA  delay_color = (255,255,127)  angular_velocity = 0} //Yellow
ShotData {id = 18   rect = (0,160,24,184)     render = ALPHA  delay_color = (191,255,127)  angular_velocity = 0} //Lime
ShotData {id = 19   rect = (128,160,152,184)  render = ALPHA  delay_color = (127,255,127)  angular_velocity = 0} //Green
ShotData {id = 20   rect = (256,160,280,184)  render = ALPHA  delay_color = (127,255,191)  angular_velocity = 0} //Teal
ShotData {id = 21   rect = (384,160,408,184)  render = ALPHA  delay_color = (127,255,255)  angular_velocity = 0} //Cyan
ShotData {id = 22   rect = (0,288,24,312)     render = ALPHA  delay_color = (127,191,255)  angular_velocity = 0} //Aqua
ShotData {id = 23   rect = (128,288,152,312)  render = ALPHA  delay_color = (127,127,255)  angular_velocity = 0} //Blue
ShotData {id = 24   rect = (256,288,280,312)  render = ALPHA  delay_color = (191,127,255)  angular_velocity = 0} //Purple
ShotData {id = 25   rect = (384,288,408,312)  render = ALPHA  delay_color = (255,127,255)  angular_velocity = 0} //Magenta
ShotData {id = 26   rect = (0,416,24,440)     render = ALPHA  delay_color = (255,127,191)  angular_velocity = 0} //Pink
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 03                                                                                                            //
ShotData {id = 27   rect = (0,64,32,96)       render = ALPHA  delay_color = (255,255,255)  angular_velocity = 0} //White
ShotData {id = 28   rect = (128,64,160,96)    render = ALPHA  delay_color = (255,127,127)  angular_velocity = 0} //Red
ShotData {id = 29   rect = (256,64,288,96)    render = ALPHA  delay_color = (255,191,127)  angular_velocity = 0} //Orange
ShotData {id = 30   rect = (384,64,416,96)    render = ALPHA  delay_color = (255,255,127)  angular_velocity = 0} //Yellow
ShotData {id = 31   rect = (0,192,32,224)     render = ALPHA  delay_color = (191,255,127)  angular_velocity = 0} //Lime
ShotData {id = 32   rect = (128,192,160,224)  render = ALPHA  delay_color = (127,255,127)  angular_velocity = 0} //Green
ShotData {id = 33   rect = (256,192,288,224)  render = ALPHA  delay_color = (127,255,191)  angular_velocity = 0} //Teal
ShotData {id = 34   rect = (384,192,416,224)  render = ALPHA  delay_color = (127,255,255)  angular_velocity = 0} //Cyan
ShotData {id = 35   rect = (0,320,32,352)     render = ALPHA  delay_color = (127,191,255)  angular_velocity = 0} //Aqua
ShotData {id = 36   rect = (128,320,160,352)  render = ALPHA  delay_color = (127,127,255)  angular_velocity = 0} //Blue
ShotData {id = 37   rect = (256,320,288,352)  render = ALPHA  delay_color = (191,127,255)  angular_velocity = 0} //Purple
ShotData {id = 38   rect = (384,320,416,352)  render = ALPHA  delay_color = (255,127,255)  angular_velocity = 0} //Magenta
ShotData {id = 39   rect = (0,448,32,480)     render = ALPHA  delay_color = (255,127,191)  angular_velocity = 0} //Pink
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 04                                                                                                            //
ShotData {id = 40   rect = (0,96,16,128)      render = ALPHA  delay_color = (255,255,255)  angular_velocity = 0} //White
ShotData {id = 41   rect = (128,96,144,128)   render = ALPHA  delay_color = (255,127,127)  angular_velocity = 0} //Red
ShotData {id = 42   rect = (256,96,272,128)   render = ALPHA  delay_color = (255,191,127)  angular_velocity = 0} //Orange
ShotData {id = 43   rect = (384,96,400,128)   render = ALPHA  delay_color = (255,255,127)  angular_velocity = 0} //Yellow
ShotData {id = 44   rect = (0,224,16,256)     render = ALPHA  delay_color = (191,255,127)  angular_velocity = 0} //Lime
ShotData {id = 45   rect = (128,224,144,256)  render = ALPHA  delay_color = (127,255,127)  angular_velocity = 0} //Green
ShotData {id = 46   rect = (256,224,272,256)  render = ALPHA  delay_color = (127,255,191)  angular_velocity = 0} //Teal
ShotData {id = 47   rect = (384,224,400,256)  render = ALPHA  delay_color = (127,255,255)  angular_velocity = 0} //Cyan
ShotData {id = 48   rect = (0,352,16,384)     render = ALPHA  delay_color = (127,191,255)  angular_velocity = 0} //Aqua
ShotData {id = 49   rect = (128,352,144,384)  render = ALPHA  delay_color = (127,127,255)  angular_velocity = 0} //Blue
ShotData {id = 50   rect = (256,352,272,384)  render = ALPHA  delay_color = (191,127,255)  angular_velocity = 0} //Purple
ShotData {id = 51   rect = (384,352,400,384)  render = ALPHA  delay_color = (255,127,255)  angular_velocity = 0} //Magenta
ShotData {id = 52   rect = (0,480,16,512)     render = ALPHA  delay_color = (255,127,191)  angular_velocity = 0} //Pink
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 05                                                                                                            //
ShotData {id = 53   rect = (16,16,32,32)      render = ALPHA  delay_color = (255,255,255)  angular_velocity = 0} //White
ShotData {id = 54   rect = (144,16,160,32)    render = ALPHA  delay_color = (255,127,127)  angular_velocity = 0} //Red
ShotData {id = 55   rect = (272,16,288,32)    render = ALPHA  delay_color = (255,191,127)  angular_velocity = 0} //Orange
ShotData {id = 56   rect = (400,16,416,32)    render = ALPHA  delay_color = (255,255,127)  angular_velocity = 0} //Yellow
ShotData {id = 57   rect = (16,144,32,160)    render = ALPHA  delay_color = (191,255,127)  angular_velocity = 0} //Lime
ShotData {id = 58   rect = (144,144,160,160)  render = ALPHA  delay_color = (127,255,127)  angular_velocity = 0} //Green
ShotData {id = 59   rect = (272,144,288,160)  render = ALPHA  delay_color = (127,255,191)  angular_velocity = 0} //Teal
ShotData {id = 60   rect = (400,144,416,160)  render = ALPHA  delay_color = (127,255,255)  angular_velocity = 0} //Cyan
ShotData {id = 61   rect = (16,272,32,288)    render = ALPHA  delay_color = (127,191,255)  angular_velocity = 0} //Aqua
ShotData {id = 62   rect = (144,272,160,288)  render = ALPHA  delay_color = (127,127,255)  angular_velocity = 0} //Blue
ShotData {id = 63   rect = (272,272,288,288)  render = ALPHA  delay_color = (191,127,255)  angular_velocity = 0} //Purple
ShotData {id = 64   rect = (400,272,416,288)  render = ALPHA  delay_color = (255,127,255)  angular_velocity = 0} //Magenta
ShotData {id = 65   rect = (16,400,32,416)    render = ALPHA  delay_color = (255,127,191)  angular_velocity = 0} //Pink
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 06                                                                                                            //
ShotData {id = 66   rect = (64,0,128,64)      render = ALPHA  delay_color = (255,255,255)  angular_velocity = 0} //White
ShotData {id = 67   rect = (192,0,256,64)     render = ALPHA  delay_color = (255,127,127)  angular_velocity = 0} //Red
ShotData {id = 68   rect = (320,0,384,64)     render = ALPHA  delay_color = (255,191,127)  angular_velocity = 0} //Orange
ShotData {id = 69   rect = (448,0,512,64)     render = ALPHA  delay_color = (255,255,127)  angular_velocity = 0} //Yellow
ShotData {id = 70   rect = (64,128,128,192)   render = ALPHA  delay_color = (191,255,127)  angular_velocity = 0} //Lime
ShotData {id = 71   rect = (192,128,256,192)  render = ALPHA  delay_color = (127,255,127)  angular_velocity = 0} //Green
ShotData {id = 72   rect = (320,128,384,192)  render = ALPHA  delay_color = (127,255,191)  angular_velocity = 0} //Teal
ShotData {id = 73   rect = (448,128,512,192)  render = ALPHA  delay_color = (127,255,255)  angular_velocity = 0} //Cyan
ShotData {id = 74   rect = (64,256,128,320)   render = ALPHA  delay_color = (127,191,255)  angular_velocity = 0} //Aqua
ShotData {id = 75   rect = (192,256,256,320)  render = ALPHA  delay_color = (127,127,255)  angular_velocity = 0} //Blue
ShotData {id = 76   rect = (320,256,384,320)  render = ALPHA  delay_color = (191,127,255)  angular_velocity = 0} //Purple
ShotData {id = 77   rect = (448,256,512,320)  render = ALPHA  delay_color = (255,127,255)  angular_velocity = 0} //Magenta
ShotData {id = 78   rect = (64,384,128,448)   render = ALPHA  delay_color = (255,127,191)  angular_velocity = 0} //Pink
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 11                                                                                                            //
ShotData {id = 79   rect = (32,0,48,16)       render = ALPHA  delay_color = (255,255,255)  angular_velocity = 0} //White
ShotData {id = 80   rect = (160,0,176,16)     render = ALPHA  delay_color = (255,127,127)  angular_velocity = 0} //Red
ShotData {id = 81   rect = (288,0,304,16)     render = ALPHA  delay_color = (255,191,127)  angular_velocity = 0} //Orange
ShotData {id = 82   rect = (416,0,432,16)     render = ALPHA  delay_color = (255,255,127)  angular_velocity = 0} //Yellow
ShotData {id = 83   rect = (32,128,48,144)    render = ALPHA  delay_color = (191,255,127)  angular_velocity = 0} //Lime
ShotData {id = 84   rect = (160,128,176,144)  render = ALPHA  delay_color = (127,255,127)  angular_velocity = 0} //Green
ShotData {id = 85   rect = (288,128,304,144)  render = ALPHA  delay_color = (127,255,191)  angular_velocity = 0} //Teal
ShotData {id = 86   rect = (416,128,432,144)  render = ALPHA  delay_color = (127,255,255)  angular_velocity = 0} //Cyan
ShotData {id = 87   rect = (32,256,48,272)    render = ALPHA  delay_color = (127,191,255)  angular_velocity = 0} //Aqua
ShotData {id = 88   rect = (160,256,176,272)  render = ALPHA  delay_color = (127,127,255)  angular_velocity = 0} //Blue
ShotData {id = 89   rect = (288,256,304,272)  render = ALPHA  delay_color = (191,127,255)  angular_velocity = 0} //Purple
ShotData {id = 90   rect = (416,256,432,272)  render = ALPHA  delay_color = (255,127,255)  angular_velocity = 0} //Magenta
ShotData {id = 91   rect = (32,384,48,400)    render = ALPHA  delay_color = (255,127,191)  angular_velocity = 0} //Pink
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 12                                                                                                            //
ShotData {id = 92   rect = (32,32,56,56)      render = ALPHA  delay_color = (255,255,255)  angular_velocity = 0} //White
ShotData {id = 93   rect = (160,32,184,56)    render = ALPHA  delay_color = (255,127,127)  angular_velocity = 0} //Red
ShotData {id = 94   rect = (288,32,312,56)    render = ALPHA  delay_color = (255,191,127)  angular_velocity = 0} //Orange
ShotData {id = 95   rect = (416,32,440,56)    render = ALPHA  delay_color = (255,255,127)  angular_velocity = 0} //Yellow
ShotData {id = 96   rect = (32,160,56,184)    render = ALPHA  delay_color = (191,255,127)  angular_velocity = 0} //Lime
ShotData {id = 97   rect = (160,160,184,184)  render = ALPHA  delay_color = (127,255,127)  angular_velocity = 0} //Green
ShotData {id = 98   rect = (288,160,312,184)  render = ALPHA  delay_color = (127,255,191)  angular_velocity = 0} //Teal
ShotData {id = 99   rect = (416,160,440,184)  render = ALPHA  delay_color = (127,255,255)  angular_velocity = 0} //Cyan
ShotData {id = 100  rect = (32,288,56,312)    render = ALPHA  delay_color = (127,191,255)  angular_velocity = 0} //Aqua
ShotData {id = 101  rect = (160,288,184,312)  render = ALPHA  delay_color = (127,127,255)  angular_velocity = 0} //Blue
ShotData {id = 102  rect = (288,288,312,312)  render = ALPHA  delay_color = (191,127,255)  angular_velocity = 0} //Purple
ShotData {id = 103  rect = (416,288,440,312)  render = ALPHA  delay_color = (255,127,255)  angular_velocity = 0} //Magenta
ShotData {id = 104  rect = (32,416,56,440)    render = ALPHA  delay_color = (255,127,191)  angular_velocity = 0} //Pink
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 13                                                                                                            //
ShotData {id = 105  rect = (32,64,64,96)      render = ALPHA  delay_color = (255,255,255)  angular_velocity = 0} //White
ShotData {id = 106  rect = (160,64,192,96)    render = ALPHA  delay_color = (255,127,127)  angular_velocity = 0} //Red
ShotData {id = 107  rect = (288,64,320,96)    render = ALPHA  delay_color = (255,191,127)  angular_velocity = 0} //Orange
ShotData {id = 108  rect = (416,64,448,96)    render = ALPHA  delay_color = (255,255,127)  angular_velocity = 0} //Yellow
ShotData {id = 109  rect = (32,192,64,224)    render = ALPHA  delay_color = (191,255,127)  angular_velocity = 0} //Lime
ShotData {id = 110  rect = (160,192,192,224)  render = ALPHA  delay_color = (127,255,127)  angular_velocity = 0} //Green
ShotData {id = 111  rect = (288,192,320,224)  render = ALPHA  delay_color = (127,255,191)  angular_velocity = 0} //Teal
ShotData {id = 112  rect = (416,192,448,224)  render = ALPHA  delay_color = (127,255,255)  angular_velocity = 0} //Cyan
ShotData {id = 113  rect = (32,320,64,352)    render = ALPHA  delay_color = (127,191,255)  angular_velocity = 0} //Aqua
ShotData {id = 114  rect = (160,320,192,352)  render = ALPHA  delay_color = (127,127,255)  angular_velocity = 0} //Blue
ShotData {id = 115  rect = (288,320,320,352)  render = ALPHA  delay_color = (191,127,255)  angular_velocity = 0} //Purple
ShotData {id = 116  rect = (416,320,448,352)  render = ALPHA  delay_color = (255,127,255)  angular_velocity = 0} //Magenta
ShotData {id = 117  rect = (32,448,64,480)    render = ALPHA  delay_color = (255,127,191)  angular_velocity = 0} //Pink
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 14                                                                                                            //
ShotData {id = 118  rect = (032,96,048,128)   render = ALPHA  delay_color = (255,255,255)  angular_velocity = 0} //White
ShotData {id = 119  rect = (160,96,176,128)   render = ALPHA  delay_color = (255,127,127)  angular_velocity = 0} //Red
ShotData {id = 120  rect = (288,96,304,128)   render = ALPHA  delay_color = (255,191,127)  angular_velocity = 0} //Orange
ShotData {id = 121  rect = (416,96,432,128)   render = ALPHA  delay_color = (255,255,127)  angular_velocity = 0} //Yellow
ShotData {id = 122  rect = (32,224,48,256)    render = ALPHA  delay_color = (191,255,127)  angular_velocity = 0} //Lime
ShotData {id = 123  rect = (160,224,176,256)  render = ALPHA  delay_color = (127,255,127)  angular_velocity = 0} //Green
ShotData {id = 124  rect = (288,224,304,256)  render = ALPHA  delay_color = (127,255,191)  angular_velocity = 0} //Teal
ShotData {id = 125  rect = (416,224,432,256)  render = ALPHA  delay_color = (127,255,255)  angular_velocity = 0} //Cyan
ShotData {id = 126  rect = (32,352,48,384)    render = ALPHA  delay_color = (127,191,255)  angular_velocity = 0} //Aqua
ShotData {id = 127  rect = (160,352,176,384)  render = ALPHA  delay_color = (127,127,255)  angular_velocity = 0} //Blue
ShotData {id = 128  rect = (288,352,304,384)  render = ALPHA  delay_color = (191,127,255)  angular_velocity = 0} //Purple
ShotData {id = 129  rect = (416,352,432,384)  render = ALPHA  delay_color = (255,127,255)  angular_velocity = 0} //Magenta
ShotData {id = 130  rect = (32,480,48,512)    render = ALPHA  delay_color = (255,127,191)  angular_velocity = 0} //Pink
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 15                                                                                                            //
ShotData {id = 131  rect = (48,16,64,32)      render = ALPHA  delay_color = (255,255,255)  angular_velocity = 0} //White
ShotData {id = 132  rect = (176,16,192,32)    render = ALPHA  delay_color = (255,127,127)  angular_velocity = 0} //Red
ShotData {id = 133  rect = (304,16,320,32)    render = ALPHA  delay_color = (255,191,127)  angular_velocity = 0} //Orange
ShotData {id = 134  rect = (432,16,448,32)    render = ALPHA  delay_color = (255,255,127)  angular_velocity = 0} //Yellow
ShotData {id = 135  rect = (48,144,64,160)    render = ALPHA  delay_color = (191,255,127)  angular_velocity = 0} //Lime
ShotData {id = 136  rect = (176,144,192,160)  render = ALPHA  delay_color = (127,255,127)  angular_velocity = 0} //Green
ShotData {id = 137  rect = (304,144,320,160)  render = ALPHA  delay_color = (127,255,191)  angular_velocity = 0} //Teal
ShotData {id = 138  rect = (432,144,448,160)  render = ALPHA  delay_color = (127,255,255)  angular_velocity = 0} //Cyan
ShotData {id = 139  rect = (48,272,064,288)   render = ALPHA  delay_color = (127,191,255)  angular_velocity = 0} //Aqua
ShotData {id = 140  rect = (176,272,192,288)  render = ALPHA  delay_color = (127,127,255)  angular_velocity = 0} //Blue
ShotData {id = 141  rect = (304,272,320,288)  render = ALPHA  delay_color = (191,127,255)  angular_velocity = 0} //Purple
ShotData {id = 142  rect = (432,272,448,288)  render = ALPHA  delay_color = (255,127,255)  angular_velocity = 0} //Magenta
ShotData {id = 143  rect = (48,400,64,416)    render = ALPHA  delay_color = (255,127,191)  angular_velocity = 0} //Pink
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 16                                                                                                            //
ShotData {id = 144  rect = (64,64,128,128)    render = ALPHA  delay_color = (255,255,255)  angular_velocity = 0} //White
ShotData {id = 145  rect = (192,64,256,128)   render = ALPHA  delay_color = (255,127,127)  angular_velocity = 0} //Red
ShotData {id = 146  rect = (320,64,384,128)   render = ALPHA  delay_color = (255,191,127)  angular_velocity = 0} //Orange
ShotData {id = 147  rect = (448,64,512,128)   render = ALPHA  delay_color = (255,255,127)  angular_velocity = 0} //Yellow
ShotData {id = 148  rect = (64,192,128,256)   render = ALPHA  delay_color = (191,255,127)  angular_velocity = 0} //Lime
ShotData {id = 149  rect = (192,192,256,256)  render = ALPHA  delay_color = (127,255,127)  angular_velocity = 0} //Green
ShotData {id = 150  rect = (320,192,384,256)  render = ALPHA  delay_color = (127,255,191)  angular_velocity = 0} //Teal
ShotData {id = 151  rect = (448,192,512,256)  render = ALPHA  delay_color = (127,255,255)  angular_velocity = 0} //Cyan
ShotData {id = 152  rect = (64,320,128,384)   render = ALPHA  delay_color = (127,191,255)  angular_velocity = 0} //Aqua
ShotData {id = 153  rect = (192,320,256,384)  render = ALPHA  delay_color = (127,127,255)  angular_velocity = 0} //Blue
ShotData {id = 154  rect = (320,320,384,384)  render = ALPHA  delay_color = (191,127,255)  angular_velocity = 0} //Purple
ShotData {id = 155  rect = (448,320,512,384)  render = ALPHA  delay_color = (255,127,255)  angular_velocity = 0} //Magenta
ShotData {id = 156  rect = (64,448,128,512)   render = ALPHA  delay_color = (255,127,191)  angular_velocity = 0} //Pink
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
(http://dl.dropbox.com/u/3185156/Danmakufu%20errors/moartokenizer.png)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Areylie on February 08, 2010, 11:10:08 PM
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?
How complicated? Depends on weather you want to use complicated trigonometry or complicated OBJ_LASER hax.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on February 08, 2010, 11:23:19 PM
http://www.youtube.com/watch?v=LNToeEMZz1I

I found this was pretty useful for learning BG's =D. Helepolis explains how to do it rather well
Yeah, I already watched it some time ago. But I still couldn't figure out what was wrong, so I'm back here.

I guess maybe I'll try to be a bit more specific.
I'm trying to use a static background atm for some spellcard attacks.
The problem is that nothing appears. I still see the default spellcard background - The one that's all shiny and purple and stuffs.
I've tried using #Background and @Background, but nothing ever seems to show up.
As I said before, I can make it appear through @DrawLoop, but that would make the boss sprite disappear.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Areylie on February 08, 2010, 11:31:28 PM
As I said before, I can make it appear through @DrawLoop, but that would make the boss sprite disappear.
Place the code for drawing the sprite after the code for drawing the background.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on February 08, 2010, 11:32:49 PM

I'm trying to use a static background atm for some spellcard attacks.
The problem is that nothing appears. I still see the default spellcard background - The one that's all shiny and purple and stuffs.
I've tried using #Background and @Background, but nothing ever seems to show up.
Do you have a SetScore in your Initalize?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on February 09, 2010, 12:03:11 AM
Yep, and the spellcards themselves work perfectly fine.
Maybe I'll post up one of the codes if this problems persists.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DarkOverord on February 09, 2010, 12:23:19 AM
How complicated? Depends on weather you want to use complicated trigonometry or complicated OBJ_LASER hax.
Actually thanks to Iryan it runs almost perfect. I've just gont one Trig that doesn't seem to work. Guys.
(http://www.majhost.com/gallery/DarkOverord/Other/SS2/Toehoes/help01.png)
Just because I want to double check I'm not messing this up (I probably am). What angle is that Red laser pointing at? 180 I think?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 09, 2010, 12:30:04 AM
90?

Where did you learn Danmakufu, just out of curiousity?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DarkOverord on February 09, 2010, 12:38:00 AM
90?

Where did you learn Danmakufu, just out of curiousity?
Helepolis' YouTube Tutorials and Touhou wiki.

About 5 days ago :B And I just looked up the vid where angles are mentioned :V I forgot and my mind reset to 0 is at the top not to the right >.< I'll keep that in mind as I try and troubleshoot it again. I wanna make sure I'm not being really stupid before I ask again :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 09, 2010, 12:42:19 AM
No no no, I just wanted to make sure everything was getting covered in the tutorials that are available. If you don't know something, then it's not a stupid question.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DarkOverord on February 09, 2010, 12:44:46 AM
No no no, I just wanted to make sure everything was getting covered in the tutorials that are available. If you don't know something, then it's not a stupid question.
I dunno. Forgetting Danmakufu's angle setup is a bit silly. And yeah. I'm pretty much trying to do stuff that I haven't seen in a tutorial (Getting a laser to spawn bullets, unless there is one and I missed it)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 09, 2010, 12:48:26 AM
Heh, we have a basic tutorial (http://www.shrinemaiden.org/forum/index.php?topic=30.0) if you're really interested in danmakufu. Some of it will be refresher from the videos, but I guarentee you'll have a much deeper understanding if you read through the basic tutorial, rather than if you just go by a ten minute video...

And yes, it covers spawning bullets from other bullets and lasers.

Tutorial thread index (http://www.shrinemaiden.org/forum/index.php?topic=385.0) is stickied by the way, when you're ready to learn a new topic.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DarkOverord on February 09, 2010, 01:02:43 AM
Heh, we have a basic tutorial (http://www.shrinemaiden.org/forum/index.php?topic=30.0) if you're really interested in danmakufu. Some of it will be refresher from the videos, but I guarentee you'll have a much deeper understanding if you read through the basic tutorial, rather than if you just go by a ten minute video...

And yes, it covers spawning bullets from other bullets and lasers.

Tutorial thread index (http://www.shrinemaiden.org/forum/index.php?topic=385.0) is stickied by the way, when you're ready to learn a new topic.
Aye I've got that down. From what I can tell, this is a coding mess up on my end XD. I think it's down to how I have the lasers aimed which is causing this problem :V Or something to that effect

http://www.majhost.com/gallery/DarkOverord/Other/SS2/Toehoes/ohyoucrazylasers.png

Because as seen in this picture, in the default starting position it's only spawning 3/4, whereas in the right side, all 4 are spawning (Ignoring the red laser) I'll post my (Very messy) code though, or at least the relevant part, as I doubt you need all the BG stuff. Maybe someone will see how I've messed this up.

Code: [Select]
task MainTask{
      wait(60);
      loop{
         fire;
         wait(300);
      }
   }

task fire{
let x=0;
let g=3;
let z=0;
loop{
let Angle = GetAngleToPlayer;
let dir = Angle-45;
while(x<4){
if(g==4){g=5}
Laser1(GetEnemyX+50*cos(dir),GetEnemyY+50*sin(dir),dir,g,20);

if(z==3){
wait(15);
CreateLaserA(1,GetEnemyX+50*cos(dir+135),GetEnemyY+50*sin(dir+135),500,15,2,40);
SetShotDirectionType(PLAYER);
SetLaserDataA(1,0,0,0,0,0,0);
SetShotKillTime(1,130);
SetShotDirectionType(ABSOLUTE);
FireShot(1);}


if(g==5){g=2};
g++;
x++;
Angle+=90;
dir+=90;
z++;


}
wait(200);
yield;
}
}

task Laser1(x,y,dir,g,delay){
let obj = Obj_Create(OBJ_LASER);

Obj_SetPosition(obj,x,y);
ObjLaser_SetLength(obj,500);
ObjLaser_SetWidth(obj,20);
ObjShot_SetGraphic(obj,g);
ObjShot_SetDelay(obj,delay);
ObjLaser_SetSource(obj,true);
Obj_SetAngle(obj,dir);

let bulletx;
let bullety;

let a1=atan2((GetClipMinY - Obj_GetY(obj)), (GetClipMinX - Obj_GetX(obj)))+360;
let a2=atan2((GetClipMinY - Obj_GetY(obj)), (GetClipMaxX - Obj_GetX(obj)))+360;

if(dir<a1){
bulletx=GetClipMinX;
bullety=Obj_GetY(obj)+(bulletx-Obj_GetX(obj))*tan(Obj_GetAngle(obj)-180);
} else{ if(dir>a2){
bulletx=GetClipMaxX;
bullety=Obj_GetY(obj)+(bulletx-Obj_GetX(obj))*tan(Obj_GetAngle(obj)-180);
} else{
bullety=GetClipMinY;
bulletx=Obj_GetX(obj)-(bullety-Obj_GetY(obj))*tan(Obj_GetAngle(obj)-90);
}
}

let j = 0;
let dir2 = 0;
while(j<6){
CreateShotA(5, bulletx, bullety, 5);
SetShotDataA(5, 0, 2, dir2, 0.5, 0.1, 3, g-2+209);
FireShot(5);
j++;
dir2+=360/6;
}

wait(180);
ObjShot_FadeDelete(obj);



}

function wait(w){
loop(w){yield;}
}
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on February 09, 2010, 08:48:38 AM
KrakoCloud: It's @BackGround, not @Background. Remember that Danmakufu is case-sensitive and also written by Japanese people so some things may not make sense and just require memorization. (ClearByteCodeCash lololol)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on February 09, 2010, 11:31:39 PM
KrakoCloud: It's @BackGround, not @Background. Remember that Danmakufu is case-sensitive and also written by Japanese people so some things may not make sense and just require memorization. (ClearByteCodeCash lololol)

Pffft. It works now.

Thank you. >_>"
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kinzo the Astro Curious on February 10, 2010, 02:14:11 AM
Hmm... watched a few tutorials on danmakufu and had a go, and seem to be having trouble with a particular command.

GetCenterX
and GetCenterY

just cause an error and it conks out. No idea whats going on, I'm just entering what i think is the centre value manually now  ???
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade on February 10, 2010, 02:23:29 AM
I thought GetCenterX and GetCenterY were constant values and that they were just put into Danmakufu so that you didn't have to calculate the values yourself. Like if you were making a command that involved putting in x and y values, those would work.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 10, 2010, 02:36:34 AM
They're there so people can clearly read code. It's easy to tell what's going on when you see those methods used in place of arbitrary numbers. It's not so easy to tell when all you see is numbers left, right and center, since many people don't recognize 224 as GetCenterX, or 240 as GetCenterY. Which, by the way, are those values.

Here are the contants, if you want. It's sometimes useful to know them so:

GetCenterX = 224;
GetCenterY = 240;
GetClipMinX = 32;
GetClipMinY = 16;
GetClipMaxX = 416;
GetClipMaxY = 464;

Uh, don't try to impress people or save your time by just using these numbers in your script. It's much easier to read if you use the method names rather than the values they hold.

Also, Torpedo, you probably just used them incorrectly. You may post your code and we can troubleshoot it for you, if you like.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kinzo the Astro Curious on February 10, 2010, 03:52:45 AM
Odd, I didnt have the original file anymore but I had modified it with the actual values as I found them on the the touhou wiki, so I thought I would test it with the GetCenterX and GetCenterY values instead and see if it should be working then realised what I've been doing lol.

Been typing "GetCentre" instead of "GetCenter" though im sure the first spelling is the right one, but I guess not in danmakufu lol.

Tricky to get used to this ;, and == business, I program in basic language usually lol. Though matlab and thyme have their similarities.

Still, Ive used the alternative command to make a spinning colour wheel that cycles all 7 (as I saw this on a youtube video and wanted to try and copy it lol) so I'm pleased so far. But im miles off touhou dance contest!

EDIT : one wikipedia later and I've found the problem. God damned american english! I was right - for my country lol
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 10, 2010, 04:01:51 AM
God damned american english!

Haha, this is the least of your worries. Wait until you start encountering the blatant spelling errors, like SetIntersecrionLine, COODINATE or ClearByteCodeCash.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on February 10, 2010, 09:48:03 AM
Haha, this is the least of your worries. Wait until you start encountering the blatant spelling errors, like SetIntersecrionLine, COODINATE or ClearByteCodeCash.

This. 

I damn my British-English often because when using codes like 'SetColour' which will very quickly throw an error at you =|
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kinzo the Astro Curious on February 12, 2010, 01:25:46 AM
Can you make a bullet retreive its own angle, or would you always have to calculate the angle it will now be at, relative to the angle you spawned it from?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on February 12, 2010, 01:31:38 AM
Either a constantly adjusting variable or Obj_GetAngle(obj).
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kinzo the Astro Curious on February 12, 2010, 02:42:58 AM
How do I reference the bullet with that command? would I need to set up the bullet specially?

I'm guessing what I'm asking for definately isnt something covered by the basics tutorial here. Still I got something that worked in the end by calculation.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 12, 2010, 03:43:17 AM
Yes, you would need to make an object bullet, otherwise you're stuck using calculations to determine where your bullet will end up.

Not that "angular velocity * frames" is a hard calculation to do but.... Yeah.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kinzo the Astro Curious on February 12, 2010, 03:55:02 AM
its only going to be that simple if you only tell the bullet to only turn consistantly up to that point... and thats boring  :V (hence hoping for an easier way)

I'll get the basics down before I start faffing around with object scripting though.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade on February 12, 2010, 03:58:23 AM
I am having trouble with certain part of an experimental script. There's only one part that really matters, so I'll post that

Quote

   task root(x,y,v,dir,graphic,delay){
      let obj = Obj_Create(OBJ_SHOT);

      Obj_SetPosition(obj,x,y);
      Obj_SetSpeed(obj,v);
      Obj_SetAngle(obj,dir);
      ObjShot_SetGraphic(obj,graphic);
      ObjShot_SetDelay(obj,delay);
      ObjShot_SetBombResist(obj,false);

      if(!Obj_BeDeleted(obj)){
         loop{
            if(((Obj_GetX(obj)-GetEnemyX)^2+(Obj_GetY(obj)-GetEnemyY)^2)^0.5>rand_int(60,120)){
               ObjShot_FadeDelete(obj);
            }
            Obj_SetAngle(obj,Obj_GetAngle(obj)+rand_int(-35,35));
            CreateShotA(1,Obj_GetX(obj),Obj_GetY(obj),20);
            SetShotDataA(1,0,0.08,rand_int(0,359),0,0,0.04,GREEN05);
            SetShotKillTime(1,240);
            FireShot(1);

            wait(12);
            yield;

         }
      }
   }


As you can see, it's an object bullet. It works fine rignt now, but I've been trying to make it do something when it gets deleted.
I've tried using if(Obj_BeDeleted(obj)==true) in several spots, but for some reason whatever I put in there either 1. starts even when the shot isn't deleted and happens even when the shot doesn't exist (i.e. they spawn out of the top-left corner, or 2. doesn't happen.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 12, 2010, 04:12:28 AM
  task root(x,y,v,dir,graphic,delay){
      let obj = Obj_Create(OBJ_SHOT);

      Obj_SetPosition(obj,x,y);
      Obj_SetSpeed(obj,v);
      Obj_SetAngle(obj,dir);
      ObjShot_SetGraphic(obj,graphic);
      ObjShot_SetDelay(obj,delay);
      ObjShot_SetBombResist(obj,false);

      //"while the bullet is not deleted, do the following"
      while(!Obj_BeDeleted(obj)){
            if(((Obj_GetX(obj)-GetEnemyX)^2+(Obj_GetY(obj)-GetEnemyY)^2)^0.5>rand_int(60,120)){
               ObjShot_FadeDelete(obj);
            }
            //this is going to make the bullet's almost completely random, which you probably don't want to do.
            Obj_SetAngle(obj,Obj_GetAngle(obj)+rand_int(-35,35));
            //this is going to create bullets every frame, I dont think you want to do that either.
            CreateShotA(1,Obj_GetX(obj),Obj_GetY(obj),20);
            SetShotDataA(1,0,0.08,rand_int(0,359),0,0,0.04,GREEN05);
            SetShotKillTime(1,240);
            FireShot(1);
            //If you want the angle changing and bullet spawning to happen every thirteen frames (Wait(12) + yield, like you had before), you could say "if(frame%13==0){ SpawnBulletChangeAngle; }" inside this while loop, and say frame++; at the beginning of the loop. This way, everything you've put inside there will occur every thirteen frames. Obviously, declare the variable "frame".

            //Since while statements will repeat during the one frame, we'll need to yield to postpone the check till the next frame.
            yield;
      }
   //So this is outside of the while loop, meaning after the bullet is deleted, since the loop will only occur if the bullet isn't alive. Insert whatever you want to happen upon death here.
   dostuff;
   }
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade on February 12, 2010, 05:21:38 PM
Actually, I did want it to randomly change angles. But that's besides the point.
I solved the problem with your suggestion of using an if statement and creating a variable (named count instead of frame 'cuz I'm cool like that).

Quote

         if(count%13==0){
            Obj_SetAngle(obj,Obj_GetAngle(obj)+rand_int(-35,35));
            CreateShotA(1,Obj_GetX(obj),Obj_GetY(obj),20);
            SetShotDataA(1,0,0.08,rand_int(0,359),0,0,0.04,GREEN05);
            SetShotKillTime(1,240);
            FireShot(1);
            wait(12);
         }


But then I created another if statement within the same while loop telling it what to do if it went over a certain value.
I still have no idea about what that percent sign does, but thanks.

But now I've hit another problem: I can't run #BGM without it crashing, and I've no idea why.
My script and music are both in the same folder, but the music is in a sub-folder called bgm.

I've tried putting in #BGM[.\bgm\blah.wav], and it just crashes Danmakufu.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 12, 2010, 06:01:31 PM
Hm, I've encountered this problem too. As far as I can tell, you just have to restart the script several times and it will eventually stop crashing for good. From my experience this can happen when you modify any of the # lines that affect the actual playing of the script, ie. #BGM and #BackGround.

I assume danmakufu stores some data of the script for loading purposes or something like that. When you change the lines, danmakufu will get confused from the differences between the stored data and the actual data and barf. If you attempt to play the script a couple of times more, eventually you will overwrite the old stored information with the new data and danmakufu won't barf anymore until you change the line again.

Hmm, if my theory is correct, then you should also make the crashing disappear by renaming the file or putting it in a different folder. Also, if you then create a different script with the old name of the crashing script, the new script will probably crash a couple of times, too. I should probably test that...



Now a question from me: Could it be that the collision detection for very thin or short lasers is incredibly off?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on February 12, 2010, 06:06:32 PM
I thought you had to put #BGM[User(filepath)]
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on February 12, 2010, 06:20:53 PM
I thought you had to put #BGM[User(filepath)]
That's for #BackGround[User(filepath, horizontal scrolling, vertical scrolling)]
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on February 13, 2010, 06:08:16 AM
Stuffman has a question for once!

Hey, you know how CtC skips the main menu when you play a replay? How does it do that? I get how you could save the player/difficulty choices from the menu with common data and use a IsReplay check to get that, but how do you get it to ignore the input that came in from the menu?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on February 13, 2010, 06:11:22 AM
Stuffman has a question for once!

Hey, you know how CtC skips the main menu when you play a replay? How does it do that? I get how you could save the player/difficulty choices from the menu with common data and use a IsReplay check to get that, but how do you get it to ignore the input that came in from the menu?
You mean the custom menu? (With GAME START, PRACTICE MODE, etc)

Perhaps they did something like if not IsReplay then display menu, else it doesn't show up.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on February 13, 2010, 06:12:17 AM
I'm not sure if this is the method that CtC uses, but I set common data, use the Retry; function, then on startup, load and check for that data. Replays go from the beginning of the current run, and Retry; can be used to re-locate that beginning. It's kind of hard to explain, but I think you should be able to figure it out from there.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on February 13, 2010, 06:24:33 AM
I'm not sure if this is the method that CtC uses, but I set common data, use the Retry; function, then on startup, load and check for that data. Replays go from the beginning of the current run, and Retry; can be used to re-locate that beginning. It's kind of hard to explain, but I think you should be able to figure it out from there.

Oh that is so fucking clever.

Yeah I think I get how to do this.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on February 13, 2010, 06:35:04 AM
Yeah I think I get how to do this.
I don't :x

So you set the start point with commondata and use Retry; during replays to start from that point?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on February 13, 2010, 07:30:57 AM
Retry; restarts the script, of course. It doesn't sound useful, but that's what my trick was for. Basically, it goes like this.

The part in your menus that would otherwise start the stage:
Code: [Select]
SetCommonData("SkipMenu",1);
SaveCommonData;
Retry;

In @Initialize:
Code: [Select]
LoadCommonData;
if(GetCommonDataDefault("SkipMenu",0)==1){
  DeleteCommonData("SkipMenu");
  LoadStage;
}else{
  LoadMenu;
}

When you start the script, it will branch to LoadMenu. When you're done with the menu (it reaches the Retry; code block), it sets the common data and resets the script - but then when it loads, it will branch to LoadStage instead.

This was my secret, but since you asked, I guess I can't hide it anymore, heh.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kinzo the Astro Curious on February 13, 2010, 04:42:55 PM
I'm stuck lol. I've got a 100x100 image im trying to use to animate (its 4 frames inside that space)

Code: [Select]
script_enemy_main{

let CSD = GetCurrentScriptDirectory;
let imgboss = CSD ~ "IMG\BossA.png";


@Initialize{
LoadGraphic(imgboss);
SetLife(1000);
SetMovePosition01(224 ,150 ,5);
let c = 1;
let f = 1;

mainTask;
}

@MainLoop{
       SetCollisionA(GetX, GetY, 32);
       SetCollisionB(GetX, GetY, 24);
yield;
}

@DrawLoop{
SetTexture(imgboss);
SetRenderState(ADD);
SetGraphicScale(2,2);
SetGraphicAngle(0,0,0);
if(f<10){
SetGraphicRect(0,0,50,50);
}
if(f>=10){
SetGraphicRect(50,0,100,50);
}
DrawGraphic(GetX,GetY);
f++;
if(f==20){f = 1;}
}

Its only a snippet of the code, but these are the only relevant parts to what it crashes on. I dont get why its crashing either, but it goes down at the if statement.

Its definately something stupid, but then I haven't exactly been coding in this language type before now lol.

EDIT : forgot to say I've had this run with just the "SetGraphicRect(0,0,50,50);" line and not trying to make it animate, so Its not the image thats the problem.

EDIT AGAIN : Nevermind, got there in the end. nothing was wrong with the if statement, thats what was racking my brain so much. Its that let f = 0 was being defined in the same frame it was called in a different thread, so moving it before initialize solved the problem.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on February 13, 2010, 05:20:55 PM
I'm stuck lol. I've got a 100x100 image im trying to use to animate (its 4 frames inside that space)

Code: [Select]
script_enemy_main{

let CSD = GetCurrentScriptDirectory;
let imgboss = CSD ~ "IMG\BossA.png";


@Initialize{
LoadGraphic(imgboss);
SetLife(1000);
SetMovePosition01(224 ,150 ,5);
let c = 1;
let f = 1;

mainTask;
}

@MainLoop{
       SetCollisionA(GetX, GetY, 32);
       SetCollisionB(GetX, GetY, 24);
yield;
}

@DrawLoop{
SetTexture(imgboss);
SetRenderState(ADD);
SetGraphicScale(2,2);
SetGraphicAngle(0,0,0);
if(f<10){
SetGraphicRect(0,0,50,50);
}
if(f>=10){
SetGraphicRect(50,0,100,50);
}
DrawGraphic(GetX,GetY);
f++;
if(f==20){f = 1;}
}

Its only a snippet of the code, but these are the only relevant parts to what it crashes on. I dont get why its crashing either, but it goes down at the if statement.

Its definately something stupid, but then I haven't exactly been coding in this language type before now lol.

EDIT : forgot to say I've had this run with just the "SetGraphicRect(0,0,50,50);" line and not trying to make it animate, so Its not the image thats the problem.

EDIT AGAIN : Nevermind, got there in the end. nothing was wrong with the if statement, thats what was racking my brain so much. Its that let f = 0 was being defined in the same frame it was called in a different thread, so moving it before initialize solved the problem.

Use the Animation Handling Library (http://www.shrinemaiden.org/forum/index.php?topic=4711.0) to save yourself from the headaches of coding animation logic.
[/self-promotion]
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kinzo the Astro Curious on February 13, 2010, 09:37:23 PM
If im honest, trying to work out how to use it seems more confusing to me than just going along as I am at the moment, now I've figured what that stupid mistake was.  :blush:

Speaking of stupid mistakes

I want this code to fire bullets out randomly in all directions, but then descend downward. (thats the red bullets, I am having no trouble with the yellow ones)

It only fires bullets to the right however, which I'm baffled by :s I even nulled both accelerations to try and counter that.

Code: [Select]
task fire{
wait(120);
loop{
    loop(24){
let velx = rand(0,4);
let vely = rand(0,4);
CreateShotA(1,GetX, GetY, 0);
SetShotDataA_XY(1,0, velx -2,vely - 2,(velx - 2) / 60,0.1,NULL,NULL,RED01);
FireShot(1);
}
wait(20);
loop(20){
CreateShot01(GetX,GetY,2, rand(0,360), YELLOW12 ,0);
}
wait(10);
}
}

modding the code into this let me get SOMEWHERE, but the shots are firing primarily down a diagonal.

(IGNORE THIS CODE BELOW, ITS JUST PROOF IM A 9)
Code: [Select]
task fire{
wait(120);
loop{
    loop(24){
let dir = -1;
loop(2){
let velx = rand(0,4);
let vely = rand(0,4);
CreateShotA(1,GetX, GetY, 0);
SetShotDataA_XY(1,0, velx * dir,vely * dir,(velx * dir) / 60,0.1,dir*5,10,RED01);
FireShot(1);
dir = 1;
}
}
wait(20);
loop(20){
CreateShot01(GetX,GetY,2, rand(0,360), YELLOW12 ,0);
}
wait(10);
}
}
Ends up leaving the top right totally uncovered by the red bullets, and it definately isnt firing into the bottom left (but they descend there anyway from the above ones)
(http://i11.photobucket.com/albums/a180/manmuppet/screenie.png)
Also yes, I am a flying car.  :V

EDIT : LOL I know why the modded code behaved like it did now. Still, any solution to the original code to get all the random directions?

SetShotDataA_XY's behavior is confusing :/ ... or I'm just not sleeping enough and something daft is wrong in that one too  :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DgBarca on February 14, 2010, 01:25:33 PM
So, like I said on IRC, I want to do a custom UFOish life and bomb counter, but I kinda fail to it, I have that :
When getting a item (http://pastebin.com/m7ee6fcd3)
Array arrange (http://pastebin.com/m3f4c1984)
CreateLifeCount(x,y,num) works properly when used separately but I fail how to fire it proprely...

I really want it to work, it is almost finished (http://img9.imageshack.us/img9/7447/ufopk.png)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: lactose on February 14, 2010, 08:38:55 PM
Code: [Select]
#TouhouDanmakufu
#Title[unknown]
#BGM[.\bgm.mp3]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
 
        let CSD = GetCurrentScriptDirectory;

        let imgBoss = CSD ~ "system\cirno.png";
        let cut = CSD ~ "system\cirnocut.png";
        let bg = CSD ~ "system\lake.png";
     



         @Initialize {
                 SetLife(3000);
                 SetTimer(30);
                 SetScore(50000);
         SetMovePosition01(GetCenterX,GetCenterY,10);
                 LoadGraphic(imgBoss);
                 LoadGraphic(cut);
                 LoadGraphic(bg);

                 CutIn(YOUMU,"Powder storm",cut,0,0,300,384);

         mainTask;

         }

         @MainLoop{
                SetCollisionA(GetX,GetY,32);
                SetCollisionB(GetX,GetY,16);
            yield;
         }

         @DrawLoop{       
 
                 // data for the boss
                 SetTexture(imgBoss);   
                 SetRenderState(ALPHA);
                 SetAlpha(255);
                 SetGraphicRect(0,0,110,110);
                 SetGraphicScale(0.7,0.7);
                 SetGraphicAngle(0,0,0);
                 DrawGraphic(GetX,GetY);

         }

         @BackGround{
           
                 SetTexture(bg);   
                 SetRenderState(ALPHA);
                 SetAlpha(255);
                 SetGraphicRect(0,0,512,512);
                 SetGraphicScale(1,1);
                 SetGraphicAngle(0,0,0);
                 DrawGraphic(GetCenterX,GetCenterY);
         }   
     
         @Finalize{
                 // delete the image from memory
                 DeleteGraphic(imgBoss);
                 DeleteGraphic(cut);
                 DeleteGraphic(bg);


         }


         // main task. activates stuff.
         task mainTask{
         yield;
               fire;
         }


         task fire{
                 let x = 0;
                 let dir = 180;
                 loop{
                       while(x<8){
                          superbullet(GetEnemyX,GetEnemyY,3,dir,AQUA01,0);
                          dir+=180/8;
                          x++;
                       }
                       x = 0;
                       dir=180;
                       wait(90);
                       yield;
                 }
        }

         // object bullet task
task superbullet(x,y,v,dir,graphic,delay){
                 let obj = Obj_Create(OBJ_SHOT);

                 Obj_SetPosition(obj,x,y);
Obj_SetSpeed(obj,v);
                 Obj_SetAngle(obj,dir);
                 ObjShot_SetGraphic(obj,graphic);
                 ObjShot_SetDelay(obj,0);
ObjShot_SetBombResist(obj,true);

                 while(Obj_BeDeleted(obj)==false) {

                         Obj_SetSpeed(obj,0);         // stop the bullet
                         wait(30);                    //wait half second
                         Obj_SetAngle(obj, atan2(GetPlayerY - Obj_GetY(obj), GetPlayerX - obj_GetX9obj)));  // Homes
                         ObjShot_SetGraphic(obj,Aqua23);           // changes graphic
                         Obj_SetSpeed(obj,4);                 // Fires bullets

         yield;
                 }                 
        }
         





         }


     }


It says there's something wrong with the wait function, but I can't find anything wrong? Any ideas.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 14, 2010, 08:45:28 PM
There is no regular wait(); command in danmakufu. You are calling a wait(); function. You didn't define a wait(); function.

What you need is this:

Code: [Select]
function wait(t){
    loop(t){ yield; }
}

Put it somewhere to the variable definitions at the beginning of the script.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on February 16, 2010, 06:42:02 PM
Trying to load a boss script in a stage file and I get this

---------------------------
ScriptError「C:\Users\Owner\Desktop\Danmakufu\script\Contest 4\Suikamahaha\GeineGoose.txt」
---------------------------
SetLifeが見つかりません
C:\Users\Owner\Desktop\Danmakufu\script\Contest 4\Suikamahaha\sp2heaven.txt(37行目)

         CreateEnemyBossFromFile(GetCurrentScriptDirectory ~ "pluralheaven.txt", 0, 0, 0, 0, 0);

      }

   }



   @BackGround

   {

      //B
~~~
---------------------------
OK   
---------------------------

Boss file works fine by itself

Edit: solved ._.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 16, 2010, 08:30:42 PM
I has question, iv'e seen the great dance master Helepolis do it, so I know it is not within the realm of imposibility. How do I draw on top of the default stats? you know on the game frame? And on that note is it possible to erase the side stats? (the fake SA phantasm also did it...somehow) id like to revamp the side bar with stuff like Power, and more updated graphics.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on February 16, 2010, 09:20:43 PM
And on that note is it possible to erase the side stats?
It's something along the lines of:
Code: (ERASE THE SIDE STATS!!) [Select]
SetDefaultStatusVisible(boolean);
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 17, 2010, 04:32:29 AM
I has question, iv'e seen the great dance master Helepolis do it, so I know it is not within the realm of imposibility. How do I draw on top of the default stats? you know on the game frame? And on that note is it possible to erase the side stats? (the fake SA phantasm also did it...somehow) id like to revamp the side bar with stuff like Power, and more updated graphics.

I don't know how I missed this question for so long but whatever. Using object effects set on layer 8 (ObjEffect_SetLayer(obj, 8 );) will draw above absolutely everything inside the program window. SetDefaultStatusVisible(false); erases all the information on the stg frame (except the fps counter). SetRateScoreSystemEnable(false); gets rids of the default point system that you see in the bottom left corner (it's different from the default stati).
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 17, 2010, 04:36:04 AM
I don't know how I missed this question for so long but whatever. Using object effects set on layer 8 (ObjEffect_SetLayer(obj, 8 );) will draw above absolutely everything inside the program window. SetDefaultStatusVisible(false); erases all the information on the stg frame (except the fps counter). SetRateScoreSystemEnable(false); gets rids of the default point system that you see in the bottom left corner (it's different from the default stati).

Oooo~ to think its so simple, I already have a few functions set up to do easy effect objects, im going to have fun with this tomorow~
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 17, 2010, 04:37:38 AM
Oooo~ to think its so simple

Ahh I'm glad I'm not the only person who actually finds most of Danmakufu's workarounds to be somewhat simple :<
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 17, 2010, 02:23:24 PM
Hrmmm, interesting....
Annoying... yet interesting...  :/

Apparently when you create a SinuateLaser object and reduce the laser length after the creation beyond a certain value that depends on the width of the laser, the shot graphic rect gets distortet so that you can see the bullet graphics that are next to the actual bullet graphic in the used shot sheet.

What.
Title: Danmakufu Makeover
Post by: WriggleNightbug on February 19, 2010, 01:07:12 AM
Alright so ive been working on a customized frame setup for my game, I need to use the use of numbers from now on so im gonna need to start changing the built-in graphics, I remember hearing that the built in resources can be modified:

1. how do I change the number fonts with my own? (for score, high score, power, etc)
2. I found a folder that changes the default sounds, where do I put it?
3. Can I remove the floating doilies around the boss?
4. Can I color the health bars? grey feels outdated...

I suppose this thread could also be dedicated to all the others who want to give their danmakufu some flavour too, so feel free to ask your questions too! ^^
Title: Re: Danmakufu Makeover
Post by: Suikama on February 19, 2010, 01:13:28 AM
The floating squares can be removed by adding MagicCircle(false); in init
Title: Re: Danmakufu Makeover
Post by: WriggleNightbug on February 19, 2010, 01:15:25 AM
The floating squares can be removed by adding MagicCircle(false); in init

That works out great I was planning on using my own circle graphics ^^
Title: Re: Danmakufu Makeover
Post by: Naut on February 19, 2010, 01:32:51 AM
1. how do I change the number fonts with my own? (for score, high score, power, etc)

Object effects, layer 8.

(http://i641.photobucket.com/albums/uu134/Nautth/snapshot000a.jpg)

2. I found a folder that changes the default sounds, where do I put it?

~\se

3. Can I remove the floating doilies around the boss?

You can edit effect.png for danmakufu and add in your own graphics if you want, but basically requires you to export your own th_dnh.exe folder with your game, since the image will be in a root folder.

4. Can I color the health bars? grey feels outdated...

Build your own, object effects, layer 5 or greater.
Title: Re: Danmakufu Makeover
Post by: WriggleNightbug on February 19, 2010, 01:37:45 AM
Object effects, layer 8.

(http://i641.photobucket.com/albums/uu134/Nautth/snapshot000a.jpg)

~\se

You can edit effect.png for danmakufu and add in your own graphics if you want, but basically requires you to export your own th_dnh.exe folder with your game, since the image will be in a root folder.

Build your own, object effects, layer 5 or greater.

Oh I see, I could simply draw over the existing healthbar, one question though, how did you implement ZUN font? is there a simple way of turning your graphics into numbers like that?
Title: Re: Danmakufu Makeover
Post by: Naut on February 19, 2010, 01:45:36 AM
No, there is no way to actually change them. You'd have to write your own function to convert numbers to strings and then select and draw images in correspondance.
Title: Re: Danmakufu Makeover
Post by: WriggleNightbug on February 19, 2010, 01:53:01 AM
No, there is no way to actually change them. You'd have to write your own function to convert numbers to strings and then select and draw images in correspondance.

I worried it would end up being that way, new question:

which function converts a number into a string in danmakufu?
Title: Re: Danmakufu Makeover
Post by: Suikama on February 19, 2010, 01:53:32 AM
No, there is no way to actually change them.
Hooray for danmakufu!
Title: Re: Danmakufu Makeover
Post by: Naut on February 19, 2010, 01:56:15 AM
which function converts a number into a string in danmakufu?

ToString(23442);

returns

"23442.000000"
Title: Re: Danmakufu Makeover
Post by: WriggleNightbug on February 19, 2010, 01:57:53 AM
ToString(23442);

returns

"23442.000000"

I suppose theres no easy way to getting only one digit?...unless you devided with 10, 100, 1000, etc, then used the flooring thing, THEN made it string, think that would work?
Title: Re: Danmakufu Makeover
Post by: Naut on February 19, 2010, 02:03:15 AM
You can erase elements of a string just like an array. If you don't want six decimal places, just say:

let number = 23442;
number = ToString(number); //"23442.000000"
loop(7){
   number = erase(number, length(number)-1);
}

number now equals "23442".

Also, most of these questions could've gone in the Q&A thread.
Title: Re: Danmakufu Makeover
Post by: WriggleNightbug on February 19, 2010, 02:08:03 AM
You can erase elements of a string just like an array. If you don't want six decimal places, just say:

let number = 23442;
number = ToString(number); //"23442.000000"
loop(7){
   number = erase(number, length(number)-1);
}

number now equals "23442".

that does making it alot cleaner ^^ Okay heres my plan:

1. Make an effect object with an array of 10 numbers
2. Repeat the drawing task for the number of characters in the string, increasing the x drawing value
3. Make it so each seperate digit is put into the right effect using the arrays

id need:

1.a way to get how many characters are in the string
2.a way to get each digit alone so it can pick the right part of the array
Title: Re: Danmakufu Makeover
Post by: Drake on February 19, 2010, 02:09:52 AM
length(string), and string[n].

go away naut i see you there
Title: Re: Danmakufu Makeover
Post by: WriggleNightbug on February 19, 2010, 02:21:41 AM
length(string), and string[n].

go away naut i see you there

so the length is returned in number of characters
and string dooooes...wait theres a function just called string?
Title: Re: Danmakufu Makeover
Post by: Drake on February 19, 2010, 02:22:51 AM
No, a string is technically just an array of characters. Because of this, you can access the individual characters like you can in an array.
string is just an example variable that contains a string.

string = "apple";
string[4] would equal 'e'.
Title: Re: Danmakufu Makeover
Post by: WriggleNightbug on February 19, 2010, 02:32:00 AM
No, a string is technically just an array of characters. Because of this, you can access the individual characters like you can in an array.
string is just an example variable that contains a string.

string = "apple";
string[4] would equal 'e'.

a string is an array!? well mah world is turned upside down =o this opens a few doors though, custom number display system will be my project for tomorow, once I master that, Il be able to finish my customized frame with no problem ^^
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on February 19, 2010, 06:55:20 AM
I don't see a reason to create seperate thread for Q&A-ish question. Merged topics, continue here.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 19, 2010, 06:41:35 PM
I keep bumping into a new problem, no matter what my number is, using Number[0] for example causes an error, the same error I get if I use a number bigger than the array (I have graphics for 0, 1 and 2 for testing purposes)

if my number is "100"
wouldnt Number[0] give me 1? why doesnt it fit into the effect object's array?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 19, 2010, 07:00:07 PM
Wait, after testing it some more I noticed the it never gives me a value, I tried it with drawtext and it gives me an error, while regular numbers work just fine, am I supposed to do something with the number afterwards?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on February 19, 2010, 08:01:48 PM
Strings are stored as an array, numbers aren't. In order to get each digit, this is what I did:

Code: [Select]
let num=GetScore;
while(num>0){
  digit=num%10; //get the ones digit

  //do stuff to draw the number to the screen

  num=trunc(num/10);  //divide by ten, so next loop will get the tens digit instead, and so on
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 19, 2010, 08:17:58 PM
Strings are stored as an array, numbers aren't. In order to get each digit, this is what I did:

Code: [Select]
let num=GetScore;
while(num>0){
  digit=num%10; //get the ones digit

  //do stuff to draw the number to the screen

  num=trunc(num/10);  //divide by ten, so next loop will get the tens digit instead, and so on
}

Oh Thank Yoooooou!

Iv'e been at it all day messing up my scripts and adding more stuff that didnt work, but now it works and the nightmare is over ^^ your awesome =D
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on February 19, 2010, 08:36:10 PM
Strings are stored as an array, numbers aren't. In order to get each digit, this is what I did:

Code: [Select]
let num=GetScore;
while(num>0){
  digit=num%10; //get the ones digit

  //do stuff to draw the number to the screen

  num=trunc(num/10);  //divide by ten, so next loop will get the tens digit instead, and so on
}

Oh, thanks. This will be useful for some time. *saves code*

P.S. Aw, dang. You remind me of the time I spend playing Mario games, Azure.

EDIT: That snippet of code!!
This is what the creators of Touhou Mushuugeki ~ Concealed the Conclusion did, isn't it!?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 19, 2010, 08:39:55 PM
Oh, thanks. This will be useful for some time. *saves code*

P.S. Aw, dang. You remind me of the time I spend playing Mario games, Azure.

EDIT: That snippet of code!!
This is what the creators of Touhou Mushuugeki ~ Concealed the Conclusion did, isn't it!?

To me it doesn't matter who did it, its a lifesaver  :* Il be done with my customized status setup by the end of today thanks to this
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on February 19, 2010, 08:42:59 PM
I got a question myself.
You know that bonus thingy under the name of the spell cards?
Is there a function to get this number?

...P.S. This post to be edited, once I get a screenshot of the thing.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 19, 2010, 08:50:06 PM
I got a question myself.
You know that bonus thingy under the name of the spell cards?
Is there a function to get this number?

...P.S. This post to be edited, once I get a screenshot of the thing.

Do you mean the one set with SetScore?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: lactose on February 19, 2010, 09:53:14 PM
Thanks. You got me through that problem, but now I have another.

Code: [Select]
#TouhouDanmakufu
#Title[blizzbullet]
#BGM[.\bgm.mp3]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
 
        let CSD = GetCurrentScriptDirectory;

        let imgBoss = CSD ~ "system\cirno.png";
        let cut = CSD ~ "system\cirnocut.png";
        let bg = CSD ~ "system\snowbg.png";
        let lay = CSD ~ "system\blizzard.png";

        let f = 0;
        let f2 = 0;

        let slide = 0;
     



         @Initialize {
                 SetLife(3000);
                 SetTimer(30);
                 SetScore(50000);
         SetMovePosition01(GetCenterX,GetCenterY,10);
                 LoadGraphic(imgBoss);
                 LoadGraphic(cut);
                 LoadGraphic(bg);
                 LoadGraphic(lay);

                 CutIn(YOUMU,"Powder storm",cut,0,0,300,384);

         mainTask;

         }

         @MainLoop{
                SetCollisionA(GetX,GetY,32);
                SetCollisionB(GetX,GetY,16);
            yield;
         }

         @DrawLoop{       
 
                 // data for the boss
                 SetTexture(imgBoss);   
                 SetRenderState(ALPHA);
                 SetAlpha(255);
                 SetGraphicRect(0,0,110,110);
                 SetGraphicScale(0.7,0.7);
                 SetGraphicAngle(0,0,0);
                 DrawGraphic(GetX,GetY);

         }

         @BackGround{
           
                 SetTexture(bg);   
                 SetRenderState(ALPHA);
                 SetAlpha(255);
                 SetGraphicRect(0,0,512,512);
                 SetGraphicScale(1,1);
                 SetGraphicAngle(0,0,0);
                 DrawGraphic(GetCenterX,GetCenterY);

                 SetTexture(lay);   
                 SetRenderState(ADD);
                 SetGraphicRect(0,0,20000,20000);
                 SetGraphicScale(1,1);
                 SetGraphicAngle(0,0,0);
                 DrawGraphic(GetCenterX+slide,GetCenterY+slide);

                 slide+=2;
         }   
     
         @Finalize{
                 // delete the image from memory
                 DeleteGraphic(imgBoss);
                 DeleteGraphic(cut);
                 DeleteGraphic(bg);


         }

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

         // main task. activates stuff.
         task mainTask{
                 wait(120);
         yield;
                 movement;
                 fire2;
         }



         task movement{

                 loop{

                         SetMovePositionRandom01(60,30,10,GetCenterX-120,GetCenterY-100,GetCenterX+120,GetCenterY-40);
                         wait(30);
                         SetColor(128,128,255);
                         Concentration01(80);
                         SetColor(225,225,225);
                         wait(30);
                         fire;
                         wait(180);
                         yield;
       
                  }

         }
         task fire{
                 let x = 0;
                 let dir = rand_int(0,359);

                 while(x<16){
                          superbullet(GetEnemyX+60*cos(dir),GetEnemyY+60*sin(dir),3,dir,AQUA03,0);
                          dir+=22.5;
                          x++;
                      }
         }

         task fire2{
                 let x = 0;
                 let dir = 0;
   
                 loop{
                         while(x<36){
                                CreateShotA(1,GetEnemyX+20*cos(dir),GetEnemyY+20*sin(dir),0);
                                SetShotDataA(1,0,1,dir,-0.2,0,1,AQUA23);
                                FireShot(1);

                                CreateShotA(2,GetEnemyX+20*cos(dir),GetEnemyY+20*sin(dir),0);
                                SetShotDataA(2,0,1,dir,-0,2,0,1,AQUA23);
                                FireShot(2);

                                dir+=360/36;
                                x++;
                          }
                          x = 0;
                          dir = 0;
                          wait(90);
                          yield;
                      }


             }



         // object bullet task
task superbullet(x,y,v,dir,graphic,delay){
                 
                 let obj = Obj_Create(OBJ_SHOT);

                 Obj_SetPosition(obj,x,y);
Obj_SetSpeed(obj,v);
                 Obj_SetAngle(obj,dir);
                 ObjShot_SetGraphic(obj,graphic);
                 ObjShot_SetDelay(obj,0);
ObjShot_SetBombResist(obj,true);

                 while(!Obj_BeDeleted(obj)){
                     
                        wait(15);
                        Obj_SetSpeed(obj,0);
                        Concentration02(15);
                        wait(45);
                        ObjShot_SetGraphic(obj,RED03);
                        loop(8){
                                CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),4,dir,300,10,BLUE01,0);
                                dir+=360/8;
                 }
                 wait(60);
                 ObjShot_FadeDelete(obj);
                 yield;
                 }                 
        }
         





         }


     }


Apparently something is wrong with SetShotDataA. I have the 8 arguments. Should there be a function before hand telling danmakufu what SetShotData is?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Janitor Morgan on February 19, 2010, 09:55:31 PM
Thanks. You got me through that problem, but now I have another.

*snip*

Apparently something is wrong with SetShotDataA. I have the 8 arguments. Should there be a function before hand telling danmakufu what SetShotData is?

CreateShotA(2,GetEnemyX+20*cos(dir),GetEnemyY+20*sin(dir),0);
SetShotDataA(2,0,1,dir,-0,2,0,1,AQUA23);
FireShot(2);

Your -0.2 has an extra comma in it, making it nine arguments.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on February 19, 2010, 10:16:37 PM
To me it doesn't matter who did it, its a lifesaver  :* Il be done with my customized status setup by the end of today thanks to this
I don't know if anyone else thought of it before, but I made that up about 6 hours before I posted that. It's pretty simple when you think about it, actually.

Always Mew⑨: I think the function you want is GetSpellCardBonusScore.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on February 19, 2010, 11:28:51 PM
Always Mew⑨: I think the function you want is GetSpellCardBonusScore.

Thank you thank you thank you...
*goes to make custom cut in stuff*
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 20, 2010, 01:28:55 AM
Is there a way to obtain the high score? I need to draw it using my number function ^^
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on February 20, 2010, 01:39:56 AM
Is there a way to obtain the high score? I need to draw it using my number function ^^

There is a way to get the current score. If you want to get and store high score, you'll need to use common data.
oh hai im back and ready to answer questions again
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on February 20, 2010, 01:40:17 AM
Is there a way to obtain the high score? I need to draw it using my number function ^^
Use common data.
Example:
Code: [Select]
if(GetScore >= GetCommonDataDefault("HighScore", 0)) { SetCommonData("HighScore", GetScore); }

EDIT: Ah, fuck. Blargelunar-dial'd.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 20, 2010, 01:50:51 AM
There is a way to get the current score. If you want to get and store high score, you'll need to use common data.
oh hai im back and ready to answer questions again

Is there a way to make it so that the value wont be erased if the script is reset? =o
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on February 20, 2010, 01:54:05 AM
Is there a way to make it so that the value wont be erased if the script is reset? =o
Code: [Select]
SaveCommonData;
It saves all the common data in the file to a file named "The_Script_That_Is_Currently_Running.dat"

You can go to the Danmakufu Wiki (http://dmf.shrinemaiden.org) if you want more info on common data and stuff.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on February 20, 2010, 08:31:07 PM
Is there a way to have a A Laser to move straight down?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 20, 2010, 08:41:52 PM
When in doubt, use an object laser with Obj_SetY(obj, Obj_GetY(obj) + v); in the while{} brackets, v being the velocity of course.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on February 20, 2010, 08:55:55 PM
FRICKEN YIELD;!!!!! fixed it
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 20, 2010, 09:11:28 PM
That is odd. With your code, it shouldn't crash, it should freeze because you forgot the yield;  :V

Also, if you increase v by one every frame, the laser will accelerate to a speed of 10 after 10 frames. You will barely see it before it rushes off the screen with a velocity so fast that it can easily jump through the players hitbox.

Also, Obj_SetSpeed does nothing for a laser if I remember correctly.

Also, the crashing could be because YELLOW60 is not a bullet graphic in the shotsheet you are using.

Also, it looks like you might have an additional closing } bracket in there. That could of course be the couse for your crashing, too.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on February 20, 2010, 09:17:50 PM
Speaking of lasers, what bullet type is the best one to use for a projectile-type laser? Mine stretches out a ton, so I'm not quite sure what to use.

I'm using the 4.1 shotsheet, because it matters.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on February 20, 2010, 09:25:55 PM
Speaking of lasers, what bullet type is the best one to use for a projectile-type laser? Mine stretches out a ton, so I'm not quite sure what to use.

I'm using the 4.1 shotsheet, because it matters.

You're usually looking for the big bubble bullets, the ones with the white outline and actual tiny hitboxes.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on February 20, 2010, 09:27:16 PM
Also, for some reason I can't figure this out- how can I make custom player characters actually appear on my list? Right now it's only Reimu/Marisa/Rumia.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 20, 2010, 09:29:25 PM
Well, put the respective folder in your player folder, make shure that the player script has the correct head, and then try to scroll sideways inside the player select menu.

Also, if you are making your own player character, make shure that the folder your player script is in has a one-word-name. For some reason danmakufu will read a folder "Youmu Player" as two folders named "Youmu" and "Player" when inside the player directory, so danmakufu will crash when you try to select the player.

Other than that, I don't know...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on February 20, 2010, 09:34:25 PM
Well, put the respective folder in your player folder, make shure that the player script has the correct head, and then try to scroll sideways inside the player select menu.

Also, if you are making your own player character, make shure that the folder your player script is in has a one-word-name. For some reason danmakufu will read a folder "Youmu Player" as two folders named "Youmu" and "Player" when inside the player directory, so danmakufu will crash when you try to select the player.

Other than that, I don't know...

My bad, it's the card/plural scripts themselves restricting the characters to the default. Derp.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on February 20, 2010, 09:44:53 PM
You're usually looking for the big bubble bullets, the ones with the white outline and actual tiny hitboxes.

That works fairly well, but I was thinking more along the lines of the Nue/Letty/Merlin/Shou curved lasers.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 20, 2010, 09:52:09 PM
In that case I'd use the ones commented as "Glowing medium round bullets (right side)"
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on February 21, 2010, 01:15:25 AM
Code: [Select]
task gammaray(theta){
let dtheta = rand(-25,25);
let tracked = false;
let gamray = Obj_Create(OBJ_SINUATE_LASER);
Obj_SetPosition(gamray,GetX,GetY);
Obj_SetSpeed(gamray,1);
Obj_SetAngle(gamray,theta+dtheta);
ObjShot_SetGraphic(gamray,GREEN41);
ObjSinuateLaser_SetWidth(gamray,4);
ObjSinuateLaser_SetLength(gamray,30);
while(!Obj_BeDeleted(gamray)){
while(tracked == false){
if(GetDistance(GetPlayerX,GetPlayerY,Obj_GetX(gamray),Obj_GetY(gamray)))<150){
Obj_SetAngle(gamray,atan2(GetPlayerY-GetY,GetPlayerX-GetX));
Obj_SetSpeed(gamray,4);
tracked = true;
}
yield;
}
if(Obj_GetY(gamray)>GetClipMaxX){
Obj_SetAngle(gamray,180-Obj_GetAngle(gamray));
}
yield;
}
}
...
function GetDistance(x1,y1,x2,y2){
return((((x2-x1)^2)+((y2-y1)^2))^(1/2);
}

I get an error saying I have mismatched braces somewhere in this task. Where is it?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade on February 21, 2010, 01:35:34 AM
         if(GetDistance(GetPlayerX,GetPlayerY,Obj_GetX(gamray),Obj_GetY(gamray)))<150){

   function GetDistance(x1,y1,x2,y2){
      return((((x2-x1)^2)+((y2-y1)^2))^(1/2);
   }


Wrong number of parentheses. Put another one after if.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on February 21, 2010, 02:02:50 AM
Ah. That worked.

Next issue: I can't get AddShot to work correctly.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on February 21, 2010, 02:18:26 AM
It would help if we knew what you were doing, but I'm pretty sure I know what it is already.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on February 21, 2010, 02:32:32 AM
Here's a sample of broken AddShot:
Code: [Select]
//Moving, shooting wall laser:Crazy Wall
task crazywall{
let spawnpoint = 0;
let direction = 0;
if(GetPlayerX>GetCenterX){
spawnpoint = GetClipMinX;
direction = 0;
}else{
spawnpoint = GetClipMaxX;
direction = 180;
}
CreateLaserA(1,spawnpoint,0,GetCenterX,25,AQUA03,60);
SetLaserDataA(1,0,direction,0,0,0,90);
SetLaserDataA(1,60,direction,0,0,0.25,90);
SetShotKillTime(1,600);
ascent(a in 0..20){
CreateLaserC(2,0,0,4,30,AQUA41,0);
SetLaserDataC(2,0,4,90,0,0,0);
ascent(b in 0..10){
AddShot(30*a,1,2,GetCenterX*b/10);
}
ascent(b in 0..9){
AddShot(30*a+15,1,2,GetCenterX*b/9);
}
}
FireShot(1);
}

Edited; the code means the wall will spawn on the side of the field the player's not on.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on February 21, 2010, 02:36:09 AM
AddShot(30*a,1,2,GetCenterX*b/10);

You're telling it to shoot at GetCenterX*b/10 from the base of the laser. GetCenterX just means 244 so you're telling it to shoot at 244*b/10 from the laser's base along the laser.

(Does that even make sense?)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 21, 2010, 02:36:30 AM
New question! =D

I have a boss that spews out my custom made power and point items, like a fountain, but when the boss dies so do the items, because their effect objects that the boss created. This is a problem becaus this means an enemy's items wont show up at all. ^^;;

Is there a way to make an effect object independent? or transfer it to the stage's effects?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on February 21, 2010, 02:39:38 AM
AddShot(30*a,1,2,GetCenterX*b/10);

You're telling it to shoot at GetCenterX*b/10 from the base of the laser. GetCenterX just means 244 so you're telling it to shoot at 244*b/10 from the laser's base along the laser.

(Does that even make sense?)

It does when the laser has length 244. Still, when I run the code, I get no uncharacteristically straight LaserCs.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 21, 2010, 02:43:07 AM
Is there a way to make an effect object independent? or transfer it to the stage's effects?

Yes. Create the effect object... In the stage.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 21, 2010, 02:44:07 AM
Yes. Create the effect object... In the stage.

Eeee...that comes with a little problem, how does the stage know when or where to spawn the items? ^^;
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 21, 2010, 02:48:28 AM
Well you can get whether or not the boss just died using IsBossExisting and a little bit of logic. To drop items on the boss' location after it just died, just pass CommonData in the boss' @Finalize of it's coordinates, then spawn all your items on that location the next frame.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 21, 2010, 02:50:30 AM
Well you can get whether or not the boss just died using IsBossExisting and a little bit of logic. To drop items on the boss' location after it just died, just pass CommonData in the boss' @Finalize of it's coordinates, then spawn all your items on that location the next frame.

would IsBossExisting work with multiple enemies onscreen during stages?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 21, 2010, 02:51:21 AM
You cannot have more then one boss on the screen at any time, all other enemies will not trigger the function. You can use GetEnemyNum to see how many enemies in total are currently alive.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 21, 2010, 03:00:01 AM
You cannot have more then one boss on the screen at any time, all other enemies will not trigger the function. You can use GetEnemyNum to see how many enemies in total are currently alive.

okay so I can get the enemy number, maybe if it sees the number go down I can make the dropping event trigger...worth a try ^^
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on February 21, 2010, 03:05:14 AM
okay so I can get the enemy number, maybe if it sees the number go down I can make the dropping event trigger...worth a try ^^

The problem is if an enemy dies on the same frame that an enemy spawns. The best solution for this would be to use common data in every enemy's @Finalize containing an array describing the location and type of item to drop. Then you read the data in the stage script to create the items and delete the array in the common data.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on February 21, 2010, 03:10:18 AM
AddShot(30*a,1,2,GetCenterX*b/10);

You're telling it to shoot at GetCenterX*b/10 from the base of the laser. GetCenterX just means 244 so you're telling it to shoot at 244*b/10 from the laser's base along the laser.

(Does that even make sense?)

Wait, along the laser? Am I accidentally firing the LaserCs in the direction of the LaserA or is something else the matter?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on February 21, 2010, 03:14:42 AM
Wait, along the laser? Am I accidentally firing the LaserCs in the direction of the LaserA or is something else the matter?
Your firing LaserCs from the direction of LaserA, put 0,1*b/10 for it to fire from the LaserA
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on February 21, 2010, 03:15:29 AM
Wait, along the laser? Am I accidentally firing the LaserCs in the direction of the LaserA or is something else the matter?

That is indeed what you're doing. If the laser being added to is facing 90 degrees and the 4th parameter in AddShot is 200, then the added shot will be added at 90 degrees 200 pixels away from the base of the parent laser.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on February 21, 2010, 03:19:48 AM
Actually, with no change to the parameters, I'm seeing a stream of the lasers at x=0 but none farther to the right (assuming the wall spawns on the left).
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 21, 2010, 03:23:58 AM
The problem is if an enemy dies on the same frame that an enemy spawns. The best solution for this would be to use common data in every enemy's @Finalize containing an array describing the location and type of item to drop. Then you read the data in the stage script to create the items and delete the array in the common data.

Im so confused, I almost get what your trying to tell me to do but I dont think I get it, do you mean create a new common data every time an enemy spawns? how do I make an array out of the strings used for common data? how do I call the function in stage trough the enemy's @Finalize? my main issue right now is knowing when an enemy dies X3
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on February 21, 2010, 03:40:38 AM
Enemy's @Finalize:
Code: [Select]
@Finalize {
    // Assuming we want the enemy to drop 10 power items and 12 point items.
    // Reason for the 2D array is so if multiple enemies die in one frame, they don't override
    // each other so both enemies will drop items instead of just one.
    SetCommonData("powerItems", GetCommonDataDefault("powerItems", []) ~ [[10, GetX, GetY]]);
    SetCommonData("pointItems", GetCommonDataDefault("pointItems", []) ~ [[12, GetX, GetY]]);
}

In the stage's @MainLoop:
Code: [Select]
@MainLoop{
    let powerItemsArray = GetCommonDataDefault("powerItems", []);
    ascent(i in 0..length(powerItemsArray)){
        loop(powerItemsArray[i][0]){
            // Assuming the function that creates power items is called CreatePowerItem
            // Also assuming you want to randomize the locations slightly.
            CreatePowerItem(powerItemsArray[i][1] + rand(-32, 32), powerItemsArray[i][2] + rand(-32, 32));
        }
    }

    // And do the same thing with pointItemsArray. Too lazy to write more code.

    SetCommonData("powerItems", []);
    SetCommonData("pointItems", []);
    yield;
}

Lines of code with comments show a lot more than just explanation. I hope this helps.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on February 21, 2010, 03:52:09 AM
Your firing LaserCs from the direction of LaserA, put 0,1*b/10 for it to fire from the LaserA

I cannot make sense of that 0,1*b/10. Could you post the complete line of code?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: WriggleNightbug on February 21, 2010, 04:06:26 AM
Yes! works perfectly, thanks dancing Flandre! ^^
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on February 21, 2010, 04:19:00 AM
I cannot make sense of that 0,1*b/10. Could you post the complete line of code?
Perhaps it would be best to describe what you are trying to accomplish. If we know that, then we can show you a piece of code that will do what you want and you can look through it and compare it to your own code to see what went wrong.

Yes! works perfectly, thanks dancing Flandre! ^^
No problem. *dances some more*
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on February 21, 2010, 04:34:36 AM
What I'm trying to do:

Every 30 frames, fire 10 evenly spaced LaserC(2)s straight downward from the LaserA.
Every 30 frames, starting from Frame 45, fire 9 evenly spaced LaserC(2)s straight downward from the LaserA.

Keep doing this until the LaserA is deleted 600 frames after its creation.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 21, 2010, 03:29:23 PM
Umm, do you really want to use LaserCs for that? It seems LaserAs would work just fine, and Cs are much harder for danmakufu to process.

Anyways...


Code: [Select]
task TAttack(x, y, ang, length){


let obj= Obj_Create(OBJ_LASER);

Obj_SetPosition(obj,x, y);
ObjLaser_SetLength(obj, length);
ObjLaser_SetWidth(obj, 20);
ObjShot_SetDelay(obj, 0);
Obj_SetAngle(obj, ang);
ObjLaser_SetSource(obj, true);
ObjShot_SetGraphic(obj, WHITE11);

let timer=0;

while(Obj_BeDeleted(obj)==false){

timer++;

if(timer>0&&timer%30==0&&timer<530){
ascent(i in 0..10){
CreateLaserC(1, x+cos(ang)*(i/9)*length, y+sin(ang)*(i/9)*length, 10, 25, RED11, 5);
SetLaserDataC(1, 0, 2, ang+90, 0, 0, 0);
FireShot(1);
}
}

if(timer>30&&(timer-15)%30==0&&timer<530){
ascent(i in 0..9){
CreateLaserC(1, x+cos(ang)*((i+0.5)/9)*length, y+sin(ang)*((i+0.5)/9)*length, 10, 25, RED11, 5);
SetLaserDataC(1, 0, 2, ang+90, 0, 0, 0);
FireShot(1);
}
}

if(timer==600){ ObjShot_FadeDelete(obj); }

yield;
}
}
I programmed not exactly what you said, but what I assume you meant. If I got it wrong, then please tell me.  :D

If you meant for the lasers to go straight down instead of rectangular to the laser, just replace ang+90 in the SetLaserDataC functions with 90.

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on February 21, 2010, 03:46:37 PM
That worked mostly as expected. I just forgot to mention the "wall" had a downward velocity of 0.25 (which was easy enough to add in, and fix so the sub-lasers spawned from the laser's current position instead of its initial position).

Why LaserC? Don't LaserA's always have a bright light at their base? This field of lasers is fairly thick, and the player has to see through it (the task is run in conjunction with one commented "Orbital Strike Cannon" - guess what that does).
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 21, 2010, 03:53:08 PM
*facepalm*

I meant CreateLaser01.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on February 21, 2010, 07:59:10 PM
I went and changed all of that too, and the dimensions and graphics. The RED11 lasers looked white. Now they look like aqua needles. I also threw in a differential so the player still has to stay on his or her toes.

Now, about SetDurableSpellCard. I think it doesn't require any parameters; is this true? Yes.

Also, if I call PlayMusic in the first card of a Plural Script, will it keep playing? Yes.

Oh, and how do I change the frame, Reimu's graphics, and Marisa's graphics?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Shockman on February 22, 2010, 05:53:31 AM
how do you change the framework?
it's not really explained anywhere.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on February 22, 2010, 06:02:11 AM
By changing the framework, do you mean changing the ugly default purple cloud frame image, or the way system information is displayed?

The former is accomplished by putting a 640x480 image called stg_frame.png in the img folder in your Danmakufu root directory. If there is no img folder, you can go ahead and create one.

The latter is accomplished by first disabling the default system view with SetDefaultStatusVisible(false); and then making a bunch of effect objects on layer 8 to draw your own custom graphics instead. You can get the information to display in the script with GetScore, GetGraze, GetPoint, GetPlayerLife, and GetPlayerBomb.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Shockman on February 22, 2010, 06:07:20 AM
By changing the framework, do you mean changing the ugly default purple cloud frame image, or the way system information is displayed?

The former is accomplished by putting a 640x480 image called stg_frame.png in the img folder in your Danmakufu root directory. If there is no img folder, you can go ahead and create one.

The latter is accomplished by first disabling the default system view with SetDefaultStatusVisible(false); and then making a bunch of effect objects on layer 8 to draw your own custom graphics instead. You can get the information to display in the script with GetScore, GetGraze, GetPoint, GetPlayerLife, and GetPlayerBomb.
thanks! I was talking about the cloud frame.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on February 22, 2010, 11:53:23 PM
I'm having problems with these CreateShots.

Code: [Select]
CreateShot01(Obj_GetX(redbeam)*cos(Obj_GetAngle(redbeam))*l*ObjLaser_GetLength(redbeam)/7,Obj_GetY(redbeam)*sin(Obj_GetAngle(redbeam))*l*ObjLaser_GetLength(redbeam)/7,0.6,Obj_GetAngle(redbeam)+90,RED05,10);
CreateShot01(Obj_GetX(redbeam)*cos(Obj_GetAngle(redbeam))*l*ObjLaser_GetLength(redbeam)/7,Obj_GetY(redbeam)*sin(Obj_GetAngle(redbeam))*l*ObjLaser_GetLength(redbeam)/7,0.6,Obj_GetAngle(redbeam)-90,RED05,10);
CreateShot01(Obj_GetX(bluebeam)*cos(Obj_GetAngle(bluebeam))*l*ObjLaser_GetLength(bluebeam)/7,Obj_GetY(bluebeam)*sin(Obj_GetAngle(bluebeam))*l*ObjLaser_GetLength(bluebeam)/7,0.6,Obj_GetAngle(bluebeam)+90,BLUE05,10);
CreateShot01(Obj_GetX(bluebeam)*cos(Obj_GetAngle(bluebeam))*l*ObjLaser_GetLength(bluebeam)/7,Obj_GetY(bluebeam)*sin(Obj_GetAngle(bluebeam))*l*ObjLaser_GetLength(bluebeam)/7,0.6,Obj_GetAngle(bluebeam)-90,BLUE05,10);
CreateShot01(Obj_GetX(greenbeam)*cos(Obj_GetAngle(greenbeam))*l*ObjLaser_GetLength(greenbeam)/7,Obj_GetY(greenbeam)*sin(Obj_GetAngle(greenbeam))*l*ObjLaser_GetLength(greenbeam)/7,0.6,Obj_GetAngle(greenbeam)+90,GREEN05,10);
CreateShot01(Obj_GetX(greenbeam)*cos(Obj_GetAngle(greenbeam))*l*ObjLaser_GetLength(greenbeam)/7,Obj_GetY(greenbeam)*sin(Obj_GetAngle(greenbeam))*l*ObjLaser_GetLength(greenbeam)/7,0.6,Obj_GetAngle(greenbeam)-90,GREEN05,10);

Right now they spawn ludicrously far away from the actual lasers, which have carefully manipulated dynamic angles, lengths, and base positions.

They're in an Ascent loop of l in 2..5 (will be changed to 1..5 and all instances of 7 changed to 6), and here's how the lasers operate:

(image to come)
The lasers are color coded. redbeam is aimed at the source of greenbeam. bluebeam is aimed at the source of redbeam. greenbeam is aimed at the source of bluebeam.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 22, 2010, 11:58:39 PM
Should be Xcoordinate + distance*cos(angle), not *. Also, the variable l may be large, but fix the first area before you check that.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on February 23, 2010, 12:26:13 AM
Presumably that error also exists in Y. After all, you saw how freakin' long the x term was.

I must have accidentally lumped Obj_GetX into the "stuff to multiply together" category.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: ChaoStar on February 24, 2010, 08:37:00 PM
Code: [Select]
script_spell BloodRage{
let img_spell = GetCurrentScriptDirectory~"CrimsonAura.png";

function wait(w){
loop(w){yield;}
}
SetPlayerInvincibility(20);
CrimsonGlow;
wait(60);


task CrimsonGlow{
let obj = Obj_Create(OBJ_EFFECT);
ObjEffect_SetRenderState(obj,ALPHA);
ObjEffect_SetTexture(obj,img_spell);

Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
ObjEffect_SetScale(obj,1,1);
ObjEffect_SetLayer(obj,5);
ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLESTRIP);

ObjEffect_SetVertexXY(obj,0,-21.5,-20.5);
ObjEffect_SetVertexXY(obj,0,21.5,-20.5);
ObjEffect_SetVertexXY(obj,0,-21.5,20.5);
ObjEffect_SetVertexXY(obj,0,21.5,20.5);

ObjEffect_SetVertexUV(obj,0,0,0);
ObjEffect_SetVertexUV(obj,1,43,0);
ObjEffect_SetVertexUV(obj,2,0,41);
ObjEffect_SetVertexUV(obj,3,43,41);



}

@Initialize{
LoadGraphic(img_spell);

}

@MainLoop{
CollectItems();
yield;
}

@Finalize{
}



End();
}

The object effect won't appear... is it the code, or the image?

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 24, 2010, 08:40:54 PM
Hurrr, I see what you're doing there. :V

As far as I know, you have to call the SetVertex functions every frame anew.

Edit:

Wait, there's more!

Quote
ObjEffect_SetVertexXY(obj,0,-21.5,-20.5);
ObjEffect_SetVertexXY(obj,0,21.5,-20.5);
ObjEffect_SetVertexXY(obj,0,-21.5,20.5);
ObjEffect_SetVertexXY(obj,0,21.5,20.5);

Also, you didn't create any vertices.  :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 24, 2010, 08:44:38 PM
You didn't declare how many vertices you're using:

ObjEffect_CreateVertex(obj, 4);

Also, you're declaring multiple coordinates for the same vertex using SetVertexXY (note they're all using the 0th vertex).

NINJA BITCH

And to comment on your answer Iryan, no you do not need to keep setting vertices. You do if they're moving, but they will always be drawn on the last coordinate you set them on. All set functions are permanent (except SetFog).
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on February 25, 2010, 12:09:58 AM
SetFog
:X
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Janitor Morgan on February 25, 2010, 05:16:16 PM
Is it possible to manually call a different player's bomb using UseSpellCard (i.e. Master Spark with ReimuA)?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on February 25, 2010, 05:25:03 PM
Is it possible to manually call a different player's bomb using UseSpellCard (i.e. Master Spark with ReimuA)?
If you want to call Player Script #1's bomb from Player Script #2, no, it isn't.
If you want, you can create different bombs in your own player script. Then you can use if statements in your @SpellCard block to tell Danmakufu which bomb to use. See Stuffman's Sakuya A script if you want to see how it's done. (Did I word that right?)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: ChaoStar on February 27, 2010, 07:51:32 PM
Code: [Select]
#TouhouDanmakufu
#Title[Beatrix Spell 1: Little Mermaid]
#Text[Test of EoSD Difficulty system.]
#BackGround[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{

let CSD = GetCurrentScriptDirectory;

let imgBoss = CSD ~ "img\Beatrix.png";

let back = CSD ~ "white.png";

let SupaShot = GetCurrentScriptDirectory~"\Supershot.txt";

let Difficulty = 2;


@Initialize{
SetLife(4500);
SetTimer(80);
SetScore(350000);
SetInvincibility(120);
      LoadUserShotData(SupaShot);
SetMovePosition01(GetCenterX,GetCenterY,5);
LoadGraphic(imgBoss);
LoadGraphic(back);
CutIn(YOUMU,"Mermaid sign: Mortal Soul",NULL,0,0,0,0);
mainTask;
}

@MainLoop{
SetCollisionA(GetX,GetY,32);
SetCollisionB(GetX,GetY,16);
yield;
}

@DrawLoop{
SetTexture(imgBoss);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicRect(0,0,54,58);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetX,GetY);
}

   @BackGround{
      SetTexture(NULL);
      SetRenderState(ALPHA);
      SetAlpha(255);
      SetGraphicRect(0,0,1024,1024);
      SetGraphicScale(1,1);
      SetGraphicAngle(0,0,0);
      DrawGraphic(GetCenterX,GetCenterY);
   }


@Finalize{
DeleteGraphic(imgBoss);

}

task mainTask{
yield;
mainFire;
movement;
}

task movement{
SetMovePosition01(GetCenterX,120,5);

yield;

}


task mainFire{
let xplus = 0;
let mxsp = 2;
let line = 0;
let xplus = (GetClipMinX/2)/3;
loop{
line = rand_int(0,5);
loop(16+line){
CreateShot02(GetClipMinX+xplus,GetClipMinY,2,90,-0.2,mxsp+0.2,175,0);
xplus+=GetClipMaxX/(16+line);
mxsp+=0.1;
yield;
}
xplus = 0;
mxsp = 2;
line = rand_int(0,5);
wait(10);
loop(16+line){
CreateShot02(GetClipMaxX-xplus,GetClipMinY,2,90,0.1,mxsp+0.2,175,0);
xplus+=GetClipMaxX/(16+line);
mxsp+=0.1;
yield;
}
xplus = 0;
mxsp = 2;
wait(10);
xplus = (GetClipMinX/2)/3;
loop(3){
BookBullet(GetCenterX+100+xplus,GetClipMinY,5,90,243,0);
BookBullet(GetCenterX-100-xplus,GetClipMinY,5,90,243,0);
xplus+=(GetClipMaxX/2)/3;
wait(20);
}
wait(120);


}
}


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


task BookBullet(x,y,v,d,graphic,delay){
let obj = Obj_Create(OBJ_SHOT);
let bounce = 0;
Obj_SetPosition(obj,x,y);
Obj_SetSpeed(obj,v);
Obj_SetAngle(obj,d);
ObjShot_SetGraphic(obj,graphic);
ObjShot_SetDelay(obj,delay);
while(!Obj_BeDeleted(obj)){


CreateShot02(Obj_GetX(obj),Obj_GetY(obj),rand(2,5),d+180+rand(-20,20),-0.1,-3,173,20);
yield;



}

}


}

For some reason, it fires two lines like I want it to the first time, but the second time... it only fires a half line, and then a full line. What have I done wrong? Or, why does this happen?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 27, 2010, 08:07:19 PM
You don't reset xplus back to zero at the end.

Therefore it stays at a value of ((GetClipMaxX/2)/3)*3, which is exactly half the width of the playing field. Add xplus=0; at the beginning of the looping part of your task, and it will work out fine.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 27, 2010, 10:55:40 PM
Therefore it stays at a value of ((GetClipMaxX/2)/3)*3, which is exactly half the width of the playing field.

GetClipMaxX = 416
416/2 = 208
208/3 = 69.333
69.333*3 = 208

GetCenterX = 224

...exactly half the width of the playing field.

Hm

(GetClipMinX + GetClipMaxX)/2 = GetCenterX
(32 + 416)/2 = 224
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 27, 2010, 11:21:18 PM
And my estimate of the dimensions of the error being wrong by less than 10% is totally disastrous for my suggested code reperation which sets the variable to the correct value without any influence of the previous value.

Besides, if xplus equals ((GetClipMaxX/2)/3)*3 at the start of the motion, and the bullets are spawned at the x coordinate of GetClipMinX+xplus, then the right number is actually 32+208=240, so if you want to nitpick on me, at least do it properly.  :V

Did I meantion that I like to construct sentences that, through the overuse of relative sentences and generally superfluously specific and formal diction, become difficult to read or at least to understand properly, no matter whether or not seperate lines of thought are sperated by colons properly, when in the end all that is left is a single overly long, convoluted mess?

Because it is true.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on February 27, 2010, 11:54:37 PM
Properly!? The part I quoted was the only incorrect part. This had nothing to do with his code, which I still haven't read :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: ChaoStar on February 28, 2010, 01:30:20 AM
Code: [Select]
#TouhouDanmakufu
#Title[Beatrix Nonspell 2]
#Text[Test of EoSD Difficulty system. Bea's so agile... look at her go!]
#BackGround[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{

let CSD = GetCurrentScriptDirectory;

let imgBoss = CSD ~ "img\Beatrix.png";

let back = CSD ~ "white.png";

let SupaShot = GetCurrentScriptDirectory~"\Supershot.txt";

let Difficulty = 2;


@Initialize{
SetLife(2000);
SetTimer(60);
SetScore(350000);
SetInvincibility(120);
      LoadUserShotData(SupaShot);
SetMovePosition01(GetCenterX,GetCenterY,5);
LoadGraphic(imgBoss);
LoadGraphic(back);

mainTask;
}

@MainLoop{
SetCollisionA(GetX,GetY,32);
SetCollisionB(GetX,GetY,16);
yield;
}

@DrawLoop{
SetTexture(imgBoss);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicRect(0,0,54,58);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetX,GetY);
}

   @BackGround{
      SetTexture(NULL);
      SetRenderState(ALPHA);
      SetAlpha(255);
      SetGraphicRect(0,0,1024,1024);
      SetGraphicScale(1,1);
      SetGraphicAngle(0,0,0);
      DrawGraphic(GetCenterX,GetCenterY);
   }


@Finalize{
DeleteGraphic(imgBoss);

}

task mainTask{
yield;
mainFire;
movement;
}

task movement{
SetMovePosition01(GetCenterX,120,5);

yield;

}


task mainFire{
let directional = 0;
loop{
directional = 0;
SetMovePosition01(GetCenterX+150,120,5);
wait(120);

Concentration01(40);
wait(40);
loop(12){
BookBullet(GetX,GetY,5,80+directional,97,0);
directional+=360/12;
}
wait(20);
directional = 0;
SetMovePosition01(GetCenterX-150,120,5);
wait(120);
Concentration01(40);
wait(40);
loop(12){
BookBullet(GetX,GetY,5,80+directional,97,0);
directional+=360/12;
}
wait(20);
}
}


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

task BookBullet(x,y,v,d,graphic,delay){
let obj = Obj_Create(OBJ_SHOT);
let bounce = 0;
Obj_SetPosition(obj,x,y);
Obj_SetSpeed(obj,v);
Obj_SetAngle(obj,d);
ObjShot_SetGraphic(obj,graphic);
ObjShot_SetDelay(obj,delay);
while(!Obj_BeDeleted(obj)){
if(Obj_GetX(obj) > GetClipMaxX){Obj_SetAngle(obj,180-Obj_GetAngle(obj));}
else if(Obj_GetX(obj) < GetClipMinX){Obj_SetAngle(obj,180-Obj_GetAngle(obj));}
else if(Obj_GetY(obj) < GetClipMinY){Obj_SetAngle(obj,-Obj_GetAngle(obj));}
else if(Obj_GetY(obj) > GetClipMaxY){Obj_SetAngle(obj,-Obj_GetAngle(obj));}
yield;
}

}


}

Auauauau~ why won't it STOP BOUNCING T__T

What did I do wrong...?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade on February 28, 2010, 01:37:11 AM
I've hit this problem before, and someone else has solved it for me.
I don't remember the specifics, but your BookBullet is set to bounce indefinitely since it will never exit the screen nor be deleted by ObjShot_FadeDelete or something like that.

Depending on what you want, you can either have it be deleted at a certain time after firing with an object delete code or after a certain number of bounces. The second method makes use of a count variable within a number of if statements.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: ChaoStar on February 28, 2010, 01:38:14 AM
Thank you. I just remembered what I forgot. T__T
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Janitor Morgan on February 28, 2010, 02:45:59 AM
Are object lasers set to behave like the CreateLaserB family by default? I can't get my lasers to move so that I can test an idea I had for Collision_Obj_Obj.

EDIT: Might help if I put the code here. :V
Code: [Select]
task StraightLaser(x, y, l, w, g, d) {
let thing = Obj_Create(OBJ_LASER);
let reflectcount = 1;
Obj_SetX(thing, x);
Obj_SetY(thing, y);
ObjLaser_SetLength(thing, l);
ObjLaser_SetWidth(thing, w);
   Obj_SetSpeed(thing, 2);
Obj_SetAngle(thing, atan2(GetPlayerY - Obj_GetY(thing), GetPlayerX - Obj_GetX(thing)));
ObjShot_SetBombResist(thing, true);
ObjShot_SetGraphic(thing, g);
ObjShot_SetDelay(thing, d);
Obj_SetCollisionToObject(thing, true);

while (!Obj_BeDeleted(thing)) {
if (Collision_Obj_Obj(id, thing) && reflectcount != 0) {
Obj_SetAngle(thing, Obj_GetAngle(thing)-180);
reflectcount = 0;
}
if (Obj_GetX(thing) < 0 || Obj_GetX(thing) > 448) {
if (reflectcount == 0) {
Obj_SetAngle(thing, -(Obj_GetAngle(thing)));
reflectcount = 1;
}
}
yield;
}
}

The id variable in there is from a globally-defined object laser.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on February 28, 2010, 02:53:06 AM
Obj_SetSpeed doesn't work with lasers, you need to move them manually.

Code: [Select]
x+=cos(a)*v;
y+=sin(a)*v;
Obj_SetPosition(obj,x,y);

Run this every frame. Beforehand, just set v and a to velocity and angle respectively, and x and y to where the laser spawned.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Janitor Morgan on February 28, 2010, 03:13:48 AM
Yay, they move now. Thanks, Azure.

...Now if I could figure out why they're not changing direction when they collide. DX

(http://img23.imageshack.us/img23/6378/screenshotthing.jpg)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade on February 28, 2010, 03:30:19 AM
Change direction as in what? You want them to actually face the direction they're going in? Then you still have to SetAngle, even if their movement is directed by SetPosition. The angle set is the way the graphic is oriented, with one part always facing the direction headed. Since most shots are circles, you can't really tell, but I think you can see the difference while using object butterflies all facing right. On the other hand, if you just want it to change direction, then that involves SetPosition in regards to the angle it was headed in and the angle of bounce.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Janitor Morgan on February 28, 2010, 03:45:36 AM
Change direction as in what? You want them to actually face the direction they're going in? Then you still have to SetAngle, even if their movement is directed by SetPosition.

I'm doing this already, but the lasers just keep going as if they're not colliding with the sinuate laser around the player at all. I have Obj_SetCollisionToObject(thing, true); (with the relevant object IDs) in both of the related tasks, and the sinuate laser's ID is global AND being passed to the aimed laser's task. They just don't interact. =/
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: ChaoStar on February 28, 2010, 06:48:02 AM
I'm doing this already, but the lasers just keep going as if they're not colliding with the sinuate laser around the player at all. I have Obj_SetCollisionToObject(thing, true); (with the relevant object IDs) in both of the related tasks, and the sinuate laser's ID is global AND being passed to the aimed laser's task. They just don't interact. =/

Hmm. I'm guessing, but maybe you need an if statement that tells the lasers what to do if they collide? Just tell the Hadron Collider to find the Higgs Boson.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Janitor Morgan on February 28, 2010, 06:56:24 AM
Hmm. I'm guessing, but maybe you need an if statement that tells the lasers what to do if they collide? Just tell the Hadron Collider to find the Higgs Boson.

Have that already, as mentioned in the code block up there. The laser generated by the StraightLaser task is supposed to bounce off of the sinuate laser based on what's in the while loop I've got.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 28, 2010, 09:43:10 AM
1. I hope I can assume you didn't just copypaste Azure's code but instead changed the respective angle variables to the variable name you are using, right?

2. Is your sinuate laser created in the main script, or did you create it inside a task? If the latter one, then the straight laser cannot check the collision with the sinuate laser as the variable that stores the id of the sinuate laser does not exist in the script of the straight laser. To fix this, you'd just have to create the variable id right at the beginning of the script and have the sinuate laser task merely insert the object id into this variable. That way it can be accessed from anywhere, including your stright laser task.

3. If you want to create several sinuate lasers, and if two of them coexist for one or more frames, then you'll need object arrays. *cough cough*


Another tip: If the direction change of the laser actually does work, the laser will probably turn spin around its base, making everything look awkward. Thus, you should insert the following line before the SetAngle command:

Code: [Select]
Obj_SetPosition(thing, ObjLaser_GetEndX(thing), ObjLaser_GetEndY(thing));
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Janitor Morgan on February 28, 2010, 08:06:06 PM
1. I hope I can assume you didn't just copypaste Azure's code but instead changed the respective angle variables to the variable name you are using, right?

2. Is your sinuate laser created in the main script, or did you create it inside a task? If the latter one, then the straight laser cannot check the collision with the sinuate laser as the variable that stores the id of the sinuate laser does not exist in the script of the straight laser. To fix this, you'd just have to create the variable id right at the beginning of the script and have the sinuate laser task merely insert the object id into this variable. That way it can be accessed from anywhere, including your stright laser task.

3. If you want to create several sinuate lasers, and if two of them coexist for one or more frames, then you'll need object arrays. *cough cough*


Another tip: If the direction change of the laser actually does work, the laser will probably turn spin around its base, making everything look awkward. Thus, you should insert the following line before the SetAngle command:

Code: [Select]
Obj_SetPosition(thing, ObjLaser_GetEndX(thing), ObjLaser_GetEndY(thing));

1) I changed it to fit my script.
2) The laser itself is created in a task that is called from @Initialize. I tried creating the object ID at the beginning and passing it into the sinuate laser task, but it didn't seem to change anything.
3) I'll have to read up on object arrays when I get the chance, then.

This is working out just like the last time I tried making a script: I get one part working, and the rest either falls to pieces or just doesn't come to me. D=
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on February 28, 2010, 09:17:23 PM
After fooling around, I've come to the simple but fatal conclusion that danmakufu just royally fucks up when it has to determine the collision of sinuate lasers with other objects.

 :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Janitor Morgan on February 28, 2010, 09:23:25 PM
After fooling around, I've come to the simple but fatal conclusion that danmakufu just royally fucks up when it has to determine the collision of sinuate lasers with other objects.

 :ohdear:

Well, crap. At least we learned a bit about sinuate lasers out of this...

Thanks for the help.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 01, 2010, 03:51:39 PM
I remember someone posted a code for an angled ellipse somewhere around here... Was it NC/Naut/Blargel? Well whoever it is... can someone direct me to where it is/repost the code or something? I've tried looking everywhere, but I can't seem to find it anymore... :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 01, 2010, 03:55:15 PM
I remember someone posted a code for an angled ellipse somewhere around here... Was it NC/Naut/Blargel? Well whoever it is... can someone direct me to where it is/repost the code or something? I've tried looking everywhere, but I can't seem to find it anymore... :ohdear:

I think it was a post by Drake in the old Q&A thread. I don't remember when it was posted so it might be hard to find it still.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 01, 2010, 04:00:30 PM
I think it was a post by Drake in the old Q&A thread. I don't remember when it was posted so it might be hard to find it still.

oh there...
Code: [Select]
task ellipse{
    let a = 0;
    let dist;
    loop(36){
        dist = ((sin(a))^2+(2*cos(a))^2)^0.5;
        CreateShot01(GetEnemyX,GetEnemyY,2/dist,a,YELLOW04,12);
        a += 10;
    }
}

apparently it really was drake at Q&A thread II :V (I should really start saving things I may use in the future...)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 01, 2010, 05:44:07 PM
NC/Naut/Blargel
Quote
Group of "danmakufu experts"
Quote
Not me
thanks a lot, bro
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 01, 2010, 06:16:05 PM
So I was having this weird issue of not being able to play music correctly. At first I thought it was because I was trying to load music from a player script and Danmakufu wasn't allowing it, but when I tried loading and playing it from a single or stage script, nothing played either. Turning on the debug window revealed that it wasn't loading correctly so I checked the filepath. It was fine. Just to be sure I tried a variety of other things like renaming the mp3, renaming the folder, moving the mp3 into a folder full of stuff that was being loaded correctly, trying absolute file paths, and loading another song. It turned out that loading another mp3 with the same name worked perfectly fine which meant my mp3 was borked somehow. However, opening it in Quicktime or Audacity worked fine and it played normally so I was confused. Just to be sure, I tried converting the mp3 into a wav and loading that instead. No success. After a while of tinkering, I got the bright idea of opening the mp3 with Audacity and immediately resaving it as an mp3. Somehow this worked.

Moral of the story: Danmakufu sucks at sound.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on March 01, 2010, 06:28:04 PM
So I was having this weird issue of not being able to play music correctly. At first I thought it was because I was trying to load music from a player script and Danmakufu wasn't allowing it, but when I tried loading and playing it from a single or stage script, nothing played either. Turning on the debug window revealed that it wasn't loading correctly so I checked the filepath. It was fine. Just to be sure I tried a variety of other things like renaming the mp3, renaming the folder, moving the mp3 into a folder full of stuff that was being loaded correctly, trying absolute file paths, and loading another song. It turned out that loading another mp3 with the same name worked perfectly fine which meant my mp3 was borked somehow. However, opening it in Quicktime or Audacity worked fine and it played normally so I was confused. Just to be sure, I tried converting the mp3 into a wav and loading that instead. No success. After a while of tinkering, I got the bright idea of opening the mp3 with Audacity and immediately resaving it as an mp3. Somehow this worked.

Moral of the story: Danmakufu sucks at sound.

I want to say, mp3s and stuff saved from Amazing Slow Downer DON'T WORK. Why is this?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 01, 2010, 06:51:15 PM
Try encoding it at different speeds. That might just be the entire issue of "Danmakufu vs mp3" anyways.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on March 01, 2010, 11:58:25 PM
thanks a lot, bro
he didn't mention Hele either so :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on March 02, 2010, 03:01:57 AM
How would you have an Spell Object spin?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 02, 2010, 03:44:01 AM
let x = GetPlayerX; //center x coordinate of your objshot
let y = GetPlayerY; //center y coordinate of your objshot
let radius = 50; //distance from center to any one tip of the graphic rect, like (0, 0).
let angle = 0; //this is how we'll spin the graphic.

while(!Obj_BeDeleted(obj)){
   //plot the object's vertices.
   ObjEffect_SetVertexXY(obj, 0, x + radius*cos(angle), y + radius*sin(angle));
   ObjEffect_SetVertexXY(obj, 1, x + radius*cos(angle + 90), y + radius*sin(angle + 90));
   ObjEffect_SetVertexXY(obj, 2, x + radius*cos(angle + 180), y + radius*sin(angle + 180));
   ObjEffect_SetVertexXY(obj, 3, x + radius*cos(angle + 270), y + radius*sin(angle + 270));
   angle+=4; //Change this value to spin it faster/slower/in the opposite direction. "Every frame we shift the graphic by 4 degrees clockwise".
   yield;
}


Other people will tell you to do shit with Obj_SetAngle, but fuck that noise.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 02, 2010, 04:27:43 AM
I would have said ObjEffect_SetAngle.  :/
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 02, 2010, 04:36:29 AM
(http://i641.photobucket.com/albums/uu134/Nautth/dn.jpg)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on March 02, 2010, 04:37:33 AM
(http://i641.photobucket.com/albums/uu134/Nautth/dn.jpg)
DOUBLE ANGLE
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 02, 2010, 08:11:41 AM
thanks a lot, bro
he didn't mention Hele either so :V
sorry, I forgot... :(
I just put the first ones I thought of...

trust me... I'm really bad when it comes to memory :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DgBarca on March 02, 2010, 11:38:46 AM
let x = GetPlayerX; //center x coordinate of your objshot
let y = GetPlayerY; //center y coordinate of your objshot
let radius = 50; //distance from center to any one tip of the graphic rect, like (0, 0).
let angle = 0; //this is how we'll spin the graphic.

while(!Obj_BeDeleted(obj)){
   //plot the object's vertices.
   ObjEffect_SetVertexXY(obj, 0, x + radius*cos(angle), y + radius*sin(angle));
   ObjEffect_SetVertexXY(obj, 1, x + radius*cos(angle + 90), y + radius*sin(angle + 90));
   ObjEffect_SetVertexXY(obj, 2, x + radius*cos(angle + 180), y + radius*sin(angle + 180));
   ObjEffect_SetVertexXY(obj, 3, x + radius*cos(angle + 270), y + radius*sin(angle + 270));
   angle+=4; //Change this value to spin it faster/slower/in the opposite direction. "Every frame we shift the graphic by 4 degrees clockwise".
   yield;
}


Other people will tell you to do shit with Obj_SetAngle, but fuck that noise.

Seriously using Obj_SetPosition(obj) and ObjEffect_SetAngle(obj) make things lot easier that every method that I now but... :V
(ho no naut is gonna (http://img412.imageshack.us/img412/2933/bestbro.png) me)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on March 02, 2010, 12:16:20 PM
I must be seriously missing something but for all effect objects, including players, I use ObjEffect_SetAngle as well. Setting vertex in each frameloop is more like for updating a changing object (like circle shrinking etc.)

The only reason I know for awkward method Naut mentioned above is he had some big issues with Sanae's hitbox effect. Something like it is flipping all over the screen? Cannot remember exactly any more.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 02, 2010, 02:21:39 PM
I must be seriously missing something but for all effect objects, including players, I use ObjEffect_SetAngle as well. Setting vertex in each frameloop is more like for updating a changing object (like circle shrinking etc.)

The only reason I know for awkward method Naut mentioned above is he had some big issues with Sanae's hitbox effect. Something like it is flipping all over the screen? Cannot remember exactly any more.

If Naut's hitbox was flipping all over the screen, then he hasn't mastered effect objects yet. For ObjEffect_SetVertex, if it's a square image and you're using triangle fan, you're supposed to do this:

ObjEffect_SetVertexXY(obj, 0, -32, -32);
ObjEffect_SetVertexXY(obj, 1, 32, -32);
ObjEffect_SetVertexXY(obj, 2, 32, 32);
ObjEffect_SetVertexXY(obj, 3, -32, 32);

And then when you do Obj_SetPosition(obj, GetPlayerX, GetPlayerY);, it'll draw on the player's position.

ObjEffect_SetAngle will rotate the object's vertexes around the point you specify with Obj_SetPosition and ObjEffect_SetVertexXY will set the positions of the vertexes relative to the that point. Naut's hitbox image was probably rotating incorrectly because he was doing something like this:

ObjEffect_SetVertexXY(obj, 0, GetPlayerX-32, GetPlayerY-32);
ObjEffect_SetVertexXY(obj, 1, GetPlayerX+32, GetPlayerY-32);
ObjEffect_SetVertexXY(obj, 2, GetPlayerX+32, GetPlayerY+32);
ObjEffect_SetVertexXY(obj, 3, GetPlayerX-32, GetPlayerY+32);

If he didn't use Obj_SetPosition, it defaults to the point (0, 0) and when ObjEffect_SetAngle is used, it will rotate the vertexes around (0, 0) and thereby make the image fly off randomly.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 02, 2010, 07:14:12 PM
this was liek 6 months ago guiz wtf :<

I still use trig to do it out habit. I like knowing where all my vertices are. Plus I usually stretch the image in weird ways nowadays so :V

ALSO FUCK YOUR NOISE

YEAH
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Alice★f on March 02, 2010, 07:59:51 PM
Code: [Select]
#TouhouDanmakufu#Title[Test Attack 1]#Text[This is a test boss for Danmakufu. Created by GreenVirus on 3/2/10]#Image[.\img.png]#BackGround[User(.\bg.png, 0, 0)]#BGM[.\bgm.mp3]#PlayLevel[Easy]#Player[FREE]#ScriptVersion[2]
script_enemy_main { let BossImage = "script\img\ExRumia.png"; let BossCutIn = "script\img\ExRumia.png"; let frame = 0 @Initialize { LoadGraphic(BossImage); SetLife(12000); SetDamageRate(100, 100); SetTimer(50); SetInvincibility(600); CutIn(KOUMA, "Q.E.D 10", BossCutIn, 0, 0, 200, 600); SetScore(100000); SetEnemyMarker(True); Concentration02(100); MagicCircle(True); SetEffectForZeroLife(100, 120, 5); }
@MainLoop { SetCollisionA(GetX, GetY, 32);        SetCollisionB(GetX, GetY, 24);        if(frame==60){            CreateShot01(GetX, GetY, 3, GetAngleToPlayer, RED01, 0);            frame = 0; }        frame++; }
    @DrawLoop { SetTexture(BossImage); DrawGraphic(GetX, GetY);    }
    @Finalize {    }
    @BackGround {    }}
***Argh, how do you format this?*** Meanwhile I'll keep trying to fix it...
And when I run it, I get this error message:
(http://localhostr.com/files/2b27ff/ErrorMsg.png)
I was following the examples on this page: http://dmf.shrinemaiden.org/wiki/index.php?title=Danmakufu_Basics_Tutorial (http://dmf.shrinemaiden.org/wiki/index.php?title=Danmakufu_Basics_Tutorial)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nimble on March 02, 2010, 08:05:20 PM
You missing ; in line 15 from your scirpt is here

let BossCutIn = "scriptimgExRumia.png";
let frame = 0  <--- Overhere
@Initialize

like this

let BossCutIn = "scriptimgExRumia.png";
let frame = 0;
@Initialize
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Alice★f on March 02, 2010, 08:11:48 PM
Thanks, but now I get the following error:
(http://localhostr.com/files/870d7b/ErrorMsg2.png)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 02, 2010, 08:32:27 PM
Booleans in danmakufu must be in all lowercase. It's case sensitive, that way, "Obj" and "obj" are entirely different variables.

"true" and "false". Just like that - no caps.

Meanwhile, does anyone know how I would get the distance from the player to the edge of the screen given an angle?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on March 02, 2010, 08:52:53 PM
Does anyone know how I would get the distance from the player to the edge of the screen given an angle?
atan2(y_coordinate - GetPlayerY, x_coordinate - GetPlayerX);
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Alice★f on March 02, 2010, 09:12:37 PM
Booleans in danmakufu must be in all lowercase. It's case sensitive, that way, "Obj" and "obj" are entirely different variables.

"true" and "false". Just like that - no caps.

Meanwhile, does anyone know how I would get the distance from the player to the edge of the screen given an angle?
Thank you so much. I did not know that before!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 02, 2010, 09:16:00 PM
atan2(y_coordinate - GetPlayerY, x_coordinate - GetPlayerX);

How does that help exactly? I need to put the angle in and then get the distance to the edge of the screen in that direction... and I'm fairly sure DMF does not have an algebraic solver.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 02, 2010, 09:39:48 PM
What you try to accomplish is certainly possibly, but you need conditional statements. I happen to have used such code in a form of my newest project...  :V

Assuming ang is the angle you have and (x|y) is the point from which you need the distance from, it should look something like this...

Code: [Select]

function GetShit(x, y, ang){

let dist1;
let dist2;

while(ang>180){ ang-=360; }
while(ang<=-180){ ang+=360; }

let atl=atan2(GetClipMinY-y, GetClipMinX-x); //angle to top left corner
let atr=atan2(GetClipMinY-y, GetClipMaxX-x); //angle to top right corner
let abl=atan2(GetClipMaxY-y, GetClipMinX-x); //angle to bottom left corner
let abr=atan2(GetClipMaxY-y, GetClipMaxX-x); //angle to bottom right corner

if(ang>=atl && ang<=atr){ // In that case, the angle points to the top
  dist1=y-GetClipMinY;
  dist2=( (dist1^2) * ( (dist2/tan(ang+90))^2) )^0.5;
}
if(ang>=abr && ang<=abl){ // In that case, the angle points to the bottom
  dist1=GetClipMaxY-y;
  dist2=( (dist1^2) * ( (dist2/tan(ang))^2) )^0.5;
}
if(ang>=atr && ang<=abr){ // In that case, the angle points to the right side
  dist1=GetClipMaxX-x;
  dist2=( (dist1^2) * ( (dist2/tan(ang-90))^2) )^0.5;
}
if( (ang>=-180 && ang<=atl) || (ang>=abl && ang<=180) ){ // In that case, the angle points to the left side
  dist1=x-GetClipMinX;
  dist2=( (dist1^2) * ( (dist2/tan(ang+180))^2) )^0.5;
}

return dist2;
}

I don't know if this works, but I am too tired to test is right now and have to go to sleep in ~ 20 minutes. If the code doesn't work, I'll get back to it tomorrow.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 02, 2010, 10:45:34 PM
Um, what? Last I checked this doesn't need anything special...
Code: [Select]
#UserShotData

ShotImage = ".\geoshot.png"

// Shotdata = Geometric Shot Replace
// Render = always ADD
// Angular = "R" shots rotate, non-labeled shots don't (these have yet to be added)
// Delay_color = Always the same as that of the bullet

//******************************* Starting shot data ***************************************//

// Template ShotData Command
// ShotData{ id=x rect=(left,top,right,bottom) render=ADD angular_velocity = 0 delay_color= (red,green,blue) }


// 16-diameter circle (12 colors)
ShotData{ id=1 rect=(0,0,15,39) render=ADD angular_velocity = 0 delay_color= (255,0,0) } //red
ShotData{ id=2 rect=(16,0,31,39) render=ADD angular_velocity = 0 delay_color= (255,255,0) } //yellow
ShotData{ id=3 rect=(32,0,47,39) render=ADD angular_velocity = 0 delay_color= (0,255,0) } //green
ShotData{ id=4 rect=(48,0,63,39) render=ADD angular_velocity = 0 delay_color= (0,255,255) } //aqua
ShotData{ id=5 rect=(64,0,79,39) render=ADD angular_velocity = 0 delay_color= (0,0,255) } //blue
ShotData{ id=6 rect=(80,0,95,39) render=ADD angular_velocity = 0 delay_color= (255,0,255) } //pink
ShotData{ id=7 rect=(0,24,15,39) render=ADD angular_velocity = 0 delay_color= (255,128,1) } //orange
ShotData{ id=8 rect=(16,24,31,39) render=ADD angular_velocity = 0 delay_color= (128,255,1) } //chart.
ShotData{ id=9 rect=(32,24,47,39) render=ADD angular_velocity = 0 delay_color= (1,255,128) } //foam
ShotData{ id=10 rect=(48,24,63,39) render=ADD angular_velocity = 0 delay_color= (1,128,255) } //azure
ShotData{ id=11 rect=(64,24,79,39) render=ADD angular_velocity = 0 delay_color= (128,1,255) } //purple
ShotData{ id=12 rect=(80,24,95,39) render=ADD angular_velocity = 0 delay_color= (255,1,128) } //rviol

gives me a semicolon-related error on line 11 for some reason.

Never mind; I was calling it with include_function instead of LoadUserShotData like I was supposed to. Idiot me... and I just realized why shots 1-6 are acting all wacky, too...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on March 03, 2010, 08:22:11 AM
How does that help exactly? I need to put the angle in and then get the distance to the edge of the screen in that direction... and I'm fairly sure DMF does not have an algebraic solver.


atan2(sourceY - targetY, sourceX - targetX);
the atan2 function gives you angle theta directed to the target from the source.
To find distance, you want this.
((targetX-SourceX)^2+(targetY-SourceY)^2)^(1/2)
It's the pythagorean theorem.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 03, 2010, 10:20:44 AM
Given an angle and you're looking for the distance from a point to the edge of the screen on that angle... I think you could do something like this:

Code: [Select]
function distance(x, y, angle)
{
let xb=x;
let yb=y;
while(xb>GetClipMinX && xb<GetClipMaxX)
{
xb+=cos(angle); //this gets the end x, you may want to try multiplying cos(angle) by a decimal cause this'll only get it to the pixel, which means it's not exact...
}
while(yb>GetClipMinY && yb<GetClipMaxY)
{
yb+=sin(angle); //this gets the end y, you may want to try multiplying sin(angle) by a decimal cause this'll only get it to the pixel, which means it's not exact...
}

return(((x-xb)^2+(y-yb)^2)^0.5)); //pythagorean theorem from start point to end point...
}

there may be some things here that's wrong... cause I wasn't able to check it (and I never actually used the return function... ever...), but you should get the idea from that...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 03, 2010, 11:13:21 AM
Is there a way to detect when a player object shot hits an enemy, aside from waiting for it to be deleted?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 03, 2010, 11:18:11 AM
Is there a way to detect when a player object shot hits an enemy, aside from waiting for it to be deleted?

try turning it into an object shot or object effect then just make it deal damage (by creating a player bullet directly on top of it... preferably using the same graphic so the extra bullet is not seen...) to the enemy when it touches it... and delete it immediately...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 03, 2010, 11:41:19 AM
try turning it into an object shot or object effect then just make it deal damage (by creating a player bullet directly on top of it... preferably using the same graphic so the extra bullet is not seen...) to the enemy when it touches it... and delete it immediately...

That... seems like even more work. >.>;;
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 03, 2010, 11:52:27 AM
That... seems like even more work. >.>;;

This is how I did it (when I did that)

Code: [Select]
task ringshots(x, y, angle)
{
let enemy_target=-1;
let obj=Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj, x, y);
Obj_SetAngle(obj, angle);
Obj_SetSpeed(obj, 5);
Obj_SetCollisionToPlayer(obj, false);
ObjShot_SetGraphic(obj, 2);
ObjShot_SetDelay(obj, 0);
while(Obj_BeDeleted(obj)==false)
{
yield;
ascent(i in EnumEnemyBegin..EnumEnemyEnd) {
enemy_target=EnumEnemyGetID(i);
if( ((GetEnemyInfo(enemy_target, ENEMY_X)-Obj_GetX(obj))^2+(GetEnemyInfo(enemy_target, ENEMY_Y)-Obj_GetY(obj))^2)^0.5<=20) //distance from bullet to enemy is less than 20 (it's a big bullet)
{
CreatePlayerShot01(Obj_GetX(obj),Obj_GetY(obj),1,270,1.5,1,2);
Obj_Delete(obj);
}
}
}
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 03, 2010, 12:02:12 PM
Oooh, shiny.

Quote
Obj_SetCollisionToPlayer(obj, false);

this is the piece I was missing. =D

EDIT: Does this work for enemy detection on player bullets, or do I need to use CollisionToObject instead?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 03, 2010, 12:12:16 PM
Oooh, shiny.

this is the piece I was missing. =D

EDIT: Does this work for enemy detection on player bullets, or do I need to use CollisionToObject instead?


Code: [Select]
ascent(i in EnumEnemyBegin..EnumEnemyEnd) {
enemy_target=EnumEnemyGetID(i);
if( ((GetEnemyInfo(enemy_target, ENEMY_X)-Obj_GetX(obj))^2+(GetEnemyInfo(enemy_target, ENEMY_Y)-Obj_GetY(obj))^2)^0.5<=20) //distance from bullet to enemy is less than 20 (it's a big bullet)
{
CreatePlayerShot01(Obj_GetX(obj),Obj_GetY(obj),1,270,1.5,1,2);
Obj_Delete(obj);
}
}

this part actually already detects if the player bullet's colliding with the enemy...

ascent(i in EnumEnemyBegin..EnumEnemyEnd) {
enemy_target=EnumEnemyGetID(i);

This part makes sure that you're detecting all enemies on the screen...

if( ((GetEnemyInfo(enemy_target, ENEMY_X)-Obj_GetX(obj))^2+(GetEnemyInfo(enemy_target, ENEMY_Y)-Obj_GetY(obj))^2)^0.5<=20) //distance from bullet to enemy is less than 20 (it's a big bullet)

This part detects if the bullet is colliding with the enemy you're checking at the time...



I'm thinking I should've put a +1 on the EnumEnemyEnd... I'm just not so sure...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 03, 2010, 12:16:56 PM
Yeah, I got that. I was just confused about whether it was a player script or an enemy script 'cuz I saw ObjShot_SetDelay();

and the player tutorial mentions that player shots can't have delay. But yeah. I see it now.

>.< ty, y'ben very he'pful.

EDIT: Why do my object shots look a lot brighter than the same shots created with CreatePlayerShot01()?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 03, 2010, 01:07:27 PM
EDIT: Why do my object shots look a lot brighter than the same shots created with CreatePlayerShot01()?

that... I have no idea why... I haven't been experimenting with graphic differences and stuff... :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 03, 2010, 01:15:39 PM
EDIT: Why do my object shots look a lot brighter than the same shots created with CreatePlayerShot01()?

In your shot definition file (the one that starts with #PlayerShotData), if you defined an alpha value, it will use that when doing CreatePlayerShot01. However, if you create the bullet as an object, you need to manually set the alpha with Obj_SetAlpha.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 03, 2010, 01:22:55 PM
^ I thought of that, but even using Obj_SetAlpha to the same value, the object shots are still brighter.

(http://i591.photobucket.com/albums/ss352/Orichalc71/bright3.png)

Obj shots from main body (without/with setalpha), CreatePlayerShot01's from the options.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 03, 2010, 01:35:49 PM
Hmmmm.... strange. It worked for my player.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 03, 2010, 02:22:22 PM
>.< Wow. I'm either really failing today or... well, I'm just really failing today.

Code: [Select]
            let j = 0;
            while(j < length(Arrow)){
                let obj = Arrow[j];
                if(!Obj_BeDeleted(obj)){
                    if(((GetEnemyInfo(bastard, ENEMY_X)-Obj_GetX(obj))^2+
                        (GetEnemyInfo(bastard, ENEMY_Y)-Obj_GetY(obj))^2)^0.5<=20) {
                        ping = true;
                        // do stuff;
                        Obj_Delete(obj);
                    } else if (Obj_GetY(obj) <= GetClipMinY()) {
                        Obj_Delete(obj);
                    }
                } else {
//                    erase(Arrow,j);
//                    j--;
                }
                j++;
            }

If I un-comment out those lines, it does an infinite loop, but... that's a standard maneuver for iterating through an array, isn't it?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 03, 2010, 02:53:51 PM
If you uncomment out those lines, then j will decrease below length(Arrow), and thus the while( j < length(Arrow) ) will always be true, causing an infinite loop, I assume. Chances are your logic is incorrect somewhere, though I can't see it at the moment. Enemy enumeration has never looked so confusing.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 03, 2010, 03:03:32 PM
If you uncomment out those lines, then j will decrease below length(Arrow), and thus the while( j < length(Arrow) ) will always be true, causing an infinite loop, I assume. Chances are your logic is incorrect somewhere, though I can't see it at the moment. Enemy enumeration has never looked so confusing.

doesn't j stay the same? cause there's both a j++; and a j--;

but then you're also erasing something in the array... which I think is the 1st (or 0 in array) term...

Code: [Select]
            let j = 0;
            while(j < length(Arrow)){
                let obj = Arrow[j];
                if(!Obj_BeDeleted(obj)){
                    if(((GetEnemyInfo(bastard, ENEMY_X)-Obj_GetX(obj))^2+
                        (GetEnemyInfo(bastard, ENEMY_Y)-Obj_GetY(obj))^2)^0.5<=20) {
                        ping = true;
                        // do stuff;
                        Obj_Delete(obj);
                    } else if (Obj_GetY(obj) <= GetClipMinY()) {
                        Obj_Delete(obj);
                    }
                } else {
//                    erase(Arrow,j);
//                    j--;
                }
                j++;
            }

Ok... analyze...

Getting an object from the array Arrow:
1)As long as it's not deleted:
1a)If it's 20 pixels away from "bastard", do stuff and delete it
1b)Otherwise, if it's above the playing field, delete it
2)If it HAS been deleted, remove it from the array, and subtract 1 from j
3)Add 1 to j after all that...

this makes j and the length of the array go down if something has been deleted, and j increases reaching the length sooner or later...

so you're basically checking everything in the array if they're either close to "bastard" or above the field...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 03, 2010, 03:10:12 PM
except that every time j--; executes, so does erase();, which causes length(Arrow) to drop by 1 as well. So it should be getting 1 closer to finishing every time... except that it's not.

but then... aren't you saying here that if it's not 20 pixels away from "bastard" you automatically do the commented out lines?

No, the else is operating on if(!Obj_BeDeleted()) - in other words, only if the object I pulled out of Arrow no longer exists
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 03, 2010, 03:13:55 PM
No, the else is operating on if(!Obj_BeDeleted()) - in other words, only if the object I pulled out of Arrow no longer exists

sorry... that was wrong... I updated my previous post if you noticed :D
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 03, 2010, 03:42:08 PM
know what? **** it. I'll make 'em straight homing. Maybe I'll come back to this method when I implement it for Musuu. (It'll be SO much goddamn easier in Musuu, too.)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 03, 2010, 03:49:55 PM
know what? **** it. I'll make 'em straight homing. Maybe I'll come back to this method when I implement it for Musuu. (It'll be SO much goddamn easier in Musuu, too.)

yeowtch... another person pissed at danmakufu... (nice graphics for that nazrin player btw... are the mice the ones in the Arrow array?)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 03, 2010, 04:00:44 PM
Taking it to this thread now.

As you may have noticed, I have released a new project (http://www.mediafire.com/?rtq2ihzem2u). If you have played it or read the thread, you may have noticed this:

...though it has an unhealthy tendency to do this:

(http://i591.photobucket.com/albums/ss352/Orichalc71/crash.png)

Sometimes right when I launch the script, occasionally after the ten-second intro "attack"; once I'm into the script proper, I'm usually okay, though one time it crashed halfway through. >.>

It's intermittent, and I've never seen DMF act like this before, so... ???

There seems to be nothing wrong with the individual spell- and non-card scripts, so I'm asking you, why would a plural script randomly cause danmakufu to crash? Could it be because of the type of file used for the bgm or something? I'm stumped.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 03, 2010, 04:04:19 PM
NEVER USE .OGG AND DANMAKUFU

EVER
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 03, 2010, 04:11:35 PM
Ah. Ok.

 :blush:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 03, 2010, 04:16:14 PM
Code: [Select]
            let j = 0;
            while(j < length(Arrow)){
                let obj = Arrow[j];
                if(!Obj_BeDeleted(obj)){
                    if(((GetEnemyInfo(bastard, ENEMY_X)-Obj_GetX(obj))^2+
                        (GetEnemyInfo(bastard, ENEMY_Y)-Obj_GetY(obj))^2)^0.5<=20) {
                        ping = true;
                        // do stuff;
                        Obj_Delete(obj);
                    } else if (Obj_GetY(obj) <= GetClipMinY()) {
                        Obj_Delete(obj);
                    }
                } else {
//                    erase(Arrow,j);
//                    j--;
                }
                j++;
            }

If I un-comment out those lines, it does an infinite loop, but... that's a standard maneuver for iterating through an array, isn't it?

Why oh why do people NEVER use ascents or descents for this stuff. Descents are ideal when dealing with arrays where you need to delete something if it doesn't match a certain condition. Lemme rewrite this for you:

Code: [Select]
            descent(j in 0..length(Arrow)){
                let obj = Arrow[j];
                if(!Obj_BeDeleted(obj)){
                    if(((GetEnemyInfo(bastard, ENEMY_X)-Obj_GetX(obj))^2+
                        (GetEnemyInfo(bastard, ENEMY_Y)-Obj_GetY(obj))^2)^0.5<=20) {
                        ping = true;
                        // do stuff;
                        Obj_Delete(obj);
                    } else if (Obj_GetY(obj) <= GetClipMinY()) {
                        Obj_Delete(obj);
                    }
                } else {
                      erase(Arrow,j);
                }
            }
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 03, 2010, 04:24:45 PM
Why oh why do people NEVER use ascents or descents for this stuff. Descents are ideal when dealing with arrays where you need to delete something if it doesn't match a certain condition. Lemme rewrite this for you:

Code: [Select]
            descent(j in 0..length(Arrow)){
                let obj = Arrow[j];
                if(!Obj_BeDeleted(obj)){
                    if(((GetEnemyInfo(bastard, ENEMY_X)-Obj_GetX(obj))^2+
                        (GetEnemyInfo(bastard, ENEMY_Y)-Obj_GetY(obj))^2)^0.5<=20) {
                        ping = true;
                        // do stuff;
                        Obj_Delete(obj);
                    } else if (Obj_GetY(obj) <= GetClipMinY()) {
                        Obj_Delete(obj);
                    }
                } else {
                      erase(Arrow,j);
                }
            }

why the heck did I forget ascents and descents... *facepalm*
I used that in my original! :blush:
Specifically here...

...
Code: [Select]
task ringshots(x, y, angle)
{
...
ascent(i in EnumEnemyBegin..EnumEnemyEnd) {
enemy_target=EnumEnemyGetID(i);
if( ((GetEnemyInfo(enemy_target, ENEMY_X)-Obj_GetX(obj))^2+(GetEnemyInfo(enemy_target, ENEMY_Y)-Obj_GetY(obj))^2)^0.5<=20) //distance from bullet to enemy is less than 20 (it's a big bullet)
{
CreatePlayerShot01(Obj_GetX(obj),Obj_GetY(obj),1,270,1.5,1,2);
Obj_Delete(obj);
}
}
}
}
Am such an idiot...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 03, 2010, 04:25:41 PM
Why oh why do people NEVER use ascents or descents for this stuff. Descents are ideal when dealing with arrays where you need to delete something if it doesn't match a certain condition.
They are not in the video tutorials. Go figure.

All this loop(n){ x++; do shit related to x; } and while(x<n){ x++; do shit related to x; } is so much more typing and less clear compared to simply using ascents and descents. I almost though I was the only one that regularly uses them. Glad you disproved me on this one


Also: Damn, as an mp3 the loop point of the music got changed yet again. Now I'll have to refix it... >.<
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 03, 2010, 04:27:08 PM
yeowtch... another person pissed at danmakufu... (nice graphics for that nazrin player btw... are the mice the ones in the Arrow array?)

No, the purple shots were in Arrow. The idea was, each of the mice can track a target, and their distance to that target. (measured in frames, of course) Whenever a "dowsing" shot hit an enemy, it'd relay that position to each of the mice; if the mouse is closer to that enemy than its current target (or if it doesn't have a target) then it turns and chases the new enemy.

I've gone through and commented up my code (http://www.mediafire.com/?milnn4vo0dv), in case anybody wants to poke around and see just what the **** is going wrong.

Why oh why do people NEVER use ascents or descents for this stuff. Descents are ideal when dealing with arrays where you need to delete something if it doesn't match a certain condition. Lemme rewrite this for you:

I'm not sure which would piss me off more: if this doesn't work, or if it does. Going to try it now.

It's not crashing, but slowdown happens really quickly (down to ~20fps after 10-15 seconds; compare my original with commented-out lines, which was ~54fps at the end of my 45s test card)

edit: D'OH! I figured it out... I wasn't using erase() right. I was expecting it to modify the array I passed it, but instead it returns the modified array. v_v gyeh...

Worst part is, this isn't the first time I've made this mistake. >.< (though never with this magnitude of breakage)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on March 03, 2010, 04:39:56 PM
never mind, I remember you have to have a TRAIGNLELIST or something like that
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 03, 2010, 04:41:40 PM
D'OH! I figured it out... I wasn't using erase() right. I was expecting it to modify the array I passed it, but instead it returns the modified array. v_v gyeh...

Worst part is, this isn't the first time I've made this mistake. >.< (though never with this magnitude of breakage)

Ahahaha, wow. I dunno how I didn't catch that either.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 03, 2010, 04:42:09 PM
@ Demonbman:

You forgot the ObjEffect_SetPrimitiveType command.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 03, 2010, 04:43:41 PM
Also, don't forget the load the graphic if you didn't... since a lot of people also forget to do that...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 03, 2010, 06:22:10 PM
What you try to accomplish is certainly possibly, but you need conditional statements. I happen to have used such code in a form of my newest project...  :V

Assuming ang is the angle you have and (x|y) is the point from which you need the distance from, it should look something like this...

Code: [Select]

function GetShit(x, y, ang){

let dist1;
let dist2;

while(ang>180){ ang-=360; }
while(ang<=-180){ ang+=360; }

let atl=atan2(GetClipMinY-y, GetClipMinX-x); //angle to top left corner
let atr=atan2(GetClipMinY-y, GetClipMaxX-x); //angle to top right corner
let abl=atan2(GetClipMaxY-y, GetClipMinX-x); //angle to bottom left corner
let abr=atan2(GetClipMaxY-y, GetClipMaxX-x); //angle to bottom right corner

if(ang>=atl && ang<=atr){ // In that case, the angle points to the top
  dist1=y-GetClipMinY;
  dist2=( (dist1^2) * ( (dist2/tan(ang+90))^2) )^0.5;
}
if(ang>=abr && ang<=abl){ // In that case, the angle points to the bottom
  dist1=GetClipMaxY-y;
  dist2=( (dist1^2) * ( (dist2/tan(ang))^2) )^0.5;
}
if(ang>=atr && ang<=abr){ // In that case, the angle points to the right side
  dist1=GetClipMaxX-x;
  dist2=( (dist1^2) * ( (dist2/tan(ang-90))^2) )^0.5;
}
if( (ang>=-180 && ang<=atl) || (ang>=abl && ang<=180) ){ // In that case, the angle points to the left side
  dist1=x-GetClipMinX;
  dist2=( (dist1^2) * ( (dist2/tan(ang+180))^2) )^0.5;
}

return dist2;
}

I don't know if this works, but I am too tired to test is right now and have to go to sleep in ~ 20 minutes. If the code doesn't work, I'll get back to it tomorrow.

Your code returned this error:
---------------------------
ScriptError「C:\Users\AweStriker\Downloads\th_dnh\script\AweScript\PrismStar.txt」
---------------------------
一回も代入していない変数を使おうとしました(91行目)

  dist2=( (dist1^2) * ( (dist2/tan(ang+90))^2) )^0.5;
}
if(ang>=abr && ang<=abl){ // In that case, the angle points to the b
~~~
---------------------------
OK   
---------------------------

which is variable-related.
(Also I renamed it to GetDistToEdge, because I like indicative names)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 03, 2010, 06:25:29 PM
And I instantly see why. This is why I shouldn't code 20 minutes before going to bed.  :V

dist2=( (dist1^2) * ( (dist2/tan(ang+90))^2) )^0.5;

should be

dist2=( (dist1^2) * ( (dist1/tan(ang+90))^2) )^0.5;

Fix this error in all the respective lines, then test again. Hopefully it will work.

Edit: Ack, screw it! It should be:


dist2=( (dist1^2) + ( (dist1/tan(ang+90))^2) )^0.5;
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 03, 2010, 07:48:09 PM
Well, that spellcard's done, but I'm having trouble with the next one.
Yes, this is for a boss...
Code: [Select]
#TouhouDanmakufu
#Title[Reflection Sniper]
#Text[Looks more like a bomb than a bullet]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{

let CSD = GetCurrentScriptDirectory;
let imgBoss = CSD ~ "Materials\Graphics\PlaceholderBoss.png";
#include_function "lib\ExpandedShotDatav4\shot_replace.dnh";

@Initialize{
SetLife(1000);
SetDamageRate(25,15);
SetTimer(40);
SetScore(1000);
SetMovePosition02(GetCenterX,GetCenterY,5);
LoadGraphic(imgBoss);
ShotInit;
mainTask;
}

@MainLoop{
SetCollisionA(GetX,GetY,32);
SetCollisionB(GetX,GetY,16);
yield;
}

@DrawLoop{

SetTexture(imgBoss);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicRect(0,0,64,64);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetX,GetY);

}

@BackGround{



}

@Finalize{

DeleteGraphic(imgBoss);

}
task mainTask{
wait(60);
startmove;
wait(60);
SniperGun;
ascent(i in -1..1){
ReflectPod(GetAngle+60*i);
}
}

task startmove{
let cirno=9;
let anglechange;
let curvetime = 0;
SetSpeed(1);
SetAngle(rand(0,360));
let selected = GetAngle;
while(cirno==9){
SetAngle(selected);
SetSpeed(1);
anglechange=rand(-0.2,0.2);
if(curvetime>=120){
loop(150){
SetAngle(GetAngle+anglechange);
SetSpeed(1);
if(GetEnemyX<GetClipMinX){
SetAngle(rand(-90,90));
}
if(GetEnemyX>GetClipMaxX){
SetAngle(rand(90,270));
}
if(GetEnemyY<GetClipMinY){
SetAngle(rand(0,180));
}
if(GetEnemyY>GetClipMaxY){
SetAngle(rand(180,360));
}
yield;
}
curvetime=0;
selected=rand(0,360);
SetSpeed(0);
wait(120);
}
curvetime++;
if(GetEnemyX<GetClipMinX){
SetAngle(rand(-90,90));
selected = GetAngle;
SetSpeed(1);
}
if(GetEnemyX>GetClipMaxX){
SetAngle(rand(90,270));
selected = GetAngle;
SetSpeed(1);
}
if(GetEnemyY<GetClipMinY){
SetAngle(rand(0,180));
selected = GetAngle;
SetSpeed(1);
}
if(GetEnemyY>GetClipMaxY){
SetAngle(rand(180,360));
selected = GetAngle;
SetSpeed(1);
}
yield;
}
}

task fire{

}

task ReflectPod(angle){
let reflecttime=0;
let reflect = Obj_Create(OBJ_SHOT);
Obj_SetPosition(reflect,GetX,GetY);
Obj_SetAngle(reflect,angle);
ObjShot_SetGraphic(reflect,ORANGE02);
Obj_SetSpeed(reflect,1);
ObjShot_SetBombResist(reflect,true);
Obj_SetCollisionToPlayer(reflect,false);
while(!Obj_BeDeleted(reflect)){
if(Obj_GetX(reflect)<=GetClipMinX||Obj_GetX(reflect)>=GetClipMaxX){
Obj_SetAngle(reflect,180-angle);
}
if(Obj_GetY(reflect)<=GetClipMinY||Obj_GetY(reflect)>=GetClipMaxY){
Obj_SetAngle(reflect,360-angle);
}
if(reflecttime==540){
explosion(Obj_GetX(reflect),Obj_GetY(reflect));
Obj_Delete(reflect);
}
if(GetDistance(Obj_GetX(reflect),Obj_GetY(reflect),GetPlayerX,GetPlayerY)<12){
explosion(Obj_GetX(reflect),Obj_GetY(reflect));
Obj_Delete(reflect);
}
reflecttime++;
wait(1);
}
}

task SniperGun{
CreateLaser01(GetX,GetY,5,GetAngleToPlayer,100,25,PURPLE41,0);
}

task DualBomb{

}

function explosion(x,y){
let dir = 90;
loop(5){
CreateShotA(1,x,y,0);
SetShotDataA(1,0,0.1,dir,0.5,0,0,ORANGE03);
SetShotKillTime(1,240);
CreateShotA(2,0,0,0);
SetShotDataA(2,0,5,dir,0,-0.8,1,ORANGE01);
ascent(m in 1..24){
AddShot(m*10,1,2,0);
}
FireShot(1);
dir+=360/5;
}
loop(25){
CreateShot01(x,y,1,dir,RED01,0);
dir+=360/25;
}
}

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

function GetDistance(x1,y1,x2,y2){
return(((x2-x1)^2+(y2-y1)^2)^(1/2))
}
}

There are several problems:
1. Only 2 reflect objectshots are being spawned. Where's the third one?

2. The reflect objectshots will bounce in the opposite direction of the one they were traveling rather than actually reflect (but only after they've bounced once; the first bounce is a true reflection)

3. Only one ORANGE01 shot is spawned from the explosion function. There should be one every ten frames.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 03, 2010, 08:00:12 PM
There are several problems:
1. Only 2 reflect objectshots are being spawned. Where's the third one?
The ascent function starts on the lowest value and increases by one each loop, ending when it is 1 lower than the upper bound. ascent(i in 0..3){} is done once for i=0, i=1 and i=2. Your stuff is repeated for i=-1 and i=0. To make it work, change it to (i in -1..2)
 
Quote
3. Only one ORANGE01 shot is spawned from the explosion function. There should be one every ten frames.
Um, you are adding shots, okay, but you are not creating the shots you are adding. You only create one shot and then try to add that one shot 23 times. After the first time, the id ceases to exist and you have to create it again.
Code: [Select]
         CreateShotA(2,0,0,0);
         SetShotDataA(2,0,5,dir,0,-0.8,1,ORANGE01);
         ascent(m in 1..24){
            AddShot(m*10,1,2,0);
         }
...should be...
Code: [Select]
         ascent(m in 1..24){
            CreateShotA(m*10,0,0,0);
            SetShotDataA(m*10,0,5,dir,0,-0.8,1,ORANGE01);
            AddShot(m*10,1,m*10,0);
         }


Quote
2. The reflect objectshots will bounce in the opposite direction of the one they were traveling rather than actually reflect (but only after they've bounced once; the first bounce is a true reflection)
You are determining the new angle based on the variable angle, not on the actual angle of the bullet. On the first reflection they are still the same, but after that they are not. To fix this, insert angle=Obj_GetAngle(reflect); into your while loop{}.

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 03, 2010, 10:14:06 PM
Sorry for bringing this up now, but
They are not in the video tutorials. Go figure.
made me rage really hard, even though obviously Iryan isn't talking about himself.

The wiki and other tutorials exist for a reason. Hele's tutorials are not everything that can be possibly explained to you, and they're just videos. He's not going to explain to you every fucking little thing danmakufu has buried in it's predeffed function list and every nuance of it's syntax. They aren't explaining super duper complex programming shit, nor does it explain every simple little programming turd. The wiki exists as a reference to the functions that are available and what you can do with the base of the language, so use it. This also goes for the other tutorials. They're damn fine tutorials, and it would pain me to see questions being asked that could have been answered easily if the person would use the VERY OBVIOUSLY PLACED RESOURCES outlined for them.

fuckjsd

EDIT: complaining about danmakufu is best reserved for stuff that is impossible due to it's own limitations, or really really complicated stuff that generally is hard to accomplish by anyone and/or takes stupidly large amounts of time to complete
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on March 03, 2010, 10:44:32 PM
@ Demonbman:

You forgot the ObjEffect_SetPrimitiveType command.
lol I notice that now
But now that I put it in it still doesnt work :X

Ill post the whole Bomb script

Code: [Select]
script_spell Ultimate_Shield{
let shield = GetCurrentScriptDirectory~"img\字る.png";
let sparkle = GetCurrentScriptDirectory~"img\effect.png";
let spin = 4;

@Initialize{yield; LoadGraphic(shield); LoadGraphic(sparkle); run();}
@MainLoop{spin++; yield;}
@Finalize{DeleteGraphic(shield); DeleteGraphic(sparkle);}

task run(){SetPlayerInvincibility(220); loop(10){yield;} Sparlke; loop(220){yield;} End;}

task Sparlke{
loop{
loop(1){yield;}
Sparkle(GetPlayerX+rand(-120,120),GetPlayerY+rand(-120,120));
}}

task Sparkle(xx,yy){

let spark=Obj_Create(OBJ_EFFECT);
let atta = 0;
let attb = 0;
let attfra = 0;

ObjEffect_SetTexture(spark,sparkle);
ObjEffect_SetScale(spark,1,1);
ObjEffect_SetRenderState(spark,255);
ObjEffect_CreateVertex(spark,8);
ObjEffect_SetLayer(spark,8);
ObjEffect_SetPrimitiveType(spark,PRIMITIVE_TRIANGLEFAN);

while(Obj_BeDeleted(spark)==false){attfra++;

   ObjEffect_SetVertexXY(spark, 0, xx-20,yy-20);
   ObjEffect_SetVertexXY(spark, 1, xx,yy-20);
   ObjEffect_SetVertexXY(spark, 2, xx+20,yy-20);
   ObjEffect_SetVertexXY(spark, 3, xx+20,yy);
   ObjEffect_SetVertexXY(spark, 4, xx+20,yy+20);
   ObjEffect_SetVertexXY(spark, 5, xx,yy+20);
   ObjEffect_SetVertexXY(spark, 6, xx-20,yy+20);
   ObjEffect_SetVertexXY(spark, 7, xx-20,yy);

ObjEffect_SetVertexUV(spark,0,0,0);
ObjEffect_SetVertexUV(spark,1,0,10);
ObjEffect_SetVertexUV(spark,2,0,20);
ObjEffect_SetVertexUV(spark,3,10,0);
ObjEffect_SetVertexUV(spark,4,20,20);
ObjEffect_SetVertexUV(spark,5,20,10);
ObjEffect_SetVertexUV(spark,6,20,0);
ObjEffect_SetVertexUV(spark,7,10,0);

if(attfra>80){atta++;
ObjEffect_SetVertexXY(spark, 1, xx,yy-20+atta);
ObjEffect_SetVertexXY(spark, 3, xx+20-atta,yy);
ObjEffect_SetVertexXY(spark, 5, xx,yy+20-atta);
ObjEffect_SetVertexXY(spark, 7, xx-20+atta,yy);}

if(atta==20){Obj_Delete(spark);}
}}

What I want to happen is a object that appears, then the corners fold in, but I cant even get the image to appear at all >_<;
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 04, 2010, 12:59:18 AM
 >:(

Okay, I'm fed up with this... I've been trying to use COLOR## shot IDs with Shot Replace V4, and I can't get it to work. I'm assuming the problem is somewhere in the shot_replace.dnh file, as if I put in the plain number ID it works fine. There is EXACTLY ONE LINE that could possibly have the problem in it...
Code: [Select]
LoadUserShotData(".\supershot.txt")And that would be it.

What the heck do I put in that line to make it work, if anything will? Or does the sub need to be a function, or a task? Or do I just need to use the numbers?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 04, 2010, 02:09:59 AM
There is no shot_replace.dnh that comes with supershot v4 or v4.1. Did you make your own?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 04, 2010, 02:42:38 AM
What.

That's odd, mine was packaged in for no apparent reason...  :/
Although I do know 4.1 doesn't have one.
I guess I'll just stick to using the numbers then.

Although there is another thing I wanted to do...

Parsee's Grandfather Cherry Blossom cards produce that 5-petaled flower thing, and I want one with 6. How would I do that?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 04, 2010, 02:58:39 AM
let x = GetX;
let y = GetY;

ascent(i in 0..6){
   CreateShotA(0, x + 15*cos(i*60), y + 15*sin(i*60), 20);
   SetShotDataA(0, 0, 0, i*60, 0, 0, 0, YELLOW12);
   SetShotKillTime(0, 240);
   FireShot(0);
}

It's just a circle of bullets.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: ChaoStar on March 04, 2010, 03:54:35 AM
I wanted to make something like Sakuya's last word, in IN. buuut...

How do you make object bullets curve?

How do you make them curve, and when a variable equals one, shoot bullets in the direction the bullet is pointing?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 04, 2010, 03:59:26 AM
How do you make object bullets curve?

How do you make them curve, and when a variable equals one, shoot bullets in the direction the bullet is pointing?

while(!Obj_BeDeleted(obj)){
  angle++;
  Obj_SetAngle(obj, angle);
  if(variable==1){
    CreateShot01(Obj_GetX(obj), Obj_GetY(obj), 3, Obj_GetAngle(obj), RED01, 0);
  }
  yield;
}


Insert whatever logic you may need.

Totally going to consistantly highlight danmakufu code from now on, so much easier to read.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 05, 2010, 02:44:07 AM
nm, answered on IRC.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 05, 2010, 04:26:37 AM
Huh. Don't CreateA bullets fade delete? Mine just seem to cease to exist instantaneously.

Still, I got the radius right on that snowflake thing first try (6). It looks good next to accompanying "sonic wave" and stream of fireballs. Can't wait until I add the dark purple fog, lightning, and bright white laser trail.

EDIT: Lightning is proving a bad idea to implement
EDIT2: never mind, lightning is too awesome to not implement

What, you thought all those were going to be spawned from the same projectile?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on March 05, 2010, 04:31:51 AM
Use SetShotKillTime to delete LaserA
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 05, 2010, 05:12:02 AM
I wasn't asking about that.

I have this code:
Code: [Select]
task icecrystal(x,y){
let seeddir = rand_int(0,360);
ascent(i in 1..7){
CreateShotA(1,x+6*cos(seeddir),y+6*sin(seeddir),4);
SetShotDataA(1,0,0,seeddir,0,0,0,86);
SetShotKillTime(1,180);
FireShot(1);
seeddir+=360/6;
}
}

and instead of fading out, the crystals vanish abruptly.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Hat on March 05, 2010, 05:20:24 AM
IT'S TIME... for another classic episode of my crippling, brain-raping stupidity.

So. Ya know how in MoF and all the games ever the options kind of... drift a little as you move? They'll lag behind your movement a bit. Could someone please provide a bit of guidance? I needn't have a whole working script, just a quick conceptual response should be sufficient (it's for LERNIN :V)

if there were ever any doubt that I am a retard...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on March 05, 2010, 05:25:42 AM
In stead of having the options move when the player does, set it only to update the position using the % way.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 05, 2010, 07:05:34 AM
IT'S TIME... for another classic episode of my crippling, brain-raping stupidity.

So. Ya know how in MoF and all the games ever the options kind of... drift a little as you move? They'll lag behind your movement a bit. Could someone please provide a bit of guidance? I needn't have a whole working script, just a quick conceptual response should be sufficient (it's for LERNIN :V)

if there were ever any doubt that I am a retard...

How I did it in my Nazrin player just recently:

Code: [Select]
    let PickX = []; // option positions             
    let PickY = []; // (lol parallel arrays)
    @MainLoop{
        if((GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD)){
            PickX = [-30,-18,18,30];
            PickY = [-4,4,4,-4];
        } else {
            PickX = [-120,-60,60,120];
            PickY = [12,-8,-8,12];
        }
        ascent(i in 0..4){
...
            let optx = (PickX[i] - Obj_GetX(opt))/4 + Obj_GetX(opt);
            let opty = (PickY[i] - Obj_GetY(opt))/4 + Obj_GetY(opt);
            Obj_SetX(opt,optx);
            Obj_SetY(opt,opty);
        }
    }

Seems to work well enough. You can also play with optx and opty a bit before calling SetX and SetY. (I put some sinusoidal action in)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 05, 2010, 10:28:42 AM
Code: [Select]
script_spell Ultimate_Shield{
let shield = GetCurrentScriptDirectory~"img\字る.png";
let sparkle = GetCurrentScriptDirectory~"img\effect.png";
let spin = 4;

@Initialize{yield; LoadGraphic(shield); LoadGraphic(sparkle); run();}
@MainLoop{spin++; yield;}
@Finalize{DeleteGraphic(shield); DeleteGraphic(sparkle);}

task run(){SetPlayerInvincibility(220); loop(10){yield;} Sparlke; loop(220){yield;} End;}

task Sparlke{
loop{
loop(1){yield;}
Sparkle(GetPlayerX+rand(-120,120),GetPlayerY+rand(-120,120));
}}

task Sparkle(xx,yy){

let spark=Obj_Create(OBJ_EFFECT);
let atta = 0;
let attb = 0;
let attfra = 0;

ObjEffect_SetTexture(spark,sparkle);
ObjEffect_SetScale(spark,1,1);
ObjEffect_SetRenderState(spark,255);
ObjEffect_CreateVertex(spark,8);
ObjEffect_SetLayer(spark,8);
ObjEffect_SetPrimitiveType(spark,PRIMITIVE_TRIANGLEFAN);

while(Obj_BeDeleted(spark)==false){attfra++;

   ObjEffect_SetVertexXY(spark, 0, xx-20,yy-20);
   ObjEffect_SetVertexXY(spark, 1, xx,yy-20);
   ObjEffect_SetVertexXY(spark, 2, xx+20,yy-20);
   ObjEffect_SetVertexXY(spark, 3, xx+20,yy);
   ObjEffect_SetVertexXY(spark, 4, xx+20,yy+20);
   ObjEffect_SetVertexXY(spark, 5, xx,yy+20);
   ObjEffect_SetVertexXY(spark, 6, xx-20,yy+20);
   ObjEffect_SetVertexXY(spark, 7, xx-20,yy);

ObjEffect_SetVertexUV(spark,0,0,0);
ObjEffect_SetVertexUV(spark,1,0,10);
ObjEffect_SetVertexUV(spark,2,0,20);
ObjEffect_SetVertexUV(spark,3,10,0);
ObjEffect_SetVertexUV(spark,4,20,20);
ObjEffect_SetVertexUV(spark,5,20,10);
ObjEffect_SetVertexUV(spark,6,20,0);
ObjEffect_SetVertexUV(spark,7,10,0);

if(attfra>80){atta++;
ObjEffect_SetVertexXY(spark, 1, xx,yy-20+atta);
ObjEffect_SetVertexXY(spark, 3, xx+20-atta,yy);
ObjEffect_SetVertexXY(spark, 5, xx,yy+20-atta);
ObjEffect_SetVertexXY(spark, 7, xx-20+atta,yy);}

if(atta==20){Obj_Delete(spark);}
}}

What I want to happen is a object that appears, then the corners fold in, but I cant even get the image to appear at all >_<;
ObjEffect_SetRenderState(spark,255);
 ...?! I think you meant to type:
ObjEffect_SetRenderState(spark,ADD); ObjEffect_SetRenderAlpha(spark,255);
Other than that, when in doubt check the file paths of the images again. And I am so totally not going to look wether or not you placed you vertices correctly.



I wasn't asking about that.

I have this code:
Code: [Select]
task icecrystal(x,y){
let seeddir = rand_int(0,360);
ascent(i in 1..7){
CreateShotA(1,x+6*cos(seeddir),y+6*sin(seeddir),4);
SetShotDataA(1,0,0,seeddir,0,0,0,86);
SetShotKillTime(1,180);
FireShot(1);
seeddir+=360/6;
}
}

and instead of fading out, the crystals vanish abruptly.
SetShotKillTime makes the bullets vanish instantaneously. They only fade (like every regular bullet) when they are removed through bombs or player death. For forced fade deletiong you will have to use ObjShot_FadeDelete(obj);
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 05, 2010, 12:41:40 PM
So. Ya know how in MoF and all the games ever the options kind of... drift a little as you move? They'll lag behind your movement a bit. Could someone please provide a bit of guidance? I needn't have a whole working script, just a quick conceptual response should be sufficient (it's for LERNIN :V)

I don't want to emphasize any misplaced self-doubt you may have, but you probably should've looked at other player scripts that use the same effect before asking that question.

Unless you don't download player scripts >: |
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Hat on March 05, 2010, 02:01:25 PM
I do, but none of the player scripts I have use that effect; that is, unless your Remilia does, but I can't tell. \=| I suppose I'll look at the scripts that have already been posted before I come bothering you guys here...?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 05, 2010, 03:16:03 PM
Usually the idea is to at least attempt to find an answer on your own before asking a question about it. I don't mind helping people with their Danmakufu problems, but I do mind if they don't put any effort at all in to solving them.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 05, 2010, 06:23:44 PM
So I've been trying to get an Object Sinuate to move in something akin to a sine wave.
Code: [Select]
task lightningbolt(x,y,speed,direction){
let laserbolt = ObjSinuateLaser_Create(x,y,speed,direction,50,8,67,0);
while(!Obj_BeDeleted(laserbolt)){
Obj_SetPosition(laserbolt,Obj_GetX(laserbolt)+25*cos(direction+90),Obj_GetY(laserbolt)+25*sin(direction+90));
yield;
}
}
This is the way I am currently trying to do it. The initial angle points it right at the player, obviously, but with any luck it will curve off to either side. In short, this is the part of the card that is likely to cause the most trouble due to its erratic movement.

But right now, it just seems to be shooting a laser at some odd angle.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 05, 2010, 06:35:38 PM
Add a let dir = direction and dir++ in there, bud. Just having one direction isn't going to do you much good.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 05, 2010, 06:39:22 PM
So I've been trying to get an Object Sinuate to move in something akin to a sine wave.
Code: [Select]
task lightningbolt(x,y,speed,direction){
let laserbolt = ObjSinuateLaser_Create(x,y,speed,direction,50,8,67,0);
while(!Obj_BeDeleted(laserbolt)){
Obj_SetPosition(laserbolt,Obj_GetX(laserbolt)+25*cos(direction+90),Obj_GetY(laserbolt)+25*sin(direction+90));
yield;
}
}
This is the way I am currently trying to do it. The initial angle points it right at the player, obviously, but with any luck it will curve off to either side. In short, this is the part of the card that is likely to cause the most trouble due to its erratic movement.

But right now, it just seems to be shooting a laser at some odd angle.
Huh? Why would it do anything else?

Obj_SetPosition(laserbolt,Obj_GetX(laserbolt)+25*cos(direction+90),Obj_GetY(laserbolt)+25*sin(direction+90));

This code makes your laser move with a speed of 25 pixels per frame (which is ludicrously high if you ask me) in the direction of (direction+90).
Where is the code that is supposed to cause random movement? I don't see any.

If you want to have the bullet curve in a random direction, then include another parameter in your function, lets call it phi, and then put direction+=phi in your while{} loop. Then randomize the number you put into phi somehow.

Edit: Dang it, lunar dial'd!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 05, 2010, 08:09:48 PM
I just realized the source of my problem is entirely different.

Here's what I missed:
   task lightningbolt(x,y,speed,direction){
      let offset = rand_int(0,360);
      let laserbolt = ObjSinuateLaser_Create(x,y,speed,direction,50,8,67,0);
      while(!Obj_BeDeleted(laserbolt)){
         Obj_SetPosition(laserbolt,Obj_GetX(laserbolt)+25*rand(0,1)*cos(offset)*cos(direction+90),Obj_GetY(laserbolt)+25*rand(0,1)*sin(offset)*sin(direction+90));
         yield;
      }
   }


This will move the sinuate laser (because it is one) to a point somewhere within 25 pixels of its last position every frame, but with a general velocity of (speed) in (direction). I think.

AFTER TESTING: Meh, it's close enough.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: professor_scissors on March 07, 2010, 03:12:33 AM
Hey, quick Stage/Enemy scripting question!

I want enemies on a stage that follow another enemy around like slaves. If this were a boss, I'd just have them reference GetEnemyX/Y, but it's just another, larger normal enemy. Any tips on how to accomplish this?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on March 07, 2010, 04:16:39 AM
Hey, quick Stage/Enemy scripting question!

I want enemies on a stage that follow another enemy around like slaves. If this were a boss, I'd just have them reference GetEnemyX/Y, but it's just another, larger normal enemy. Any tips on how to accomplish this?

In the master enemy's @MainLoop:
SetCommonData("ThisEnemysX", GetX);
SetCommonData("ThisEnemysY", GetY);

Then in the slave enemy's, F.O.E.!:
..... GetCommonData("ThisEnemysX", GetX); .....
..... GetCommonData("ThisEnemysY", GetY); .....
.....or just make the slave enemies move in the same pattern as the master enemy.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 07, 2010, 05:36:29 AM
Odd...
I'm having trouble with this code. It's giving me a mismatch error for some reason... a reason that I can't see.
Code: [Select]
script_enemy_main{

let CSD = GetCurrentScriptDirectory;
let imgBoss = CSD ~ "Materials\Graphics\PlaceholderBoss.png";
#include_function ".\ExpandedShotDatav4\shot_replace.dnh";

@Initialize{
SetLife(1000);
SetDamageRate(25,15);
SetTimer(40);
SetScore(1000);
SetMovePosition01(GetCenterX,GetCenterY-150,5);
LoadGraphic(imgBoss);
ShotInit;
CutIn(KOUMA,"Collapse Sign "\""Burial in the Collapsing Cavern"\","",0,0,0,0);
mainTask;
}

@MainLoop{
SetCollisionA(GetX,GetY,32);
SetCollisionB(GetX,GetY,16);
yield;
}

@DrawLoop{

SetTexture(imgBoss);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicRect(0,0,64,64);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetX,GetY);

}

@BackGround{



}

@Finalize{

DeleteGraphic(imgBoss);

}
task mainTask{
collapseroutine;
move;
}

task collapseroutine{
let shotchoice = [52, 155, 164, 207]
loop{
CreateShotA(1,rand_int(GetClipMinX,GetClipMaxX),GetClipMinY,10);
SetShotDataA_XY(1,0,rand(-1,1),0,0,0.07,0,3,shotchoice[rand_int(0,3)]);
FireShot(1);
wait(30);
}
}

task move{
loop{
SetMovePositionRandom01(200,50,4,GetClipMinX,GetClipMinY,GetClipMaxX,GetCenterY-75);
earthfans;
wait(120);
}
}

task earthfans{
let angle = GetAngleToPlayer;
ascent[a in 3..8]{
ascent in [b in -5..6]{
CreateShotA(1,GetX,GetY,5);
SetShotDataA(1,0,1,angle+90+10*b,0,0,0,37);
SetShotDataA(1,10*a,0,angle+rand_int(-5,5),0,0,0,37);
SetShotDataA(1,90-10*a,NULL,0,0,0,37);
FireShot(1);
CreateShotA(1,GetX,GetY,5);
SetShotDataA(1,0,1,angle-90+10*b,0,0,0,37);
SetShotDataA(1,10*a,0,angle+rand_int(-5,5),0,0,0,37);
SetShotDataA(1,90-10*a,NULL,0,0,0,37);
FireShot(1);
}
}
}

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

}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 07, 2010, 05:54:22 AM
Quote
         ascent in [b in -5..6]{

dunno if it'd cause a mismatch error, but that certainly doesn't look right.

...moreover, are square brackets kosher for ascents? I've only ever seen parentheses.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on March 07, 2010, 05:58:12 AM
Ascents are written in Paranthesis, not brackets, so Blue Showdown is right

ascent(b in -5..6){

should fix your problem
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 07, 2010, 06:26:55 AM
*slaps self upside the head*

It won't fix my latency problems (for some reason DMF's average speed has dropped to about 50 after I fixed teh jerkiness), but it will fix my script...

So if anyone knows what to do about those...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on March 07, 2010, 06:32:49 AM
Maybe you have too many programs running, or maybe you have too many bullets on the playing field at once? I'm not sure what you mean by "latency problems".
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on March 07, 2010, 06:39:43 AM
ObjEffect_SetRenderState(spark,255);
 ...?! I think you meant to type:
ObjEffect_SetRenderState(spark,ADD); ObjEffect_SetRenderAlpha(spark,255);
Other than that, when in doubt check the file paths of the images again. And I am so totally not going to look wether or not you placed you vertices correctly.   
for some reason I get an error with ObjEffect_SetRenderAlpha(spark,255);   like its saying that thats isnt a command or something
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on March 07, 2010, 06:42:36 AM
Because it isn't a command. The only way to change the alpha of an object effect is with ObjEffect_SetVertexColor(obj,vertex,alpha,r,g,b);
Obj is the object (of course), vertex is the number of the vertex to change (you have to loop through all of them - remember the numbering starts at 0), alpha is obvious (0 to 255 as usual), and r/g/b is the color.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 07, 2010, 10:31:57 AM
for some reason I get an error with ObjEffect_SetRenderAlpha(spark,255);   like its saying that thats isnt a command or something
Auuuugh.

Well, yeah. I did a typo in my advice. It would have had to be ObjEffect_SetAlpha(spark,255);, without the "Render". And even then, even though it would have been an actual command, it probably wouldn't have worked properly. Use Azure's code.

...I seriously need to reread the advice I give.  :X
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 07, 2010, 03:34:37 PM
Maybe you have too many programs running, or maybe you have too many bullets on the playing field at once? I'm not sure what you mean by "latency problems".

I only ever have Danmakufu running at one time (other than Notepad and Windows Explorer), but somehow it still won't go above 50 FPS except for bursts of super-fast-ness after a script is done running.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 07, 2010, 07:19:04 PM
Auuuugh.

Well, yeah. I did a typo in my advice. It would have had to be ObjEffect_SetAlpha(spark,255);, without the "Render". And even then, even though it would have been an actual command, it probably wouldn't have worked properly. Use Azure's code.

...I seriously need to reread the advice I give.  :X
That isn't a command either.
Obj_SetAlpha(obj,255);
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 07, 2010, 07:25:04 PM
That isn't a command either.
Obj_SetAlpha(obj,255);
brb punching myself in the face
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on March 07, 2010, 07:37:16 PM
This was implied in the previous posts, but just to avoid confusion: Obj_SetAlpha doesn't work with object effects, just shots and lasers. That's why I said the ObjEffect_SetVertexColor method.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 07, 2010, 08:31:31 PM
Ascents are written in Paranthesis, not brackets, so Blue Showdown is right

ascent(b in -5..6){

should fix your problem

Surprisingly, that didn't work. In fact, the text of the error is...
---------------------------
ScriptError「C:\Users\AweStriker\Downloads\th_dnh\script\AweScript\CollapseCavern.txt」
---------------------------
"}"が必要です(349行目)

      loop{

         CreateShotA(1,rand_int(GetClipMinX,GetClipMaxX),GetClipMinY,10);

         SetShotDataA_XY(1,0,rand(-1,1),0,0,0.07,0,3
~~~
---------------------------
OK   
---------------------------
which is exactly the same error I got the first time. HM
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 07, 2010, 08:35:31 PM
Code: [Select]
   task collapseroutine{
      let shotchoice = [52, 155, 164, 207]
      loop{
         CreateShotA(1,rand_int(GetClipMinX,GetClipMaxX),GetClipMinY,10);
         SetShotDataA_XY(1,0,rand(-1,1),0,0,0.07,0,3,shotchoice[rand_int(0,3)]);
         FireShot(1);
         wait(30);
      }
   }
Quote
      let shotchoice = [52, 155, 164, 207] ;

Missing a seimcolon there.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 07, 2010, 09:47:44 PM
Code: [Select]
   task collapseroutine{
      let shotchoice = [52, 155, 164, 207]
      loop{
         CreateShotA(1,rand_int(GetClipMinX,GetClipMaxX),GetClipMinY,10);
         SetShotDataA_XY(1,0,rand(-1,1),0,0,0.07,0,3,shotchoice[rand_int(0,3)]);
         FireShot(1);
         wait(30);
      }
   }
Missing a seimcolon there.

Fixed, but the fans here just hang in midair. What's wrong in the SetShotData?
Code: [Select]
task earthfans{

let angle = GetAngleToPlayer;

ascent(a in 3..8){

ascent(b in -5..6){

CreateShotA(1,GetX,GetY,5);

SetShotDataA(1,0,1,angle+90+10*b,0,0,0,37);

SetShotDataA(1,20*a,0,angle+rand_int(-5,5),0,0,0,37);

SetShotDataA(1,90-10*a,1,NULL,0,0,0,37);

FireShot(1);

CreateShotA(1,GetX,GetY,5);

SetShotDataA(1,0,1,angle-90+10*b,0,0,0,37);

SetShotDataA(1,20*a,0,angle+rand_int(-5,5),0,0,0,37);

SetShotDataA(1,90-10*a,1,NULL,0,0,0,37);

FireShot(1);

}

}

}[/size][/font]
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 07, 2010, 09:55:26 PM
Well...

When a assumes values ranging from 3 to 7, then the second parameter of the SetShotData commands, that is the time after creation that the change will take place, will look like this:

0;

60; 80; 100; 120; 140;

60; 50; 40; 30; 20;

As you can see, the effects of the third SetShotData apply earlier that the effects of the second, meaning that the bullets are left with a speed and an acceleration of zero.

Edit: Fixed typoes. Posting 10 minutes before going to bed makes me type stupid things, even when I actually know better... T.T
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 07, 2010, 10:58:10 PM
Well that's no good, I need the third SetShotData lines to occur simultaneously.

...so if I change the spread velocity of the bullets to 2... and then... wait, these are all being spawned simultaneously. I need a constant in the third line.

And now it works fine!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 10, 2010, 02:18:52 AM
Anyone know how the CtC Yukari's teleportation effect works? I remember it vaguely but I don't have CtC anymore so I cant look at it myself.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nimble on March 10, 2010, 11:04:54 AM
Move Boss instanly and then

Concentration01(30);

=w=b
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 10, 2010, 12:52:28 PM
Please tell me you're joking... I was pretty sure there was a fancier effect than that. :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nimble on March 10, 2010, 02:22:53 PM
Hmm, if you asking for her effect like in this one (CtC stage 4) (http://www.youtube.com/watch?v=LT1-0BPsOhc). It is Concentration01(30).
I just notice that they add white line for addition gap effect for teleportation too.

Taken from Phantasm Romance, Daiyousei teleportation movement.
Code: [Select]
Concentration01(30);
flg=0;
wait(30);
SetMovePosition02(cenX+movepos[move],rand(80,120),1);
wait(30);
flg=1;
Concentration01(30);

Did I miss something?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 10, 2010, 05:50:26 PM
If I had to guess, I'd say two CreateLaserA's with delay==SetShotKillTime, and Explosion01 (http://dmf.shrinemaiden.org/wiki/index.php?title=Enemy_Script_Functions#Explosion01) or Concentration01(30) depending on if you want the circle to expand or contract (in addition to other effects like SetEnemyMarker(false), SetX, SetY and an invisible sprite).
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 11, 2010, 06:27:43 AM
Awww, it really is just default effects? How saddening. I thought the CtC team was really awesome and made their own effect for it. Oh well, thanks.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 11, 2010, 06:34:19 AM
How saddening.

Saddening doesn't even begin to describe CtC code.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: AweStriker Nova on March 11, 2010, 02:36:02 PM
Saddening doesn't even begin to describe CtC code.

Is it that it's so incomprehensible no one can steal it or so unoptimized that it runs way too slowly on anything less than a high-end PC? Or both?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: professor_scissors on March 11, 2010, 04:37:19 PM
More advanced stage enemy problem!

Code for an enemy in a stage script is as follows:

Code: [Select]
script_enemy_main
{//Slave-having enemy
let count=0;
let cx=GetCenterX();
let imgEnemy=GetCurrentScriptDirectory~"img\Enemy.png";
let imgAngle=0;
let shotAngle=0;
let id = GetArgument;

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

task TMove {
wait(400);
VanishEnemy;
}

@Initialize
{
SetLife(500);
SetGraphicRect(1,1,32,32);
SetMovePosition03(GetCenterX+(-(GetX-GetCenterX)+600), GetY + 800, 30, 1);

if(id) {
SetCommonData("Enemy01LeftX", GetX);
SetCommonData("Enemy01LeftY", GetY);
} else {
SetCommonData("Enemy01RightX", GetX);
SetCommonData("Enemy01RightY", GetY);
}

SetCommonData("Enemy01Side", GetArgument);
ascent(i in 0..4) {
CreateEnemyFromScript("Familiar", GetX, GetY, 0, 0, i*90);
}
TMove;
}

@MainLoop
{
    SetCollisionA(GetX, GetY, 16);
        SetCollisionB(GetX, GetY, 16);
if(id) {
SetCommonData("Enemy01LeftX", GetX);
SetCommonData("Enemy01LeftY", GetY);
} else {
SetCommonData("Enemy01RightX", GetX);
SetCommonData("Enemy01RightY", GetY);
}
yield;
}

@Finalize
{//読みこんだファイルを削除
CreateItem(ITEM_SCORE, GetX + rand(-10,10), GetY + rand(10,10));
}

@DrawLoop
{//描画
SetTexture(imgEnemy);
SetColor(255,255,255);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,imgAngle);
DrawGraphic(GetX(),GetY());
SetRenderState(ADD);
SetGraphicAngle(0,0,-imgAngle);
DrawGraphic(GetX(),GetY());
imgAngle+=4;
if(imgAngle>360){imgAngle=0;}
}
}

script_enemy Familiar {
let ImgFam = GetCurrentScriptDirectory ~ "img\Enemy.png";
let imgAngle=0;
let angle = GetArgument;
let id = false;

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


    @Initialize {
        SetLife(100);
        SetScore(0);
        SetDamageRateEx(100, 100, 50, 50);

        LoadGraphic(ImgFam);
        SetTexture(ImgFam);
SetGraphicRect(1,1,32,32);

id = GetCommonData("Enemy01Side");

        TRotate;
        TFire;
    }

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

@DrawLoop
{//描画
SetTexture(ImgFam);
SetColor(255,255,255);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,imgAngle);
DrawGraphic(GetX(),GetY());
SetRenderState(ADD);
SetGraphicAngle(0,0,-imgAngle);
DrawGraphic(GetX(),GetY());
imgAngle+=4;
if(imgAngle>360){imgAngle=0;}
}

  @Finalize
{//読みこんだファイルを削除
CreateShot01(GetX, GetY, 2, angle, RED01, 10);
CreateShot01(GetX, GetY, 2, angle+30, RED01, 10);
CreateShot01(GetX, GetY, 2, angle-30, RED01, 10);
CreateItem(ITEM_SCORE, GetX + rand(-10,10), GetY + rand(10,10));
}

// rotate around the boss
    task TRotate {
let eX = 0;
let eY = 0;
loop {
if(id) {
eX = GetCommonData("Enemy01LeftX");
eY = GetCommonData("Enemy01LeftY");
} else {
eX = GetCommonData("Enemy01RightX");
eY = GetCommonData("Enemy01RightY");
}
SetX(eX + cos(angle) * 50);
SetY(eY + sin(angle) * 50);
yield;
angle += 1.5;
}
}

    task TFire {
        loop {
CreateShot01(GetX, GetY, 2, angle, RED01, 10);
            wait(40);
        }
    }
}

This is supposed to create one enemy with four slave enemies rotating around it. I have a test state script with just the one enemy, and it does do this - but as soon as the master enemy is killed, the game crashes and force-quits. Is there some kind of garbage collection I should be doing in here?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: ChaoStar on March 11, 2010, 04:39:22 PM
More advanced stage enemy problem!

Code for an enemy in a stage script is as follows:

Code: [Select]
script_enemy_main
{//Slave-having enemy
let count=0;
let cx=GetCenterX();
let imgEnemy=GetCurrentScriptDirectory~"img\Enemy.png";
let imgAngle=0;
let shotAngle=0;
let id = GetArgument;

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

task TMove {
wait(400);
VanishEnemy;
}

@Initialize
{
SetLife(500);
SetGraphicRect(1,1,32,32);
SetMovePosition03(GetCenterX+(-(GetX-GetCenterX)+600), GetY + 800, 30, 1);

if(id) {
SetCommonData("Enemy01LeftX", GetX);
SetCommonData("Enemy01LeftY", GetY);
} else {
SetCommonData("Enemy01RightX", GetX);
SetCommonData("Enemy01RightY", GetY);
}

SetCommonData("Enemy01Side", GetArgument);
ascent(i in 0..4) {
CreateEnemyFromScript("Familiar", GetX, GetY, 0, 0, i*90);
}
TMove;
}

@MainLoop
{
    SetCollisionA(GetX, GetY, 16);
        SetCollisionB(GetX, GetY, 16);
if(id) {
SetCommonData("Enemy01LeftX", GetX);
SetCommonData("Enemy01LeftY", GetY);
} else {
SetCommonData("Enemy01RightX", GetX);
SetCommonData("Enemy01RightY", GetY);
}
yield;
}

@Finalize
{//読みこんだファイルを削除
CreateItem(ITEM_SCORE, GetX + rand(-10,10), GetY + rand(10,10));
}

@DrawLoop
{//描画
SetTexture(imgEnemy);
SetColor(255,255,255);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,imgAngle);
DrawGraphic(GetX(),GetY());
SetRenderState(ADD);
SetGraphicAngle(0,0,-imgAngle);
DrawGraphic(GetX(),GetY());
imgAngle+=4;
if(imgAngle>360){imgAngle=0;}
}
}

script_enemy Familiar {
let ImgFam = GetCurrentScriptDirectory ~ "img\Enemy.png";
let imgAngle=0;
let angle = GetArgument;
let id = false;

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


    @Initialize {
        SetLife(100);
        SetScore(0);
        SetDamageRateEx(100, 100, 50, 50);

        LoadGraphic(ImgFam);
        SetTexture(ImgFam);
SetGraphicRect(1,1,32,32);

id = GetCommonData("Enemy01Side");

        TRotate;
        TFire;
    }

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

@DrawLoop
{//描画
SetTexture(ImgFam);
SetColor(255,255,255);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,imgAngle);
DrawGraphic(GetX(),GetY());
SetRenderState(ADD);
SetGraphicAngle(0,0,-imgAngle);
DrawGraphic(GetX(),GetY());
imgAngle+=4;
if(imgAngle>360){imgAngle=0;}
}

  @Finalize
{//読みこんだファイルを削除
CreateShot01(GetX, GetY, 2, angle, RED01, 10);
CreateShot01(GetX, GetY, 2, angle+30, RED01, 10);
CreateShot01(GetX, GetY, 2, angle-30, RED01, 10);
CreateItem(ITEM_SCORE, GetX + rand(-10,10), GetY + rand(10,10));
}

// rotate around the boss
    task TRotate {
let eX = 0;
let eY = 0;
loop {
if(id) {
eX = GetCommonData("Enemy01LeftX");
eY = GetCommonData("Enemy01LeftY");
} else {
eX = GetCommonData("Enemy01RightX");
eY = GetCommonData("Enemy01RightY");
}
SetX(eX + cos(angle) * 50);
SetY(eY + sin(angle) * 50);
yield;
angle += 1.5;
}
}

    task TFire {
        loop {
CreateShot01(GetX, GetY, 2, angle, RED01, 10);
            wait(40);
        }
    }
}

This is supposed to create one enemy with four slave enemies rotating around it. I have a test state script with just the one enemy, and it does do this - but as soon as the master enemy is killed, the game crashes and force-quits. Is there some kind of garbage collection I should be doing in here?

Have it so that the slaves also die if the main enemy is killed, you're getting an error because if the master dies, the slaves go to an impossible location, which is nowhere.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: professor_scissors on March 11, 2010, 05:30:19 PM
Have it so that the slaves also die if the main enemy is killed, you're getting an error because if the master dies, the slaves go to an impossible location, which is nowhere.

Right, I figured it might be something like that. There a quick function for this, or do I need to have the master communicate its death to the slaves via Common Data?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: ChaoStar on March 11, 2010, 07:40:27 PM
Right, I figured it might be something like that. There a quick function for this, or do I need to have the master communicate its death to the slaves via Common Data?

http://dmf.shrinemaiden.org/wiki/index.php?title=Enemy_Script_Functions#VanishEnemy

in the mainloop of each slave, have an if statement that says like, if(MasterAlive == 0){VanishEnemy;}

MasterAlive needs to be a common data. and just set MasterAlive to 0, in the master's finalize.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on March 11, 2010, 11:19:23 PM
Is it that it's so incomprehensible no one can steal it or so unoptimized that it runs way too slowly on anything less than a high-end PC? Or both?

Not really. If you try a lot of my newer scritps (e.g. my really fucking annoying Mikaruge boss), I use CtC's sprite animation scripts. I wanted to try using the cut-in functions, too, but I don't get how the freaking thing works.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: professor_scissors on March 12, 2010, 12:48:21 AM
http://dmf.shrinemaiden.org/wiki/index.php?title=Enemy_Script_Functions#VanishEnemy

in the mainloop of each slave, have an if statement that says like, if(MasterAlive == 0){VanishEnemy;}

MasterAlive needs to be a common data. and just set MasterAlive to 0, in the master's finalize.
Got this implemented, but it still crashes upon master death about 20% of the time. Is there any way to do this that doesn't rely on the concurrency happening in the right order?

Code for the record:
Code: [Select]
script_enemy_main
{ //Slave-having enemy
let imgEnemy=GetCurrentScriptDirectory~"img\Enemy.png";
let imgAngle=0;
let shotAngle=0;
let id = GetArgument;

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

task TMove {
while(GetX < GetClipMaxX + 51 && GetX > GetClipMinX - 51) {
if(GetSpeed > 0.5) {
SetSpeed(GetSpeed - 0.05);
}
yield;
}
VanishEnemy;
}

@Initialize
{
SetLife(500);
SetGraphicRect(1,1,32,32);

if(id) {
SetCommonData("Enemy01LeftX", GetX);
SetCommonData("Enemy01LeftY", GetY);
SetCommonData("Enemy01LeftDead", false);
SetAngle(30);
SetSpeed(5);
} else {
SetCommonData("Enemy01RightX", GetX);
SetCommonData("Enemy01RightY", GetY);
SetCommonData("Enemy01RightDead", false);
SetAngle(150);
SetSpeed(5);
}

SetCommonData("Enemy01Side", GetArgument);
ascent(i in 0..4) {
CreateEnemyFromScript("Familiar", GetX, GetY, 0, 0, i*90);
}
TMove;
}

@MainLoop
{
    SetCollisionA(GetX, GetY, 16);
        SetCollisionB(GetX, GetY, 16);
if(id) {
SetCommonData("Enemy01LeftX", GetX);
SetCommonData("Enemy01LeftY", GetY);
} else {
SetCommonData("Enemy01RightX", GetX);
SetCommonData("Enemy01RightY", GetY);
}
yield;
}

@Finalize
{//読みこんだファイルを削除
if(id) {
SetCommonData("Enemy01LeftDead", true);
} else {
SetCommonData("Enemy01RightDead", true);
}
CreateItem(ITEM_SCORE, GetX + rand(-10,10), GetY + rand(10,10));
}

@DrawLoop
{//描画
SetTexture(imgEnemy);
SetColor(255,255,255);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,imgAngle);
DrawGraphic(GetX(),GetY());
SetRenderState(ADD);
SetGraphicAngle(0,0,-imgAngle);
DrawGraphic(GetX(),GetY());
imgAngle+=4;
if(imgAngle>360){imgAngle=0;}
}
}

script_enemy Familiar {
let ImgFam = GetCurrentScriptDirectory ~ "img\Enemy.png";
let imgAngle=0;
let angle = GetArgument;
let id = false;

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


    @Initialize {
        SetLife(100);
        SetScore(0);
        SetDamageRateEx(100, 100, 50, 50);

        LoadGraphic(ImgFam);
        SetTexture(ImgFam);
SetGraphicRect(1,1,32,32);

id = GetCommonData("Enemy01Side");

        TRotate;
        TFire;
    }

    @MainLoop {
    SetCollisionA(GetX, GetY, 8);
        SetCollisionB(GetX, GetY, 8);
if(id) {
if(GetCommonData("Enemy01LeftDead")) {
VanishEnemy;
}
} else {
if(GetCommonData("Enemy01RightDead")) {
VanishEnemy;
}
}
       yield;
    }

@DrawLoop
{//描画
SetTexture(ImgFam);
SetColor(255,255,255);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,imgAngle);
DrawGraphic(GetX(),GetY());
SetRenderState(ADD);
SetGraphicAngle(0,0,-imgAngle);
DrawGraphic(GetX(),GetY());
imgAngle+=4;
if(imgAngle>360){imgAngle=0;}
}

  @Finalize
{//読みこんだファイルを削除
CreateItem(ITEM_SCORE, GetX + rand(-10,10), GetY + rand(10,10));
}

// rotate around the boss
    task TRotate {
let eX = 0;
let eY = 0;
loop {
if(id) {
eX = GetCommonData("Enemy01LeftX");
eY = GetCommonData("Enemy01LeftY");
} else {
eX = GetCommonData("Enemy01RightX");
eY = GetCommonData("Enemy01RightY");
}
SetX(eX + cos(angle) * 50);
SetY(eY + sin(angle) * 50);
yield;
angle += 1.5;
}
}

    task TFire {
        loop {
CreateShot01(GetX, GetY, 1.5, angle+180, RED01, 10);
CreateShot01(GetX, GetY, 2, angle+180, ORANGE01, 10);
            wait(36);
        }
    }
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on March 12, 2010, 12:59:01 AM
Use GetCommonDataDefault("name",defaultvalue); instead. It returns the value of the data like normal, but if it doesn't exist, then it returns the default value. Set the default value to be out of the playing field and it should work.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: professor_scissors on March 12, 2010, 06:33:14 AM
Use GetCommonDataDefault("name",defaultvalue); instead. It returns the value of the data like normal, but if it doesn't exist, then it returns the default value. Set the default value to be out of the playing field and it should work.
And this seems to have solved it. Much thanks!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 12, 2010, 06:44:26 AM
Note: I personally find it much, much easier to SCD game-wide common data on loading and just use GCD instead of GCDD because the extra parameter gets very confusing when reading and editing.

In this case GCDD would be used because it's only used in like one instance, but just saying.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 12, 2010, 10:32:51 AM
Are enemy/boss scripts considered INSIDE a stage or outside?

what I mean is... if you set a task/function or if you load a graphic or declare a variable in the stage script... can you call it from the enemy/boss script? or do you have to declare it in both?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 12, 2010, 10:39:15 AM
Even if the enemy script is in the same file as the stage script and called through CreateEnemyFromScript, variables declared in one script will not carry over to the other. You have to use Common Data for that one.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 12, 2010, 10:55:29 AM
Are enemy/boss scripts considered INSIDE a stage or outside?

what I mean is... if you set a task/function or if you load a graphic or declare a variable in the stage script... can you call it from the enemy/boss script? or do you have to declare it in both?

When a graphic is loaded, it's loaded into memory so that anything can use it. When a graphic is deleted, likewise, nothing can use it anymore. This means you can load all the graphics and sound a stage is going to use in the stage itself. However if you use variables to hold the filepaths of the graphics and sound, those variables won't automatically carry over to other scripts.

For functions and variables that multiple things need to use, you should make them in a separate file and use #include_function in every script that needs them since they don't automatically carry over when you make them in a stage.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 12, 2010, 11:16:14 AM
For functions and variables that multiple things need to use, you should make them in a separate file and use #include_function in every script that needs them since they don't automatically carry over when you make them in a stage.
One thing I want to note, because I encountered this annoying problem:

You cannot call the same #include_function twice in the same file, even if the file contains seperate scripts.

For example: I have a file with a spell card script that calls familiars. The script for these familiars are contained inside the file so that I can call them with CreateEnemyFromScript and so that I don't have more txt files lying around. Both the boss and the familiar script shall have a set of functions that I stored in a seperate file.
Calling #include_function on this seperate file in both scripts will make danmakufu ignore the second instance. To get around this problem, you can either have all the child scripts be contained in seperate files so you can call CreateEnemyFromFile instead, or you can duplicate the txt file that stores the functions and call #include_function once on the original and once on the copy.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: professor_scissors on March 12, 2010, 09:38:04 PM
Same problem as above has returned! Same code, and the enemy still causes a fatal game crash upon death on rare occasions. The trigger seems to be the enemy dying while at least one of its slaves is off the left edge of the screen. Any idea what could cause that?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 13, 2010, 12:09:59 AM
Hmmm, do you summon more than one of these enemies at once? If so, both enemies would use the same common data, which would cause problems...


If you get an actual error message, it would help to see it. You can use Ctrl+C to copy it and then post it here. It may also help to see the updated code as well.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 13, 2010, 01:20:15 AM
As for the common data problem, you set the common data in the parent enemy as an array, before the others spawn. Instead of using new common data, you concatenate stuff onto the previous array.

Or something similar.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: professor_scissors on March 13, 2010, 07:11:39 PM
Okay, I think I have some kind of fundamental misunderstanding about how Common Data works. My understanding is that they act as 'global' variables - set a Common Data by a string in one place, and then anyone else who accesses it will get the data, regardless of where or how many places it's accessed. Is this wrong? And if not, how would having multiple slaves make this a problem?


Here's the current code:
Code: [Select]
script_enemy_main
{ //Slave-having enemy
let imgEnemy=GetCurrentScriptDirectory~"img\Enemy.png";
let imgAngle=0;
let shotAngle=0;
let id = GetArgument;

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

task TMove {
while(GetX < GetClipMaxX + 51 && GetX > GetClipMinX - 51) {
if(GetSpeed > 0.5) {
SetSpeed(GetSpeed - 0.05);
}
yield;
}
VanishEnemy;
}

@Initialize
{
SetLife(500);
SetGraphicRect(1,1,32,32);

if(id) {
SetCommonData("Enemy01LeftX", GetX);
SetCommonData("Enemy01LeftY", GetY);
SetCommonData("Enemy01LeftDead", false);
SetAngle(30);
SetSpeed(5);
} else {
SetCommonData("Enemy01RightX", GetX);
SetCommonData("Enemy01RightY", GetY);
SetCommonData("Enemy01RightDead", false);
SetAngle(150);
SetSpeed(5);
}

SetCommonData("Enemy01Side", GetArgument);
ascent(i in 0..4) {
CreateEnemyFromScript("Familiar", GetX, GetY, 0, 0, i*90);
}
TMove;
}

@MainLoop
{
    SetCollisionA(GetX, GetY, 16);
        SetCollisionB(GetX, GetY, 16);
if(id) {
SetCommonData("Enemy01LeftX", GetX);
SetCommonData("Enemy01LeftY", GetY);
} else {
SetCommonData("Enemy01RightX", GetX);
SetCommonData("Enemy01RightY", GetY);
}
yield;
}

@Finalize
{//読みこんだファイルを削除
if(id) {
SetCommonData("Enemy01LeftDead", true);
} else {
SetCommonData("Enemy01RightDead", true);
}
CreateItem(ITEM_SCORE, GetX + rand(-10,10), GetY + rand(10,10));
}

@DrawLoop
{//描画
SetTexture(imgEnemy);
SetColor(255,255,255);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,imgAngle);
DrawGraphic(GetX(),GetY());
SetRenderState(ADD);
SetGraphicAngle(0,0,-imgAngle);
DrawGraphic(GetX(),GetY());
imgAngle+=4;
if(imgAngle>360){imgAngle=0;}
}
}

script_enemy Familiar {
let ImgFam = GetCurrentScriptDirectory ~ "img\Enemy.png";
let imgAngle=0;
let angle = GetArgument;
let id = false;

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


    @Initialize {
        SetLife(100);
        SetScore(0);
        SetDamageRateEx(100, 100, 50, 50);

        LoadGraphic(ImgFam);
        SetTexture(ImgFam);
SetGraphicRect(1,1,32,32);

id = GetCommonData("Enemy01Side");

        TRotate;
        TFire;
    }

    @MainLoop {
    SetCollisionA(GetX, GetY, 8);
        SetCollisionB(GetX, GetY, 8);
if(id) {
if(GetCommonDataDefault("Enemy01LeftDead", true)) {
VanishEnemy;
}
} else {
if(GetCommonDataDefault("Enemy01RightDead", true)) {
VanishEnemy;
}
}
       yield;
    }

@DrawLoop
{//描画
SetTexture(ImgFam);
SetColor(255,255,255);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,imgAngle);
DrawGraphic(GetX(),GetY());
SetRenderState(ADD);
SetGraphicAngle(0,0,-imgAngle);
DrawGraphic(GetX(),GetY());
imgAngle+=4;
if(imgAngle>360){imgAngle=0;}
}

  @Finalize
{//読みこんだファイルを削除
CreateItem(ITEM_SCORE, GetX + rand(-10,10), GetY + rand(10,10));
}

// rotate around the boss
    task TRotate {
let eX = 0;
let eY = 0;
loop {
if(id) {
eX = GetCommonDataDefault("Enemy01LeftX", -50);
eY = GetCommonDataDefault("Enemy01LeftY", -50);
} else {
eX = GetCommonDataDefault("Enemy01RightX", -50);
eY = GetCommonDataDefault("Enemy01RightY", -50);
}
SetX(eX + cos(angle) * 50);
SetY(eY + sin(angle) * 50);
yield;
angle += 1.5;
}
}

    task TFire {
        loop {
CreateShot01(GetX, GetY, 1.5, angle+180, RED01, 10);
CreateShot01(GetX, GetY, 2, angle+180, ORANGE01, 10);
            wait(36);
        }
    }
}

And it's not any error message - Danmakufu just crashes and quits with a generic "this program has stopped functioning" windows message.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 13, 2010, 08:06:05 PM
Afaik, that is how it works. The problem with having multiples of the slave spawning enemy out at once is the following:

If I read your script correctly, then you have Common Data that keeps track of whether or not each of the slave (and the main enemy) is alive. If you have more than one of the slave spawning enemies on the field at once, both enemies (and their slaves) will use the same common data. Thus the death of the first enemy (or one of its slaves) will affect the behaviour of the second enemy and its slaves, and vice versa.


Hm, on why your script keeps crashing... what happens if you don't shoot the enemy but instead let it just ponder out of the playing field? Since you vanish it when it leaves the field, it could be that the familiars need to haveif(BeParentVanished==true){VanishEnemy;} or something similar inside their main loops.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: professor_scissors on March 14, 2010, 04:15:53 AM
Afaik, that is how it works. The problem with having multiples of the slave spawning enemy out at once is the following:

If I read your script correctly, then you have Common Data that keeps track of whether or not each of the slave (and the main enemy) is alive. If you have more than one of the slave spawning enemies on the field at once, both enemies (and their slaves) will use the same common data. Thus the death of the first enemy (or one of its slaves) will affect the behaviour of the second enemy and its slaves, and vice versa.
I see where you're coming from, but I only ever have two of that enemy on the field at once - one on the left, and one on the right. Thus, the argument makes sure they're segregated to separate sets of Common Data.

Quote
Hm, on why your script keeps crashing... what happens if you don't shoot the enemy but instead let it just ponder out of the playing field? Since you vanish it when it leaves the field, it could be that the familiars need to haveif(BeParentVanished==true){VanishEnemy;} or something similar inside their main loops.
If they drift off the side of the screen and autovanish, the game doesn't complain. The only thing that seems to trigger the destruction is if the player kills the master enemy while it's off the edge of the field, in the buffer zone between leaving the field and vanishing.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 14, 2010, 10:53:33 AM
On another note, remove the SetScore(0); from the familiars. If you leave it out your enemy won't have a score, and leaving it in may in fact cause other casualties if danmakufu is as stupid as I think it is. And it ususally is.


Hmm, I have an idea. Change the SetDamageRateEx in your script to regular SetDamageRate commands. It could be that danmakufu goes nuts if you damage the familiar while the parent enemy is already vanished.
And besides, afaik SetDamageRateEx didn't really work the way it should, anyways. At least it didn't for me when the parent enemy was a boss enemy. I had to transfer the damage from the familiars to the boss by storing it in CommonData.

In the slim chance that SetDamageRateEx actually is what causes the crashing, this method would also circumvent this peculiar problem since the damage is first transferred from the slaves to a CommonData that continues to exist when the enemy is dead. The damaging of the master enemy is part of its own script, so it won't be called anymore once it is vanished and couldn't cause trouble anymore.

Here are some code example from my own scripts.

In the script of the master enemy:
Code: [Select]
//at the beginning of the script

    SetCommonData("Damage", 0);

//in the @MainLoop
AddLife(GetCommonData("Damage"));
SetCommonData("Damage", 0);
In the script of the slaves:
Code: [Select]
//at the beginning of the script

    let hp=50;
    let hpcheck=false;

 //in the @Initialize
hpcheck=true;
hp=GetLife;

//in the @MainLoop
if(hpcheck==true){
if(OnBomb==false){ SetCommonData("Damage", GetCommonData("Damage")+GetLife-hp); }
hp=GetLife;
}

Of course, in your case you would need one separate CommonData for each of the enemies that are on screen at once, in this case one "DamageLeft" and "DamageRight", for example.
If you want to reduce the damage the slaves do to the parent enemy, you can simply include a factor of 0.5 or something to either the damage transferring or the damage receiving part of the script.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 15, 2010, 02:51:34 PM
How do you get a certain number of random integer variables and make sure that they're not equal?

let's say we have this

Code: [Select]
let a=rand_int(1, 6);
let b=rand_int(1, 6);
let c=rand_int(1, 6);
let d=rand_int(1, 6);

how can you make sure that a!=b!=c!=d?

All I can think of is

Code: [Select]
let a=rand_int(1, 6);
let b;
ascent(i in 1..7)
{
let num=rand_int(1, 6);
if(num!=i)
{
b=num;
}
}
...

or something like that... but it doesn't always guarantee a proper outcome... :ohdear:

EDIT: or is this something that can make use of the Break function? I'm not sure how it's used

Code: [Select]

let a;
let b;
a=rand_int(1, 6);
loop
{
b=rand_int(1, 6);
if(a!=b)
{
break;
}
}
???

EDIT2: nevermind! I got it working!!! It actually IS the break function :D
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 15, 2010, 03:06:31 PM
How do you get a certain number of random integer variables and make sure that they're not equal?

let's say we have this

Code: [Select]
let a=rand_int(1, 6);
let b=rand_int(1, 6);
let c=rand_int(1, 6);
let d=rand_int(1, 6);

how can you make sure that a!=b!=c!=d?

All I can think of is

Code: [Select]
let a=rand_int(1, 6);
let b;
ascent(i in 1..7)
{
let num=rand_int(1, 6);
if(num!=i)
{
b=num;
}
}
...

or something like that... but it doesn't always guarantee a proper outcome... :ohdear:

EDIT: or is this something that can make use of the Break function? I'm not sure how it's used

Code: [Select]

let a;
let b;
a=rand_int(1, 6);
loop
{
b=rand_int(1, 6);
if(a!=b)
{
break;
}
}
???

The quickest way to do it is like this:
Code: [Select]
let a = rand_int(1, 5);
let b = rand_int(1, 5);
let c = rand_int(1, 5);
let d = rand_int(1, 5);
while(a == b){b = rand_int(1, 5);}
while(a == c || b == c){c = rand_int(1, 5);}
while(a == d || b == d || c == d){d = rand_int(1, 5);}

However, if you end up needing to make sure a large amount of variables are unique, you'll need a different method or else you'll have to write a bunch of extra redundant code. The "better" way to handle this would be like this:
Code: [Select]
let randomArray;
ascent(i in 1..6){
    randomArray ~ [i];
}
// randomArray now contains the numbers from 1 to 5. Obviously you can
// change the numbers in the ascent to suit your purposes.

let a = unique_rand_int;
let b = unique_rand_int;
let c = unique_rand_int;
let d = unique_rand_int;

// This function removes a value from the randomArray before returning it so
// it will guarantee uniqueness. However, beware of when the array becomes
// empty because you will get an error when using the function.
function unique_rand_int {
    let indx = rand_int(0, length(randomArray)-1);
    let value = randomArray[indx];
    erase(randomArray, indx);
    return value;
}
This is a lot of extra code for what you were going for, but if you needed to pick an integer between 1 and 100 for 50 variables or something like that, this would be shorter.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 15, 2010, 03:09:29 PM
The quickest way to do it is like this:
Code: [Select]
let a = rand_int(1, 5);
let b = rand_int(1, 5);
let c = rand_int(1, 5);
let d = rand_int(1, 5);
while(a == b){b = rand_int(1, 5);}
while(a == c || b == c){c = rand_int(1, 5);}
while(a == d || b == d || c == d){d = rand_int(1, 5);}

However, if you end up needing to make sure a large amount of variables are unique, you'll need a different method or else you'll have to write a bunch of extra redundant code. The "better" way to handle this would be like this:
Code: [Select]
let randomArray;
ascent(i in 1..6){
    randomArray ~ [i];
}
// randomArray now contains the numbers from 1 to 5. Obviously you can
// change the numbers in the ascent to suit your purposes.

let a = unique_rand_int;
let b = unique_rand_int;
let c = unique_rand_int;
let d = unique_rand_int;

// This function removes a value from the randomArray before returning it so
// it will guarantee uniqueness. However, beware of when the array becomes
// empty because you will get an error when using the function.
function unique_rand_int {
    let indx = rand_int(0, length(randomArray)-1);
    let value = randomArray[indx];
    erase(randomArray, indx);
    return value;
}
This is a lot of extra code for what you were going for, but if you needed to pick an integer between 1 and 100 for 50 variables or something like that, this would be shorter.

oh... why didn't I think of using while... it's just for a small number of variables anyway... at least I solved it using a different way myself :D Thanks!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 15, 2010, 03:46:28 PM
Posting code for bullets that properly reflect along the border for doods on IRC. Delete any undesirable chunk of reflect code.

task RShot(orix, oriy, velocity, angletaken, graphic, bounces){
   let getxa;
   let getya;
   let anglereflex;
   let reflectcount = 0;
   let objshot = Obj_Create(OBJ_SHOT); //Set all information.
   Obj_SetPosition(objshot, orix, oriy);
   ObjShot_SetGraphic(objshot, graphic);
   Obj_SetSpeed(objshot, velocity);
   Obj_SetAngle(objshot, angletaken);
   while(!Obj_BeDeleted(objshot)){ //While the object shot exists, do all this.
      getxa = Obj_GetX(objshot); //Store the object shot's coordinates in variables for easy reference.
      getya = Obj_GetY(objshot);
      if(getxa < GetClipMinX && reflectcount < bounces){ //Reflect on the left border.
         anglereflex = -angletaken+180; //Reflection formula for x axis.
         let position = GetClipMinX - Obj_GetX(objshot); //Adjust for any lost distance beyond the border.
         Obj_SetX(objshot, GetClipMinX + position);
         Obj_SetAngle(objshot, anglereflex);
         angletaken = anglereflex;
         reflectcount++;
      }
      if(getxa > GetClipMaxX && reflectcount < bounces){ //Reflect on the right border.
         anglereflex = -angletaken+180; //Reflection formula for x axis.
         let position = GetClipMaxX - Obj_GetX(objshot); //Adjust for any lost distance beyond the border.
         Obj_SetX(objshot, GetClipMaxX + position);
         Obj_SetAngle(objshot, anglereflex);
         angletaken = anglereflex;
         reflectcount++;
      }
      if(getya < GetClipMinY && reflectcount < bounces){ //Reflect on the top border.
         anglereflex = -angletaken; //Reflection formula for y axis.
         let position = GetClipMinY - Obj_GetY(objshot); //Adjust for any lost distance beyond the border.
         Obj_SetY(objshot, GetClipMinY + position);
         Obj_SetAngle(objshot, anglereflex);
         angletaken = anglereflex;
         reflectcount++;
      }
      if(getya > GetClipMaxY && reflectcount < bounces){ //Reflect on the bottom border.
         anglereflex = -angletaken; //Reflection formula for y axis.
         let position = GetClipMaxY - Obj_GetY(objshot); //Adjust for any lost distance beyond the border.
         Obj_SetY(objshot, GetClipMaxY + position);
         Obj_SetAngle(objshot, anglereflex);
         angletaken = anglereflex;
         reflectcount++;
      }
      yield;
   }
}


The variable bounces is highlighted, this is to show that you may change how many times you want a bullet to bounce.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on March 18, 2010, 04:37:22 AM
Gah, how do you make a loading screen, with a background, a "this much has loaded" bar, etc.?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 18, 2010, 04:46:49 AM
Stage script, effect objects/drawn images in @BackGround. Effect objects will allow you to draw over the STG_Frame though, so I recommend those. For the loading bar, you'll just want to Load all your shit in different frames, like this:

yield;
LoadGraphic(bigspritesheet.png);
yield;
LoadMusic(awesomemusic.mp3);
yield;
CompileEnemyFromFile(boss.txt);
yield;
StartStage;

During all those yield statements, have a graphic that slowly gets larger to "show" the user how much has loaded. This is really the only way to accomplish this effect.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on March 18, 2010, 08:33:11 AM
I'm pretty sure Naut is right about that being the only way, since even if you load stuff as a task the code can't get around to the drawloop without a yield.

It seems like a dumb thing to do since all those yields will just increase loading time.

As a side note, I have no idea why CtC takes so long to load, it doesn't seem like it uses that much media.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on March 18, 2010, 12:17:28 PM
Normally a loading bar is a useful thing, but seeing that in Danmakufu's case it is only annoyance I don't see why people are trying to implement it. Rather have a loading animation like in UB (bubbling sake gourd) or some kind of spinning stuff just to make the loading screen more enjoyable.

Otherwise the classic black screen + Loading... suffices more than enough.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Gc on March 18, 2010, 02:29:29 PM
Gah, how do you make a loading screen, with a background, a "this much has loaded" bar, etc.?
Here's how I made mine:
Code: [Select]
task LoadScreen {
Wait(1);

LoadGraphic(CSD ~ "img\LOADING.BG.png");
LoadGraphic(CSD ~ "img\LOADING.BAR.png");

let content = length(img) + length(sfx) + length(bgm);
let progress = 0;

LoadScreenBackground(content);

ascent(i in 0..length(img)) {
LoadGraphic(img[i]);
LoadScreenLoader(430, 395, 610, 410, progress + 1, content);
LoadScreenLoader(430, 435, 610, 450, i + 1, length(img));
progress ++;
Wait(1);
}

ascent(i in 0..length(sfx)) {
LoadSE(sfx[i]);
LoadScreenLoader(430, 395, 610, 410, progress + 1, content);
LoadScreenLoader(430, 435, 610, 450, i + 1, length(sfx));
progress ++;
Wait(1);
}

ascent(i in 0..length(bgm)) {
LoadMusic(bgm[i]);
LoadScreenLoader(430, 395, 610, 410, progress + 1, content);
LoadScreenLoader(430, 435, 610, 450, i + 1, length(bgm));
progress ++;
Wait(1);
}

DeleteGraphic(CSD ~ "img\LOADING.BG.png");
DeleteGraphic(CSD ~ "img\LOADING.BAR.png");

MenuScreen(1);

task LoadScreenBackground(let length) {
let obj = Obj_Create(OBJ_EFFECT);
Obj_SetPosition(obj, 0, 0);

ObjEffect_SetTexture(obj, CSD ~ "img\LOADING.BG.png");
ObjEffect_SetRenderState(obj, ALPHA);
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
ObjEffect_SetLayer(obj, 8);
ObjEffect_CreateVertex(obj, 4);

ObjEffect_SetVertexUV(obj, 0, 0, 0);
ObjEffect_SetVertexUV(obj, 1, 640, 0);
ObjEffect_SetVertexUV(obj, 2, 640, 480);
ObjEffect_SetVertexUV(obj, 3, 0, 480);

loop(length) {
ObjEffect_SetVertexXY(obj, 0, 0, 0);
ObjEffect_SetVertexXY(obj, 1, 640, 0);
ObjEffect_SetVertexXY(obj, 2, 640, 480);
ObjEffect_SetVertexXY(obj, 3, 0, 480);
Wait(1);
}

Obj_Delete(obj);
}

task LoadScreenLoader(let x1, let y1, let x2, let y2, let progress, let total) {
let totalWidth = x2 - x1;
let currentWidth = (progress / total) * totalWidth;

let obj = Obj_Create(OBJ_EFFECT);
Obj_SetPosition(obj, 0, 0);

ObjEffect_SetTexture(obj, CSD ~ "img\LOADING.BAR.png");
ObjEffect_SetRenderState(obj, ALPHA);
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
ObjEffect_SetLayer(obj, 8);
ObjEffect_CreateVertex(obj, 4);

ObjEffect_SetVertexUV(obj, 0, 0, 0);
ObjEffect_SetVertexUV(obj, 1, 16, 0);
ObjEffect_SetVertexUV(obj, 2, 16, 16);
ObjEffect_SetVertexUV(obj, 3, 0, 16);

ObjEffect_SetVertexXY(obj, 0, x1, y1);
ObjEffect_SetVertexXY(obj, 1, x1 + currentWidth, y1);
ObjEffect_SetVertexXY(obj, 2, x1 + currentWidth, y2);
ObjEffect_SetVertexXY(obj, 3, x1, y2);

Wait(1);

Obj_Delete(obj);
}
}

The problem with that is that img, sfx and bgm (all arrays) can't be empty otherwise you get a division by 0.

It DOES make the loading longer, but I'd much rather have a longer load time than a crash because I try to load everything in one frame.

Also, inefficient code blah blah blah weird indenting blah blah blah

Here are all 3 arrays I used as an example :
Code: [Select]
let img = [
CSD ~ "img\MENU.BG.png",
CSD ~ "img\MENU.CHOICE.1.png",
CSD ~ "img\MENU.CHOICE.2.png",
CSD ~ "img\STAGE.CHANGE.BG.png",
CSD ~ "img\STAGE.CHANGE.BONUS.png",
CSD ~ "img\STAGE.CHANGE.PRESS.png"
];

let sfx = [
CSD ~ "sfx\MENU.MOVE.wav",
CSD ~ "sfx\MENU.SELECT.wav",
CSD ~ "sfx\STAGE.CHANGE.wav",
CSD ~ "sfx\BOSS.SNIPER.KILL.0.wav",
CSD ~ "sfx\BOSS.SNIPER.KILL.1.wav",
CSD ~ "sfx\BOSS.SNIPER.KILL.2.wav",
CSD ~ "sfx\BOSS.SNIPER.DEATH.wav",
CSD ~ "sfx\BOSS.SPY.KILL.0.wav",
CSD ~ "sfx\BOSS.SPY.KILL.1.wav",
CSD ~ "sfx\BOSS.SPY.KILL.2.wav",
CSD ~ "sfx\BOSS.SPY.DEATH.wav",
CSD ~ "sfx\BOSS.SCOUT.KILL.0.wav",
CSD ~ "sfx\BOSS.SCOUT.KILL.1.wav",
CSD ~ "sfx\BOSS.SCOUT.KILL.2.wav",
CSD ~ "sfx\BOSS.SCOUT.DEATH.wav",
CSD ~ "sfx\BOSS.MEDIC.DEATH.wav",
CSD ~ "sfx\BOSS.ENGINEER.DEATH.wav",
CSD ~ "sfx\BOSS.DEMOMAN.KILL.0.wav",
CSD ~ "sfx\BOSS.DEMOMAN.KILL.1.wav",
CSD ~ "sfx\BOSS.DEMOMAN.KILL.2.wav",
CSD ~ "sfx\BOSS.DEMOMAN.DEATH.wav",
CSD ~ "sfx\BOSS.PYRO.DEATH.wav",
CSD ~ "sfx\BOSS.DEMOMAN.KILL.0.wav",
CSD ~ "sfx\BOSS.DEMOMAN.KILL.1.wav",
CSD ~ "sfx\BOSS.DEMOMAN.KILL.2.wav",
CSD ~ "sfx\BOSS.DEMOMAN.DEATH.wav",
CSD ~ "sfx\BOSS.HEAVY.KILL.0.wav",
CSD ~ "sfx\BOSS.HEAVY.KILL.1.wav",
CSD ~ "sfx\BOSS.HEAVY.KILL.2.wav",
CSD ~ "sfx\BOSS.HEAVY.DEATH.wav",
];

let bgm = [
CSD ~ "bgm\MENU.BGM.mp3"
];
(I can't say I'm done making images or finding sfx and bgm...)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: professor_scissors on March 18, 2010, 08:42:31 PM
Replacing SetDamageRateEx with SetDamageRate did not solve the problem. Also, problem was observed when killing an enemy that was fully on screen.

At this point, if it wasn't for the fact that CtC works without this error, I'd chalk it up to unreconciliable flaws in Danmakufu's internal logic. Maybe if I make them all independent enemies instead of slaves, and associate them purely by common data?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 18, 2010, 09:51:46 PM
@ professor_scissors

Ha!

After tinkering around with your script I think I figured out where the problem lies.

Apparently, danmakufu goes insane when you call CreateEnemyFromScript in the @Initialize part of the parent enemy. I "outsourced" the slave creation from the @Initialize to a task that simply read
Code: [Select]
task TSpawn{
yield;
ascent(i in 0..4) {
SetCommonData("Enemy01Side", id);
CreateEnemyFromScript("Familiar", GetX, GetY, 0, 0, i*90);
}
}
And now the error doesn't seem to appear anymore.

What got my attention was a strange occurance when I played around with the enemies' health. After making the main enemy tough and the slaves weak, I noticed that one of the slaves was much tougher than the others. So I tried this, and it seemed to work.

To be precise, the full code that is working for me right now is this:
Code: [Select]
script_enemy_main
{ //Slave-having enemy
   let imgEnemy=GetCurrentScriptDirectory~"img\Enemy.png";
   let imgAngle=0;
   let shotAngle=0;
   let id = GetArgument;
   
   function wait(n) {
      loop(n) { yield; }
   }

   task TMove {
      while(GetX < GetClipMaxX + 51 && GetX > GetClipMinX - 51) {
         if(GetSpeed > 0.5) {
            SetSpeed(GetSpeed - 0.05);
         }
         yield;
      }
      VanishEnemy;
   }

task TSpawn{
yield;

ascent(i in 0..4) {
SetCommonData("Enemy01Side", id);
CreateEnemyFromScript("Familiar", GetX, GetY, 0, 0, i);
}
}


   @Initialize
   {
      SetLife(10);
SetDamageRate(100, 100);

LoadGraphic(imgEnemy);
     
      if(id) {
         SetCommonData("Enemy01LeftX", GetX);
         SetCommonData("Enemy01LeftY", GetY);
         SetCommonData("Enemy01LeftDead", false);
         SetAngle(30);
         SetSpeed(5);
      } else {
         SetCommonData("Enemy01RightX", GetX);
         SetCommonData("Enemy01RightY", GetY);
         SetCommonData("Enemy01RightDead", false);
         SetAngle(150);
         SetSpeed(5);
      }
      TSpawn;
      TMove;
   }
   
   @MainLoop
   {
       SetCollisionA(GetX, GetY, 16);
        SetCollisionB(GetX, GetY, 16);
      if(id) {
         SetCommonData("Enemy01LeftX", GetX);
         SetCommonData("Enemy01LeftY", GetY);
      } else {
         SetCommonData("Enemy01RightX", GetX);
         SetCommonData("Enemy01RightY", GetY);
      }
      yield;
   }
   
   @Finalize
   {
//      if(id) {
//         SetCommonData("Enemy01LeftDead", true);
//      } else {
//         SetCommonData("Enemy01RightDead", true);
//      }
      CreateItem(ITEM_SCORE, GetX + rand(-10,10), GetY + rand(10,10));
   }
   
   @DrawLoop
   {//
      SetTexture(imgEnemy);
      SetGraphicRect(1,1,32,32);
      SetColor(255,255,255);
      SetRenderState(ALPHA);
      SetGraphicAngle(0,0,imgAngle);
      DrawGraphic(GetX(),GetY());

      SetTexture(imgEnemy);
      SetGraphicRect(1,1,32,32);
      SetColor(255,255,255);
      SetRenderState(ADD);
      SetGraphicAngle(0,0,-imgAngle);
      DrawGraphic(GetX(),GetY());
      imgAngle+=4;
      if(imgAngle>360){imgAngle-=360;}
   }
}

script_enemy Familiar {
   let ImgFam = GetCurrentScriptDirectory ~ "img\Enemy.png";
   let imgAngle=0;
   let angle = (GetArgument)*90;
   let id = GetCommonData("Enemy01Side");
   
   function wait(w) {
      loop(w) { yield; }
   }


    @Initialize {
        SetLife(10);
        SetDamageRate(100, 100);

        TRotate;
        TFire;
    }

    @MainLoop {
       SetCollisionA(GetX, GetY, 8);
        SetCollisionB(GetX, GetY, 8);
      if(id) {
         if(GetCommonDataDefault("Enemy01LeftDead", true)||BeParentVanished==true) {
            VanishEnemy;
         }
      } else {
         if(GetCommonDataDefault("Enemy01RightDead", true)||BeParentVanished==true) {
            VanishEnemy;
         }
      }
       yield;
    }

   @DrawLoop
   {//
      SetTexture(ImgFam);
      SetGraphicRect(1,1,32,32);
      SetColor(255,255,255);
      SetRenderState(ALPHA);
      SetGraphicAngle(0,0,imgAngle);
      DrawGraphic(GetX(),GetY());

      SetTexture(ImgFam);
      SetGraphicRect(1,1,32,32);
      SetColor(255,255,255);
      SetRenderState(ADD);
      SetGraphicAngle(0,0,-imgAngle);
      DrawGraphic(GetX(),GetY());
      imgAngle+=4;
      if(imgAngle>360){imgAngle=0;}
   }

    @Finalize
   {//
      CreateItem(ITEM_SCORE, GetX + rand(-10,10), GetY + rand(10,10));
   }

   // rotate around the boss
    task TRotate {
      let eX = 0;
      let eY = 0;
      loop {
         if(id) {
            eX = GetCommonDataDefault("Enemy01LeftX", -50);
            eY = GetCommonDataDefault("Enemy01LeftY", -50);
         } else {
            eX = GetCommonDataDefault("Enemy01RightX", -50);
            eY = GetCommonDataDefault("Enemy01RightY", -50);
         }
         SetX(eX + cos(angle) * 50);
         SetY(eY + sin(angle) * 50);
         yield;
         angle += 1.5;
      }
   }

    task TFire {
        loop {
         CreateShot01(GetX, GetY, 1.5, angle+180, RED01, 10);
         CreateShot01(GetX, GetY, 2, angle+180, ORANGE01, 10);
            wait(36);
        }
    }
}

It contains a number of other small differences, some of which may have had a positive effect on the performance of the script, so when you still get errors, copypaste the entire script. I didn't implement the damaging of the main enemy through the slaves yet, though.

Among other things, you had SetGraphicRect and other drawing related functions inside the @Initialize parts of the scripts. Generally, you call these in the @DrawLoop once for each individual call of DrawGraphic. Also, you still had SetScore(0); in your slave scripts, which as I said doesn't do anything except maybe cause additinal problems.

Also, you should load the data for the enemies (graphics and sounds) at the beginning of the stage you want to use them in. Otherwise you'll load the stuff into memory mutliple times and cause slight slow down when the enemies appear.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 18, 2010, 10:00:47 PM
Picture.
(http://d.imagehost.org/dl/a1c24ec8a466e6ca8cc42a9e50f5deda/0135/camerashot.bmp)
I'd like to refer you to the GetPointToLine(ox, oy, p1x, p1y, p2x, p2y); (http://www.shrinemaiden.org/forum/index.php?topic=5164) function.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 18, 2010, 10:52:21 PM
In general, it is not a good idea to throw in any function that doesn't "have" to go into @Initialize, in it. (Read: SetLife, SetTimer, SetScore, etc)
Just wait a frame or two and use a task.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on March 18, 2010, 11:27:18 PM
I'd like to refer you to the GetPointToLine(ox, oy, p1x, p1y, p2x, p2y); (http://www.shrinemaiden.org/forum/index.php?topic=5164) function.
W-w-what?
..... I'm wrapping my brain around how to use this function in this, so help me, Eirin.

EDIT: Ah, fuck. I can't get it. I'll use Collision_Line_Circle instead...
EDIT!!: It* works!

* Collision_Line_Circle
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 19, 2010, 12:15:00 PM
My idea would've been...

Code: [Select]
function Killzone(x, y, ang, length, width){

//the distance from the center in the direction of the length
let d1= (| GetPointToLine(GetPlayerX, GetPlayerY, x, y, x+cos(ang+90), y+sin(ang+90)) |);

//the distance from the center in the direction of the width
let d2= (| GetPointToLine(GetPlayerX, GetPlayerY, x, y, x+cos(ang), y+sin(ang)) |);

//if the player is in the boundaries, he is killed
if(d1<0.5*length && d2<0.5*width){ ShootDownPlayer; }

}
...where (x|y) is the center of the zone and the zone has the dimensions of length*width and is aligned according to the angle.

But if your code works... nevermind...


Edit: Blargh, put GetX instead of GetPlayerX in the code. Should work now.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on March 19, 2010, 06:55:42 PM
You should first make sure the player's not invincible before you kill them.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: professor_scissors on March 19, 2010, 10:48:46 PM
wall o' text
Aha! This worked, finally. Thank you very much!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: TwiliAezure on March 20, 2010, 12:42:51 AM
I just wanna ask, is it possible to Fire one kind of shot from one option and fire a different type on the other?
Like this... (Fire on left, Knives on right)
(http://img716.imageshack.us/img716/8085/isthisevenpossible.png)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Gc on March 20, 2010, 12:47:27 AM
I just wanna ask, is it possible to Fire one kind of shot from one option and fire a different type on the other?
Like this... (Fire on left, Knives on right)
(http://img716.imageshack.us/img716/8085/isthisevenpossible.png)
Add an argument to your option task
Code: [Select]
task WhateverYourOptionTaskIs(bullet) {then use "bullet" without quotes to use the predefined bullet graphic
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: TwiliAezure on March 20, 2010, 03:01:28 AM
Add an argument to your option task
Code: [Select]
task WhateverYourOptionTaskIs(bullet) {then use "bullet" without quotes to use the predefined bullet graphic

Thanks a lot, MokouTan!
I'm not sure what argument to put in and I don't know exactly where to put it... Sorry, I'm such a noob.  :ohdear:
(There's FOUR options!)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 20, 2010, 04:01:08 AM
Well he mains something like this:

task Option(bullet){
   let objoption = Obj_Create(OBJ_EFFECT);
   //etc.
   while(!Obj_BeDeleted(objoption)){
      //etc.
      FireShot(x, y, velocity, angle, bullet);
      yield;
   }
}

Then, in @Initialize or wherever you call your Options, you can say:

Option(1);
Option(2);
Option(3);
Option(4);

So that one option will use the bullet graphic 1, the other 2, the next 3, the last 4. The arguments you create in your tasks can be passed around within that task, which makes it useful for modifying the task without actually rewriting it. For more on tasks, read up on them in the Intermediate Tutorial (http://www.shrinemaiden.org/forum/index.php?topic=865.msg31779#msg31779).

FireShot isn't actually a function in player scripting, by the way.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 20, 2010, 04:08:15 AM
task Option(bullet){
   let objoption = Obj_Create(OBJ_EFFECT);
   //etc.
   while(!Obj_BeDeleted(objoption)){
      //etc.
      FireShot(x, y, velocity, angle, bullet);
      yield;
   }
}

You know, I've noticed this in a few of your other posts, but holy shit you syntax color your fucking code on the forums. Obviously, you have too much time on your hands. As if most of us don't... we're just lazy.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 20, 2010, 04:09:15 AM
Took me all of thirty seconds for that post :S
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: TwiliAezure on March 20, 2010, 04:14:00 AM
Oooooooooooh! Thanks, Naut!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 20, 2010, 09:47:39 AM
>.< Why does Danmakufu hate sound files?

I'm trying to add sounds (.mp3's) into my Nazrin player, but it's only playing half the sound. .wav's will play correctly, but they're also about 10 times bigger.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 20, 2010, 05:04:29 PM
Sound effects just seem to belong in wav files, no matter how huge they become. For anything that isn't music I just suggest using wav files anyways.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nobu on March 20, 2010, 10:25:32 PM
Is there a way to program something into a bullet so that it does something upon colliding with the hitbox of another bullet/laser (or programming the bullet/laser to affect any bullet that comes into contact with it),  such as splitting into more bullets/deleting/etc?

Basically, i'm trying to make a laser that effectively blocks and disperses bullets that collide with it, but I don't even know where to begin trying to program this behavior. Any help or advice would be much appreciated.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on March 20, 2010, 11:00:02 PM
Is there a way to program something into a bullet so that it does something upon colliding with the hitbox of another bullet/laser (or programming the bullet/laser to affect any bullet that comes into contact with it),  such as splitting into more bullets/deleting/etc?

Basically, i'm trying to make a laser that effectively blocks and disperses bullets that collide with it, but I don't even know where to begin trying to program this behavior. Any help or advice would be much appreciated.
Object bullets and the Obj_SetCollisionToObject/Collision_Obj_Obj functions are what you're gonna need.

All bullets that will affect or be affected need to be object bullets/lasers, and then set Obj_SetCollisionToObject to true for each object, then make statements where if Collision_Obj_Obj is true, do whatever you wanna do (explosions of bullets or rainbows w/e)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 20, 2010, 11:00:13 PM
Ahehehehem, yeah, that is somewhat advanced.

All bullets and lasers you want to use have to be object bullets and object lasers, the ids of which you need to store in arrays. If you want only a fixed number of these lasers, and if you want none of them to disappear, it is fairly doable. If you to create any number of lasers and if you want these lasers to fade away, it becomes somewhat tricky.

Then you have to perform Collision_Obj_Obj checks for every possible combination

As a scripting example, you need to create an array for the object ids of the lasers right at the beginning of your script. Then you need to make your regular object bullet creation task, where you check in the while{} part if the bullet is colliding with any of the lasers which ids are stored in the laser array. If it collides, you insert the code that does what you want to do.
Important is that you have to delete the id in the array after the laser ceases to exist, or else the arrays will grow larger and larger, and danmakufu bitches around if its arrays become too long.

A code example that you would insert at the beginning of the script:

Code: [Select]

let lazors = [];

task TLazor(x, y, whatever){

   let obj=Obj_Create(OBJ_LASER);

   lazors=lazors~obj;

   //insert standard object laser stuff here

   while(Obj_BeDeleted(obj)==false){

      //insert laser behaviour code here

      yield;

   }

   let number=0;
   
   while(number<length(lazors)){

       if(lazors(number)==obj){ //checks if the place in the array holds the id

           lazors=erase(lazors, number); //if it does, danmakufu deletes the place

       } else{
           number++; //if not, it moves on to the next
       }

   }

}

This would be the framework code for the lasers. Now you need to include the following code in the while{} part of the object bullets:

Code: [Select]

ascent(i in 0..length(lazors)){
   if(Collision_Obj_Obj(obj, lazors(i))==true){

       //stuff you want to happen when the bullet hits the laser.

   }
}

Though I wouldn't swear by this code. It is midnight around here, so I may have mode a stupid mistake or two here and there...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nobu on March 21, 2010, 12:53:59 AM
Suikama, Iryan, thank you so much. *_*

I was scouring the wiki looking for something like Collision_Obj_Obj and Obj_SetCollisionToObject, but completely missed it over until now.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nimble on March 24, 2010, 06:55:35 PM
How can I rorate ObjectEffect =w=?
I try ObjEffect_SetAngle and it fly away :o

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Infy♫ on March 24, 2010, 06:58:00 PM
Code: [Select]
ObjEffect_SetAngle(obj,0,0,angle);
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 24, 2010, 07:01:34 PM
You have to define your vertices around the 0,0 point if you want to use ObjEffect_SetAngle. For a 64x64 image, it would be something like:

ObjEffect_SetVertexXY(obj, 0, -32, -32);
ObjEffect_SetVertexXY(obj, 1, 32, -32);
ObjEffect_SetVertexXY(obj, 2, 32, 32);
ObjEffect_SetVertexXY(obj, 3, -32, 32);

Then you can set the angle with ObjEffect_SetAngle(obj, 0, 0, angle);

I usually just use trigonometry and set the XY coordinates every frame instead of dicking around with the 0,0 point and SetAngle. But I also like to fuck around with the shape of my objects, so :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nimble on March 24, 2010, 07:50:59 PM
You have to define your vertices around the 0,0 point if you want to use ObjEffect_SetAngle. For a 64x64 image, it would be something like:

ObjEffect_SetVertexXY(obj, 0, -32, -32);
ObjEffect_SetVertexXY(obj, 1, 32, -32);
ObjEffect_SetVertexXY(obj, 2, 32, 32);
ObjEffect_SetVertexXY(obj, 3, -32, 32);

Then you can set the angle with ObjEffect_SetAngle(obj, 0, 0, angle);

I usually just use trigonometry and set the XY coordinates every frame instead of dicking around with the 0,0 point and SetAngle. But I also like to fuck around with the shape of my objects, so :V


oh ... I got it...
I use this before

   ObjEffect_SetVertexXY(OE_MagicCircle, 0, GetX-25, GetY-25);
   ObjEffect_SetVertexXY(OE_MagicCircle, 1, GetX+25, GetY-25);
   ObjEffect_SetVertexXY(OE_MagicCircle, 2, GetX+25, GetY+25);
   ObjEffect_SetVertexXY(OE_MagicCircle, 3, GetX-25, GetY+25);

after change to Obj_SetX, Obj_SetY and ObjEffect_SetVertexXY(OE_MagicCircle, 0, -25, -25); it rolate correctly.
/me facepalm
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on March 25, 2010, 03:58:41 PM
You have to define your vertices around the 0,0 point if you want to use ObjEffect_SetAngle. For a 64x64 image, it would be something like:

ObjEffect_SetVertexXY(obj, 0, -32, -32);
ObjEffect_SetVertexXY(obj, 1, 32, -32);
ObjEffect_SetVertexXY(obj, 2, 32, 32);
ObjEffect_SetVertexXY(obj, 3, -32, 32);

Then you can set the angle with ObjEffect_SetAngle(obj, 0, 0, angle);

I usually just use trigonometry and set the XY coordinates every frame instead of dicking around with the 0,0 point and SetAngle. But I also like to fuck around with the shape of my objects, so :V

I've actually tried doing this, and even though this does work, it's not all that accurate. If it happens to be a circle and you try to spin it this way, you'll notice it'll always be a bit off and you can't ever quite get it to be perfect. There is a a way to achieve that, though, but you can't do it this way. Instead of setting definite points in SetVertexXY and using SetAngle to spin it, you'll revolve the actual XY coordinates themselves in a circle around an imaginary center (center of the image) using angles to define the points and with a radius half the width/height of the desired image. This way, even if your circle may not be a perfect one, it will definitely rotate like it. Even if it's an oval and not a circle, it can easily morph it too look like one and spin around it's actual center.  A few pixels does make a difference.  This is the code you want.

Code: [Select]
ObjEffect_SetVertexUV(obj,0,0,0);
ObjEffect_SetVertexUV(obj,1,0,64);
ObjEffect_SetVertexUV(obj,2,64,0);
ObjEffect_SetVertexUV(obj,3,64,64);

while(!Obj_BeDeleted(obj)){
Obj_SetPosition(obj,GetX,GetY);

ObjEffect_SetVertexXY(obj,0,radius1*cos(ang1),radius1*sin(ang1));
ang1+=360/4;
ObjEffect_SetVertexXY(obj,2,radius1*cos(ang1),radius1*sin(ang1));
ang1+=360/4;
ObjEffect_SetVertexXY(obj,3,radius1*cos(ang1),radius1*sin(ang1));
ang1+=360/4;
ObjEffect_SetVertexXY(obj,1,radius1*cos(ang1),radius1*sin(ang1));
ang1+=360/4;


ang1+=angrotation;
yield;
 }



To make this work, you'll have to plug in some variables. I already explained what the radius should be.
As for ang1, this image is set to spin. Plugging in ang1 starting at 0 at the beginning of the task, each ang1+=360/4; spins the degrees of the angle by 90 degrees, to draw the left, right, top, and bottom of the image.  ang1+=angrotation at the end there will be your angular rotation after each of the XY coordinates have been set. It works by shifting the entire ang1 after it made a complete 360 and drew the said image at those points. You'll have to plug in and define ang1, radius1, and angrotation yourself at the beginning of the object task.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on March 25, 2010, 10:27:57 PM
That's getting overly complicated. If it doesn't spin perfectly, then that just means your vertices are off.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on March 25, 2010, 10:30:45 PM
Ummm why not just use this?

Code: [Select]
   ObjEffect_SetVertexXY(obj, 0, x+(radius)*cos(angle), y+(radius)*sin(angle));
   ObjEffect_SetVertexXY(obj, 1, x+(radius)*cos(angle+90), y+(radius)*sin(angle+90));
   ObjEffect_SetVertexXY(obj, 2, x+(radius)*cos(angle+180), y+(radius)*sin(angle+180);
   ObjEffect_SetVertexXY(obj, 3, x+(radius)*cos(angle+270), y+(radius)*sin(angle+270));
angle+=2;
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on March 27, 2010, 01:35:39 AM
Ummm why not just use this?

Code: [Select]
code

It's just not my style.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on March 27, 2010, 05:11:12 PM
I'm having a bit of a problem with this tutorial (http://dmf.shrinemaiden.org/wiki/index.php?title=Danmakufu_Intermediate_Tutorial#How_to_use_Tasks.21). I tried copying the end code with the bullets that are supposed to bounce off the sides, but it's not working.

After figuring out there was a missing bracket for the task itself, Danmakufu is now telling me that "Bullet" isn't identified. I've got yields in the right places (I think - one at the end of MainLoop and the end of the task's while statement, right?) and as far as I can tell there aren't any other problems.

If someone could help me with this, I would be much obliged. This (http://www.majhost.com/gallery/Elementoid/DANMAKUFU/tut_-_bounce1.txt) is the code I have right now.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on March 27, 2010, 05:19:38 PM
I'm having a bit of a problem with this tutorial (http://dmf.shrinemaiden.org/wiki/index.php?title=Danmakufu_Intermediate_Tutorial#How_to_use_Tasks.21). I tried copying the end code with the bullets that are supposed to bounce off the sides, but it's not working.

After figuring out there was a missing bracket for the task itself, Danmakufu is now telling me that "Bullet" isn't identified. I've got yields in the right places (I think - one at the end of MainLoop and the end of the task's while statement, right?) and as far as I can tell there aren't any other problems.

If someone could help me with this, I would be much obliged. This (http://www.majhost.com/gallery/Elementoid/DANMAKUFU/tut_-_bounce1.txt) is the code I have right now.

You have your bullet task in @Finalize. I don't think it should be there. Your script should look something like this:

Code: [Select]
@Finalize{
Deletion Stuff Here
   }

Tasks/Functions go here

} <---script_enemy_main final bracket

Edit: Also, it's much easier to use Pastebin for danmakufu stuff. Just c/p.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 27, 2010, 06:16:55 PM
I am typing something, and then my internets explode for an hour. Great.

Anyways, yeah, what Fury said.


On another note, I advise you to read the tutorial as it is posted on this forum (http://www.shrinemaiden.org/forum/index.php?topic=865.0), rather than on the wiki. It may very well be that the wiki formating has screwed up some of the code parts.

However, the missing } bracket error seems to be in the original, too. I'd change it, but since the post it is in is no longer mine, I can't.  :(
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on March 27, 2010, 06:27:21 PM
Furienify: I guess when I read "behind @Finalize" I assumed that it had to be in it.

Iryan: Mkay, I'll check out the other tutorial.

Than you both for the prompt responses. They helped a lot.  :)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 27, 2010, 06:56:12 PM
However, the missing } bracket error seems to be in the original, too. I'd change it, but since the post it is in is no longer mine, I can't.  :(

Fixed both forum and wiki versions.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on March 28, 2010, 12:19:22 AM
Posting here since I can't get any help on IRC.

Background: I'm using Helepolis' custom cutin script.

1. Occasionally (I can't seem to pin it down) the cutin is called but it doesn't make the whole 'spellcard noise'. Is there any way to fix this?

2. On the second card of my entry, the cutin flashes by for maybe a third of a second and then runs away as fast as possible. On my first card this isn't a problem, but neither make any noise.

Any tips on how to fix this?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 28, 2010, 02:36:30 PM
Posting here since I can't get any help on IRC.

Background: I'm using Helepolis' custom cutin script.

1. Occasionally (I can't seem to pin it down) the cutin is called but it doesn't make the whole 'spellcard noise'. Is there any way to fix this?

2. On the second card of my entry, the cutin flashes by for maybe a third of a second and then runs away as fast as possible. On my first card this isn't a problem, but neither make any noise.

Any tips on how to fix this?

I noticed these problems as well. I dunno what the trigger is, but under certain conditions, the sound doesn't play. In the script I'm working on currently, all the cut-in calls don't make a sound, not even the normal CutIn ones. It probably has something to do with the timing in mine because I call them in @MainLoop about a second after the spellcard script starts. The easiest fix is probably just to make a sound effect yourself, which is what I will be doing once I get around to adding sound.

As for the cut ins disappearing too quickly, which cut in style were you using? I did notice that if you use the MoF style cut ins, the portrait will move kinda strangely. It probably is a mistake or oversight in the custom cut in script itself and Helepolis or someone else who feels like reading through the code needs to fix later.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on March 28, 2010, 06:15:03 PM
I noticed these problems as well. I dunno what the trigger is, but under certain conditions, the sound doesn't play. In the script I'm working on currently, all the cut-in calls don't make a sound, not even the normal CutIn ones. It probably has something to do with the timing in mine because I call them in @MainLoop about a second after the spellcard script starts. The easiest fix is probably just to make a sound effect yourself, which is what I will be doing once I get around to adding sound.

As for the cut ins disappearing too quickly, which cut in style were you using? I did notice that if you use the MoF style cut ins, the portrait will move kinda strangely. It probably is a mistake or oversight in the custom cut in script itself and Helepolis or someone else who feels like reading through the code needs to fix later.

This happens to me, too, but I just call PlaySE("se\seUseSpellCard.wav"); or whatever the name of the sound was.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nobu on March 28, 2010, 07:45:42 PM
As for the cut ins disappearing too quickly, which cut in style were you using? I did notice that if you use the MoF style cut ins, the portrait will move kinda strangely. It probably is a mistake or oversight in the custom cut in script itself and Helepolis or someone else who feels like reading through the code needs to fix later.

I thought it was kinda strange too, until I actually looked at how the MoF cut-ins move. They really do do that weird quick movement from the top right corner to the bottom, then rise up slowly. I think it's more noticeable/looks weird due to the level of opacity in the initial part, but the movement itself is pretty much spot on.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on March 28, 2010, 08:18:29 PM
It's not Kanako-style though, I'm using the Nazrin type. I've tried all 3, and for this one particular spell it just goes by really quickly.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 28, 2010, 08:29:25 PM
I thought it was kinda strange too, until I actually looked at how the MoF cut-ins move. They really do do that weird quick movement from the top right corner to the bottom, then rise up slowly. I think it's more noticeable/looks weird due to the level of opacity in the initial part, but the movement itself is pretty much spot on.

Yeah, I realize MoF cut ins do move like that, but I think it moves too fast or something. I dunno.



ANYWAYS, time for a rant about the idiocies of Danmakufu because I'm super frustrated at this thing I was working on that became impossible to do. Period. No work arounds will save you here. My goal was to make a function called StringToNumber. It was supposed to take a string that has only numbers and one or no decimal points and convert it into the corresponding float. However, I came across two issues, one of which I overcame and one of which completely stumped me and caused me to give up and rage at Danmakufu.

Issue 1: The Character Data Type
Most of you should be familiar with how Danmakufu stores integers are floats and, therefore, all numbers are stored as the same data type and can be freely compared with each other. You may also be aware of the boolean data type which stores only true or false, as well as the string data type which stores letters (and numbers and symbols). What you may not know if you only worked with Danmakufu is that there is also a character data type. The string data type is actually an array of characters, which means that you can do stuff like "this is a string lol"[3] and it will give you the character "s". That's pretty neat and all, but the issue comes up when you try to do if("this is a string lol"[3] == "s"), or in other words, see if a specific character in a string is a certain character. At first glance, that looks fine, but when you try to run it, Danmakufu will throw an error. This would likely stump a lot of Danmakufu users who never touched another scripting/programming language, and it even stumped me for a bit until I realized that "this is a string lol"[3] gave me a character and that I was comparing this character to a 1-character-long-string "s". I was doing the equivalent of if([1, 2, 3, 4][3] == [4]) which would compare a number to an array. What I really had to do was this: if("this is a string lol"[3] == "s"[00]).

What the hell, right? Well this was the least of my problems.

Issue 2: WTF Fail Math
Hey, what's 1*10000000000? It should be 10000000000, right? Well, not according to Danmakufu! What's that you say? Danmakufu can't possibly be that stupid? Well guess what? It is. It reallly is THAT stupid. If I used OutputDebugString to output just 10000000000, it would output it just fine. However, if I outputted 10000000000*1, it would give me 9999997952. That's 2048 off from what it should be, by the way. Likewise, multiplying 10000000000 with 2 would multiply the inaccuracy by 2. Just for no apparent reason, multiplication with large numbers becomes extremely inaccurate. I have found no way to solve this problem. The engine is just that bad.

In all the times I've been working with Danmakufu, I've always thought that it was a weak language and that it had some rather strange and somewhat annoying quirks. I also thought that some of its features could use some polishing, However, I had never thought I'd encounter a big enough problem that would prevent me from doing something I wanted to do. I always thought that there would be a workaround to get around or somewhat fix the problem. And now I've been proven wrong. Thanks Danmakufu for being a pain in the ass. I can't wait for Musuu to become as useable as Danmakufu without all of its idiocies.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on March 28, 2010, 08:41:57 PM
Quote
2048 off
Sounds like a memory problem or something. Looks like the developers never even considered large numbers :moogy:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 28, 2010, 09:18:18 PM
Issue 2: WTF Fail Math

 :o

Waitaminute...

If it is only the mathmatical operators of second and higher order that danmakufu fucks up, wouldn't it theoretically be possible to test how exactly danmakufu fucks up the math and then, if it fucks it up the same way everytime (which is most likely true), write a function that corrects these errors by the means of addition and subtraction? I know it is incredibly time-consuming, stupid, bothersome, asinine and totally not worth the effort, but damnit!

On an unrelated note, I don't think I've ever used the word fuck on a forum before, most certainly not more than once in a single post.  :/
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on March 28, 2010, 09:21:04 PM
function Goddamnbasicfuckingmaththatdanmakufucan'tevendoproperlyshiiiiiiiiiiit(number1, number2, operation{
   //lol have fun
}

On an unrelated note, I don't think I've ever used the word fuck on a forum before, most certainly not more than once in a single post.  :/
Programming does that to ya
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on March 28, 2010, 09:27:44 PM
(stuff about character data type)
if("this is a string lol"[3] == "s")

The character data type is indicated the same way as in C - with single quotes, not double quotes. Use single quotes around 's' and it should work perfect without having to use the "s"[0] ugly workaround.
As for your other question, I have no clue.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 28, 2010, 10:39:30 PM
<- uses single-quotes for characters
<- giggled at bagel for first problem
<- wtfd at second
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 28, 2010, 11:46:31 PM
Your second problem stems from the highest number that can be safely stored in Danmakufu (or so I think). While I don't know what it is (I'm sure it would be rather easy to find out), I do know that instead of erroring, Danmakufu will just keep rolling with it and it'll usually fuck up your script somehow in the long run. Usually unpredictably, too. Interestingly enough, it will fuck up in the exact same way every time, provided you don't change anything. I point you to one of my earlier scripts for an example. Popcorn bullets! (http://www.shrinemaiden.org/forum/index.php?topic=1151.msg163162#msg163162)

Also, to my Ijiyatsu bros, while subtracting 0.01 from the point multiplier, the sixth decimal place will fuck up and start displaying a 1 after 50 subtractions in a row. If you've still got one of the earlier builds hanging around -- one that displays the power level using a DrawText function in the bottom right corner -- try moving to the top of the screen. The multiplier should immediately max at 1.000000. Then move back down. The multiplier will start moving back to 0.000000, but halfway through the last decimal place will change for no reason. It fixes itself once it hits 0.000000, I had to use the round function to fix the random quirk, and it works fine in practice, but you can still see it there, haunting me.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on March 29, 2010, 03:14:04 AM
Danmakufu randomly crashes now whenever I do... anything in it.

Has been functioning 100% okay all day. All I did was put my contest entry into a RAR file and send it to a friend- as soon as he started getting the errors, I did too. Yeah, it's applocale.

Do the fates/danmakufu just conspire against me? :ohdear: Troubleshoot!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 29, 2010, 03:33:08 AM
Troubleshoot!

Post script!

You couldn't have seriously been expecting any other answer? :P
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on March 29, 2010, 03:43:10 AM
Post script!

You couldn't have seriously been expecting any other answer? :P

I'm not running any actual scripts though, it's just danmakufu being... argh-inducing and I don't want to break anyone else's.

I grabbed a clean danmakufu install and ported my entry over- it worked fine, except none of my shots appeared, so I assume that I put the path down wrong when including the shotsheet, so I fix (I think?) the pathname, copy the folder over again and overwrite everything I had and... now that danmakufu refuses to work!

IRC seems to suggest it's just danmakufu being danmakufu... but I wish it would stop that. :ohdear:

FalseEdit: I tried to take the entry out of my clean install, but the system won't let me. I don't have permission to move it out of the script folder. Is Vista fucking around with me again?  :/
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 29, 2010, 04:01:36 AM
This is likely not a case of Danmakufu being Danmakufu; you're doing something wrong.

Also, are you running Danmakufu while trying to take the entry out/don't have admin rights...?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 29, 2010, 06:43:41 AM
*facepalms at the single quotes and slaps self for not thinking about that*
Also, I did think about writing a function that corrects the problem with addition/subtraction, but I can't quite pinpoint the problem. The first case of the problem occurred with the number becoming too large, actually. Only later when I started testing did I get numbers that were smaller than they should be. Maybe I'll check again later, but for now, I'm too angry at Danmakufu to try this and will likely not work with it for a few weeks. I do still want to finish my script I'm currently working on but not now.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on March 29, 2010, 07:29:24 AM
About the custom cut-in script, I haven't encountered an issue where everything is executed in high speed. This is like totally new for me. Would be good if the script or a video could be provided, if you want.

As for the MoF type cut-in, it might look weird because it does not have the same smooth movement as in the original games.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 29, 2010, 08:44:20 AM
Wow... so many topics in the Q&A thread today...

Mind if I add mine? :ohdear:

ok... so... I was just wondering... how does the spell card score system work in touhou?

All I'm getting is that every frame the spell card goes (unless it's a survival) the score drops a certain amount... I'm guessing around a 3-digit value... and whenever you graze a bullet... it goes up by a certain value, I have no idea... And it also starts at around 1mil, maybe, at stage 1 and increases per stage...

I really don't know :/... I'm asking this cause I'm trying to create my own spell card score system for my game... and I'm gonna base it on this... danmakufu's default score system is weirding me out... and it's not helping that there's something wrong with my computer's graphics cause all effect objects weird out whenever I use SetScore(...) and I can never really get proper text from danmakufu... something's wrong with my graphics card or something...

And another thing... Does anyone know anyway to change or disable to way danmakufu adds to your score whenever you hit an enemy? (I think it starts somewhere at graze 100? or something... maybe it's not graze... maybe it's point items... I need to experiment more...) I've tried using SetRateScoreSystemEnable(false)... I don't really know what that does, but it's not helping...

Hope this isn't too much or weirding people out... :ohdear:

EDIT: Checked parts of IN and UFO
IN: st1-st6, ex, LW (no difference in difficulty)
10M, 15M, 20M, 22M, 26M, 30M, 40M, 1B
+12K to bonus for every time point... It's time points... not graze apparently

UFO:
Easy st1 is 2m per spell card and it increases by 2m per spell card... every mode above increases by 2m again, meaning normal st1 is 4m, hard st2 is 8m, etc... EX is 22m... NO POINT INCREASE FOR GRAZE...
around 50K decrease per second... not that good at estimating...

EDIT2: the default score adding system in danmakufu depends on graze... I'm thinking it's a somehow more complicated version of damage*graze or something like that...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on March 29, 2010, 08:49:42 AM
Update on WTF Fail Math.

Float precision sucks. Danmakufu uses floats for everything. Therefore, Danmakufu number precision sucks. And therefore, string to float function is not possible to make. Storing a number as a string in an array so you can store both strings and numbers in the same array is never going to be possible in Danmakufu. I'm going to stop trying that now.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 29, 2010, 10:47:38 AM
And another thing... Does anyone know anyway to change or disable to way danmakufu adds to your score whenever you hit an enemy? (I think it starts somewhere at graze 100? or something... maybe it's not graze... maybe it's point items... I need to experiment more...) I've tried using SetRateScoreSystemEnable(false)... I don't really know what that does, but it's not helping...

Hm. It seems it is depending only on the amount of graze you have. Well, since you are going to make you own scoring system anyways, it would be somewhat bothersome but possible to do the following in the stage script:

Code: [Select]
SetCommonData("gz", 0);

@MainLoop{
   SetCommonData("gz", GetCommonData("gz")+GetGraze);
   AddGraze(-GetGraze);
}

And then you make the score you get from different things dependent on the CommonData "gz".
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 29, 2010, 11:09:55 AM
Hm. It seems it is depending only on the amount of graze you have. Well, since you are going to make you own scoring system anyways, it would be somewhat bothersome but possible to do the following in the stage script:

Code: [Select]
SetCommonData("gz", 0);

@MainLoop{
   SetCommonData("gz", GetCommonData("gz")+GetGraze);
   AddGraze(-GetGraze);
}

And then you make the score you get from different things dependent on the CommonData "gz".

That would work... thanks... :D

But then that would add another problem... anyone know how much score graze adds? :V joke... I'll just make the values up myself...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on March 29, 2010, 11:59:14 AM
This is likely not a case of Danmakufu being Danmakufu; you're doing something wrong.

Also, are you running Danmakufu while trying to take the entry out/don't have admin rights...?

Danmakufu definitely wasn't running at the time, I checked my processes. And I do have admin rights unless they up and ran off over the course of a few seconds.

After a clean reboot, having gone to bed, I can take the script out now. Neither of my Danmakufu copies, however, will work, nor will they after I extract a clean copy from the RAR.

Given the nature of the error (click on anything in the menu, crash) I'm inclined to think it's applocale screwing up since the error is identical, but even after running applocale.msi again and attempting a repair, nothing works still. :/
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 29, 2010, 12:02:38 PM
An extreme solution, but have you tried using System Restore to bring your computer back a few days? Could've been something you installed lately, or whatever else.



Your second problem stems from the highest number that can be safely stored in Danmakufu
The first case of the problem occurred with the number becoming too large, actually.

>: |
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on March 29, 2010, 01:01:37 PM
An extreme solution, but have you tried using System Restore to bring your computer back a few days? Could've been something you installed lately, or whatever else.

Just tried it, no luck. How strange. I sent it to someone else for playtesting yesterday and it was just fine. Guess I'll have to check for viruses or something when I get home.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 29, 2010, 01:40:39 PM
Just tried it, no luck. How strange. I sent it to someone else for playtesting yesterday and it was just fine. Guess I'll have to check for viruses or something when I get home.

>.< I had a problem like this just recently, actually. Try deleting* script_index.dat.

*by "deleting", I of course mean "renaming".
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 29, 2010, 02:15:05 PM
Ah, that might actually work. If I recall correctly, danmakufu stores certain script data there. If your script is screwed up in certain ways, danmakufu saves this screwed up data and will therefore cease to work properly until you got rid of this data, either by removing the scripts and then starting danmakufu a high number of times, or by releasing the data file.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 29, 2010, 03:24:05 PM
making the hiscore system this time...
Code: [Select]
...
let hsscorenum1=GetCommonData(GetCommonData("CURRENTHS"));
...
Code: [Select]
...
if(GetCommonData("gametype")=="PRACTICE")
{
if(GetCommonData("difficulty")=="EASY")
{
let hiscorearray=["PRAC_1E_HISCORE", "PRAC_2E_HISCORE", "PRAC_3E_HISCORE", "PRAC_4E_HISCORE", "PRAC_5E_HISCORE", "PRAC_6E_HISCORE"];
if(GetCommonData("SCORE")>GetCommonData(hiscorearray[currentstage-1]))
{
SetCommonData(hiscorearray[currentstage-1], GetCommonData("SCORE"));
SetCommonData("CURRENTHS", hiscorearray[currentstage-1]);
}
}
...
Note: These are just parts of the script... I'm sure that there's no missing brackets or semicolons or whatever...

This keeps on spewing out the same error
型が一致しません(961行目)   <-- whatever that means...

I think it's obviously possible to call a common data with a common data... or however you word it... I just don't know why this is erroring... >:(

tried putting something like this SetCommonData("CURRENTHS", "PRAC_1E_HISCORE"); in @Initialize... it makes the error stop, but then... that piece of code makes other common datas, that don't error without it, error for some reason... and removing the subroutine that contains that first line of code also makes the script play, but of course, it's not drawing the score anymore...

help? :ohdear: (Can't post the full code... it's too long and it's very messy and confusing right now... but I can still understand it and know where everything is...)

(the things in the array are common datas with values currently set at 0... and currentstage is well... the current stage... 1-6)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 29, 2010, 03:28:58 PM
<snip>

Do you have both a regular array called hiscorearray and a common data by the name of "hiscorearray"? If not, then here lies your problem.

Blah, I can't read code properly.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 29, 2010, 03:37:17 PM
Do you have both a regular array called hiscorearray and a common data by the name of "hiscorearray"? If not, then here lies your problem.

I don't get it... if you're saying that the -1 brings the value to -1 instead of the minimum 0... it's not cause the minimum value I'm bringing currentstage to is 1...
hiscorearray was only declared there...

Just tried declaring hiscorearray as an empty array first then just change it there, that didn't help...

the common datas I'm using are the strings in the array... so there are lines somewhere else saying something like
Code: [Select]
SetCommonData("PRAC_1E_HISCORE", 0);
SetCommonData("PRAC_2E_HISCORE", 0);
SetCommonData("PRAC_3E_HISCORE", 0);
SetCommonData("PRAC_4E_HISCORE", 0);
SetCommonData("PRAC_5E_HISCORE", 0);
SetCommonData("PRAC_6E_HISCORE", 0);

EDIT:
tried turning this
Code: [Select]
      SetCommonData(hiscorearray[currentstage-1], GetCommonData("SCORE"));
      SetCommonData("CURRENTHS", hiscorearray[currentstage-1]);
into this
Code: [Select]
SetCommonData(hiscorearray[currentstage-1], GetCommonData("SCORE"));
SetCommonData("CURRENTHS", GetCommonData(hiscorearray[currentstage-1]));
then just loading CURRENTHS as a normal value...
now it's giving me nothing...

*sigh* I'll just try again tomorrow... gotta stop now...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on March 29, 2010, 03:51:42 PM
making the hiscore system this time...
Code: [Select]
...
let hsscorenum1=GetCommonData(GetCommonData("CURRENTHS"));
...
Code: [Select]
...
   if(GetCommonData("gametype")=="PRACTICE")
   {
   if(GetCommonData("difficulty")=="EASY")
   {
   let hiscorearray=["PRAC_1E_HISCORE", "PRAC_2E_HISCORE", "PRAC_3E_HISCORE", "PRAC_4E_HISCORE", "PRAC_5E_HISCORE", "PRAC_6E_HISCORE"];
      if(GetCommonData("SCORE")>GetCommonData(hiscorearray[currentstage-1]))
      {
      SetCommonData(hiscorearray[currentstage-1], GetCommonData("SCORE"));
      SetCommonData("CURRENTHS", hiscorearray[currentstage-1]);
      }
   }
...
Note: These are just parts of the script... I'm sure that there's no missing brackets or semicolons or whatever...

This keeps on spewing out the same error
型が一致しません(961行目)   <-- whatever that means...

I think it's obviously possible to call a common data with a common data... or however you word it... I just don't know why this is erroring... >:(

tried putting something like this SetCommonData("CURRENTHS", "PRAC_1E_HISCORE"); in @Initialize... it makes the error stop, but then... that piece of code makes other common datas, that don't error without it, error for some reason... and removing the subroutine that contains that first line of code also makes the script play, but of course, it's not drawing the score anymore...

help? :ohdear: (Can't post the full code... it's too long and it's very messy and confusing right now... but I can still understand it and know where everything is...)

(the things in the array are common datas with values currently set at 0... and currentstage is well... the current stage... 1-6)

The way I can see around this is if you manually check what stage the player is on and update the high score from there.
 
Code: [Select]
if(GetCommonData("PRAC_1E")=="OnStage"){
//your high score code
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on March 29, 2010, 04:56:42 PM
I could never understand how arrays of objects work...
Could someone please explain it in more... simple terms?

Thank you.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 29, 2010, 05:08:52 PM
Well...

When you create an object with a task, the first thing you usually do is creating a variable, usually named obj, that stores a freshly generated object id.

Code: [Select]
let obj=Obj_Create(OBJ_WHATEVER);
To make an object array, you just create an empty array at the beginning of the script_enemy_main{}
Code: [Select]
let objarray=[];
Then you insert a line in your object task that adds the id of the newly generated object to the array.

Code: [Select]
objarray=objrarray ~ obj;
That way you can refer to any of the objects you created outside of the tasks that created them by refering to the entries in the array, for example, objarray[1].

Now the only thing left is to make shure that the id gets cut from the array once the object ceases to exist. To accomplish this, you need to put this code (or something similar) at the end of the object task, behind the while(Obj_BeDeleted(obj)==false){} part, so that it gets executed at the right time:

Code: [Select]
let ocount=0;
while(ocount<length(objarrray)){

    if(objarray[ocount]==obj){
        objarray=erase(objarray, ocount);
    } else{
        ocount++;
    }
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 29, 2010, 05:47:08 PM
let hiscorearray=[GCD("PRAC_1E_HISCORE"), GCD("PRAC_2E_HISCORE"), GCD("PRAC_3E_HISCORE"), GCD("PRAC_4E_HISCORE"), GCD("PRAC_5E_HISCORE"), GCD("PRAC_6E_HISCORE")];

ps just because you access common data through strings doesn't mean they are located in the string
because that doesn't make any sense whatsoever

But the way you're using this makes me think that you're creating a new hiscorearray every frame. Not that it's technically wrong, but you'd think that would be updated instead of recreated. Also, instead of using the localized array hiscorearray and changing values through common data, you probably should just create one common data for easy access. Ideally, a 2D array.

SetCommonData("HISCOREARRAY", [ [eG,nG,hG,lG],[e1,e2,e3,e4,e5,e6],[n1,n2,n3,n4,n5,n6],[h1,h2,h3,h4,h5,h6],[l1,l2,l3,l4,l5,l6] ] ) or something of the sort. That way it could be actually ya know saved without any fandangled crappery.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on March 29, 2010, 09:52:37 PM
>.< I had a problem like this just recently, actually. Try deleting* script_index.dat.

*by "deleting", I of course mean "renaming".

This works! Temporarily. I can play my whole plural script through once before it gets broken again.

So...

Ah, that might actually work. If I recall correctly, danmakufu stores certain script data there. If your script is screwed up in certain ways, danmakufu saves this screwed up data and will therefore cease to work properly until you got rid of this data, either by removing the scripts and then starting danmakufu a high number of times, or by releasing the data file.

^How exactly can I fix this screwed up data?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 29, 2010, 09:59:16 PM
This works! Temporarily. I can play my whole plural script through once before it gets broken again.

So...

^How exactly can I fix this screwed up data?

Post script!

You couldn't have seriously been expecting any other answer? :P
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on March 29, 2010, 10:11:14 PM
Pastebin Scripts:

Spellcard 1 (http://pastebin.com/vQQVaqFb)
Spellcard 2 (http://pastebin.com/uFFJB5uS)
NonSpell 1 (http://pastebin.com/9yJynPmP)
NonSpell 2 (http://pastebin.com/99LQYuXD)

RAR of everything, commented out and removed music to save space. (http://www.mediafire.com/download.php?n2hwdzgyd2i)

I've never posted much of my work before. Nerves~ :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 29, 2010, 10:15:09 PM
This works! Temporarily. I can play my whole plural script through once before it gets broken again.

So...

^How exactly can I fix this screwed up data?
Lolidunno.
Theoretically, getting rid of the old script_index.dat and maybe of the contents of the replay folder are the only things I know that will get the data clean again.

However, you said you were able to play through your script again once, right? And after that, danmakufu would start to crash again once you tried to do anything in the starting menu, right?

If so, we can deduce that it really was a problem in the script_index.dat, and that running the script screwed it up again. Now the problem is to find which part of you script causes the problem. Since this is a very peculiar error, my guesses would be:

There is probably something wrong with the header of any of the files that are part of the plural script. Popular mistakes would be:

- Missing the line #ScriptVersion[2]
- Having a script with an #BackGround[ ] be called inside another script with an #BackGround[ ].
- Having the line #Player[ ] formatted the wrong way.

Maybe there is another problem somewhere. Maybe you named some script files in your script folder in such a way that danmakufu screws up the archiving. For example, having the ? symbol in the name of a file (or anywhere else in the script) could cause severe problems, I imagine. Maybe you named one of the files so that its name is read by danmakufu as a command when archiving.

I'd check the heads of your all your scripts first.  When you've found an error, clean the script_index.dat and then try again.

Good luck.  :ohdear:


Edit: rawr, scripts. I should go to sleep now so that I can get up early tomorrow (actually, that is today by now  :o ), but I want to check them out, anyways.
Let's see...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on March 29, 2010, 10:24:13 PM
Loli dunno?

Oh wait
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on March 29, 2010, 10:34:18 PM
Loli dunno?

Oh wait

Glad that wasn't just me.

@Iryan: You can head to bed, Tyltalis found the error. For SOME REASON I have space after #ScriptVersion but before the [2] in addition to several other parameters. I fixed all those and it works perfectly now. (Except for those weird cutin anomalies, but I can't help them.)

EDIT: I LIED BROKE AGAIN
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on March 29, 2010, 10:42:21 PM
AHASHAHAHA I found an error

You forget the closing ] bracket in one of the #Text[] lines.

Therefore the entire script was considered to be the text for the script. However, since danmakufu reads the playing part of the script from script_enemy_main onwards, the script was still playable. Then, when archiving, things gout fucked up.

http://www.youtube.com/watch?v=VcHJvsOb984 (http://www.youtube.com/watch?v=VcHJvsOb984)


Moep, now I may just as well listen Octavarium through till the end.  :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on March 29, 2010, 10:48:07 PM
AHASHAHAHA I found an error

You forget the closing ] bracket in one of the #Text[] lines.

Therefore the entire script was considered to be the text for the script. However, since danmakufu reads the playing part of the script from script_enemy_main onwards, the script was still playable. Then, when archiving, things gout fucked up.

http://www.youtube.com/watch?v=VcHJvsOb984 (http://www.youtube.com/watch?v=VcHJvsOb984)


Moep, now I may just as well listen Octavarium through till the end.  :V

It WORKS! Thanks so much. :*
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 30, 2010, 03:29:24 AM
tried the 2D arrays idea... now CURRENTHS always gives me 0... It's not changing/updating the value... don't know if I'm doing this right or not...

Code: [Select]
SetCommonData("HISCOREARRAY", [[0,0,0,0],[0,0],[0,0,0,0 blah blah etc... ]);
let array= [blah, blah2, blah3];
SetCommonData(GetCommonData("HISCOREARRAY")[0], array);
SetCommonData("HISCOREARRAY"[0], array);
^these lines aren't actually part of the code... they're just there to show the basis of the code...

I've never used arrays for common datas...

Code: [Select]
if(GetCommonData("SCORE")>GetCommonData("HISCOREARRAY")[0][0])
{
SetCommonData("HISCOREARRAY"[0], array); //or SetCommonData(GetCommonData("HISCOREARRAY")[0], array);
}
SetCommonData("CURRENTHS", GetCommonData("HISCOREARRAY")[0][0]);

None of them are working... :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on March 30, 2010, 04:43:13 AM
GetCommonData("HISCOREARRAY")[0][0]

You put the array index in the wrong place.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 30, 2010, 06:51:29 AM
GetCommonData("HISCOREARRAY")[0][0]

You put the array index in the wrong place.
I don't really get what you said... cause that's exactly what was in my code... (I'm an idiot :/)

I did some testing... moved pieces of code around and stuff... and as I thought
Code: [Select]
SetCommonData(GetCommonData("HISCOREARRAY")[0], hsarrayb);
this line has always been the problem... I really don't know how to change arrays INSIDE commondatas...

Code: [Select]
hsarrayc=GetCommonData("HISCOREARRAY");
hsarrayb=[GetCommonData("SCORE"), GetCommonData("HISCOREARRAY")[0][1],
GetCommonData("HISCOREARRAY")[0][2], GetCommonData("HISCOREARRAY")[0][3] ];
hsarrayc[0]=hsarrayb;
if(GetCommonData("SCORE")>GetCommonData("HISCOREARRAY")[0][0])
{
SetCommonData("HISCOREARRAY", hsarrayc);
}
SetCommonData("CURRENTHS", GetCommonData("HISCOREARRAY")[0][0]);
What a workaround... :V at least I got it working...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on March 30, 2010, 04:38:31 PM
Oh, I misread your SetCommonData("HISCOREARRAY"
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nobu on March 30, 2010, 10:47:40 PM
Quick dumb question here. I'm trying to append object ids to an empty array, but I get the error that i'm not concatenating the write data type. Do I have to turn the object ID into a string or something, or do something special with the array?

Relevant code:

let thearray = [];

let obj = Obj_Create(OBJ_SHOT);
thearray =  thearray ~ obj;
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on March 30, 2010, 11:01:25 PM
thearray =  thearray ~ [obj];

should work.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nobu on March 30, 2010, 11:03:53 PM
Ohh, I get it. Thanks a lot. o/
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 30, 2010, 11:33:37 PM
Just to clarify (even if you said you get it), you were trying to concatenate an object to an array. Technically it's just invalid because you can only concatenate two arrays. So just throw the object into a make-believe array and poof.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Danielu Yoshikoto on March 31, 2010, 12:08:25 AM
I need help with a simple Menu script.
I used "Wonderful☆Life's Introduction to Menus" as a base, but my Danmakufu keeps crashing after it told me that something is wrong with "enemy_script_main".
Code: [Select]
#?????e????
#Title[Some Title]
#Text[Some Text]
#Player[FREE]
#ScriptVersion[2]

script_stage_main{

let Selection=0;
let warning=0;
let alph1=150;
let alph2=150;
let alph3=150;
let alph4=0;
let alph5=0;
let MenuBG=GetCurrentScriptDirectory~"IMG\MenuBackground.png"
let Icon1=GetCurrentScriptDirectory~"IMG\Cirno.png"
let Icon2=GetCurrentScriptDirectory~"IMG\Daiyousei.png"
@Initialize{
LoadGraphic(MenuBG);
   SetLife(1);
}

@MainLoop{
if(GetKeyState(VK_UP) == KEY_PUSH){Selection+=1;warning=0;}
if(GetKeyState(VK_DOWN) == KEY_PUSH){Selection-=1;warning=0;}
if(GetKeyState(VK_SHOT) == KEY_PUSH && Selection==0){warning=1;}
if(GetKeyState(VK_SHOT) == KEY_PUSH && Selection==1){warning=1;}
if(GetKeyState(VK_SHOT) == KEY_PUSH && Selection==2){ClearStage;}
}

@DrawLoop{
DrawText("Idiot",GetCenterX,GetCenterY,15,alph1);
DrawText("Triple Idiot",GetCenterX,GetCenterY-20,15,alph2);
DrawText("EXIT",GetCenterX,GetCenterY-60,15,alph3);
if(Selection==0){alph1=255; alph2=150; alph3=150;}
if(Selection==1){alph1=150; alph2=255; alph3=150;}
if(Selection==2){alph1=150; alph2=150; alph3=255;}
if(Selection==0&&warning==1;){alph4=255;}else{alph4=0;}
if(Selection==1&&warning==1;){alph5=255;}else{alph5=0;}
if(Select>2){Select=2;}
if(Select<0){Select=0;}

SetTexture(Icon1);
SetGraphicRect(0,0,128,128);
SetAlpha(aplh4);
DrawGraphic(GetCenterX-64,GetCenterY);

SetTexture(Icon2);
SetGraphicRect(0,0,128,128);
SetAlpha(aplh5);
DrawGraphic(GetCenterX-64,GetCenterY-20);
}

}

I bet it is like the most simplest thing, but I was too stupid to find it.
Also yes this was only a test to see if the options on the menu would work, If so they should display a small picture on the side of the option, when chosen, and when the option was changed it would disappear again.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 31, 2010, 12:13:02 AM
You script needs to start with #TouhouDanmakufu[Stage] if you're using script_stage_main. Also, enemy_script_main doesnt exist, it's script_enemy_main.

Please tab your code.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 31, 2010, 12:14:23 AM
#TouhouDanmakufu[Stage]fuckgoddammit naut
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Danielu Yoshikoto on March 31, 2010, 12:26:43 AM
So yeah... after fixing that... (and also some other errors) I am now with the problem that nothing appears...

I think something is wrong with the overall script (http://dmf.shrinemaiden.org/wiki/index.php?title=Wonderful%E2%98%86Life%27s_Introduction_to_Menus).

Code: [Select]
let MenuBG=GetCurrentScriptDirectory~"IMG\MenuBackground.png";
let Baka=GetCurrentScriptDirectory~"IMG\Cirno.png";
let Baka2=GetCurrentScriptDirectory~"IMG\Daiyousei.png";
@Initialize{
LoadGraphic(MenuBG);
LoadGraphic(Baka);
LoadGraphic(Baka2);
}
[...]
@DrawLoop{

SetTexture(MenuBG);
SetGraphicRect(0,0,400,480);
SetAlpha(255);
DrawGraphic(GetCenterX,GetCenterY);

DrawText("Idiot",GetCenterX,GetCenterY,15,alph1);
DrawText("Triple Idiot",GetCenterX,GetCenterY-20,15,alph2);
DrawText("EXIT",GetCenterX,GetCenterY-60,15,alph3);
if(Selection==0){alph1=255; alph2=150; alph3=150; alph4=0; alph5=0;}
if(Selection==1){alph1=150; alph2=255; alph3=150; alph4=0; alph5=0;}
if(Selection==2){alph1=150; alph2=150; alph3=255; alph4=0; alph5=0;}
if(Selection==0&&warning==1){alph4=255}
if(Selection==1&&warning==1){alph5=255}
if(Selection>2){Selection=2}
if(Selection<0){Selection=0}

SetTexture(Baka);
SetGraphicRect(0,0,128,128);
SetAlpha(alph4);
DrawGraphic(GetCenterX-64,GetCenterY);

SetTexture(Baka2);
SetGraphicRect(0,0,128,128);
SetAlpha(alph5);
DrawGraphic(GetCenterX-64,GetCenterY-20);
}

}
I am seriously too dumb for menu scripting, I think.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 31, 2010, 12:38:01 AM
Nothing appearing as in...?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Danielu Yoshikoto on March 31, 2010, 12:41:48 AM
Nothing appearing as in...?

Only Standart Danmakufu Stage Background and Player.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 31, 2010, 12:47:22 AM
@DrawLoop does not work for stage scripts. You need to throw all your drawing functions in @BackGround. The reason why nothing errors is because Danmakufu just completely ignores the @DrawLoop in stage scripts.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Danielu Yoshikoto on March 31, 2010, 12:51:41 AM
@DrawLoop does not work for stage scripts. You need to throw all your drawing functions in @BackGround. The reason why nothing errors is because Danmakufu just completely ignores the @DrawLoop in stage scripts.

Thanks for the help.
I will be sure to not credit you for the help with the menu.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on March 31, 2010, 01:16:50 AM
@DrawLoop does not work for stage scripts. You need to throw all your drawing functions in @BackGround. The reason why nothing errors is because Danmakufu just completely ignores the @DrawLoop in stage scripts.

How about @MainLoop?
Do effect objects work in @MainLoop?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 31, 2010, 02:33:24 AM
Yes they do. When you yield out of a @MainLoop to tasks, Danmakufu still treats it as if you're still in the @MainLoop, which is why you can't draw things using DrawGraphic or anything like that in tasks. If you yield out of your @DrawLoop, you can (in enemy scripts and whatever). Same with yielding out of the @BackGround.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on March 31, 2010, 03:17:27 AM
So uh then, what exactly does MainLoop have over DrawLoop anyways?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 31, 2010, 03:30:12 AM
So uh then, what exactly does MainLoop have over DrawLoop anyways?

Spawns bullets.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on March 31, 2010, 03:39:25 AM
I think you can still shoot bullets with the DrawLoop though...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on March 31, 2010, 03:59:19 AM
So you can. Well, @MainLoop is force ran at 60 fps. So there.

Don't make me try to justify Danmakufu's way of doing things.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 31, 2010, 08:40:09 AM
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... Should I make my own task for declaring LastSpell like
Code: [Select]
let playerlife=GetPlayerLife;

function HitCheck //to be called every frame in @MainLoop
{
ForbidBomb(true);
if(OnPlayerMissed==true)
{
AddLife(-GetLife);
}
}

function BonusCheck //to be called in @Finalize
{
ForbidBomb(false);
if(GetPlayerLife<playerlife)
{
ExtendPlayer(1);
return false;
}else{
return true;
}
}
Code: [Select]
@MainLoop
HitCheck;
...etc...
@Finalize
if(BonusCheck==true)
{
AddScore(blah);
}
...
wait... why did I even post this if I already thought of a workaround... guess it's me being too lazy to edit 200 notepad files :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Danielu Yoshikoto on March 31, 2010, 10:28:46 AM
Is there a way to check if the player was hit/used a bomb while LastSpell is activated[...]

Wasn?t there this simple "LastSpell" function you can call in initialize?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on March 31, 2010, 10:36:08 AM
Wasn?t there this simple "LastSpell" function you can call in initialize?

I was using that... but apparently I can't check if the player was hit unless you use SetScore(value) then put if(GetSpellCardBonus==true) in @Finalize... but my question was... how do you check if you didn't use SetScore...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on March 31, 2010, 04:47:14 PM
Why would you need to check for LastSpell if the pattern isn't even a card in the first place?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on April 01, 2010, 02:53:44 AM
I've got another little situation that I need help with. Basically I need to find the distance between an object and the player so that the object can behave differently when in close proximity to it.

My first attempt was ugly and would have only acted in a square around the player. There was something wrong with it, though,  and it seemed like too much of a hassle to try and fix. Next, I tried looking for a function that could just find the distance for me, to no avail. Then I realized that I could just make my own using the distance formula (hooray for geometry) but I don't know how to tell danmakufu to find the square root of a number. (I'm assuming that ^ will work for exponents.)

If someone knows how to do that, or a function that I overlooked, some insight would be much appreciated.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on April 02, 2010, 03:28:25 AM
Why would you need to check for LastSpell if the pattern isn't even a card in the first place?

I made my own Score function... so yeah... it's a card... just... danmakufu doesn't think it is :V

I've got another little situation that I need help with. Basically I need to find the distance between an object and the player so that the object can behave differently when in close proximity to it.

My first attempt was ugly and would have only acted in a square around the player. There was something wrong with it, though,  and it seemed like too much of a hassle to try and fix. Next, I tried looking for a function that could just find the distance for me, to no avail. Then I realized that I could just make my own using the distance formula (hooray for geometry) but I don't know how to tell danmakufu to find the square root of a number. (I'm assuming that ^ will work for exponents.)

If someone knows how to do that, or a function that I overlooked, some insight would be much appreciated.

^0.5 raised to the 0.5 is the same as getting the square root...

It's so nice to have MotK back :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on April 02, 2010, 03:58:44 AM
 :o I didn't know that. Wow...

Thanks a bunch. That will definitely be a useful tidbit to know from now on...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan 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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel 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);
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on April 03, 2010, 06:24:30 PM
That's how I figured it always worked man D:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nobu on April 03, 2010, 08:28:13 PM
Umu.. what's the difference between a task and a function?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon 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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on April 03, 2010, 10:19:03 PM
Still gotta remember that a function can return a value.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon 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";
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou 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.
(http://www.curiousexpeditions.org/phi-spiral.jpg)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline 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;
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on April 09, 2010, 03:01:17 AM
turn = something;

turn*=0.9;
setangle(getangle+turn);
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on April 09, 2010, 06:36:43 AM
Thank you. Both worked wonderfully.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: ChaoStar on April 12, 2010, 02:17:48 PM
So uh, how do I make a nice, perfect double helix shape? Like in SA.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan 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.

 ;)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: ChaoStar on April 12, 2010, 05:13:48 PM
Thank you. ^__^
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: ChaoStar on April 13, 2010, 03:04:20 PM
does GetEnemyShotCountEx  detect lasers?

Just wondering.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel 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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: ChaoStar 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
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky 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...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel 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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky 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
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nobu on April 14, 2010, 04:28:47 AM
I swear, Danmakufu is so finicky sometimes. :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut 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
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nobu on April 14, 2010, 05:14:59 AM
Whoa Naut, that makes complete sense. I think my programmer level just went up.  :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky 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
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou 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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut 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
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou 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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nobu 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'
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou 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"
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake 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.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on April 15, 2010, 09:46:27 PM
Aaaah, so the function I'm looking for is 'ToString'.
But would an array work if I were to just plug it in? Or would I have to use the function 'ToString' each time?
For example,

Code: [Select]
let v=5;

LoadGraphic(image[v]);

Would it ignore the array and load the picture named 'image[v]' because it doesn't recognize the array because there's no 'ToString' function? By the sound of it, I'm going to have to use ToString everytime I want to deal with variables and strings.

By the way, would LoadGraphic(image~ToString(v)) work? Or, will I have to use "" to label what's the string, so LoadGraphic("image"~ToString(v));
Also, what if I want to use "" in my string?  lets say the variable is I'm using is "v" .   Could I just go on and plug in LoadGraphic("image"~ToString("v")); ?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on April 15, 2010, 10:01:13 PM
In theory, if your array image is an array that stores the paths of your image files as strings, image[n] will output the path of the respective image in form of a string. In that case LoadGraphic(image[n]); should work.

About the other stuff I have no clue.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on April 15, 2010, 10:17:23 PM
I guess I'll never know that one.
Alright, one last thing before I get back to work.
What do I do if I want a number in a number of specified digits? Lets say...4
So a function that normally return 5 will return 0005, or if it would return .05 to return 0.005
I want to avoid getting number that would normally return 15 return 00015. I would want that same function to return 0015 instead.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on April 15, 2010, 10:24:31 PM
I guess I'll never know that one.
Alright, one last thing before I get back to work.
What do I do if I want a number in a number of specified digits? Lets say...4
So a function that normally return 5 will return 0005, or if it would return .05 to return 0.005
I want to avoid getting number that would normally return 15 return 00015. I would want that same function to return 0015 instead.

Useful Miscellaneous Code Snippets (http://www.shrinemaiden.org/forum/index.php?topic=5164.0), first post.  ;)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on April 15, 2010, 10:27:30 PM
@Fujiwara No Mokou:

You can't name a variable with quotes in it, and even if you could, don't. ToString converts any other data type to a String. If you put quotes around anything, Danmakufu treats that (appropriately) as a String.

Code: [Select]
let v=5;
LoadGraphic(image[v]);

Would it ignore the array and load the picture named 'image[v]' because it doesn't recognize the array because there's no 'ToString' function? By the sound of it, I'm going to have to use ToString everytime I want to deal with variables and strings.

If the array "image" holds Strings in it, then you won't have to use ToString. For example:

let image = ["sound1.wav", "sound2.wav", "sound3.wav", "sound4.wav", "sound5.wav", "sound6.wav"];
let v = 5;
LoadGraphic(image[v]);

Will tell Danmakufu to load the graphic represented by the String in the 6th place of the array called image.

If the array held anything other than Strings, like numbers for example:

let image = [1, 2, 3, 4, 5, 6];
let v = 5;
LoadGraphic(image[v]);

This would error, because it's trying to load a number as a graphic (the 6th place in the array image is a number), which isn't possible. So you'd need to convert that number to a String so it would be read properly:

let image = [1, 2, 3, 4, 5, 6];
let v = 5;
LoadGraphic(ToString(image[v]));

Now this probably wouldn't do anything because you're trying to load a file called "6.000000" in your root directory, which probably doesn't exist. So in my example, I added GetCurrentScriptDirectory to add a larger pathname to the file, and I also added ".png" to the end of the string to make sure it knows what file to load, specifically. ~ concatenates Strings.

Quote
By the way, would LoadGraphic(image~ToString(v)) work? Or, will I have to use "" to label what's the string, so LoadGraphic("image"~ToString(v));

No, neither would work. if image is a String:

let image = "effect";

Then you would have the following in the first example:

let v = 5;
let image = "effect";
LoadGraphic(image~ToString(v));

Loading a graphic called "effect5.000000". All numbers are stored as the long data type in danmakufu, so converting any number to a string shows all the decimal places. In my previous example (http://www.shrinemaiden.org/forum/index.php?topic=4771.msg313441#msg313441), I added in code that shaves off all those needless decimal places.

For your second example, LoadGraphic("image"~ToString(v)); will load an image called "image5.000000", which is more wrong than the first example, heh. Again, Danmakufu treats everything inside quotes as a String, and it ignores any similarities the String may have with an existing variable.

Quote
Also, what if I want to use "" in my string?  lets say the variable is I'm using is "v" .   Could I just go on and plug in LoadGraphic("image"~ToString("v")); ?

Well, you can't start a variable name with a quote, so that's not possible. Disregarding the error I just mentioned regarding "image" being taken as a String instead of a variable, you'd still have to fix those quotes inside the strig by indicating to Danmakufu that those quotes do not end the String. There is a special character \ which indicates to Danmakufu that some letter near it is meant to be treated as part of the String and not as it's special character identity. I'd explain how to use it, but Danmakufu fucks it up so hard that I honestly am not sure if it treats the next letter as a String, or the letter before it (it should be the one after it, but fuck some example I've seen).

For example:

Say you want to display

Awesome Sign "You Are Screwed"

as a spellcard name. You'd need to have the following code in your CutIn:

CutIn(YOUMU, "Awesome Sign "\""You Are Screwed"\", "", 0, 0, 0, 0);
//the last five parameters are for the image, so ignore them

Now it looks like the \ character is correctly indicating that the character after it is to be displayed properly, but by that logic the string ends at

"Awesome Sign "

Which is no good. Going the other way, if the \ character indicates the letter before it is to be left in the String, the String should end at

"Awesome Sign ""

Which is even more >: |

So I ask this to more experienced programmers than I, how does this escape character work!?

What do I do if I want a number in a number of specified digits? Lets say...4
So a function that normally return 5 will return 0005, or a if it would return .05 to return 0.005
I want to avoid getting number that would normally return 15 return 00015. I would want that same function to return 0015 instead.

To display 00015, you would need to have it as a String. Numbers will automatically shave off all zeros before any non-zero number. So then you could just add zeros...:

let number = "000" ~ "15";

//number is now "00015"

Going the other way, you'd still need to convert the number to a String to prevent Danmakufu from displaying all six decimal places:

let number = 0.5;
let string = ToString(number);
//string is now equal to "0.500000"

loop(3){
   string = erase(string, length(string)-1);
}

//string now equals "0.500"

Useful Miscellaneous Code Snippets (http://www.shrinemaiden.org/forum/index.php?topic=5164.0), first post.  ;)

Drake's code adds commas and useless shit :V

EDITs: fixed my speedtypin' errors
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on April 15, 2010, 10:51:59 PM
I'm not looking for comas in place of decimals.
Actually, scratch what I asked. How do I get the number of digits in a given number? Is there even a function for that?
I'm looking at function int() and trunc() but I'm not sure what they do.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on April 15, 2010, 10:59:26 PM
I'm not looking for comas in place of decimals.
Read my post >: |

Actually, scratch what I asked. How do I get the number of digits in a given number? Is there even a function for that?
I'm looking at function int() and trunc() but I'm not sure what they do.

Convert it to a string, use length(String);

let number = 84368907;

let temp = "";

temp = ToString(number);

let digits = length(temp);

//digits is now equal to the length of temp, or 8.

int() does the same thing as trunc() and truncate(), which just elimates all the decimal places and converts them to zeroes. so:

int(5.2319);
trunc(5.2987);
truncate(5.21037);

All equal 5.000000.

I assume there was plans to include the int data type in Danmakufu, but instead mkm just decided to use all longs? Or does the int data type actually pop up anywhere? Nowhere I've seen, anyway.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on April 15, 2010, 11:06:38 PM
I thought function length() only works for arrays? It works for digits too? That's a surprise.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on April 15, 2010, 11:13:09 PM
Err, well it doesn't work for numbers. It does work for Strings and arrays, since to Danmakufu, they are the same thing. A String is just an array of characters.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on April 15, 2010, 11:30:26 PM
Would that mean

let arr=[t,e,s,t];
return arr
be the same as
return "test"  ?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on April 15, 2010, 11:38:38 PM
Would that mean

let arr=['t','e','s','t'];
return arr
be the same as
return "test"  ?

Fixed your notation, and yes, it would.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on April 16, 2010, 01:05:38 AM
Alright. I'll put this on pause for a while. Back to what I was trying to do-
your function earlier...
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
LoadGraphic doesn't load sounds
Where as this helps me load the files, I can't actually call them in DrawLoop.
Instead of writing SetTexture(GetCurrentScriptDirectory~"effect"~result~".png") I'd like to write SetTexture(effect1)
I try to use variables whenever I load stuff to make things easier for myself.

Problem, though, is,
Code: [Select]
ascent(i in 1..21){
let effect~i=GetCurrentScriptDirectory~"effect"~ToString(i)~".png";

  }
won't work. I need to find a way to attach numbers to the end of variables. Know a way to do that?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on April 16, 2010, 01:12:03 AM
He told you everything you need to. If it's not working, then you need to give more details rather than saying "it doesn't work."
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on April 16, 2010, 01:17:21 AM
He told you everything you need to. If it's not working, then you need to give more details rather than saying "it doesn't work."

you didn't read my post. I said what I was looking for. Did you look above the code, rather than just reading what was on the bottom?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on April 16, 2010, 01:23:01 AM
To attach numbers to the end of variables, you use that function he gave you again. The problem is that by default DMF loads numbers with 6 decimal places. Here's a modified version of that code:
Code: [Select]
function IntString(number){
   let str = ToString(number);
   let str2 = "";
   let i = 0;
   while (str[i] != '.')
   {
      str2 = str2 ~ [str[i]];
      i++;
   }
   return(str2);
}
Then just use IntString(number) in place of everywhere you use ToString. If you don't want to write
SetTexture(GetCurrentScriptDirectory~"effect"~IntString(var)~".png"); every time, just write a function for it:

Code: [Select]
function SetTextureNew(num){
SetTexture(GetCurrentScriptDirectory~"effect"~IntString(num)~".png");
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on April 16, 2010, 02:56:51 AM
I finally got Naut's function to work now.
This was useful too. But it wasn't really what I was looking for -when I said "attach numbers to variables".
My goal is, to be able to put in SetTexture(effect1); SetTexture(effect2);, or even have a function that can do that for me.
The actual string itself is represented by a variable. I'm looking for a way to easily define these variables as strings without having to put in tons of lines of code, and easily manipulate the variables themselves.

But first I want to know how Naut's function works.
What's really pondering me is what '.' means.
These two lines of code hard to follow.
while(number < length(string) && string[number] != '.'){
             result = result ~ ToString(string[number]);

What does '.' mean, and why does string[number] have to have the function ToString() when you have both string and number as arrays? I thought you can multiply those and end up with an array, and it wouldn't make a difference since arrays and strings are essentially the same thing.

Like you said, problem is that by default DMF loads numbers with 6 decimal places. But I can hardly even see how this is getting rid of those.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on April 16, 2010, 03:08:52 AM
I finally got Naut's function to work now.
This was useful too. But it wasn't really what I was looking for -when I said "attach numbers to variables".
My goal is, to be able to put in SetTexture(effect1); SetTexture(effect2);, or even have a function that can do that for me.
The actual string itself is represented by a variable. I'm looking for a way to easily define these variables as strings without having to put in tons of lines of code, and easily manipulate the variables themselves.

You can't loop the declaration of different variables.

But first I want to know how Naut's function works.
What's really pondering me is what '.' means.
These two lines of code hard to follow.
while(number < length(string) && string[number] != '.'){
             result = result ~ ToString(string[number]);

What does '.' mean, and why does string[number] have to have the function ToString() when you have both string and number as arrays? I thought you can multiply those and end up with an array, and it wouldn't make a difference since arrays and strings are essentially the same thing.

Like you said, problem is that by default DMF loads numbers with 6 decimal places. But I can hardly even see how this is getting rid of those.

"Blah" indicates a string, 'B' indicates a character. When you use brackets to get one letter out of a String, Danmakufu has that letter delcared as a char (represeneted by single quotes). The code I posted (which is Nuclear Cheese's, originally) will start at the very end of the number String, and keep deleting the last character until it hits a decimal (!= '.'), and will then return the String with everything after the decimal removed. I have to use ToString(string[number]) because it's returning me a char data type, when I want it to be a String so I can concatenate it to the String I want returned.

'b' != "b"
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on April 16, 2010, 03:37:37 AM
You can't loop the declaration of different variables.

"Blah" indicates a string, 'B' indicates a character.

"" Indicates strings and '' indicates characters.
Okay, so I get this part. By the way, how do you find out this stuff? It seams like you know hidden info.  Things like '' "" % += I don't really know where to find them anywhere.

Anyway, here's the part I don't get.
The code I posted will start at the very end of the number String, and keep deleting the last character until it hits a decimal (!= '.'), and will then return the String with everything after the decimal removed.

But where in the code is it doing that?
I don't see where it's saying "start at the beginning of the number string" either (is there a way to make it start at the end of the number string and add or erase characters there?), and I thought the function erase() deletes characters in arrays. I don't see that anywhere.

Forgive me if I'm being blind, but I have a hard time following this. If in the given ascent loop, variable 'i' is 1.00000, and number is 0.00000, what happens from there?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on April 16, 2010, 03:39:39 AM
Er, my mistake, the code starts at the beginning of the string and copies them to another one, until it hits a decimal (effectively deleting all the post decimal contents).

Here's a trace:

  let string = "" ~ ToString(i);
      let number = 0;
      let result = "";
      while(number < length(string) && string[number] != '.'){
             result = result ~ ToString(string[number]);
             number++;
      }

First iteration of the while loop,
number = 0;
result = "";
so we'll copy a value to result from string, which is string[number] (or string[0]), which equals 1:
result = result ~ ToString(string[number]);
result = "" ~ ToString(string[number]);
result = "" ~ ToString(string[0]);
result = "" ~ ToString('1');
result = "" ~ "1";
result = "1"

Next iteration of the while loop,
number = 1;
result = "1";

string[number]=='.' now, so the loop stops here.

If there was more than one digit before the decimal, the code would keep concatenating characters to the end of result until it hits the decimal.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on April 16, 2010, 03:47:45 AM
Edited my question and added another one.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nobu on April 16, 2010, 03:51:00 AM
Okay, so I get this part. By the way, how do you find out this stuff? It seams like you know hidden info.  Things like '' "" % += I don't really know where to find them anywhere.

Danmakufu is a programming language with syntax based on C(++), so you can find that sort of hidden info by learning how to program.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on April 16, 2010, 03:54:51 AM
Added a trace.

Quoted from my above post...


Here's a trace:

  let string = "" ~ ToString(i);
      let number = 0;
      let result = "";
      while(number < length(string) && string[number] != '.'){
             result = result ~ ToString(string[number]);
             number++;
      }


First iteration of the while loop,
number = 0;
result = "";

All while checks are true, number is less than the length of string and string[number]!='.'.
So we'll copy a value to result from string, which is string[number] (or string[0]), which equals 1:
result = result ~ ToString(string[number]);
result = "" ~ ToString(string[number]);
result = "" ~ ToString(string[0]);
result = "" ~ ToString('1');
result = "" ~ "1";
result = "1"


Next iteration of the while loop,
number = 1;
result = "1";


string[number]=='.' now, so the loop stops here.

If there was more than one digit before the decimal, the code would keep concatenating characters to the end of result until it hits the decimal.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on April 16, 2010, 04:57:41 AM
Oh, I get it. So basically, it's copying the character digits from string A , which has a value with unwanted digits to string B, which holds no value in it  "", until it hits the character ' . ' which happens to be a decimal.
Clever. And I didn't know multiplying a string by array will give you the value of a character of the defined array.  "3"[1]= '3'.  Would this mean "3"[2] give you an error, since there is no second character?
I didn't know      "" ~ ToString('1');  =    "" ~ ToString(1);     either.   I thought it would it would be   "'1'" and "1" , because there would be a difference in putting in ''
Or am I messing up somewhere?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on April 16, 2010, 05:12:37 AM
"3"[1] would error. "3"[0] would give '3'.

Note that this isn't multiplying. It's standard array notation. Strings by definition are arrays of characters accessible as a bundle.

array = ['a',1,2,87,'b'];
array[0] gets the entry at location 0, which is 'a'.
array[3] gets the entry at location 3, which is 87.

string = "derp";
string[0] gets the entry at location 0, which is 'd'.

array = [[0,1],[2,3],[4,5]];
array[2][0] gets the entry at location 0 of the entry at location 2, which is 4.

array = ["okay","asdasd","derp"];
array[1][3] gets 'a'. array[2][2] gets 'r'.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on April 16, 2010, 05:13:58 AM
And I didn't know multiplying a string by array will give you the value of a character of the defined array.
Uhhh, there's so much wrong with that statement I don't even know where to begin. You seem to have a fundamental misunderstanding about array notation. You aren't multiplying an array with an array to get the data out, you're just indicating which index to look at when you put a number in square brackets after an array. For example:

let array = [1, 2, 3, 4, 5];
let newVariable = array[0];


newVariable would contain the number 1 now. Note that, array[0] is NOT the same as array*[0]. The latter would give an error. Now, on the same line of thought, a string is just an array of characters and so you can still put a number in square brackets to get the character out. As a side note, and I'm sure this has already been mentioned previously, Danmakufu considers the use of double quotes ( " ) as an indication that the characters between them is a string. If you use single quotes ( ' ), then it is a character (and obviously cannot be longer than one character long). This means that "a" does not equal 'a'.

Quote
"3"[1]= '3'.  Would this mean "3"[2] give you an error, since there is no second character?
Or am I messing up somewhere?

Following what I was saying earlier, "3"[1] would actually raise an error because the first element in an array is actually [0], not [1]. "3"[ 0 ] would equal '3' and any other number besides 0 would raise an error because the array is not that long.

Quote
I didn't know      "" ~ ToString('1');  =    "" ~ ToString(1);     either.   I thought it would it would be   "'1'" and "1" , because there would be a difference in putting in ''

Because Danmakufu treats single quotes as a keyword indicating a character, putting '1' into a function will result in Danmakufu interpreting it as a character, not as a string storing '1'. You forget that outside of double quotes, nothing is considered a string, just keywords and data.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on April 16, 2010, 05:38:22 AM
I see. So it actually starts at 0.
Sorry, I didn't know how arrays worked.
So, thinking logically, "text"=['t','e','x','t']
That would explain a lot.

Quote from: Drake
array = ["okay","asdasd","derp"];
array[1][3] gets 'a'. array[2][2] gets 'r'.

This confuses me. Where's the math in that?

EDIT: Oh, wait, nevermind. I see what you did there.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on April 16, 2010, 06:01:55 AM
Sounds like you got it. Just for the sake of completeness,

array = ["okay","asdasd","derp"];
array[1][3] == "asdasd"[3] == 'a'
array[2][2] == "derp"[2] == 'r'


Oh I just noticed this:
array = ['a',1,2,87,'b'];
array[0] gets the entry at location 0, which is 'a'.
array[3] gets the entry at location 3, which is 87.
Although this array is legal in some languages, Danmakufu will not allow numbers and strings to be stored in the same array. There are a lot of rules governing arrays inside arrays as well in Danmakufu but that's a bit more advanced.

EDIT: Oh wait those are characters, not strings. Strangely Danmakufu stores characters as numbers so that's fine in an array I guess... I haven't tested that.  :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on April 16, 2010, 08:15:32 AM
Double posting 'cause it's not really related to my previous post.

Hey I figured this out. Now you can have mixed value arrays. Only problem is that since you have to use these functions, you're gonna need some extra processing power. I don't think it'll be very much though. Basically you turn the strings into arrays of numbers representing the ascii code and then turn them back when you need the strings again. Because the strings get converted into arrays of numbers, you can't directly store the converted strings in with other numbers. Instead you'll have to put the numbers in an array on their own and stick that array in with the converted strings. When you need the strings back, just convert them back with the other function.

I don't think anyone will ever actually use this, but whatever.

 
  function StringToNumberArray(string){
    let array = [];
    ascent(i in 0..length(string)){
      array = array ~ [CharacterToNumber(string[i])];
    }
    return array;
  }
 
  function NumberArrayToString(array){
    let string = "";
    ascent(i in 0..length(array)){
      string = string ~ [NumberToCharacter(array[i])];
    }
    return string;
  }
 
  function CharacterToNumber(char){
    return floor(char);
  }
 
  function NumberToCharacter(num){
    let chars = [' ', '!', '"', '#', '$', '%', '&', "'"[0], '(', ')', '*', '+', ',', '-', '.', '/',
                 '0', '1', '2', '3', '4', '5', '6', '7'   , '8', '9', ':', ';', '<', '=', '>', '?',
                 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G'   , 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
                 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W'   , 'X', 'Y', 'Z', '[', '\', ']', '^', '_',
                 '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g'   , 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
                 'p', 'q', 'r', 's', 't', 'u', 'v', 'w'   , 'x', 'y', 'z', '{', '|', '}', '~'];
    return chars[num-32];
  }


Yes I could've stored the characters in a string instead of an array (same thing), but I couldn't remember how to escape a double quote.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on April 19, 2010, 03:01:28 AM
This sort of isn't a real question, but in my latest script (http://bulletforge.org/u/elementoid/p/sburb-sburban-lotus-spira/v/1), there seem to be some inherent problems with the math, the main one I've noticed being when you try to give it 5 "leaves," and it gets cut off.

I think the problem might be that it ends up dividing circlenum (which has a value of 72) by leaf (in this case 5, resulting in a non-integer) and this is messing things up? And if that's the case, is there really any way for me to try and fix it without permanently defining one of the variables?

I apologize for having such a petty problem. I'm still not really good at any of this stuff yet...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Hyouga Kazu on April 19, 2010, 04:50:33 AM
Danmakufu doesn't see the difference between integers and doubles, so dividing 72 by 5 would result in 14.4.
Maybe you could post your script here so we can check it for other errors, because sometimes it's just a small error you never expected to make.  ;)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on April 19, 2010, 10:00:06 AM
After some testing I have com to the conclusion that the problem lies in these lines of code:

Code: [Select]
let distmax = (leafbullets/2)*distinc;
Code: [Select]
if(dist>=distmax){
dec=true;
}
Code: [Select]
if(dec==false){
dist+=distinc;
}
if(dec==true){
dist-=distinc;
}

What happens is the following: If the expression (leafbullets/2) is not an integer, then the code that changes the dist variable can not reach the points at which the direction changes without overshooting the mark. To overshoot, it needs an additional run of the loop. That means that the dist variable will "lag" behind the other parts of the script that forms a blossom, and the amount by which it lags behind increases with each additional leaf. When the blossom comes full circle, the accumulated difference in distance becomes clearly visible.

The solution:
Make shure that  (leafbullets/2)  is always an integer.  ;)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on April 19, 2010, 10:13:45 PM
So I suppose there's really no way of fixing it aside from permanently defining something so that it always came out as an integer. Oh well.

Thanks for helping me figure it out, anyways.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade on April 19, 2010, 10:37:03 PM
There (http://dmf.shrinemaiden.org/wiki/index.php?title=Mathematical_or_Information_Functions#truncate) are (http://dmf.shrinemaiden.org/wiki/index.php?title=Mathematical_or_Information_Functions#round) other (http://dmf.shrinemaiden.org/wiki/index.php?title=Mathematical_or_Information_Functions#ceil) options (http://dmf.shrinemaiden.org/wiki/index.php?title=Mathematical_or_Information_Functions#floor) to make integer values, you know.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on April 19, 2010, 10:49:56 PM
Well, changing the code to round(leafbullets/2) will minimize the difference, but it won't remove it.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on April 19, 2010, 10:54:40 PM
I didn't even know any of those functions existed. Clearly I need to spend more time lurking on the function pages. *newbnewbnewb*

Thanks for the help.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on April 21, 2010, 12:25:10 AM
What determines the hitbox size of a non-script bullet / object, and is there any way to set it?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on April 21, 2010, 12:34:21 AM
Half the size of the circle contained by the average of the horizontal and vertical graphic rects of your bullet image. For example, if your graphic has a rect of (0, 0, 64, 64), the hitbox would be a circle at the center of the bullet with a radius of 16. If your rect was (0, 0, 32, 64), the circle would have a radius of 12. Or at least, this is a good approximation :V

And no, you cannot set it unless it's an object or script bullet.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on April 21, 2010, 12:53:56 AM
I'm pretty sure it takes half of width or height (whatever is smaller), rather than the average. If you want to set it manually, either make the graphic rect bigger/smaller, or make an object bullet, turn off collision (Obj_SetCollisionToPlayer(false); I think), and manually check distance from the bullet to the player - make sure you also check if they're invincible or not if you do that, though.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on April 21, 2010, 01:00:53 AM
I'm going to note that deathbombing will not work if you use ShootDownPlayer with that method (which is pretty much the only way to able to use it), so I wouldn't really suggest it.

If you really wanted to, you could check the custom radius, play the sound effect and wait a frame before killing the player.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on April 21, 2010, 01:12:36 AM
I'm pretty sure it takes half of width or height (whatever is smaller), rather than the average.

I originally thought that was well, but then I thought about more rectangular bullets like the knives (or Johnny Walker's Tenshi rocks), which have a really large hitbox for their estimated width. It's like that for any rectangular bullet actually, as long as it isn't a laser.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on April 21, 2010, 03:37:03 AM
I originally thought that was well, but then I thought about more rectangular bullets like the knives (or Johnny Walker's Tenshi rocks), which have a really large hitbox for their estimated width. It's like that for any rectangular bullet actually, as long as it isn't a laser.

I had a 128 by 16 bullet once (don't ask why), and only the center had collision - no hitbox outside the graphic, either. Maybe those rectangular bullets have square graphic rects (extending past the actual sides of the bullet), so that makes the hitbox bigger?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on April 21, 2010, 04:42:05 AM
I suppose that is a possibility :< Makes sense. Would be nice to set custom hitboxes, though.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on April 21, 2010, 08:45:50 AM
If you feel like using Bullet Scripts (http://dmf.shrinemaiden.org/wiki/index.php?title=Bullet_Script_Functions), you can manually set the collision size, but that's a pretty big pain in my opinion.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on April 21, 2010, 06:44:27 PM
They're also incredibly slow. It's like spawning an individual enemy every bullet you fire.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on April 22, 2010, 08:07:39 PM
Code: [Select]
#TouhouDanmakufu
#Title[Spell Template]
#Text[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {

let BossImage="script\ExRumia\img\ExRumia.png";
let BossCutIn="";

#include_function "lib\SHOT_REPLACE\shot_replace.dnh"
function wait(let frames){ loop(frames){yield;} }

//////////

@Initialize {
LoadGraphic(BossImage);

shotinit;

SetLife(5000);
SetDamageRate(100,100);
SetTimer(60);
SetInvincibility(120);
SetScore(500000);
SetEnemyMarker(true);

CutIn(YOUMU, "x"\""x"\", BossCutIn, 0, 0, 0, 0);

SetMovePosition03(GetCenterX, GetCenterY-100, 20, 20);

Shot2;
}

//////////

@MainLoop {
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 24);
yield;
}

//////////

@DrawLoop {     
SetColor(255,255,255);
SetRenderState(ALPHA);
SetTexture(BossImage);
SetGraphicRect(64,1,127,64);
DrawGraphic(GetX,GetY);

}

//////////

@Finalize {

}

//////////

task Shot2{
wait(30);

let ang = -90;
let dir = 1;
let angchange;

loop{
angchange = 0.5;
loop(50){
loop(7){
WallBullet(ang);
ang -= 360/7;
}
ang += angchange * dir;
angchange -= 0.01;
wait(2);
}
dir = dir*-1;
yield;
}
}

task WallBullet(ang){
let obj=Obj_Create(OBJ_SHOT);

let bounce = 0;

Obj_SetPosition(obj, GetX+5*cos(ang), GetY-30+5*sin(ang));
Obj_SetSpeed(obj, 3.7);
Obj_SetAngle(obj, ang);
ObjShot_SetGraphic(obj, BLUE23);
ObjShot_SetDelay(obj, 5);
ObjShot_SetBombResist(obj, false);

while(!Obj_BeDeleted(obj)){
if(Obj_GetX(obj)<GetClipMinX && bounce==0){
CreateShot01(Obj_GetX(obj), Obj_GetY(obj), 3.3, 180-Obj_GetAngle(obj), GREEN23, 5);
bounce++;
}
if(Obj_GetX(obj)>GetClipMaxX && bounce==0){
CreateShot01(Obj_GetX(obj), Obj_GetY(obj), 3.3, 180-Obj_GetAngle(obj), GREEN23, 5);
bounce++;
}
if(Obj_GetX(obj)<GetClipMinY && bounce==0){
CreateShot01(Obj_GetX(obj), Obj_GetY(obj), 3.3, 360-Obj_GetAngle(obj)-180, GREEN23, 5);
bounce++;
}
yield;
}
}

///
}

Sorry about the bother, but I'm having trouble with this script.
I want streams of bullets to alternate moving left and right, but the clockwise movement seems greater than the counterclockwise. The streams basically don't stay within the same place, and they can shift greatly if you wait long enough. Over time, this leads to an inevitable death.

I've exaggerated the script to make this more easily seen. Any help?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on April 22, 2010, 08:31:36 PM
I don't see the shifting that you're talking about in the script you posted. I measured the angles by turning on invincibility and planting the player at a place where the bullets would switch directions and held spacebar. The shifting didn't occur.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on April 22, 2010, 09:24:24 PM
Woah. I had no idea you could use the spacebar like that.

But anyway, when I use it, the streams are moving the way I described them.

Maybe I didn't say it well enough? I want a stream to move from one point to another. But this doesn't seem to work - The streams do it for a while, but eventually it doesn't work anymore. In fact, one stream will eventually go straight down 90 degrees.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade on April 22, 2010, 11:17:58 PM
Every time I try to run this, I get some weird error message about tasks and subs or something. What's wrong?

Code: [Select]
#TouhouDanmakufu
#Title[test_06]
#Text[...]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{

let CSD = GetCurrentScriptDirectory;
let shotfx = CSD ~ "sfx\tan0.wav";
let shotfx2 = CSD ~ "sfx\shot3.wav";
let lasfx = CSD ~ "sfx\laser01.wav";

@Initialize{
LoadUserShotData(CSD ~"Data\supershot.txt");
SetLife(1900);
SetTimer(80);
SetScore(700000);
SetDamageRate(45,60);
LoadSE(shotfx);
LoadSE(shotfx2);
LoadSE(lasfx);
MagicCircle(false);
SetText("test_05");
SetPlayerInvincibility(9999);

SetMovePosition03(GetCenterX,GetCenterY,1,100);
test;
}

@MainLoop{
SetCollisionA(GetX,GetY,60);
SetCollisionB(GetX,GetY,16);
yield;
}

@DrawLoop{
yield;
}

@BackGround{
yield;
}

@Finalize{
DeleteSE(shotfx);
DeleteSE(shotfx2);
DeleteSE(lasfx);
yield;
}

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

// In any given triangle, this function finds one side of a triangle using the angle opposite of it and the two sides that make that angle.
// It uses a derived form of the law of cosines.

function sidefinder(a, anglegiven, b){
return (a^2 + b^2 - 2 * a * b * cos(anglegiven)) ^ 0.5;
}

// In any given triangle, this function finds one angle of a triangle using the sides next to it, then the side opposite of it.
// It uses a derived form of the law of cosines.

function anglefinder(a, b, c){
return acos((-1 * (c ^ 2 - (a ^ 2 + b ^ 2))) / (2 * a * b));
}

task statlaser(x, y, angle, laslength, laswidth, graphic, delay){
let obj = Obj_Create(OBJ_LASER);
Obj_SetPosition(obj, x, y);
Obj_SetSpeed(obj, 0);
Obj_SetAngle(obj, angle);
ObjLaser_SetLength(obj, laslength);
ObjLaser_SetWidth(obj, laswidth);
ObjShot_SetGraphic(obj, graphic);
ObjLaser_SetSource(obj, false);
ObjShot_SetDelay(obj, delay);
ObjShot_ToItem(obj, true);

wait(360);
ObjShot_FadeDelete(obj);
}

task test{
wait(300);
testpattern;
}

task testpattern{
loop(
statlaser(GetCenterX, GetCenterY, 0, 30, 5, WHITE01, 0);
statlaser(GetCenterX, GetCenterY, 90, 40, 5, WHITE01, 0);
statlaser(GetCenterX+30, GetCenterY, anglefinder(30, sidefinder(30, 40, 90), 40) , sidefinder(30, 40, 90), 5, WHITE01, 0);
wait(599);
yield;
}
}
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on April 22, 2010, 11:25:25 PM
Code: [Select]
function sidefinder(a, anglegiven, b){
      return (a^2 + b^2 - 2 * a * b * cos(anglegiven)) ^ 0.5;
   }

should be

Code: [Select]
function sidefinder(a, anglegiven, b){
      return ( (a^2 + b^2 - 2 * a * b * cos(anglegiven)) ^ 0.5);
   }
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade on April 22, 2010, 11:32:06 PM
Tried it. Didn't work, but I think that would have caused other problems anyways, so thanks.
I also tried moving around the different tasks and functions at the end of the script, and I found that

Code: [Select]
function sidefinder;
function anglefinder;
task test;
task testpattern;
task statlaser;

gives out a different type of error code, this time about statlaser. However, that doesn't make sense because I'm using it in another script, and it seems fine.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on April 22, 2010, 11:38:19 PM
When you get the error, pressing ctrl+c should save the error text so you can post it here for everyone to examine. It makes spotting the errors much easier.

On an unrelated note, I don't think there should be yield;s in you @BackGround and @DrawLoop.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade on April 22, 2010, 11:56:44 PM
What is this I don't even (http://img140.imageshack.us/img140/9853/subtaskerrorthing.jpg)

And the second error message is the standard something isn't right with the task thing (http://img697.imageshack.us/img697/8013/thisthing.jpg)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on April 23, 2010, 12:01:06 AM
Ah, found it.


Quote
   task testpattern{
      loop(
         statlaser(GetCenterX, GetCenterY, 0, 30, 5, WHITE01, 0);
         statlaser(GetCenterX, GetCenterY, 90, 40, 5, WHITE01, 0);
         statlaser(GetCenterX+30, GetCenterY, anglefinder(30, sidefinder(30, 40, 90), 40) , sidefinder(30, 40, 90), 5, WHITE01, 0);
         wait(599);
         yield;
      }
   }
that bracket should be a {. Because it isn't, danmakufu misinterprets the code in a weird way.


It is generally helpful to always look one or two lines before the line danmakufu errors on because faulty use of brackets or semi colons will often make it read the seperate statements in different lines as one single statement.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on April 24, 2010, 12:35:13 AM
Hm, I've been working on a different project ever since my Internet became really shitty.
I've finished about an eighth of it already, and I'm trying to do something that changes according to how many continues the player has used.
Is there a function to do that? Continued; only returns weather whether the player has continued or not.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: GenericTouhouFailure on April 24, 2010, 02:18:05 AM
HALP! I f***ed Up bad! Danmakufu Hates me!
---------------------------
ScriptError
---------------------------
ファイルが見つかりません
(C:\_DataFolder\*Censored*\th_dmh\script\UUC\enemy\Enemy1.txt)
---------------------------
OK   
---------------------------

I didn't find the translation anywhere.
Fake Edit: when transated. says

---------------------------
ScriptError
---------------------------
File Not Found
(C:\_DataFolder\*Censored*\th_dmh\script\UUC\enemy\Enemy1.txt)
---------------------------
OK
---------------------------
somehow Danmakufu hates reading my file.... (it exists)
Is is vista that causes this sh*t?
(same goes for music files, not sound effects, music files, it just refuses to play. Not even CtC is free from this glitch...)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on April 24, 2010, 02:47:24 AM
HALP! I f***ed Up bad! Danmakufu Hates me!
---------------------------
ScriptError
---------------------------
ファイルが見つかりません
(C:\_DataFolder\*Censored*\th_dmh\script\UUC\enemy\Enemy1.txt)
---------------------------
OK   
---------------------------

I didn't find the translation anywhere.
<insertloltranslationhere>
somehow Danmakufu hates reading my file.... (it exists)
Is is vista that causes this sh*t?
(same goes for music files, not sound effects, music files, it just refuses to play. Not even CtC is free from this glitch...)
Eh, you *did* take a look at this (http://www.shrinemaiden.org/forum/index.php?topic=4155.0), right?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: GenericTouhouFailure on April 24, 2010, 03:01:38 AM
Eh, you *did* take a look at this (http://www.shrinemaiden.org/forum/index.php?topic=4155.0), right?
I actually *did* but somehow didn't find the solution. I claims to "Not find" my file even though it is there. FDIZASDFGHIGK RAGE >:(
*triple Checks for spelling errors...* Nope.... None..
strange...
I put the enemy to replace the one in ExRumia and it works....
Fake Edit again: Oh wow.. with abit of copyandpasting It works... thanks anyways.. (*whacks head for stupidity*)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on April 24, 2010, 03:16:09 AM
I actually *did* but somehow didn't find the solution. I claims to "Not find" my file even though it is there. FDIZASDFGHIGK RAGE >:(
*triple Checks for spelling errors...* Nope.... None..
strange...
I put the enemy to replace the one in ExRumia and it works....
Fake Edit again: Oh wow.. with abit of copyandpasting It works... thanks anyways.. (*whacks head for stupidity*)
Ah.
Where is the file you summon the enemy from and what do you call to summon the enemy (Yes, that CreateEnemyFromFile function, what did you put there)?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: GenericTouhouFailure on April 24, 2010, 03:23:41 AM
After checking again. it was a stupid TYPO Lol!
that happens soo many times
@Drawloop and @DrawLoop
(captial L)
in this case...
"Enemy1.txt" vs "Enemy01.txt"
FU-
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on April 24, 2010, 03:26:55 AM
After checking again. it was a stupid TYPO Lol!
that happens soo many times
@Drawloop and @DrawLoop
(captial L)
in this case...
"Enemy1.txt" vs "Enemy01.txt"
FU-
Hurrrrrrrrrr why must Danmakufu be so specific
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on April 24, 2010, 03:34:04 AM
Hurrrrrrrrrr why must Danmakufu be so specific

Because ambiguous code sucks.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on April 24, 2010, 03:40:30 AM
How is it supposed to know you mean "01" when you just type "1"? Name all your files/variables with the same convention and you shouldn't have that problem.
(Though I admit that I've screamed at it a few times too...)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on April 24, 2010, 09:02:32 PM
Is there a difference in whether you change an attack's amount of health, or if you change the enemy's damage-taken ratio? Like, maybe in how the life bar looks or works?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on April 24, 2010, 09:16:55 PM
Is there a difference in whether you change an attack's amount of health, or if you change the enemy's damage-taken ratio? Like, maybe in how the life bar looks or works?

It changes the length of the health bars. The usual Touhou process is a high-health nonspell, followed by a spellcard with low health but high damage resistance that fades over time. A lot of Danmakufu users emulate this with delayed tasks that set the damage resistance lower and lower over time.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: GenericTouhouFailure on April 25, 2010, 01:06:24 PM
Danmakufu Hates Me Epic(not)sode 2

All scripts with music WONT PLAY.
Even CtC!
Any Halp?
I use vista.
Also, if i get any halp I can't try it until next weekend when I get to use a PC again... :(

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on April 25, 2010, 05:56:03 PM
Danmakufu Hates Me Epic(not)sode 2

All scripts with music WONT PLAY.
Even CtC!
Any Halp?
I use vista.
Also, if i get any halp I can't try it until next weekend when I get to use a PC again... :(

Gonna have to be a bit more specific. When does Danmakufu crash (if at all)? If music was the issue then the script would play normally, you just wouldn't hear anything.

Anyway, I have a hueg problem of my own:

(code)

There is nothing wrong with your code, other than being inefficient. Post the whole file.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on April 25, 2010, 07:43:46 PM
How about that? Pretty sure that that might be the problem.

Anyway, I have a hueg problem of my own:

Code: [Select]
This piece of code creates a
---------------------------
ScriptError
---------------------------
script_enemy_main内で
「{...}」が対応していません。
---------------------------
OK   
---------------------------

In my experience, this error almost exclusively comes up because you're missing a closing bracket for the script_enemy_main portion. If you're not missing it, it's been placed in the wrong spot (such as you're closing it appropriately, but before a task, etc.)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on April 26, 2010, 03:21:14 AM
Quote
if(InnerCirc5 >= 0 && FrontalAssault >= 1 && GetPlayerX-15 <= -GetClipMinX && GetPlayerY+25 <= -GetClipMaxY){SetX((GetPlayerX+cos(45)*1)){SetX((GetPlayerX+cos(60)*1)); SetY((GetPlayerY-sin(60)*1))} else
   if(InnerCirc6 >= 0 && FrontalAssault >= 1 && GetPlayerX-15 <= -GetClipMinX && GetPlayerY+25 <= -GetClipMaxY){SetX((GetPlayerX+cos(45)*1)){SetX((GetPlayerX+cos(75)*1)); SetY((GetPlayerY-sin(75)*1))} else

Bolded {'s are mismatched. This may happen on other lines, too, these were just the first I caught.

When in doubt, use your search function.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: GenericTouhouFailure on April 26, 2010, 07:00:35 AM
Gonna have to be a bit more specific. When does Danmakufu crash (if at all)? If music was the issue then the script would play normally, you just wouldn't hear anything.


danmakufu doesn't crash. It just doesn't play music from ANY script. Only sound effects work.
scripts work fine only lacking bgm....
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on April 26, 2010, 07:15:06 AM
danmakufu doesn't crash. It just doesn't play music from ANY script. Only sound effects work.
scripts work fine only lacking bgm....

It might be an issue with the sound file's container/format, but if you just raw downloaded CtC it should work fine. Hmm. I can only think that a danmakufu option is off, our somehow the sound output isn't being processed to the correct medium (external speakers, headset, etc.). But if SFX works, the latter is unlikely.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: ChaoStar on April 26, 2010, 05:16:09 PM

There is nothing wrong with your code, other than being inefficient. Post the whole file.

rong, there was something. I found it with the help of someone
Title: shot replace script
Post by: setifur on April 27, 2010, 03:05:16 AM
I have been using danmakufu for a while but just recently i had the idea of making my own bullets for it but i dont quite understand how to code the replace script can some one please help
Title: Re: shot replace script
Post by: Blargel on April 27, 2010, 06:29:35 AM
First of all, please post questions about Danmakufu in the Q&A thread (http://www.shrinemaiden.org/forum/index.php?topic=4771.0) to prevent clutter in the topic list.

To answer your question, there are two parts of making a shot replace script. First, you need to make a definition file (http://touhou.wikia.com/wiki/Touhou_Danmakufu:_User-defined_Bullets) that contains the graphical behavior of every bullet you want to make. If you read everything on that page, you should be able to make the definition file fairly easily. After creating the file, you need to call LoadUserShotData(path to your definition file) and your script will be able to use the bullets that you created by putting the id numbers that you defined into the graphics parameter of the shot creation functions. Note that at this point, you can use both the default Danmakufu bullets as well as the new ones that you defined. The second part of a shot replace script is making a file that reassigns the constants that Danmakufu uses for the default graphics to hold the values of the new bullets. For example, if you defined a red circular bullet with an id of 1, you could put let RED01 = 1;.

It would probably be best to look at other people's examples to learn so you can take a look at working code. Here is a thread with some of the shot data and shot replace scripts that other people have made (http://www.shrinemaiden.org/forum/index.php?topic=1050.0).
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on April 27, 2010, 10:12:28 AM
Is there any easy-ish or a universal way to tilt 3d objects? I can't figure out how to tilt/rotate the 3d objects I make... for example... a simple cube is like this

Code: [Select]
ascent(i in 0..4)
{
SetGraphicAngle(i*90, 0, 90);
DrawGraphic3D(45*sin(i*90), 0, 45*cos(i*90));
}
SetGraphicAngle(90, 90, 90);
DrawGraphic3D(0, -45, 0);
DrawGraphic3D(0, 45, 0);
Note: I'm not that sure... I haven't tested it (no danmakufu in this comp), but you get the point...

Now, how would I tilt that cube? to for example, a cube standing on one point...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on April 28, 2010, 05:44:59 AM
I believe you would have to have the Y and Z parameters of DrawGraphic3D to make it tilt.



Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on April 28, 2010, 06:14:38 AM
Sometimes I see percentage signs (%) in scripts. What is it used for? I can't seem to figure this out.

Also, since I'm still very bad at Danmakufu - How would one get a bullet to bounce off walls twice?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on April 28, 2010, 06:18:26 AM
Is there any easy-ish or a universal way to tilt 3d objects? I can't figure out how to tilt/rotate the 3d objects I make... for example... a simple cube is like this

Code: [Select]
ascent(i in 0..4)
{
SetGraphicAngle(i*90, 0, 90);
DrawGraphic3D(45*sin(i*90), 0, 45*cos(i*90));
}
SetGraphicAngle(90, 90, 90);
DrawGraphic3D(0, -45, 0);
DrawGraphic3D(0, 45, 0);
Note: I'm not that sure... I haven't tested it (no danmakufu in this comp), but you get the point...

Now, how would I tilt that cube? to for example, a cube standing on one point...

To rotate an object in 2D, you would specify a point to rotate about, get the distance and angle to that point, and move it by incrementing the angle while keeping the distance the same, correct? At the same time, you would need to rotate the graphic at the same speed that you are incrementing the angle.

In 3D, it would be similar. You would need to specify a 3D point to rotate around, get the 3D distance and the three angles (x, y, and z angles). Then you increment the angles (in different ways likely) while changing the graphic angles the same way as well.

However, due to Danmakufu's terrible 3D engine, the angles happen to come across a phenomenon called gimbal locking (http://en.wikipedia.org/wiki/Gimbal_lock) where it can't rotate in certain angles under certain conditions. Also, Danmakufu only takes integer values for the SetGraphicAngle function, possibly due to a bug. If you put in a float, it will truncate it which means that if you rotate the graphic slowly, it will be jerky.

Sometimes I see percentage signs (%) in scripts. What is it used for? I can't seem to figure this out.

Also, since I'm still very bad at Danmakufu - How would one get a bullet to bounce off walls twice?
% is a math operator called modulus. Basically it divides the first number with the second number and tells you what the remainder is. For example, 17%5 would be 2 because 17/5 is 3 remainder 2.

For your second question, it sounds like you already know how to bounce a bullet off once. Why don't you just get a variable to hold how many times the bullet bounced and if it exceeds however many times you want, then you don't bounce it anymore?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on April 28, 2010, 10:46:06 PM
For your second question, it sounds like you already know how to bounce a bullet off once. Why don't you just get a variable to hold how many times the bullet bounced and if it exceeds however many times you want, then you don't bounce it anymore?
Pfft, why didn't I see this. Alright, thanks.

EDIT : There seem to be some inconsistencies and problems if I change speed, the bounce limit, etc, but this will work for now...
Title: Doesn't get objects
Post by: 空SoraのNo鏡Kagami on April 29, 2010, 12:36:53 AM
I've been at this for a whole day. While I'll admit I don't get variables, I decided I'd learn from them...
However I don't get how the Object shots (etc) are supposed to be set up... And no, the wiki isn't helping.
Title: Re: Doesn't get objects
Post by: Furienify on April 29, 2010, 12:56:53 AM
I've been at this for a whole day. While I'll admit I don't get variables, I decided I'd learn from them...
However I don't get how the Object shots (etc) are supposed to be set up... And no, the wiki isn't helping.

Here's basic object code, at least for a bullet:

Code: [Select]
task Bullet(x, y, v, angle, graphic, delay) {
      let obj=Obj_Create(OBJ_SHOT);
//defines a variable so we don't have to constantly reference the object with Obj_Create(OBJ_SHOT);

      Obj_SetPosition(obj, x, y); //This sets the XY coordinates of the bullet's spawn. Note how this is called up in the task.
      Obj_SetSpeed(obj, v); //Sets the object's spawned speed
      Obj_SetAngle(obj, angle); //Like the above, but this sets the angle.
      ObjShot_SetGraphic(obj, graphic); //Object's graphic
      ObjShot_SetDelay  (obj, 0); //Delay before the object is created and fires
      ObjShot_SetBombResist (obj, true); //An alternative option to set whether or not the object is destroyed by bombs.

      while(Obj_BeDeleted(obj)==false) {

//A while loop. Essentially, while this object has not been deleted (aka, 'while this object exists') the bracketed code will be taken into account
//This is where you can, in a way, dynamically control your object using variables. An example is below.
              yield;
       }

Code: [Select]

let timer = 0; //<--- define this before script_enemy_main, I should note

while(Obj_BeDeleted(obj)==false) {
//again... while object exists, we'll do this:
timer++;
//every frame, the 'timer' counter increases by one.

if(timer ==120){
//120 frames, or two seconds after the object's creation (not counting the time you put in the object's delay), the bracketed action occurs.

Obj_SetAngle(obj, Obj_GetAngle(obj) +45)
//Changes the object's angle. Uses the GETANGLE function to retrieve the object's current angle, and then increments it by 45 degrees.

let timer = 0
//Sets the timer back to 0. After two more seconds, the angle will be incremented by 45 again, on and on until the bullet is somehow deleted.

} //closes the if-statement
     yield; //it's a type of loop, so you always yield your loops
} //closes the 'while object is existing' statement, AKA the while loop.

This is always the way I understood it. You can then call the 'Bullet' object anywhere else, IE:

Bullet(GetEnemyX,GetEnemyY,GetAngleToPlayer,3,RED01,60);
^For a bullet that spawns on the enemy after a 1 second delay, moving at a speed of 3 towards wherever the player was at its spawn time.

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on April 29, 2010, 01:05:11 AM
Here, check this link out as well. (http://bulletforge.org/u/onthenet/p/dmf-example-archive-beginner/v/05) Onthenet can explain most of the basic danmakufu functions, with practical examples, far better than I can. It's where everything started making sense to me, at least!

(That ought to be linked in the Tutorial thread, also.)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on April 29, 2010, 01:15:40 AM
Obj_Create is not a value in itself. It simply creates an object. You can't store this object anywhere unless you give it a memory address i.e. the variable. If you use Obj_Create in everything it'll attempt to create a new object for each command and will just generally fail.

also that example can be simplified:
while(!etcdeleted)
    loop(120){yield;}
    setangle;
}
Title: Re: Doesn't get objects
Post by: Blargel on April 29, 2010, 07:50:10 AM
I've been at this for a whole day. While I'll admit I don't get variables, I decided I'd learn from them...
However I don't get how the Object shots (etc) are supposed to be set up... And no, the wiki isn't helping.

If you don't get variables, then it isn't a great idea to learn about objects for the time being. A variable is basically container where you can put whatever information you want to save for later. For example, if you put let asdf;, you would have a variable called asdf that can store whatever information you want now. Then later, if you put asdf = 11;, the container called "asdf" will hold the number 11. Then, you can use this variable in place of regular numbers in math and such like this:

let jklSemicolon = asdf + 5; // Now we have a variable called jklSemicolon that contains 16
CreateShot01(GetX, GetY, 1, asdf, RED01, 10); // This shot will shoot at an angle of 11 because asdf is 11.


There's a lot more things you can do with variables so you should read some of the beginner tutorials in the tutorial thread to fully understand it. Objects rely heavily on manipulation of variables so it would be best if you learned variables first.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on April 30, 2010, 04:12:13 AM
I have some little questions about the use of "yield;" command. As I know, it is used to link the @MainLoop to other task.

1. Can 1 yield; command in @MainLoop be connected to all other yield; in tasks?
2. Can 1 yield; command in tasks be connected to all other yield;s?
3. Can I put a yield; command in @DrawLoop?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fujiwara no Mokou on April 30, 2010, 04:32:51 AM
I have some little questions about the use of "yield;" command. As I know, it is used to link the @MainLoop to other task.

1. Can 1 yield; command in @MainLoop be connected to all other yield; in tasks?
2. Can 1 yield; command in tasks be connected to all other yield;s?
3. Can I put a yield; command in @DrawLoop?

1)You mean if it actually affects the tasks themselves? No.
2)No, all tasks are independent of one another. They can run simultaneously.
3) Yes, but you don't ever want to do that. Generally, MainLoop and DrawLoop have a hidden yield; of their own. It just doesn't exactly "stop and look for other tasks to run", like the written function.

Generally, the yield; function delays a later function or task by said amount of frames.
For example, if you have this in you @Initialize...

@Initialize{
this;
loop(60){yield;}
that;
task this{dostuff; yieldyieldyield;}
task that{dootherstuff; yield;yield;yield;}
}

task that will happen 60 frames after task this.
However, the yields in the actual tasks do not affect one another. What happens in the brackets, stays in the brackets. This allows tremendous flexibility in scripting.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on April 30, 2010, 04:36:16 AM
To simplify that point, you should always just have a single yield; in MainLoop. Then you can put yield; in any task, and the code will wait one frame when it reaches that statement.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on April 30, 2010, 04:39:49 AM
So after tasks (with  yield;) is called, 1 yield; in MainLoop traces back to all yield;s in the tasks and vice versa?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on April 30, 2010, 04:43:17 AM
Yes. You only ever need a single yield; in MainLoop, and that will handle all the ones that are in tasks.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on April 30, 2010, 04:47:45 AM
Essentially:
When a task is first called, Danmakufu immediately enters that task and runs until it reaches the end or a yield, at which it returns to where it was called, like a function or sub.
When yield is called anywhere but in a task, Danmakufu will start up all tasks from where they left off before and run them until they reach their end or a yield.
When yield is called in a task, that task will pause its running until a yield is called somewhere that is not a task.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on April 30, 2010, 04:52:58 AM
Another problem:

I would like to make a SFX for shooting boss like in Touhou games (best demonstrated in SA Phantasm's script)

However, what's the difference between GetEnemyLife and GetLife?

For functions without parameters, the brackets not necessary, right?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on April 30, 2010, 04:58:09 AM
Another problem:

I would like to make a SFX for shooting boss like in Touhou games (best demonstrated in SA Phantasm's script)

However, what's the difference between GetEnemyLife and GetLife?

For functions without parameters, the brackets not necessary, right?

GetLife returns the life of the current enemy (whose script it is being called in). GetEnemyLife returns the life of the current BOSS, no matter where it's being called.

Functions without parameters do not need brackets ( p.s.: they're actually called parentheses, brackets are the square ones, like these --> [ ] ).
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on April 30, 2010, 05:01:00 AM
I have some little questions about the use of "yield;" command. As I know, it is used to link the @MainLoop to other task.

1. Can 1 yield; command in @MainLoop be connected to all other yield; in tasks?
2. Can 1 yield; command in tasks be connected to all other yield;s?
3. Can I put a yield; command in @DrawLoop?

The word "link" isn't the best way to describe how yielding works. This is how tasks behave step by step. First take a look at this code:

Code: [Select]
@Initialize {
    taskOne;
    taskTwo;
    taskThree;
}

@MainLoop {
    yield;
}

task taskOne {
    yield;
    loop {
        CreateShot01(GetX, GetY, rand(0, 5), rand(0, 360), BLUE01, 5);
        loop(5){
            yield;
        }
    }
}

task taskTwo {
    loop(60){
        yield;
    }
    // Create an effect or something, I dunno.
}

task taskThree {
    loop {
        CreateShot01(GetX, GetY, 3, GetAngleToPlayer, RED03, 10);
        loop(12){
            yield;
        }
    }
}

So first, when it goes into @Initialize, the first thing it does is go into taskOne. The very first thing is taskOne is a yield, which in a task means to pause the task until a yield is encountered outside of any task. Since taskOne is paused now, it continues where it left off in @Initialize and starts up taskTwo. The first thing in taskTwo is also a yield (or rather, 60 yields) so it pauses taskTwo and goes on where it left off in @Initialize again. Therefore it starts up taskThree, which finally doesn't have a yield in front so the script does something, fire a bullet at the player. After that, taskThree encounters a yield and so pauses itself like the other two tasks and goes back to where it left off, which is the end of @Initialize.

Since @Initialize is done, we go into @DrawLoop (yes @DrawLoop is first), but there is none so it goes to @MainLoop. @MainLoop has a single yield. This is the yield that I meant when I said that the tasks are paused until a yield is encountered outside of any task. At this yield, any task that has not finished yet will be continued in the order that they were started. In this example, none of the three tasks have finished yet (and really only one will ever finish because the other two are infinite loops) so it goes to the first task we ever started, taskOne and continues where it left off, the beginning of the infinite loop. It shoots a blue bullet at a random angle and speed before encountering a yield again. taskTwo gets another yield so it immediately repauses itself, and taskTwo also gets a yield so it immediately repauses itself. Now that all the tasks are either finished or repaused, it goes back to the @MainLoop past where the yield is. The MainLoop is done, so the game waits for 1/60 of a second and then loops back to the beginning of the @MainLoop. This continues over and over, resulting in a random bullet every 5 frames, an aimed bullet every 12 frames, and an effect created 60 frames after the start of the script.

As said earlier, you are allowed to put a yield in @DrawLoop as well, but it is not recommended. Since all commands that are supposed to be run in that frame when the tasks continue themselves will be piled into the @DrawLoop instead of the @MainLoop, many unexpected errors may occur. Also if you have a yield in @DrawLoop and in @MainLoop, since there would be two yields per frame, it would cause the script to run two times faster.


Warning - while you were typing 5 new replies have been posted. You may wish to review your post.
....lol
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on April 30, 2010, 05:17:47 AM
LOL

Code: [Select]
task HitBoss{
   yield;
   let life = GetEnemyLife;
   let maxlife = life;
   yield;
   loop{
      if(!(GetEnemyLife==life)){
life = GetEnemyLife;
if(life<(maxlife/10)){
    PlaySE(SE_HIT1);
}else{PlaySE(SE_HIT2);}
      }
      loop(5){yield;}
   }
}

So I bet this task is to be declared only at the beginning of the script, right?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on April 30, 2010, 05:27:10 AM
That's definitely something to be called in @Initialize only because if you try it in @MainLoop, it'll create 60 new tasks that do the same thing every second, causing you to have an extremely large amount of redundant tasks that would potentially slow down Danmakufu considerably.

However, there are some tasks that could be called every frame without problems, though I don't have an example right off the bat.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on April 30, 2010, 05:30:06 AM
Something like task setstuff { SetObjectStuff; }
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on April 30, 2010, 05:34:30 AM
Using a task to create an object bullet/effect would be something you can call every frame, since the task would end when the bullet is deleted.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on April 30, 2010, 05:38:06 AM
The main problem is no SFX is produced.
My first diagnosis (:P) shows that if first yield; is removed like the following:

Code: [Select]
task HitBoss{
   //yield;
   let life=GetEnemyLife;
   let maxlife=life;
   if(frame%5==0){ascent(i in 0..life){CreateShot01(GetX, GetY, 2, 360/life*i, 0, 10);}}
   if(life==0){CreateShot01(GetX, GetY, 2, GetAngleToPlayer, 0, 10);}
   yield;
   loop{
      if(GetEnemyLife!=life){
life=GetEnemyLife;
if(life<(maxlife/10)){
    PlaySE("script\Patchouli\SFX\damage00.wav");
}else{PlaySE("script\Patchouli\SFX\damage01.wav");}
      }
      loop(5){yield;}
   }
}

There are bullets, but SFX not produced. (meaning value of life is correct)

I do have a yield; in MainLoop.

To your reference, here are some related function/task/loops:

Code: [Select]
sub bossSC{
   if(frame==-120){HitBoss;}
   //Stuffs here, used to draw boss and it doesn't have yield;
}
@DrawLoop {
   bossSC;
}
Title: Re: Doesn't get objects
Post by: 空SoraのNo鏡Kagami on May 01, 2010, 01:39:59 AM
There's a lot more things you can do with variables so you should read some of the beginner tutorials in the tutorial thread to fully understand it. Objects rely heavily on manipulation of variables so it would be best if you learned variables first.

Yeah, i guess you have a point. I'm only 13 after all. Although, if I don't look at it and try, I'll NEVER get it... So wish me luck. Blah, blah, blah.
Title: Re: Doesn't get objects
Post by: Kylesky on May 01, 2010, 02:03:24 AM
Yeah, i guess you have a point. I'm only 13 after all. Although, if I don't look at it and try, I'll NEVER get it... So wish me luck. Blah, blah, blah.

You may be one of the youngest people here... I'm just 15 and I thought I was the youngest here :V (though, I started using danmakufu at 14 :/ )
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Nazo on May 01, 2010, 03:55:00 AM
It may be something with the game, but, when I try to start up a script from the Directory (in game), it gives me an error and shuts down.
                                                                                                ?
Would anyone like to tell me what I'm doing wrong?  :derp:

(Before you ask, yes, I'm new to this.)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 01, 2010, 03:58:34 AM
It may be something with the game, but, when I try to start up a script from the Directory (in game), it gives me an error and shuts down.
                                                                                                ?
Would anyone like to tell me what I'm doing wrong?  :derp:

(Before you ask, yes, I'm new to this.)

Is it a certain script or all scripts?

also... I didn't know you could put a question mark like that :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on May 01, 2010, 04:01:54 AM
You're using applocale, right?
Title: Re: Doesn't get objects
Post by: Areylie on May 01, 2010, 04:08:09 AM
You may be one of the youngest people here... I'm just 15 and I thought I was the youngest here :V (though, I started using danmakufu at 14 :/ )
I started using Danmakufu at 11-12, and am now 13. :V

note that I am the creator of the shot replace script :c

It may be something with the game, but, when I try to start up a script from the Directory (in game), it gives me an error and shuts down.
                                                                                                ?
Would anyone like to tell me what I'm doing wrong?  :derp:

(Before you ask, yes, I'm new to this.)

Care to answer 2 questions?

A) Do any other modes cause errors?
B) Are you running the game under either AppLocale, or have your system locale set to Japanese?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on May 01, 2010, 10:06:13 PM
Is there any way to mute the built-in sound effects in Danmakufu?

Edit: Well, I suppose I could just replace the actual sound effect files themselves in th_dnh.dat with blank files, but I'm looking for a less messy solution :/
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 01, 2010, 10:19:05 PM
Make a blank sound file and name them as so


seGraze
seScore
seEnemyExplode01
seBomb_MarisaAseBomb_MarisaA_Star
seBomb_MarisaB


They are all .wavs
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 01, 2010, 11:46:51 PM
Is there any way to mute the built-in sound effects in Danmakufu?

When on the frame (or frame after) you know it starts playing:

StopSE(seSuperNaturalBorder01.wav);
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on May 02, 2010, 01:28:17 AM
Thanks!

Another question: would you (the replier) recommend, for timing danmaku/stages, a task with yields, or a if/then-type structure using a time variable that gets incremented each frame? I.e.,
Code: [Select]
task Pewpew {
   yield;
   while (1) {
      loop (60) {yield;}
      //Shoot stuff here
   }
}
versus
Code: [Select]
let time = 0;
@MainLoop {
   if (time%60 == 0) {
      //Shoot stuff here
   }
   time++;
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on May 02, 2010, 01:43:28 AM
Entirely personal preference and how well you are at organizing either method.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on May 02, 2010, 01:46:38 AM
Most people prefer using tasks, so that you can "insert" something in the middle without having to adjust everything after it. Plus, it makes it much easier to set variable times, such as waiting for the midboss to die before moving on.

Also, you can just use loop{stuff;} to loop infinitely. It will work the exact same, but it looks a bit nicer in my opinion.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on May 02, 2010, 03:31:04 AM
Tasks look neater, but if/then structures are more flexible; I run into a bit of trouble when trying to convert my if/then structures into tasks.

When on the frame (or frame after) you know it starts playing:

StopSE(seSuperNaturalBorder01.wav);

Actually, that doesn't work. :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 02, 2010, 03:35:09 AM
What sound are you trying to stop?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on May 02, 2010, 03:57:38 AM
What sound are you trying to stop?

Essentially, I have
Code: [Select]
SetScore(900001);
StopSE(seUseSpellCard.wav);
in @MainLoop, which gives me an error on line 2.
With quotes around seUseSpellCard.wav, it runs without any errors, but the sound doesn't get stopped.
Title: Danmakufu error
Post by: NekoMikoSanae on May 02, 2010, 07:45:31 AM
Hello everyone.
Yesterday I downloaded Danmakufu, only to find that it's not working. =/
Before I can even do anything, right after opening Danmakufu, I get this error:
"th_dnh.exe has encountered a problem and will therfore close.".
And yes, I am running it in Japanese.
I also have Windows XP, if that helps.

Can anyone solve this problem?

Thanks in advance! =D
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on May 02, 2010, 08:23:19 AM
NicePianoPlayer,

Welcome to Rika's and Nitori's Garage. Please make sure you post all dnh "help me" related thinks in this thread as the thread exists here for a reason. To play Danmakufu or use it, you need to install and configure Applocal from Microsoft.

Please read this thread for detailed information: http://www.shrinemaiden.org/forum/index.php?topic=4138.0
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: NekoMikoSanae on May 02, 2010, 08:43:56 AM
NicePianoPlayer,

Welcome to Rika's and Nitori's Garage. Please make sure you post all dnh "help me" related thinks in this thread as the thread exists here for a reason. To play Danmakufu or use it, you need to install and configure Applocal from Microsoft.

Please read this thread for detailed information: http://www.shrinemaiden.org/forum/index.php?topic=4138.0

I will do so next time, but I already tried the solution you offer and it's still not working...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on May 02, 2010, 08:49:18 AM
Offhand the only thing I know of that causes Windows crash errors at startup is when Danmakufu is trying to load something it doesn't like. Is it a clean Danmakufu folder or did you drop a bunch of scripts and stuff in there before starting it up?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: NekoMikoSanae on May 02, 2010, 08:59:27 AM
Offhand the only thing I know of that causes Windows crash errors at startup is when Danmakufu is trying to load something it doesn't like. Is it a clean Danmakufu folder or did you drop a bunch of scripts and stuff in there before starting it up?

I downloaded it from the touhou wiki site. And yes, I think there are some scripts inside. I'll try launching without them. =)

Update: Still not working after I cleaned all of the folders. >_<
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on May 02, 2010, 09:15:26 AM
I highly doubt the method being described in the thread fails. I am still sensing that you are not actually launching the game using the shortcut created by Applocal. The danmakufu zip from the wiki contains only Ex Rumia afaik. And those always work as the integrity is checked often.

Explain to us step by step what you did and trying to do. Screenshots would be even better along with it.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Shade on May 02, 2010, 03:28:18 PM
I'm not really sure if this should go here but anyway...   :/

I download Concealed the Conclusion  cause it looked pretty good, I merged all the files and  tried it out to come across a error that I have received countless times before. "th_dnh.exe has encountered a problem and needs to close.  We are sorry for the inconvenience."

So I did what I did with the other times, I updated stuff. I tried it again, and had the same error. Now I had no idea what to do, and figured out I needed applocale. I downloaded that, and ran it with one of the box 'language' (Fourth one from the top) And it still doesn't work.

Do I have to download that specific font to make it work?

Thanks,
Shade.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 02, 2010, 03:46:45 PM
ran it with one of the box 'language' (Fourth one from the top)
sorry if I misunderstood what you said but... danmakufu runs with japanese... it's usually the last on the language list of applocale...

also, what do you mean by "merged all the files"?

another thing... from previous experience, no, you don't need to download any font to make applocale work...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Shade on May 02, 2010, 03:55:32 PM
Let's see,  Yeah, there's japanese, but it comes out in... boxes.

when I said merged, I meant, I merged all the extractions from each part together.

So I don't need to download font? OK then, but it still doesn't want to run.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 02, 2010, 04:05:51 PM
I'm blank then :/
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Shade on May 02, 2010, 04:08:16 PM
Aw... :( Eventually it'll be figured out... I hope. :3
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on May 02, 2010, 04:10:52 PM
You want to use the bottom language option in AppLocale. It won't work otherwise, asian fonts or no. If it still won't work then go ahead and install that East Asian Fonts option, you'll just need to put in your XP disk for a sec.

(To intercept any incoming questions, go to Control Panel -> Regional and Language Options -> Languages tab and check the option.)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Shade on May 02, 2010, 04:12:37 PM
Alright, I guess I'll just try all of them at the bottom then, thanks.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on May 02, 2010, 07:36:28 PM
Hmm, actually, my Danmakufu runs okay without Applocale, aside from showing error messages with blocks and accented vowels. :/
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on May 02, 2010, 09:47:11 PM
It's not entirely certain what causes it to crash, it's just that it does for most people and AppLocale fixes the problem 99% of the time.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 03, 2010, 06:49:17 AM
In 3D, it would be similar. You would need to specify a 3D point to rotate around, get the 3D distance and the three angles (x, y, and z angles). Then you increment the angles (in different ways likely) while changing the graphic angles the same way as well.

Sorry for bringing this up again... but I seriously can't get it... I've been working on getting this cube rotating 3-ways around 30-60 mins every day, but I still can't figure out how the hell it's done... I can get it to rotate around 1 axis, yes... but after doing the same to another axis and trying to rotate it on both axes at the same time, the entire thing just collapses into the 6 faces... :ohdear:

What I get so far, is that when you rotate it by an axis, the rotation of each axis affects one thing in SetGraphicAngle and 2 things in DrawGraphic3D...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on May 03, 2010, 08:05:27 AM
Sorry for bringing this up again... but I seriously can't get it... I've been working on getting this cube rotating 3-ways around 30-60 mins every day, but I still can't figure out how the hell it's done... I can get it to rotate around 1 axis, yes... but after doing the same to another axis and trying to rotate it on both axes at the same time, the entire thing just collapses into the 6 faces... :ohdear:

What I get so far, is that when you rotate it by an axis, the rotation of each axis affects one thing in SetGraphicAngle and 2 things in DrawGraphic3D...

However, due to Danmakufu's terrible 3D engine, the angles happen to come across a phenomenon called gimbal locking (http://en.wikipedia.org/wiki/Gimbal_lock) where it can't rotate in certain angles under certain conditions. Also, Danmakufu only takes integer values for the SetGraphicAngle function, possibly due to a bug. If you put in a float, it will truncate it which means that if you rotate the graphic slowly, it will be jerky.
Either you didn't read this part or you didn't understand the implications. Danmakufu is unable to freely rotate any graphic in all combinations of angles due to gimbal locking. Danmakufu is utterly not able to do what you want.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 03, 2010, 08:14:50 AM
Either you didn't read this part or you didn't understand the implications. Danmakufu is unable to freely rotate any graphic in all combinations of angles due to gimbal locking. Danmakufu is utterly not able to do what you want.

I thought what you meant by that is that danmakufu won't be able to rotate it under certain conditions, like certain angle combinations, etc... I didn't think it meant that danmakufu is not able to do it at all... :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Shade on May 03, 2010, 08:46:17 PM
Hey! I finally got it to work. Although, there is a new problem:

There's no music playing! I copied all the music from each file to the bgm file, but still no music! xD Help.

EDIT: Never mind, got it. :P
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: NekoMikoSanae on May 04, 2010, 10:53:39 AM
I highly doubt the method being described in the thread fails. I am still sensing that you are not actually launching the game using the shortcut created by Applocal. The danmakufu zip from the wiki contains only Ex Rumia afaik. And those always work as the integrity is checked often.

Explain to us step by step what you did and trying to do. Screenshots would be even better along with it.

1. I unzipped the file I got.

2. Used AppLocale with Japanese and created a shortcut.

3. I use the shortcut and I get the error before even seeing the menu. ("th_dnh.exe has encountered a problem...")

(No use posting a screenshot since my PC isn't in English.)


By the way, I'm not getting this problem when I'm NOT using AppLocale, but if I choose anything but 'Directory' I get the error again, or the game just closes. (Both with RumiaEx and Concealed the Conclusion.)

Also, RumiaEx gives the error when I enter the folder using Danmakufu, and CoC sometimes skips boss battles after another kind of strange error.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on May 04, 2010, 12:44:31 PM
1. I unzipped the file I got.
2. Used AppLocale with Japanese and created a shortcut.
3. I use the shortcut and I get the error before even seeing the menu. ("th_dnh.exe has encountered a problem...")

(No use posting a screenshot since my PC isn't in English.)

By the way, I'm not getting this problem when I'm NOT using AppLocale, but if I choose anything but 'Directory' I get the error again, or the game just closes. (Both with RumiaEx and Concealed the Conclusion.)

Also, RumiaEx gives the error when I enter the folder using Danmakufu, and CoC sometimes skips boss battles after another kind of strange error.
I am out of of ideas. If you are using Windows Vista, turning off the UAC (if it is on) Else I have no idea.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on May 05, 2010, 01:41:24 AM
I am having absolutely no luck with user-made shots. I've been trying to use some of Puremrz's bullets for a while, and have only made marginal progress.

I have:

Somehow, the result of  everything is this (http://i684.photobucket.com/albums/vv203/Elementoid3/Danmakufu%20Sprites/waaaaat.png) (not the pretty butterflies I was hoping for). I have no idea how anything could have messed up the texture coordinates (unless they were wrong all along, for some reason), but I'm at my wits end. Could someone please walk me through exactly what I need to do to get from point A to point B?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on May 05, 2010, 01:46:29 AM
Looks just like the rects are off. Check 'em manually in Paint or something.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on May 05, 2010, 02:26:12 AM
I tried redownloading all the relevant items again, and the problem is persisting. Could it be that the thing itself  (http://www.mediafire.com/?o2mgyzdmm5o)has problems?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 05, 2010, 02:36:30 AM
The Picture of the Shots is wrong, Photobucket resized the image to a different size. I do not have the fixed one, I did at one time, but I deleted it T_T
Title: Re: Danmakufu Intermediate Tutorial
Post by: Foremoster on May 05, 2010, 06:18:03 AM
Hmmm what about those time stopping shots ? Can you help explain ?


[This is not my script]

#TouhouDanmakufu
#Title[Stuff 1]
#Text[A recreation of the spell card I made about a month into Danmakufu-ing.
Requires CtC shot replacement script.]
#Image[]
#BackGround[User(script\img\blank.png, 0, 0)]
#BGM[]
#PlayLevel[?H Easy]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
#include_function "lib\SHOT_REPLACE\shot_replace.dnh";
    let frame = -300;
    let time = -300;
    let chargecolour = 255;
    let shotcolourcount = 0;
    let num = 8;
    let anglering = 0;
    let yukariangle = 0;
    let IsTimeStopping = false;
    let imgExRumia = "script\img\ExRumia.png";
    let graphic = [BLUE56, SP03];

    @Initialize {
        shotinit;
        SetLife(15000);
        SetTimer(99);
        SetInvincibility(60);
        SetEnemyMarker(true);

        SetX(GetCenterX);
        SetY(GetClipMinY + 120);

        MagicCircle(false);

        LoadGraphic(imgExRumia);
    }

    @MainLoop {
        yukariangle-=0.05;
        SetCollisionA(GetX, GetY, 36);
        SetCollisionB(GetX, GetY, 10);
        chargecolour = rand(0, 255);
        if(frame == -240) { SetColor(chargecolour, chargecolour, chargecolour); Concentration02(120); }
        anglering += 6;
        if(frame == 1) {
if(!IsTimeStopping) {
        loop (num) {
        CreateShot01(GetX, GetY, 3, anglering, graphic[0], 10);
        anglering += 360/(num);
        }
}
        frame = 0;
        }
        if(time == 300) {
        SetInvincibility(60);
        IsTimeStopping = true;
        TimeStop(250, 1, 1, 1);
        }
        if(time == 330) {
        loop(180) {
        let x = rand(-275, 275); let y = rand(-50, 180);
        CreateShot01(GetX+x, GetY+y, 3, atan2((GetPlayerY)-(GetY+y), (GetPlayerX)-(GetX+x)), graphic[rand_int(1, 1)], 0);
        CreateShot01(GetX+x, GetY+y, 3, atan2((GetPlayerY)-(GetY+y), (GetPlayerX)-(GetX+x))+15, graphic[rand_int(1, 1)], 0);
        CreateShot01(GetX+x, GetY+y, 3, atan2((GetPlayerY)-(GetY+y), (GetPlayerX)-(GetX+x))-15, graphic[rand_int(1, 1)], 0);
        }
        }
        if(time == 360) {
        IsTimeStopping = false;
        time = 0;
        }
        time++;
        if(!IsTimeStopping) { frame++; }
    }

    @DrawLoop {
        SetTexture(imgExRumia);
        SetColor(255, 255, 255);
        SetGraphicAngle(0, 0, 0);
        SetGraphicScale(1, 1);
        SetGraphicRect(0, 0, 63, 63);
        DrawGraphic(GetX, GetY);
    }

    @Finalize {
        DeleteGraphic(imgExRumia);
    }
}

 :3 Or is it somewhere in the tutorial ?
I also don't really understand the

ascent(i in -200..200){

thingy
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on May 05, 2010, 08:00:51 AM
Foremoster, for those kind of questions you shouldn't bump up ancient threads. For any help regarding scripts or danmakufu you should post in this thread. Tutorial archive threads are obviously meant for tutorial additions or comments. Not for help.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Foremoster on May 05, 2010, 09:39:44 AM
Got it  :)
Title: Re: Danmakufu Intermediate Tutorial
Post by: Chronojet ⚙ Dragon on May 05, 2010, 05:01:06 PM
Hmmm what about those time stopping shots ? Can you help explain ?

[This is not my script]
Code: [Select]
#TouhouDanmakufu
#Title[Stuff 1]
#Text[A recreation of the spell card I made about a month into Danmakufu-ing.
Requires CtC shot replacement script.]
#Image[]
#BackGround[User(script\img\blank.png, 0, 0)]
#BGM[]
#PlayLevel[‡H Easy]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
#include_function "lib\SHOT_REPLACE\shot_replace.dnh";
    let frame = -300;
    let time = -300;
    let chargecolour = 255;
    let shotcolourcount = 0;
    let num = 8;
    let anglering = 0;
    let yukariangle = 0;
    let IsTimeStopping = false;
    let imgExRumia = "script\img\ExRumia.png";
    let graphic = [BLUE56, SP03];

    @Initialize {
        shotinit;
        SetLife(15000);
        SetTimer(99);
        SetInvincibility(60);
        SetEnemyMarker(true);

        SetX(GetCenterX);
        SetY(GetClipMinY + 120);

        MagicCircle(false);

        LoadGraphic(imgExRumia);
    }

    @MainLoop {
        yukariangle-=0.05;
        SetCollisionA(GetX, GetY, 36);
        SetCollisionB(GetX, GetY, 10);
        chargecolour = rand(0, 255);
        if(frame == -240) { SetColor(chargecolour, chargecolour, chargecolour); Concentration02(120); }
        anglering += 6;
        if(frame == 1) {
if(!IsTimeStopping) {
        loop (num) {
        CreateShot01(GetX, GetY, 3, anglering, graphic[0], 10);
        anglering += 360/(num);
        }
}
        frame = 0;
        }
        if(time == 300) {
        SetInvincibility(60);
        IsTimeStopping = true;
        TimeStop(250, 1, 1, 1);
        }
        if(time == 330) {
        loop(180) {
        let x = rand(-275, 275); let y = rand(-50, 180);
        CreateShot01(GetX+x, GetY+y, 3, atan2((GetPlayerY)-(GetY+y), (GetPlayerX)-(GetX+x)), graphic[rand_int(1, 1)], 0);
        CreateShot01(GetX+x, GetY+y, 3, atan2((GetPlayerY)-(GetY+y), (GetPlayerX)-(GetX+x))+15, graphic[rand_int(1, 1)], 0);
        CreateShot01(GetX+x, GetY+y, 3, atan2((GetPlayerY)-(GetY+y), (GetPlayerX)-(GetX+x))-15, graphic[rand_int(1, 1)], 0);
        }
        }
        if(time == 360) {
        IsTimeStopping = false;
        time = 0;
        }
        time++;
        if(!IsTimeStopping) { frame++; }
    }

    @DrawLoop {
        SetTexture(imgExRumia);
        SetColor(255, 255, 255);
        SetGraphicAngle(0, 0, 0);
        SetGraphicScale(1, 1);
        SetGraphicRect(0, 0, 63, 63);
        DrawGraphic(GetX, GetY);
    }

    @Finalize {
        DeleteGraphic(imgExRumia);
    }
}
:3 Or is it somewhere in the tutorial ?
I also don't really understand the

ascent(i in -200..200){

thingy
wut that looks like my script? :V
If you want to know how time stopping *works*, then let's look at this:
TimeStop(120*, 1**, 0***, 1****);
* How many frames to stop time (or whatever you like to call it)
** stops the player if true, doesn't if false
*** stops all bullets (if true, not if false)
**** stops the background
also 1 should be true and 0 should be false, but it still works, I guess

ascent(variable in min..max) { stuff; }
it basically means:
let variable = min;
while(variable < max) { stuff; variable++; }

Or something like that.

Sorry if I explained anything incorrectly :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 05, 2010, 05:08:33 PM
ascent(variable in min..max)
Pretty much is an extended loop function, used to call multiple things with a different variable
 
ascent(variable in -5..6){
CreateShot01(x,y,3,90+10*variable,RED05,0);
}
 
Would actually create 11 Bullets, because
varialble = [-5,-4,-3,-2,-1,0,1,2,3,4,5,6];
 
But it calls all of the numbers at once.
the example would create bullets that shoot at
40,30,50,60,70,etc. etc.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on May 05, 2010, 05:13:49 PM
ascent(variable in -5..6){
CreateShot01(x,y,3,90+10*variable,RED05,0);
}
 
Would actually create 11 Bullets, because
varialble = [-5,-4,-3,-2,-1,0,1,2,3,4,5,6];
Actually, ascent excludes the second parameter from the loops, in that case the loop for variable=6.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 06, 2010, 02:02:12 AM
For the past hour I have been trying to come up with a reflective system, on the center X.
As of now I have the code check for which keys are pressed and act accordingly, but its not really working


Code: [Select]

#TouhouDanmakufu
#Title[Spell 1]
#Text[Spell 1]
#Player[FREE]
#BackGround[User(.\img.png)]
#ScriptVersion[2]


script_enemy_main{
//let BossImg = GetCurrentScriptDirectory~"bossimg.png";


//#include_function "lib\ExpandedShotDatav4\shot_replace.dnh"
let frame = 10;
let acc = 0;
let s1 = 1.5;
let angle = 0;
let  l =60;
let move = 0;
let o = 15;
let n = 12;
let side = 0;
let verticle = GetPlayerY;
let objLaz1=Obj_Create(OBJ_LASER);


task Laser{
      Obj_SetAngle(objLaz1, 90);
      ObjLaser_SetLength(objLaz1, 490);
      ObjLaser_SetWidth(objLaz1, 7);
      ObjShot_SetDelay(objLaz1, 60);
      ObjShot_SetGraphic(objLaz1, WHITE03);
      Obj_SetSpeed(objLaz1, 0);
      Obj_SetY(objLaz1, 0);
      while(Obj_BeDeleted(objLaz1)==false) {
                  Obj_SetX(objLaz1, GetCenterX);
       
            Obj_SetCollisionToObject(objLaz1, true);
            ObjShot_SetBombResist(objLaz1, true);
            yield;
      }
}




    @Initialize {
//SoundLoad;
        //LoadGraphic(BossImg);
SetMovePosition02(GetCenterX, GetCenterY-60, 0);
        SetLife(300);
        SetEnemyMarker(true);
        Concentration01(60);
        Concentration02(60);
        MagicCircle(true);
//ShotInit;
Laser;
//Task;


    }


    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 24); 
        frame+=1;

if(frame%1==0){
//loop(4){
CreateShotA(0,GetCenterX+side,verticle,10);
SetShotDataA(0,0,0,0,0,0,0,RED05);
//SetShotDataA(0,120,0,angle+frame*8,0.03,0.05,3,RED05);
SetShotKillTime(0,200);
angle+=360/4;
FireShot(0);
// }
}


if(GetKeyState(VK_LEFT)==KEY_HOLD)
{
side+=3.5;
}
if(GetKeyState(VK_RIGHT)==KEY_HOLD)
{
side-=3.5;
}


if(GetKeyState(VK_UP)==KEY_HOLD)
{
verticle-=3.5;
}
if(GetKeyState(VK_DOWN)==KEY_HOLD)
{
verticle+=3.5;
}
if(side<14){
side=32;
}
if(verticle<GetClipMinY)
{
verticle=GetClipMinY+1;
}
if(verticle>GetClipMaxY)
{
verticle=GetClipMaxY-1;
}


if(GetPlayerX<GetCenterX)
{


if(side>GetCenterX){side=side-20;}


if(side>GetClipMaxX)
{
side=GetClipMaxX-1;
}
}
if(GetPlayerX<GetCenterX)
{
if(side>GetClipMinX)
{
side=GetClipMinX+1;}


if(side>GetCenterX){side=side+20;}
}
}
@DrawLoop{
DrawText(side,GetCenterX,GetCenterY,25,255);
DrawText(verticle,GetCenterX,GetCenterY-30,25,255);




DrawText(GetPlayerX,GetCenterX,GetCenterY+30,25,255);
DrawText(GetCenterX,GetCenterX,GetCenterY+60,25,255);
/*
SetTexture(BossImg);
SetRenderState(ALPHA); SetAlpha(255);
SetGraphicScale(1.25,1.25);
SetGraphicAngle(0,0,0);
if(int(GetSpeed())==0){SetGraphicRect(0,0,33,63);}
if(GetSpeedX()<0){SetGraphicRect(32,0,69,62);}


if(GetSpeedX()>0){ SetGraphicAngle(180,0,0);
SetGraphicRect(32,0,69,62);}
DrawGraphic(GetX,GetY);
*/
}
@Finalize{
//DeleteGraphic(BossImg);
}
}


Sorry for big code, I was told that my "tabbing" made the code unreadable, hopefully this is better.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on May 06, 2010, 02:47:21 PM
1. What do you mean with reflective system? Why do you need button input for it? Please explain in sufficcient detail what you are trying to accomplish.

2. The code is still very hard to read since it isn't indented...  :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 06, 2010, 11:48:10 PM
I want to make it so that when the player moves on one side of the screen, like a mirror the same thing happens on the other side, with the Center being the reflective point
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 07, 2010, 12:45:02 AM
Reflecting over the center x (left to right reflection and vice versa):

NewX = (GetCenterX - GetPlayerX) + GetCenterX;
NewY = GetPlayerY;

Reflecting over the center y (top to bottom reflection and vice versa):

NewX = GetPlayerX;
NewY = (GetCenterY - GetPlayerY) + GetCenterY;


Your code is illegible to me in it's current state. So I'll fix it...
Code: [Select]
#TouhouDanmakufu
#Title[Spell 1]
#Text[Spell 1]
#Player[FREE]
#BackGround[User(.\img.png)]
#ScriptVersion[2]


script_enemy_main{
//let BossImg = GetCurrentScriptDirectory~"bossimg.png";


//#include_function "lib\ExpandedShotDatav4\shot_replace.dnh"
let frame = 10;
let acc = 0;
let s1 = 1.5;
let angle = 0;
let  l =60;
let move = 0;
let o = 15;
let n = 12;
let side = 0;
let verticle = GetPlayerY;
let objLaz1=Obj_Create(OBJ_LASER);


task Laser{
Obj_SetAngle(objLaz1, 90);
ObjLaser_SetLength(objLaz1, 490);
ObjLaser_SetWidth(objLaz1, 7);
ObjShot_SetDelay(objLaz1, 60);
ObjShot_SetGraphic(objLaz1, WHITE03);
Obj_SetSpeed(objLaz1, 0);
Obj_SetY(objLaz1, 0);
while(Obj_BeDeleted(objLaz1)==false) {
Obj_SetX(objLaz1, GetCenterX);
Obj_SetCollisionToObject(objLaz1, true);
ObjShot_SetBombResist(objLaz1, true);
yield;
}
}




    @Initialize {
//SoundLoad;
//LoadGraphic(BossImg);
SetMovePosition02(GetCenterX, GetCenterY-60, 0);
SetLife(300);
SetEnemyMarker(true);
Concentration01(60);
Concentration02(60);
MagicCircle(true);
//ShotInit;
Laser;
//Task;
}


    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 24);
        frame+=1;
   
if(frame%1==0){
//loop(4){
CreateShotA(0,GetCenterX+side,verticle,10);
SetShotDataA(0,0,0,0,0,0,0,RED05);
//SetShotDataA(0,120,0,angle+frame*8,0.03,0.05,3,RED05);
SetShotKillTime(0,200);
angle+=360/4;
FireShot(0);
//   }
}

if(GetKeyState(VK_LEFT)==KEY_HOLD){
side+=3.5;
}
if(GetKeyState(VK_RIGHT)==KEY_HOLD){
side-=3.5;
}

if(GetKeyState(VK_UP)==KEY_HOLD){
verticle-=3.5;
}
if(GetKeyState(VK_DOWN)==KEY_HOLD){
verticle+=3.5;
}
if(side<14){
side=32;
}
if(verticle<GetClipMinY){
verticle=GetClipMinY+1;
}
if(verticle>GetClipMaxY){
verticle=GetClipMaxY-1;
}


if(GetPlayerX<GetCenterX){
if(side>GetCenterX){
side=side-20;
}
if(side>GetClipMaxX){
side=GetClipMaxX-1;
}
}

if(GetPlayerX<GetCenterX){
if(side>GetClipMinX){
side=GetClipMinX+1;
}
if(side>GetCenterX){
side=side+20;
}
}
}

@DrawLoop{
DrawText(side,GetCenterX,GetCenterY,25,255);
DrawText(verticle,GetCenterX,GetCenterY-30,25,255);
DrawText(GetPlayerX,GetCenterX,GetCenterY+30,25,255);
DrawText(GetCenterX,GetCenterX,GetCenterY+60,25,255);
/*
SetTexture(BossImg);
SetRenderState(ALPHA); SetAlpha(255);
SetGraphicScale(1.25,1.25);
SetGraphicAngle(0,0,0);
if(int(GetSpeed())==0){
SetGraphicRect(0,0,33,63);
}
if(GetSpeedX()<0){
SetGraphicRect(32,0,69,62);
}
if(GetSpeedX()>0){
SetGraphicAngle(180,0,0);
SetGraphicRect(32,0,69,62);
}
DrawGraphic(GetX,GetY);
*/
}

@Finalize{
//DeleteGraphic(BossImg);
}
}

That's your code with it's tabbing fixed. Here's your code with the problem fixed:

Code: [Select]
#TouhouDanmakufu
#Title[Spell 1]
#Text[Spell 1]
#Player[FREE]
#BackGround[User(.\img.png)]
#ScriptVersion[2]


script_enemy_main{
//let BossImg = GetCurrentScriptDirectory~"bossimg.png";


//#include_function "lib\ExpandedShotDatav4\shot_replace.dnh"
let frame = 10;
let angle = 0;
let NewX = GetPlayerX;
let NewY = GetPlayerY;
let objLaz1=Obj_Create(OBJ_LASER);


task Laser{
Obj_SetAngle(objLaz1, 90);
ObjLaser_SetLength(objLaz1, 490);
ObjLaser_SetWidth(objLaz1, 7);
ObjShot_SetDelay(objLaz1, 60);
ObjShot_SetGraphic(objLaz1, WHITE03);
Obj_SetSpeed(objLaz1, 0);
Obj_SetY(objLaz1, 0);
while(Obj_BeDeleted(objLaz1)==false) {
Obj_SetX(objLaz1, GetCenterX);
Obj_SetCollisionToObject(objLaz1, true);
ObjShot_SetBombResist(objLaz1, true);
yield;
}
}




    @Initialize {
//SoundLoad;
//LoadGraphic(BossImg);
SetMovePosition02(GetCenterX, GetCenterY-60, 0);
SetLife(300);
SetEnemyMarker(true);
Concentration01(60);
Concentration02(60);
MagicCircle(true);
//ShotInit;
Laser;
//Task;
}


    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 24);
        frame+=1;
//frame++; <-- ???

NewX = (GetCenterX - GetPlayerX) + GetCenterX;
NewY = GetPlayerY;

//If the remainder of frame divided by one equals zero, do this. Every frame?
if(frame%1==0){
//loop(4){
CreateShotA(0,NewX,NewY,10);
SetShotDataA(0,0,0,0,0,0,0,RED05);
//SetShotDataA(0,120,0,angle+frame*8,0.03,0.05,3,RED05);
SetShotKillTime(0,200);
angle+=360/4;
FireShot(0);
//   }
}

}

@DrawLoop{
/*
SetTexture(BossImg);
SetRenderState(ALPHA); SetAlpha(255);
SetGraphicScale(1.25,1.25);
SetGraphicAngle(0,0,0);
if(int(GetSpeed())==0){
SetGraphicRect(0,0,33,63);
}
if(GetSpeedX()<0){
SetGraphicRect(32,0,69,62);
}
if(GetSpeedX()>0){
SetGraphicAngle(180,0,0);
SetGraphicRect(32,0,69,62);
}
DrawGraphic(GetX,GetY);
*/
}

@Finalize{
//DeleteGraphic(BossImg);
}
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 07, 2010, 01:12:10 AM
Crap, i find the hardest way around stuff, i feel very smart right now. Thank You



Title: Re: Danmakufu Intermediate Tutorial
Post by: Foremoster on May 07, 2010, 05:38:11 PM
wut that looks like my script? :V
If you want to know how time stopping *works*, then let's look at this:
TimeStop(120*, 1**, 0***, 1****);
* How many frames to stop time (or whatever you like to call it)
** stops the player if true, doesn't if false
*** stops all bullets (if true, not if false)
**** stops the background
also 1 should be true and 0 should be false, but it still works, I guess

ascent(variable in min..max) { stuff; }
it basically means:
let variable = min;
while(variable < max) { stuff; variable++; }

Or something like that.

Sorry if I explained anything incorrectly :V


I Sense Sakuya spell cards in the air  
Title: Re: Danmakufu Intermediate Tutorial
Post by: Kylesky on May 08, 2010, 02:39:23 AM

I Sense Sakuya spell cards in the air

Sakuya (http://bulletforge.org/u/kylesky/p/sakuya-boss-fight/v/11) :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: GenericTouhouFailure on May 08, 2010, 12:57:47 PM
Hey GUYZ, Check out my first script:
Normal Vidaya (http://www.youtube.com/watch?v=PcpogzPKI1Y)
Lunatic Vidaya (speedhacked to prevent extra shitty mistakes) (http://www.youtube.com/watch?v=yO5EbkiQXd4)
BulletForge Project (no No download link yet) (http://bulletforge.org/u/generictouhoufan/p/placeholder-unthinkable-unnatural-curve-placeholder)
Stuff changed since the video:
Final spell is now replaced with amulets.
Kanako's 1st sc has double the original health.
Kanako's Lunatic 1st sc name is now Unthinkable Natural Wind Curve instead of Unthinkable Unnatural wind curve well damnit wind is definitely natural
ALSO:
LOLMODIFYNAUT'SSANAE

so any comments or recommendations?

Also how do i stop this
Code: [Select]
DrawText("Graze "~ToString(GetGraze),GetCenterX .....
from generating
Graze 0.00000000000000
and instead getting
Graze 0

-Translation aka tl;dr-
Do not want = Graze 0.0000000000000
want = Graze 0
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 08, 2010, 01:08:48 PM
Also how do i stop this
Code: [Select]
DrawText("Graze "~ToString(GetGraze),GetCenterX .....
from generating
Graze 0.00000000000000
and instead getting
Graze 0

function NumberToString(num){
    let string=ToString(num);
    let numberstring="";
    ascent(i in 0..length(string)){
        if(string[ i ]!='.'){
            numberstring=numberstring~string[ i ];
        }else{
            break;
        }
    }
    return numberstring;
}
OR
function NumberToString(num){
    let string=ToString(num);
    let numberstring="";
    let i=0;
    loop{
        if(string[ i ]!='.'){
            numberstring=numberstring~string[ i ];
        }else{
            break;
        }
    i++;
    }
    return numberstring;
}
OR
function NumberToString(num){
    let string=ToString(num);
    let numberstring="";
    let i=0;
    while(string[ i ]!='.'){
        numberstring=numberstring~string[ i ];
        i++;
    }
    return numberstring;
}

then just call it like this :
Code: [Select]
DrawText("Graze "~NumberToString(GetGraze),GetCenterX .....

Note: I didn't test the code, but I think that would work...


so any comments or recommendations?

it's just an idea... not sure if it's a good one, but... since the story's basically sanae looking for new spell card ideas, why not make her bombs/spell cards vary over time... like per stage or something...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: GenericTouhouFailure on May 08, 2010, 01:47:17 PM
it's just an idea... not sure if it's a good one, but... since the story's basically sanae looking for new spell card ideas, why not make her bombs/spell cards vary over time... like per stage or something...
Err. Im not sure about tearing up naut's sanae further... besides It's not easy to come up with decent bomb ideas.
I'll consider.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bananamatic on May 09, 2010, 12:00:31 AM
Just started trying some basic stuff :V

One problem: Shot lasers don't appear. No error, but when I use CreateLaser01, the boss stands there and does nothing.

Is there some requirement to make them work? I tried copying a laser pattern from a different script which worked, but in mine it didn't.

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 09, 2010, 12:10:44 AM
Post script
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bananamatic on May 09, 2010, 12:46:16 AM
Post script
I don't believe it's required, as I simply copied this script from the tutorial to check if I have done anything wrong:
Code: [Select]
CreateLaser01(GetX, GetY, 2, GetAngleToPlayer, 200, 16, RED01, 20); No error, the boss just sits there doing absolutely nothing.
Tested a different laser script and it worked, but shot lasers don't do a thing.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on May 09, 2010, 12:53:31 AM
Could you post the entire script that you're using? That's the right format for firing lasers, so there's probably something off about another part of the script.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bananamatic on May 09, 2010, 01:14:03 AM
nevermind, figured it out

had it spawning at the top of the screen which might work for bullets but not for these lasers

EDIT: I need help on several other things

1) bullets aimed at the player don't go behind the boss, so
2) How to make the boss do something depending on the player's position? Like, if the the player goes to Y<200, the boss unleashes an undodgeable wall

Also, why doesn't this work or rather, how to make frame== and loop work together and how to make several conditions at once?
I've looked at the tutorials, but I haven't found anything on that.

Code: [Select]
if (frame==5){
           loop(3)
{
            CreateShot01(240, 110, 7, GetAngleToPlayer+rand(-10, 10), RED01, 10);
            frame = 0;

}

It redirects me to DrawLoop with an error which I can't find in the Troubleshooting FAQ.

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on May 09, 2010, 03:27:19 AM
1 - Aimed bullets should be able to go behind the boss. I'm not sure why this isn't working.

2 - Just use an if statement like:
Code: [Select]
if(GetPlayerY<200){
     Blah blah impenetrable wall
}

Your code seems to be missing a closing bracket (which might be raising the error?), unless there's more to it than just that loop. This is how I would have written it:
Code: [Select]
if (frame==5){
     loop(3){
          CreateShot01(GetX, GetY, 7, GetAngleToPlayer+Rand(-10, 10), RED01, 10);
     }
     frame=0;
}
First, there's the closing bracket. I changed the X and Y values so that the bullets would spawn directly on top of the boss. Then I stuck the frame=0; outside of the loop, since it's unnecessary to repeat it three times at once.

So every five frames, the boss will fire a varying spread of bullets towards the player
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bananamatic on May 09, 2010, 11:11:34 AM
When I use GetX and GetY, it just shoots from the top of the screen.

Tried that too, still got an error.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: GenericTouhouFailure on May 09, 2010, 11:26:09 AM
1. Could you paste your entire code at http://pastebin.com/ (http://pastebin.com/)? then give us the link.
2. If bullets are coming from the top of the screen you could.... A: Try using GetEnemyX GetEnemyY B: Ensure you did not forget a SetMovePosistion01() in @Initialize
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: CK Crash on May 09, 2010, 01:33:10 PM
When I use GetX and GetY, it just shoots from the top of the screen.

Tried that too, still got an error.
This is because your BOSS is at the top of the screen. Use SetMovePosition02(GetCenterX,GetCenterY-120,60) in your @Initialize so that your boss is actually somewhere visible.

Also I will now shamelessly advertise these examples (http://bulletforge.org/u/onthenet/p/dmf-example-archive), since you appear to have read the tutorials but are still having trouble actually implementing the functions and stuff.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 空SoraのNo鏡Kagami on May 09, 2010, 09:03:48 PM
Is there some way to separate frames for things. Like, l want one shot to be x frames, and another to be another.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 09, 2010, 09:19:56 PM
if i understood you right:

if(frame==5){
do stuff;}

if(frame==10){
do stuff;}

is what your looking for.


You want to fire a shot when frame equals a number right?
or
if you want to do the same thing you use the "||"


if(frame==5 || frame==10 || frame==15){
do stuff;}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on May 09, 2010, 09:43:24 PM
Something important to remember relating to that.
Code: [Select]
if(frame==5){
Task1;
frame=0;
}
if(frame==10){
Task2;
frame=0;
}
frame++;

This will only do Task1 every five frames, since the frame is reset every time it happens, so the frame count never reaches 10. If you take out frame=0; from the first part, then the script will alternate between Task1 and Task2 every five frames.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on May 09, 2010, 09:59:59 PM
Try using modulos:
Code: [Select]
if (frame%5 == 0) {
   Task1;
}
if (frame%10 == 0) {
   Task2;
}
frame++;

The modulo is the % symbol, and it returns the remainder of the first number divided by the second number. E.g., 12%5 would equal 2, since the remainder of 12/5 is 2.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 09, 2010, 10:22:46 PM
nvm work around
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 空SoraのNo鏡Kagami on May 10, 2010, 12:32:12 AM
TO ALL THOSE WHO RESPONDED TO MY "FRAMES" PROBLEM (Quoting you all was too long)

Uhh... I'll say it again, to make sure we aren't wasting time here. Basically, I want one section of bullets to spawn less bullets at a time, and the other, to spawn more... because I haven't a real clue what was put down.  ???
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 10, 2010, 01:06:39 AM
I think i understand now


Code: [Select]
let a = 10 //or how many you want to start out with




if(frame==5){
 a++;
loop(a+a){
Bullets;}
}


if(frame==10){
loop(a-(a/2){
Bullets;}
frame=0;
}


Pretty much, a increases


Pretty Much, a will increase when frame is 5
the number of bullets fired when frame is 5 is "a" plus "a"
the number of bullets fired when frame is 10 is "a" minus half of "a"


Thus as time goes on, more bullets will be fired if frame equals 5, and less at a 10
so it at first will fire
20 at 5
5 at 10
22 at 5
etc..
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 10, 2010, 02:06:56 AM
sup

(http://i43.tinypic.com/2e5qk2q.jpg)
I know what this means and how to fix it, I'm just posting to fuck with your minds a bit. Azure has probably seen this.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 空SoraのNo鏡Kagami on May 10, 2010, 02:53:58 AM
*Sigh* Sorry Bman, I think I'll postpone that until I understand variables more. And on to a problem I've had ever since i downloaded Danmakufu... LASERS DON'T WORK

huh, that's weird... it just spontaneously started working again... On somewhat related news, I spelled spontaneous right!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on May 10, 2010, 02:59:16 AM
sup

(http://i43.tinypic.com/2e5qk2q.jpg)
I know what this means and how to fix it, I'm just posting to fuck with your minds a bit. Azure has probably seen this.
Dammit Naut
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 10, 2010, 03:17:41 AM
For somereason my little detection snippet:
Code: [Select]

if(PosX<Pos2X+5 && PosX>Pos2X-5 && PosY<Pos2Y+20 && PosY>Pos2Y-20){yield;
ShootDownPlayer;}


is not working, and instead if I go to a corner of the screen, usually the lower right, I die when nothing is around me


i also have


Code: [Select]

let PosX = Obj_GetX(id);
let PosY = Obj_GetY(id);
let Pos2X = Obj_GetX(objid);
let Pos2Y = Obj_GetY(objid);



to check for positions.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 10, 2010, 03:31:08 AM
For somereason my little detection snippet:
dfasghrjyew4
is not working, and instead if I go to a corner of the screen, usually the lower right, I die when nothing is around me

Sounds like your problem lies elsewhere. Post the whole script?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 10, 2010, 03:57:40 AM
Code: [Select]

#TouhouDanmakufu
#Title[Spell 1]
#Text[Spell 1]
#Player[FREE]
#BackGround[User(.\img.png)]
#ScriptVersion[2]


script_enemy_main{
let BossImg = GetCurrentScriptDirectory~"bossimg.png";
#include_function ".\S_I_Load.txt"
#include_function "lib\SHOT_REPLACE\shot_replace.dnh"
let frame = 10;
let acc = 0;
let s1 = 1.5;
let angle = 0;
let  l =60;
let move = 0;
let o = 15;
let n = 12;
let side = 0;
let NewX = 0;
let NewY = 0;
let imagefile = GetCurrentScriptDirectory ~ "bossimg.png";
let objLaz1=Obj_Create(OBJ_LASER);
let objid = Obj_Create(OBJ_EFFECT);




task Laser{
      Obj_SetAngle(objLaz1, 90);
      ObjLaser_SetLength(objLaz1, 490);
      ObjLaser_SetWidth(objLaz1, 17);
      ObjShot_SetDelay(objLaz1, 60);
      ObjShot_SetGraphic(objLaz1, WHITE60);
      Obj_SetSpeed(objLaz1, 0);
      Obj_SetY(objLaz1, 0);
      while(Obj_BeDeleted(objLaz1)==false) {
                  Obj_SetX(objLaz1, GetCenterX);
                  Obj_SetCollisionToObject(objLaz1, true);
                  ObjShot_SetBombResist(objLaz1, true);
            yield;
      }
}


task HitShot(id,x,y,speed,angle,graphic,delay){
let lol = 0;
let n = 0;
let numbe = 0;
let id=Obj_Create(OBJ_SHOT);


Obj_SetPosition(id,x,y);
Obj_SetAngle(id, angle);
Obj_SetSpeed(id, speed);
ObjShot_SetGraphic(id, graphic);
ObjShot_SetDelay  (id, delay);
ObjShot_SetBombResist (id, false);


while(Obj_BeDeleted(id)==false){
let PosX = Obj_GetX(id);
let PosY = Obj_GetY(id);
let Pos2X = Obj_GetX(objid);
let Pos2Y = Obj_GetY(objid);
yield;


if(PosX<Pos2X+5 && PosX>Pos2X-5
&& PosY<Pos2Y+20 && PosY>Pos2Y-20){yield;
ShootDownPlayer;}
}
}




    @Initialize {
SoundLoad;
        LoadGraphic(BossImg);
LoadGraphic(imagefile);
SetMovePosition02(GetCenterX, GetCenterY-120, 0);
        SetLife(300);
        SetEnemyMarker(true);
        Concentration01(60);
        Concentration02(60);
        MagicCircle(true);
shotinit;
Laser;


    }


    @MainLoop {yield;
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 24);
        frame+=1;

if(frame==30){
ReflectPlayer;
     }


if(frame%2==0){
HitShot(frame+1,GetX,GetY,3,rand(0,360),SP03,10);
}
}
@DrawLoop{yield;


SetTexture(BossImg);
SetRenderState(ALPHA); SetAlpha(255);
SetGraphicScale(1.25,1.25);
SetGraphicAngle(0,0,0);
if(int(GetSpeed())==0){SetGraphicRect(0,0,33,63);}
if(GetSpeedX()<0){SetGraphicRect(32,0,69,62);}


if(GetSpeedX()>0){ SetGraphicAngle(180,0,0);
SetGraphicRect(32,0,69,62);}
DrawGraphic(GetX,GetY);


}
@Finalize{
//DeleteGraphic(BossImg);
}




task ReflectPlayer{


 
  ObjEffect_SetTexture(objid,imagefile);
          ObjEffect_SetPrimitiveType(objid, PRIMITIVE_TRIANGLEFAN);
          ObjEffect_CreateVertex(objid, 4);
  ObjEffect_SetScale(objid,1,1);
  ObjEffect_SetRenderState(objid,ALPHA);
  Obj_SetAlpha(objid,255);


while(Obj_BeDeleted(objid)==false){yield;


NewX = (GetCenterX - GetPlayerX) + GetCenterX;
NewY = GetPlayerY;


          ObjEffect_SetVertexXY(objid, 0, NewX-30, NewY-30);
          ObjEffect_SetVertexUV(objid, 0, 0, 0);
 
          ObjEffect_SetVertexXY(objid, 1, NewX+30, NewY-30);
          ObjEffect_SetVertexUV(objid, 1, 33, 0);
 
          ObjEffect_SetVertexXY(objid, 2, NewX+30, NewY+30);
          ObjEffect_SetVertexUV(objid, 2, 33, 63);


          ObjEffect_SetVertexXY(objid, 3, NewX-30, NewY+30);
          ObjEffect_SetVertexUV(objid, 3, 0, 63);


  ObjEffect_SetLayer(objid, 7);

}
}
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 10, 2010, 04:03:24 AM
You don't set the position of the object named "objid" (setting graphic coordinates does not set it's position). Declare NewX and NewY globally and use those instead of Obj_GetX(objid) and Obj_GetY(objid).
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 空SoraのNo鏡Kagami on May 13, 2010, 03:15:40 AM
Okay... Major problem... Any new Spell or anything, I try to make... it doesn't show up
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 13, 2010, 03:18:10 AM
Post Script Please


It could be a problem when you forgot to include
#TouhouDanmakufu




Or maybe


#Title[]
and
#Text[]
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on May 13, 2010, 03:42:34 AM
Okay... Major problem... Any new Spell or anything, I try to make... it doesn't show up
Don't do this. Please. Ever. We don't know what the fuck that would mean, and even if someone guesses correctly, it's still a horrible horrible thing to do stop it.

Give as much info as you possibly can.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 空SoraのNo鏡Kagami on May 14, 2010, 01:22:08 AM
Post Script Please


It could be a problem when you forgot to include
#TouhouDanmakufu

How could I miss that! I'm dumb, I blame school.

Don't do this. Please. Ever. We don't know what the fuck that would mean, and even if someone guesses correctly, it's still a horrible horrible thing to do stop it.

Give as much info as you possibly can.

I'm afraid I don't follow, I gave you info... The spell, clearly doesn't show up. If the spell didn't show up when I chose it, I would have said so, if that's what you meant.

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 14, 2010, 01:40:03 AM
I'm afraid I don't follow, I gave you info... The spell, clearly doesn't show up. If the spell didn't show up when I chose it, I would have said so, if that's what you meant.

You didn't give us anything. There are many reasons for many problems, telling us only the problem without any other information is very unhelpful. If you can't relay anything else, your best bet it to just post the script along with a brief description of your problem, as well as any possible solutions you may have already tried. Like Drake said, we can "best guess" the problem due to other people running into similar obstacles (and the very likely mistakes they made), but once you get better at scripting your problems will become more elaborate and we won't be able to guess it based off of your coding skill as we perceive it.

The best way to receive help is to post your script.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on May 14, 2010, 02:10:57 AM
Goddammit adding any comments gives me a script_enemy_main error WHY DO YOU DO THIS TO ME

Code: [Select]
#TouhouDanmakufu
#Title[Hibachi]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
let frame = 0;
let attack = 5;

@Initialize
{
LoadUserShotData(GetCurrentScriptDirectory ~ "supershot\supershot.txt");
SetLife(18000);
SetInvincibility(60);
MagicCircle(false);
SetRateScoreSystemEnable(false);
PlayMusic(GetCurrentScriptDirectory ~ "bgm\]-[_-34(#!.mp3");
SetMovePosition02(GetCenterX, GetCenterY - 120, 10);

}

@MainLoop
{
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);
Bombimmunity;
if(GetLife<18000 && attack == 5)
{
pew;
attack = 6;
}
if(GetPlayerLife==1){SetLife(0);}

frame++;
yield;
}

@DrawLoop
{

}

@Finalize
{
}

function Wait(frames){loop(frames){yield;}}

task Bombimmunity
{
if(OnBomb)
{
SetDamageRate(0,0);
}
else
{
SetDamageRate(100, 0);
}
}

task pew
{
}

task pew2
{
ascent(j in 0..60)
{
ascent(i in 0..30)
{
CreateShot02(GetX+50*cos(i*360/30+j*4.5), GetY+50*sin(i*360/30+j*4.5), 4, i*360/30+j*4.5, -0.02, 2, PURPLE21, 10);
}
Wait(6);
}
Wait(30);
pew;
}
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 空SoraのNo鏡Kagami on May 14, 2010, 02:46:00 AM
You didn't give us anything. There are many reasons for many problems, telling us only the problem without any other information is very unhelpful. If you can't relay anything else, your best bet it to just post the script along with a brief description of your problem, as well as any possible solutions you may have already tried. Like Drake said, we can "best guess" the problem due to other people running into similar obstacles (and the very likely mistakes they made), but once you get better at scripting your problems will become more elaborate and we won't be able to guess it based off of your coding skill as we perceive it.

The best way to receive help is to post your script.

Well, the problem was me forgetting to put #TouhouDanmakufu...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on May 14, 2010, 03:17:17 AM
There we go. That would have been solved nigh immediately if you had posted your script. Keep it in mind.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 14, 2010, 04:08:51 AM
Code: [Select]
PlayMusic(GetCurrentScriptDirectory ~ "bgm]-[_-34(#!.mp3");

WTF IS THAT!?!?!? :yumemi:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on May 14, 2010, 04:50:46 AM
http://www.youtube.com/watch?v=uYFmJxmMGYI
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on May 14, 2010, 08:29:36 PM
Had some inspiration and time to fool around with danmakufu, so I wanted to create a 12 sided TRIANGLEFAN magic circle. Now before everybody jumps the boat saying: DONT USE TRIANGLEFAN!!! USE STRIP. No, I need trianglefan here because the image I am using is not a strip like Fujiwara's circle tutorial.

Anyway, the vertex placing went smooth with some trig code ( /me brofists Drake & Naut ) but the UV placing is making me rage hard.

Code: [Select]
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
ObjEffect_CreateVertex(obj, 13);

ObjEffect_SetVertexXY(obj, 0, 0, 0);

ascent(circx in 1..13){
ObjEffect_SetVertexXY(obj, circx, circsize*cos(circx*360/11), circsize*sin(circx*360/11));
ObjEffect_SetVertexUV(obj, circx, ????, ???);   // <------- ?????????????

}

Image used: (http://i39.tinypic.com/a2ejxl.png)

Basically, how do I set up the code for the UV ? =|
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on May 14, 2010, 08:34:00 PM
No, I need trianglefan here because the image I am using is not a strip like Fujiwara's circle tutorial.
[...]
Basically, how do I set up the code for the UV ? =|
If you're not using the standard image, then nobody will know how to set up the vertices without seeing said image first.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on May 14, 2010, 08:57:46 PM
If you're not using the standard image, then nobody will know how to set up the vertices without seeing said image first.
Rectangular image, 128x128. Forgot to add to my post. It is now added.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on May 14, 2010, 11:14:27 PM
Then the coordinates should be exactly the same for UV as they are for XY. Just use half the width of the image instead of the radius of the circle, and add half the width of the image to both sets of coordinates too:

Code: [Select]
   ascent(circx in 1..13){
      ObjEffect_SetVertexXY(obj, circx, circsize*cos(circx*360/11), circsize*sin(circx*360/11));
      ObjEffect_SetVertexUV(obj, circx, 64*cos(circx*360/11)+64, 64*sin(circx*360/11)+64);
     
   }
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: 8lue Wizard on May 14, 2010, 11:26:39 PM
   ascent(circx in 1..13){
      ObjEffect_SetVertexXY(obj, circx, circsize*cos(circx*360/11), circsize*sin(circx*360/11));

typo?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on May 16, 2010, 11:12:01 AM
Blue Basil, no it is not a typo. Else the circle won't close and leaves open a triangle.

Then the coordinates should be exactly the same for UV as they are for XY. Just use half the width of the image instead of the radius of the circle, and add half the width of the image to both sets of coordinates too:

Code: [Select]
   ascent(circx in 1..13){
      ObjEffect_SetVertexXY(obj, circx, circsize*cos(circx*360/11), circsize*sin(circx*360/11));
      ObjEffect_SetVertexUV(obj, circx, 64*cos(circx*360/11)+64, 64*sin(circx*360/11)+64);
     
   }
You are ace Azure. It worked. The only thing needed was setting ObjEffect_SetVertexUV(obj, 0, 64, 64); for the first vertex, else a small gap remained open.

Thank you =3


Question #2

New question regarding math and stuff. How do I pinpoint the angle towards the player using SetMovePosition? If I apply the "homing" code from Obj Bullets the Boss starts doing weird stuff. I basically want the boss to launch itself towards the player, but continue the angular path so it moves out of the screen. Basically it is like Marisa's Blazing Star
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 16, 2010, 11:28:40 AM
I basically want the boss to launch itself towards the player, but continue the angular path so it moves out of the screen. Basically it is like Marisa's Blazing Star

I tried to do that before... remember how boss/enemy scripts have SetSpeed and SetAngle?
Code: [Select]
task movement{
    SetAngle(GetAngleToPlayer);
    SetSpeed(3);
    while(GetX>GetClipMinX-30 && GetX<GetClipMaxX+30 && GetY>GetClipMinY-30 && GetY<GetClipMaxY+30){yield;}
    SetSpeed(0);
}
Change however you want...



Now for a question of my own :V

How would you detect if something's in an OVAL... circle's are easy with:
Code: [Select]
if(((x1-x2)^2+(y1-y2)^2)^0.5<=radius)but what about ovals? I'm guessing it also uses the distance function, but a value that changes depending on the length, width and angle of the oval will replace the radius...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 16, 2010, 06:33:34 PM
Now for a question of my own :V

How would you detect if something's in an OVAL... circle's are easy with:
Code: [Select]
if(((x1-x2)^2+(y1-y2)^2)^0.5<=radius)but what about ovals? I'm guessing it also uses the distance function, but a value that changes depending on the length, width and angle of the oval will replace the radius...

This was just fucking painful. I tried out numerous prototype functions, like...

Code: [Select]
function EllipseCollision(x, y, c, d, r, s, angle, radius){
return
(s^2)(cos(angle)^2)(x^2) + (s^2)(sin(angle)^2)(y^2) - (s^2)(2)(x*cos(angle))(y*sin(angle)) - (s^2)(2)(x*c*cos(angle)) - (s^2)(2)(y*c*sin(angle)) + (s^2)(c^2) +
(r^2)(sin(angle)^2)(x^2) + (r^2)(cos(angle)^2)(y^2) + (r^2)(2)(x*cos(angle))(y*cos(angle)) - (r^2)(2)(y*d*cos(angle)) - (r^2)(2)(x*d*sin(angle)) + (r^2)(d^2) - (r^2)(d^2)
<= radius;
}

...or even...

Code: [Select]
function EllipseCollision(x, y, c, d, r, s, angle, radius){
let A = (s*s)*(cos(angle)*cos(angle)) + (r*r)*(sin(angle)*sin(angle));
let B = (s*s)*(sin(angle)*sin(angle)) + (r*r)*(cos(angle)*cos(angle));
let C = -2*((s*s)*(c*cos(angle)) + (r*r)*(d*sin(angle)));
let D = -2*((s*s)*(c*sin(angle)) + (r*r)*(d*cos(angle)));
let E = 2*((s*s)*(cos(angle)*sin(angle)) - (r*r)*(cos(angle)*sin(angle)));
let F = (s*s)*(c*c) + (r*r)*(d*d) - (r*r)*(s*s);

return A*x^2  + B*y^2  + C*x + D*y + E*x*y + F <= radius;
}

Only to find out something so fucking simple that I threw together after thinking about what we're trying to do for 30 seconds...

Code: [Select]
function EllipseCollision(x, y, c, d, r, s, angle){
return ((x-c)^2+(y-d)^2)^0.5 <= (|r*cos(angle) + s*sin(angle)|);
}

Actually works.

KILL ME NOW (http://www.shrinemaiden.org/forum/index.php?topic=5164.msg340026#msg340026)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 17, 2010, 02:33:33 AM
KILL ME NOW (http://www.shrinemaiden.org/forum/index.php?topic=5164.msg340026#msg340026)

oh god :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on May 17, 2010, 05:12:23 AM
A question about the application of subdirectory.

For example, a SC script file "script\Testing\SCs\spellcard.txt" would like to use a file in "script\Testing\img\back.jpg".

From Naut I learnt that I could use .\\img\back.jpg,

however should the quotation marks be present like:

Code: [Select]
let background = ".\\img\back.jpg";
or it's omitted or any other detail since this is not working  :(
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on May 17, 2010, 05:20:34 AM
A question about the application of subdirectory.

For example, a SC script file "script\Testing\SCs\spellcard.txt" would like to use a file in "script\Testing\img\back.jpg".

From Naut I learnt that I could use .\\img\back.jpg,

however should the quotation marks be present like:

Code: [Select]
let background = ".\\img\back.jpg";
or it's omitted or any other detail since this is not working  :(
I believe Danmakufu requires you to use the quotes.
Also, iirc it should be
Code: [Select]
let thisisastring = ".\..\..\img\back.jpg"/me is probably wrong

EDIT: Hey look (http://www.shrinemaiden.org/forum/index.php?topic=4752.0)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on May 17, 2010, 05:34:46 AM
What is the difference between . and .. ?  :ohdear:

Mukyuu?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 17, 2010, 05:37:37 AM
What is the difference between .\ and ..\ ?  :ohdear:

. is same directory, while .. is previous/outer directory
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on May 17, 2010, 06:08:57 AM
Mukyuu?
Henry is correct.

Also, Mewkyuu is the name I go by on these forums.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on May 17, 2010, 06:21:10 AM
Haven't realized...

Btw, is .\..\ equivalent to ..\ then?

Since I thought "..\test.txt" is equivalent to ".\test.txt"...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on May 17, 2010, 07:17:53 AM
.\ is the same thing as using GetCurrentScriptDirectory, while ..\moves up one directory. They are completely different things. If your script is script\test\Spell.txt and you want to access script\test\image.png, you would just use ".\image.png" as the path. If you want to access script\img\image.txt however, you will need to use ".\..\img\image.png".

Edit: using just "..\img\image.png" is completely wrong, as well as not using .\ or GetCurrentScriptDirectory at the beginning. Just don't do it.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on May 17, 2010, 08:01:48 AM
I tried to do that before... remember how boss/enemy scripts have SetSpeed and SetAngle?
Code: [Select]
task movement{
    SetAngle(GetAngleToPlayer);
    SetSpeed(3);
    while(GetX>GetClipMinX-30 && GetX<GetClipMaxX+30 && GetY>GetClipMinY-30 && GetY<GetClipMaxY+30){yield;}
    SetSpeed(0);
}
Change however you want...
You will never believe it but I totally never knew SetAngle was usable for bosses. I feel so stupid. (  '.')b Thanks. 
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on May 17, 2010, 08:02:25 AM
I've heard if a file is referenced like this:

**in script\testing\SC\1.txt**
A line: #include_function ".\..\func\draw.txt"

The relative directories in draw.txt will switch to those of 1.txt, right?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 17, 2010, 08:48:41 AM
You will never believe it but I totally never knew SetAngle was usable for bosses. I feel so stupid. (  '.')b Thanks.
:V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on May 17, 2010, 09:07:26 AM
SetAngle is only applicable to bosses, right? :]
It's just like GetX and GetY for boss  ???
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 17, 2010, 09:32:05 AM
SetAngle is only applicable to bosses, right? :]
It's just like GetX and GetY for boss  ???

I think SetAngle works for enemies also...

GetX and GetY also works for both bosses and enemies...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on May 17, 2010, 10:52:08 AM
I think SetAngle works for enemies also...

GetX and GetY also works for both bosses and enemies...

sigh...
I barely make scripts for enemies...
thank you for telling me  :D
Title: Need help with Danmakufu
Post by: Kingault on May 18, 2010, 12:47:48 AM
Whenever I insert this into my script:

Code: [Select]
if(frame==60){
            CreateShot01(GetX, GetY, 3, GetAngleToPlayer, RED01, 10);
            frame = 0;
        }
        frame++;

This happens:

(http://img64.imageshack.us/img64/2453/bullcj.jpg)


I have gone through the Error Message Troubleshooting guide, but still no change.

Here is the entire @MainLoop part of the script:
Code: [Select]
@MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 24);
        if(frame==60){
            CreateShot01(GetX, GetY, 3, GetAngleToPlayer, RED01, 10);
            frame = 0;
        }
        frame++;
    }


Please help. Thanks in advance.




Title: Re: Need help with Danmakufu
Post by: Demonbman on May 18, 2010, 12:50:24 AM
These sort of things belong in the Q&A (http://www.shrinemaiden.org/forum/index.php?topic=4771.0) thread that we have in here.


But IOW your problem is likely because you havent defined Frame as a variable
Title: Re: Need help with Danmakufu
Post by: Kingault on May 18, 2010, 12:52:29 AM
These sort of things belong in the Q&A (http://www.shrinemaiden.org/forum/index.php?topic=4771.0) thread that we have in here.


But IOW your problem is likely because you havent defined Frame as a variable
Ah.
I can't believe I forgot that.
Thanks.

Also, I can't believe I didn't see the Q&A thread.
Going to try what you said.


EDIT: It works! Thanks.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Alfred F. Jones on May 18, 2010, 12:55:55 AM
These sort of things belong in the Q&A (http://www.shrinemaiden.org/forum/index.php?topic=4771.0) thread that we have in here.

Oh what a good idea for a merge
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 18, 2010, 12:57:13 AM
Thank you Mr./Ms. Ichigo Rurouni
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kingault on May 18, 2010, 01:13:03 AM
Thank you Mr./Ms. Ichigo Rurouni

And thank you!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on May 18, 2010, 10:46:13 PM
Having a problem that makes me want to rip my hair out. I even wrote up a diagram and everything to make sure I had it right, and I'm pretty sure I do.

The problem is, I want to spawn 13 bullets on top of the boss that will move in neat half-circles and end up 200 dist away from their starting point. For some reason, the bullets either don't move, or spawn around one of the circles that one of the bullets is supposed to travel along.

Code: [Select]
let ShootAngle=0;

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

if(frame==120){
loop(13){
DreamBullet(ShootAngle, 200);
ShootAngle+=360/13;
}
}
frame++;
}
Code: [Select]
task DreamBullet(ANGLE, MaxDist){

let obj_DBUL=Obj_Create(OBJ_SHOT);

let AngleToBoss=atan2(GetEnemyY-Obj_GetY(obj_DBUL), GetEnemyX-Obj_GetX(obj_DBUL));

Obj_SetPosition(obj_DBUL, GetX, GetY);
Obj_SetAngle(obj_DBUL, ANGLE);
Obj_SetSpeed(obj_DBUL, 0);
ObjShot_SetGraphic(obj_DBUL, WHITE02);
ObjShot_SetDelay  (obj_DBUL, 20);
ObjShot_SetBombResist (obj_DBUL, true);

yield;

while(Obj_BeDeleted(obj_DBUL)==false){

ascent(var in 0..(180/5)+1){
Obj_SetPosition(obj_DBUL, (GetX+(0.5*MaxDist)*cos(ANGLE)) +(0.5*MaxDist)*cos((var*5)+AngleToBoss), (GetY+(0.5*MaxDist)*sin(ANGLE)) +(0.5*MaxDist)*sin((var*5)+AngleToBoss));

yield;
}

yield;
}
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 18, 2010, 10:49:21 PM
I believe your problem is that you don't have "ANGLE" increasing by anything resulting in the Bullet spawning at the right place but does not move
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on May 18, 2010, 11:29:46 PM
That is not the problem considering he's moving the bullet manually instead of using angles and speed.

First of all, you don't need the yield before the while loop.
Second, you don't even need the while loop considering you have nothing deleting the bullet, as well as yields inside the ascent anyways. What will end up happening in this case is that it'll reach the end of the ascent, then loop back around because of the while and do everything over, which I presume you don't want.
Third, I find it odd that you're using an ascent for the bullet behaviour and that you use a while loop with an extra variable for spawning the bullets in a circle. You should probably switch those around.

In addition you could probably compute the half-circles in a different way, but fix those things first and see what happens.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Gc on May 18, 2010, 11:45:49 PM
Code: [Select]
let ShootAngle=0;

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

if(frame==120){
loop(13){
DreamBullet(ShootAngle, 200);
ShootAngle+=360/13;
}
}
frame++;
}
No yield; in MainLoop
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on May 19, 2010, 12:03:04 AM
Demonbman: The angle is actually increased back when ShootAngle is modified in the loop that calls DreamBullet.

Drake: I fixed points one and two (nothing changed, unfortunately). That yield that was stuck in before the while statement is what caused the bullets to either spawn on top of the boss or in a circle; either way the bullets don't move at all.

The reason I keep changing the bullet position is because it's an easier way of moving them in a circle, at least I think. Instead of telling the bullet to move a certain distance and then turn at a certain angle, I'm just resetting the position of the bullet every frame in order to make it look like it's moving. Then all I have to do is use trig on a single changing angle variable. For this particular pattern, the bullet is supposed to move around a radius that itself lies on a circle around the boss. I can draw a diagram to help illustrate this if it would help.

The Cube: DERPA DERPA DERP  :V

Well now the bullets move in a half circle but as a uniform ring starting from where the other ring spawned. At least they're moving though.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on May 19, 2010, 12:21:37 AM
The reason I keep changing the bullet position is because it's an easier way of moving them in a circle, at least I think. Instead of telling the bullet to move a certain distance and then turn at a certain angle, I'm just resetting the position of the bullet every frame in order to make it look like it's moving. Then all I have to do is use trig on a single changing angle variable. For this particular pattern, the bullet is supposed to move around a radius that itself lies on a circle around the boss. I can draw a diagram to help illustrate this if it would help.
I know that. I use it in pretty much everything I do.

also GFDI
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on May 19, 2010, 12:35:27 AM
Oh, I thought that was what your point three was about. I'm not sure what you meant then.  :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 19, 2010, 05:18:18 AM
Shot replace script error I can't understand :ohdear:
Code: [Select]
---------------------------
error
---------------------------
弾定義ファイルにエラーがあります。
**************insert path to replace script here*************
tokenizer:不正なファイルの終端です
---------------------------
OK   
---------------------------

scripts:
Code: [Select]
#UserShotData

ShotImage = ".\shot_all.png"

ShotData{ id = 1 rect = (38,0,214,173) render = ALPHA delay_color = (255,0,0) }
...
insert id's 2-99 here
...
ShotData{ id = 100 rect = (458,1551,498,1580) render = ALPHA delay_color = (255,128,0) }
and
Code: [Select]
let RED05=3;let ORANGE05=4;let YELLOW05=5;let GREEN05=6;let AQUA05=7;let BLUE05=8;let PURPLE05=9;let WHITE05=2;
...
insert replace things for every other id here
...
function initmeh{
LoadUserShotData(GetCurrentScriptDirectory~"shot_all.txt");
}

yes... the script calling it is in the same directory as both scripts and the image...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 19, 2010, 05:35:22 AM
The tokenizer error pops up randomly in a shot sheet. It happens when something isn't quite right with your sheet.


My way to solve this, is to comment out ids 1-50, then test the sheet, if it works, then the error is somewhere in the below 50 ids, if it doesn't, then its in the above 50 ids, and repeat as neccesary until you find the id that is causing the error
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 19, 2010, 06:16:35 AM
The tokenizer error pops up randomly in a shot sheet. It happens when something isn't quite right with your sheet.


My way to solve this, is to comment out ids 1-50, then test the sheet, if it works, then the error is somewhere in the below 50 ids, if it doesn't, then its in the above 50 ids, and repeat as neccesary until you find the id that is causing the error

you wouldn't believe this...

it worked after I REMOVED all of the comments on the text file... (comments to help me remember what id is what color and stuff)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on May 19, 2010, 08:43:42 AM
My guess is with your previous error that somewhere a  "/'  was forgotten in front of the ******  or forgot to end with a slash. As I notice the ****** part showed up in the error msg. Just a wild guess because bad termination of the /*   */ comment block causes very weird errors that make you rage.

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Gc on May 19, 2010, 01:44:19 PM
you wouldn't believe this...

it worked after I REMOVED all of the comments on the text file... (comments to help me remember what id is what color and stuff)
yep, Danmakufu is retarded with shot sheets. // comments make it crash (tokenizer), but you can use /* */ comments in the beginning. (I did not try /* */ lower in the shot definition files)

My guess: it's because there's no end-of-line ( ; ) in shot sheets and if you // comment, it goes to the end of the file, it comments out the end-of-file flag and DMF doesn't know what to do then, making it crash.

But don't quote me on that
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on May 19, 2010, 04:18:12 PM
Shotsheets are entirely determined by tokens. Why it's this way instead of code, I have no idea. But it does mean that // comments can possibly fuck up tokenizing hard, even if it doesn't look it.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Suikama on May 19, 2010, 04:22:37 PM
yep, Danmakufu is retarded with shot sheets. // comments make it crash (tokenizer), but you can use /* */ comments in the beginning. (I did not try /* */ lower in the shot definition files)

My guess: it's because there's no end-of-line ( ; ) in shot sheets and if you // comment, it goes to the end of the file, it comments out the end-of-file flag and DMF doesn't know what to do then, making it crash.

But don't quote me on that
This explains a lot...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Shade on May 19, 2010, 07:18:00 PM
Pffft. I got a awesome new computer, and now when I try to load danmakufu, it lets me make a selection, but when I click on Concealed the conclusion, or anything that's supposed to load regularly, it immediately takes me out of the game, and says that th_dfh has stopped working, windows is now checking for a solution: A problem is preventing the game from loading.

No duh. >.>


Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 19, 2010, 08:00:59 PM
Use AppLocale. (http://www.shrinemaiden.org/forum/index.php?topic=4292.0)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Shade on May 19, 2010, 08:01:47 PM
I can try that, but the thing is I can play plural.

I guess it's worth a shot.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: puremrz on May 20, 2010, 05:44:41 PM
Question~

I want to make a flag-like motion on an effect object, so I figured it needs more than 4 vertices for that. But the problem is, how do I set that up? All I understand now is how to make 4-vertices objects.
For example, I want to make a rectangle that has its vertices like this:

(http://i32.photobucket.com/albums/d49/puremrz/hmmm.jpg)

How do I do this without making the image look undistorted?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on May 20, 2010, 06:26:57 PM
Let's assume the picture is width x height.

Relevant code parts:

On creation:
Code: [Select]
ObjEffect_CreateVertex(obj, 2*(n));
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);

let bgphi=0;
let wave= whatever ;
let n= whatever ;

In the while(){} loop, something like this:
Code: [Select]
bgphi-=2.5;

ascent(i in 0..n){

ObjEffect_SetVertexUV(obj, 2*i, 0, 512*2*i/n);
ObjEffect_SetVertexUV(obj, 1+2*i, width, 512*2*i/n);

ObjEffect_SetVertexXY(obj, 2*i,  -width/2  + width*i/n + 50*sin(bgphi+wave*i)*0.01^(1-i/n) ,height/2 + 10*sin(bgphi+wave*i) );
ObjEffect_SetVertexXY(obj, 1+2*i,  -width/2 + width*i/n + 50*sin(bgphi+wave*i)*0.01^(1-i/n) , -height/2 + 10*sin(bgphi+wave*i) );

}

With a sufficiently high n, it should look alright.
The higher the value of wave, the more ripples the flag will have. A higher n requires a proportionally lower wave.
The values of 15 and 8 determine by how much the picture waves up/down and towards/away from the viewpoint. Adjust the values according to the height of the picture and the supposed strength of the wave effect.


The code might have some typing errors, please watch warmly until the testing is done...

Done.

...say, did  you actually want the "flag" to be "fixed" at a "pole" on the left side, or something different?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: SparklingOrange on May 20, 2010, 07:12:18 PM
Hi. Excuse me for butting in, but since this is a Q&A thread...I have a couple of things to ask (which may have been answered already...I dunno)

1.) I can't play bgm at all...I've tried calling the file into a variable (or calling the file directly) and playing it with PlayMusic(), but it won't play. This works with sound effects, but I can't seem to get my mp3 files to work. Is it the file I'm using, or am I just scripting it wrong? If it's the file, what are supposed to be the proper specs for Danmakufu to play the file?

Here's the code for my stage script:
Code: [Select]
#?????e????[Stage]
#Title[EoMT Stage 1]
#Text[]
#Image[]
#BackGround[Default]
#Player[.\player\robo_b.txt]
#ScriptVersion[2]

script_stage_main
{
let get = GetCurrentScriptDirectory;
let cx = GetCenterX();
let cy = GetCenterY();

@Initialize{
Stage();
}
@MainLoop{yield;}
@Finalize{
}

task Stage{
PlayMusic(get~"bgm\st1.mp3");
wait(60);
CreateEnemyFromFile(get~"stg1enemy1.txt",cx+25,0,0,0,0);
CreateEnemyFromFile(get~"stg1enemy1.txt",cx-25,0,0,0,0);
wait(30);
CreateEnemyFromFile(get~"stg1enemy1.txt",cx,0,0,0,0);
CreateEnemyFromFile(get~"stg1enemy1.txt",cx+45,0,0,0,0);
CreateEnemyFromFile(get~"stg1enemy1.txt",cx-45,0,0,0,0);
wait(30);
CreateEnemyFromFile(get~"stg1enemy1.txt",cx+25,0,0,0,0);
CreateEnemyFromFile(get~"stg1enemy1.txt",cx-25,0,0,0,0);
CreateEnemyFromFile(get~"stg1enemy1.txt",cx+75,0,0,0,0);
CreateEnemyFromFile(get~"stg1enemy1.txt",cx-75,0,0,0,0);
WaitZeroEnemy();
wait(60);
CreateEnemyBossFromFile(get~"stg1midboss_normal.txt",cx,0,0,0,0);
WaitZeroEnemy();
CreateEventFromScript("Talk1");
while(OnEvent()){yield;}
wait(120);
CreateEnemyBossFromFile(get~"stg1boss_normal.txt",cx,0,0,0,0);
WaitZeroEnemy();
wait(60);
CreateEventFromScript("Talk2");
while(OnEvent()){yield;}
wait(60);
Clear();
}
//wait function, simulates if statement
function wait(w){
loop(w){yield;}
}
//halts script until there aren't any enemies on screen
function WaitZeroEnemy(){
while(GetEnemyNum()!= 0){yield;}
}
}

And here's the gist of the code for my starting boss event script...do I need to stop the last bgm first before playing the next one?
Code: [Select]
script_event entertalk(){
let get = GetCurrentScriptDirectory;
@Initialize{
}
@MainLoop{
TextOutA("\c[AQUA]Gist of text");
PlayMusic(get ~ ".\bgm\st1b.mp3");
TextOutA("\c[RED]Text");
SetStep(2); //sets life to 0 so it moves to the next boss subscript
}

@Finalize{
}

//wait function, simulates if statement
function wait(w){
loop(w){yield;}
}
}


2.) How do I put in frames? By frames I mean the decorative window around the playing area and the scorelists.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: puremrz on May 20, 2010, 07:37:01 PM
*omgmaths*

Wooh, thanks, it worked! ^_^
It's not really a flag, but that's just the best way to describe the effect. I'm aiming to use this as a background object for a boss, so it doesn't need to be attached to anything.
It looks great as it is now, but I'll be sure to mess around with it and see what terrible things happen if I input the wrong numbers :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on May 20, 2010, 07:41:34 PM
Wooh, thanks, it worked! ^_^
It's not really a flag, but that's just the best way to describe the effect. I'm aiming to use this as a background object for a boss, so it doesn't need to be attached to anything.
It looks great as it is now, but I'll be sure to mess around with it and see what terrible things happen if I input the wrong numbers :V

Are you trying to make a background that looks like waves on a river of blood and fire, by any chance? Because I have perfectly copypastable code for that *points to sig*  :V


In any case, if the waving picture is larger than the screen and is supposed to wave the same everywhere, just remove the *0.01^(1-i/n) from the SetVertexXY commands.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kingault on May 20, 2010, 11:13:29 PM

1.) I can't play bgm at all...I've tried calling the file into a variable (or calling the file directly) and playing it with PlayMusic(), but it won't play. This works with sound effects, but I can't seem to get my mp3 files to work. Is it the file I'm using, or am I just scripting it wrong? If it's the file, what are supposed to be the proper specs for Danmakufu to play the file?

Here's the code for my stage script:
Code: [Select]
#?????e????[Stage]
#Title[EoMT Stage 1]
#Text[]
#Image[]
#BackGround[Default]
#BGM[.\bgm.mp3]
#Player[.\player\robo_b.txt]
#ScriptVersion[2]
Fixed the BGM problem.

Or did you mean something else?
EDIT: Yeah, you meant something else. Sorry
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on May 21, 2010, 12:18:00 AM
Hi. Excuse me for butting in, but since this is a Q&A thread...I have a couple of things to ask (which may have been answered already...I dunno)

1.) I can't play bgm at all...I've tried calling the file into a variable (or calling the file directly) and playing it with PlayMusic(), but it won't play. This works with sound effects, but I can't seem to get my mp3 files to work. Is it the file I'm using, or am I just scripting it wrong? If it's the file, what are supposed to be the proper specs for Danmakufu to play the file?

You have to call LoadMusic(path) before calling PlayMusic(path).
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: durdur on May 21, 2010, 12:45:28 AM
Sorry if this has been asked before (i looked through this thread first and nothing about it showed up)
Newbie/mathematical question:
how does one make a circle of bullets (that spawns around the player) that follow the circle's circumference (and stay there) without using tasks? i hope its possible, because i've been experimenting with CreateShotA, SetShotDataA and SetShotDataA_XY for the past 3 days and nothing >.>  I get the spawning circle part right....i just can't seem to get the bullets to go along the circle's circumference. I'm sure it works with atan2 or something like that, but i fail at math D: can someone explain please  :derp:?

here is the snippet of code i've been working on, maybe it helps:

Code: [Select]
    @MainLoop {
SetCollisionA(GetX, GetY, 31);
SetCollisionB(GetX, GetY, 31);
count++;
angle++;
circle++;

if(count==200){
loop(6){
CreateShotA(1, GetPlayerX + 100*cos(angle), GetPlayerY + 100*sin(angle), 15);
SetShotDataA_XY(1, 0, 1, 0, 0, 0, 0, 0, 213);
angle += 360/6;
FireShot(1);
}
angle = 0;
count = 0;
}
 }

Notes: Currently the bullets just go to right and all spawn facing right.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on May 21, 2010, 12:56:18 AM
Is there any particular reason you don't want to use tasks? It would make things a lot easier, and using them isn't hard, if that's what you think.

Anyways, the easiest thing I think would be to define a point that lies on the player than then if the point's position changes, have the bullet's positions change by the same amounts.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: CK Crash on May 21, 2010, 01:11:27 AM
Sorry if this has been asked before (i looked through this thread first and nothing about it showed up)
Newbie/mathematical question:
how does one make a circle of bullets (that spawns around the player) that follow the circle's circumference (and stay there) without using tasks? i hope its possible, because i've been experimenting with CreateShotA, SetShotDataA and SetShotDataA_XY for the past 3 days and nothing >.>  I get the spawning circle part right....i just can't seem to get the bullets to go along the circle's circumference. I'm sure it works with atan2 or something like that, but i fail at math D: can someone explain please  :derp:?

Code: [Select]
let pi = 3.14159265;

@MainLoop
{
SetCollisionA(GetX, GetY, 31);
SetCollisionB(GetX, GetY, 31);

count++;
angle++;
circle++;

if(count==200)
{
loop(6)
{
CreateShotA(1, GetPlayerX + 100*cos(angle), GetPlayerY + 100*sin(angle), 15);
SetShotDataA(1, 0, 1, angle+90, 360/(200*pi), 0, 0, 213);
angle += 360/6;
FireShot(1);
}
angle = 0;
count = 0;
}
}
The bullet must make a 360 degree turn in the amount of time it takes to travel the length of the circumference, so I used 360/(200*pi) for the bullet's curve per frame. Remember that it must scale with the speed in order to work with faster bullets.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: durdur on May 21, 2010, 02:02:20 AM
Thank you Onthenet^^ it worked perfectly.

Quote
Elementoid: Is there any particular reason you don't want to use tasks?

i was curious :p (and tasks still make me cry  :ohdear:)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on May 21, 2010, 02:45:11 AM
In a similar vein, I've been wondering how ZUN produces all the pretty patterns he does. His bullet control is astounding, I'm not sure where I could even begin replicating his patterns.

Kappa's Porocora comes to mind, for starters, and the similar version of it Kanako uses in MoF's extra. Another would be Wriggle's "Night Bug Storm" (I think?) where he manages to shoot out the bullets and make them align in a circle.

Man. How does he do it?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on May 21, 2010, 02:50:27 AM
Practice, patience, trial-and-error, and lots and lots of trig. Some of the patterns are simpler than they look as long as you can figure out the math behind it.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on May 21, 2010, 06:40:43 AM
**Problem solved**

Careless use of case in Header BackGround

Hooray to psuedo-English

However, in a stage script the @DrawLoop doesn't seem to work  :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on May 21, 2010, 08:20:44 AM
@DrawLoop doesn't work in stage scripts. All background drawing must be done with @BackGround
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on May 21, 2010, 08:41:59 AM
Oh...

Now with the @BackGround and @DrawLoop, the same background can scroll within the stage (only if no other @BackGround is used)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: SparklingOrange on May 21, 2010, 04:15:28 PM
You have to call LoadMusic(path) before calling PlayMusic(path).

Yep, I've done that when I called it as a variable, but it didn't work (I could've sworn the bgm thing worked before when I was using Helepolis' tutorials, but it was a different mp3 file). Do you still need to use LoadMusic() when calling it in as a directory? I kinda scripted it the way it is right now  'cause I was analyzing Stuffman's PoSR game script.

And I'm still not sure how to implement customizable game frames...it's not in the tutorials in the forum. Does it have to be drawn in the script like everything else?

EDIT: Tried what you suggested, but it's still not working.
Code: [Select]
@Initialize{
LoadMusic(get~".\bgm\st1.mp3");
Stage();
}
@MainLoop{yield;}
@Finalize{
}

task Stage{
PlayMusic(get~".\bgm\st1.mp3");
.....
Is there something I'm doing wrong? Arrgh....
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 21, 2010, 04:40:37 PM
Do you still need to use LoadMusic() when calling it in as a directory?

Everything needs to be loaded before it can be played, with the exception of sound effects, which are so small that they are automatically loaded upon a PlaySE() call.

Is there something I'm doing wrong? Arrgh....

Remove the .\ from the path name. Both .\ and GetCurrentScriptDirectory do the same thing under different circumstances, so just remove on of them. If that doesn't work, check your pathnames and try to re-encode your .mp3, sometimes shit just doesn't play due to variable bitrates and whatever else.

And I'm still not sure how to implement customizable game frames...it's not in the tutorials in the forum. Does it have to be drawn in the script like everything else?

If you just want your own personal game frame that only you can see (or anybody else that uses your copy of th_dnh), you can place a 640x480 .png image called STG_Frame.png in the root img folder, pathname "~\img" (meaning that you create a folder called img in the same folder as th_dnh.exe, and place the image there). If you want other people to see your game frame during your script, you can either tell people to put this certain image in their img folder (which people probably will not do), or you can draw a layer 8 OBJ_EFFECT over top of the game frame. Keep in mind that redrawing such a large image every frame can get costly, and if you spawn it inside an enemy script it will delete itself once the enemy dies. You'll need to create the object in a stage script and just have it sit over top of the game window. You'll also need to redraw the score, life, bomb and graze counters, since they will be covered by your image. It's probably not worth your time unless you're making a very large script, like a full game.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on May 21, 2010, 09:27:30 PM
Could someone explain @DrawTopObject and @DrawBottomObject ?
I've seen them in some scripts like the TH08 Phantasm (the one with Yukarin and Flan).
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: SparklingOrange on May 22, 2010, 03:49:45 AM
Everything needs to be loaded before it can be played, with the exception of sound effects, which are so small that they are automatically loaded upon a PlaySE() call.

Remove the .\ from the path name. Both .\ and GetCurrentScriptDirectory do the same thing under different circumstances, so just remove on of them. If that doesn't work, check your pathnames and try to re-encode your .mp3, sometimes shit just doesn't play due to variable bitrates and whatever else.

If you just want your own personal game frame that only you can see (or anybody else that uses your copy of th_dnh), you can place a 640x480 .png image called STG_Frame.png in the root img folder, pathname "~\img" (meaning that you create a folder called img in the same folder as th_dnh.exe, and place the image there). If you want other people to see your game frame during your script, you can either tell people to put this certain image in their img folder (which people probably will not do), or you can draw a layer 8 OBJ_EFFECT over top of the game frame. Keep in mind that redrawing such a large image every frame can get costly, and if you spawn it inside an enemy script it will delete itself once the enemy dies. You'll need to create the object in a stage script and just have it sit over top of the game window. You'll also need to redraw the score, life, bomb and graze counters, since they will be covered by your image. It's probably not worth your time unless you're making a very large script, like a full game.

I gave up and converted the mp3 files into wav, which is costly in size, but it works nonetheless...so it looks to be a file problem then...

As for the frame thing, the default root file method is exactly what I wanted to do. Thanks for the tip. Drawing it would be pretty cool too, but since you've mentioned the disadvantages, maybe it could be done in another time...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on May 22, 2010, 04:37:55 AM
How would one use Shot11 or Shot12 in combination with sunburst patterns? For example, creating a firework-like sunburst in which the bullets start to fall.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 22, 2010, 04:41:50 AM
You couldn't, you would have to use SetShotData_XY for that kind of pattern
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on May 22, 2010, 04:54:47 AM
Hm. Then, how do I set the arguments to give the bullets the initial angles of the burst?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on May 22, 2010, 05:00:43 AM
Set Them to go straight verticle with a little random horizontal with a little verticle decreasement but not enought to make the bullets stop or back track, yet , then after a while, have the increase the decreasement of the bullets as well as the randomness of the horizontal movements.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 22, 2010, 05:41:28 AM
How would one use Shot11 or Shot12 in combination with sunburst patterns? For example, creating a firework-like sunburst in which the bullets start to fall.

actually...
Code: [Select]
function fireworks(x, y){
    let angle=rand(0, 359);
    ascent(i in 0..12){
        CreateShot12(x, y, cos(angle+i*30)+rand(-0.0033, 0.0033), sin(angle+i*30)+rand(-0.003, 0.003), 0.0003*-cos(angle+i*30), rand(0.01, 0.02), 0.001*cos(angle+i*30), rand(1, 2), RED01, 10);
    }
}
You can edit it a bit to fit your speed, but that's basically it :V (I made it slow cause when it was fast, it went out of the screen :derp:)....... you can make it spawn really fast but slow down fast too or something...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 22, 2010, 11:22:56 PM
I'm making a curving installation laser for a player script using a 32 vertex TRIANGLEFAN rectangular object effect. It's fucking up.

My image is 128x256 (http://i47.tinypic.com/2v3py1g.png). There are 16 vertices on one side, 16 on the other. Here's the code for the laser task, which is called every time you hit the shot key:

Code: [Select]
let obj = Obj_Create(OBJ_EFFECT);
ObjEffect_SetTexture(obj, serpLaserImg);
ObjEffect_SetRenderState(obj, ALPHA);
ObjEffect_SetLayer(obj, 2);
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
ObjEffect_CreateVertex(obj, 32);
let scroll = 0;
while(GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD){
let x = GetPlayerX;
let y = GetPlayerY;
scroll--;

//The coordinates of each vertex on the image. 16 vertices on one side, 16 on the other.
ascent(i in 0..16){
ObjEffect_SetVertexUV(obj, 0 + i, 0, 0 + 8*i + scroll);
ObjEffect_SetVertexUV(obj, 31 - i, 128, 0 + 8*i + scroll);
}

//Set the vertices.
ascent(i in 0..16){

//Moves the center point of each pair of vertices up, curving slightly depending on if the player is moving left or right.
if(i>0){
x+=32*cos(270 + appliedAngle*(i+1));
y+=32*sin(270 + appliedAngle*(i+1));
}

//Set the position of the vertices. Each vertex is 32 pixels perpendicular to the center point of each vertex pair (x, y) on either side (+-90 degrees).
ObjEffect_SetVertexXY(obj, i, x + 32*cos(180 + appliedAngle*(i+1)), y + 32*sin(180 + appliedAngle*(i+1)));
ObjEffect_SetVertexXY(obj, 31 - i, x + 32*cos(0 + appliedAngle*(i+1)), y + 32*sin(0 + appliedAngle*(i+1)));
}
yield;
}
Obj_Delete(obj);
}

This produces the following images. Moving right:
(http://i50.tinypic.com/243mbrb.jpg)

Moving left:
(http://i48.tinypic.com/15i83g5.jpg)

scroll just scrolls through the laser image vertically, making it look animated. appliedAngle is a global angular modifier that is based on the player moving left and right. The longer the player holds left or right, it increases or decreases by 0.15 per frame, hitting max values of [-2.5, 2.5]. From a bullet perspective, appliedAngle would be the amount that the bullet's angle changes by per frame to look like it is curving (Obj_SetAngle(obj, Obj_GetAngle(obj) + appliedAngle);). So I'm applying this angle to each set of vertices for the laser, but it's fucking up. To me, it looks like vertex 15 and 31 are joining together for some reason. Either that, or the right side of the laser is perfectly fine and the left side is fucking up hard. I'd rather it not fuck up. Any ideas?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on May 22, 2010, 11:53:39 PM
... :/


I'm having trouble wrapping my mind around how the vertexes are supposed to map the effect together. Maybe I am just tired right now (~2 a.m. here), but there may actually be something wrong there. Instead of using PRIMITIVE_TRIANGLEFAN I'd have done it using PRIMITIVE_TRIANGLESTRIP and then, instead of dividing them into i and 31-i into 2*i and 1+2*i, if you know what I mean.

I have no idea if this will fix your problem, but I'd try it anyways.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 23, 2010, 12:11:41 AM
I've prepared an image to show my TRIANGLEFAN vertex layout:

(http://i48.tinypic.com/5ul315.png)

(actually I just realized I incorrectly labeled the vertices in this image. 1 through 15 should be on the right side, and 16 through 31 should be on the left)

Like I said, it appears vertex 15 and 31 are connecting in some way, and I don't know why. I think it may have something to do with me setting them last. I tried splitting the vertex setting into two different ascent/descent trees, and that was all sorts of fucked up.

I tried your TRIANGLESTRIP method Iryan, and the image doesn't even appear. I see what you mean though, and am still experimenting. Even if I get this to work via strip, I'd like to know why my fan method is screwing up.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on May 23, 2010, 12:23:10 AM
Yeah, I got that. However, to my knowledgde, with that arrangement of vertices and TRIANGLEFAN... well...

Youd divide the image in the triangles with the following points:

[0,1,2] (all on one line, therefore invisible)
[0,2,3] (all on one line, therefore invisible)
[0,3,4] (all on one line, therefore invisible)
...
...
[0,15,16] (makes up half the image)

[0,16,17] (from here on it works as intended)

Therefore half the image will not work out as intended

Or am I wrong here..?  :/


Edit: Damn I should go to sleep now, what with all the typing errors I miss. I want to know if it works out somehow before, though.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 23, 2010, 12:31:07 AM
Not following you at all.  :ohdear:

Using your TRIANGLESTRIP method, I get the following code:
Code: [Select]
let obj = Obj_Create(OBJ_EFFECT);
ObjEffect_SetTexture(obj, serpLaserImg);
ObjEffect_SetRenderState(obj, ALPHA);
ObjEffect_SetLayer(obj, 2);
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
ObjEffect_CreateVertex(obj, 32);
let scroll = 0;
while(GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD){
let x = GetPlayerX;
let y = GetPlayerY;
scroll--;
ascent(i in 0..16){
ObjEffect_SetVertexUV(obj, i*2, 0, 0 + 8*i + scroll);
ObjEffect_SetVertexUV(obj, 1 + i*2, 128, 0 + 8*i + scroll);
}
ascent(i in 0..16){
if(i>0){
x+=32*cos(270 + appliedAngle*(i+1));
y+=32*sin(270 + appliedAngle*(i+1));
}
ObjEffect_SetVertexXY(obj, i*2, x + 32*cos(180 + appliedAngle*(i+1)), y + 32*sin(180 + appliedAngle*(i+1)));
ObjEffect_SetVertexXY(obj, 1 + i*2, x + 32*cos(0 + appliedAngle*(i+1)), y + 32*sin(0 + appliedAngle*(i+1)));
}
yield;
}
Obj_Delete(obj);

Which has the image not even appearing. How is this screwing up?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on May 23, 2010, 12:45:48 AM
That last post of mine was highlighting what was wrong with your original method. TRIANGLEFAN divides the image in triangle in a way so that the first (zeroth) vertex is part of every triangle, wich in your case makes half of your triangles void because their points all lie on one line. Thus the image looks very asymmetrical when distorted in the ways you are doing it.


I have no idea what's wrong with your TRIANGLESTRIPified code, though. Did you change anything else, maybe? Accidentally?

Edit: BLARGH typoes.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 23, 2010, 12:48:15 AM
I have no idea what's wrong with your TRIANGLESTRIPified code, though. Did you change anything else, maybe?

Only what you told me. The code is right there, and my understanding of TRIANGLESTRIP isn't yielding any errors with it either.

That last post of mine was highlighting what was wrong with your method. TRIANGLEFAN divides the image in triangle so that the first (zeroth) vertex is part of every triangle, wich in your case makes half of your triangles void because their points all lie on tone line. Thus the image looks very asymmetrical when distorted in the ways you are doing it.

This makes a shitload more sense. Let me ponder with this.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 23, 2010, 01:00:54 AM
Fuck, go to bed Iryan. I got it. Your strip method worked perfectly, thanks a lot.
I moved the image to upload it but didnt move it back
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on May 23, 2010, 01:04:18 AM
Fuck, go to bed Iryan. I got it. Your strip method worked perfectly, thanks a lot.
I moved the image to upload it but didnt move it back
BV

Glad it works now. Hopefully it looks as awesome as I imagine it to do.

G'night.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on May 23, 2010, 01:54:52 AM
Oh man are we gonna have a WOBBLY HOMING LASER shot type in Danmakufu?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 23, 2010, 02:15:53 AM
Not wobbly or homing (and it's for Ijiyatsu). Curvy though :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: durdur on May 24, 2010, 03:39:30 AM
I got another newbie question  ::):

i've been trying to fire this loop, make it stop for a while, and then fire again. I thought this could be accomplished with a while{}, but i keep crashing danmakufu ._. can someone help me with this?

here is the code:

Code: [Select]
while(count1<=125){

CreateShotA(1, GetEnemyX + 30*cos(angle), GetEnemyY + 30*sin(angle), 15);
SetShotDataA(1, 0, 0.5, angle, 0, 0, 0, 173);
FireShot(1);

}

if(count1==165){

count = 10;
}

this is all inside the mainloop, by the way.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on May 24, 2010, 04:08:08 AM
You're not incrementing count1, so the condition "count1<=125" is always true, and this it never exits out of the loop. I think you're just looking for if instead of while, since MainLoop automatically runs once per frame - no need to use a while loop for this situation, since it basically has one built-in.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: durdur on May 24, 2010, 04:15:45 AM
Ah, thanks ^^. I changed the while statement to an if statement and it kinda works now. Just a few tweaks and it'll be done, thank you :)
(apparently i forgot that if statements can have other things than ==  ._.)
oh, and i forgot to put the variables++ in the quote. Sorry  :V

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: TheMasterSpark on May 25, 2010, 07:03:36 AM
Hello,

I just had a quick little idea a few days ago and I'd like to hear what you guys thought of it and if it'd be possible to implement.

Is there any way to assign a value to a variable that can tell if the player is using a bomb or not? I can totally envision this being awesome..

Code: [Select]

let bombing = *player using a bomb*;

if (bombing) {
    Hell breaks loose;
}

Bombers will be in for some due punishment. :]
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 25, 2010, 07:15:52 AM
Hello,

I just had a quick little idea a few days ago and I'd like to hear what you guys thought of it and if it'd be possible to implement.

Is there any way to assign a value to a variable that can tell if the player is using a bomb or not? I can totally envision this being awesome..

Code: [Select]

let bombing = *player using a bomb*;

if (bombing) {
    Hell breaks loose;
}

Bombers will be in for some due punishment. :]

actually...
if(OnBomb==true){dostuff;}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: TheMasterSpark on May 25, 2010, 07:38:13 AM
Quote from: Kylesky
actually...
if(OnBomb==true){dostuff;}

...that just sounds so obvious now that you mention it. I'm sure I've seen that OnBomb around somewhere...

Oh well, the more you learn, huh? Thanks for helping me out. :)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on May 25, 2010, 08:10:00 AM
OnBomb is true when the bomb is still effective, right?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 25, 2010, 01:35:37 PM
OnBomb is true when the bomb is still effective, right?
as long as the player is currently on the bomb, yes...



Ok... my question :V

Collision_Obj_Objは未定義の識別子です(33行目)
if(Collision_Obj_Obj(obj, hitbox)==true){

^this says that the function Collision_Obj_Obj is undefined... what's weird is... I know I called it right... 2 arguments, the 2 objects... I'm 100% sure that both obj and hitbox are shot objects, etc...

I would just use the distance formula, but the problem is that different bullets would have different sizes...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on May 25, 2010, 01:40:32 PM
Well, maybe you didn't create hitbox as a global variable but only inside a task.

Another idea would be: Did you actually call Obj_SetCollisionToObject(hitbox, true); and Obj_SetCollisionToObject(obj, true); ?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 25, 2010, 01:44:18 PM
Well, maybe you didn't create hitbox as a global variable but only inside a task.

Another idea would be: Did you actually call Obj_SetCollisionToObject(hitbox, true); and Obj_SetCollisionToObject(obj, true); ?

I did both...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on May 25, 2010, 01:47:36 PM
Wait, what kinds of objects do you want to check the collision of? I vaguely remember something along the lines of danmakufu being picky in that regard...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 25, 2010, 01:54:10 PM
Wait, what kinds of objects do you want to check the collision of? I vaguely remember something along the lines of danmakufu being picky in that regard...
both are shot objects... nevermind, it has been resolved on IRC... apparently, Collision_Obj_Obj doesn't work in player or stage scripts...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on May 26, 2010, 12:22:16 AM
I've got something I need help with, it's probably obvious. Is there a way to check if a task object exists? Like if in mainloop you wanted if(BulletExists==false){SpawnBullet;} or something to that nature. I haven't been able to figure out a way for the task to change BulletExists to false when Obj_BeDeleted(Obj)=true, for logical reasons I suppose.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on May 26, 2010, 12:46:39 AM
I've got something I need help with, it's probably obvious. Is there a way to check if a task object exists? Like if in mainloop you wanted if(BulletExists==false){SpawnBullet;} or something to that nature. I haven't been able to figure out a way for the task to change BulletExists to false when Obj_BeDeleted(Obj)=true, for logical reasons I suppose.

Create a task that checks if the object shot still exists:
Code: [Select]
let BulletExists = false;

task SpawnBullet {
   //Initializing stuff here...
   let Obj = Obj_Create(OBJ_SHOT); //Or something similar
   BulletExists = true;
   BulletExistsChecker(Obj);
   //Controlling bullet, etc. here...
}

task BulletExistsChecker (id) {
   yield;
   loop {
      if (Obj_BeDeleted(id)) {
         BulletExists = false;
         return;
      }
      yield;
   }
}

Or you could increase the scope of Obj and directly code if (Obj_BeDeleted(Obj)) {SpawnBullet;}.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on May 26, 2010, 01:12:41 AM
Is there a way to have 2 event scripts in a single talking script and between them there is some drawing effects.

I tried combining 2 event scripts into one and between them there is a looping yield; yet the whole looping yield is ignored.  :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 26, 2010, 01:37:23 AM
Just make two different events. You can use Event Steps but I find them pretty wonky, so just have two events separated by some drawing stuff.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on May 26, 2010, 01:42:03 AM
If I set the drawing stuff in the Main script (the one calling others), there will be no problem?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on May 26, 2010, 09:49:09 AM
You might want to rephrase your question a little better. It's kind of hard to understand what you mean by "drawing stuff" and "Main script". Perhaps you should give a short example of what you mean?

EDIT: Oh wait, in the context of event scripts? If you want to draw effects during an event script at a specific time during the event, you need to set and get event steps.
Title: My Danmakufu crashes instantly
Post by: DDRMANIAC007 on May 26, 2010, 09:07:18 PM
Everytime I try to run it, it shows a window of solid color, than it says that it's stopped responding. I am using Applocale to try to run it. There is nothing in the FAQ about this problem. Help!
Title: Re: My Danmakufu crashes instantly
Post by: Bitz on May 26, 2010, 10:29:31 PM
Make sure you have DirectX installed, and that your sound card and graphics card are working properly. Danmakufu doesn't like anything being out of place; when I installed a fresh copy of Windows, Danmakufu refused to run until I had all my hardware drivers and DirectX installed.
Title: Re: My Danmakufu crashes instantly
Post by: DDRMANIAC007 on May 26, 2010, 10:30:59 PM
Even though all my Touhou games work perfectly? I'll go update DirectX. I'll post in a bit.
Title: Re: My Danmakufu crashes instantly
Post by: DDRMANIAC007 on May 26, 2010, 10:37:35 PM
I can hear sound on my games, and I'm capable of running stuff like CS:S and the Touhou Projects.
Seems like everything is fine to me. I have DirectX9. No reason for Danmakufu to be not working like this. -__-
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on May 27, 2010, 01:00:20 AM
Does it do this immediately on startup, or do you choose any options?

Is it a clean install?

Tried tweaking the config options?

You could also try deleting script_index.dat, there may be an issue in that file. Rerunning danmakufu and checking your scripts forces its recreation.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on May 27, 2010, 02:01:26 AM
You might want to rephrase your question a little better. It's kind of hard to understand what you mean by "drawing stuff" and "Main script". Perhaps you should give a short example of what you mean?

EDIT: Oh wait, in the context of event scripts? If you want to draw effects during an event script at a specific time during the event, you need to set and get event steps.
If my code is like this, 2 events with a time interval between them, how should I do that effect? :ohdear:
or should I use 2 events, but the third one would not work, perhaps due to the never-ending event 2.

(in all tutorials it is taught that killing the boss would end the event, but this won't work for 2 events in a single script)
sorry for the lengthiness of my script and my poor expression  :V
Code: [Select]
script_enemy_main{
   //image and variable declaration here
   SetX(GetCenterX);
   SetY(GetClipMinY+120);
   @Initialize{
      SetLife(1);
      SetDamageRate(0,0);
      MagicCircle(false);
      CreateEventFromScript("talk2");
   }

   @MainLoop{
      if(GetEventStep==3){AddLife(-10);}
      frame++;
      yield;
   }
   @DrawLoop{
      //draw the boss image here, there is no problem for this :V
      if(GetEventStep==2&&frame2<120){event=2;}
      if(event==2){ //since here it's the drawing of an image since the boss has gone out  :V
         LoadGraphic(blank);
         SetTexture(blank);
         SetAlpha(alpha);
         SetGraphicRect(0,0,512,542);
         if(alpha<255&&token==0){alpha+=2.5;}
         if(alpha==255||token==1){token=1;frame2++;}
         if(frame2>=120&&alpha>0){alpha-=2.5;}
         if(frame2>=120&&alpha==0){event=1;}
         SetGraphicScale(1, 1);
         DrawGraphic(GetCenterX, GetCenterY);
         if(frame2>=30&&frame2<90){
            LoadGraphic(awhile);
            SetTexture(awhile);
            SetAlpha(alpha2);
            if(frame2<=50&&alpha2<255){alpha2+=255/20;}
            if(frame2>=70&&alpha2>0){alpha2-=255/20;}
            SetGraphicRect(0, 0, 615, 168);
            SetGraphicScale(0.5, 0.5);
            DrawGraphic(GetCenterX, GetCenterY);
         }
      }
   }
   @Finalize{
      DeleteGraphic(ImgBoss);
   }
}
script_event talk2{
   //image declaration here
   @Initialize{
      //loading of image here
      alternative( GetPlayerType() )
        case( REIMU_A, REIMU_B ){
           //silly conversation 1, it's not the main point
        }
        case( MARISA_A, MARISA_B ){
           //silly conversation 2, it's not the main point again
        }
        SetStep(2);
        //remove graphics here since the boss goes out for a while
        loop(324){yield;} //suppose to wait 324 but this does not work
        //load image again here
        alternative( GetPlayerType() )
        case( REIMU_A, REIMU_B ){
           //2nd part of silly conversation 1
        }
        case( MARISA_A, MARISA_B ){
           //2nd part of silly conversation 2
        }
        SetStep(3);
        //remove all graphics here
   }
   @MainLoop{
      yield;
   }
   @DrawLoop{
   }
   @Finalize{
   }
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DDRMANIAC007 on May 27, 2010, 02:05:10 AM
Does it do this immediately on startup, or do you choose any options?

Is it a clean install?

Tried tweaking the config options?

You could also try deleting script_index.dat, there may be an issue in that file. Rerunning danmakufu and checking your scripts forces its recreation.
Never had an index. Fixed by getting another copy with included stuff from a friend. I also have to run it under applocale as an administrator.
(Gotta be a better fix than that.)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 27, 2010, 02:24:10 AM
I also have to run it under applocale as an administrator.
(Gotta be a better fix than that.)

Everybody does. This is required to play. You can make a shortcut icon with Applocale, y'know. If you really don't want to do that, just switch your computer's locale to Japanese and run the program normally.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on May 27, 2010, 08:42:37 AM
If my code is like this, 2 events with a time interval between them, how should I do that effect? :ohdear:
or should I use 2 events, but the third one would not work, perhaps due to the never-ending event 2.

(in all tutorials it is taught that killing the boss would end the event, but this won't work for 2 events in a single script)
sorry for the lengthiness of my script and my poor expression  :V

long ass code here


I like how you're trying to yield 300 times in @Initialize.
An event script is not the same as a task so yielding it will not do anything. As far as I can tell, during event scripts, calling those TextOut functions actually pauses the script while the text is being displayed, so event scripts don't behave the same way as enemy scripts either. If you want to pause an event script, you can try using TextOutB and making it output a blank string and put the other parameter as the time you want to wait.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Henry on May 27, 2010, 11:33:48 AM
I like how you're trying to yield 300 times in @Initialize.
An event script is not the same as a task so yielding it will not do anything. As far as I can tell, during event scripts, calling those TextOut functions actually pauses the script while the text is being displayed, so event scripts don't behave the same way as enemy scripts either. If you want to pause an event script, you can try using TextOutB and making it output a blank string and put the other parameter as the time you want to wait.

perhaps the best solution is to use 2 scripts and stuff them into the plural script. :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on May 27, 2010, 03:26:22 PM
Wait(x)  in Event dialogue pauses the dialogue for the x-amount of seconds.

Hence why I told several people not to use 'wait' wit ha capital W as function for the task-method scripting.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: TheMasterSpark on May 27, 2010, 03:50:06 PM
There's another little thing I've been looking around for an answer to, but I've yet to find anything to help me. Is there some kind of function for shaking the screen in the way it does when you're using the Master Spark bomb in Imperishable Night and Perfect Cherry Blossom? There's also a funky laser attack in Uwabami Breakers that causes the screen to shake/tremble, and I'm sure there are more examples to be found in all of the games. So anyway, is there any kind of function for shaking the screen in that way, or would that have to be left up to the Drawing of things?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on May 27, 2010, 05:11:32 PM
It's... being worked on. There were a few different methods but I think someone was going to try render targets or something.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: TheMasterSpark on May 27, 2010, 05:16:12 PM
Alright, that's cool. :)

How about shrinking the player's field of vision, like when you're fighting Mystia in Imperishable Night? Would that work by applying a black curtain at the top layer or something like that?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on May 27, 2010, 05:46:40 PM
Alright, that's cool. :)

How about shrinking the player's field of vision, like when you're fighting Mystia in Imperishable Night? Would that work by applying a black curtain at the top layer or something like that?

Yeah, shove a giant "black curtain" Object Effect on top of everything.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: TheMasterSpark on May 27, 2010, 08:00:45 PM
Quote from: Bitz
Yeah, shove a giant "black curtain" Object Effect on top of everything.

Okay, thanks for that.

I'm sorry to be bothering you again but I seem to have run into a problem with a script of mine, and I'm more or less stumped as to what's causing it. The script revolves around a ring of Zombies spawning around the player and unless they're shot, the Zombies will all explode in unison after 3 seconds, releasing a shower of body parts. The thing here is that after the fifth ring of Zombies have been spawned, it all just starts to... well, spaz out. The sixth ring of Zombies will release only the zombie heads and the seventh ring and onwards won't appear on the screen at all, although the sound effect can still be heard. I guess it has to be something with my script enemies, since a regular ring of bullets works without issues..

Here's a link the code~

Linky! (http://pastebin.com/eTYjubk5)

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on May 27, 2010, 08:34:43 PM
First of all, please use pastebin from now on if you could. Scrolling down a page of entire scripts is really tedious.

The only thing I noticed that was odd right away was the wait(3.3);. Why exactly are you trying to loop a decimal, it doesn't work. Probably not the problem, just saying.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: TheMasterSpark on May 27, 2010, 08:40:06 PM
Ah right, sorry about that Drake. I'll modify the post and include a link to pastebin instead.

About that wait(3.3), to be perfectly honest I found inspiration for that in one of Helepolis' scripts and used it without question. It seems to work just fine, despite being a decimal~

Edit: I've fiddled around some more, trying to isolate the cause of the problem. I think it has something to do with the firing of the body parts. I tried removing the self-detonation process and the rings of Zombies would then spawn as intended. However, once I had shot enough of them (which also causes them to explode) the same issue crept up, with no more Zombie rings appearing. Is there anything wrong with how I've linked the various familiars together?

As a side question, what is the last parameter used in CreateEnemyFromScript? The Wiki says that it's a "User-defined argument" but I still haven't really been able to determine what that is, exactly..
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on May 28, 2010, 03:32:45 PM
As a side question, what is the last parameter used in CreateEnemyFromScript? The Wiki says that it's a "User-defined argument" but I still haven't really been able to determine what that is, exactly..

That's just an extra argument for when you're making multiple enemies with the same script...

For example, if you're trying to make multiple familiars or enemies with only a small difference, you can create them using the same script... Useful if, for example, you have multiple enemies with the same pattern, but shooting at different angles... just set their angles in that last argument than call this in the script
Code: [Select]
let angle=GetArgument;
or something like that...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on May 28, 2010, 04:40:44 PM
Basically, it's any extra value you want to pass along to your enemy script from wherever you're spawning it. As Kylesky said, just use GetArgument inside the enemy script to retrieve that value. Can be boolean, numerical, String/array, char -- whatever you want it to be -- it's "user-defined" after all.

Also, yeah, you can pass decimals in the "loop" function, but I'm not sure what that does. I'd hypothesize it either truncates or rounds the decimal somehow.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: TheMasterSpark on May 28, 2010, 04:50:27 PM
Alright, thanks for clearing that up for me. :)

Continuing with my current problem, can only a finite number of script enemies be used at any one time? Since a single ring of zombies consist of 60 scripted enemies in one go (10 zombies, 50 body parts), that might be putting some strain on the game?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on May 28, 2010, 05:40:05 PM
The maximum is 256, I believe. If they're not deleting themselves correctly, it could be a problem. You could probably use object bullets for the body parts to cut down on the load.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: TheMasterSpark on May 28, 2010, 06:13:50 PM
Quote from: Azure Lazuline
The maximum is 256, I believe. If they're not deleting themselves correctly, it could be a problem. You could probably use object bullets for the body parts to cut down on the load.

Ah, now that seems to be it!

Another lesson learned - do not abuse script enemies. :)

Now I need to get cracking on making the graphics available for object bullets..

Thanks a lot. :)

Edit: I feel almost embarassed to ask about a thing like this, but I seem to have hit a little snag with my bouncing bullets. I want the bullets to bounce from whichever border of the field that it hits, but I can only get the ones on the Y-axle to work. Here's how the relevant code looks..

Code: [Select]
while(!Obj_BeDeleted(obj)){

if(Obj_GetY(obj) > GetClipMaxY) {
Obj_SetAngle(obj,-dir); //This one works..
}

if(Obj_GetY(obj) < GetClipMinY) {
Obj_SetAngle(obj,-dir); //This one too..
}

if(Obj_GetX(obj) > GetClipMaxX) {
Obj_SetAngle(obj,-dir); //This one doesn't..
}

if(Obj_GetX(obj) < GetClipMinX) {
Obj_SetAngle(obj,-dir); //And neither does this one..
}
yield;
}

Does the code for bouncing bullets on the X-axle look any different than that?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Gc on May 29, 2010, 07:33:57 PM
Code: [Select]
while(!Obj_BeDeleted(obj)){

if(Obj_GetY(obj) > GetClipMaxY) {
Obj_SetAngle(obj,-dir); //This one works..
}

if(Obj_GetY(obj) < GetClipMinY) {
Obj_SetAngle(obj,-dir); //This one too..
}

if(Obj_GetX(obj) > GetClipMaxX) {
Obj_SetAngle(obj,-dir); //This one doesn't..
}

if(Obj_GetX(obj) < GetClipMinX) {
Obj_SetAngle(obj,-dir); //And neither does this one..
}
yield;
}

Does the code for bouncing bullets on the X-axle look any different than that?
[/quote]
IIRC, to bounce something on the X axis, you have to use 180 - *current angle*
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: TheMasterSpark on May 30, 2010, 08:09:23 PM
Quote from: The Cube
IIRC, to bounce something on the X axis, you have to use 180 - *current angle*

Yup, that was it. Thanks. :)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Thaws on June 01, 2010, 12:18:13 PM
Uh... I saw several people mention regarding shotsheets that dimensions are preferred to be in power of 2.

Well.. I didn't know about this before therefore I haven't done so.

So I was wondering what's the significance of doing this?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on June 01, 2010, 12:32:26 PM
Uh... I saw several people mention regarding shotsheets that dimensions are preferred to be in power of 2.

Well.. I didn't know about this before therefore I haven't done so.

So I was wondering what's the significance of doing this?
Fujiwara did a quality check on my shotsheet and discovered that if the dimensions of the image isn't a power of 2, it will show up with distorted or bleach colours in game. This goes for any image that is loaded into danmakufu. I don't know for sure if the same counts for graphicrects (don't think so). But for images it does.

So basically a image of 256x256 = ok,  253x129 is bad. My expanded shotsheet is 513x768 which is also bad.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on June 01, 2010, 06:02:55 PM
In most cases, it honestly doesn't matter - it's just a very small upgrade in quality. But if you're going to be looking at this image hundreds of times in every level, it should look as good as possible.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: SparklingOrange on June 01, 2010, 08:39:24 PM
I'm having a huge issue where my script looks to be correct, but when executed, causes Danmakufu to freeze. Whether I'm causing an overflow or not, it's really frustrating. I'm trying to make an enemy script where it shoots a circle shot similar to the spinners in Hina's stage in MoF, and only the movement works...
Code: [Select]
//stage 1 enemy 2. Stops at a point, shoots a circle shot, then retreats.
script_enemy_main{
let get = GetCurrentScriptDirectory;

    let EnemyImage = get ~ ".\img\dummy.png";
let pow2 = get ~ ".\se\pow2.wav";
    @Initialize {
LoadSE(pow2);
        LoadGraphic(EnemyImage);
        SetLife(150);
SetScore(1500);
        SetInvincibility(30);
        SetEnemyMarker(false);
        SetDurableSpellCard;

mainTask;
    }

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

    @DrawLoop {
        SetTexture(EnemyImage);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicRect(0,0,8,8);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
        DrawGraphic(GetX, GetY);
       
    }

    @Finalize {
    }
task mainTask{
move;
wait(60);
fire;
wait(90);
exit;
yield;
}

task move{
if(GetX>GetCenterX){
SetMovePosition03(GetCenterX+100,GetCenterY-90,10,4);
}
else{
SetMovePosition03(GetCenterX-100,GetCenterY-90,10,4);
}
yield;
        }
task exit{
SetMovePosition03(GetX(),GetCenterY-500,12,4);
if(GetY<GetClipMinY){
VanishEnemy;
}
yield;
}
task fire{
let angle=0;
let x=0;
loop{
PlaySE(pow2);
while(x<15){
CreateShot02(GetX(),GetY(),8,angle,-4,0.5,WHITE11,1);
angle+=360/15;
x++;
}
}
yield;
}
function wait(w){
loop(w){yield;}
}
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on June 01, 2010, 09:35:53 PM
I'm having a huge issue where my script looks to be correct, but when executed, causes Danmakufu to freeze. Whether I'm causing an overflow or not, it's really frustrating. I'm trying to make an enemy script where it shoots a circle shot similar to the spinners in Hina's stage in MoF, and only the movement works...

lots of code


There's quite a few things here that you seem to be misunderstanding and things that can be improved upon, but to start with let's take a look at what's causing Danmakufu to freeze.

This is what your fire task looks like:
Code: [Select]
      task fire{   
         let angle=0;
         let x=0;
            loop{
                  PlaySE(pow2);
                  while(x<15){
                     CreateShot02(GetX(),GetY(),8,angle,-4,0.5,WHITE11,1);
                     angle+=360/15;
                     x++;
                     }   
                  }
               yield;
            }
It's hard to catch but you have an infinite loop in there with no yields. A loop without a specified number will continue until it encounters a break; or a yield; in a task. Unfortunately, the yield in your fire task seems to be outside of the loop so Danmakufu continues to try to run the code inside the loop until it finishes (which is never). This is what's causing the freeze because the code can't advance.

Now about your other problems (that you didn't mention but are bugging me), try to keep your spacing more easily readable. The spacing I would've used in the above code would be more like this:
Code: [Select]
      task fire{   
        let angle=0;
        let x=0;
        loop{
          PlaySE(pow2);
          while(x<15){
            CreateShot02(GetX(),GetY(),8,angle,-4,0.5,WHITE11,1);
            angle+=360/15;
            x++;
          }   
        }
        yield;
      }
This groups the codes that are inside braces so that you can more easily see which functions are being called where. It also becomes more apparent that the yield is outside the loop.

Lastly, you seem to be misunderstanding how tasks work. They do not inherently loop. For example, the following bit of code will not loop when called:
Code: [Select]
task DoesNotLoop {
  CreateShot01(GetX, GetY, 3, GetAngleToPlayer, RED01, 10);
  Wait(30);
}
All it will do is create a single shot and stop running. If you intend the boss to shoot something every 30 frames for as long as it exists, you need to do this instead:
Code: [Select]
task DoesLoop {
  loop{
    CreateShot01(GetX, GetY, 3, GetAngleToPlayer, RED01, 10);
    Wait(30);
  }
}

Hope that helps.

EDIT: Scratch that I just noticed you're doing a normal enemy. The yields at the end of each task are rather pointless though.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Elementoid on June 01, 2010, 11:43:24 PM
This (http://pastebin.com/raw.php?i=wQeUcZ2T) thing I made (surprisingly) works as intended, except that for some reason, the bullets are spawning and then curving inwards, while they should be spawning at the boss' coordinates and then curving outwards. It probably has to do with how the objects' positions are changed manually, but I can't see how or why.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: SparklingOrange on June 02, 2010, 12:13:11 AM
Hope that helps.

EDIT: Scratch that I just noticed you're doing a normal enemy. The yields at the end of each task are rather pointless though.

Thanks for the tip, Blargel. I wasn't sure where the yield; should be...but I noticed that was probably the reason for the freeze due to the infinite loop thing...

One more thing, how does CreateLaserA exactly work? I tried playing around with it to make a laser shoot at an angle for some frames, rebound, then reflect to another angle, but all it does is make a spinning laser that doesn't really cut off from the base. When that didn't work, I tried creating an object laser based on what Helepolis said about object shots in his video, but I only managed to spawn the laser. It didn't move.

Also, there must be a math function out there that allows me to make a straight-line shot aimed at the player without using GetAngleToPlayer;...when I use that, the straight line breaks up when the player moves due to the position relative to the frame the shot is fired. What could it be?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade on June 02, 2010, 12:19:59 AM
The SetSpeed option for object lasers is totally useless. They can only be moved manually through SetPosition. And making lasers reflect off of walls is a lot harder than making bullets do it, I'm not really sure how.

Information on CreateLaserA should be on the wiki. The reason it spins is because that angle adjust value is the rate of adjustment, not a new angle, and it should be a very small number. And CreateLaserA makes lasers that don't terminate from the base, that's the way it is. The only ones that do are CreateLaserC and object lasers.

As for the straight-shooting, atan2 is your answer: it get the angle from point A to point B. For a recreation of GetAngleToPlayer, it would look like:

atan2 (GetPlayerY - GetEnemyY, GetPlayerX - GetEnemyX);

or more simply:

atan2 (PointB y  value - PointA y value, PointB x value - PointA x value);

*The spaces in between are just for clarity.

It's pretty useful.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DgBarca on June 02, 2010, 09:22:42 AM
How is the radius of the bullet hitbox calculated in danmakufu ?
if it is rect=(16,15,32,30)
((32-16)+(30-15))/2 ?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on June 02, 2010, 10:05:48 AM
Also, there must be a math function out there that allows me to make a straight-line shot aimed at the player without using GetAngleToPlayer;...when I use that, the straight line breaks up when the player moves due to the position relative to the frame the shot is fired. What could it be?

Something like this?
Code: [Select]
task StraightLine {
    let angle = GetAngleToPlayer;
    loop(10){
        CreateShot01(GetX, GetY, 3, angle, RED01, 10);
        Wait(5);
    }
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 02, 2010, 10:07:58 AM
Code: [Select]
        Wait(5);
What was that about never using Wait with a capital w to define something because it is an actual function related to even scripts..?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on June 02, 2010, 10:09:19 AM
That's Helepolis's stance. I personally don't give a damn... Probably because I don't do event scripts often.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: DgBarca on June 02, 2010, 10:16:43 AM
Is there a way to prevent bullets to FadeDelete when you get hit ?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Thaws on June 02, 2010, 10:18:27 AM
Is there a way to prevent bullets to FadeDelete when you get hit ?

I believe you'd need to set those bullets to be bomb resistant.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 02, 2010, 10:23:21 AM
Do you mean that they should be removed instantly without the fading, or do you mean that they should survive the death of the player?
If the former, you could try if(OnPlayerMissed==true){ Obj_Delete(obj); }. Maybe it will delete the bullet instantly before it can be fade deleted.
If the latter, you can use ObjShot_SetBombResist. If you want the bullets to survive hitting the player but not bombing, you cann add if(OnBomb==true){ ObjShot_SetBombResist(obj, false); }

That's Helepolis's stance. I personally don't give a damn... Probably because I don't do event scripts often.
Just damage prevention. If Orange is told about this issue, he won't have to spend many hours looking for the source of the bad allocation error if he eventually decides to make an event.  ;)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Blargel on June 02, 2010, 10:27:07 AM
Just damage prevention. If Orange is told about this issue, he won't have to spend many hours looking for the source of the bad allocation error if he eventually decides to make an event.  ;)

It's not going to give bad allocation and no one uses tasks in event scripts anyway. The MainLoop itself seems to get paused during the default TextOut and Wait functions in events so there's no need for tasks.

EDIT: Also, the default ExRumia stage uses Wait instead of wait for its stage task as well. :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade on June 03, 2010, 03:30:49 AM
This might sound stupid, but I keep on getting a missing-brackets error for this line of code.

Code: [Select]
if(currentspeed /= minmaxspeed){Obj_SetSpeed(obj, currentspeed + accel);}

What's wrong?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Gc on June 03, 2010, 03:35:56 AM
This might sound stupid, but I keep on getting a missing-brackets error for this line of code.

Code: [Select]
if(currentspeed /= minmaxspeed){Obj_SetSpeed(obj, currentspeed + accel);}

What's wrong?
Code: [Select]
if(currentspeed != minmaxspeed){Obj_SetSpeed(obj, currentspeed + accel);}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on June 03, 2010, 03:37:34 AM
This might sound stupid, but I keep on getting a missing-brackets error for this line of code.

Code: [Select]
if(currentspeed [b]/=[/b] minmaxspeed){Obj_SetSpeed(obj, currentspeed + accel);}

What's wrong?

what are you trying to do? I'm guessing it's supposed to be "is not equal to" ? if so... then you should use != there's no such thing as /= :V

EDIT: damn... cube beat me to it :|
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Areylie on June 03, 2010, 03:39:45 AM
Do you mean that they should be removed instantly without the fading, or do you mean that they should survive the death of the player?
If the former, you could try if(OnPlayerMissed==true){ Obj_Delete(obj); }. Maybe it will delete the bullet instantly before it can be fade deleted.
If the latter, you can use ObjShot_SetBombResist. If you want the bullets to survive hitting the player but not bombing, you cann add if(OnBomb==true){ ObjShot_SetBombResist(obj, false); }
Just damage prevention. If Orange is told about this issue, he won't have to spend many hours looking for the source of the bad allocation error if he eventually decides to make an event.  ;)
Actually, the following lines of code will do.

if(OnPlayerMissed)
if(OnBomb){ ObjShot_SetBombResist(obj, false); }

OnPlayerMissed, and OnBomb both return either "true" or "false", which is the same thing that "a==b" returns. In other words (function that returns "true" or "false") == true is a complete noop.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade on June 03, 2010, 03:41:21 AM
Okay thanks. I have no idea what I was thinking, so :colonveeplusalpha:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on June 03, 2010, 03:43:07 AM
there's no such thing as /= :V
/= is a valid symbol, which is why it gave them a weird error. variable/=2  is equivalent to using variable=variable/2, and DMF doesn't like you storing values in a conditional statement.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on June 03, 2010, 03:46:03 AM
variable/=2  is equivalent to using variable=variable/2
I had absolutely no idea you could do that :o I thought it was only for += and -=... so I guess there's a *= too?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on June 03, 2010, 03:55:03 AM
Yeah, and I think even %= works, but I haven't tested it.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on June 03, 2010, 03:57:45 AM
Why you would need to use modulus to modify a variable anyways, I haven't the slightest.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on June 03, 2010, 04:03:53 AM
There is no point in doing it, it will just stay the same, %= does nothing. I just checked
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Fetch()tirade on June 04, 2010, 11:17:35 PM
Alright, one more question: I'm gonna have to spoil what I was doing, but I was trying to create an object-shot form of CreateShot02, 11, and 12. The first two worked out, but CreateShot12 took me quite some time.

Code: [Select]
task createshot12objectform(xposition, yposition, xstarting, ystarting, xaccel, yaccel, xminmax, yminmax, graphic, delay){
let shottimer = 0;
let xposorneg = xminmax - xstarting;
let yposorneg = yminmax - ystarting;
let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj, xposition, yposition);
ObjShot_SetGraphic(obj, graphic);
ObjShot_SetDelay(obj, delay);

while(shottimer >= 0){
let currentx = Obj_GetX(obj);
let currenty = Obj_GetY(obj);
let currentangle = Obj_GetAngle(obj);
let currentlinearspeed = Obj_GetSpeed(obj);
let xcurrentspeed = currentlinearspeed * cos(currentangle);
let ycurrentspeed = currentlinearspeed * sin(currentangle);
let movex;
let movey;

if(xstarting != xminmax){
if(xposorneg < 0){
if(xcurrentspeed > xminmax){movex = xcurrentspeed + xaccel;}
}
if(xposorneg > 0){
if(xcurrentspeed < xminmax){movex = xcurrentspeed + xaccel;}
}
}

if(ystarting != yminmax){
if(yposorneg < 0){
if(ycurrentspeed > yminmax){movey = ycurrentspeed + yaccel;}
}
if(yposorneg > 0){
if(ycurrentspeed < yminmax){movey = ycurrentspeed + yaccel;}
}
}

Obj_SetPosition(obj, currentx + movex, currenty + movey);
shottimer++;
yield;
}
}

It's almost done, except when I load the test script, I get an error about variable substitution on the second Obj_SetPosition. Can someone help?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on June 05, 2010, 12:15:38 AM


let movex = 0;
let movey = 0;


solves your problem, you need to set variables to something, such as numbers, strings, arrays, id, etc.  Only when making an object does let something; work
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: GenericTouhouFailure on June 05, 2010, 12:26:37 AM
Could Someone give a hint to how I can make a item script? (You know, "P" for power and custom point items)
Effect Objects?
Enemies?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on June 05, 2010, 12:41:30 AM
Can't help you on Item Scripts but,


Here is the link to Nuclear Cheese's Object Effect Tutorial (http://dmf.shrinemaiden.org/wiki/index.php?title=Nuclear_Cheese's_Effect_Object_Tutorial#Section_0:_Before_You_Try_This)


Making Enemies is just like making bosses, just program some danmaku, have it enter the screen, stay a little bit, then have it move off screen. Then use VanishEnemy; to delete it. Oh, and set the life to something low so it can be destroyed by the player.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on June 05, 2010, 12:42:56 AM
Only when making an object does let something; work

Not true. let something; can work for any variable, with one problem: if you try to use the value before it's assigned anything, it will error for obvious reasons, and this also applies to something++; and the like. Flashtirade's problem was that those variables were getting used for Obj_SetPosition before they were given a value.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on June 05, 2010, 02:01:35 AM
Could Someone give a hint to how I can make a item script? (You know, "P" for power and custom point items)
Effect Objects?
Enemies?

Here's the item script to my game... hope it helps... just edit stuff as you see fit... It's not perfected yet, but it shows the basic way to do it... Just call it in @Finalize or something (just make sure that there's something handling it's movement and such, cause it's gonna auto-delete if nothing's controlling it... try making a dummy enemy control it or the main stage script using common datas and such... I added some comments to help you out (the original doesn't have any :V) also, I didn't add the spinning effect yet... You might want to copy-paste the thing into notepad cause it's hard to read here...

*CAUTION* KINDA LONG CODE AHEAD *CAUTION*
Code: [Select]
let itempic="lib\system\items.png";
LoadGraphic(itempic); //Declare and load the graphic used

task itemdrop(type, x, y)
{
let yacc=-5; //so that the item jumps up when spawned like in touhou games
let collection=0; //checks if the item's moving to the player (also used it to control how fast the item's moving toward the player)
let xpos=x;
let ypos=y;
let obj=Obj_Create(OBJ_EFFECT);
ObjEffect_SetTexture(obj, itempic);
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
ObjEffect_CreateVertex(obj, 4); //declare the effect object
if(type=="POWER_S") //set UV rects... change this depending on the image you're using
{
ObjEffect_SetVertexUV(obj, 0, 0, 0);
ObjEffect_SetVertexUV(obj, 1, 16, 0);
ObjEffect_SetVertexUV(obj, 2, 0, 16);
ObjEffect_SetVertexUV(obj, 3, 16, 16);
}
if(type=="POINT")
{
ObjEffect_SetVertexUV(obj, 0, 16, 0);
ObjEffect_SetVertexUV(obj, 1, 32, 0);
ObjEffect_SetVertexUV(obj, 2, 16, 16);
ObjEffect_SetVertexUV(obj, 3, 32, 16);
}
if(type=="COLLECT") //Collect's just some extra item for my game :V
{
ObjEffect_SetVertexUV(obj, 0, 112, 0);
ObjEffect_SetVertexUV(obj, 1, 128, 0);
ObjEffect_SetVertexUV(obj, 2, 112, 16);
ObjEffect_SetVertexUV(obj, 3, 128, 16);
}
if(type=="COLLECT_L")
{
ObjEffect_SetVertexUV(obj, 0, 32, 0);
ObjEffect_SetVertexUV(obj, 1, 48, 0);
ObjEffect_SetVertexUV(obj, 2, 32, 16);
ObjEffect_SetVertexUV(obj, 3, 48, 16);
}
if(type=="POWER_L")
{
ObjEffect_SetVertexUV(obj, 0, 48, 0);
ObjEffect_SetVertexUV(obj, 1, 64, 0);
ObjEffect_SetVertexUV(obj, 2, 48, 16);
ObjEffect_SetVertexUV(obj, 3, 64, 16);
}
if(type=="POWER_F")
{
ObjEffect_SetVertexUV(obj, 0, 96, 0);
ObjEffect_SetVertexUV(obj, 1, 112, 0);
ObjEffect_SetVertexUV(obj, 2, 96, 16);
ObjEffect_SetVertexUV(obj, 3, 112, 16);
}
while(Obj_BeDeleted(obj)==false)
{
if(GetCommonData("itemcollect")==1) //I set this to 1 whenever I want to auto collect all items like on event scripts, etc
{
collection=15;
}
if(ypos>GetClipMaxY+50) //deletes the item if it's way below the bottom of the screen
{
Obj_Delete(obj);
}
ypos+=yacc; //controls the falling
if(yacc<2)
{
yacc+=0.1;
}
ObjEffect_SetVertexXY(obj, 0, xpos-8, ypos-8); //sets XY rects
ObjEffect_SetVertexXY(obj, 1, xpos+8, ypos-8);
ObjEffect_SetVertexXY(obj, 2, xpos-8, ypos+8);
ObjEffect_SetVertexXY(obj, 3, xpos+8, ypos+8);
if(((xpos-GetPlayerX)^2+(ypos-GetPlayerY)^2)^0.5<=30) //if distance between item and player is less than 30, item moves to the player
{
collection=4;
}
if(((xpos-GetPlayerX)^2+(ypos-GetPlayerY)^2)^0.5<=10 && OnPlayerMissed==false) //if distance between item and player is less than 10 and player isn't dead, item is collected
{
if(type=="POWER_S") //if item is a small power item
{
SetCommonData("power", GetCommonData("power")+1);
AddScore(10);
}
if(type=="POWER_L") //if item is a large power item
{
SetCommonData("power", GetCommonData("power")+10);
AddScore(100);
}
if(type=="POWER_F") //if item is a full power item
{
SetCommonData("power", 100);
AddScore(1000);
}
if(type=="POINT") //if item is a point item... I still have to fix this :V
{
if(GetPlayerY>GetClipMinY+120)
{
AddScore(truncate(5*(GetCommonData("GRAZE")*100)/(GetPlayerY-GetClipMinY-120))+5000);
}else{
AddScore(5000+GetCommonData("GRAZE")*50);
}
AddPoint(1);
}
if(type=="COLLECT") //if item is a collection item
{
SetCommonData("collect", GetCommonData("collect")+1);
AddScore(50);
}
if(type=="COLLECT_L") //if item is a large collection item
{
SetCommonData("collect", GetCommonData("collect")+10);
AddScore(500);
}
Obj_Delete(obj);
}
if(GetCommonData("power")==100) //if power is full, I turned power items to my extra special item (item_drop is a function that sets common data so that the main stage script creates the items)
{
if(type=="POWER_S")
{
item_drop("COLLECT", xpos, ypos, 1, 0, 0);
Obj_Delete(obj);
}
if(type=="POWER_L")
{
item_drop("COLLECT_L", xpos, ypos, 1, 0, 0);
Obj_Delete(obj);
}
}
if(GetPlayerY<GetClipMinY+120 || OnBomb==true) //when the player is above the collection line or bombing, and isn't dead collect all the items...
{
if(OnPlayerMissed==false)
{
collection=10;
}
}
if(IsBossExisting==true) //Collect items disappear when there's a boss
{
if(type=="COLLECT"||type=="COLLECT_L")
{
Obj_Delete(obj);
}
}
if(collection>=1) //control movement when the item's being collected
{
xpos+=collection*cos(atan2(GetPlayerY-ypos, GetPlayerX-xpos));
ypos+=collection*sin(atan2(GetPlayerY-ypos, GetPlayerX-xpos));
}
yield;
}
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on June 05, 2010, 10:06:31 PM
Is there a way to get bullets to "glow" together, rather than have their sprites overlap?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 05, 2010, 10:26:00 PM
For that, you need to change the rendering type of these bullets to additive blend.

The thorough way to accomplish this is to create an entirely new shot data file (http://touhou.wikia.com/wiki/Touhou_Danmakufu:_User-defined_Bullets) where you define the rendering type as ADD instead of ALPHA. If you are using the expanded shot data or something similar already, you can simply make a copy of it, rename it, change the relevant instances of ALPHA to ADD and then refer to the alternate shot sheet when neccessary.

Another way to go about this would be to make the bullets lasers instead, as lasers are always rendered in additive blend, no matter what the original bullet data has.


As a precautious advice, instances where abuse of additive blended bullets make stuff difficult to read are a major source of rage for certain people, so use them wisely.  :derp:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on June 06, 2010, 03:35:53 AM
I'm trying to make an attack that speeds up, stops after a few seconds, then, after a while, shoots two bullets and moves away, but for some reason the Code I am using now (http://pastebin.com/38uVMRqW) Isn't working like that, whats wrong?
It shoots and all, then it stops, then it moves, but only half do, I have no idea why!

EDIT:
I noticed I left in the following commands, please delete them for script to work:
#include_function".\Main.txt"
Load;
DrawSat;

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 06, 2010, 08:22:31 AM
Found it!
Tthe problem lies here:
Quote
loop{
a+=5;
Fence(15,800-a,frame*3);
wait(4);
        }
Quote
if(frm==time*1.5){
...
}

frm increases by 1 every frame. If the parameter time in the Fence task is uneven, the condition if(frm==time*1.5) can neven become true. Since you change the parameter by 5 every time, half of the bullets will be unable to reach the requirement.

My tip to fix it? Change the line to:
Quote
if(frm == ceil( time*1.5 ) ){
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: GenericTouhouFailure on June 06, 2010, 11:11:47 PM
Code: [Select]
Long Code here
Thanks. I actually started on one too but never thought of checking if the player is dead :V
I really got to get my ass up and make a custom cutin soon. *searches for code to steal*
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on June 07, 2010, 05:42:53 AM
I really got to get my ass up and make a custom cutin soon. *searches for code to steal*

Wait a sec... This one's really easy to find.
This, it's Hele's TH10-12 cut-in script function. (http://www.shrinemaiden.org/forum/index.php?topic=2146.0) I've modified it for use in some of my newer scripts.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: espen on June 07, 2010, 05:01:08 PM
I'm trying to make a bullet that gravitates around a specified center of gravity, following an inverse-square distance law. In other words, I want a=G/r2 in the direction of r.

A problem I ran into was I have to be able to independently change the x- and y-velocities of the bullet, but the only control I seem to have is if the speed and the angle of motion.

Wolfram Mathworld (http://mathworld.wolfram.com/PolarCoordinates.html) gives the expression for the acceleration vector. It might be possible to accomplish by designing a recursive function which decomposes the velocity vector of the bullet into the angular and radial components.

Has such a bullet already been designed? Does it look possible to accomplish?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 07, 2010, 05:17:09 PM
It might be possible to accomplish by designing a recursive function which decomposes the velocity vector of the bullet into the angular and radial components.

Has such a bullet already been designed? Does it look possible to accomplish?

Code: [Select]
v= ( vx^2 + vy^2)^0.5;

angle = atan2(vy, vx);

This should do.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on June 07, 2010, 05:30:18 PM
Or you can move the bullet manually. Set speed and angle to 0, then just add the x and y speeds to its position every frame.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on June 09, 2010, 04:31:40 AM
Render targets. These things get nearly no mention except for three functions tucked away at the end of Drawing Functions (in the DNFWiki), which don't give any useful information apart from "this is a render target kthxbai." Apart from that, I've only heard about them once, mentioned in this thread when someone asked about a "rumbling" effect, and the reply was that someone else was trying using render targets to make it. They sound like something that requires a lot of brainpower to use and probably serve very little useful purpose at all anyways (unlike things like Object Shots, which can be very useful for shininess but are complicated to use), some sort of esoterica that would require delving into the Japanese documentation to find out about.

tl;dr

Yeah anyways, what's a render target, what can I do with them, how do I use them, etc.?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on June 09, 2010, 04:52:11 AM
They're somewhat hard to explain, but I'll try to give a short tutorial here, since I was just working with them recently.

Basically, they act as a canvas that you can draw other things on top of. Why is this useful? Say you have a complex background with 20 layers, but none of them move at all. I know, stupid, but work with me for now. You can simply draw all those onto a render target, then draw the target to the screen in DrawLoop rather than the 20 individual layers. This saves the processing power of drawing 19 images. Very useful with DrawText, since that function is pretty memory-heavy.
Another usage would be drawing a multi-layered background onto a render target, then loading it as a texture for an effect object, which you can then manipulate the vertices on, while each layer still animates individually!

All in all, it's not too useful, but it does have its situations. So how do you use it? It's easier to show example code, so here we go.


In @Initialize:
CreateRenderTarget("bg", 512, 512); // this creates the target, 512 by 512 pixels, and calls it "bg". Easy.
SetRenderTarget("bg"); // this sets it as the active drawing surface.
// (things like SetTexture, SetGraphicRect, etc. go here - the same as if you were drawing something normally.)
DrawGraphic(200,200) // draws the graphic at coordinates 200,200 of the render target, not the game field.
// (drawing more layers on it goes here. Draw as many things as you want.)
SetRenderTarget("DEFAULT"); // changes back to the default render target, which gets automatically drawn onto the playing field every frame. Make sure to do this when you're done drawing on a target.

In @DrawLoop:
SetTexture("bg"); // sets the texture to the render target we drew on before
SetGraphicRect(0,0,512,512); // normal drawing stuff here.
DrawGraphic(GetCenterX,GetCenterY); // draw it to the game field like normal - because we set the target back to "DEFAULT", DrawGraphic behaves like you're probably used to.


Other notes: If you're going to change what's drawn each frame, use ClearRenderTarget("bg"); each frame before you draw onto it to erase what was there from the previous frame. If you're loading it onto the texture of an effect object and it's changing each frame, remember that you need to use ObjEffect_SetTexture every frame so it loads the new texture (and you also need to re-declare the SetVertexUV's every time you change the texture).

That should be it. If you don't understand it, the best thing is just to experiment.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: GenericTouhouFailure on June 09, 2010, 08:55:25 AM
>Load/Save CommonDataEx
>Error
>Wut? How :V

<<<Translation>>>
How to use SaveCommonDataEx and LoadCommonDataEx. No matter how I try, danmakufu bitches about the file and freezes.
inb4toldtoreadsometutorial
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on June 09, 2010, 10:24:19 AM
>Load/Save CommonDataEx
>Error
>Wut? How :V

<<<Translation>>>
How to use SaveCommonDataEx and LoadCommonDataEx. No matter how I try, danmakufu bitches about the file and freezes.

inb4toldtoreadsometutorial

Post code. You are not posting any code. People cannot help you efficiently if you don't post code. Post the code.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: GenericTouhouFailure on June 09, 2010, 11:05:06 AM
For Example..
Code: [Select]
CreateCommonDataArea("Test");
LoadCommonDataEx("Test","new 2");
SetCommonDataEx("Test","lolwut",0);
SaveCommonDataEx("Test","new 2");
asdf
I don't even know how to use this lolwut.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 09, 2010, 11:13:42 AM
For Example..
Code: [Select]
CreateCommonDataArea("Test");
LoadCommonDataEx("Test","new 2");
SetCommonDataEx("Test","lolwut",0);
SaveCommonDataEx("Test","new 2");
asdf
I don't even know how to use this lolwut.

I have no idea if this will work, but you may try changing "new 2" to "new2" or "new_2". Considering that this is about file names, I can totally see danmakufu screwing it up when spaces are involved.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Kylesky on June 09, 2010, 12:22:27 PM
Code: [Select]
CreateCommonDataArea("Test");
LoadCommonDataEx("Test","new 2");
SetCommonDataEx("Test","lolwut",0);
SaveCommonDataEx("Test","new 2");
SaveCommonDataEx and LoadCommonDataEx saves and loads it from a .dat FILE

Here is what your code should actually look like:
Code: [Select]
CreateCommonDataArea("Test");
LoadCommonDataEx("Test",GetCurrentScriptDirectory~"new_2");
SetCommonDataEx("Test","lolwut",0);
SaveCommonDataEx("Test",GetCurrentScriptDirectory~"new_2");

also, make sure that before you use LoadCommonDataEx, that the .dat file already exists, else, an error will occur... this means, the first time you run the script, add a SaveCommonDataEx before calling it, or make sure that a SaveCommonDataEx is already called in the script before LoadCommonDataEx...
Title: Need help with events
Post by: Zerro on June 09, 2010, 04:46:02 PM
Where do I put the event?

When I put it inside a card and call it it works fine but the boss attacks while the event is going on.
Title: Re: Need help with events
Post by: Chronojet ⚙ Dragon on June 09, 2010, 04:52:25 PM
Where do I put the event?

When I put it inside a card and call it it works fine but the boss attacks while the event is going on.
This sort of question goes into the Danmakufu Q/A Thread (http://www.shrinemaiden.org/forum/index.php?topic=4771.0).

anyways,
if(!OnEvent) { MakeSomeFuckingDanmaku; }
OR
while(!OnEvent) { yield; } // if in a task

Use it like this:
Code: [Select]
let count = 10;
@MainLoop {
  if(!OnEvent) { count--; }
  if(count == 0) {
    CreateShot01(GetX, GetY, 3, GetAngleToPlayer, WHITE02, 0);
    count = 10;
  }
}
or like this:
Code: (Event!) [Select]
task Shot {
  while(!OnEvent) { yield; }
  loop {
    ascent(i in 0..10) { CreateShot01(GetX, GetY, 5, GetAngleToPlayer+i*360/10, RED01, 0); }
    loop (7) { yield; }
  }
}

If you choose the second option, you have to use a yield; somewhere in @MainLoop.
Title: Re: Need help with events
Post by: Zerro on June 09, 2010, 04:58:59 PM
Ok, thanks.

If I have anymore questions I'll put them in that thread.

Title: Re: Need help with events
Post by: Flyer on June 09, 2010, 05:40:03 PM
or you can use this in @MainLoop

@MainLoop{ ~~
  if(OnEvent){ break; }
~~}

this phrase will stop all MainLoop task while event is ongoing.
Title: Re: Need help with events
Post by: Helepolis on June 09, 2010, 09:32:01 PM
Ok, thanks.

If I have anymore questions I'll put them in that thread.
You should have done that from the start as the sticky thread is there for a reason. Now science will end you, my condolence.

Merged threads...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: GenericTouhouFailure on June 10, 2010, 12:05:30 AM
SaveCommonDataEx and LoadCommonDataEx saves and loads it from a .dat FILE

Here is what your code should actually look like:
Code: [Select]
CreateCommonDataArea("Test");
LoadCommonDataEx("Test",GetCurrentScriptDirectory~"new_2");
SetCommonDataEx("Test","lolwut",0);
SaveCommonDataEx("Test",GetCurrentScriptDirectory~"new_2");

also, make sure that before you use LoadCommonDataEx, that the .dat file already exists, else, an error will occur... this means, the first time you run the script, add a SaveCommonDataEx before calling it, or make sure that a SaveCommonDataEx is already called in the script before LoadCommonDataEx...
:V No wonder I was so confused...
Thanks.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on June 10, 2010, 04:12:16 AM
blah blah stuff about render targets here blah

Okay, cool, thanks. BV
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Megayanma on June 11, 2010, 02:34:40 AM
Objects seem to elude me.  Would someone PLEASE tell me what is wrong with this script and why it gives me an error with the "ring;" line of code in Initialize?

Code: [Select]
#TouhouDanmakufu
#Title[aimed rings won't worrrrkkkkkk]
#Text[O.o]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{


let imgExRumia="script\ExRumia\img\ExRumia.png";
let frame = 0;
let angle = 0;
let frame2 = 0;
let angle2 = 0;
let angle3 = 0;
let speed = 0.5;
let frame3 = 0;
function wait(let frames){ loop(frames){yield;} }

let SupaShot = GetCurrentScriptDirectory~"\Supershot.txt";



@Initialize{
SetLife(3700);
SetTimer(60);
SetInvincibility(120);
LoadGraphic(imgExRumia); //Load the boss graphic.
SetMovePosition02(GetCenterX, GetCenterY - 120, 60); //Move the boss to the top center of the screen.
LoadUserShotData(SupaShot);
Concentration02(120);
MagicCircle(true);
ring;




}

@MainLoop{
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);
frame++;
frame2++;
angle3++;
frame3++;

yield;



if(frame==120){







frame = 116;
angle += 16;
angle2+=6;
Slow(0);

}

if(frame2==120){

}

}
@DrawLoop{
//All this foolishness pertains to drawing the boss. Ignore everything in @Drawloop unless you have read and understand Nuclear Cheese's Drawing Tutorial.
SetColor(255,255,255);
SetRenderState(ALPHA);
SetTexture(imgExRumia);
SetGraphicRect(64,1,127,64);
DrawGraphic(GetX,GetY);
}

@Finalize
{
}
}

angle2 -= 12;

}

if(frame2==120){
frame2 = 60;
}
}
@DrawLoop{
All this foolishness pertains to drawing the boss. Ignore everything in @Drawloop unless you have read and understand Nuclear Cheese's Drawing Tutorial.
SetColor(255,255,255);
SetRenderState(ALPHA);
SetTexture(imgExRumia);
SetGraphicRect(64,1,127,64);
DrawGraphic(GetX,GetY);
}

@Finalize
{  DeleteSE(shot);


}

task ring{
wait(180+100);

let an;

loop{
an = rand_int(0,359);

loop(9){
Shot(an);
an += 360/9;
}

wait(300);
yield;
}
}

task Shot(an){
let obj = Obj_Create(OBJ_SHOT);
let count = 0;

Obj_SetPosition (obj, GetX+10*cos(an), GetY+10*sin(an));
Obj_SetAngle (obj, an);
Obj_SetSpeed (obj, 2);
ObjShot_SetGraphic (obj, RED12);
ObjShot_SetDelay (obj, 10);
ObjShot_SetBombResist (obj, false);

while(!Obj_BeDeleted(obj) ){
count++;
if(count < 45){
if(Obj_GetSpeed(obj) > 0){
Obj_SetSpeed (obj, Obj_GetSpeed(obj) -0.05);
}
}
if(count==60){
Obj_SetAngle(obj, atan2(GetPlayerY-Obj_GetY(obj) , GetPlayerX-Obj_GetX(obj) ) );
Obj_SetSpeed (obj, 2);
}
yield;
}
}
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on June 11, 2010, 02:42:51 AM
Your copy pasting skills need work :V
After your first @Finalize, there is an additional closing brace. Not only that, but an additional @DrawLoop as well. Review your code to see what you have incorrectly copied and, provided that changing it doesn't fix the error, repost.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Hakurei Miko on June 11, 2010, 04:27:57 AM
Please help this newb.

I'm new at this (honestly I only started yesterday), but now when I try to add in movement, it always has an error involving "wait(120);". D: Which I think is needed to make it move(Make it pause for 2 second*120 frames* so it can do the other command thing right?).

http://pastebin.com/G64xcDNb

I dun see what's wrong with it that'll cause that error . ???

---

And while I'm at it, *When I removed the "wait(120);"* my laser familiar only points straight down, I dun want it to do that.  :V I want it to shoot danmaku to the border of the area(so it can bounce off) and move up and down, and I also was going to make another familiar to do the same @ the right side.

Help would be greatly appreciated.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on June 11, 2010, 05:05:45 AM
The } right before every instance of where you define the function closes the enemy script up, so "wait" isn't defined in the script. Get rid of those.

Other problem is just because the only value you give for the "angle" parameter is 180.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Megayanma on June 11, 2010, 03:43:13 PM
Your copy pasting skills need work :V
After your first @Finalize, there is an additional closing brace. Not only that, but an additional @DrawLoop as well. Review your code to see what you have incorrectly copied and, provided that changing it doesn't fix the error, repost.

Whoa, sorry about that!  I guess I'm a ⑨ in training.  :blush:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Hakurei Miko on June 11, 2010, 07:42:23 PM
The } right before every instance of where you define the function closes the enemy script up, so "wait" isn't defined in the script. Get rid of those.

Other problem is just because the only value you give for the "angle" parameter is 180.

.... >.> The "wait" or the }'s? Cause when I get rid of (most) the }'s, it comes up with an error.

When I don't, my Danmakufu freezes.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on June 11, 2010, 09:15:11 PM
Every time you set up the function you do this:

//SOMETHING GOES HERE

    }            //<-- THIS BRACKET RIGHT HERE WHAT IS IT DOING THERE

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

    }


}            //<-- This bracket should be ending the enemy script, not the first
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on June 11, 2010, 09:58:43 PM
Pro top for beginners: in case you have trouble knowing what bracket closes what add a comment on top of it or behind it. (Think behind should give problem either).

Example
Code: [Select]
script_enemy_main {

task charisma {
let Scarlet = 999999999;

while (CHA > 0) {
GUNGNIR AND STUFF
RED THE NIGHTLESS CASTLE

}

} // bracket charisma

CODING AND STUFF
CODING AND STUFF
CODING AND STUFF
CODING AND STUFF
CODING AND STUFF
CODING AND STUFF

} // bracket enemy main

Or you can just count them how many you open and close. Same goes for parentheses. Logically, this example is useless if your tabbing is not properly done.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Flyer on June 12, 2010, 11:43:34 AM
(plz excuse my poor english)
I have a question. How can I make a shake effect (like a [Master Spark]) without a lagging?

I used a method that putting all objects into 'bullets' array, and when an anchor stops, I shook all objects in array with task.

But the number of objects exceeds 100, and there's horrible lagging -_- how can i solve this problem? Please help me.

here's a part of my script to shake effect.

let bullets=[];
task Shot01(~~){
   let obj1=Obj_Create(OBJ_SHOT);
   bullets=bullets~[obj1];
   ~~
   while(!Obj_BeDeleted(obj1)){
      ~~ yield;}
   let num=0;
   while(num<length(bullets)){
       if(bullets[num]==obj1){    bullets=erase(bullets,num);
      break;}
   num++;}
   Obj_Delete(obj1);
}

task Anchor(~~){
   ~~~
   while(!Obj_BeDeleted(obj)){
    ~~
      ascent(j in 0..length(bullets)){
          TrembleShot(bullets[j],rand(-1,1)*6,rand(-1,1)*6);}
      ~~ yield;}
   Obj_Delete(obj);
}

task TrembleShot(let objec,let qX,let qY){
   let trem=Obj_Create(OBJ_SHOT);
   loop(1){Obj_SetPosition(objec,Obj_GetX(objec)+qX,Obj_GetY(objec)+qY);
      yield;}
   loop(1){Obj_SetPosition(objec,Obj_GetX(objec)-qX,Obj_GetY(objec)-qY);
      yield;}
   Obj_Delete(trem);
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 12, 2010, 01:00:01 PM
Well, you are doing a great lot of stuff per frame...

One thing I would change is the Tremble task.

task TrembleShot(let objec,let qX,let qY){
        Obj_SetPosition(objec,Obj_GetX(objec)+qX,Obj_GetY(objec)+qY);
        yield;
        Obj_SetPosition(objec,Obj_GetX(objec)-qX,Obj_GetY(objec)-qY);
}


No need for the trem object or the loop. This code does pretty much exactly the same as the one you have now, but shorter and with less work for the cpu.

Also, the line Obj_Delete(obj1); in the Shot01 task is redundant, as for the code to get to that line the object has to already be deleted.

Other than that, I remember Blargel saying that danmakufu is very vulnerable to overly long arrays. Other than making the code a little bit more efficient, I don't know what to do about your problem, sorry.
  :(

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Flyer on June 12, 2010, 01:43:17 PM
Well, you are doing a great lot of stuff per frame...

One thing I would change is the Tremble task.

task TrembleShot(let objec,let qX,let qY){
        Obj_SetPosition(objec,Obj_GetX(objec)+qX,Obj_GetY(objec)+qY);
        yield;
        Obj_SetPosition(objec,Obj_GetX(objec)-qX,Obj_GetY(objec)-qY);
}


No need for the trem object or the loop. This code does pretty much exactly the same as the one you have now, but shorter and with less work for the cpu.

Also, the line Obj_Delete(obj1); in the Shot01 task is redundant, as for the code to get to that line the object has to already be deleted.

Other than that, I remember Blargel saying that danmakufu is very vulnerable to overly long arrays. Other than making the code a little bit more efficient, I don't know what to do about your problem, sorry.
  :(

I changed those tasks as your reply, and frame has slightly increased! About 3~5 fps. :D

Thank you for your kind answer!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 12, 2010, 01:44:46 PM
No problem. Say, how much slow down does the effect give you in total?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Flyer on June 12, 2010, 01:52:36 PM
57fps -> 30~45fps. High difficulty = more frame drop.

Moving bullets seems to produce more lag with Tremble task.

I recorded that script a little before.

http://tvpot.daum.net/my/ClipView.do?ownerid=yKpAyDlCKZE0&clipid=24626333&q= (http://tvpot.daum.net/my/ClipView.do?ownerid=yKpAyDlCKZE0&clipid=24626333&q=)

Sound quality is terrible so turn down the volume  :V
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 12, 2010, 02:02:14 PM
Hm, I'm wondering...


Could you not integrate the code that makes the bullet shake into the bullet code? That way you could have less tasks running, which may improve the performance even if code code that actually does stuff is almost the same.

You could keep track of the number of Anchor objects by having a variable that increases if you call the task and decreases at the end of the task after the while(Obj_BeDeleted(obj)==false){} part.
Then you put the shaking code in the Shot01 task and make that it happens if the valuable that keeps track of the Anchor objects is greater than 0.

I don't know if this is going to work, but you could try it, I guess...


Edit: typing errors are stupid y.y
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Flyer on June 12, 2010, 02:20:48 PM
Oh my... you're a genius  :]
Using CommonData solved this frame drop trouble. Frame rate has increased from 38~50fps to 45~55fps.
Thank you very much!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: SparklingOrange on June 12, 2010, 06:47:35 PM
I know I'm still not good at the whole Danmakufu business, but I've made use of the player script tutorial to make a custom spellcard of my own. What I wanted to do was spawn spontaneous lightning strikes (160x600 long) lengthwise along the playing field, followed by a flash of white. However, when I tested it out, it wouldn't run as nothing happened. The following code for activation is here:
Code: [Select]
@Spellcard{
  SetSpeed(1, 1);
if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD){
UseSpellCard("CCoil", 0);
CutIn(KOUMA,"SlowSpell",cutimg);
}else{
//UseSpellCard("LBurst", 0);
CutIn(KOUMA,"FreeSpell",cutimg);
}
  }

Everything looks fine and all, but here's the entire for "CCoil", which is what I'm starting off with:
Code: [Select]
script_spell CCoil{
let lightning=get~".\img\teslalightningtex.png
let spellcount=0;
task LightningRipple(){
let objlightning=Obj_Create(OBJ_SPELL);
let xpos=GetCenterX+rand(0,416);
let ypos=GetCenterY;
Obj_SetAlpha(objlightning,200);
ObjEffect_SetTexture(objlightning,lightning);
ObjEffect_SetRenderState(objlightning,ADD);
ObjEffect_CreateVertex(objlightning,4);
ObjEffect_SetPrimitiveType(objlightning,PRIMITIVE_TRIANGLEFAN);
ObjEffect_SetVertexUV(objlightning,0,0,0);
ObjEffect_SetVertexUV(objlightning,1,160,0);
ObjEffect_SetVertexUV(objlightning,2,0,600);
ObjEffect_SetVertexUV(objlightning,3,160,600);
while(!Obj_BeDeleted(objlightning)){
ObjEffect_SetVertexXY(objlightning,0,xpos+(60*cos(120)),ypos+(60*sin(120)));
ObjEffect_SetVertexXY(objlightning,1,xpos+(60*cos(240)),ypos+(60*sin(240)));
ObjEffect_SetVertexXY(objlightning,2,xpos+(60*cos(300)),ypos+(60*sin(300)));
ObjEffect_SetVertexXY(objlightning,3,xpos+(60*cos(60)),ypos+(60*sin(60)));
ObjSpell_SetIntersecrionLine(objlightning,xpos+(60*cos(120)),ypos+(60*sin(120)),xpos+(60*cos(60)),ypos+(60*sin(60)),5,10,true);
yield;
}
}
}
task run{
SetPlayerInvincibility(300);
ForbidShot(true);
loop(45){yield;}
while(spellcount<101){
if spellcount%10==0{
LightningRipple();
LightningRipple();
LightningRipple();
PlaySE(GetCurrentScriptDirectory()~"lightning.wav");
if(spellcount==101){
PlaySE(GetCurrentScriptDirectory()~"crash.wav");}
}
spellcount++;
yield;
}

ForbidShot(false);
SetSpeed(3.5,2.5);
loop(90){yield;}
End();
}
 
I'm still not used to creating objects, so I don't know what I did wrong. The whole setting of the vertices and putting them on the field is rather confusing, as well as the use of other mathematical equations such as trigonometric functions and modulus. I didn't come into an error for some reason, but the spell just removed a counter and that was it.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on June 12, 2010, 06:56:33 PM
Just a quick lookover, you omitted the @Initialize and stuff in what you pasted, right? In that pasted blurb of code there's an extra close bracket before run() which would end CCoil() prematurely, that's not there in the file is it?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: SparklingOrange on June 12, 2010, 07:26:52 PM
Just a quick lookover, you omitted the @Initialize and stuff in what you pasted, right? In that pasted blurb of code there's an extra close bracket before run() which would end CCoil() prematurely, that's not there in the file is it?
I took off the other parts of the spell script 'cause it seemed irrelevant. The @Initialize only has the LoadGraphic for the texture and the run task, the @MainLoop has CollectItems and @Finalize deletes the texture. I also deleted the extra bracket (silly me, I don't seem to organize properly), but it still had the same outcome.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 12, 2010, 07:34:12 PM
Hmm, a possible error is detected:

Quote
      ObjEffect_SetVertexUV(objlightning,0,0,0);
      ObjEffect_SetVertexUV(objlightning,1,160,0);
      ObjEffect_SetVertexUV(objlightning,2,0,600);
      ObjEffect_SetVertexUV(objlightning,3,160,600);
I believe vertext 2 and 3 needs to be exchanged. What you want is for the vertices to be aligned like this:
0  1
3  2
You have them like this:
0  1
2  3
This will naturally distort the image and can possibly make it invisible.

Looking for other stuff...

Edit: Hm, I'm not certain about this, but in case of doubt I would advise you to call both SetVertexXY and SetVertexUV every frame
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Hakurei Miko on June 12, 2010, 09:32:00 PM
Every time you set up the function you do this:

//SOMETHING GOES HERE

    }            //<-- THIS BRACKET RIGHT HERE WHAT IS IT DOING THERE

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

    }


}            //<-- This bracket should be ending the enemy script, not the first


*Dams my computer*

I removed it, sure, the problem about it not detecting "wait" is gone, but now every time I try to start the spell up, Danmakufu freezes on me.  :V

I'm very sorry if I'm asking too many questions, its just that its starting to get on my nerves a bit. ^^;
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on June 12, 2010, 09:48:54 PM
    task fire{
             loop{
                     yukarilaser(GetX, GetY, 2, 180, 100, 16, PURPLE01);
                     yield;
              }

    //why is there no } here

task yukarilaser(x, y, v, angle, maxLen, width, graphic) {


check your damn bracketssssss
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: SparklingOrange on June 13, 2010, 03:00:31 AM
Hmm, a possible error is detected:
I believe vertext 2 and 3 needs to be exchanged. What you want is for the vertices to be aligned like this:
0  1
3  2
You have them like this:
0  1
2  3
This will naturally distort the image and can possibly make it invisible.

Looking for other stuff...

Edit: Hm, I'm not certain about this, but in case of doubt I would advise you to call both SetVertexXY and SetVertexUV every frame
Nope, didn't get any errors. What pretty much happened was that a bomb counter was used up with nothing happening and everything going normally. Nothing changed when Stuffman mentioned the extra bracket and I removed it. I've changed the vertex order as you mentioned, but what do you mean by calling the functions "every frame"? Do you mean putting a loop over the two?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on June 13, 2010, 03:22:34 AM
Sorry I didn't get to you, totally missed your post somehow. I must unconsciously just skip posts that don't bother to use pastebin and make a huge waste of space of the page. However, I'm going to be a hypocrite and use a large post to demonstrate with color.


script_spell CCoil{

   let lightning=get~".\img\teslalightningtex.png   //OH HEY LOOK NO END TO THE STRING GUESS WHAT HAPPENS NOW
   let spellcount=0;

   task LightningRipple(){
      let objlightning=Obj_Create(OBJ_SPELL);
      let xpos=GetCenterX+rand(0,416);
      let ypos=GetCenterY;
      Obj_SetAlpha(objlightning,200);   //Setting Alpha values does not work on Effect Objects!! Use ObjEffect_SetVertexColor() !!
      ObjEffect_SetTexture(objlightning,lightning);
      ObjEffect_SetRenderState(objlightning,ADD);
      ObjEffect_CreateVertex(objlightning,4);
      ObjEffect_SetPrimitiveType(objlightning,PRIMITIVE_TRIANGLEFAN);   //Don't use a fan for this! Fans are for things shaped like fans!! Use STRIP!!
      ObjEffect_SetVertexUV(objlightning,0,0,0);
      ObjEffect_SetVertexUV(objlightning,1,160,0);
      ObjEffect_SetVertexUV(objlightning,2,0,600);
      ObjEffect_SetVertexUV(objlightning,3,160,600);
      while(!Obj_BeDeleted(objlightning)){
         ObjEffect_SetVertexXY(objlightning,0,xpos+(60*cos(120)),ypos+(60*sin(120)));
         ObjEffect_SetVertexXY(objlightning,1,xpos+(60*cos(240)),ypos+(60*sin(240)));
         ObjEffect_SetVertexXY(objlightning,2,xpos+(60*cos(300)),ypos+(60*sin(300)));
         ObjEffect_SetVertexXY(objlightning,3,xpos+(60*cos(60)),ypos+(60*sin(60)));
         ObjSpell_SetIntersecrionLine(objlightning,xpos+(60*cos(120)),ypos+(60*sin(120)),xpos+(60*cos(60)),ypos+(60*sin(60)),5,10,true);   
         yield;
      }
   }
}   //You already said this shouldn't be here so yeah

task run{
   SetPlayerInvincibility(300);
   ForbidShot(true);
   loop(45){yield;}
   while(spellcount<101){
      if spellcount%10==0{   //HOLY SHIT NO BRACKETS
         LightningRipple();
         LightningRipple();
         LightningRipple();
         PlaySE(GetCurrentScriptDirectory()~"lightning.wav");
         if(spellcount==101){
            PlaySE(GetCurrentScriptDirectory()~"crash.wav");
         }
      }
      spellcount++;
      yield;
   }
   ForbidShot(false);
   SetSpeed(3.5,2.5);
   loop(90){yield;}
   End();
}


Well the color stuff was pretty redundant lol. I dunno fix that stuff see what happens
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: SparklingOrange on June 13, 2010, 03:35:31 AM
Well the color stuff was pretty redundant lol. I dunno fix that stuff see what happens
Dang, I missed that one on the if statement....It still doesn't work, though...I could swear it has something to do with the vertex positions, but still...with the activation syntax above, would the CutIn still have worked despite nothing happening in UseSpellCard?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on June 13, 2010, 03:56:07 AM
Well, let xpos=GetCenterX+rand(0,416); should probably be let xpos=rand_int(0,416);
Second, you aren't setting the object's position which means it's nowhere. You don't control object position through XY vertices.
Third, xpos+(60*cos(120)),ypos+(60*sin(120)) should be xpos-80,ypos-300 i.e half the UV for each segment. This means the object's position is in the center of the graphic.
Fourth, vertices don't have anything to do with how your spell runs. There would still be the cutin and sound effect.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Naut on June 13, 2010, 04:06:13 AM
You don't control object position through XY vertices.

 :smug:



@SparklingOrange
Among the other things these fine gents have listed, script_spells use  @Initialize@MainLoop  and  @Finalize  too, dawg.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on June 13, 2010, 04:21:38 AM
Quote
You don't control object position through XY vertices.

Yeah, just a quick correction there; in my experience when working with objects you either have to use SetPosition or vertices, if you use both then the vertices will act really really strangely, especially if you start trying to change the angle or the speed of the object.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on June 13, 2010, 04:45:41 AM
But for standard use you want the object to actually do stuff. I use vertex manipulation to move effects around yeah, but usually you're going to actually get it to do something. Plus it's just easier for things like this. The vertices are measured by how far apart they are from the object position, so he's still going to need to set a position.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Infy♫ on June 13, 2010, 04:44:42 PM
How exactly do you use render targets? can anyone give me an example?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on June 13, 2010, 04:50:01 PM
How exactly do you use render targets? can anyone give me an example?

Azure explained it here: http://www.shrinemaiden.org/forum/index.php?topic=4771.msg357169#msg357169
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on June 13, 2010, 09:06:39 PM
This question could be very subjective but I'll ask it anyways. It's not really Danmakufu-related either *shot

In your opinion, or from experience, what amount of life would a boss be at before they switch from the normal getting-hit sound to the high-pitched almost-dead-getting-hit-sound?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on June 13, 2010, 09:34:56 PM
I never noticed they were different.

Also, I would prefer no normal shot sounds at all from the player since they basically play for the whole game D:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on June 13, 2010, 09:38:12 PM
The normal one isn't very loud and doesn't really bother me anyways. It's when you have sounds that go BVVVV BVVVV BVVVV BVVVV every time an option firescoughcoughcough that it gets grating.

5% health sounds about right.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Furienify on June 13, 2010, 09:46:51 PM
I was going to ask something like that myself - what's the syntax for that sort of thing?

I was thinking of just running a task like I do for my timer sfx- if(SyntaxForBossGettingHit && BossHealthLessThanBlah){playsfx}. Something like that. Except I couldn't find the function that detects the boss getting hit by player bullets.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 13, 2010, 09:53:54 PM
Afaik, there is none.

What I did in those situations was to create a variable called bosshp with a value of -999, set it equal to the boss's life during @Initialize, and then put the following code in the main loop:

Code: [Select]
if(bosshp>(-999) ){
if(GetLife<bosshp){
STUFF THAT HAPPENS UPON HIT
}
bosshp=GetLife;
}
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on June 13, 2010, 09:56:53 PM
I was going to ask something like that myself - what's the syntax for that sort of thing?

I was thinking of just running a task like I do for my timer sfx- if(SyntaxForBossGettingHit && BossHealthLessThanBlah){playsfx}. Something like that. Except I couldn't find the function that detects the boss getting hit by player bullets.

That function either does not exist, or is more esoteric than render targets.

I just check if the enemy's health has lowered from before and that enough time has passed since the last enemy-getting-hit-sound played. This does mean that the sound won't play if the enemy is invincible, by the way.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on June 13, 2010, 10:23:37 PM
That function either does not exist, or is more esoteric than render targets.

I just check if the enemy's health has lowered from before and that enough time has passed since the last enemy-getting-hit-sound played. This does mean that the sound won't play if the enemy is invincible, by the way.

GetHitCount
and
GetEnemyLife

What?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 13, 2010, 10:25:29 PM
GetHitCount
WHY DO I NOT KNOW THIS COMMAND?!
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Bitz on June 13, 2010, 10:30:41 PM
Durr hurr hurr *shoots self*

Yeah, I supposed GetHitCount could work too. However, GetHitCount only accounts for projectiles and not other things, like certain bombs and such.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: SparklingOrange on June 14, 2010, 04:28:42 AM
:smug:



@SparklingOrange
Among the other things these fine gents have listed, script_spells use  @Initialize@MainLoop  and  @Finalize  too, dawg.
Yes, I know. I didn't copypaste them onto my original post, but they're there in the actual script from my file.

Well, let xpos=GetCenterX+rand(0,416); should probably be let xpos=rand_int(0,416);
Second, you aren't setting the object's position which means it's nowhere. You don't control object position through XY vertices.
Third, xpos+(60*cos(120)),ypos+(60*sin(120)) should be xpos-80,ypos-300 i.e half the UV for each segment. This means the object's position is in the center of the graphic.
Fourth, vertices don't have anything to do with how your spell runs. There would still be the cutin and sound effect.
Yeah, just a quick correction there; in my experience when working with objects you either have to use SetPosition or vertices, if you use both then the vertices will act really really strangely, especially if you start trying to change the angle or the speed of the object.
I only wanted the texture to position randomly on the x axis, and the y stays at the center. For the angle, I only want it to stay at 90o. I guess it wasn't really necessary to put in the XY functions, so I did what you guys suggested and set the position like so...if it helps, I posted the entire spell script here. I put ??? on the IntersecrionLine xy coordinates 'cause I'm not sure how to set up the damage line relative to the position of the texture (I've put random values to test it out)
Code: [Select]
script_spell CCoil{
let lightning=get~".\img\teslalightningtex.png
let spellcount=0;
task LightningRipple(){
let objlightning=Obj_Create(OBJ_SPELL);
let xpos=rand_int(0,416);
let ypos=GetCenterY;
Obj_SetAlpha(objlightning,200);
                Obj_SetAngle(objlightning,90);
ObjEffect_SetTexture(objlightning,lightning);
ObjEffect_SetRenderState(objlightning,ADD);
ObjEffect_CreateVertex(objlightning,4);
ObjEffect_SetPrimitiveType(objlightning,PRIMITIVE_TRIANGLEFAN);
ObjEffect_SetVertexUV(objlightning,0,0,0);
ObjEffect_SetVertexUV(objlightning,1,160,0);
ObjEffect_SetVertexUV(objlightning,2,160,600);
ObjEffect_SetVertexUV(objlightning,3,0,600);
while(!Obj_BeDeleted(objlightning)){
Obj_SetPosition(objlightning,xpos,ypos);
ObjSpell_SetIntersecrionLine(objlightning,???,100,10,true);
yield;
}
}
task run{
SetPlayerInvincibility(300);
ForbidShot(true);
loop(45){yield;}
while(spellcount<101){
if (spellcount%5==0){
LightningRipple();
LightningRipple();
LightningRipple();
PlaySE(GetCurrentScriptDirectory()~"lightning.wav");
if(spellcount==101){
PlaySE(GetCurrentScriptDirectory()~"crash.wav");}
}
spellcount++;
yield;
}

ForbidShot(false);
SetSpeed(3.5,2.5);
loop(90){yield;}
End();
}
  @Initialize{
  LoadGraphic(lightning);
  run();
  }
  @MainLoop{
  CollectItems();
  yield;
  }
  @Finalize{
  DeleteGraphic(lightning);
  }
}
Yet there's still no difference because no matter how many times I've checked for mistakes on this, the only thing this does is use up a bomb counter. No CutIn effect or sound, no lightning bolt, no lightning death, nothing, zilch, nada...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on June 14, 2010, 04:38:10 AM
You didn't fix the first thing.

let lightning=get~".img   eslalightningtex.png

should be

let lightning=get~".img   eslalightningtex.png";

And I'm still not sure about the directory you have set up there but yeah.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on June 14, 2010, 05:04:12 AM
Plus, assuming you defined get as GetCurrentScriptDirectory, get~".\img\teslalightningtex.png" won't work, since it would put your current script path twice in a row (script\something\script\something\img\file.png rather than just script\something\img\file.png). Either use GetCurrentScriptDirectory or .\, but not both, like this:
Code: [Select]
let lightning=get~"img\teslalightningtex.png";
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: SparklingOrange on June 14, 2010, 07:04:00 AM
You didn't fix the first thing.

let lightning=get~".\img\teslalightningtex.png

should be

let lightning=get~".\img\teslalightningtex.png";

And I'm still not sure about the directory you have set up there but yeah.
Arrgh...missed that one too. It's fixed.
Plus, assuming you defined get as GetCurrentScriptDirectory, get~".\img\teslalightningtex.png" won't work, since it would put your current script path twice in a row (script\something\script\something\img\file.png rather than just script\something\img\file.png). Either use GetCurrentScriptDirectory or .\, but not both, like this:
Code: [Select]
let lightning=get~"img\teslalightningtex.png";
Really? I did both and the files still loaded properly. It might've been something else.

Update: I've found the problem for the whole spellcard issue...it turns out I didn't capitalize the c in @SpellCard, so it's not running the freaking script at all.

I am a moron.

But now that's out of the way, there comes another issue. The lightning didn't render, but the damage line did. Whether the lightning was too small or whatever...it didn't show up. I switched from ADD to ALPHA, but when I tried playtesting, my computer crashed twice for some strange reason. Coincidence or not, I'm still trying to check it out...
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Drake on June 14, 2010, 05:32:28 PM
god fucking dammit sakhrgkasgkdasjfgaks


Anyways, the reason it isn't showing up is because you misinterpreted what I said and removed XY entirely. UV vertices and XY vertices are intertwined with each other. UV sets the position on your image as a vertex point on the game field XY distance from the object's actual position. When you have all four vertices up, it will make a rectangle. Say the XYs were set like this:

ObjEffect_SetVertexXY(objlightning,0,-80,-300);
ObjEffect_SetVertexXY(objlightning,1,80,-300);
ObjEffect_SetVertexXY(objlightning,2,80,300);
ObjEffect_SetVertexXY(objlightning,3,-80,300);


Then the lightning will be drawn in a rectangle with the object's actual position being in the direct center.

ObjEffect_SetVertexXY(objlightning,0,0,0);
ObjEffect_SetVertexXY(objlightning,1,160,0);
ObjEffect_SetVertexXY(objlightning,2,160,600);
ObjEffect_SetVertexXY(objlightning,3,0,600);


Then the top-left corner of the lightning is the object's position.

ObjEffect_SetVertexXY(objlightning,0,70,-50);
ObjEffect_SetVertexXY(objlightning,1,160,-110);
ObjEffect_SetVertexXY(objlightning,2,130,370);
ObjEffect_SetVertexXY(objlightning,3,240,0);


This will totally skew the graphic and I have no idea where the object position actually is, but I don't really care.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Infy♫ on June 15, 2010, 04:01:31 PM
how do you get danmakufu to draw everything onto a render target?
or is this not even possible and have I been lied to?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on June 16, 2010, 12:22:57 PM
how do you get danmakufu to draw everything onto a render target?
or is this not even possible and have I been lied to?

Azure explained it, me gets link. :ohdear:
Huzzah for render targets :V (http://www.shrinemaiden.org/forum/index.php?topic=4771.msg357169#msg357169)
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Infy♫ on June 16, 2010, 01:38:28 PM
...
freakin read up. that page you linked to doesnt answer my question and it has been posted before.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on June 16, 2010, 02:20:11 PM
...
freakin read up. that page you linked to doesnt answer my question and it has been posted before.
Damn, then I'm not sure what now.
I'm stumped on this too :(
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Demonbman on June 17, 2010, 03:50:21 AM
Argh, I am stumpted


http://pastebin.com/c9bhhRa3 (http://[url=http://pastebin.com/c9bhhRa3)] This Code  is giving me problems, I want it to shoot the Fence bullets like I set it to, it works the first time, then when the boss gets in the middle, it messes up, I've tried using both the If method and the task method, but I have no idea how to get this to work, sorry for any inconviences I cause you guys
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KrackoCloud on June 18, 2010, 12:14:21 AM
http://www.mediafire.com/?mlglzm2djew

I'm trying to work out the spellcard background, but... If you notice, at one point, the squiggly lines in the back undergo some weird cutoff effect.
Could someone help me with this?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 18, 2010, 12:27:13 AM
http://www.mediafire.com/?mlglzm2djew

I'm trying to work out the spellcard background, but... If you notice, at one point, the squiggly lines in the back undergo some weird cutoff effect.
Could someone help me with this?
I tried changing
   SetGraphicRect(0,0,600,1000+scroll);
to
   SetGraphicRect(0,scroll,600,1000+scroll);
and
   SetGraphicRect(0,0,600,600-scroll);
to
   SetGraphicRect(0,-scroll,600,600-scroll);

Now it works. Not entirely shure what caused the error, though.  :/
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KomeijiKoishi on June 19, 2010, 03:18:30 PM
How can I achieve this?

If I have a negative number, I want that it counts as a positive one.

But I want positive ones to stay positive.

Using " |number| ! didn't work.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 19, 2010, 03:22:16 PM
Um den Betrag einer Zahl n zu erhalten gibt es zwei M?glichkeiten.

Entweder: abs(n)
Oder: (| n |)

Dritte aber unpraktische M?glichkeit: (n^2)^0.5
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: KomeijiKoishi on June 19, 2010, 03:23:25 PM
Danke, funzt jetzt.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Flyer on June 19, 2010, 04:21:33 PM
Excuse me (and sorry for my poor english). How can I let objects remain after defeating boss?

I want to make UFO item when I defeat a spellcard, but UFO object had just disappeared as spellcard ended and nothing happened. ???
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Iryan on June 19, 2010, 04:29:11 PM
Ah, that is a little advanced.

You see, because you defined the UFO object in the spell card script, it ceases to exist once the spell ends. To get around this problem, you will have to put the code that defines the object inside the stage script that the boss script is part of. To call the object at the right time, I advise creating a CommonData "UfoSpawn" that is set to false. Then you code the stage script so that it will spawn the object and set UfoSpawn to false if its value was true before. Then you make it so that, at the time when the object would be spawned in the player script, you set the UfoSpawn to true instead.

Understood?
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Flyer on June 19, 2010, 04:41:28 PM
Thank you. It worked. :]
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on June 19, 2010, 06:42:52 PM
Sigh.

You know that bug with fog where if you use a polygon that's too big it'll get shaded uniformly instead of having the fog applied correctly? Well on my new computer that bug occurs with any polygon large enough to fill the screen. I'm not sure if it's Windows 7 or my video card causing it. Anybody want to offer any ideas of how I could try to fix it? I already updated my video card drivers. I'd like to try some of the checkbox options in config to see if any of them help but I don't know what they are.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Gc on June 19, 2010, 08:04:06 PM
Sigh.

You know that bug with fog where if you use a polygon that's too big it'll get shaded uniformly instead of having the fog applied correctly? Well on my new computer that bug occurs with any polygon large enough to fill the screen. I'm not sure if it's Windows 7 or my video card causing it. Anybody want to offer any ideas of how I could try to fix it? I already updated my video card drivers. I'd like to try some of the checkbox options in config to see if any of them help but I don't know what they are.
That could be because Danmakufu does not work with DirectX 11. But don't quote me.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on June 19, 2010, 08:33:39 PM
Stuffman I have the EXACT same problem with my 3D stages. The fog error is occurring while I was pretty damn sure on XP it wasn't.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on June 19, 2010, 08:52:47 PM
One solution is to tile the floor with polygons instead of making it one huge one, but I'm finding it impossible to make it seamless, so it also looks bad. :ohdear:
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Helepolis on June 19, 2010, 08:54:34 PM
My floor sections are 1024x1024 each, the only problem is that the backdrop fog sheet is too large, probably that is why it is bleeding through. But it aint bleeding through in my DJ stage. Wonder why exactly =/

How big is yours then?

Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on June 19, 2010, 08:57:58 PM
It was 1000x1500 in the version that worked in WinXP. If I get it down to around 800x800 the bug stops triggering but that isn't enough to cover the screen, especially given how you descend from the clouds at the start of the game.

I'm gonna need to find a solution to this since obviously there'll be some people playing this on Win7.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Azure Lazuline on June 19, 2010, 09:06:55 PM
Make a transparent gradient image, then manually place that over the floor so it gets darker as it gets farther away from the camera. It's a bit harder to work with, but it looks better and you get more control over what it looks like.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Chronojet ⚙ Dragon on June 19, 2010, 09:07:21 PM
Hmmmmm...
Why is it that some functions don't work on certain types of scripts
e.g. GotSpellCardBonus on stage scripts?
But others work e.g. ShootDownPlayer;

WARNING: 1 POST TO THREAD LOCK.
Title: Re: Danmakufu Q&A/Problem Thread v3
Post by: Stuffman on June 19, 2010, 09:10:53 PM
Make a transparent gradient image, then manually place that over the floor so it gets darker as it gets farther away from the camera. It's a bit harder to work with, but it looks better and you get more control over what it looks like.

Hmm, I'll try this; it should work; I'll put the floor before the fog command so mountains and such get affected normally.

In other news,
3000 POSTS OF PROBLEM SOLVING. WELL DONE.