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

Re: Danmakufu Q&A/Problem Thread
« Reply #30 on: May 23, 2009, 07:57:24 PM »
new question

what are the names of the get spellcard sound and the spellcard start sound? I need to know so I can replace them with
something else.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #31 on: May 23, 2009, 08:12:37 PM »
Sounds that you can change by filename are

sePlayerShot01.wav   
seGraze.wav   
sePlayerCollision.wav (?)
sePlayerSpellCard.wav (?)
se1UP.wav   
seScore.wav   
seBomb_ReimuA.wav   
seExplode01.wav   
seBomb_ReimuB.wav
seUseSpellCard.wav (?)
seGetSpellCardBonus.wav (?)
seEnemyExplode01.wav   
seSuperNaturalBorder1.wav   
seSuperNaturalBorder2.wav

and

STG_Player01.png
STG_Player11.png
CutIn_PlayerChar01.png
CutIn_PlayerChar11.png
Select_Player01.png
Select_Player11.png
STG_Frame.png

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

Re: Danmakufu Q&A/Problem Thread
« Reply #32 on: May 23, 2009, 08:20:24 PM »
Okay, thanks

Now I have two more questions. How do you
make a title screen, and how do you make something carry over
from game sessions? (Like say you unlocked Extra and quit the game, when you started
it up again Extra would still be there)
« Last Edit: May 23, 2009, 08:25:58 PM by Darkblizer »

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #33 on: May 23, 2009, 10:35:57 PM »
God don't even start that what are you thinking.


Uh, am I able to define a bullet's collision detection without making a bullet script?

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

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread
« Reply #34 on: May 23, 2009, 10:41:22 PM »
How about creating an object bullet and then using Obj_SetCollisionToPlayer and Obj_SetCollisionToObject?
Old Danmakufu stuff can be found here!

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

Re: Danmakufu Q&A/Problem Thread
« Reply #35 on: May 23, 2009, 11:06:56 PM »
God don't even start that what are you thinking.


Uh, am I able to define a bullet's collision detection without making a bullet script?


If you are looking for normal bullets, sorry, I don't believe there is a command. Not that I remember having seen, anyway.

Obj-SetCollisionto(Player/Object) just does it for object bullets.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #36 on: May 23, 2009, 11:07:21 PM »
Oh, sorry, I meant define the size of the hitbox.

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

Re: Danmakufu Q&A/Problem Thread
« Reply #37 on: May 23, 2009, 11:13:00 PM »
Not for the default bullets. The hitbox is defined by how large the image is, and is scaled appropriately. So if you want the hitbox to fill the image, increase the black area surrounding the image so that the hitbox is larger. If you want it smaller, cut off as much black outline as possible. So no, you aren't able to define a hitbox unless you've created your own bullet script.

That said, you can dick around with the shot replace script until you get what your looking for. Good luck, in any case.

Now I have two more questions. How do you
make a title screen, and how do you make something carry over
from game sessions? (Like say you unlocked Extra and quit the game, when you started
it up again Extra would still be there)

[walloftext]
For the title screen, you'll have to change STG_Frame.png to be the outside of your game window as it would be if it was on the title screen. Then you draw an image overtop of everything in the game window that meshes with the image you've defined for STG_Frame.png, then draw text that changes whenever you change KEYSTATE (up and down, then moves onto new directives when you hit the shot button). Make sure everything is drawn above the player character, or have the player character forced off the screen with SetPlayerX(1000) or something. Depending on which combination of buttons the player clicks, you then run scripts accordingly. So you could have a certain variable set whenever "Start Game" is highlighted, so when you press the shot button is will start loading your game script. It's an absolutely INTENSE amount of coding for such a useless effect, seeing as it drops most people's FPS greatly (Fantom Fantasm, check the spellcard history screen. What's your FPS? Mine is like 42 and I've got a dual core with 4GB of RAM). Now that doesn't really matter, but seriously, why even bother with a title screen? It's nice, but it takes years to code. Not worth it at all, don't try it.
[/walloftext]


As for your second question, I've no idea. As far as I know, SetCommonData is only active for the duration of the game script, so I really have no idea how people accomplished this.
« Last Edit: May 23, 2009, 11:20:38 PM by Naut »

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #38 on: May 24, 2009, 02:11:32 AM »
Quote
As for your second question, I've no idea. As far as I know, SetCommonData is only active for the duration of the game script, so I really have no idea how people accomplished this.

There's a SaveCommonData function that will save all the common data you have set for a given script.

Re: Danmakufu Q&A/Problem Thread
« Reply #39 on: May 24, 2009, 02:13:46 AM »
....Well there you go.

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #40 on: May 24, 2009, 08:16:30 PM »
Oddly I'm having trouble with a rather simple issue. What's a good way to fire bullets in a smooth oval?

I figured I would break it into four 90 degree segments with steadily increasing speed towards the sides, but a linear formula creates a sort of dent in it, like so:



Code: [Select]
PlaySE(GetCurrentScriptDirectory~"SFX\BulletWave.wav");
i=4;shotshift=1;
CreateShot01(GetX,GetY,1.5,GetAngleToPlayer,YELLOW21,0);
CreateShot01(GetX,GetY,1.5,GetAngleToPlayer-180,YELLOW21,0);
while(i<90){
  CreateShot01(GetX,GetY,1.5+(shotshift/10),GetAngleToPlayer-i,YELLOW21,0);
  CreateShot01(GetX,GetY,1.5+(shotshift/10),GetAngleToPlayer+i,YELLOW21,0);
  CreateShot01(GetX,GetY,1.5+(shotshift/10),180+GetAngleToPlayer-i,YELLOW21,0);
  CreateShot01(GetX,GetY,1.5+(shotshift/10),180+GetAngleToPlayer+i,YELLOW21,0);
  i+=shotshift;
  shotshift++;
}

Any ideas for a formula? (Also, if you're wondering, the bullets are intended to be more compressed towards the short end of the oval)

Re: Danmakufu Q&A/Problem Thread
« Reply #41 on: May 24, 2009, 08:51:33 PM »
Have two different radial values for your circle formula.



This code will spawn bullets along the oval defined.

Hope I'm understanding your question correctly....

Re: Danmakufu Q&A/Problem Thread
« Reply #42 on: May 24, 2009, 09:15:44 PM »
Oddly I'm having trouble with a rather simple issue. What's a good way to fire bullets in a smooth oval?

I figured I would break it into four 90 degree segments with steadily increasing speed towards the sides, but a linear formula creates a sort of dent in it, like so:



Code: [Select]
PlaySE(GetCurrentScriptDirectory~"SFX\BulletWave.wav");
i=4;shotshift=1;
CreateShot01(GetX,GetY,1.5,GetAngleToPlayer,YELLOW21,0);
CreateShot01(GetX,GetY,1.5,GetAngleToPlayer-180,YELLOW21,0);
while(i<90){
  CreateShot01(GetX,GetY,1.5+(shotshift/10),GetAngleToPlayer-i,YELLOW21,0);
  CreateShot01(GetX,GetY,1.5+(shotshift/10),GetAngleToPlayer+i,YELLOW21,0);
  CreateShot01(GetX,GetY,1.5+(shotshift/10),180+GetAngleToPlayer-i,YELLOW21,0);
  CreateShot01(GetX,GetY,1.5+(shotshift/10),180+GetAngleToPlayer+i,YELLOW21,0);
  i+=shotshift;
  shotshift++;
}

Any ideas for a formula? (Also, if you're wondering, the bullets are intended to be more compressed towards the short end of the oval)

Well, you could always make a variation of the Rosarch in Danmaku script Naut posted somewhere in page 1..

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #43 on: May 24, 2009, 09:33:08 PM »
Pretty much what Naut said, anything with a circle you're going to have to use trig.

Squares, however...

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

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #44 on: May 24, 2009, 09:54:21 PM »
Well that's fine for spawning an oval, but I was looking for a way to spawn them all from the same origin point, i.e. the bullets make an oval due to flying at different speeds.

Quote
Squares, however...

I am intrigued by the idea of shot squares.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #45 on: May 24, 2009, 10:14:08 PM »
Use a CreateShot11, then. You have the bullets spawn from the same point, with x velocity based on cos(angle) and y velocity based on sin(angle). I'm too lazy to make an example, though.

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

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #46 on: May 24, 2009, 10:19:58 PM »
Oh right, I forgot about that function. Yeah I should be able to figure it out from there.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #47 on: May 24, 2009, 10:25:17 PM »
Oh crap I can probably make square patterns with that too

ALL HAIL ME

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

Re: Danmakufu Q&A/Problem Thread
« Reply #48 on: May 25, 2009, 01:56:38 AM »

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #49 on: May 25, 2009, 02:49:49 AM »
Frick yeah

Looks like it would suit Reimu well? Someone go make a Reimu boss :V

Re: Danmakufu Q&A/Problem Thread
« Reply #50 on: May 25, 2009, 03:31:10 AM »
I have got another question.

Is it possible to use AddShot with an object bullet? I am trying to recreate basically the first wave of bullets in Remilia's Red Magic attack (EoSD, last spell on Normal difficulty). I ran into a problem:

Code: [Select]
#TouhouDanmakufu
#Title[Red Magic]
#Text[Test script]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
let ImgBoss = "script\thC\IMAGE\CHAR\DOT\boss_yukari.png";

let count = 1140;
let a=0;





task Bounce(x, y, v, angle) {
     let obj=Obj_Create(OBJ_SHOT);

     Obj_SetPosition(obj, x, y);
     Obj_SetAngle(obj, angle);
     Obj_SetSpeed(obj, v);
     ObjShot_SetGraphic(obj, RED03);
     ObjShot_SetDelay(obj, 0);
     ObjShot_SetBombResist(obj, true);
     Obj_SetCollisionToObject(obj, true);

     while(Obj_BeDeleted(obj)==false){

           if(Obj_GetX(obj)<GetClipMinX) {
                Obj_SetAngle(obj, 180 - Obj_GetAngle(obj) ) ;
                Obj_SetX(obj, Obj_GetX(obj) + 0.1);
                PlaySE("script\Remilia Spell Cards\sfx\shot3.wav");
           }

           if(Obj_GetX(obj)>GetClipMaxX) {
                Obj_SetAngle(obj, 180 - Obj_GetAngle(obj) ) ;
                Obj_SetX(obj, Obj_GetX(obj) - 0.1);
                PlaySE("script\Remilia Spell Cards\sfx\shot3.wav");
           }

           if(Obj_GetY(obj)<GetClipMinY) {
                Obj_SetAngle(obj, 0 - Obj_GetAngle(obj) ) ;
                Obj_SetY(obj, Obj_GetY(obj) + 0.1);
                PlaySE("script\Remilia Spell Cards\sfx\shot3.wav");
           }

       yield;
}
}







@Initialize {
SetLife(2500);
SetTimer(60);
SetScore(10000000);

SetEnemyMarker(true);

SetMovePosition02(225, 120, 60);

LoadGraphic(ImgBoss);
SetTexture(ImgBoss);
SetGraphicRect(0, 0, 128, 128);
}

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

if(count == 1200) {
                PlaySE("script\Remilia Spell Cards\sfx\shot4.wav");

loop(8){
Bounce(GetX, GetY, 3, a);

ascent(i in 1..500){
    CreateShotA(1, 0, 0, 30);
    SetShotDataA(1, 100, 0, rand(0, 360), 0, 0.03, 2, RED01);
    AddShot(i*15+0, obj, 1, 0);
}

a += 360/8;
}

count=0
}

count++;
}

@DrawLoop {
DrawGraphic(GetX, GetY);
}

@Finalize {
DeleteGraphic(ImgBoss);
}
}


Code: [Select]
AddShot(i*15+0, obj, 1, 0);

This is the problem being read. It refers to obj as the source of the error.

Is there a such way to use AddShot with object bullets properly? Do I have to use another object bullet? I hope not.

Speaking of which, about the bullets in AddShot... Is it possible with CreateShotA bullets to change every single one of them that are created by other bullets at once with SetShotDataA, as in Remilia's spell cards, or does that have to do with more object bullets?
« Last Edit: May 25, 2009, 03:40:02 AM by Frazer »

Delpolo

Re: Danmakufu Q&A/Problem Thread
« Reply #51 on: May 25, 2009, 03:33:57 AM »
My first post at these forums, and I need to know whether it's possible to make a square hitbox for an Object Bullet. I want to make a Tetris-like survival spell, but then the player could just hide in the safe corners between bullets. (At first, I thought it was something like SetCollisionA, like SetCollisionB, but then I realised that the B stands for Bullet, and not 2nd.)

Also, is changing the bomb graphic for the bomb count possible, like it's possible for the life graphic?

Last thing, someone did tests on the REIMU, MARISA and Sakuya players to check their damage rate, but did they also test Rumia?

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #52 on: May 25, 2009, 04:01:56 AM »
Quote
My first post at these forums, and I need to know whether it's possible to make a square hitbox for an Object Bullet.

It's possible but you're going to need to do manual hit detection. That is, since it's already an object bullet, you can have it check if, say, GetPlayerX and GetPlayerY are within certain coordinates and kill the player if they are. All built-in hit hitbox functions are round.

Quote
Also, is changing the bomb graphic for the bomb count possible, like it's possible for the life graphic?

No, which I find a bit odd. It probably can be changed, or at least replaced with a different default graphic, but there's no documented function.

Quote
Last thing, someone did tests on the REIMU, MARISA and Sakuya players to check their damage rate, but did they also test Rumia?

Lemme pull the data up for you.
Speed (unfocused/focused): 4/1.6
Hitbox size: 1
Unfocused shot (close/near): ~144/165
Focused shot: ~238
Unfocused bomb (close/near): ~0/800
Focused bomb: ~2200

Her unfocused stuff is pretty crappy, but her focused stuff is pretty good.

Re: Danmakufu Q&A/Problem Thread
« Reply #53 on: May 25, 2009, 04:17:48 AM »
I have got another question.

Is it possible to use AddShot with an object bullet?

No. AddShot only works on CreateShotA's And CreateLaserABC's. To spawn a bullet from an object bullet, you just spawn any bullet on the object bullet's coordinates. like this:

CreateShot01(Obj_GetX(obj), Obj_GetY(obj), ...);

To have it keep spawning bullets every fifteen frames, as per your AddShot code (by the way, ascent i in 1..500? Holy shit that is a lot of bullets to process on one frame... Eight times!), you'll want to use the modulus function (%15) and just set a frame counter to increment in the object bullet's while(){} code tree.

Anyways, here's the fixed code. Things I changed:

  • Removed the ascent code when you spawn the Bounce bullets, and moved a similar code into task Bounce to spawn RED01's every fifteen frames.
  • Restructured the Bounce task's reflection code to more accurately reflect the bullets. Try to use this formula from now on, it will never fail.

Code: [Select]
#TouhouDanmakufu
#Title[Red Magic]
#Text[Test script]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
let ImgBoss = "script\thC\IMAGE\CHAR\DOT\boss_yukari.png";

let count = 1140;
let a=0;





task Bounce(x, y, v, angle) {
     let obj=Obj_Create(OBJ_SHOT);
     let frame = 0;
     Obj_SetPosition(obj, x, y);
     Obj_SetAngle(obj, angle);
     Obj_SetSpeed(obj, v);
     ObjShot_SetGraphic(obj, RED03);
     ObjShot_SetDelay(obj, 0);
     ObjShot_SetBombResist(obj, true);
     Obj_SetCollisionToObject(obj, true);

     while(Obj_BeDeleted(obj)==false){
frame++;
           if(Obj_GetX(obj)<GetClipMinX) {
        let position = GetClipMinX - Obj_GetX(obj);
                Obj_SetAngle(obj, 180 - Obj_GetAngle(obj) ) ;
                Obj_SetX(obj, Obj_GetX(obj) + position);
                PlaySE("script\Remilia Spell Cards\sfx\shot3.wav");
           }

           if(Obj_GetX(obj)>GetClipMaxX) {
        let position = GetClipMaxX - Obj_GetX(obj);
                Obj_SetAngle(obj, 180 - Obj_GetAngle(obj) ) ;
                Obj_SetX(obj, Obj_GetX(obj) + position);
                PlaySE("script\Remilia Spell Cards\sfx\shot3.wav");
           }

           if(Obj_GetY(obj)<GetClipMinY) {
        let position = GetClipMinY - Obj_GetY(obj);
                Obj_SetAngle(obj, 0 - Obj_GetAngle(obj) ) ;
                Obj_SetY(obj, Obj_GetY(obj) + position);
                PlaySE("script\Remilia Spell Cards\sfx\shot3.wav");
           }
if(frame%15==0){
CreateShotA(1, Obj_GetX(obj), Obj_GetY(obj), 30);
SetShotDataA(1, 100, 0, rand(0, 360), 0, 0.03, 2, RED01);
FireShot(1);
}

       yield;
}
}







@Initialize {
SetLife(2500);
SetTimer(60);
SetScore(10000000);

SetEnemyMarker(true);

SetMovePosition02(225, 120, 60);

LoadGraphic(ImgBoss);
SetTexture(ImgBoss);
SetGraphicRect(0, 0, 128, 128);
}

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

if(count == 1200) {
                PlaySE("script\Remilia Spell Cards\sfx\shot4.wav");

loop(8){
Bounce(GetX, GetY, 3, a);
a += 360/8;
}

count=0
}

count++;
}

@DrawLoop {
DrawGraphic(GetX, GetY);
}

@Finalize {
DeleteGraphic(ImgBoss);
}
}

Some things to note about your code and why it was running into errors. The reason it said obj was the source of the error is because the variable obj doesn't exist outside of task Bounce (you declared it inside the task, so to Danmakufu, that variable doesn't exist outside of it). To fix this, just declare let obj = NULL at the very start of the script. This way the variable obj can be used throughout the entire script without running into errors. This won't actually fix your problem though, since you can't use AddShot with object bullets, but I thought you should know that.

As I mentioned earlier, your reflection code was incorrect (as in, it won't work properly 100% of the time). The code I included gets the distance that the bullet would have traveled if it actually reflected off of the invisible barrier, then set's it's position accordingly. The code you have will only correct for small speed values, since the bullets will sometimes go 0.1 of a pixel beyond the game window.

Speaking of which, about the bullets in AddShot... Is it possible with CreateShotA bullets to change every single one of them that are created by other bullets at once with SetShotDataA, as in Remilia's spell cards, or does that have to do with more object bullets?

Do you mind rephrasing this? I'm not really sure what you're asking.

Re: Danmakufu Q&A/Problem Thread
« Reply #54 on: May 25, 2009, 07:32:55 AM »
No. AddShot only works on CreateShotA's And CreateLaserABC's. To spawn a bullet from an object bullet, you just spawn any bullet on the object bullet's coordinates. like this:

CreateShot01(Obj_GetX(obj), Obj_GetY(obj), ...);

To have it keep spawning bullets every fifteen frames, as per your AddShot code (by the way, ascent i in 1..500? Holy shit that is a lot of bullets to process on one frame... Eight times!), you'll want to use the modulus function (%15) and just set a frame counter to increment in the object bullet's while(){} code tree.

Anyways, here's the fixed code. Things I changed:

  • Removed the ascent code when you spawn the Bounce bullets, and moved a similar code into task Bounce to spawn RED01's every fifteen frames.
  • Restructured the Bounce task's reflection code to more accurately reflect the bullets. Try to use this formula from now on, it will never fail.

Code: [Select]
#TouhouDanmakufu
#Title[Red Magic]
#Text[Test script]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
let ImgBoss = "script\thC\IMAGE\CHAR\DOT\boss_yukari.png";

let count = 1140;
let a=0;





task Bounce(x, y, v, angle) {
     let obj=Obj_Create(OBJ_SHOT);
     let frame = 0;
     Obj_SetPosition(obj, x, y);
     Obj_SetAngle(obj, angle);
     Obj_SetSpeed(obj, v);
     ObjShot_SetGraphic(obj, RED03);
     ObjShot_SetDelay(obj, 0);
     ObjShot_SetBombResist(obj, true);
     Obj_SetCollisionToObject(obj, true);

     while(Obj_BeDeleted(obj)==false){
frame++;
           if(Obj_GetX(obj)<GetClipMinX) {
        let position = GetClipMinX - Obj_GetX(obj);
                Obj_SetAngle(obj, 180 - Obj_GetAngle(obj) ) ;
                Obj_SetX(obj, Obj_GetX(obj) + position);
                PlaySE("script\Remilia Spell Cards\sfx\shot3.wav");
           }

           if(Obj_GetX(obj)>GetClipMaxX) {
        let position = GetClipMaxX - Obj_GetX(obj);
                Obj_SetAngle(obj, 180 - Obj_GetAngle(obj) ) ;
                Obj_SetX(obj, Obj_GetX(obj) + position);
                PlaySE("script\Remilia Spell Cards\sfx\shot3.wav");
           }

           if(Obj_GetY(obj)<GetClipMinY) {
        let position = GetClipMinY - Obj_GetY(obj);
                Obj_SetAngle(obj, 0 - Obj_GetAngle(obj) ) ;
                Obj_SetY(obj, Obj_GetY(obj) + position);
                PlaySE("script\Remilia Spell Cards\sfx\shot3.wav");
           }
if(frame%15==0){
CreateShotA(1, Obj_GetX(obj), Obj_GetY(obj), 30);
SetShotDataA(1, 100, 0, rand(0, 360), 0, 0.03, 2, RED01);
FireShot(1);
}

       yield;
}
}







@Initialize {
SetLife(2500);
SetTimer(60);
SetScore(10000000);

SetEnemyMarker(true);

SetMovePosition02(225, 120, 60);

LoadGraphic(ImgBoss);
SetTexture(ImgBoss);
SetGraphicRect(0, 0, 128, 128);
}

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

if(count == 1200) {
                PlaySE("script\Remilia Spell Cards\sfx\shot4.wav");

loop(8){
Bounce(GetX, GetY, 3, a);
a += 360/8;
}

count=0
}

count++;
}

@DrawLoop {
DrawGraphic(GetX, GetY);
}

@Finalize {
DeleteGraphic(ImgBoss);
}
}

Some things to note about your code and why it was running into errors. The reason it said obj was the source of the error is because the variable obj doesn't exist outside of task Bounce (you declared it inside the task, so to Danmakufu, that variable doesn't exist outside of it). To fix this, just declare let obj = NULL at the very start of the script. This way the variable obj can be used throughout the entire script without running into errors. This won't actually fix your problem though, since you can't use AddShot with object bullets, but I thought you should know that.

As I mentioned earlier, your reflection code was incorrect (as in, it won't work properly 100% of the time). The code I included gets the distance that the bullet would have traveled if it actually reflected off of the invisible barrier, then set's it's position accordingly. The code you have will only correct for small speed values, since the bullets will sometimes go 0.1 of a pixel beyond the game window.

Do you mind rephrasing this? I'm not really sure what you're asking.


1. Okay. Thank you very much.

2. Eh, what I was trying to say is that I have a Scarlet Gensokyo replica script, but it doesn't work out like the actual Scarlet Gensokyo as to when the bullets begin to move.

Here is the code:
Code: [Select]
#TouhouDanmakufu
#Title[Scarlet Sign "Scarlet Gensokyo"]
#Text[Test script]
#Image[.\img\Scarletsign.png]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
let ImgBoss = "script\thC\IMAGE\CHAR\DOT\boss_remilia.png";

let count = 731;
let a=0;
let num=4;
let num2=16;
let num3=12;

@Initialize {
SetLife(6000);
SetDamageRate(100, 0);
SetTimer(120);
SetScore(10000000);
SetInvincibility(300);

SetMovePosition02(225, 120, 60);
CutIn(YOUMU, "Scarlet Sign "\""Scarlet Gensokyo"\", "", 0, 0, 0, 0);

LoadGraphic(ImgBoss);
SetTexture(ImgBoss);
SetGraphicRect(0, 0, 128, 128);
}

@MainLoop {
SetShotAutoDeleteClip(0, 0, 0, 0);
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);

if(count == 100){
PlaySE("lib\THCCL\SE\kira03.wav");

Concentration01(80);
PlaySE("lib\THCCL\SE\power0.wav");
}

if(count == 180){
SetMovePositionRandom01(50,20,5,GetClipMinX()+100,30,GetClipMaxX()-100,100);
PlaySE("lib\THCCL\SE\kira00.wav");

loop(num2){
CreateShotA(1, GetX, GetY, 0);
SetShotDataA(1, 0, 3, a, 1.5, 0, 5, RED03);
SetShotDataA(1, 60, 3, NULL, 0, 0, 5, RED03);
a += 360/num2;

ascent(i in 1..500){
    CreateShotA(2, 0, 0, 30);
    SetShotDataA(2, 100, 0, rand(0, 360), 0, 0.03, 2, RED01);
    AddShot(i*10+0, 1, 2, 0);
}
FireShot(1);
}
}

if(count == 310){
PlaySE("lib\THCCL\SE\kira03.wav");
}

if(count == 390){
PlaySE("lib\THCCL\SE\kira00.wav");

loop(num2){
CreateShotA(9, GetX, GetY, 0);
SetShotDataA(9, 0, 3, a+135, -1.5, 0, 5, RED03);
SetShotDataA(9, 60, 3, NULL, -0, 0, 5, RED03);
a += 360/num2;

ascent(i in 1..500){
    CreateShotA(10, 0, 0, 30);
    SetShotDataA(10, 100, 0, rand(0, 360), 0, 0.03, 2, RED01);
AddShot(i*10+0, 9, 10, 30);
}
FireShot⑨;
}
}

if(count == 520){
PlaySE("lib\THCCL\SE\kira03.wav");
}

if(count == 600){
SetMovePositionRandom01(100,20,5,GetClipMinX()+100,30,GetClipMaxX()-100,100);
PlaySE("lib\THCCL\SE\kira00.wav");

loop(num2){
CreateShotA(17, GetX, GetY, 0);
SetShotDataA(17, 0, 3, a+75, 1.5, 0, 5, RED03);
SetShotDataA(17, 60, 3, NULL, 0, 0, 5, RED03);
a += 360/num2;

ascent(i in 1..500){
    CreateShotA(18, 0, 0, 30);
    SetShotDataA(18, 100, 0, rand(0, 360), 0, 0.03, 2, RED01);

AddShot(i*10+0, 17, 18, 30);
}
FireShot(17);
}
}

if(count == 730){
PlaySE("lib\THCCL\SE\kira03.wav");
}

if(count == 750){
Concentration01(120);
PlaySE("lib\THCCL\SE\power0.wav");
}

if(count == 870){
PlaySE("lib\THCCL\SE\kira00.wav");

loop(num3){
CreateShotA(33, GetX, GetY, 0);
SetShotDataA(33, 0, 5, a, 0, 0, 5, RED03);
CreateShotA(35, GetX, GetY, 0);
SetShotDataA(35, 8, 5, a+23, 0, 0, 5, RED03);
CreateShotA(37, GetX, GetY, 0);
SetShotDataA(37, 16, 5, a+46, 0, 0, 5, RED03);
CreateShotA(39, GetX, GetY, 0);
SetShotDataA(39, 24, 5, a+69, 0, 0, 5, RED03);
a += 360/num3;

ascent(i in 1..500){
    CreateShotA(34, 0, 0, 30);
    SetShotDataA(34, 100, 0, rand(0, 360), 0, 0.03, 2, RED01);
    CreateShotA(36, 0, 0, 30);
    SetShotDataA(36, 100, 0, rand(0, 360), 0, 0.03, 2, RED01);
    CreateShotA(38, 0, 0, 30);
    SetShotDataA(38, 100, 0, rand(0, 360), 0, 0.03, 2, RED01);
    CreateShotA(40, 0, 0, 30);
    SetShotDataA(40, 100, 0, rand(0, 360), 0, 0.03, 2, RED01);

    AddShot(i*8+0, 33, 34, 30);
    AddShot(i*8+8, 35, 36, 30);
    AddShot(i*8+16, 37, 38, 30);
    AddShot(i*8+24, 39, 40, 30);

}

FireShot(33);
FireShot(35);
FireShot(37);
FireShot(39);
}

;
count=0
}
count++;
}

@DrawLoop {
DrawGraphic(GetX, GetY);
}

@Finalize {
DeleteGraphic(ImgBoss);
}
}


Let's take a look at the bullets that are left behind by the RED03's (the AddShot RED01's). It takes each bullet from the time it appears a delay of 100 frames to begin moving. This means that the bullets, in turns, begin to take their effects and move, instead of every one of them instantly accelerating at once. Remilia causes the latter to happen by creating some kind of wave during her fight that turns all of the bullets purple at once and slowly accelerate (this happens with one of her hard and lunatic spell cards [which I believe is the third to last one], Red Magic and Scarlet Gensokyo). What would I do to cause it to happen as Remilia does, instead of using the actual delay part of SetShotDataA?



Also, one other note: in (ascent 1... 500), it appears that this function states, by my witnessing, that this is the maximum number of bullets that can be added. What else does this code represent by increasing and decreasing the numbers?
« Last Edit: May 25, 2009, 07:36:54 AM by Frazer »

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #55 on: May 25, 2009, 09:10:49 PM »
Frazer: That's actually simple to do. Make a variable that starts at the value of the frame you want the first bullet to move at. Every time you create a bullet, subtract that value by the same time it takes to create the next one. So:

Code: [Select]
let TimeToMove = 240;
if(frame==0)
{
CreateShotA(shot, GetX, GetY, 10);
SetShotDataA(shot, 0, 0, 0, 0, 0, 0, RED01);
SetShotDataA(shot, TimeToMove, Angle, 0, 0, 0.2, 4, RED01);
FireShot(shot);
shot++;
TimeToMove -= 10;
frame = -10;
}

Something similar to that. You most likely won't do it exactly like that, but I guess it shows what I mean. So, let's look at it...

Every time frame hits 0, the bullet is created, shot is increased so each new shot has its own number, frame is set to -10, meaning it'll take 10 more frames to get it up to 0 again. Because of this, we decrease TimeToMove by 10. However, I'm sure you know to reset the value of TimeToMove eventually, since it'd be bad if the bullet moves at say, -10 frames. XD



Okay, that said, I have a question of my own...

Is there a way to reduce the life of an enemy or boss without directly hitting the original boss enemy itself? Like, say I wanted a boss to have a familiar, but shooting said familiar would harm the boss, though not as much as shooting the boss itself. Know what I'm saying? (I think this happened in Imperishable Night...) Normally, I could just figure out how much damage the familiar is taking and do "SetLife(GetLife() - [value])", but that refills the lifebar, it doesn't visually represent anything related to the original size of the lifebar.

I'm probably wording this badly...

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #56 on: May 25, 2009, 09:38:09 PM »
Quote
Is there a way to reduce the life of an enemy or boss without directly hitting the original boss enemy itself? Like, say I wanted a boss to have a familiar, but shooting said familiar would harm the boss, though not as much as shooting the boss itself. Know what I'm saying? (I think this happened in Imperishable Night...) Normally, I could just figure out how much damage the familiar is taking and do "SetLife(GetLife() - [value])", but that refills the lifebar, it doesn't visually represent anything related to the original size of the lifebar.

You can put a negative number in AddLife to damage the boss.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #57 on: May 26, 2009, 02:17:05 AM »
I'm wondering how Naut got his squares done. I did it this way, and for some reason angle 225 is missing.

Code: [Select]
task square(){     
    let a = 45;
    let xv = NULL;
    let yv = NULL;
    loop(40){
        if (a>=45 && a<135){
            xv = ((a - 90) / -9)/5;
            yv = 5/5;
        }else if(a>=135 && a<225){
            xv = -5/5;
            yv = ((a - 180) / -9)/5;
        }else if(a>=225 && a<315){
            xv = ((a - 270) / -9)/5;
            yv = -5/5;
        }else if(a>=315 && a<405){
            xv = 5/5;
            yv = ((a - 360) / -9)/5;
        }
        CreateShot11(GetEnemyX, GetEnemyY, xv, yv, RED01, 9);
        a += (360/40);
    }
}

The last /5 was just to slow it down and observe.

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

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #58 on: May 26, 2009, 02:18:27 AM »
Ah, thanks, Stuffman. New question: Is there any way I can stop a user-defined bullet from changing the angle its graphic is put in when it changes the angle it's moving in? Like

< v > ^

It'd spin like that when going at angle 0, but if it were to bounce off a wall...

^ > v <

It'd just flip. I don't want that, I want a bullet that never changes graphical direction based on its direction of movement- is this possible?

Re: Danmakufu Q&A/Problem Thread
« Reply #59 on: May 26, 2009, 02:30:34 AM »
Use Obj_SetX and Obj_SetY to guide it's movement, instead of the speed functions. it's more difficult, but the bullet's graphic is automatically adjusted for different angles of movement, so you'd have to keep setting it's angle to whatever you want it to be, then guide it's movement each frame. It's not as long and tiring as it sounds; just a bit of trigonometry, but it's still a pain in the ass.

For Drake:

Code: [Select]
#TouhouDanmakufu
#Title[What]
#BackGround[User(.\PIC\black.png, 1, 1)]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {


let ImgBoss = "script/ExRumia/img/ExRumia.png";
let vxa = -3;

    @Initialize {

SetLife(6000);
SetTimer(100);
SetScore(5000000);
MagicCircle(false);
SetDamageRate(100, 20);
SetEnemyMarker(true);
LoadGraphic(ImgBoss);
LoadSE(se1);
SetMovePosition02(GetCenterX, GetCenterY - 100, 1);
squares;

    }

    @MainLoop {
    SetCollisionB(GetX, GetY, 24);
SetShotAutoDeleteClip(64, 400, 64, 64);
yield;
}

    @DrawLoop {
SetTexture(ImgBoss);
SetGraphicRect(0, 0, 64, 64);
DrawGraphic(GetX, GetY);
    }

    @Finalize {
DeleteGraphic(ImgBoss);
DeleteSE(se1);
    }

task squares{
loop(10){yield;}
let vxa = -3;
loop(33){
CreateShotA(0, GetX, GetY, 6);
CreateShotA(1, GetX, GetY, 6);
SetShotDirectionType(PLAYER);
SetShotDataA_XY(0, 0, vxa, 3, 0, 0, 0, 0, RED01);
SetShotDataA_XY(1, 0, vxa, -3, 0, 0, 0, 0, RED01);
vxa+= 3/16;
FireShot(0);
FireShot(1);}
vxa-= 6/16;
loop(31){
CreateShotA(2, GetX, GetY, 6);
CreateShotA(3, GetX, GetY, 6);
SetShotDirectionType(PLAYER);
SetShotDataA_XY(2, 0, 3, vxa, 0, 0, 0, 0, RED01);
SetShotDataA_XY(3, 0, -3, vxa, 0, 0, 0, 0, RED01);
vxa-= 3/16;
FireShot(2);
FireShot(3);
}
squares;
}

}

I like to think I cheated to make the squares, but here is the code you requested none-the-less. Needless CreateShotA's, I know, but I don't have the parameters of most of the shot functions memorized yet.