Author Topic: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)  (Read 152869 times)

Drake

  • *
« Last Edit: July 11, 2011, 03:43:23 PM by Helepolis »

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

CK Crash

  • boozer
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #1 on: April 26, 2011, 11:50:13 PM »
this keeps happening:

-Play menu song
-Fade out menu song
-Play boss song
-Boss battle and shit
-Fade out boss song
-Try to play menu song again
-It plays but begins fading immediately?

what do

Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #2 on: April 27, 2011, 12:18:49 AM »
You tried deleting and reloading it after fading/stopping?

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

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #3 on: April 27, 2011, 01:09:06 AM »
question

Try FadeOutMusic("menu music", -5000); or some really small/low number. I haven't tested, but it might actually work.

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #4 on: April 27, 2011, 10:41:19 PM »
What does CreateEnemyBossFromSingleScriptFile(); do?

Found in stage0.txt

CK Crash

  • boozer
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #5 on: April 27, 2011, 10:46:09 PM »
If there isn't a function with that name defined in the script, it might be a deprecated version of CreateEnemyBossFromFile. I'd imagine you could use it when you want a single pattern midboss or something?

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #6 on: April 27, 2011, 10:57:20 PM »
What does CreateEnemyBossFromSingleScriptFile(); do?

Found in stage0.txt

If it isn't listed on the wiki, you can probably safely ignore it. It's probably 99% certain none of us would know either anyway. If you're truly curious, try it yourself in a stage script and see what happens.

Here's my theory though. First of all, correct me if I'm wrong, but stage0.txt is an internal script from the .dat file right? It sounds like it's used as the "stage" that Single and maybe Plural enemies would be spawned in. If that's the case, then CreateEnemyBossFromSingleScriptFile is likely a version of the CreateEnemyBossFromFile function that the average scripter isn't supposed to use because it would read from memory which script file was selected in the dnh menu and spawn it at a predetermined position. Judging from the naming, it looks like there might be a CreateEnemyBossFromPluralScriptFile as well.
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #7 on: April 28, 2011, 01:12:50 PM »
Where are the tutorials to learn how to make menu screen and stage transitions  :V
Hey There !

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #8 on: April 28, 2011, 02:41:11 PM »
Where are the tutorials to learn how to make menu screen and stage transitions  :V
There are none :V
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #9 on: April 28, 2011, 04:14:14 PM »
Where are the tutorials to learn how to make menu screen and stage transitions  :V

Menus aren't too hard to do. All you need is a variable to keep track of which selection you're on and something listening for the player pressing a direction. For example:
Code: [Select]
task MainMenu {
  let selection = 0;
  loop {
    if(GetKeyState(VK_UP)==KEY_PUSH){ selection--;}
    if(GetKeyState(VK_DOWN)==KEY_PUSH){ selection++;}
    yield;
  }
}

Of course, how it is now, if you have only, for example, 5 menu items, the selection can go beyond that so you need to make it wrap around:
Code: [Select]
let selection = 0;
task MainMenu {
  let menuItems = 5; // how many menu items there should be.
  loop {
    if(GetKeyState(VK_UP)==KEY_PUSH){ selection--;}
    if(GetKeyState(VK_DOWN)==KEY_PUSH){ selection++;}
    if(selection >= menuItems){ selection = 0; }
    if(selection < 0){ selection = menuItems-1; }
    yield;
  }
}

You might notice I made the items count from 0 to 4 instead of 1 to 5. That's cause I'm a silly programmer person that counts from 0, but you can count from 1 to 5 if you wanted. Anyways, now that you have the logic down for this basic menu, you have to draw it. You can use either DrawText in the @DrawLoop, or if you're feeling fancy, effect objects. Generally, the only thing you'll be doing with the drawing is checking what value selection is and highlighting the corresponding menu choice. This is why I put selection outside of the task; we want other functions to be able to read it.

Now that we're displaying and controlling the menu, we actually need to let the player be able to select the choices. We'll be using the shot key for this of course.
Code: [Select]
let selection = 0;
let location = "main";
task MainMenu {
  let menuItems = 5; // how many menu items there should be.
  loop {
    if(GetKeyState(VK_UP)==KEY_PUSH){ selection--;}
    if(GetKeyState(VK_DOWN)==KEY_PUSH){ selection++;}
    if(selection >= menuItems){ selection = 0; }
    if(selection < 0){ selection = menuItems-1; }

    if(GetKeyState(VK_SHOT)==KEY_PUSH){
      alternative(selection)
      case(0){
        StoryStart; // Of course you're going to have to write these functions
        location = "story";
      }
      case(1){
        StagePractice;
        location = "stage practice";
      }
      case(2){
        SpellcardPractice;
        location = "spellcard practice";
      }
      case(3){
        MusicRoom;
        location = "music room"
      }
      case(4){
        ClearStage; //generally the last choice is to quit the game so we'll exit out of the game
      }
      return; //now that the player chose something, we can let the main menu task end. If it's needed again, just call the task again.
    }
    yield;
  }
}

These are just the basics of menu creation. You should also program things that happen when the player presses a cancel key so they can go backwards in menus. It should be fairly intuitive now how you add stuff to menus. Other things you can play around with is an options menu and unlockables. These might be a bit more complicated but possible to do with the information and examples I've given. For organization's sake, I believe it's better to have each separate menu as a separate task and to end each task as the player leaves that particular menu. It saves a lot of headache to do it that way instead of stuffing the whole menu system inside a single task (like I did my first time). Don't forget to update the location variable every time so that your menu drawing functions know what to draw.

As for stage transitions, just make a task that covers the screen with an effect object and draws whatever text you want on it while loading the textures and sounds for the next stage. After a while, make it wait until the player presses the shot key and fade the effect away and start the next stage task.
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Atfyntify

  • Danmakufu worshipper
  • I worship Danmakufu
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #10 on: April 28, 2011, 05:32:31 PM »
sooooo...as I remember before the danmakufu request thread expired, I remember someone requesting a yukari and yuyuko. there is already a yukari and reimu border team script and there isn't a yuyuko solo one so I decided to make one. and then I was visiting the player script tutorial that Stuffman made and I made yuyuko but there was an error

http://pastebin.com/zNnurp8G
« Last Edit: April 29, 2011, 07:53:44 AM by Helepolis »
I CAN'T WAIT FOR TOUHOU 14!

Zengar Zombolt

  • Space-Time Tuning Circle - Wd/Fr
  • Green-Red Divine Clock
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #11 on: April 28, 2011, 05:44:36 PM »
Your spritesheet seems to be called img_yuyuko, not img_sprite.

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #12 on: April 28, 2011, 06:08:46 PM »
sooooo...as I remember before the danmakufu request thread expired, I remember someone requesting a yukari and yuyuko. there is already a yukari and reimu border team script and there isn't a yuyuko solo one so I decided to make one. and then I was visiting the player script tutorial that Stuffman made and I made yuyuko but there was an error

Code: [Select]
Massive code that probably should've been pastebin'd

But and kept getting an error saying that this part was wrong:
Code: [Select]
ObjEffect_SetTexture(objoption,img_sprite); 
    ObjEffect_SetRenderState(objoption,ALPHA);

Also, Obj_SetAlpha doesn't work for for effect objects. You need to use ObjEffect_SetVertexColor(id, vertex, red, green, blue, alpha) after creating the vertices in order to change the alpha.
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

puremrz

  • Can't stop playing Minecraft!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #13 on: April 28, 2011, 08:13:10 PM »
This one is killing me:

First I have this:

Code: [Select]
let arraysize=GetCommonDataDefault("SpellcardData",[0]);
loop(10){
arraysize=arraysize~[0];
SetCommonData("SpellcardData",arraysize);
}

Which is all okay and working.
It's an array that is supposed to keep track which spellcard has been cleared on which difficulty.

But then I do this:

Code: [Select]
if(GetCommonData("SpellcardData"[spellcardnumber])<spellcarddifficulty){
 SetCommonData("SpellcardData"[spellcardnumber],4);
}

And it errors when it tries to compare the value of the array (spellcardnumber, which I set to 1 for testing) with a normal variable (spellcarddifficulty, an integer which ranges from 1-4).
How can I fix 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: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #14 on: April 28, 2011, 08:22:01 PM »
"SpellcardData"[spellcardnumber] will give you characters of the string "SpellcardData", and then it will get that commondata, and etc you get the picture.

if(GetCommonData("SpellcardData")[spellcardnumber]<spellcarddifficulty){
is what you want, but you can't actually set individual indices of an array stored as commondata. You have to give it the entire array, which means you have to edit the index of a global array first, and then hand it to the commondata (as you did in your first snippet).

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

puremrz

  • Can't stop playing Minecraft!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #15 on: April 28, 2011, 08:40:26 PM »
"SpellcardData"[spellcardnumber] will give you characters of the string "SpellcardData", and then it will get that commondata, and etc you get the picture.

if(GetCommonData("SpellcardData")[spellcardnumber]<spellcarddifficulty){
is what you want, but you can't actually set individual indices of an array stored as commondata. You have to give it the entire array, which means you have to edit the index of a global array first, and then hand it to the commondata (as you did in your first snippet).

Now it's no longer crashing, which is good. But I'm a little confused about the last part.

Since this spellcard is cleared, I want to change my CommonData from [0,0,0,0,0... to [0,3,0,0,0... (since it's spellcard 2 and it's cleared on Hard).
You just told me to, but I don't understand how I could match this together with the piece of code that creates the CommonData in the beginning.

All I can think of is this:
Code: [Select]
SetCommonData("SpellcardData"[spellcardnumber],spellcarddifficulty);But that's wrong.
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

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #16 on: April 28, 2011, 08:57:13 PM »
I don't mean to be mean or anything, but I'm surprised yet again by how far you've gotten in your game despite the fact that you lack the knowledge of a lot of important computer science concepts.

Anyways, Drake said you cannot set the value of something directly inside an array if it's still stored in common data. Therefore, you have to take out the array, change it, and then pass in the whole array back to the SetCommonData. In code it looks like this:
Code: [Select]
let spellcardData = GetCommonData("SpellcardData");
spellcardData[1] = 3;
SetCommonData("SpellcardData", spellcardData);
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

puremrz

  • Can't stop playing Minecraft!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #17 on: April 28, 2011, 09:06:38 PM »
I don't mean to be mean or anything, but I'm surprised yet again by how far you've gotten in your game despite the fact that you lack the knowledge of a lot of important computer science concepts.

:V
That's because I had 0 knowledge of such things even before I started! Ohohoho! (Blame Kanako for getting me into Danmakufu)
Though, Danmakufu doesn't need to get too complicated, most of the time, to make nice things in it. Luckily that has already been taken care of by the programmer of Danmakufu.

Anyway, thanks, that worked. Even though my code is everyone's nightmare, this should really be everything I need to know, unless I come up with more genious customization ideas...
After all, I keep learning new things and improvements as I go.
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

DgBarca

  • Umineko fuck yeah
  • Spoilers ?
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #18 on: April 28, 2011, 10:58:38 PM »
Common Data Ex problem
On a stage init, I have that to get the High Score, stored in a Score.dat
Code: [Select]
LoadCommonDataEx("Top_Score",GCSD~"PROJET\DATA\Score.dat");
  if(!IsCommonDataAreaExists("Top_Score")){
CreateCommonDataArea("Top_Score");
SetCommonDataEx("Top_Score","MaxScore",200);
  }

@MainLoop {
   SaveCommonDataEx("Top_Score", GCSD~"PROJET\DATA\Score.dat"); //laggy, but for demo purpose.
}

Normally, it would get the category in the file, and if it doesn't exist, create it
However, it seems that it reset every time (at 200).
[21:16] <redacted> dgbarca makes great work
[21:16] <redacted> i hope he'll make a full game once

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #19 on: April 28, 2011, 11:16:16 PM »
I've tried playing around with saving and loading common data with the Ex functions but with no real success. Have you gotten ex common data to save and load correctly before? If not, I suggest to just store the stuff you want saved in normal common data and use the ex functions to handle the common data that doesn't need to be saved (like intercommunication between scripts). Stuff stored with the ex functions won't be saved with the normal SaveCommonData function.

If you insist on using the ex functions, just keep playing around with it. Post discoveries and such 'cause I'm curious too. One suggestion I can think of is to create the common data area first before attempting to load. Perhaps Danmakufu needs a common data area to stick the data into and doesn't load the data if it can't find the area you specified.
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Nimono

  • wat
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #20 on: April 29, 2011, 12:00:01 AM »
Okay, so I just met a problem while messing with effect objects.

http://pastebin.com/rEBTW833

I'm trying to get this in the shape of a star. I have a picture file of a star shape, and that worked fine before, but the stars are supposed to spin, and I didn't like how it looked like they weren't centered, so I figured I'd try to mess with the number and positioning of the vertices to get the shape. Surprisingly, I actually got it on my first try. There's just one problem: for some reason, there's two points (it looks to be vertices 0, 2, and 8, top left and top right if you remove the "+rotangle" stuff) where there's a blob outside the star shape, as if it's trying to connect those vertices, for some reason. It doesn't really make much sense to me, since all the other vertices are working just fine. Could it be because of the values I gave for the UV stuff? I don't really know how I'd match those up "correctly" without using a power of four for the amount of vertices... I'd appreciate any help.

EDIT:

http://i244.photobucket.com/albums/gg13/MatthewPZC/snapshot023b.jpg this is what I'm talking about
« Last Edit: April 29, 2011, 12:23:14 AM by Riolu180 »

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #21 on: April 29, 2011, 01:03:29 AM »
Well, you're really doing things the hard way, so there isn't that much I can do to help you. What I'd do is use objxpos and objypos as parameters for Obj_SetPosition, leave the XY vertices alone, and use ObjEffect_SetAngle. Then again, I'd also use four vertices, so...

I'm having a problem with common data. Relevant functions and subroutines: http://pastebin.com/ypmq5Ses
So BGD_Frame is used to draw the stage background. Oddly enough, selecting the stage works perfectly. It's the floor selection that's a problem. Door and Stairs each reset the player's location and, thanks to the structure of my task system, open a new wave of enemies. Upon ascending or descending Stairs, the common datum "floorNum" changes according to what I input for the function. That works, too; in the first new room, the background changes accordingly.
But when I go through a door on the new floor, it shows the background for the floor the player was just on. Id est, if I go from floor one to floor two and through another door, floor one's background shows. And if I go from floor two to floor one and through a door, floor two's background shows. What incredibly derpy thing could I be overlooking?

Nimono

  • wat
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #22 on: April 29, 2011, 01:10:00 AM »
Well, you're really doing things the hard way, so there isn't that much I can do to help you. What I'd do is use objxpos and objypos as parameters for Obj_SetPosition, leave the XY vertices alone, and use ObjEffect_SetAngle. Then again, I'd also use four vertices, so...

Well, like I said, I'm using 10 just to ensure that the star rotates smoothly. I do NOT feel like spending hours, maybe days, trying to draw a star graphic that rotates perfectly so it looks the same no matter which of the points is pointing up. :/ Also, the objxpos/objypos stuff was taken from the player script tutorial. I've always done it like this...

EDIT: Agh, I figured it out. It's because of how the triangle fan works, so it's making triangles out of the top point and every other point on the star...ugh, how will I fix this without using too many vertices? I've already got it fixed, but it'll use 12 vertices... I've found a way to do 9, but I get the feeling that if I ever decide to try to put an actual texture on this, it'll look terrible...
« Last Edit: April 29, 2011, 01:29:12 AM by Riolu180 »

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #23 on: April 29, 2011, 07:21:57 AM »
I found this laser shot sheet somewhere. Then I realize that this is the laser sheet I've been looking for all over (the mini-lasers used at Shou's stage and Byakuren's 3rd spell)!
However, The problem is that I don't know how to use it in Danmakufu (or should I say, I don't know what to type in the shot.txt thingy). And also, I also like to use other shotsheets for spawning other bullets (Yuyuko Butterflies and other bullets, since I'm making a Yuyuko script), but doing so in the same script might cause a conflict in the bullet's image.
If anyone knows how to use 2 shotsheets in one script, or to include the lasersheet to the shotsheet, please do.
Please notify me if I'm violating any rules. ><

Here's the UFO laser image: http://i563.photobucket.com/albums/ss73/seannavarro_and_pikachu/etama9.png

And here's the shotsheet I'm using:
http://i563.photobucket.com/albums/ss73/seannavarro_and_pikachu/supershot.png
« Last Edit: April 29, 2011, 07:54:15 AM by Helepolis »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #24 on: April 29, 2011, 07:58:11 AM »
First, welcome to the forums and RikaNitori. Violation of rules, well. . . posting screens over 640x480 and/or 150kb is frowned up. So I fixed it this time for you.

About your question:

Quote from: LostCelesti
However, The problem is that I don't know how to use it in Danmakufu (or should I say, I don't know what to type in the shot.txt thingy).
As you said it yourself: You don't know how to use it.

I would advise you to first learn the tutorial about custom shotsheets. This simply makes you understand how those shotsheets (images which you posted), make sense and how they are used. What you want to do is possible, but requires the lasers to be put inside the image of the bullets (seeing there is enough space).



Atfyntify

  • Danmakufu worshipper
  • I worship Danmakufu
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #25 on: April 29, 2011, 04:42:12 PM »
Quote
Yuyuko Butterflies and other bullets, since I'm making a Yuyuko script

Danmakufu has default bullets which you can use. and that including butterflies. check the bullets out here: http://en.touhouwiki.net/wiki/Touhou_Danmakufu:_Bullets
I CAN'T WAIT FOR TOUHOU 14!

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #26 on: April 29, 2011, 06:39:00 PM »
I'm having a problem with common data. Relevant functions and subroutines: http://pastebin.com/ypmq5Ses
So BGD_Frame is used to draw the stage background. Oddly enough, selecting the stage works perfectly. It's the floor selection that's a problem. Door and Stairs each reset the player's location and, thanks to the structure of my task system, open a new wave of enemies. Upon ascending or descending Stairs, the common datum "floorNum" changes according to what I input for the function. That works, too; in the first new room, the background changes accordingly.
But when I go through a door on the new floor, it shows the background for the floor the player was just on. Id est, if I go from floor one to floor two and through another door, floor one's background shows. And if I go from floor two to floor one and through a door, floor two's background shows. What incredibly derpy thing could I be overlooking?
I don't think there's enough info to debug this. What you have shown us doesn't really have any issues that I can see so the problem might be elsewhere.
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #27 on: April 29, 2011, 08:50:51 PM »
NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO >_<

Well, at least I know where the problem isn't.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #28 on: April 30, 2011, 02:48:57 AM »
I'm trying to make a shot type with the 'options' or 'satelites' are spinning and the bullets are going in all directions, kinda like Reimu C's in SA, but are always spinning, not shooting where you last moved. is it possible, or am I just hoping for something impossible.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #29 on: April 30, 2011, 03:30:09 AM »
Been a long time since I've visited this place (or danmakufu, for that matter, so bear with me or don't, your choice).

I decided to start messing with danmakufu for the first time in months and still focusing on spell cards, so I am experimenting with object bullets some more. I had an idea after getting Yuyuko's graphic to function as a boss that involves setting up two different object bullets.

Idea: Fire a bunch of butterflies (obj/first object) randomly that soon come to a stop, have them change angle, then fire a ring of large bullets (obj2/second object). When collision detection is successfully performed between the two objects, the butterflies will begin to accelerate (like a wave [think of the Explosion[#, #, #, #] function] spreading outward and "reanimating" the butterflies).

Problem: The butterflies work fine, but I cannot figure out how to fire more than one obj2 bullet and have the code that permits the collision detection for obj1 at the same time.

E.X. 1:
Code: [Select]
script_enemy_main{
let count = 0;
let a = 0;
let s = 1;
let color = 223;
let reanimation = 0;
let obj2 = Obj_Create(OBJ_SHOT);

(then after @Finalize)

task reanimate(speed, angle) {
     let obj = Obj_Create(OBJ_SHOT);
     let a = rand(-5, 5);
     let objreanimation = 0;

     Obj_SetPosition(obj, GetX, GetY);
     Obj_SetAngle(obj, angle);
     Obj_SetSpeed(obj, speed);
     ObjShot_SetGraphic(obj, 208);
     ObjShot_SetDelay(obj, 5);
     ObjShot_SetBombResist(obj, true);
     Obj_SetCollisionToObject(obj, true);
     Obj_SetCollisionToPlayer(obj, true);
     Obj_SetAlpha(obj, 255);


     while(Obj_BeDeleted(obj)==false){
     let objspeed=Obj_GetSpeed(obj);

if(objspeed > 0){Obj_SetSpeed(obj, objspeed - 0.05);}
if(objspeed < 0){Obj_SetSpeed(obj, 0);}

if(reanimation == 1){
Obj_SetAngle(obj, Obj_GetAngle(obj) + a);
}

if(Collision_Obj_Obj(obj, obj2)){
objreanimation = 2;
}
if(objreanimation == 2 && objspeed < 2){
ObjShot_SetGraphic(obj, 209);
Obj_SetSpeed(obj, objspeed + 0.005);
}



       yield;
}
}

task reanimateshot(speed, angle) {
     let obj2 = Obj_Create(OBJ_SHOT);

     Obj_SetPosition(obj2, GetX, GetY);
     Obj_SetAngle(obj2, angle);
     Obj_SetSpeed(obj2, speed);
     ObjShot_SetGraphic(obj2, 236);
     ObjShot_SetDelay(obj2, 5);
     ObjShot_SetBombResist(obj2, true);
     Obj_SetCollisionToObject(obj2, true);
     Obj_SetCollisionToPlayer(obj2, false);
     Obj_SetAlpha(obj2, 255);

     while(Obj_BeDeleted(obj2)==false){



       yield;
}
}

I have learned that adding  let obj2 = Obj_Create(OBJ_SHOT);  into the actual object's task (in this case, reanimateshot) just overwrites the original   let obj2 = Obj_Create(OBJ_SHOT);. This lets the script continue normally, but the object collision between obj and obj2 does not happen because obj2 is redefined in its own task and no longer associated with obj1. This is fine, but then I try this:

E.X. 2:
Code: [Select]
let obj2 = Obj_Create(OBJ_SHOT);

(then after @Finalize)

task reanimateshot(speed, angle) {

     Obj_SetPosition(obj2, GetX, GetY);
     Obj_SetAngle(obj2, angle);
     Obj_SetSpeed(obj2, speed);
     ObjShot_SetGraphic(obj2, 236);
     ObjShot_SetDelay(obj2, 5);
     ObjShot_SetBombResist(obj2, true);
     Obj_SetCollisionToObject(obj2, true);
     Obj_SetCollisionToPlayer(obj2, false);
     Obj_SetAlpha(obj2, 255);

     while(Obj_BeDeleted(obj2)==false){



       yield;
            }
}

(then in the main task)

if(count == 360){
a = rand(0, 360);
loop(20){
reanimateshot(3, a);

a += 360/20;
}
}

So the task [reanimate] now recognizes obj2 properly which is half of what I want. The other half of the problem still unsolved is that obj2 does not loop more than once (the complete opposite of the previous example), so rather than having twenty bubbles moving and activating all of the butterflies, there is only one bubble that activates a single line of butterflies. How can I loop obj2 so that the twenty bubbles that I want all appear while retaining the collision detection with obj1? I do not want to end up having to create twenty separate object bullets (x20 more lines) just to complete that ring of bubbles and trigger the collision detection at the same time. It is probably right under my nose, but isn't there a simpler way to do it?