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

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread
« Reply #720 on: September 17, 2009, 10:26:59 PM »
So... how do you make the screen shake? Bullets, player, and all (for a set amount of frames)?  Is there a way to do it without going through too much trouble?

A code would be nice.

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #721 on: September 18, 2009, 12:25:01 AM »
I bet you'll have to use tasks, and a variable shaking=1 (or 0), which indicates the shaking is occurring.

Then mark all bullet current position just before shaking (using e.g. xtemp, ytemp), then

Obj_SetPosition(xtemp+rand(-10,10), ytemp+rand(-10,10)); (for shots and lasers)

And SetPlayerX and SetPlayerY in similar way.

The background can be also shaked as well...
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

CK Crash

  • boozer
Re: Danmakufu Q&A/Problem Thread
« Reply #722 on: September 18, 2009, 12:46:30 AM »
The problem with your idea Henry is that everything will not just shake, but move around completely randomly. This would mess up most bullet patterns as well as cause random clipdeaths for an unlucky player. I see what you're trying to do with the "xtemp" variable, but how would you make your bullet move and shake at the same time (without some trig anyways)? Realistically, shaking the background is pretty much the only thing you can do without causing the player to get annoyed.
Code: [Select]
if (shaking == true){DrawGraphic(GetCenterX+rand(-4,4),GetCenterY+rand(-4,4));}
else{DrawGraphic(GetCenterX,GetCenterY);}
Just declare a variable "shaking", and set it to "true" whenever you want the effect.

Re: Danmakufu Q&A/Problem Thread
« Reply #723 on: September 18, 2009, 01:04:28 AM »
You could make the player shake too.

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #724 on: September 18, 2009, 01:39:05 AM »
Em.

As in marisa's SC's, the player, bullets, background all shake in the same direction.

another variable can be used to determine the shaking x=rand(-10,10), y=rand(-10,10);

Then I made this to demonstrate shaking of player and bullets:

Code: [Select]
#TouhouDanmakufu
#Title[Shaking "Vision error"]
#Text[...]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main{
   let ImgBoss = "script\img\ExRumia.png";
   let frame = -120;
   let MAX=30;
   let i;
   let j;
   let x;
   let y;
   let xtemp=0;
   let ytemp=0;
   let playerX;
   let playerY;
   let shaking=0;
   @Initialize{
      SetLife(4000);
      SetTimer(60);
      SetScore(1000000);
      SetMovePosition02(GetCenterX, GetClipMinY+120, 120);
      CutIn(YOUMU, "Shaking "\""Vision error"\", "", 0, 0, 0, 0);
      LoadGraphic(ImgBoss);
      SetTexture(ImgBoss);
      SetGraphicRect(0, 0, 64, 64);
      LoadUserShotData(GetCurrentScriptDirectory~"images\shot_All.txt");
   }
   @MainLoop{
      SetCollisionA(GetX, GetY, 32);
      SetCollisionB(GetX, GetY, 16);
      if(frame%80==20&&frame>0){
         ascent(i in 0..MAX){
            ascent(j in 0..8){
               Bullet(2, GetAngleToPlayer+i*360/MAX, j*8);
            }
         }
      }
      if(frame%240==40){
         shaking=1;
      }
      if(frame%240==140){
shaking=0;
      }
      if(frame%240>=40&&frame%240<140){
playerX=GetPlayerX-xtemp;
playerY=GetPlayerY-ytemp;
      }
      if(shaking==1){
xtemp=rand(-10,10);
ytemp=rand(-10,10);
SetPlayerX(playerX+xtemp);
SetPlayerY(playerY+ytemp);
      }
      frame++;
      yield;
   }
   @DrawLoop{
      DrawGraphic(GetX,GetY);
   }
   @Finalize{
      DeleteGraphic(ImgBoss);
   }
   task Bullet(v, angle, delay){
      loop(delay){yield;}
      let obj=Obj_Create(OBJ_SHOT);
      Obj_SetPosition(obj, GetEnemyX, GetEnemyY);
      Obj_SetSpeed(obj,0);
      Obj_SetAngle(obj,angle);
      ObjShot_SetGraphic(obj, 57);
      ObjShot_SetDelay(obj, 10);
      let objX=Obj_GetX(obj);
      let objY=Obj_GetY(obj);
      while(Obj_BeDeleted(obj)==false){
if(shaking==0){
    Obj_SetPosition(obj, objX, objY);
}else{
    Obj_SetPosition(obj, objX+xtemp, objY+ytemp);
}
objX+=cos(angle)*v;
objY+=sin(angle)*v;
yield;
      }
   }
}
The bullets does not shake in the way as same as the player. Why?
« Last Edit: September 18, 2009, 02:32:52 AM by Henry »
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Thaws

  • _m廿廿m_
Re: Danmakufu Q&A/Problem Thread
« Reply #725 on: September 18, 2009, 12:11:23 PM »
I'm having another idea about the shaking thing.

(bullets is a array of bullets)
Code: [Select]
task shake(duration)
{
let sframe = 0;
while (sframe < duration)
{
xtemp=rand(-10,10);
    ytemp=rand(-10,10);
    SetPlayerX(GetPlayerX+xtemp);
    SetPlayerY(GetPlayerY+ytemp);
ascent(i in 0..length(bullets)-1)
{
Obj_SetPosition(bullets[i], Obj_GetX(bullets[i])+xtemp, Obj_GetY(bullets[i])+ytemp);
}
sframe++;
yield;

    SetPlayerX(GetPlayerX-xtemp);
    SetPlayerY(GetPlayerY-ytemp);
ascent(i in 0..length(bullets)-1)
{
Obj_SetPosition(bullets[i], Obj_GetX(bullets[i])-xtemp, Obj_GetY(bullets[i])-ytemp);
}
sframe++;
yield;
}
}
« Last Edit: September 18, 2009, 12:26:32 PM by Thaws »

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #726 on: September 18, 2009, 01:28:58 PM »
Both your and my segment has a fundamental problem: The boss is not moved and this leads to distortion of bullet patterns.
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #727 on: September 18, 2009, 01:40:01 PM »
You know, this whole screen shaking thing should be MUCH easier because it has been used so many times in Anaki script ( yes , that one. ).

I downloaded the aniki script and started analysing it yesterday but stopped because it was bed time.

It seriously should be easier somehow.
« Last Edit: September 18, 2009, 01:42:50 PM by Helepolis »

Thaws

  • _m廿廿m_
Re: Danmakufu Q&A/Problem Thread
« Reply #728 on: September 18, 2009, 01:48:34 PM »
Both your and my segment has a fundamental problem: The boss is not moved and this leads to distortion of bullet patterns.

SetX(GetX + xtemp);
SetY(GetY + ytemp);

Problem solved.

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #729 on: September 18, 2009, 02:45:20 PM »
(Can you post the whole script here? I'm having problem in successfully making it :()

Code: [Select]
#TouhouDanmakufu
#Title[Moon-Metal Sign "Sunshine reflector"]
#Text[The danmaku version of the card with same name in SWR]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
    let frame = -120;
    let bg = GetCurrentScriptDirectory~"images\Bossbggrey.jpg";
    let random;
    let i;
    let j;
    let radius;
    let bullets=[];
    let size=0;
    #include_function "..\drawing.txt"
    @Initialize {
       SetLife(1500);
       SetTimer(60);
       SetScore(1000000);
       SetDamageRate(25,0);
       SetMovePosition02(GetCenterX, GetClipMinY+120, 120);
       SetInvincibility(120);
       Concentration01(120);
       PlaySE(GetCurrentScriptDirectory~"SFX\Charge.wav");
       CutIn(YOUMU, "Moon-Metal Sign "\""Sunshine reflector"\", "", 0, 0, 0, 0);
       LoadGraphic(ImgBoss);
       SetTexture(ImgBoss);
       SetGraphicRect(0, 0, 64, 64);
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
        if(frame==60){
           ascent(i in 0..6){
      Laser(GetX+cos(GetAngleToPlayer+i*360/6)*60, GetY+sin(GetAngleToPlayer+i*360/6)*60, GetAngleToPlayer+i*360/6-120, 60, 0, 60, 1);
      Laser(GetX+cos(GetAngleToPlayer+i*360/6)*60, GetY+sin(GetAngleToPlayer+i*360/6)*60, GetAngleToPlayer+i*360/6, 60, 0, 60, 2);
              ascent(j in 0..6){
                 
              }
           }
        }
if(frame==120){
   ascent(i in 0..7){
      ascent(j in 0..6){
ShootBullet(GetX, GetY, 1, GetAngleToPlayer+i*360/7, 10+j*5, 11, size);
      }
   }
}
        frame++;
        yield;
    }

    @DrawLoop {
       bossSC;
    }
    @BackGround{
       backgroundSC;
    }
    task Laser(x,y,angle,length,delay,delay2,type){
       loop(delay){yield;}
       let obj=Obj_Create(OBJ_LASER);
       Obj_SetPosition(obj, x, y);
       Obj_SetAngle(obj, angle);
       Obj_SetSpeed(obj, 0);
       ObjLaser_SetLength(obj, length);
       ObjLaser_SetWidth(obj, 10);
       ObjLaser_SetSource(obj, false);
       ObjShot_SetGraphic(obj, 160);
       Obj_SetCollisionToObject(obj,true);
       if(type==2){
          ObjShot_SetGraphic(obj, 158);
       }
       if(type==3){
  ObjShot_SetGraphic(obj, 153);
       }

       ObjShot_SetDelay  (obj, delay2);
       while(Obj_BeDeleted(obj)==false&&frame>120){
  ascent(i in 0..size){
             if(Collision_Obj_Obj(obj, bullets[i])==1){
        if(type==2){
   Obj_SetAngle(bullets[i], 2*Obj_GetAngle(obj)-Obj_GetAngle(bullets[i]));
}
if(type==3){
   ShootBullet(Obj_GetX(bullets[i]), Obj_GetY(bullets[i]), 1, 2*Obj_GetAngle(obj)-Obj_GetAngle(bullets[i]), 0, 11, size);
}
     }
  }
          yield;
       }
    }
    task ShootBullet(x,y,v,angle,delay,type,store){
       loop(delay){yield;}
       let obj=Obj_Create(OBJ_SHOT);
       Obj_SetPosition(obj, x, y);
       Obj_SetAngle(obj, angle);
       Obj_SetSpeed(obj, v);
       ObjShot_SetGraphic(obj, 160);
       Obj_SetCollisionToObject(obj,true);
       bullets ~ obj; //problems here
       size++;
    }
    @Finalize {
        DeleteGraphic(ImgBoss);
    }
}

Thing I would like to make here:

1. 3 types of lasers: white, red and blue
2. Bullets do the following action:
if it hits white laser, just pass through it.
if it hits blue laser, it reflects.
if it hits red laser, not only it reflects, a new bullet is generated, continuing the bullets last motion.

I bet there is a very serious problem in the algorithm, is the spell card a bad idea? (with wrong segment marked)
« Last Edit: September 18, 2009, 03:26:01 PM by Henry »
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread
« Reply #730 on: September 21, 2009, 03:38:42 AM »
Excuse my noobishness, but I just don't understand why this script won't run

Code: [Select]
#TouhouDanmakufu
#Title[Why doesn't this one work?]
#Text[Using loop to spawn bullets in a circular pattern.]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{


   let imgExRumia="script\ExRumia\img\ExRumia.png";
   let frame = 0;
   let angle = 0;
   
   
   @Initialize{
      SetLife(1500);
      SetTimer(60);
      SetInvincibility(30);
      LoadGraphic(imgExRumia); //Load the boss graphic.
      SetMovePosition02(GetCenterX, GetCenterY - 100, 120);
      hitit;
   }
   
   @MainLoop{
   SetCollisionA(GetX, GetY, 32);
   SetCollisionB(GetX, GetY, 16);
 



   
   }

   @DrawLoop{
     

      SetColor(255,255,255);
      SetRenderState(ALPHA);
      SetTexture(imgExRumia);
      SetGraphicRect(64,1,127,64);
      DrawGraphic(GetX,GetY);
   }
     
   @Finalize
   {
   DeleteGraphic(imgExRumia);
   }

              task hitit{
                            loop(120){yield}
            loop{
       loop(36){CreateShot01(GetX + 60*cos(angle), GetY + 60*sin(angle), 3, angle, BLUE12, 12);
                    angle += 360/36;}   
                                            loop(6){yield;}
                                     
                   }
                          }
}             
   



When this one does--
Code: [Select]
#TouhouDanmakufu
#Title[Spawning Bullets in a Circle intermediate]
#Text[Using loop to spawn bullets in a circular pattern.]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{


   let imgExRumia="script\ExRumia\img\ExRumia.png";
   let frame = 0;
   let angle = 0;
   
   
   @Initialize{
      SetLife(1500);
      SetTimer(60);
      SetInvincibility(30);
      LoadGraphic(imgExRumia); //Load the boss graphic.
      SetMovePosition02(GetCenterX, GetCenterY - 100, 120); //Move the boss to the top center of the screen.
   }
   
   @MainLoop{
   SetCollisionA(GetX, GetY, 32);
   SetCollisionB(GetX, GetY, 16);
   frame++;
   
if(frame==118){
   hitit;
   angle += 4;
   frame = 112;
   
}
   
   
   }

   @DrawLoop{
     
      SetColor(255,255,255);
      SetRenderState(ALPHA);
      SetTexture(imgExRumia);
      SetGraphicRect(64,1,127,64);
      DrawGraphic(GetX,GetY);
   }
     
   @Finalize
   {
      DeleteGraphic(imgExRumia);
   }


 task hitit{
   loop(36){
                                             CreateShot01(GetX + 60*cos(angle), GetY + 60*sin(angle), 3, angle, BLUE12, 12);
                                             angle += 360/36;
}
}
}
}



It makes no sense, it's an almost exact reproduction. It's a very easy script, but I just can't get past it. How can I make it so it will load the stuff I want @initialize?

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #731 on: September 21, 2009, 03:52:15 AM »
put a yield in your mainloop goddammit


aksdfksjbgljasdbljabldjsf

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

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #732 on: September 21, 2009, 04:18:59 AM »
In fact I still think yield; is not a very good function to use, so if it is not necessary, I don't use it :)

My above script is edited:

Code: [Select]
#TouhouDanmakufu
#Title[Moon-Metal Sign "Sunshine reflector"]
#Text[The danmaku version of the card with same name in SWR]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
    let frame = -120;
    let random;
    let i;
    let j;
    let radius;
    let bullets=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
    let size=0;
    let ImgBoss = "script\img\ExRumia.png";
    LoadUserShotData(GetCurrentScriptDirectory~"images\shot_All.txt");
    @Initialize {
       SetLife(1500);
       SetTimer(60);
       SetScore(1000000);
       SetDamageRate(25,0);
       SetMovePosition02(GetCenterX, GetClipMinY+120, 120);
       SetInvincibility(120);
       Concentration01(120);
       PlaySE(GetCurrentScriptDirectory~"SFX\Charge.wav");
       CutIn(YOUMU, "Moon-Metal Sign "\""Sunshine reflector"\", "", 0, 0, 0, 0);
       LoadGraphic(ImgBoss);
       SetTexture(ImgBoss);
       SetGraphicRect(0, 0, 64, 64);
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
        if(frame==60){
           ascent(i in 0..6){
      Laser(cos(i*360/6)*60, sin(i*360/6)*60, GetAngleToPlayer, i*360/6-120, 60, 0, 60, 1);
      Laser(cos(i*360/6)*60, sin(i*360/6)*60, GetAngleToPlayer, i*360/6, 60, 10, 60, 2);
              ascent(j in 0..6){
Laser(cos(i*360/6)*180+cos(j*360/6)*60, sin(i*360/6)*180+sin(j*360/6)*60, GetAngleToPlayer, j*360/6-120, 60, 20, 60, 3);
              }
      Laser(cos(i*360/6)*60, sin(i*360/6)*180, GetAngleToPlayer, i*360/6-120, 60, 30, 60, 2);
      Laser(cos(i*360/6)*300, sin(i*360/6)*180, GetAngleToPlayer, i*360/6+60, 60, 40, 60, 2);

           }
        }
if(frame==120){
   ascent(i in 0..7){
      ascent(j in 0..6){
ShootBullet(GetX, GetY, 1, GetAngleToPlayer+i*360/7, 10+j*5, 11);
      }
   }
}
        frame++;
        yield;
    }

    @DrawLoop {
       DrawGraphic(GetX,GetY);
    }
    task Laser(x,y,slant,angle,length,delay,delay2,type){
       loop(delay){yield;}
       let obj=Obj_Create(OBJ_LASER);
       Obj_SetPosition(obj, GetX+cos(slant)*x-y*sin(slant), GetY+sin(slant)*x+y*cos(slant));
       Obj_SetAngle(obj, slant+angle);
       Obj_SetSpeed(obj, 0);
       ObjLaser_SetLength(obj, length);
       ObjLaser_SetWidth(obj, 10);
       ObjLaser_SetSource(obj, false);
       Obj_SetCollisionToObject(obj,true);
       bullets[size]=obj;
       if(type==1){
  ObjShot_SetGraphic(obj, 96);
       }
       if(type==2){
          ObjShot_SetGraphic(obj, 94);
       }
       if(type==3){
  ObjShot_SetGraphic(obj, 89);
       }
       ObjShot_SetDelay  (obj, delay2);
       while(Obj_BeDeleted(obj)==false&&frame>120){
          yield;
       }
       size++;
    }
    task ShootBullet(x,y,v,angle,delay,type){
       loop(delay){yield;}
       let obj=Obj_Create(OBJ_SHOT);
       Obj_SetPosition(obj, x, y);
       Obj_SetAngle(obj, angle);
       Obj_SetSpeed(obj, v);
       ObjShot_SetGraphic(obj, 11);
       Obj_SetCollisionToObject(obj,true);
       while(Obj_BeDeleted(obj)==false&&frame>120){
  ascent(i in 0..size){
             if(Collision_Obj_Obj(obj, bullets[i])==1){ //bug here
        if(type==2){
   Obj_SetAngle(obj, 2*Obj_GetAngle(obj)-Obj_GetAngle(bullets[i]));
}
if(type==3){
   ShootBullet(Obj_GetX(obj), Obj_GetY(obj), 1, 2*Obj_GetAngle(bullets[i])-Obj_GetAngle(obj), 0, 11);
}
     }
  }
          yield;
       }
    }
    @Finalize {
        DeleteGraphic(ImgBoss);
    }
}

It requires the CtC shot_all.txt and the corresponding image to work.
Can anyone try to find why there is a bug?
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #733 on: September 21, 2009, 04:55:34 AM »
Here, have a useful page.

http://touhou.wikia.com/wiki/Touhou_Danmakufu:_Translated_Error_Messages

Your error message reads, variables of different types are being compared. I believe the problem is that you are reading if Collision_Obj_Obj==1, while I don't think true/false returns work that way. That is, 1 is always true, but true is not always 1. Just remove the ==1 and the if statement will register it as true/false just fine. That makes the script stop crashing but I don't know if it's actually running correctly since I didn't bother to put the shot_all in there.

Re: Danmakufu Q&A/Problem Thread
« Reply #734 on: September 21, 2009, 05:09:54 AM »
I live!! I have a question regarding shot angles,GetAngleToPlayer just gets the angle of the player, is there some part of a code or something to fire directly at the player? or will i need to create a task bullet or laser??

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #735 on: September 21, 2009, 08:07:22 AM »
I am amazed people try to use a task function but still use their mainloop as the leading code ( such as in if frame == x then do -> )

Ohwell, everybodies style I guess.

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #736 on: September 21, 2009, 12:27:23 PM »
Here, have a useful page.

http://touhou.wikia.com/wiki/Touhou_Danmakufu:_Translated_Error_Messages

Your error message reads, variables of different types are being compared. I believe the problem is that you are reading if Collision_Obj_Obj==1, while I don't think true/false returns work that way. That is, 1 is always true, but true is not always 1. Just remove the ==1 and the if statement will register it as true/false just fine. That makes the script stop crashing but I don't know if it's actually running correctly since I didn't bother to put the shot_all in there.
Thanks for your help.
However, my computer cannot display Japanese properly (My computer displays Chinese properly but when I use Applocale, Danmakufu crashes :() So that the translated error message may not be so helpful for me. :(
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Re: Danmakufu Q&A/Problem Thread
« Reply #737 on: September 21, 2009, 04:09:05 PM »
Yeah no problem guys I got this. Don't confuse yourselves or anything trying to figure this mofo out -- I got it covered.

I live!! I have a question regarding shot angles,GetAngleToPlayer just gets the angle of the player, is there some part of a code or something to fire directly at the player? or will i need to create a task bullet or laser??

GetAngleToPlayer gets the angle from the boss to the player. So if you're shooting a bullet spawned on the boss' position (GetX, GetY) and you use the function GetAngleToPlayer as your angle parameter, then the bullet will be fired towards the player. However, if the bullet is spawned on some other location other than the boss', then GetAngleToPlayer will not work. It does not get the angle from the bullet to the player.

If you want to get the angle from the bullet to the player, then you must use atan2(Player's Y - Bullet's Y, Player's X - Bullet's X).

For example, if you spawned a bullet on the coordinates (200, 300), then the angle from (200, 300) to (GetPlayerX, GetPlayerY) would be calculated like so:
atan2(GetPlayerY - 300, GetPlayerX - 200);

So the bullet's code would look like:
CreateShot01(200, 300, 3, atan2(GetPlayerY - 300, GetPlayerX - 200), RED01, 0);

Another example, bullet spawned on (10, 340):
CreateShot01(10, 340, 2, atan2(GetPlayerY - 340, GetPlayerX - 10), BLUE02, 0);

Etc.
Other useless information.

Re: Danmakufu Q&A/Problem Thread
« Reply #738 on: September 21, 2009, 05:09:10 PM »
Thank you Naut that worked like a charm :) but now im having another issue, i want to fire a ring of bullets that spread out, then stop, ive tried using the loop function with CreateShotAs and realized after half an hour that wouldnt work, so what would i do? never mind DgBarca helped me with it :)
« Last Edit: September 21, 2009, 05:38:33 PM by Demonbman »

shazbot

Re: Danmakufu Q&A/Problem Thread
« Reply #739 on: September 21, 2009, 10:51:06 PM »
hello, I have literally downloaded danmakufu 3 days before this post and have been reading the tuts, however I have a reoccurring problem, movement, I cannot seem to get the boss to move no matter where,how, or with what I place the SetMovePosition functions; placing the answer in a full script would be helpful, I'm sorry if this has already been brought up, 25 pages is a wee to much to sift through.

EDIT: see new post
« Last Edit: September 22, 2009, 07:11:32 PM by shazbot »

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #740 on: September 22, 2009, 12:23:22 AM »
Thank you Naut that worked like a charm :) but now im having another issue, i want to fire a ring of bullets that spread out, then stop, ive tried using the loop function with CreateShotAs and realized after half an hour that wouldnt work, so what would i do? never mind DgBarca helped me with it :)

Yes, that works.
ascent(i in 0..24){
  CreateShotA(0, GetX, GetY, 10); //fire from boss
  SetShotDataA(0, 0, 2, i*360/24+*any constant here, e.g. GetAngleToPlayer*, 0, -0.05, 0, *your graphic here*);
  FireShot(0); //don't miss this
}
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #741 on: September 22, 2009, 12:24:57 AM »
hello, I have literally downloaded danmakufu 3 days before this post and have been reading the tuts, however I have a reoccurring problem, movement, I cannot seem to get the boss to move no matter where,how, or with what I place the SetMovePosition functions; placing the answer in a full script would be helpful, I'm sorry if this has already been brought up, 25 pages is a wee to much to sift through.
Try downloading scripts. If it doesn't work, reinstall Danmakufu.
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #742 on: September 22, 2009, 05:49:46 AM »
hello, I have literally downloaded danmakufu 3 days before this post and have been reading the tuts, however I have a reoccurring problem, movement, I cannot seem to get the boss to move no matter where,how, or with what I place the SetMovePosition functions; placing the answer in a full script would be helpful, I'm sorry if this has already been brought up, 25 pages is a wee to much to sift through.

Post your script here between  code  tags so we can see it.

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #743 on: September 22, 2009, 08:06:28 AM »
Hi everyone.

If I need to create a Shot-Laser Collision, which that the shot divides into 2: 1 continue its motion, another is reflected and the function for the shot is FireShot(x,y,angle,delaybeforeappearance,fadeindelay).

If I use
if(Collision_obj_obj(bullet, laser)==0){
FireShot(Get_ObjX(bullet), Get_ObjY(bullet), reflected angle, 0, 0);
}

It fails because the Created Bullet also collides with the laser.

is that anyway to solve the problem?
« Last Edit: September 22, 2009, 08:16:51 AM by Henry »
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

Thaws

  • _m廿廿m_
Re: Danmakufu Q&A/Problem Thread
« Reply #744 on: September 22, 2009, 10:00:06 AM »
Hi everyone.

If I need to create a Shot-Laser Collision, which that the shot divides into 2: 1 continue its motion, another is reflected and the function for the shot is FireShot(x,y,angle,delaybeforeappearance,fadeindelay).

If I use
if(Collision_obj_obj(bullet, laser)==0){
FireShot(Get_ObjX(bullet), Get_ObjY(bullet), reflected angle, 0, 0);
}

It fails because the Created Bullet also collides with the laser.

is that anyway to solve the problem?

A simple method would be to not do any collison checking until the bullet has been spawned for over 60frames or something.

So add a frame varible with frame++; somewhere then use
if((Collision_obj_obj(bullet, laser)==0)&&(frame > 60)){
FireShot(Get_ObjX(bullet), Get_ObjY(bullet), reflected angle, 0, 0);
}

Something like that.

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #745 on: September 22, 2009, 01:39:09 PM »
This solution is charming, thanks Thaws :)

P.S.
Code: [Select]
#TouhouDanmakufu
#Title[Moon-Metal Sign "Sunshine reflector"]
#Text[The danmaku version of the card with same name in SWR]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
    let frame = -120;
    let bg = GetCurrentScriptDirectory~"images\Bossbggrey.jpg";
    let random;
    let i;
    let j;
    let radius;
    let bullets=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
    let laser=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
    let size=0;
    #include_function "..\drawing.txt"
    @Initialize {
       SetLife(1500);
       SetTimer(60);
       SetScore(1000000);
       SetDamageRate(25,0);
       SetMovePosition02(GetCenterX, GetClipMinY+120, 120);
       SetInvincibility(120);
       Concentration01(120);
       PlaySE(GetCurrentScriptDirectory~"SFX\Charge.wav");
       CutIn(YOUMU, "Moon-Metal Sign "\""Sunshine reflector"\", "", 0, 0, 0, 0);
       LoadGraphic(ImgBoss);
       SetTexture(ImgBoss);
       SetGraphicRect(0, 0, 64, 64);
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
        if(frame==60){
           ascent(i in 0..6){
      ascent(j in 0..2){
         Laser(60, 0, GetAngleToPlayer+i*60, -120*j, 60, 0, 60, 1-j);
      }
              ascent(j in 0..2){
Laser(60, 60*3^0.5, GetAngleToPlayer+i*360/6, 120*j, 60, 20, 60, 2);
Laser(30, 90*3^0.5, GetAngleToPlayer+i*360/6, 180-120*j, 60, 30, 60, 1);
              }
           }
        }
if(frame%120==0&&frame>0){
   random=rand(0,360);
   ascent(i in 0..8){
      ascent(j in 0..4){
ShootBullet(GetX, GetY, 3, random+i*360/8+45, 10+j*6);
      }
   }
}
        frame++;
        yield;
    }

    @DrawLoop {
       bossSC;
    }
    @BackGround{
       backgroundSC;
    }
    task Laser(x,y,slant,angle,length,delay,delay2,type){
       loop(delay){yield;}
       let obj=Obj_Create(OBJ_LASER);
       let type2=type;
       Obj_SetPosition(obj, GetX+cos(slant)*x-y*sin(slant), GetY+sin(slant)*x+y*cos(slant));
       Obj_SetAngle(obj, slant+angle);
       Obj_SetSpeed(obj, 0);
       ObjLaser_SetLength(obj, length);
       ObjLaser_SetWidth(obj, 10);
       ObjLaser_SetSource(obj, false);
       Obj_SetCollisionToObject(obj,true);
       bullets[size]=obj;
       laser[size]=type2;
       size++;
       if(type2==0){
  ObjShot_SetGraphic(obj, 160-8);
       }
       if(type2==1){
          ObjShot_SetGraphic(obj, 158-8);
       }
       if(type2==2){
  ObjShot_SetGraphic(obj, 153-8);
       }
       ObjShot_SetDelay  (obj, delay2);
       while(Obj_BeDeleted(obj)==false){
  if(frame%250==0){
     type2=0;
             laser[size]=type2;
     ObjShot_SetGraphic(obj, 160-8);
  }
  if(frame%250==125){
     type2=type;
     laser[size]=type2;
             if(type2==0){
  ObjShot_SetGraphic(obj, 160-8);
             }
             if(type2==1){
                ObjShot_SetGraphic(obj, 158-8);
             }
             if(type2==2){
  ObjShot_SetGraphic(obj, 153-8);
             }
  }
          yield;
       }
    }
    task ShootBullet(x,y,v,angle,delay){
       loop(delay){yield;}
       let obj=Obj_Create(OBJ_SHOT);
       let count=1;
       let frame2=0;
       Obj_SetPosition(obj, x, y);
       Obj_SetAngle(obj, angle);
       Obj_SetSpeed(obj, v);
       ObjShot_SetGraphic(obj, 11);
       Obj_SetCollisionToObject(obj,true);
       while(Obj_BeDeleted(obj)==false){
  ascent(i in 0..size){
             if(Collision_Obj_Obj(obj, bullets[i])&&frame2>10&&count>0){
        if(laser[i]==1){
   Obj_SetAngle(obj, 2*Obj_GetAngle(bullets[i])-Obj_GetAngle(obj));
}
if(laser[i]==2){
   ShootBullet(Obj_GetX(obj)+cos(Obj_GetAngle(bullets[i])), Obj_GetY(obj)+sin(Obj_GetAngle(bullets[i])), v, 2*Obj_GetAngle(bullets[i])-Obj_GetAngle(obj), 0);
   count--;
}
     }
  }
  frame2++;
          yield;
       }
    }
    @Finalize {
        DeleteGraphic(ImgBoss);
    }
}

Is there anyway to make it faster?
« Last Edit: September 22, 2009, 03:00:50 PM by Henry »
Old/Forgotten member.

Old Patchouli Project was outdated but new one is in progress.

shazbot

Re: Danmakufu Q&A/Problem Thread
« Reply #746 on: September 22, 2009, 07:10:54 PM »
oh nevermind it seems the problem was the copypasta-ed full script not what I was inputting, I may have deleted one too many things when trying to remove the attack, sorry for any inconvenience.
« Last Edit: September 22, 2009, 07:13:57 PM by shazbot »

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread
« Reply #747 on: September 22, 2009, 07:23:38 PM »
put a yield in your mainloop goddammit


aksdfksjbgljasdbljabldjsf


I don't understand. Why does it work when I put in "yield;", but not when I don't?
I thought yield is a subfunction that delays frames.

Re: Danmakufu Q&A/Problem Thread
« Reply #748 on: September 22, 2009, 08:18:47 PM »

CK Crash

  • boozer
Re: Danmakufu Q&A/Problem Thread
« Reply #749 on: September 22, 2009, 11:42:17 PM »
Yield basically tells a script to stop and look for another task it should be working on. If you don't have one in @MainLoop, it will only execute a task up to its first yield, after which it will be completely forgotten. By looping yield, it tells a task to stop and check for others a certain number of frames before continuing.