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

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #360 on: July 23, 2009, 02:39:13 PM »
Ah, so it is possible after all! I'll try this out when I finally get the chance, thanks!

Edit:
Ah, it seems to look for the shot replacements, but once that's solves it errors some more about "shotinit;" and "WHITEI02"
But I solved that, so the real important part of the script is:

Code: [Select]
let playerv=0;

if(frame>1){
 if((GetKeyState(VK_SLOWMOVE) == KEY_HOLD) || (GetKeyState(VK_SLOWMOVE) == KEY_PUSH))
         {
            playerv = GetPlayerInfo(PLAYER_SPEED_LOW);
         }else
         {
            playerv = GetPlayerInfo(PLAYER_SPEED_HIGH);
         }
         if((GetKeyState(VK_LEFT) == KEY_HOLD) || (GetKeyState(VK_LEFT) == KEY_PUSH))
         {
            SetPlayerX(GetPlayerX + playerv*2);
         }
         if((GetKeyState(VK_RIGHT) == KEY_HOLD) || (GetKeyState(VK_RIGHT) == KEY_PUSH))
         {
            SetPlayerX(GetPlayerX - playerv*2);
}
}


It's very similiar to what I tried, except that I tried moving the player with GetPlayerX, which is wrong ofcourse!
« Last Edit: July 23, 2009, 05:24:22 PM by puremrz »
Full Danmakufu game "Juuni Jumon - Summer Interlude" is done!
By the same person who made Koishi Hell 1,2 (except this game is serious)
Topic: http://www.shrinemaiden.org/forum/index.php/topic,9647.0.html

Re: Danmakufu Q&A/Problem Thread
« Reply #361 on: July 23, 2009, 08:33:34 PM »
Am I able to put this in a task, subroutine, function, etc. so I will be able to save space instead of copying and pasting whenever it needs to be called? I am making a spellcard, but it requires this to be called up numerous times:



Code: [Select]
if(s < 0.0035){
accelerate = 1;
}

if(s > 0.035){
accelerate = 0;
}

if(accelerate == 1){
s += 0.0035;
}

if(accelerate == 0){
s -= 0.0035;
}

CK Crash

  • boozer
Re: Danmakufu Q&A/Problem Thread
« Reply #362 on: July 23, 2009, 09:01:16 PM »
Subroutines are exactly what you want to use. They let you call up a part of the script whenever you want. Just put this somewhere outside of the @Loops, but still inside the boss script (after @Finalize is a good idea)...

Code: [Select]
sub callthisfunction
{
if(s < 0.0035){
accelerate = 1;
}

if(s > 0.035){
accelerate = 0;
}

if(accelerate == 1){
s += 0.0035;
}

if(accelerate == 0){
s -= 0.0035;
}
}

...then just use callthisfunction; anywhere to use it again.

Functions basically work the same, you can also provide a number of variables for the function to use.

Code: [Select]
function shootredbullet(speed)
{
CreateShot01(GetX,GetY,speed,GetAngleToPlayer,RED01,30);
}

You could put shootredbullet(4); to shoot a red bullet at that speed. You can use more variables, just separate them with commas. Be sure not to name them the same as your declared variables, as this can lead to confusing situations.

Re: Danmakufu Q&A/Problem Thread
« Reply #363 on: July 23, 2009, 09:47:54 PM »
I understand. Thank you very much.

Another question about functions: Can I put more than one bullet in the same function, or is only one bullet allowed per function?

Re: Danmakufu Q&A/Problem Thread
« Reply #364 on: July 23, 2009, 10:09:56 PM »
You can put a near endless amount of information inside of a subroutine/function/task, it needn't be bullets either.

Re: Danmakufu Q&A/Problem Thread
« Reply #365 on: July 23, 2009, 10:30:51 PM »
Okay. Thank you.

Hat

  • Just an unassuming chapeau.
  • I will never be ready.
Re: Danmakufu Q&A/Problem Thread
« Reply #366 on: July 24, 2009, 10:12:52 PM »
Blaaaargh. I almost had it! The homing code I mean. The trouble is when I cross the 180 degree line relative to the bullet, it starts looping around in the opposite direction. I'm attributing this to a mysterious change in sign, but I can't seem to iron out that problem. I'm pretty sure it's because I'm using p_angle > Obj_GetAngle(obj) or what have you. That argument gets fucked up when the 180 line is crossed (coz atan2 loops around into -180 and starts counting up from there)... so what do I do now?

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #367 on: July 24, 2009, 10:37:01 PM »
Here's a blurb of code Drake wrote up for Josette Y's homing shot that may be helpful:

angle is the current angle of the object shot, maxTraverse is the maximum number of degrees the shot can turn each frame.
Code: [Select]
let direction=atan2(GetEnemyY-Obj_GetY(objb), GetEnemyX-Obj_GetX(objb));
let difference = direction - angle;
while(difference >= 180) { difference -= 360; }
while(difference < -180) { difference += 360; }
let diffAbsolute = (|difference|);
if(diffAbsolute < maxTraverse) {
angle = direction;
} else {
angle += maxTraverse * difference / diffAbsolute;
}
Obj_SetAngle(objb, angle);

Of particular interest is those while loops, which will force the angle into the -180~180 range and make it work with other calculations correctly.

Re: Danmakufu Q&A/Problem Thread
« Reply #368 on: July 25, 2009, 12:22:48 AM »
Try inputting something to normalize the angles to a positive value:

while(p_angle < 0){ p_angle+=360; }
while(p_angle > 360){ p_angle-=360; }

Of particular interest is those while loops, which will force the angle into the -180~180 range and make it work with other calculations correctly.

Oh God

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #369 on: July 25, 2009, 12:45:34 AM »
naut made a booboo

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

Primula

  • EARL TYPE 222
Re: Danmakufu Q&A/Problem Thread
« Reply #370 on: July 26, 2009, 02:41:17 AM »
However,this script keeps crashing on me because I was editing the dialogue.


Code: [Select]
#ScriptVersion[2]
script_enemy_main{
#include_function "script\WalkerScript\Tenshi\BgControl.txt";
let ImgBoss = "script\WalkerScript\img\TenshiBoss.png";
let count = 0;
let bgm = false;
task Behavior(){
yield;
while( GetEventStep() != 1 ){ yield; }
PlaySE("script\WalkerScript\sound\charge2.mp3");
SetColor(250,50,50);
Concentration01(120);
SetColor(255,255,255);
SetMovePosition03( GetCenterX(), GetCenterY() - 100, 20, 5 );
SetEnemyMarker( true );
while( GetEventStep() != 2 ){ yield; }
while( GetEventStep() != 3 ){ yield; }
bgm = true;
PlayMusic("script\WalkerScript\sound\Hisouten.mp3");


}
@Initialize{
DeleteMusic("script\WalkerScript\sound\Tenshi.mp3");
SetLife( 1 );
DeleteEnemyShotToItem( ALL );
CollectItems;
SetDamageRate( 0, 0 );
SetX( GetCenterX );
SetY( -128 );
CreateEventFromScript( "Talk" );
Behavior();



      }
@MainLoop{
if( !OnEvent() && bgm ){ AddLife( -1 ); }
yield;
count++;
}
@DrawLoop{


BgScrollEx2(TenshiBG3, 0, -0.01, 2,255);
BgScrollEx(TenshiBG4, 0, -10, 1, 25);
                  LoadGraphic(ImgBoss);
                  SetTexture(ImgBoss);
SetGraphicRect( 0, 0, 48, 66 );
DrawGraphic(GetX, GetY);

}
}
script_event Talk{
let imgplayerdeh=GetCurrentScriptDirectory~"img\Marisa8.png";
let imgplayermad=GetCurrentScriptDirectory~"img\Marisa5.png";
let imgplayersad=GetCurrentScriptDirectory~"img\Marisa6.png";
let imgplayerblah=GetCurrentScriptDirectory~"img\Marisa7.png";
let imgenemyglad=GetCurrentScriptDirectory~"img\Tensi.png";
let imgenemymad=GetCurrentScriptDirectory~"img\Tenshi.png";
let imgenemyblah=GetCurrentScriptDirectory~"img\TenshiCutIn.png";
@Initialize{
LoadGraphic(imgplayerdeh);
LoadGraphic(imgplayermad);
LoadGraphic(imgplayersad);
LoadGraphic(imgplayerblah);
LoadGraphic(imgenemyglad);
LoadGraphic(imgenemymad);
LoadGraphic(imgenemyblah);
}

@MainLoop{
SetChar(LEFT,imgplayersad);SetGraphicRect(LEFT,0,0,167,439);
MoveChar(LEFT,FRONT);
TextOut( "\c[GREEN]Finally... it's over." );
SetChar(LEFT,imgplayerblah);SetGraphicRect(LEFT,0,0,167,439);
TextOut( "\c[GREEN]I should go back home, it's freezing here." );
MoveChar(LEFT,BACK);
SetStep( 1 );
TextOut( "\c[BLUE]Yes, it's very cold but..." );
SetStep( 2 );
Wait( 60 );
SetStep( 3 );
SetChar(RIGHT,imgenemyglad);SetGraphicRect(RIGHT,0,0,240,393);
MoveChar(RIGHT,FRONT);
TextOut( "\c[BLUE]You're very close to the Heaven..." );
                MoveChar(RIGHT,BACK);
                SetChar(LEFT,imgplayermad);SetGraphicRect(LEFT,0,0,167,439);
MoveChar(LEFT,FRONT);
TextOut( "\c[GREEN]Oh no... You are still alive?!" );
MoveChar(LEFT,BACK);
SetChar(RIGHT,imgenemyblah);SetGraphicRect(RIGHT,0,0,240,393);
MoveChar(RIGHT,FRONT);
TextOut( "\c[BLUE]Yes." );
                MoveChar(RIGHT,BACK);
                        SetStep( 4 );
SetChar(LEFT,imgplayerblah);SetGraphicRect(LEFT,0,0,167,439);
MoveChar(LEFT,FRONT)
TextOut( "\c[GREEN]What are you trying to do!?");
SetChar(LEFT,imgplayerdeh);SetGraphicRect(LEFT,0,0,167,439);
TextOut( "\c[GREEN]Please stop! I'm tired!");
MoveChar(LEFT,BACK);
SetChar(RIGHT,imgenemyblah);SetGraphicRect(RIGHT,0,0,240,393);
MoveChar(RIGHT,FRONT);
TextOut( "\c[BLUE]So you want a rest?.\nThen you will have a rest..." );
SetChar(RIGHT,imgenemymad);SetGraphicRect(RIGHT,0,0,240,393);
TextOut( "\c[BLUE]Forever... in the Heaven!!!" );
                        SetStep( 5 );
}
@Finalize{
DeleteGraphic(imgplayerdeh);
DeleteGraphic(imgplayermad);
DeleteGraphic(imgplayersad);
DeleteGraphic(imgplayerblah);
DeleteGraphic(imgenemyglad);
DeleteGraphic(imgenemymad);
DeleteGraphic(imgenemyblah);
}
}

Sorry Walker,I just want to fool around with scripts..(and used Stuffman's dialogues for bases) D8

Johnny Walker

  • Perdition Crisis~
Re: Danmakufu Q&A/Problem Thread
« Reply #371 on: July 26, 2009, 06:10:44 AM »
However,this script keeps crashing on me because I was editing the dialogue.

<heregoesacode>

Sorry Walker,I just want to fool around with scripts..(and used Stuffman's dialogues for bases) D8
Don't worry. Feel free to use anything I've created (or modified 8D). They're just for fun.

Aaand... You forgot a ";" in the middle line of:
Code: [Select]
SetChar(LEFT,imgplayerblah);SetGraphicRect(LEFT,0,0,167,439);
MoveChar(LEFT,FRONT) <---
TextOut( "\c[GREEN]What are you trying to do!?");

Fixed:

Code: [Select]
#ScriptVersion[2]
script_enemy_main{
#include_function "script\WalkerScript\Tenshi\BgControl.txt";
let ImgBoss = "script\WalkerScript\img\TenshiBoss.png";
let count = 0;
let bgm = false;
task Behavior(){
yield;
while( GetEventStep() != 1 ){ yield; }
PlaySE("script\WalkerScript\sound\charge2.mp3");
SetColor(250,50,50);
Concentration01(120);
SetColor(255,255,255);
SetMovePosition03( GetCenterX(), GetCenterY() - 100, 20, 5 );
SetEnemyMarker( true );
while( GetEventStep() != 2 ){ yield; }
while( GetEventStep() != 3 ){ yield; }
bgm = true;
PlayMusic("script\WalkerScript\sound\Hisouten.mp3");


}
@Initialize{
DeleteMusic("script\WalkerScript\sound\Tenshi.mp3");
SetLife( 1 );
DeleteEnemyShotToItem( ALL );
CollectItems;
SetDamageRate( 0, 0 );
SetX( GetCenterX );
SetY( -128 );
CreateEventFromScript( "Talk" );
Behavior();



      }
@MainLoop{
if( !OnEvent() && bgm ){ AddLife( -1 ); }
yield;
count++;
}
@DrawLoop{


BgScrollEx2(TenshiBG3, 0, -0.01, 2,255);
BgScrollEx(TenshiBG4, 0, -10, 1, 25);
                  LoadGraphic(ImgBoss);
                  SetTexture(ImgBoss);
SetGraphicRect( 0, 0, 48, 66 );
DrawGraphic(GetX, GetY);

}
}
script_event Talk{
let imgplayerdeh=GetCurrentScriptDirectory~"img\Marisa8.png";
let imgplayermad=GetCurrentScriptDirectory~"img\Marisa5.png";
let imgplayersad=GetCurrentScriptDirectory~"img\Marisa6.png";
let imgplayerblah=GetCurrentScriptDirectory~"img\Marisa7.png";
let imgenemyglad=GetCurrentScriptDirectory~"img\Tensi.png";
let imgenemymad=GetCurrentScriptDirectory~"img\Tenshi.png";
let imgenemyblah=GetCurrentScriptDirectory~"img\TenshiCutIn.png";
@Initialize{
LoadGraphic(imgplayerdeh);
LoadGraphic(imgplayermad);
LoadGraphic(imgplayersad);
LoadGraphic(imgplayerblah);
LoadGraphic(imgenemyglad);
LoadGraphic(imgenemymad);
LoadGraphic(imgenemyblah);
}

@MainLoop{
SetChar(LEFT,imgplayersad);SetGraphicRect(LEFT,0,0,167,439);
MoveChar(LEFT,FRONT);
TextOut( "\c[GREEN]Finally... it's over." );
SetChar(LEFT,imgplayerblah);SetGraphicRect(LEFT,0,0,167,439);
TextOut( "\c[GREEN]I should go back home, it's freezing here." );
MoveChar(LEFT,BACK);
SetStep( 1 );
TextOut( "\c[BLUE]Yes, it's very cold but..." );
SetStep( 2 );
Wait( 60 );
SetStep( 3 );
SetChar(RIGHT,imgenemyglad);SetGraphicRect(RIGHT,0,0,240,393);
MoveChar(RIGHT,FRONT);
TextOut( "\c[BLUE]You're very close to the Heaven..." );
                MoveChar(RIGHT,BACK);
                SetChar(LEFT,imgplayermad);SetGraphicRect(LEFT,0,0,167,439);
MoveChar(LEFT,FRONT);
TextOut( "\c[GREEN]Oh no... You are still alive?!" );
MoveChar(LEFT,BACK);
SetChar(RIGHT,imgenemyblah);SetGraphicRect(RIGHT,0,0,240,393);
MoveChar(RIGHT,FRONT);
TextOut( "\c[BLUE]Yes." );
                MoveChar(RIGHT,BACK);
                        SetStep( 4 );
SetChar(LEFT,imgplayerblah);SetGraphicRect(LEFT,0,0,167,439);
MoveChar(LEFT,FRONT);
TextOut( "\c[GREEN]What are you trying to do!?");
SetChar(LEFT,imgplayerdeh);SetGraphicRect(LEFT,0,0,167,439);
TextOut( "\c[GREEN]Please stop! I'm tired!");
MoveChar(LEFT,BACK);
SetChar(RIGHT,imgenemyblah);SetGraphicRect(RIGHT,0,0,240,393);
MoveChar(RIGHT,FRONT);
TextOut( "\c[BLUE]So you want a rest?.\nThen you will have a rest..." );
SetChar(RIGHT,imgenemymad);SetGraphicRect(RIGHT,0,0,240,393);
TextOut( "\c[BLUE]Forever... in the Heaven!!!" );
                        SetStep( 5 );
}
@Finalize{
DeleteGraphic(imgplayerdeh);
DeleteGraphic(imgplayermad);
DeleteGraphic(imgplayersad);
DeleteGraphic(imgplayerblah);
DeleteGraphic(imgenemyglad);
DeleteGraphic(imgenemymad);
DeleteGraphic(imgenemyblah);
}
}


KomeijiKoishi

Re: Danmakufu Q&A/Problem Thread
« Reply #372 on: July 26, 2009, 11:33:10 AM »
Question:
You know that rand(x, y) always takes any number between x and y. But is there a function which only allows exactly TWO things to choose?
For example: A bullet should either curve to the left or the right, but with the same curve variable.

Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #373 on: July 26, 2009, 12:42:53 PM »
yes, you can use rand_int(A,B) to choose integers between A and B, inclusively.

Use this algorithm:

-1^(rand_int(0,1))*[curve angle]
Old/Forgotten member.

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

Primula

  • EARL TYPE 222
Re: Danmakufu Q&A/Problem Thread
« Reply #374 on: July 26, 2009, 12:44:13 PM »
Ahh I see~Thank you Walker!

Edit:Oh wait I'm solving my other problem sorry~
« Last Edit: July 26, 2009, 06:31:16 PM by Vappie »

8lue Wizard

  • Cobalt Magician
  • (Apparently)
Re: Danmakufu Q&A/Problem Thread
« Reply #375 on: July 26, 2009, 09:20:41 PM »
So, I'm trying to create a custom bullet according to the template on TouhouWiki, but it's not working. I don't get any error messages, and the resultant bullets have hit detection (which doesn't happen if I just stick a random unused identifier in), but no graphic.

>.>
<.<

OUENDAN!!!

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #376 on: July 27, 2009, 11:29:22 AM »
Question:

Is it possible in Danmakufu to detect which player has been chosen at the character select screen? So I can call this inside the stage script to perform different dialogues. Like if Reimu --> Dialogue1  if Marisa --> Dialogue 2

Awnser to:
So, I'm trying to create a custom bullet according to the template on TouhouWiki, but it's not working. I don't get any error messages, and the resultant bullets have hit detection (which doesn't happen if I just stick a random unused identifier in), but no graphic.

>.>
<.<

OUENDAN!!!
Having no graphics can cause alot of things afaik:
- did you loaded your custom bullets with example: let <var>   = GetCurrentScriptDirectory"<pathtocustombullets.txt"; and LoadUserShotData(<var>)
- Did you make sure the GraphicRect is set proper?


Henry

  • The observer
  • Exploring to the new world of Danmaku
Re: Danmakufu Q&A/Problem Thread
« Reply #377 on: July 27, 2009, 01:41:39 PM »
Question:

Is it possible in Danmakufu to detect which player has been chosen at the character select screen? So I can call this inside the stage script to perform different dialogues. Like if Reimu --> Dialogue1  if Marisa --> Dialogue 2

Yes, of course you can :)

use GetPlayerType() as in:
Code: [Select]
if(GetPlayerType==REIMU_A||GetPlayerType==REIMU_B){
   }else{
}

My question: Can I use addshot for obj bullets?

Code: [Select]
#TouhouDanmakufu
#Title[Metal Sign "Metal Fatigue High Level"]
#Text[Remake of metal fatigue in stage 4 of EoSD with reflecting bullets]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
    let frame = -120;
    let bg = GetCurrentScriptDirectory~"images\Bossbggrey.jpg";
    let random;
    let i;
    let j;
    #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, "Metal Sign "\""Arrows of Venus"\", "", 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==0&&frame>0) {
           random=rand(0,360);
           ascent(i in 0..8){
      CreateShotA(0, GetX, GetY, 0);
      SetShotDataA(0, 0, 2, GetAngleToPlayer+i*360/8, 0, 0, 2, 27);
      SetShotDataA(0, 30, 2, GetAngleToPlayer+i*360/8, 0, -0.1, 0, 27);
      SetShotKillTime(0, 71);
              ascent(j in 0..8){
                 Bullet(2, random+i*360/8+GetAngleToPlayer, 0);
              }
      FireShot(0);
           }
        }
        frame++;
        yield;
    }

    @DrawLoop {
       bossSC;
    }
    @BackGround{
       backgroundSC;
    }
    task Bullet(speed,angle,delay){
       let obj=Obj_Create(OBJ_SHOT);
       Obj_SetPosition(obj, GetX+cos(GetAngleToPlayer+i*360/8)*80, GetY+cos(GetAngleToPlayer+i*360/8)*80);
       Obj_SetAngle(obj, angle);
       Obj_SetSpeed(obj, speed);
       ObjShot_SetGraphic(obj, 27);
       ObjShot_SetDelay  (obj, delay);
       while(Obj_BeDeleted(obj)==false){
          ObjShot_SetBombResist (obj, true);
          if(Obj_GetX(obj)<GetClipMinX||Obj_GetX(obj)>GetClipMaxX){
             Obj_SetAngle(obj, 180-Obj_GetAngle(obj));
             if(Obj_GetX(obj)<GetClipMinX){
                Obj_SetX(obj, Obj_GetX(obj)+0.1);
             }else{
                Obj_SetX(obj, Obj_GetX(obj)-0.1);
             }
             ObjShot_SetGraphic(obj, 27);
          }
          if(Obj_GetY(obj)<GetClipMinY){
             Obj_SetAngle(obj, -Obj_GetAngle(obj));
             if(Obj_GetY(obj)<GetClipMinY){
                Obj_SetY(obj, Obj_GetY(obj)+0.1);
             }
             ObjShot_SetGraphic(obj, 27);
          }
  AddShot(70,0,obj,0);
          yield;
       }
    }
    @Finalize {
        DeleteGraphic(ImgBoss);
    }
}
Old/Forgotten member.

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

Zengar Zombolt

  • Space-Time Tuning Circle - Wd/Fr
  • Green-Red Divine Clock
Re: Danmakufu Q&A/Problem Thread
« Reply #378 on: July 27, 2009, 01:45:41 PM »
Code: [Select]
if(GetPlayerType==REIMU_A||GetPlayerType==REIMU_B){
   }else{
}
}
Afaik you can make it shorter by
Code: [Select]
if(GetPlayerType==REIMU){
code goes here}else{
moar code goes here}
Remember that you can refer to both REIMU_A and REIMU_B as REIMU.
« Last Edit: July 27, 2009, 03:08:18 PM by The sword that cleaves evil »

8lue Wizard

  • Cobalt Magician
  • (Apparently)
Re: Danmakufu Q&A/Problem Thread
« Reply #379 on: July 27, 2009, 02:59:28 PM »
Ah~ Never mind. I did a spot check for typos and it works now. I probably had a letter somewhere with the wrong capitalization.

...too bad it look so ugly. *goes to fix*


Also, how do you view replays?
« Last Edit: July 27, 2009, 03:33:18 PM by Blue_Wolf »

Thaws

  • _m廿廿m_
Re: Danmakufu Q&A/Problem Thread
« Reply #380 on: July 27, 2009, 03:26:40 PM »
My question: Can I use addshot for obj bullets?

I'm not sure if you can or not, but why would you need to?
You can get the X and Y coordinate of the Object Bullet with Obj_GetX and Obj_GetY respectively.
Then you can just shoot bullets or do whatever with those coordinates.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #381 on: July 27, 2009, 05:16:17 PM »
@Henry & The Sword that cleaves evil,

Thank you both. Now I can further implement Reimu as playable character in my game.

Zengar Zombolt

  • Space-Time Tuning Circle - Wd/Fr
  • Green-Red Divine Clock
Re: Danmakufu Q&A/Problem Thread
« Reply #382 on: July 27, 2009, 05:23:57 PM »
Y' welcome.
Now I have a doubt: When calling shot IDs, the ID name is a string, or an integer?

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #383 on: July 27, 2009, 05:46:43 PM »
Integers.

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

CK Crash

  • boozer
Re: Danmakufu Q&A/Problem Thread
« Reply #384 on: July 27, 2009, 05:49:29 PM »
However, you can set a variable to that integer, if you don't want to memorize as much. This is how the shot replace script works, since all the shot names like RED01 are actually just variables that equal the matching shot ID.

Zengar Zombolt

  • Space-Time Tuning Circle - Wd/Fr
  • Green-Red Divine Clock
Re: Danmakufu Q&A/Problem Thread
« Reply #385 on: July 27, 2009, 05:51:07 PM »
Integers.
However, you can set a variable to that integer, if you don't want to memorize as much. This is how the shot replace script works, since all the shot names like RED01 are actually just variables that equal the matching shot ID.
Fuck yes, just what I wanted.
Thanks, guys.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #386 on: July 28, 2009, 12:38:32 AM »
aghgghghh i need help
I did a bunch of editing to try and have both the player bullet variables and target variable in the same task so that they could reference each other. It's not working because the collision detection function is done while the bullet isn't deleted. The thing is that because they both work on a different BeDeleted segment.

Like what the fuck do I have to smash the entire target code into the option bullet code? I'm just posting the entire goddamn thing.

Code: [Select]
#TouhouDanmakufu[Player]
#ScriptVersion[2]
#Menu[Reimu D2]
#Text[Hakurei Reimu type D
            ?uConcentrated attack type?v

Shot:   ?uAbsolution Needle?v

Bomb: ?uWild Annihilation Dance?v]
#Image[.\sl_pl00.png]
#ReplayName[ReimuD2]

script_player_main{

#include_function ".\common.txt"
let c = GetCurrentScriptDirectory();
let bNextShot = false;
let optiona = 0;
let focusalpha = 0;
let focussize = 1;
let drawcount = 0;
let shotcount = -1;
let rad = 45;

task DrawHitbox(){
let hitbox = Obj_Create(OBJ_SHOT);
Obj_SetSpeed(hitbox,0);
Obj_SetCollisionToPlayer(hitbox, false);
ObjShot_SetBombResist(hitbox, true);
ObjShot_SetGraphic(hitbox, 100);
while(!Obj_BeDeleted(hitbox)){

if(IsPressRight()==true){
if(IsPressDown()==true){ Obj_SetPosition(hitbox, GetPlayerX+1, GetPlayerY+1); //Right+Down
}else if(IsPressUp()==true){ Obj_SetPosition(hitbox, GetPlayerX+1, GetPlayerY-2); //Right+Up
}else{ Obj_SetPosition(hitbox, GetPlayerX+1, GetPlayerY);} //Right

}else if(IsPressLeft()==true){
if(IsPressDown()==true){ Obj_SetPosition(hitbox, GetPlayerX-2, GetPlayerY+1); //Left+Down
}else if(IsPressUp()==true){ Obj_SetPosition(hitbox, GetPlayerX-2, GetPlayerY-2); //Left+Up
}else{ Obj_SetPosition(hitbox, GetPlayerX-2, GetPlayerY);} //Left

}else if(IsPressDown()==true){ Obj_SetPosition(hitbox, GetPlayerX, GetPlayerY+1); //Down

}else if(IsPressUp()==true){ Obj_SetPosition(hitbox, GetPlayerX, GetPlayerY-2); //Up

}else{ Obj_SetPosition(hitbox, GetPlayerX, GetPlayerY); //Neutral
}
Obj_SetAngle(hitbox, optiona);
Obj_SetAlpha(hitbox, focusalpha);
yield;
}
}

task OptionScript{
if(IsPressShot()==true && shotcount==-1){shotcount=0;}
if(IsPressSlow()==true){rad = 20;}else{rad = 45;}
if(shotcount%5 == 0){
PlaySE(c~"se_plst00.wav");
let r = rand(-5,5);
ShotScript(GetPlayerX+8, GetPlayerY-10, GetPlayerX+(rad*cos(optiona)), GetPlayerY+(rad*sin(optiona)), r, true);
r = rand(-5,5);
ShotScript(GetPlayerX-8, GetPlayerY-10, GetPlayerX+(rad*cos(optiona)), GetPlayerY-(rad*sin(optiona)), r, true);
r = rand(-5,5);
ShotScript(0, 0, GetPlayerX-(rad*cos(optiona)), GetPlayerY+(rad*sin(optiona)), r, false);
r = rand(-5,5);
ShotScript(0, 0, GetPlayerX-(rad*cos(optiona)), GetPlayerY-(rad*sin(optiona)), r, false);
}
if(shotcount>=0){shotcount++;}
if(shotcount>=5){shotcount=-1;}
yield;
}

task ShotScript(x1,y1,x2,y2,r,m){
//TARGET
let f = 0;
ascent(enemy in EnumEnemyBegin..EnumEnemyEnd){
let enemyID = EnumEnemyGetID(enemy);
let target = Obj_Create(OBJ_LASER);
Obj_SetX(target, GetEnemyInfo(enemyID, ENEMY_X));
Obj_SetY(target, GetEnemyInfo(enemyID, ENEMY_Y));
Obj_SetSpeed(target, 0);
Obj_SetCollisionToPlayer(target, false);
ObjShot_SetBombResist(target, true);
ObjShot_SetGraphic(target, 101);
ObjLaser_SetLength(target, 100);
ObjLaser_SetWidth(target, 500);
ObjLaser_SetSource(target, false);
while(!Obj_BeDeleted(target)){
Obj_SetX(target, GetEnemyInfo(enemyID, ENEMY_X));
Obj_SetY(target, GetEnemyInfo(enemyID, ENEMY_Y));
f++;
if(f>2){Obj_Delete(target);}
yield;
}
}
//MAIN BULLET
if(m==true){
let g = 103;
let i = -2;
let a = 115;
let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj, x1, y1);
Obj_SetAngle(obj, 270);
ObjShot_SetGraphic(obj, g);
Obj_SetAlpha(obj, a);
Obj_SetSpeed(obj, 10);
ObjShot_SetBombResist(obj, true);
ObjShot_SetDamage(obj, 1);
ObjShot_SetPenetration(obj, 10);
Obj_SetCollisionToObject(obj, true);
while(!Obj_BeDeleted(obj)){
/*if(Collision_Obj_Obj(obj,obj)==true){
i = 0;
}else{
g = 103;
}*/
if(i>=0){
ObjShot_SetDamage(obj, 0);
i++;
a-=3;
}
if(i>=0 && i<6){
g = 104;
Obj_SetSpeed(obj, 1.5);
}else if(i>=6 && i<12){
a = 35;
g = 105;
Obj_SetSpeed(obj, 1.5);
}else if(i>16){
Obj_Delete(obj);
}
ObjShot_SetGraphic(obj, g);
Obj_SetAlpha(obj, a);
yield;
}
}
//OPTION BULLET
let g = 101;
let i = -2;
let a = 170;
let opt = Obj_Create(OBJ_SHOT);
Obj_SetPosition(opt, x2, y2);
Obj_SetAngle(opt, 270);
ObjShot_SetGraphic(opt, g);
Obj_SetAlpha(opt, a);
Obj_SetSpeed(opt, 10);
ObjShot_SetBombResist(opt, true);
ObjShot_SetDamage(opt, 0.7);
ObjShot_SetPenetration(opt, 10);
while(!Obj_BeDeleted(opt)){
//if(Obj_IsIntersected(opt)==true){
if(Collision_Obj_Obj(opt,target)==true){
i = 0;
a = 220;
Obj_SetAngle(opt, 270+r);
}else{
g = 101;
}
if(i>=0){
ObjShot_SetDamage(opt, 0);
Obj_SetSpeed(opt, 1.5);
i++;
g = 102;
a-=2;
}
if(i>16){
Obj_Delete(opt);
}
ObjShot_SetGraphic(opt, g);
Obj_SetAlpha(opt, a);
yield;
}
}

@Initialize{
LoadGraphic(c~"pl00.png");
LoadPlayerShotData(c~"plshot00.txt");
                                          SetPlayerLifeImage(c~"pl00.png", 213, 293, 247, 325);
SetRibirthFrame(15);
SetSpeed(4, 1.5);
DrawHitbox;
}

@MainLoop{
drawcount++;
SetIntersectionCircle(GetPlayerX, GetPlayerY, 1);
optiona+=3; if(optiona>=360){optiona = 0;}
OptionScript;
yield;
}
@Missed{}
@SpellCard{
SetSpeed(4, 1.5);
UseSpellCard("WildAnnihilationDance", 0);
}
@DrawLoop{
SetTexture(c~"pl00.png");
SetAlpha(255);
SetGraphicScale(1,1);

//Draw player
SetGraphicAngle(0,0,0);
if(IsPressRight()==true){
SetGraphicRect(228, 102, 260, 146);
}else if(IsPressLeft()==true){
SetGraphicRect(230, 53, 261, 97);
}else{
if(drawcount<10){SetGraphicRect(5, 3, 38, 51);}
if(drawcount>=10 && drawcount<20){SetGraphicRect(37, 3, 70, 51);}
if(drawcount>=20 && drawcount<30){SetGraphicRect(69, 3, 102, 51);}
if(drawcount>=30 && drawcount<40){SetGraphicRect(101, 3, 134, 51);}
if(drawcount>=40 && drawcount<50){SetGraphicRect(134, 3, 165, 51);}
if(drawcount>=50 && drawcount<60){SetGraphicRect(165, 3, 198, 51);}
if(drawcount>=60 && drawcount<70){SetGraphicRect(198, 3, 229, 51);}
if(drawcount>=70 && drawcount<80){SetGraphicRect(228, 3, 262, 51);}
}
DrawGraphic(GetPlayerX, GetPlayerY);

//Draw options
SetGraphicRect(70, 148, 84, 162);
SetGraphicAngle(0,0,optiona*-1);

DrawGraphic(GetPlayerX+(rad*cos(optiona)), GetPlayerY+(rad*sin(optiona)));
DrawGraphic(GetPlayerX+(rad*cos(optiona)), GetPlayerY-(rad*sin(optiona)));
DrawGraphic(GetPlayerX-(rad*cos(optiona)), GetPlayerY+(rad*sin(optiona)));
DrawGraphic(GetPlayerX-(rad*cos(optiona)), GetPlayerY-(rad*sin(optiona)));

//Draw focus circle
if(IsPressSlow==true){
focusalpha+=30;
if(focusalpha>250){focusalpha=250;}
}else{
focusalpha-=30;
if(focusalpha<0){focusalpha=0;}
}
if(focusalpha>210){
focussize-=0.04;
if(focussize<=1){focussize=1;}
}else{
focussize = (focusalpha/240)+0.4;
}
SetAlpha(focusalpha);
SetGraphicRect(213, 151, 285, 213);
SetGraphicScale(focussize, focussize);
SetGraphicAngle(0,0,0);
DrawGraphic(GetPlayerX, GetPlayerY);
/*SetGraphicScale(1,1);
SetGraphicAngle(0,0,optiona);
DrawGraphic(GetPlayerX, GetPlayerY);*/

drawcount++;
if(drawcount>=80){drawcount=0;}
}

@Finalize{}
}

script_spell WildAnnihilationDance{
let frame = 0;
@Initialize{
SetPlayerInvincibility(120);
DeleteEnemyShotToItem(SHOT);
CollectItems;
}
@MainLoop{
frame++;
if(frame>120){End;}
yield;
}
@Finalize{
}
}

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 #387 on: July 28, 2009, 10:58:44 AM »
@Henry & The Sword that cleaves evil,

Thank you both. Now I can further implement Reimu as playable character in my game.

Also, as a reminder: If you want to use
Code: [Select]
if(GetPlayerType==REIMU){
   spell card 1
}else{
   spell card 2
}
to make plural script or stage like Patchouli's or Satori's (different spell card in respect to different players), you will end up getting a life bar (for boss) divided into 2 but only 1 spell is playable.

I used another spell card, including 2 spell card versions, separated with an if...else... control statement.
Code: [Select]
if(GetPlayerType==REIMU_A||GetPlayerType==REIMU_B){
   }else{
}
}
Afaik you can make it shorter by
Code: [Select]
if(GetPlayerType==REIMU){
code goes here}else{
moar code goes here}
Remember that you can refer to both REIMU_A and REIMU_B as REIMU.
However, I tried that, it doesn't work for me. :(

Sorry, Drake. I don't know about player scripts and I cannot answer your question :(
« Last Edit: July 28, 2009, 02:59:54 PM by Henry »
Old/Forgotten member.

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

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #388 on: July 28, 2009, 03:45:49 PM »
I'm having a problem. I'm trying to make some enemy familiars loop around the boss in a bit of an diagonal oval shape, but I can't seem to make it do that. My current method for familiars involves using things like this:

Code: [Select]
famix1 = GetX+famidist*cos(famiang1);
famiy1 = GetY+famidist*sin(famiang1);
famix2 = GetX+famidist*cos(famiang2);
famiy2 = GetY+famidist*sin(famiang2);
famiang1 += 2;
famiang2 -= 2;

Stuff like that. Well, for familiars you can't hit, that is. (I don't see why they should all be killable.) I just want to use this code to make it loop around the boss in an oval shape, that's all. (Also, I'd rather not use any other method. Doesn't make sense to do it a more complicated way. XD)
« Last Edit: July 28, 2009, 04:02:07 PM by pikaguy900 »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread
« Reply #389 on: July 28, 2009, 03:48:46 PM »
@Henry & The Sword that cleaves evil,

Thank you both. Now I can further implement Reimu as playable character in my game.

Also, as a reminder: If you want to use
Code: [Select]
if(GetPlayerType==REIMU){
   spell card 1
}else{
   spell card 2
}
to make plural script or stage like Patchouli's or Satori's (different spell card in respect to different players), you will end up getting a life bar (for boss) divided into 2 but only 1 spell is playable.

I used another spell card, including 2 spell card versions, separated with an if...else... control statement.

I only used it for my Dialogue script and it works perfect. I am not planning in making spellcards like Satori or Patchouli. Reimu and Marisa share the same enemy spellcards.