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

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: Danmakufu Q&A/Problem Thread
« Reply #240 on: July 09, 2009, 10:17:51 AM »
I have a question...

is it possible to get data, like a certain variable, from another script every frame, so that you could also use that same variable on that enemy? (the variable is used in both scripts at the same time)

for example... you have a boss that spawns familiars using the CreateEnemyFromFile function and the familiars have to use a certain variable in the boss' script that the boss also uses, but you can't just copy paste the calculation cause it's randomized at some points.
« Last Edit: July 09, 2009, 10:45:02 AM by kyle_090594 »
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Stuffman

  • *
  • We're having a ball!
Re: Danmakufu Q&A/Problem Thread
« Reply #241 on: July 09, 2009, 03:37:13 PM »
You need to use the CommonData functions. You use them to declare variables that exist globally.

For instance, in your boss script you would say
Code: [Select]
SetCommonData("bossvariable",variable);And in the familiar script you can access it with
Code: [Select]
GetCommonData("bossvariable");
This will work fine in your mainloops.

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #242 on: July 09, 2009, 08:44:47 PM »
I decided to scrap my original idea for the Fate spellcard, and now I have this:

Code: [Select]
#TouhouDanmakufu
#Title[Reflection of a Fate Broken with Scarlet]
#Text[]
#Image[]
#BackGround[Default]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
#include_function "lib\SHOT_REPLACE\shot_replace.dnh"
let BossImage = GetCurrentScriptDirectory ~ "boss_remilia.png";
let BossCutIn = GetCurrentScriptDirectory ~ "Remilia.png";
let frame = -100;
let frame2 = -100;
let anim_frame = 0;
let Angle = 0;
let ShotSFX = "script\sfx\shot.wav";
let LaserSFX = "script\sfx\laser.wav";
let Fate = [];
let Fate2 = [];
let Break = [];
let Angle2 = 0;

task ReflectingFate
{
let i = 0;
while (i < length(Fate))
{
if (Obj_BeDeleted(Fate[i]))
{
Fate = erase(Fate, i);
i--;
}
else
{
if(Obj_GetX(Fate[i]) <= GetClipMinX() || Obj_GetX(Fate[i]) >= GetClipMaxX())
{
Obj_SetAngle(Fate[i], 180-Obj_GetAngle(Fate[i]));
}
if(Obj_GetY(Fate[i]) <= GetClipMinY() || Obj_GetY(Fate[i]) >= GetClipMaxY())
{
Obj_SetAngle(Fate[i], 360-Obj_GetAngle(Fate[i]));
}
let e = 0;
while(e < length(Break) && !Obj_BeDeleted(Fate[i]))
{
if(Collision_Obj_Obj(Fate[i], Break[e]) == true)
{
let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj, Obj_GetX(Fate[i]), Obj_GetY(Fate[i]));
Obj_SetAngle(obj, (Obj_GetAngle(Fate[i]) + 360) + 45);
Obj_SetSpeed(obj, 2);
ObjShot_SetGraphic(obj, AQUA05);
Fate2 = Fate2 ~ [obj];

let obj2 = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj2, Obj_GetX(Fate[i]), Obj_GetY(Fate[i]));
Obj_SetAngle(obj2, (Obj_GetAngle(Fate[i]) + 360) - 45);
Obj_SetSpeed(obj2, 2);
ObjShot_SetGraphic(obj2, AQUA05);
Fate2 = Fate2 ~ [obj2];
Obj_Delete(Fate[i]);
}
e++;
}
}
i++;
}
}

task BrokenFate
{
let h = 0;
while (h < length(Fate2))
{
if (Obj_BeDeleted(Fate2[h]))
{
Fate2 = erase(Fate2, h);
h--;
}
else
{
if(Obj_GetY(Fate2[h]) <= GetClipMinY())
{
Obj_SetAngle(Fate2[h], 360-Obj_GetAngle(Fate2[h]));
}
let e = 0;
while(e < length(Break) && !Obj_BeDeleted(Fate2[h]))
{
if(Collision_Obj_Obj(Fate2[h], Break[e]) == true)
{
Obj_SetAngle(Fate2[h], 180-Obj_GetAngle(Fate2[h]));
}
e++;
}
}
h++;
}
}

@Initialize
{
shotinit;
LoadGraphic(BossImage);
SetLife(400);
SetDamageRate(0,0);
SetTimer(72);
SetDurableSpellCard();
CutIn(YOUMU, "Reflection of a Fate Broken with Scarlet", BossCutIn, 0, 0, 256, 320);
SetScore(70000);
SetEnemyMarker(true);
MagicCircle(true);
SetMovePosition02(GetCenterX,130,30);
}

@MainLoop
{
ReflectingFate;
BrokenFate;
anim_frame++;
SetCollisionB(GetX(),GetY(),24);
if(frame == 0)
{
loop(8)
{
let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj, GetX, GetY);
Obj_SetAngle(obj, Angle);
Obj_SetSpeed(obj, 2);
ObjShot_SetGraphic(obj, AQUA04);
Fate = Fate ~ [obj];
Angle += 45;
}
Angle += 22.5;
frame = -100;

}
if(frame2 >= 60 && frame2 < 100)
{
if(frame2%5 == 0)
{
loop(8)
{
let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj, GetX, GetY);
Obj_SetAngle(obj, Angle2);
Obj_SetSpeed(obj, 4);
ObjShot_SetGraphic(obj, RED32);
Break = Break ~ [obj];

Angle2 += 45;
}
Angle2 += 22.5;
//PlaySE(LaserSFX);
}
}
if(frame2 >= 100)
{
frame2 -= 100;
}
frame++;
frame2++;
}

@DrawLoop
{
SetTexture(BossImage);
if(anim_frame >= 0 && anim_frame < 8)
{
if(GetSpeedX()==0)
{
SetGraphicRect(31,31,95,94);
}
else if(GetSpeedX()>0)
{
SetGraphicRect(286,415,352,478);
}
else if(GetSpeedX()<0)
{
SetGraphicRect(286,159,348,222);
}
}
if(anim_frame >= 8 && anim_frame < 16)
{
if(GetSpeedX()==0)
{
SetGraphicRect(31,159,95,222);
}
else if(GetSpeedX()>0)
{
SetGraphicRect(286,415,352,478);
}
else if(GetSpeedX()<0)
{
SetGraphicRect(286,159,348,222);
}
}
if(anim_frame >= 16 && anim_frame < 24)
{
if(GetSpeedX()==0)
{
SetGraphicRect(31,287,95,350);
}
else if(GetSpeedX()>0)
{
SetGraphicRect(286,415,352,478);
}
else if(GetSpeedX()<0)
{
SetGraphicRect(286,159,348,222);
}
}
if(anim_frame >= 24 && anim_frame < 32)
{
if(GetSpeedX()==0)
{
SetGraphicRect(31,415,95,478);
}
else if(GetSpeedX()>0)
{
SetGraphicRect(286,415,352,478);
}
else if(GetSpeedX()<0)
{
SetGraphicRect(286,159,348,222);
}
}
if(anim_frame >= 32)
{
anim_frame = 0;
}
DrawGraphic(GetX, GetY);
}

@Finalize
{
DeleteGraphic(BossImage);
}
}

Of course, I wouldn't be posting here if I didn't have a problem... The problem is that while everything works as I want them to, EVERYTHING SLOWS DOWN SO MUCH. I have no idea why... Is it solely because of the tasks? Or what? I just can't tell.

Re: Danmakufu Q&A/Problem Thread
« Reply #243 on: July 09, 2009, 09:27:51 PM »
Holy fucking shiiiiiiiiiiIIIIIIIIIIIIIIIIIIIIT. I have a quad core and my computer was crying on that. Too much reflecting causes major slowdown. When I made my Mokou script I originally had the white glowing orbs reflect (oh baby), which created a giant mesh of particles but slowed down even the sturdiest of computers, so I had to scrap that and throw fireballs with it instead. Point: Reflecting takes a lot of processing, for whatever reason. Especially if more than a few bullets are updating their information during a span of a few frames (like your script).

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #244 on: July 09, 2009, 09:57:30 PM »
Oh, I didn't know that... Problem is, without reflecting, there's really not much point to this spellcard at all...

...Also, I've had more reflecting bullets than this spawn at once, and that never gave me slowdown... *points to Armageddon Matter script* I need more ideas, then... I still want the splitting to happen when the bullets get sliced, but without reflecting, there's no point to it, because the bullets won't even go to the player then... Unless I find some good and easy way to make them fly up, then fall down. (I'm not good with "gravity" effects like that, though... Any advice on some simple ways to do it?)

EDIT: Okay, it can't be the reflecting alone. I am now going to assume it is the Collision_Obj_Obj because when I comment out all the reflecting stuff, I still get big slowdown eventually, even when many bullets begin leaving the screen...
« Last Edit: July 09, 2009, 10:00:12 PM by pikaguy900 »

Re: Danmakufu Q&A/Problem Thread
« Reply #245 on: July 10, 2009, 03:11:30 AM »
Likely.

My reflecting example was 40x worse than what yours is, so that is a very plausable assumption. Collision_Obj_Obj is pretty eff'd to begin with, so reflecting based on that can't really yield nice results in bulk. That is, the collision lasts for more than one frame and thus things get processed for a needlessly long time. Try having the bullets reflect only once (implement a counter to check if the bullets have already reflected) and see if that helps. Or ignore that idea if you really want them to keep reflecting.... Which is probably not a good idea in the first place. Ever play Light Sign "Reflection, Refraction" for longer than 15 seconds? Yeah.

Simple way to do gravity effects is CreateShot12 with a positive y-acceleration and a negative y-velocity (will rise upwards and slowly fall downwards). Another way is to use CreateShotA's that have angular velocity to point them downward... But that's needlessly complex when you can indicate a vertical component (gravity) with CreateShot12 or SetShotDataA_XY.

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #246 on: July 10, 2009, 04:19:05 AM »
Eh, thanks, Naut, but nevermind. Yes, the problem was Collision_Obj_Obj, but without that, my whole spellcard was ruined... Thus, I decided to just change the spellcard altogether. Now it's those knives whirling around while large, white bullets appear every so often from the boss, angling downward. Four in each direction they go in, which is two, so eight bullets. Each stops at a certain distance, and after 270 frames after spawning, they create a ring 16 smaller bullets EACH (8 x 16) and zoom at the player. :D  I have yet to beat it without dying. It is perfect! ;D It's easy to dodge, yet not.

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: Danmakufu Q&A/Problem Thread
« Reply #247 on: July 10, 2009, 10:10:44 AM »
You need to use the CommonData functions. You use them to declare variables that exist globally.

For instance, in your boss script you would say
Code: [Select]
SetCommonData("bossvariable",variable);And in the familiar script you can access it with
Code: [Select]
GetCommonData("bossvariable");
This will work fine in your mainloops.

Thanks! that worked!
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Hat

  • Just an unassuming chapeau.
  • I will never be ready.
Re: Danmakufu Q&A/Problem Thread
« Reply #248 on: July 11, 2009, 01:29:49 AM »
Supposing I had eight object bullets I made, and I had defined a function that fired a set of bullets from each object bullet. How do I have the function select the coordinates of one bullet of the eight, and fire it, each frame, and not fire from the remaining eight frames? It's more complicated than you'd realize. The most I have right now is something like this:
Code: [Select]
#TouhouDanmakufu
#Title[Nonspell Somethingerother]
#Text[Somethingerother Nonspell is Somethingerotherrrrrr]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
    let ImgBoss = "script\img\ExRumia.png";
let frame = 0;


    @Initialize {
        SetLife(2000);
        SetTimer(50);
        SetScore(1000000);

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

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

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
if(frame == 120){
FSpheres;
frame = 0;
}
yield;
frame++;

    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
    }

    @Finalize {
        DeleteGraphic(ImgBoss);
    }
function FSpheres{
let ang = GetAngleToPlayer;
ascent(i in 0..8){
TSpheres(ang + i*45, i);
}
}
task TSpheres(let shotangle, let i){
let dist = 0;
let timer = 0;
let mod = 1;
let CX = GetX;
let CY = GetY;
let sphere_id = Obj_Create(OBJ_SHOT);
Obj_SetPosition(sphere_id, GetX, GetY);
ObjShot_SetDelay(sphere_id, 5);
ObjShot_SetBombResist(sphere_id, true);
ObjShot_SetGraphic(sphere_id, RED02);
while(Obj_BeDeleted(sphere_id) == false && timer <= 250){
Obj_SetPosition(sphere_id, GetX + dist*cos(shotangle), GetY + dist*sin(shotangle));
shotangle += mod;
dist+=0.2;
if(mod <= 4){mod += 0.2;}
timer++;
yield;
}
while(Obj_BeDeleted(sphere_id) == false && timer > 250){
let chase = GetAngleToPlayer;
loop{
Obj_SetPosition(sphere_id, CX + dist*cos(shotangle), CY + dist*sin(shotangle));
//I REALLY WANT SOMETHING HERE TO MAKE IT WORK
Bullet(shotangle, Obj_GetX(sphere_id), Obj_GetY(sphere_id));
CX += 2*cos(chase);
CY += 2*sin(chase);
shotangle += 4;
timer++;
yield;
}
}
}
function Bullet(b_angle, b_x, b_y){
let p = rand_int(1, 2);
alternative(p)
case(1){
loop(5){
CreateShot02(b_x, b_y, 10, b_angle - 20, -1, 3, RED56, 3);
b_angle += 10;
}
}
case(2){
loop(7){
CreateShot02(b_x, b_y, 10, b_angle - 30, -1, 2, GREEN56, 3);
b_angle += 10;
}
}
}

Thaws

  • _m廿廿m_
Re: Danmakufu Q&A/Problem Thread
« Reply #249 on: July 11, 2009, 03:44:30 AM »
Supposing I had eight object bullets I made, and I had defined a function that fired a set of bullets from each object bullet. How do I have the function select the coordinates of one bullet of the eight, and fire it, each frame, and not fire from the remaining eight frames? It's more complicated than you'd realize. The most I have right now is something like this:
Code: [Select]
#TouhouDanmakufu
#Title[Nonspell Somethingerother]
#Text[Somethingerother Nonspell is Somethingerotherrrrrr]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
    let ImgBoss = "script\img\ExRumia.png";
let frame = 0;


    @Initialize {
        SetLife(2000);
        SetTimer(50);
        SetScore(1000000);

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

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

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
if(frame == 120){
FSpheres;
frame = 0;
}
yield;
frame++;

    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
    }

    @Finalize {
        DeleteGraphic(ImgBoss);
    }
function FSpheres{
let ang = GetAngleToPlayer;
ascent(i in 0..8){
TSpheres(ang + i*45, i);
}
}
task TSpheres(let shotangle, let i){
let dist = 0;
let timer = 0;
let mod = 1;
let CX = GetX;
let CY = GetY;
let sphere_id = Obj_Create(OBJ_SHOT);
Obj_SetPosition(sphere_id, GetX, GetY);
ObjShot_SetDelay(sphere_id, 5);
ObjShot_SetBombResist(sphere_id, true);
ObjShot_SetGraphic(sphere_id, RED02);
while(Obj_BeDeleted(sphere_id) == false && timer <= 250){
Obj_SetPosition(sphere_id, GetX + dist*cos(shotangle), GetY + dist*sin(shotangle));
shotangle += mod;
dist+=0.2;
if(mod <= 4){mod += 0.2;}
timer++;
yield;
}
while(Obj_BeDeleted(sphere_id) == false && timer > 250){
let chase = GetAngleToPlayer;
loop{
Obj_SetPosition(sphere_id, CX + dist*cos(shotangle), CY + dist*sin(shotangle));
//I REALLY WANT SOMETHING HERE TO MAKE IT WORK
Bullet(shotangle, Obj_GetX(sphere_id), Obj_GetY(sphere_id));
CX += 2*cos(chase);
CY += 2*sin(chase);
shotangle += 4;
timer++;
yield;
}
}
}
function Bullet(b_angle, b_x, b_y){
let p = rand_int(1, 2);
alternative(p)
case(1){
loop(5){
CreateShot02(b_x, b_y, 10, b_angle - 20, -1, 3, RED56, 3);
b_angle += 10;
}
}
case(2){
loop(7){
CreateShot02(b_x, b_y, 10, b_angle - 30, -1, 2, GREEN56, 3);
b_angle += 10;
}
}
}

If I'm understanding what you mean correctly, you want each object bullet to carry out the Bullet function per 8 frames but never at the same time as the others, right?
You can let a counter varible = 1 inside the TSpheres task and add 1 to it like the timer varible. After the counter++; statement, add a if(counter == 9){counter = 1;}
Then use if(counter == i){fire Bullet function}.
I think this should work...

Hat

  • Just an unassuming chapeau.
  • I will never be ready.
Re: Danmakufu Q&A/Problem Thread
« Reply #250 on: July 11, 2009, 03:52:16 AM »
Hmm... See, the trouble is, I'm trying to randomize which bullet fires. Then, it kind of becomes a shot-inna-dark scenario (this is what I was planning originally, but I thought it would look weird). I need to have a rand_int(0, 8 ) called somewhere not within the task (or else it will be called eight times, coz of the while statement), and then contrast 'i' with that.

EDIT: I actually tried this, and it almost looks okay. It's impossible to win (I put WAAAAAY too many bullets in, will have to put a '&& timer%x' in with the 'if' statement you described), but there's a weirder problem. After the first bullet cluster exits the screen, bullets start SPEWING from the top left corner. Is there any way I could incorporate Obj_BeDeleted into the Bullet function, and make that... not happen? XD
« Last Edit: July 11, 2009, 03:58:35 AM by Karfloozly »

Thaws

  • _m廿廿m_
Re: Danmakufu Q&A/Problem Thread
« Reply #251 on: July 11, 2009, 04:30:28 AM »
After the first bullet cluster exits the screen, bullets start SPEWING from the top left corner. Is there any way I could incorporate Obj_BeDeleted into the Bullet function, and make that... not happen? XD

I'm not quite sure what's causing the top left bullets, something like the bullets are fired after the TSpheres are deleted, right?
I tried your script, and somehow, it worked fine after I incuded
   SetShotAutoDeleteClip(30, 30, 30, 30);
in the @Initialize.

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #252 on: July 11, 2009, 04:46:54 AM »
Hmm... Have you tried creating an array of object bullets? It's quite simple to make, and doesn't even need a task, or even a FUNCTION! Well, I think. I've tested with a subroutine, and it worked fine, since it requires no yields.... Anyways, the basic code you need is this:


Code: [Select]
sub BulletArray
{
    let i = 0
    while(i < length(Array))
    {
        if(Obj_BeDeleted(Array[i]))
        {
           Array = erase(Array, i);
           i--;
        }
        else
        {
            *do stuff to the bullet here*
        }
        i++;
    }
}

You need to make Array a global variable, of course. ("let Array = [];") When you want to add bullets, set up your object as normal, but instead of modifying it after that, do something like "Array = Array ~ [obj];" and modify it in the subroutine/function/task you check the array's value in and stuff, using "Array" to access a bullet ID. Doing "Array = Array ~ [obj];" creates a new area of the array you can get an index for and stores the value of what is in the brackets, obj in this case, to that position. Doing this effectively creates an array of bullets.

I hope that makes sense... I learned this from [whoever it was that made that Random Sign "Entropy" script, I forget who it was...].

Re: Danmakufu Q&A/Problem Thread
« Reply #253 on: July 11, 2009, 05:10:06 AM »
EDIT: I actually tried this, and it almost looks okay. It's impossible to win (I put WAAAAAY too many bullets in, will have to put a '&& timer%x' in with the 'if' statement you described), but there's a weirder problem. After the first bullet cluster exits the screen, bullets start SPEWING from the top left corner. Is there any way I could incorporate Obj_BeDeleted into the Bullet function, and make that... not happen? XD
[/quote]

Oh, I had that problem. You're bullets don't stop moving (or don't delete, one or the other, I forget which is was) and (I think) when your bullets are deleted, they go to the top left corner.

What I did was made the bullets only move when they aren't deleted (At least, I'm pretty sure that's what I did..)

I'll be more sure about this on the weekend, but I know it goes something like that.

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #254 on: July 11, 2009, 06:14:49 PM »
Hey, I have a question. Nothing extremely important I need RIGHT NOW, but it's just something I'd like to have...

I'm working on a player script for Onthenet, and he wants some of the player's shots to have a small death effect when hitting enemuies, like how MarisaA's "tree" bullets explode into those green circles. The only way I can think of to get that would be to make those shots object bullets, check if they hit the boss, and if so, spawn another bullet that does no damage, animates for a bit, then dies... However, I'd like to know, are there any commands or anything I could use to have a bullet do that normally, without going through all the object stuff?

Thanks in advance, and once again, no rush for this info, it's just something small that he can live without if needed.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #255 on: July 11, 2009, 06:43:29 PM »
That's what I've been working on with Reimu for the past week.

It can be done, but I still can't figure out how to detect hitbox collision for every enemy.

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 #256 on: July 11, 2009, 06:45:21 PM »
I'm pretty sure it'll have to be object bullets. The only way to track normal bullet collision is through enemy scripts, and it only gets whether they've been hit or not, not where the bullet was.

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #257 on: July 11, 2009, 08:07:06 PM »
EDIT: Found my problem... I was using whole numbers (i.e., 5) when I meant to use DECIMALS (i.e., 0.5)... Oops. Now it works perfectly!
« Last Edit: July 11, 2009, 08:12:13 PM by pikaguy900 »

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #258 on: July 12, 2009, 05:13:50 PM »
Hiya guys, I'm rather new to this programming stuff (I don't think RPGmaker counts as programming), and I have a few questions for you...

My problem is this:



I want a bullet to spawn 100 pixels left of the boss (which is currently in the center of the screen, but not visible), and it has to be aimed at the player from the spot where the bullet appears, not where the boss is. Is there a code for that? GetAngleToPlayer only makes it aim at me from the boss' perspective.

This is what the simple shot looks like now:
Code: [Select]
CreateLaser01(GetX-100, GetY, 3, GetAngleToPlayer, 200, 10, RED02, 0);
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

Nimono

  • wat
Re: Danmakufu Q&A/Problem Thread
« Reply #259 on: July 12, 2009, 06:24:01 PM »
This is a very simple problem, and one that many people have often. Fortunately, the solution is simple, too. There's two methods you can use, both restated here before:

1: atan2. It works, as I heard it, by getting the angle from 0, 0 to the position you supply (such as GetPlayerX, GetPlayerY). However, this doesn't work in the default method, but there's a simple formula to make it work right:

atan2([Y of Target Point (where it goes to)] - [Y of Source Point (where it spawns from)], [X of Target Point] - [X of Source Point])

Thus, in your example, it'd be like this:

atan2(GetPlayerY - GetY, GetPlayerX - (GetX - 100))

That would check the angle at GetX-100, GetY, and angle to the player from there, instead of from GetX, GetY. The same can also be done in reverse (enemy minus player) for player shots to make them home in on bosses, but that, as far as I know, is the ONLY way to make them do such a thing with mere angles.

2: The absolute simplest method: SetShotDirectionType(PLAYER); That is all you have to do to make a shot get the angle to the player as Angle 0. In fact, this is the only method you can use on CreateShotA that will dynamically change according to where the player is at that point, whereas normally, you only get the value at the exact frame the bullet was spawned. This does not work for Player shots.

And that's what I know. Is there anything confusing about that? I stink at explaining half the time...

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #260 on: July 12, 2009, 06:54:28 PM »
This is a very simple problem, and one that many people have often. Fortunately, the solution is simple, too. There's two methods you can use, both restated here before:

1: atan2. It works, as I heard it, by getting the angle from 0, 0 to the position you supply (such as GetPlayerX, GetPlayerY). However, this doesn't work in the default method, but there's a simple formula to make it work right:

atan2([Y of Target Point (where it goes to)] - [Y of Source Point (where it spawns from)], [X of Target Point] - [X of Source Point])

Thus, in your example, it'd be like this:

atan2(GetPlayerY - GetY, GetPlayerX - (GetX - 100))

That would check the angle at GetX-100, GetY, and angle to the player from there, instead of from GetX, GetY. The same can also be done in reverse (enemy minus player) for player shots to make them home in on bosses, but that, as far as I know, is the ONLY way to make them do such a thing with mere angles.

2: The absolute simplest method: SetShotDirectionType(PLAYER); That is all you have to do to make a shot get the angle to the player as Angle 0. In fact, this is the only method you can use on CreateShotA that will dynamically change according to where the player is at that point, whereas normally, you only get the value at the exact frame the bullet was spawned. This does not work for Player shots.

And that's what I know. Is there anything confusing about that? I stink at explaining half the time...


Ah, it works now, I tried both of them and they did what I wanted. Thanks! ^_^

I've only used Danmakufu for a few days, still figuring out how things work. It would be nice if I could make at least one whole stage with it (or a whole game). Well, I only have two spellcards so far (Which I concider to be awesome).


Oh, another thing. Is there a space-saving time to make multiple bullets appear after each other, from a moving spot, in a span of, say, 100 frames, with 3 frames between each bullet?

In other words...

Code: [Select]
if(frame==3){
CreateShot01(GetX, GetY, 4, GetAngleToPlayer, RED01, 0);
frame=0;
}
if(frame==6){
CreateShot01(GetX, GetY, 4, GetAngleToPlayer, RED01, 0);
frame=0;
}
if(frame==9){
CreateShot01(GetX, GetY, 4, GetAngleToPlayer, RED01, 0);
frame=0;
}

etc...

It's quite a drag to make such long scripts for simple shots as this.
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

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #261 on: July 12, 2009, 07:00:24 PM »
Code: [Select]
   if(frame%3==0){
   CreateShot01(GetX, GetY, 4, GetAngleToPlayer, RED01, 0);
   }

Actually you could have just gotten rid of the bulk on yours if you wanted.

Code: [Select]
   if(frame==3){
   CreateShot01(GetX, GetY, 4, GetAngleToPlayer, RED01, 0);
   frame=0;
   }

But the former would let you do other things dependent on 'frame'.
« Last Edit: July 12, 2009, 07:02:49 PM by Drake »

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

CK Crash

  • boozer
Re: Danmakufu Q&A/Problem Thread
« Reply #262 on: July 12, 2009, 07:03:39 PM »
Slightly more detailed than Drake's response:

if (frame%3 == 0 && frame > *start frame* && frame < *end frame*){CreateShot01(GetX, GetY, 4, GetAngleToPlayer, RED01, 0);}

% works by dividing the number and getting the remainder, which will equal 0 if it divides cleanly. And in case you didn't know, && is and, || is or.

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #263 on: July 12, 2009, 07:21:04 PM »
Aha! I thought it had to do with dividing, I just couldn't find out how to actually make that work. But Drake's answer helped me out, thanks!
Onthenet's confused me even more though, can you write it in a codebox? Because I can't slice it apart to pieces that work, without getting error messages in Danmakufu.



Okay, last one for today, unless I find more questions really fast. :V
Another really common one I bet, but anyway:

I know how to make normal circles work (Read: I know where I left the txt file that has the code in it), but how do you get them to spin while moving outward?
I see it a lot in Touhou, for example Suwako's last spellcard has only that, but I'm not having luck finding the code for it.
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

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread
« Reply #264 on: July 12, 2009, 07:40:32 PM »
Do you know how to create a bullet with angular velocity? If not, look at the danmakufu basics tutorial by Blargel and you will know.

Then, if you do know how to create bullets with an angular velocity, to create spinning bulletrings you just have to create a regular bullet ring and then give every bullet the same angular velocity. just make sure that it is small enough for the bullets not being able to go full circle and return to their starting point.

I believe Suwako's last spell's bullets are programmed in a way so that their angular velocity decreases over time, but I don't exactly know to which degree. You'd have to tinker with the numbers a little, I guess.
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."

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #265 on: July 12, 2009, 08:02:48 PM »
Modulus works this way. Take for example the frame%3==0.

frame = 1
1/3 = 0.33
33 is not zero, so nothing happens.

frame = 2
2/3 = 0.66
66 is not zero, so nothing happens.

frame = 3
3/3 = 1(.0)
It's 0, so the statement is true.

frame = 12
12/3 = 4(.0)
Statement is true.

frame = 25
25/3 = 8.33
Nothing happens.

Get it? Onthenet's is just if you want to do something for a set time and then stop.

Code: [Select]
if(frame%3==0 && frame>300 && frame<600){
    CreateShot01(GetX, GetY, 4, GetAngleToPlayer, RED01, 0);
}

It will wait 300 frames, then fire every 3 frames for another 300 frames.

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

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #266 on: July 12, 2009, 08:07:01 PM »
Do you know how to create a bullet with angular velocity? If not, look at the danmakufu basics tutorial by Blargel and you will know.

Then, if you do know how to create bullets with an angular velocity, to create spinning bulletrings you just have to create a regular bullet ring and then give every bullet the same angular velocity. just make sure that it is small enough for the bullets not being able to go full circle and return to their starting point.

I believe Suwako's last spell's bullets are programmed in a way so that their angular velocity decreases over time, but I don't exactly know to which degree. You'd have to tinker with the numbers a little, I guess.


I got that far, but the thing is, I can't find a way to link created shots with the circle.

This are the bits and piece I have so far:

Code: [Select]
if(frame==20){
CreateShotA(1, GetX, GetY, 0);
SetShotDataA(1, 30, 2, GetAngleToPlayer, 1, 0, 7, RED02);
}



if(frame==60){
let a   = 0;
let num = 24; //
        loop(num)
{
CreateShot01(GetX, GetY, 3, a+GetAngleToPlayer, RED01, 0);
a += 360/num;
}



if(frame==60){
FireShot(1);
frame=0;
}
}


In short: I made a big spinning bullet script and a circle script split in 3. Right now it shoots a circle with no special movement, and a single spinning bullet.
How do I modify it so it will replace the normal moving bullets with the new spinning bullets?




Drake:
Ah, okay. I found my own way to do that as well:

Code: [Select]
if(frame%6==0){
if(frame<=60){
CreateShot01(GetX, GetY, 4, GetAngleToPlayer, RED01, 0);
    }
}

if(frame==120){
frame=0;
}

As long as the frames not above 60 it won't shoot.

But the other way seems interesting too, thanks for sharing!
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

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread
« Reply #267 on: July 12, 2009, 08:28:50 PM »
I got that far, but the thing is, I can't find a way to link created shots with the circle.

This are the bits and piece I have so far:

Code: [Select]
if(frame==20){
CreateShotA(1, GetX, GetY, 0);
SetShotDataA(1, 30, 2, GetAngleToPlayer, 1, 0, 7, RED02);
}



if(frame==60){
let a   = 0;
let num = 24; //
        loop(num)
{
CreateShot01(GetX, GetY, 3, a+GetAngleToPlayer, RED01, 0);
a += 360/num;
}



if(frame==60){
FireShot(1);
frame=0;
}
}

In short: I made a big spinning bullet script and a circle script split in 3. Right now it shoots a circle with no special movement, and a single spinning bullet.
How do I modify it so it will replace the normal moving bullets with the new spinning bullets?
Umm...
If you think that your code should create a ring that spirals outwards, you probably didn't understand how the ShotA commands work properly.  You have to create a bullet with CreateShotA, configure its behaviour using SetShotDataA and then fire it with FireShotA. You have to repeat this three steps for every single bullet.

Thus, a correct version of the code would look like this:

Code: [Select]
if(frame==60){
let a   = 0;
let num = 24; //
        loop(num){
             CreateShotA(1, GetX, GetY, 0);
             SetShotDataA(1, 0, 2, GetAngleToPlayer+a, 0.5, 0, 7, RED02);
                     FireShot(1);
     a += 360/num;
}
       }
This, or at least a variation of this, should work.



On an entirely different note, am I the only one who uses the ascent function? All you other folks seem to always create regular loops in which a variable is increased. Am I missing something here?
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."

puremrz

  • Can't stop playing Minecraft!
Re: Danmakufu Q&A/Problem Thread
« Reply #268 on: July 12, 2009, 08:35:38 PM »
Thank you, now it works the way I want it :D
There was no sample script for this that explained it enough, so I had no idea it worked like this. I would never have guessed ^^;
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

Drake

  • *
Re: Danmakufu Q&A/Problem Thread
« Reply #269 on: July 12, 2009, 09:00:31 PM »
You use ascent when you need a temporary variable, and usually for spawning mass amounts of bullets. When you have something that you need for more than one event, you increment it.

Well, more or less. It's pretty situational.

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