Author Topic: ※ Danmakufu Q&A/Problem thread 3 ※  (Read 468581 times)

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #330 on: September 23, 2016, 10:10:28 PM »
So, I've started trying out spell making, and I've ran into a little problem :
Code: [Select]
// name the boss
let bossname = ObjText_Create;
ObjText_SetText(bossname, "Boss Name");
ObjText_SetFontSize(bossname,9);
ObjRender_SetPosition(bossname, 16, 12, 0);

// name a spellcard
let spellName = ObjText_Create;
ObjText_SetText(spellName, "Name of spell");
ObjText_SetFontSize(spellName,9);
ObjRender_SetPosition(bossname, 500,60, 0);

I expected it to work but when i play the script it just shows the name of the spellcard in the top left corner. I tried random coordinates to see if it would change but nothing moved, also the boss name stops showing if there's the spell name.
Any idea on how to fix it ?

Also more importantly how do I chain a nonspell to a spellcard ? And how do I add lives to a boss (because a lifebar = 1 nonspell + 1 spell is cleaner than everything on a single lifebar) ?

And last question for now : how do I force a player script for my whole script ? (is it easy and short to do ?)
« Last Edit: September 23, 2016, 10:21:25 PM by JoJo »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #331 on: September 24, 2016, 01:24:48 AM »
This should cover everything you'll need to know about text objects.

This should cover everything you'll need to know about plurals.

Player scripts can be specified in the header with #Player.

I recommend reading everything, but if you just need those little bits, Ctrl+F will be your best friend.
Also you should probably start transferring commonly used stuff to a function script and use #include in every script to add it.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #332 on: September 24, 2016, 04:03:15 AM »
So, I've started trying out spell making, and I've ran into a little problem :
Code: [Select]
// name the boss
let bossname = ObjText_Create;
ObjText_SetText(bossname, "Boss Name");
ObjText_SetFontSize(bossname,9);
ObjRender_SetPosition(bossname, 16, 12, 0);

// name a spellcard
let spellName = ObjText_Create;
ObjText_SetText(spellName, "Name of spell");
ObjText_SetFontSize(spellName,9);
ObjRender_SetPosition(bossname, 500,60, 0);

I expected it to work but when i play the script it just shows the name of the spellcard in the top left corner. I tried random coordinates to see if it would change but nothing moved, also the boss name stops showing if there's the spell name.
You keep using bossname in the second bit instead of spellName, and an x-coordinate of 500 is outside the game field so you won't see it. Changing the first SetPosition won't do anything because the second one will overwrite it.

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #333 on: September 24, 2016, 07:07:37 AM »
i didn't see i forgot to change the setPosition. I'm feeling stupid now lol
Thanks i guess

Edit : I've made a plural script. It almost works, but when a pattern ends (for example when the non spell links to the spellcard) bullets spawn in the top right corner. Also, the BGM stops playing when a pattern ends. I've removed the PlayBGM from the spell single script because it would just replay the BGM from the beginning. How do I set it up so the music just keeps playing normally ?
« Last Edit: September 24, 2016, 12:37:24 PM by JoJo »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #334 on: September 24, 2016, 03:51:58 PM »
Put the BGM stuff in the plural. If you make stages later, transfer the BGM code to the stage script.
Some more info

Also make sure in the bullet spawning tasks you have
Code: [Select]
if(!Obj_IsDeleted(obj)){//or whatever you named the variable
    //stuff
    wait(n);//insert number here
}
That way you don't get the bullets spawning in the corner.
If you're worried about lag replace your ascent loops with a while loop, like so
Code: [Select]
let count = 0;
while(!Obj_IsDeleted(obj)&&count<m){//replace m with the number of times you want it to loop
    //stuff
    count++;
    wait(n);//set your own timer value
}
That way the loop breaks when the object is gone.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #335 on: September 27, 2016, 08:27:25 PM »
I'm not sure it can go here because it's not directly related to danmakufu scripting but I'll try since it's at least related to game making.
Someone exactly know what is wrote in green on the officials Touhou loading script?

It seems it's alwas the same thing but I can't read japanese and I don't know where I can found a translation of this.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #336 on: September 27, 2016, 09:07:33 PM »
This game is a work of fiction. All characters and organizations that appear have passed into fantasy.

THCrap has translation patches for all recent games.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #337 on: September 27, 2016, 09:30:13 PM »
Thanks a lot. I don't really know about translation since I don't have they after Touhou 8.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #338 on: September 29, 2016, 06:20:59 AM »
How do I make a player not die when they are hit? (without removing the hitbox)

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #339 on: September 29, 2016, 07:05:23 AM »
How do I make a player not die when they are hit? (without removing the hitbox)

You could trigger a counter bomb on the last frame allowed for counter bombs, which does nothing except keep the player alive. Just remember to add an extra bomb just before doing so. The implementation is up to you, of course.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #340 on: September 29, 2016, 07:15:51 AM »
From the player side or the enemy side? What do you mean by not die? Not lose a life? Not disappear? Can't really tell what the intended purpose is.
« Last Edit: September 29, 2016, 07:19:06 AM by Drake »

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #341 on: October 11, 2016, 12:46:36 AM »
Question, I'm trying to make a custom player script, where the character has a laser shot. I have the laser working in all ways except for that no collisions are actually happening. I have my code for the laser on pastebin: http://pastebin.com/7aC4APZ2 (I can post the whole player script if needed)
The only other relevant code is starting the task in @Initialize. The lasers are animated using a custom animation (noodles shooting out), there's an animation for the noodles firing out, looping as you hold the shot button, then exit.
I'm not sure why the laser isn't colliding with anything, any help for this would be lovely.
(sorry if the code's crap, this is my first project in Danmakufu)

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #342 on: October 11, 2016, 04:40:24 AM »

Since this is a straight laser, I suggest using ObjStLaser_SetAngle() instead of ObjMove_SetAngle(). They behave quite differently. I'm not sure if that's the source of the problem (it might be, it might not be), but I suggest fixing this and testing once more.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #343 on: October 11, 2016, 10:29:07 AM »
(Above isn't actually the problem, to note)



There are a few things going on that are just due to neatness, but the main "problem" is just your control flow.

It starts with a loop if the laser is hitting anything. It won't be since it hasn't been set to a position yet, so the loop doesn't run. None of the other loops trigger either and are skipped, until you hold the shot key. The laser still won't hit anything that frame, and the animation loop starts. Once the animation loop starts the laser is positioned and actually should work more or less. However because you're in that loop until you stop shooting, you'll never get back to the logging loop, which is why you won't notice any collision. Similarly you won't actually check if the player still exists until you shop shooting. Lastly, in the no-shoot state you aren't really doing anything, which could potentially trip you up in the future if you do want something to happen when not shooting. Basically you just have to pay a bit more attention to how your flow works, but otherwise it probably already functions correctly. Part of it is just that you misplaced your logging code and probably didn't test on a boss or something.

You can turn your logging code into its own task and then run it before your !Obj_IsDeleted(op_obj) loop, or you can plop it inside the shooting loop. The former would look like this:

Code: [Select]
// ...
ObjRender_SetScaleXYZ(playerShot,1,1,1);

task log(){
    while(!Obj_IsDeleted(op_obj)){
        if(ObjCol_IsIntersected(obj)) {
            WriteLog("collision");
        }
        yield;
    }
}
log();

while(!Obj_IsDeleted(op_obj)) {
// ...

(The following is just my advice and a full example of a player laser. If your stuff is fixed and you don't care about making it cleaner or easier to build on later, you can ignore this)

You seem to have three main states and cycle through them. Often I like to explicitly define my states, like you do a bit with animPhase, since it gives you more control over how your states transition.
Here's an example of how I would structure a player laser like yours. It should be immediately usable as long as you have a shot with ID 1 and have objPlayer defined.
https://gist.github.com/drakeirving/21d142646e9588a694bab30b5f968b31
It looks pretty similar to the structure you have now, but the loops are controlled only by the states, which are switched around inside each one. Stuff to run between state switches are just put between the loops. Also note how in the cooldown state you can wait for it to finish and turn off, or press the shot button again to fire before the disappear animation ends.

Another tip would be considering changing ObjShot_SetDamage(obj,0) to ObjShot_SetIntersectionEnable(obj,false) like I do above. It totally disables collision instead of just changing the damage, which is relevant for example right now, when you're testing to see if it's hitting anything; it will react regardless of whether the laser is visibly out or not because the collision is always active.
« Last Edit: October 11, 2016, 10:38:19 AM by Drake »

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #344 on: October 17, 2016, 12:33:25 AM »
I tried what you said about the collision test while loop, changed it to a task, but it makes no difference. I've tried many things, including making my code more like the example one you gave me, and nothing's changed aside from the small improvements from your code. Lasers render and follow my character's position as before. I'd tried your code with my animations and I was getting nothing, not even lasers rendering, hence why I modified my own code.
http://pastebin.com/7mWj5ihE
Note: I tried changing all the while loops (aside from !Obj_IsDeleted) into if statements, hence all the commented out yields, and it doesn't appear to make any difference. Also, I've tried other people's player scripts with lasers (a recreation of MarisaB from MoF) against the boss and they work, so it's gotta be an issue with my laser.

Here's a video showcasing the game in action (very bare-bones atm, been stuck on this for a while):
https://www.youtube.com/watch?v=vsH6CfrJUzc&feature=youtu.be
Sorry about the game not being Touhou, but I assure you I take a lot of gameplay inspiration from Touhou, hence why I chose to use Danmakufu.

If all else fails, I'll probably just make the laser into a stream of bullets to resemble a laser, which would coincidentally fit with the noodly theme, but I'd like to figure this out if possible because I'm stubborn.
« Last Edit: October 17, 2016, 12:37:26 AM by netugi »

ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #346 on: October 17, 2016, 02:38:10 AM »
I'd tried your code with my animations and I was getting nothing, not even lasers rendering, hence why I modified my own code.
If my code doesn't work drag-and-drop, and your main problem is that the laser renders (which is a Sprite) but not collides (which is a Laser object), my intuition says that either your shotsheet is incorrect or not loaded, and nothing is actually being fired. This would cause both your original problem and the problem you're finding with my code. Please make sure you can at least fire your ID 1 shot as a bullet.

EDIT: On inspection, you had originally given your laser the shot ID=1, but in your current code you use the texture variable which will absolutely not work. ObjShot_SetGraphic requires a shot ID. The above still applies though, make sure it actually fires something at all.
Also for the log task, you haven't called it wait no you did, just in the wrong place. Note that in my blurb I define the task and then immediately call it; that's what you want. If you put it in your while loop it will keep launching new tasks every frame that each try to log on every frame, and log a billion times.
« Last Edit: October 17, 2016, 04:34:28 AM by Drake »

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

TheTeff007

  • Best Touhou 2015!
  • So much cuteness...!
    • Youtube Channel
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #347 on: October 19, 2016, 01:59:02 PM »
Just got into learning ph3 (since programming on 0.12m has given me so much troubles) and I noticed that in the th_dnh.def file there is an option for resolution. Does this means that I can make it bigger and use higher quality images or just merely adjusts the size of the program and scales everything?
Small Teaser of my upcoming project~

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

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #348 on: October 19, 2016, 02:16:06 PM »
Just got into learning ph3 (since programming on 0.12m has given me so much troubles) and I noticed that in the th_dnh.def file there is an option for resolution. Does this means that I can make it bigger and use higher quality images or just merely adjusts the size of the program and scales everything?

You can actually choose to use HD graphics and have your game run with them. Do note that performance wise, you will have to compensate since DNH isn't the most... optimized when it comes to rendering.

Jeremie

  • MoonScraper
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #349 on: October 21, 2016, 11:33:42 AM »
I'm not sure I'm posting in the right thread (since this is about Danmakufu Q&A) even though I've browsed some of the boards and posts to try making sure where I should ask this question. I also tried looking up if I could find information about this here but it's been somewhat limited. I suppose it could fall under the guidelines but this is about a game project I've been working on.

A while ago I posted on this forum about a RPG project I was making. There's a little bit about guidelines I failed to notice until a recent interview with ZUN about not using data from his projects in their original form. Truth be told, I've been using music AND sounds in my RPG project from Touhou games. This is a free project that will never have a commercial release (it's budget beyond RPG Maker XP is also 0$) and while one could say that the music is used as a tool to say the story in my game project, that obviously doesn't pass when it comes to copyright laws and the likes. I was wondering what would be a good alternatives to use Touhou-related music since I still wish to use music that I feel is in tone with the events in the game and I feel music is very important for a RPG project too. I'm currently looking into certain options but any ideas, recommendations, etc. would be very welcome.
It is pitch black. You are likely to be eaten by Rumia.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #350 on: October 21, 2016, 02:47:46 PM »
It's been a while since I've posted on this thread (or used Danmakufu).
So, I'm looking to get back into it.
My main problem is that music is not playing correctly when I use the plural script : if i put the music in the plural it does nothing, if i put it only in the first single it stops playing when it gets to the next single and if i put it in each single it starts playing from the beginning when it gets to the next single.

Also, is there any site or video or whatever that explains in detail how to fire basic shapes (lines/circles/spirals)and how it works ?

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #351 on: October 21, 2016, 03:50:40 PM »
< snip >
You have two options in this case:
- Use remixes, covers or rearrangements of the original songs from ZUN. But you'll need to ask permission from the artists who made those arrangements/mixes.
- Make your own rearrangement/mix/cover

My main problem is that music is not playing correctly when I use the plural script : if i put the music in the plural it does nothing, if i put it only in the first single it stops playing when it gets to the next single and if i put it in each single it starts playing from the beginning when it gets to the next single.
Question is how you exactly put it in the plural. If you're putting it as a header, then that won't work. You'll need to separately load and play the music using the Danmakufu functions. Just like how sound effects are loaded and used, you do the same for music.

Edit: You will need to look into http://dmf.shrinemaiden.org/wiki/Functions_(ph3)#Sound_Object_Functions
« Last Edit: October 21, 2016, 03:59:08 PM by Helepolis »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #352 on: October 21, 2016, 05:12:17 PM »
Thanks ! I was putting it normally but i only used the functions in http://dmf.shrinemaiden.org/wiki/Audio_Functions and didn't know there was the Sound Object section.

Jeremie

  • MoonScraper
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #353 on: October 21, 2016, 09:01:18 PM »
You have two options in this case:
- Use remixes, covers or rearrangements of the original songs from ZUN. But you'll need to ask permission from the artists who made those arrangements/mixes.
- Make your own rearrangement/mix/cover

Ah, alrighty then, I guess that'll have to be plan A either way since I'm not gifted when it comes to music and editing it. Thanks. ~
It is pitch black. You are likely to be eaten by Rumia.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #354 on: October 22, 2016, 01:23:35 AM »
Thanks ! I was putting it normally but i only used the functions in http://dmf.shrinemaiden.org/wiki/Audio_Functions and didn't know there was the Sound Object section.
You can pretty much forget about the top-level Audio functions since they're very limited. They're basically just leftovers from 0.12m.

However, with the more powerful Sound objects you have to do a bit more management to make sure you aren't creating a million objects or have a bunch of invisible garbage. It probably won't matter if you're just playing BGM.

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #355 on: October 22, 2016, 07:44:39 PM »
Hi. I'm trying to make a circle render by using OBJ_PRIMITIVE_2D like in the default magic circle thing. I tried different things but I just can't affich it.
I already make it, based on the magic circle used by default in the player script;
Code: [Select]
task TCircle {
let dir = GetCurrentScriptDirectory();
let countVertex = 64;
function CreatePrimRender(){
let path = dir ~ "img/lb.png";
let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
ObjPrim_SetVertexCount(obj, countVertex);
ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
Obj_SetRenderPriority(obj, 0.60);
ObjPrim_SetTexture(obj, path);
ascent(iVert in 0..countVertex / 2) {
let left = iVert * 128;
let indexVert = iVert * 2;
ObjPrim_SetVertexUVT(obj, indexVert + 0, left, 0);
ObjPrim_SetVertexUVT(obj, indexVert + 1, left, 128);
}
let r = 120;
ascent(iVert in 0..countVertex / 2){
let indexVert = iVert * 2;
let a = 360 / (countVertex / 2 - 1) * iVert;
let vx1 = r * cos(a);
let vy1 = r * sin(a);
ObjPrim_SetVertexPosition(obj, indexVert + 0, vx1, vy1, 0);

let vx2 = r * cos(a);
let vy2 = r * sin(a);
ObjPrim_SetVertexPosition(obj, indexVert + 1, vx2, vy2, 0);
}
ObjRender_SetPosition(obj, 200, 200, 0);
}
CreatePrimRender();
}
I'm doing something wrong for sure but... I don't know what. It's almost the same thing than the magic circle, The task is well called, the path is right, The object and primitive type seems correct... I just don't know why it don't work. I'm depressed.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #356 on: October 23, 2016, 12:09:27 AM »
http://pastebin.com/PuFkEQe9

My boss just shoots a circle once, doesn't move at all, and then does nothing. What did i do wrong ?

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #357 on: October 23, 2016, 03:09:48 AM »
I'm doing something wrong for sure but... I don't know what. It's almost the same thing than the magic circle, The task is well called, the path is right, The object and primitive type seems correct... I just don't know why it don't work. I'm depressed.
1. If you are using primitive objects with textures, you must use ObjSprite2D_SetDestCenter (or SetDestRect, if that's your thing).
2. If you want the circle to keep rendering, you'll need to put CreatePrimRender() in a loop.
Hope this helps (?).

edit:
http://pastebin.com/PuFkEQe9

My boss just shoots a circle once, doesn't move at all, and then does nothing. What did i do wrong ?
It's because you called attack() 3 times simultaneously without telling danmakufu to wait, so they overlap.
The solutions to this problem are:
1. Put loop(n){yield;} after attack()'s in Pattern().
2. Change attack() from task to function, that way, Pattern() will wait until attack() has ended before continuing.
« Last Edit: October 23, 2016, 07:48:57 AM by Helepolis »

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #358 on: October 23, 2016, 06:53:05 AM »
As long as he changes attack() to a function, the yields he already has there will work fine. (That being said, it's arguable that putting the waiting code in the higher-level Pattern() task instead, and having attack() just be the shooting alone, makes it a bit cleaner. But really it doesn't matter.)
Also you should move playing the shot sound to outside the loop since right now it'll just stack up a bunch of calls for no reason. (Again, not that it would affect anything really.)


@Whatever: Neither points about rendering are correct, sorry. ObjSprite2D functions are just convenience functions for rectangular primitives so they aren't absolutely necessary (nor do they apply to non-rectangles), and you also don't need the code in a loop to keep it being rendered, it'll just only draw once and stay there without changing, that's all. Appreciate the intent though.
Hi. I'm trying to make a circle render by using OBJ_PRIMITIVE_2D like in the default magic circle thing. I tried different things but I just can't affich it.
I already make it, based on the magic circle used by default in the player script
Check out the vertex positions being set. Each pair of vertices represents a "top" and a "bottom" point, and all of these lined up makes your shape. Yet when you're positioning your vertices each top and bottom vertex are going to be set to the same position, so at best you have a 0-width circle. The reason the default system circle seemingly does this is because it uses a weird method to keep track of what radius every vertex should be at and then converts those points to where they should be in the circle. In your case all you have to do is make sure the "outside" radius is some width further out than the inside radius.
So let vx2 = (r+width) * cos(a) or something.
« Last Edit: October 23, 2016, 07:03:11 AM by Drake »

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #359 on: October 23, 2016, 07:27:59 AM »
Thanks a lot Drake. I do it and it magically appears. So, that's the point of listRadius[indexVert] used in the default scripts... It's good to know.