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

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #600 on: November 18, 2011, 06:15:30 PM »
@BackGround, not @Background. Yay, capitalization.
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #601 on: November 18, 2011, 07:56:58 PM »
There's no real way to disable the default explosion, but there are workarounds. The way I do it is having a really high number (like 10000) as "default" health, and if the enemy's health is actually 200 for example, then it gets added to that (10200). Every frame check if the health is less than 10000, and if so, VanishEnemy (and give the player points and stuff). The only problem with this is that destroyed enemies don't have DrawLoop called, and they can't manipulate effect objects either. There are two ways to bypass this.

1. Don't actually delete the enemy as soon as it's dead, just disable collision and set a timer. Draw the explosion graphic based on that timer and delete the enemy when it reaches 0. The problem is that homing player scripts will still home in to the enemy when it's exploding, but depending on how short your animation is, that might not be a problem.
2. Set common data, and have the stage create explosion graphics based on that common data. This is the one that I use, and it doesn't have the drawback mentioned above, but it's kind of hard to set up.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #602 on: November 18, 2011, 08:05:01 PM »
...and if so, VanishEnemy (and give the player points and stuff). The only problem with this is that destroyed enemies don't have DrawLoop called, and they can't manipulate effect objects either. There are two ways to bypass this.

Hmm.. Why not to call a special task just a frame before the enemy vanished so it can do all stuff like draw explosion, give items etc?

Also, what is common data and functions for it? Cant find any tutorial explaining how and why to use it.
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #603 on: November 18, 2011, 08:13:15 PM »
If you're handing out the script with its own danmakufu folder/executable/etc, as you usually would with scripts that follow their own system, you can remove the graphic by replacing the hidden img\system.png file, or by editing it if you can grab the actual file.

Hmm.. Why not to call a special task just a frame before the enemy vanished so it can do all stuff like draw explosion, give items etc?
Oh, the joys of expert danmakufu proggin'. As in, the terrors.
Once the enemy is destroyed, all tasks instantiated from the enemy script are ended. In other words, any effect objects drawn, the DrawLoop, all other functions you might want to do when the enemy dies, are stopped and deleted. This is exactly what Azure just said but you misinterpreted it; the two main workarounds are as they described. Calling "a special task" would be the second workaround: the function would set a bunch (i.e. a lot) of arbitrary common data, then the stage script would be constantly checking for altered values of the common data and if it finds some then it acts accordingly. Main issue is that it sucks. It's the most proper method to do it but it sucks assssss.

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

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #604 on: November 18, 2011, 10:20:07 PM »
Use ph3, avoid such terrors.
Spoiler:
Encounter new ones

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #605 on: November 19, 2011, 01:01:41 AM »
okay.jpg

Well. I think i'll be fine with default explosions. They look neutral and fit my project well. Let's pay more attention to gameplay and patterns! As for ph3, i'd rather wait untill it's out of beta and english documentation will be complete. Also old version seems to have all i need (almost).
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Shockman

  • Some idiot
  • I can't believe I got this account back .|.|.
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #606 on: November 19, 2011, 04:05:21 AM »
Is there a way to change the default keys used for moving around? My down arrow key is broken so it is hard to play scripts. I've checked the config.exe but I couldn't find any options for changing arrow keys.

Grovfu

  • Production Producer
  • DAT BULLET
    • Grovfu's Website
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #607 on: November 20, 2011, 05:47:40 PM »
Is there a list of built-in variables (not functions) that I could find? Like GetX and GetY?

Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #608 on: November 20, 2011, 08:57:44 PM »
GetX and GetY are functions though.

Well, the default shot names are variables, I suppose. Most of the other built-in variables have functions for calling them.

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

TraceTheKriken

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #609 on: November 23, 2011, 02:34:49 PM »
Finally I got my scripts work...
So, now I need to know the commands that makes the bullet's speed and direction random.
Also when I try to make stream of bullets to be fired at player from both sides of the boss like this:

50 40 30 20 10 B 10 20 30 40 50

B = Boss
Numbers = Delay frames

Result:


All bullets has GetAngleToPlayer command so it should fire ehem at player, right?

EDIT: Also how do I make a laser that is still and possibly rotates, but not moving to any direction.
« Last Edit: November 23, 2011, 02:38:38 PM by TraceTheKriken »

puremrz

  • Can't stop playing Minecraft!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #610 on: November 23, 2011, 03:50:31 PM »
GetAngleToPlayer means the angle from the boss to the player.
If you want the bullets to aim at the player, write:

SetShotDirectionType(PLAYER);
then the shoot command, with an angle of 0. CreateShot01(X,Y,speed,0,color,delay);
SetShotDirectionType(ABSOLUTE);

There are more ways to do so, but this is the only one I know by heart.
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: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #611 on: November 23, 2011, 04:19:37 PM »
Finally I got my scripts work...
So, now I need to know the commands that makes the bullet's speed and direction random.
Also when I try to make stream of bullets to be fired at player from both sides of the boss like this:

50 40 30 20 10 B 10 20 30 40 50

B = Boss
Numbers = Delay frames

Result:
-img-

All bullets has GetAngleToPlayer command so it should fire ehem at player, right?

EDIT: Also how do I make a laser that is still and possibly rotates, but not moving to any direction.
So, are you trying to get the bullets to all fire according to the left pattern, or are you trying to get them to fire according to the right pattern? If the former: all you do is move the position the bullets spawn from. If the latter, do what puremrz said. Now, as for random speed and direction:

rand(x,y)

OR

rand_int(x,y)

These two functions return a random number between x and y. You can use them anywhere you desire a random number, naturally. The former allows for decimals, the latter doesn't. I suggest the former for the speed and the latter for the direction. Also, don't set the speed too high! 5 is usually considered to be a fast bullet, so lower than that is fine, unless fast bullets are what you want. Now, as for the laser, you mean you want it to spin in place, yes? Just place your LaserA (or ObjLaser) somewhere and change its angle. I suggest you use the Turn Speed argument for this. Here's the function I speak of, just so you know.

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #612 on: November 23, 2011, 07:02:05 PM »
To elaborate on puremrz's suggestion:

GetAngleToPlayer is just the angle from the boss to the player, no matter where it is called. To get the angle between the bullet to the player (or any point to any other point!), you need to use that one trig function that you learned in school but then completely forgot about because it's so useless. Arctangent!

atan2(targetY-sourceY, targetX-sourceX)

This returns the angle from (sourceX, sourceY) to (targetX, targetY). Replace the source position with the bullet's, and the target position with the player's.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #613 on: November 23, 2011, 10:11:53 PM »
I've got one question about GetAngleToPlayer. In my script it also works with nonboss enemies on the stage. Will it work for a boss only when both boss and plain enemies appear?
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #614 on: November 23, 2011, 10:41:13 PM »
Yeah. When you call GetAngleToPlayer, you get the angle from position of the enemy you call it from to the player.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #615 on: November 25, 2011, 02:49:59 AM »
Why lasers cant be moved with Obj_SetSpeed?? Is it a bug or a feature and i have to use something like Obj_SetPosition(obj,Obj_GetX(obj)+cos(Obj_GetAngle(obj)),Obj_GetY(obj)+sin(Obj_GetAngle(obj))); instead?
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #616 on: November 25, 2011, 05:46:49 AM »
Why lasers cant be moved with Obj_SetSpeed?? Is it a bug or a feature and i have to use something like Obj_SetPosition(obj,Obj_GetX(obj)+cos(Obj_GetAngle(obj)),Obj_GetY(obj)+sin(Obj_GetAngle(obj))); instead?

Yes, that's the problem. You'd have to do exactly as you just said.
Though Obj_GetAngle(obj) would make it travel at only its own angle, so if you want like, one where it travels sideways, you'd have to have another angle.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #617 on: November 25, 2011, 03:16:54 PM »
Yes, that's the problem. You'd have to do exactly as you just said.
Though Obj_GetAngle(obj) would make it travel at only its own angle, so if you want like, one where it travels sideways, you'd have to have another angle.
good Obj_SetAngle works for lasers. Also i've noticed that laser position is measured from the beginning of it not from the center of the sprite wich is uncomfortable too.
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #618 on: November 25, 2011, 05:24:34 PM »
Uh no, it makes sense. If the position of the laser was in the middle of the laser it'd be crazy as hell to control.

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

ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #619 on: November 25, 2011, 07:36:25 PM »
I've got a new question. I'm trying to make a boss turn invisible temporarily but those white things (I don't know how else to describe them) give away the boss's position. How do you remove them?

Schezo

  • en-counse
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #620 on: November 25, 2011, 07:39:48 PM »
MagicCircle = false;
in @initialize should remove them.

Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #621 on: November 25, 2011, 09:10:21 PM »
It's MagicCircle(false);

As a general rule, you never include the capability to edit program variables lest someone do something catastrophically stupid to them. Having it as a function limits the possible inputs to the intended values, and overall increases program integrity/stability.

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

TraceTheKriken

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #622 on: November 26, 2011, 06:29:19 PM »
Now, as for random speed and direction:

rand(x,y)

OR

rand_int(x,y)

These two functions return a random number between x and y. You can use them anywhere you desire a random number, naturally. The former allows for decimals, the latter doesn't. I suggest the former for the speed and the latter for the direction.

Can you make a example for me?
A task that fires 5 bullets at the same time with random direction and speed each 1 second.
If you make this it would help me to understand how I should use these, since I don't think you can put it like this:
CreateShot01(GetEnemyX, GetEnemyY, rand(x, y), rand_int(x, y),WHITE22, 10);

Fetch()tirade

  • serial time-waster
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #623 on: November 26, 2011, 07:10:37 PM »
You can. Usually for a random integer angle, I use rand_int(0,359). Negative numbers can also be used.

AJS

  • Danmakufu Scripter
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #624 on: November 26, 2011, 07:22:56 PM »
What I'd like to know is how to get bullets to "realistically" obey gravity after being shot upwards, like in 1:54 of this video.

I already know how to get bullets to do this while standing still or when already moving downward, but as for upward-moving bullets, I can only get them to drop straight down with realistic acceleration.

TraceTheKriken

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #625 on: November 26, 2011, 09:07:44 PM »
Next thing:
How do I create this pattern with lasers:
1. Laser spawns from boss with 0 degree angle
2. Laser rotates Anti/Counter Clockwise and despawns when reaches 90 degree angle
3. another laser spawns from boss with 180 degree angle
4. this laser rotates Clockwise and despawns when reaches 90 degree angle
this pattern also should be looped

And don't tell me to check how to use CreateLaserA and SetLaserDataA from wiki, I already did that and it was no help

ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #626 on: November 26, 2011, 10:13:54 PM »
MagicCircle = false;
It's MagicCircle(false);

Thanks to both of you, I wasn't aware that the MagicCircle function affected the white things in addition to the circle itself.

Now I have a possibly more complicated question. My friend wanted to know if it is possible for a boss script to affect the movement speed of the player. I didn't think it was possible since the player speed is defined in an entirely separate script. I know there are a lot of questions piled up before mine so you can answer those first.

TheTeff007

  • Best Touhou 2015!
  • So much cuteness...!
    • Youtube Channel
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #627 on: November 27, 2011, 05:25:44 AM »
Something like Ozzy, is there a way to make that if the player is below Y, it automatically focuses? (Like in Subterrean Animism Phantasm Stage, Mitori Survival Final Phase but Inversed)
Small Teaser of my upcoming project~

No need to call me Teff007. Teff will do just as well~

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #628 on: November 27, 2011, 05:50:00 AM »
Something like Ozzy, is there a way to make that if the player is below Y, it automatically focuses? (Like in Subterrean Animism Phantasm Stage, Mitori Survival Final Phase but Inversed)

Code: [Select]
task movement {
let x = GetPlayerX; let y = GetPlayerY;
let vS = GetPlayerInfo(PLAYER_SPEED_LOW);
let vF = GetPlayerInfo(PLAYER_SPEED_LOW);
loop {
let fo = GetKeyState(VK_SLOWMOVE)!=KEY_FREE;
if(!OnPlayerMissed) {
if(GetKeyState(VK_LEFT)!=KEY_FREE) { x-=[vS,vF][fo] }
if(GetKeyState(VK_RIGHT)!=KEY_FREE) { x+=[vS,vF][fo] }
if(GetKeyState(VK_UP)!=KEY_FREE) { y-=[vS,vF][fo] }
if(GetKeyState(VK_DOWN)!=KEY_FREE) { y+=[vS,vF][fo] }
} else { x = GetCenterX; y = GetClipMaxY-64; }
if(x<GetClipMinX+16){x=GetClipMinX+16;}
if(y<GetClipMinY+16){y=GetClipMinY+16;}
if(x>GetClipMaxX-16){x=GetClipMaxX-16;}
if(y>GetClipMaxY-16){y=GetClipMaxY-16;}
SetPlayerX(x); SetPlayerY(y);
yield; while(GetPlayerY<GetCenterY+100){x=GetPlayerX;y=GetPlayerY;yield;}
}
}
« Last Edit: November 27, 2011, 05:52:24 AM by alt-kyuu-kyuu »

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #629 on: November 27, 2011, 07:14:04 AM »
Something like Ozzy, is there a way to make that if the player is below Y, it automatically focuses? (Like in Subterrean Animism Phantasm Stage, Mitori Survival Final Phase but Inversed)

If you're using not builtin Reimu or Marisa but some custom player script, maybe it should get the info about changing speed from common data exchange?

Can you make a example for me?
A task that fires 5 bullets at the same time with random direction and speed each 1 second.
If you make this it would help me to understand how I should use these, since I don't think you can put it like this:
CreateShot01(GetEnemyX, GetEnemyY, rand(x, y), rand_int(x, y),WHITE22, 10);

Code: [Select]
task fire{
   while(something){
      loop(5){
         CreateShot01(GetX,GetY,rand(1,3),rand_int(0,360),RED03,0);
         yield;
      }
      wait(60);
   yield;
   }
}

What I'd like to know is how to get bullets to "realistically" obey gravity after being shot upwards, like in 1:54 of this video.

I already know how to get bullets to do this while standing still or when already moving downward, but as for upward-moving bullets, I can only get them to drop straight down with realistic acceleration.

The easiest way is to use SetShotDataA_XY with some lower limit for Y acceleration. Here's a fast example of how to do it. Be careful with gravity value. it should be quite low to affect upward-movig bullets well http://pastebin.com/Vf2gqDRY

Or use object bullets with some variable that controls Y speed and adds it to Obj_SetY all the time. No wait. You actually have to know the Y-speed of an object and control it separately. Since objects handle only angle and speed over that angle it becomes messy. In this case you have either to control angle too or to refuse using angle and control X and Y speeds separately.



Meanwhile i faced same shit again. I'm implementing power system in my game and wanna make enemies do such an easy thing as drop power items on death. And guess what happens if i run task from the enemy script wich creates an object? How the f*ck should i handle that? Use common data? Will it work for lots of enemies with power items to drop dying at the same time (read: can common data share arrays or something?). If anyone else had to solve such a problem in their scripts - please tell what solution you found.
« Last Edit: November 27, 2011, 12:28:13 PM by MMX »
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear