~Hakurei Shrine~ > Rika and Nitori's Garage Experiments
Danmakufu Q&A/Problem Thread
<< < (2/201) > >>
Garlyle:
Quickest way I can think of: Base script, boss moves to center of screen, and have a DrawText string that writes the GetAngleToPlayer onto the screen somewhere so you can check it.

I did the same when trying to test out damage originally: A boss script that, once its invincibility wore off, counted the frames that passed until you beat it.  Since it didn't move, it let me test damage in terms of how many frames it took to take down ~1000 HP.
Naut:
Figures. Here's the test results:






GetAngleToPlayer outputs an angle between 0 and 360, atan2 outputs an angle between -180 and 180. Why is this not surprising...?

Sigh, thanks Danmakufu.

Interestingly enough, the angles are not the same, so my thought that GetAngleToPlayer = atan2(GetPlayerY - GetY, GetPlayerX - GetX) seems to be incorrect, even if the angle has 360 added to it if it outputs a negative value (notice the decimal value...? Not cool). They are negligably different though, so it doesn't really make much of a difference in a script. But really, what the hell.
Drake:
atan2 is probably less accurate considering Danmakufu does math with rounded decimals based on pixel-perfect locations.

Although if that's how it works, I wonder how GetAngle works...?
Frazer:
I've got a question.


1) Currently, I am messing with the curve laser function (CreateLaserC/SetLaserDataC). I place an AddShot (CreateShotA) to the lasers.

However, I add the bullets to the lasers, but every single bullet added to a laser goes in one direction (i.e. each curved laser goes in different directions, but every other bullet flies in the direction of, for example, 0 degrees). In addition, I am only looping one laser to add each of the bullets (one laser is looped five times in equal distances apart, the AddShot bullets are also looped to the one laser).

Here is the code I am trying to work with.


--- Code: ---#TouhouDanmakufu
#Title[Winter Sign "Flower Wither Away"]
#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 = 0;
let a = 72;

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

SetMovePosition02(225, 120, 60);
CutIn(YOUMU, "Winter Sign "\""Flower Wither Away"\", "", 0, 0, 0, 0);

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

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

if(count == 90){
PlaySE("lib\THCCL\SE\lazer00.wav");
loop(5){
CreateLaserC(1, GetX, GetY, 10, 30, WHITE01, 0);
SetLaserDataC(1, 0, 5, a, 4, 0, 3);
SetLaserDataC(1, 50, NULL, NULL, 5, -0.05, 2);
SetLaserDataC(1, 90, NULL, NULL, 0, 0.05, 5);
a += 360/5;

ascent(i in 1..900){
    CreateShotA(2, 0, 0, 20);
    SetShotDataA(2, 0, 1, 30, 0, 0, 1, BLUE11);
    CreateShotA(3, 0, 0, 20);
    SetShotDataA(3, 0, 1, 180, 0, 0, 1, BLUE11);
    CreateShotA(4, 0, 0, 20);
    SetShotDataA(4, 0, 1, -30, 0, 0, 1, BLUE11);
    AddShot(i*6+60, 1, 2, 0);
    AddShot(i*6+61, 1, 3, 0);
    AddShot(i*6+61, 1, 4, 0);
}

FireShot(1);
}
}

if(count == 210){
PlaySE("lib\THCCL\SE\lazer00.wav");
loop(5){
CreateLaserC(5, GetX, GetY, 10, 30, WHITE01, 0);
SetLaserDataC(5, 0, 5, a, -4, 0, 3);
SetLaserDataC(5, 50, NULL, NULL, -5, -0.05, 2);
SetLaserDataC(5, 90, NULL, NULL, 0, 0.05, 5);
a += 360/5;

ascent(i in 1..900){
    CreateShotA(6, 0, 0, 20);
    SetShotDataA(6, 0, 1, 30, 0, 0, 1, BLUE11);
    CreateShotA(7, 0, 0, 20);
    SetShotDataA(7, 0, 1, 180, 0, 0, 1, BLUE11);
    CreateShotA(8, 0, 0, 20);
    SetShotDataA(8, 0, 1, -30, 0, 0, 1, BLUE11);
    AddShot(i*6+60, 5, 6, 0);
    AddShot(i*6+61, 5, 7, 0);
    AddShot(i*6+61, 5, 8, 0);
}

FireShot(5);
}
;
count=0
}
count++;
}

@DrawLoop {
DrawGraphic(GetX, GetY);
}

@Finalize {
DeleteGraphic(ImgBoss);
}
}
--- End code ---


If you notice, I am trying to make a spellcard at least similar to Letty Whiterock's second spellcard of PCB. She creates five curved lasers. However, every one of the AddShot bullets in its respective I.D. only go in one direction. I am not quite sure how to make this easy to explain, but I would like each bullet to get the angle of its respective laser, not just the single core point.

Is it possible to do this with only one laser looped five times, or do I have to create separate lasers and bullets to make it work like Letty's? I want to keep the code as simple as possible.
Darkblizer:

--- Quote from: Frazer on May 05, 2009, 12:58:02 AM ---I've got a question.


1) Currently, I am messing with the curve laser function (CreateLaserC/SetLaserDataC). I place an AddShot (CreateShotA) to the lasers.

However, I add the bullets to the lasers, but every single bullet added to a laser goes in one direction (i.e. each curved laser goes in different directions, but every other bullet flies in the direction of, for example, 0 degrees). In addition, I am only looping one laser to add each of the bullets (one laser is looped five times in equal distances apart, the AddShot bullets are also looped to the one laser).

Here is the code I am trying to work with.


--- Code: ---#TouhouDanmakufu
#Title[Winter Sign "Flower Wither Away"]
#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 = 0;
let a = 72;

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

SetMovePosition02(225, 120, 60);
CutIn(YOUMU, "Winter Sign "\""Flower Wither Away"\", "", 0, 0, 0, 0);

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

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

if(count == 90){
PlaySE("lib\THCCL\SE\lazer00.wav");
loop(5){
CreateLaserC(1, GetX, GetY, 10, 30, WHITE01, 0);
SetLaserDataC(1, 0, 5, a, 4, 0, 3);
SetLaserDataC(1, 50, NULL, NULL, 5, -0.05, 2);
SetLaserDataC(1, 90, NULL, NULL, 0, 0.05, 5);
a += 360/5;

ascent(i in 1..900){
    CreateShotA(2, 0, 0, 20);
    SetShotDataA(2, 0, 1, 30, 0, 0, 1, BLUE11);
    CreateShotA(3, 0, 0, 20);
    SetShotDataA(3, 0, 1, 180, 0, 0, 1, BLUE11);
    CreateShotA(4, 0, 0, 20);
    SetShotDataA(4, 0, 1, -30, 0, 0, 1, BLUE11);
    AddShot(i*6+60, 1, 2, 0);
    AddShot(i*6+61, 1, 3, 0);
    AddShot(i*6+61, 1, 4, 0);
}

FireShot(1);
}
}

if(count == 210){
PlaySE("lib\THCCL\SE\lazer00.wav");
loop(5){
CreateLaserC(5, GetX, GetY, 10, 30, WHITE01, 0);
SetLaserDataC(5, 0, 5, a, -4, 0, 3);
SetLaserDataC(5, 50, NULL, NULL, -5, -0.05, 2);
SetLaserDataC(5, 90, NULL, NULL, 0, 0.05, 5);
a += 360/5;

ascent(i in 1..900){
    CreateShotA(6, 0, 0, 20);
    SetShotDataA(6, 0, 1, 30, 0, 0, 1, BLUE11);
    CreateShotA(7, 0, 0, 20);
    SetShotDataA(7, 0, 1, 180, 0, 0, 1, BLUE11);
    CreateShotA(8, 0, 0, 20);
    SetShotDataA(8, 0, 1, -30, 0, 0, 1, BLUE11);
    AddShot(i*6+60, 5, 6, 0);
    AddShot(i*6+61, 5, 7, 0);
    AddShot(i*6+61, 5, 8, 0);
}

FireShot(5);
}
;
count=0
}
count++;
}

@DrawLoop {
DrawGraphic(GetX, GetY);
}

@Finalize {
DeleteGraphic(ImgBoss);
}
}
--- End code ---


If you notice, I am trying to make a spellcard at least similar to Letty Whiterock's second spellcard of PCB. She creates five curved lasers. However, every one of the AddShot bullets in its respective I.D. only go in one direction. I am not quite sure how to make this easy to explain, but I would like each bullet to get the angle of its respective laser, not just the single core point.

Is it possible to do this with only one laser looped five times, or do I have to create separate lasers and bullets to make it work like Letty's? I want to keep the code as simple as possible.

--- End quote ---

Unfortunately, I don't think there's any way to track the angle of LaserC. Let me know if I'm wrong. You might have to use Object Lasers in order to be able to track the angle of it, and then fire the shots relative to that (or something along those lines..) .

I have another question. How do you make bullet patterns similar to Alice's PCB noncards?
Navigation
Message Index
Next page
Previous page

Go to full version