Author Topic: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m [Closed, read last post!]  (Read 186300 times)

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #210 on: August 06, 2013, 04:38:55 PM »
Thank you, it works perfectly.

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #211 on: August 08, 2013, 12:18:26 PM »
Is it possible to make a bullet home in on the player while curving?
 Example:
A bullet is fired from an enemy at the top middle of the screen at 0 degrees.(something like GetCenterX,GetCenterY-120)
I want it to curve towards the player, in a way that it has an angle of ~180 degrees when it arrives at the location of the player.

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #212 on: August 09, 2013, 12:08:42 AM »
For sure, but how you do it depends on how you want the bullet to move on the way there. The common thing people do is to move the bullet at some constant velocity, fire it at some angle, and then each frame or so ask the bullet for its angle to the player (using the usual atan2 parameters). If the bullet's angle is less than that, increase its angle by some fixed amount. If it's more, decrease its angle by some amount.
This is the general behaviour of patterns like Shinki's curvy toothpaste lasers, where you limit the accuracy of the homing in order to let the player dodge at the last moments.

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

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #213 on: August 09, 2013, 09:09:16 AM »
Thank you, that almost works as intended.

The problem is that the bullets fired on the right side will curve upwards instead of towards the player.
Is there anyway to change this so that they will curve the right way?
My current code is this:

Code: [Select]
task fire{
loop{
PlaySE(shot0);
ascent(angle in 0..17){
curve(GetEnemyX,GetEnemyY,3,90+22.5*angle,249,10);
}
wait(120);
}
}

task curve(x,y,velocity,angle,graphic,delay){
let obj = Obj_Create(OBJ_SHOT);

Obj_SetPosition(obj,x,y);
Obj_SetSpeed(obj,velocity);
Obj_SetAngle(obj,angle);
ObjShot_SetGraphic(obj,graphic);
ObjShot_SetDelay(obj,delay);
ObjShot_SetBombResist(obj,true);

while(!Obj_BeDeleted(obj)){
let playerangle = atan2(GetPlayerY-Obj_GetY(obj),GetPlayerX-Obj_GetX(obj));

if(Obj_GetAngle(obj)>playerangle){
Obj_SetAngle(obj,Obj_GetAngle(obj)-1);
}

if(Obj_GetAngle(obj)<playerangle){
Obj_SetAngle(obj,Obj_GetAngle(obj)+1);
}
yield;
}
}

The other way I could think of was using a familiar with the graphic of a bullet and use SetMovePositionHermite, but I couldn't find out how large the hitboxes of bullets are so that wouldn't work either.
« Last Edit: August 09, 2013, 09:17:32 AM by KuroArashi100 »

Darkness1

  • Nothing to see here.
  • Enigmatic, isn't it?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #214 on: August 09, 2013, 01:27:20 PM »
The problem is that the bullets fired on the right side will curve upwards instead of towards the player.
Is there anyway to change this so that they will curve the right way?
You have to convert the angle to an angle between 0 and 360 and then check if the first angle is 180 or -180 degrees off compared to the other angle. Here are the functions that are used for this, if you want to study them or something. http://pastebin.com/Z2SEMN5E
( Credit goes to Blargel for making most of this. I just put it all together. )

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #215 on: August 09, 2013, 01:59:56 PM »
Okay, thank you!

Qwertyzxcv

  • yas
  • k!
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #216 on: August 09, 2013, 11:42:13 PM »
So I'm trying to make a player script but when I bomb it crashes at the end. D:
Code for bomb: http://pastebin.com/F4JyQZvt
And on that topic, is there a way to remove the time stop at the beginning of a bomb?

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #217 on: August 10, 2013, 03:33:46 AM »
http://pastebin.com/Z2SEMN5E
Code: [Select]
function amod(a){ return (a+360)%360; }
screw ifs and long function names


So I'm trying to make a player script but when I bomb it crashes at the end. D:
Code for bomb: http://pastebin.com/F4JyQZvt
And on that topic, is there a way to remove the time stop at the beginning of a bomb?
? The pause is part of the Cutin function, so if you're using it, stop.
? Your type if-chain probably should be a series of if-elseif-else rather than lots of ifs and then one else (?)
? You're missing the end part of your spell script; there aren't any routines or anywhere that calls run().

? Obj_SetAlpha() doesn't work for effect or spell objects. Use this and modify for extra vertices if needed:
Code: [Select]
function ObjEffect_SetAlpha(obj, a){
    ascent(i in 0..4){ ObjEffect_SetVertexColor(obj, i, a, 255, 255, 255); }
}

? You do that silly thing where you try and use XYs to set the bullet's render coordinates on the screen itself. It's much less confusing if you just set the XYs relative to the object position, and set the object position separately. It's how you're meant to do it.
Code: [Select]
//only once
ObjEffect_SetVertexXY(objamulet,0, -27.5, -27.5);  //size is 45x45 right
ObjEffect_SetVertexXY(objamulet,1, 27.5, -27.5);
ObjEffect_SetVertexXY(objamulet,2, 27.5, 27.5);
ObjEffect_SetVertexXY(objamulet,3, -27.5, 27.5);

//per frame
Obj_SetPosition(objamulet, amuletxpos, amuletypos);
ObjEffect_SetAngle(objamulet, 0, 0, amuletangle);

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

Qwertyzxcv

  • yas
  • k!
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #218 on: August 10, 2013, 06:18:26 PM »
Thanks that helped a lot! :D

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #219 on: August 11, 2013, 03:35:02 PM »
Anyone know how to stop the game from using the fancy little explosion? I'm trying to create a stage (for a full game) and I'm getting the bosses together and the midbosses will call a fake spell card similar to what you would do if you wanted a dialog scene before a boss battle, but when the boss leaves you can still see the white explosion in the background.

Nvm, I figured it out. However, for some weird reason, the boss leaves a gray point item.
« Last Edit: August 11, 2013, 03:42:37 PM by InfiniteWave »

Qwertyzxcv

  • yas
  • k!
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #220 on: August 11, 2013, 10:36:31 PM »
Wait how did you do that

Chau

  • Warning! Incoming Engrish post!
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #221 on: August 11, 2013, 10:56:34 PM »
I think I stumbled upon a silly problem that seems to have a simple solution, but I can't find it :(

I want to concatenate a number to a string, like "A"~2~"B" should have "A2B" as a result. But when I convert 2 to a string and concatenate these strings, it ends up being "A2.00000B".
My (temporary) solution so far is to treat the "2.00000" as an array and take the first element of it (which is a character, I think?) and convert it to a 1-character-string because attaching a single character brings up an error message.

Now the result looks like this:
Code: [Select]
"A"~ToString(ToString(2)[0])~"B"This looks really silly, so I think there has to be a better solution, right? :ohdear:

Nuclear Cheese

  • Relax and enjoy the danmaku.
    • My homepage
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #222 on: August 12, 2013, 02:04:41 AM »
I think I stumbled upon a silly problem that seems to have a simple solution, but I can't find it :(

I want to concatenate a number to a string, like "A"~2~"B" should have "A2B" as a result. But when I convert 2 to a string and concatenate these strings, it ends up being "A2.00000B".
My (temporary) solution so far is to treat the "2.00000" as an array and take the first element of it (which is a character, I think?) and convert it to a 1-character-string because attaching a single character brings up an error message.

Now the result looks like this:
Code: [Select]
"A"~ToString(ToString(2)[0])~"B"This looks really silly, so I think there has to be a better solution, right? :ohdear:

If I'm not mistaken, Danmakufu stores all numbers as floating point numbers (as opposed to integers, they can have fractional parts).  So here it's just trying to give you as much precision as it can.  Unfortunately, it doesn't seem there's a way to tell Danmakufu you only want the integer part, so you'll have to improvise.

Your code as given works fine as long as your number remains in the range of 0 .. 9.  It'll start not working if you get to 10 or above or go negative, though.  A more thorough solution would look something like this:

Code: [Select]
function Get_Integer_String(number)
{
  // Get the full string
  result = ToString(number);

  new_result = "";
  for (i = 0; i < length(result); i++)
  {
    if (result[i] == ".")
    {
      // break out of the loop.  I forget - does Danmakufu actually have this? :V
      // if it doesn't, you'll have to use a flag to break out of the loop or something.
      break;
    }
    else
    {
      new_result = new_result + result[i];
    }
  }
  return new_result;
}
(usual disclaimer: pseudo-code, may not work perfectly in DMF without modification)

The above code gets the string, then loops through the string looking for the decimal point.  It copies over the string's contents until it finds the decimal point, at which point it stops and returns the copy (which only contains digits before the decimal point).  As long as DMF doesn't return a string in scientific notation (such as "2.4E10") this should work.  You might be able to get more clever with DMF's array functions, but at the very least this should do the trick.

Hope this helps!
* Nuclear Cheese returns to being a lurking ghost.
to quote Naut:
"I can see the background, there are too many safespots."
:V

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #223 on: August 12, 2013, 02:31:23 AM »
Code: [Select]
function itoa(i){
let a = ToString(i);
return a[0..length(a)-7];
}

Just for your information, the solution you intended would have been fine (although single-digit) as "A"~[ToString(2)[0]]~"B" because danmakufu strings are just character arrays. As such, you can't concatenate a character to a string for the same reason you can't do [1,2,3] ~ 4; 4 isn't an array of the same dimension. Putting a character in an array will fix it because then it's just a 1-length string.
« Last Edit: August 12, 2013, 02:45:00 AM by Drake »

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

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #224 on: August 12, 2013, 02:39:27 AM »
Wait how did you do that

Make a empty non spell, set the life to 1(this gives the illusion that the spell doesn't exist), tell the boss to move off screen, then put something like
Code: [Select]
if(frame==50){
VanishEnemy;
}

That will delete the boss without any special effects.

The Noodles Guy

  • Flip the screen
  • What if Seija met a guy with bipolar disease?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #225 on: August 12, 2013, 06:44:09 PM »
How do I merge bullets into another bullets?
Easy Modo? That's for kids, and for me.

Drake

  • *
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #226 on: August 12, 2013, 08:29:01 PM »
Delete one of the bullets and change the other if required?

EDIT: Just to note, both the (-180,180) angle problem and the number toString problem are not an issue in ph3. -179%360 == 181 and -1%360 == 359 and so on (you have a modc() function that lets you keep the negative-number behaviour), and the atoi() function I wrote above is already present in ph3.
« Last Edit: August 12, 2013, 11:46:45 PM by Drake »

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

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #227 on: August 14, 2013, 02:08:47 PM »
How do you make a variable move between certain limits?
I want bullets to spawn at a certain Y value starting at one side and moving over to the other, then wait for a few seconds, and then the same in the other direction, but I can't find out what I'm doing wrong.
Here's the code if that helps:
Code: [Select]
task fire{
loop{
loop(25){
CreateShotA(0,GetCenterX+x+rand(-4,4),GetCenterY-80,10);
SetShotDataA_XY(0,0,0,rand(-1,-2),0,0.01,0,3,44);

FireShot(0);

if(x>=-208 && x<208){
x+=16;
}
if(x<=208 && x>-208){
x-=16;
}

wait(10);
}
wait(120);
}
}

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #228 on: August 14, 2013, 03:11:30 PM »
The problem is that both if statements are true so they move, and move back in one loop.
Code: [Select]
task fire{
                let count = 0;
loop{
loop(25){
CreateShotA(0,GetCenterX+x+rand(-4,4),GetCenterY-80,10);
SetShotDataA_XY(0,0,0,rand(-1,-2),0,0.01,0,3,44);

FireShot(0);

if(x>=-208 && x<208 && count%2==0){
x+=16;
}
if(x<=208 && x>-208 && count%2==1){
x-=16;
}

wait(10);
}
                        count++;
wait(120);
}
}
This should work.
Currently a normal player

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #229 on: August 14, 2013, 04:58:16 PM »
Thanks you very much!

But now I have another problem in another script.
The script is called as familiar, but I get an error that it maintask is not an existing function and I can't find the problem.
http://pastebin.com/e21ceiw7
Can somebody help me with this?

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #230 on: August 14, 2013, 10:59:23 PM »
Your script didn't give any errors when I tried it but it didn't do anything either. The problem is that you're calling a task inside "Initialize". I don't think you can do that.

I moved the "maintask;" to the main loop and it started working. It also creates lag due to the fire task being called every frame, use a "if" statement for fire. Like

if(frame==XX){
dosomething
}

Shadow

  • Forever waiting for tomorrow
  • ...
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #231 on: August 15, 2013, 12:15:31 AM »
The problem is that you're calling a task inside "Initialize". I don't think you can do that.

You actually can, though. If you define the given task somewhere within the script, you can call said task anywhere you want as long as you keep in mind the local scope.

As for the actual problem, this is somewhat strange--it did not give me any errors either, even when spawned as a familiar (as it was intended), and it executed the entirety of the MainTask correctly. Are you sure you did not mess up brackets somewhere? This kind of error makes it seem you prematurely closed script_enemy_main and left the MainTask outside the script, but I see no such mistake in the pastebin you provided. Here are both the familiar and a dummy boss I created for testing purposes: 1 | 2.


PhantomSong

  • The Ghost Living through Everyday Life.
  • Eh, it doesn't matter.
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #232 on: August 15, 2013, 12:16:31 AM »
The problem is that you're calling a task inside "Initialize". I don't think you can do that.

You can call tasks inside Initialize. I run mainTask and InitializeAction in it o3o
Code: [Select]
     
@Initialize{
                  SetLife(4800);   
                  SetTimer(80);
                  SetMovePosition01(GetClipMinX+10,GetClipMinY+20,10);
                  LoadGraphic(imgBoss);
                  LoadGraphic(cut);
                  LoadGraphic(bg);                 
                  MagicCircle(false);
                  LoadUserShotData(shot);
                  SetInvincibility(120);
                  InitializeAction;
                  mainTask; }

(This is for a Familiar, but same purpose applies)
« Last Edit: August 15, 2013, 12:18:03 AM by PhantomSong »

KuroArashi100

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #233 on: August 15, 2013, 05:52:37 AM »
Well, I remember it not working before... but it works now. Weird. I don't remember fixing it.
When I ran it before, it would come up with an error that maintask was undefined, and the main boss would execute all other tasks except for the familiar.

My memory sometimes fails me, and I think that's what happened; I fixed the script, and then quickly switched to doing something else and the fact that I fixed it was already forgotten.
Well, thanks for trying to figure it out anyway.

@Infinite Ultima Wave:
Calling tasks in @Initialize is indeed possible; that and mainloop scripting are different methods of scripting.
Compare this:
Code: [Select]
#TouhouDanmakufu
#Title[@MainLoop scripting]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{

let count = 0;

@Initialize{
SetLife(3000);
SetMovePosition01(GetCenterX,GetCenterY-130,3);
}

@MainLoop{
count++;

if(count==60){
CreateShot01(GetEnemyX,GetEnemyY,3,90,RED01,30);
count = 0;
}
}

@DrawLoop{

}

@BackGround{

}

@Finalize{

}
}
To this:
Code: [Select]
#TouhouDanmakufu
#Title[task based scripting]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{

@Initialize{
SetLife(3000);
SetMovePosition01(GetCenterX,GetCenterY-130,3);

mainTask;
}

@MainLoop{
yield;
}

@DrawLoop{

}

@BackGround{

}

@Finalize{

}

task mainTask{
wait(120);
fire;
}

task fire{
loop{
CreateShot01(GetEnemyX,GetEnemyY,3,90,RED01,30);
wait(60);
}
}

function wait(w){ loop(w){ yield;}}

}
Both will create a boss that will create one bullet every second aimed straight down, but the method used to generate this is different.

K+ ~ Bake-Danuki

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #234 on: August 18, 2013, 12:04:00 AM »
(People may see this if they also checked the request thread)
How do you make an invincible player?
Also, while I was working with AddShot, it doesn't work, can someone see why this doesn't work?  (just modify to use The Super Shotset (ZUN's))
Code: [Select]
if (frame == 60){
loop(4){
CreateShotA(1, GetX, GetY, 0);
SetShotDataA(1, 0, 3, angle, 1, 0, 0, rand(194,200));
SetShotDataA(1, 10, 3, NULL, 0, 0, 0, NULL);
FireShot(1);
angle+=360/4;
AddShot(15, 2, 1, 0);
CreateShotA(2, 0, 0, 0);
SetShotDataA(2, 0, 3, angle, 0, -0.5, 0, rand(134,148));
SetShotDataA(2, 30, 0, NULL, 0.5, 0.5, 4, NULL);
}
angle++;
frame = 30;
}
« Last Edit: August 18, 2013, 12:15:14 AM by K+ ~ Bake-Danuki »

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #235 on: August 18, 2013, 12:22:31 AM »
You don't add the hitbox functions in the player scripts.
The Addshot problem is because you called the second bullet to be spawned by the first bullet, but the second bullet hasn't been defined yet. Put the Addshot after defining the second bullet.
Currently a normal player

K+ ~ Bake-Danuki

Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #236 on: August 18, 2013, 12:43:01 AM »
Now i feel stupid.  :blush:   But thank you!

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #237 on: August 18, 2013, 01:35:42 PM »
Anyone know how to get rid of the glow effect lasers have? When you make a laser the laser's body is glowing and I'm using a shot sheet that has ZUN's lasers.

I even tried changing the blend and still nothing.
(oddly enough if you pause the game, the glow effect is gone)

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #238 on: August 18, 2013, 02:08:02 PM »
Anyone know how to get rid of the glow effect lasers have? When you make a laser the laser's body is glowing and I'm using a shot sheet that has ZUN's lasers.

I even tried changing the blend and still nothing.
(oddly enough if you pause the game, the glow effect is gone)

ObjLaser_SetSource(obj,boolean)

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: ※ Q&A/Problem Thread 7 ※ for Danmakufu version 0.12m
« Reply #239 on: August 18, 2013, 02:37:08 PM »
I don't think that works on sinuate lasers. What I'm talking about is not the base, but the actual laser's body.

The first picture shows what the lasers look like when fired. The second shows what the lasers should look like when fired, however, it only looks that way while the game is paused.