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

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1200 on: April 30, 2018, 10:04:40 PM »
Oh, now I understand, and I don't get why your SpawnLife/Spell is a function. Can't it be a task?
They're pretty minor reasons. I really just did it for the semantics difference, it isn't important. The most significant thing for general use is that you can return values from functions but not tasks, so while I don't do it there you could restructure SpawnItem a bit to be a function that runs an internal task and returns the item object ID, then return that ID again from e.g. SpawnLife. That way you'd have access to the item object inside the event call if you needed it for whatever reason.

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1201 on: April 30, 2018, 11:41:54 PM »
Where I can learn how to make a package script?

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1202 on: May 01, 2018, 01:30:28 AM »
I don't think there are any tutorials on them yet, but there's an example package script that comes included with Danmakufu. Looking at that and the relevant functions is generally enough to make a serviceable package script.

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1203 on: May 01, 2018, 06:54:13 AM »
That's not what I want; what I'm looking for is nons/spells like this

task Main {
    while (health>0){
        A; wait(180):
        B; wait(270);
        etc
    }
}

then have tasks A/B etc
Lunatic 1cc: EoSD, PCB, IN, MoF, TD, DDC, LoLK, HSiFS, WBaWC

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1204 on: May 02, 2018, 06:52:16 PM »
Anyone mind helping me try to replicate some spells and nonspells so I can understand how they work?

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1205 on: May 02, 2018, 10:45:59 PM »
Is there a way to disable the item score?

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1206 on: May 02, 2018, 10:48:53 PM »
Anyone mind helping me try to replicate some spells and nonspells so I can understand how they work?
I can help you with some things, but I'm not an expert

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1207 on: May 02, 2018, 11:20:40 PM »
I am trying to figure out the best way to replicate something similar to Mokou's first non-spell, yet I can't seem to see if loose lasers or bullets are better to create the effect. Then if it would be better to use ascent loops or just to use regular loops. I still can't figure out how to make the bullets rotate in just one direction and not oscillate.
I can help you with some things, but I'm not an expert

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1208 on: May 03, 2018, 12:15:20 AM »
Is there a way to disable the item score?
I don't know what you mean by this.

I am trying to figure out the best way to replicate something similar to Mokou's first non-spell, yet I can't seem to see if loose lasers or bullets are better to create the effect. Then if it would be better to use ascent loops or just to use regular loops. I still can't figure out how to make the bullets rotate in just one direction and not oscillate.
Mokou's first non-spell? Why are you thinking about lasers; there are no lasers involved. The bullets also don't rotate? It's the firing angle that rotates. I don't know which pattern you're referring to with that description.

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1209 on: May 03, 2018, 12:30:52 AM »
I don't know what you mean by this.
Like take out the score that the item gives you, because if I set to 0, it still appears near the character.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1210 on: May 03, 2018, 01:31:21 AM »
Replace the stuff in resource/img/System_Stg_Digit.png with just black. I'm not sure if it's possible to overwrite the system resources on a script-by-script basis.

EDIT: ↓ wow i'm dumb
« Last Edit: May 03, 2018, 02:18:55 AM by Drake »

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

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1211 on: May 03, 2018, 02:13:47 AM »
Is there a way to disable the item score?

Are you referring to the actual score or just the text? If it's just the text, refer to:
https://dmf.shrinemaiden.org/wiki/Item_Object_Functions#ObjItem_SetRenderScoreEnable

I use this function in order to use my own custom text styling for item scoring

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1212 on: May 03, 2018, 01:53:32 PM »
This is the non spell I was talking about,(https://youtu.be/xl17uhqSuqc). What I meant was, I cannot figure out if I used CreateShotA1, how to get it to replicate similar effects to how it rotates around the boss and has multiple rows of bullets coming from three points.
I don't know what you mean by this.
Mokou's first non-spell? Why are you thinking about lasers; there are no lasers involved. The bullets also don't rotate? It's the firing angle that rotates. I don't know which pattern you're referring to with that description.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1213 on: May 03, 2018, 02:02:16 PM »
This is the non spell I was talking about,(https://youtu.be/xl17uhqSuqc). What I meant was, I cannot figure out if I used CreateShotA1, how to get it to replicate similar effects to how it rotates around the boss and has multiple rows of bullets coming from three points.

I recommend reading http://sparen.github.io/ph3tutorials/ph3u1l7.html

The caveat is that Mokou's lines of bullets aren't all the same angle but I'm confident that you can figure out how to make those adjustments in the nested loop structure :)

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1214 on: May 03, 2018, 06:47:20 PM »
How can I change the width (the actual width, not the render one) of a laser object (I'm using the objshot create and regist method).

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1215 on: May 03, 2018, 06:51:33 PM »
How can I change the width (the actual width, not the render one) of a laser object (I'm using the objshot create and regist method).

Please refer to https://dmf.shrinemaiden.org/wiki/Functions_(ph3)#Shot_Object_Functions where you should find a function that does exactly that.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1216 on: May 03, 2018, 09:27:53 PM »
I'm making a player script but the laser damage jus keep adding up unintentionally.
Here is the code:
Code: [Select]
task ShotU1{
while(true){
let las = -1;
if(Shooting){
let angleT= 270-2.5;
ascent(i in 0..2){
las = ObjShot_Create(OBJ_STRAIGHT_LASER);
ObjShot_Regist(las);
ObjShot_SetAutoDelete(las, false);
ObjShot_SetGraphic(las, 3);
ObjShot_SetDamage(las, 0.01);
ObjShot_SetPenetration(las, 3);
ObjLaser_SetLength(las, 512);
ObjLaser_SetRenderWidth(las,8);
ObjStLaser_SetAngle(las,angleT);
KeepAtObj(las,playerID);
angleT+=5;
deleteinloop(las);
}
yield;
}
yield;
}
}
task deleteinloop(las){
while(!Obj_IsDeleted(las)){
if(!Shooting){
Obj_Delete(las);
}yield;
}
}
task KeepAtObj(obj,obj1){
while(!Obj_IsDeleted(obj)){
ObjMove_SetPosition(obj,ObjRender_GetX(obj1),ObjRender_GetY(obj1));
yield;
}
}

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1217 on: May 03, 2018, 10:50:30 PM »
I'm not really sure that's a good way to make a laser? If you look closely at, say, Marisa's lasers, they actually consist of small bullets being fired along coloured lines. I didn't even know you COULD make straightlasers that deal damage to enemies. The other problem is that you're creating a laser every single frame while the player is shooting, but only delete the lasers once the player stops shooting. Assuming that your way of making a player laser even works[Its much different then the method I use], you should be able to fix the stacking laser problem by replacing the yield after the ascent loop with while(shooting){yield;}. I'm also not sure why the ascent loop makes two lasers, since they both end up occupying the exact same location. Either make only one laser or have the lasers be in different places.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1218 on: May 03, 2018, 11:24:20 PM »
I'm not really sure that's a good way to make a laser? If you look closely at, say, Marisa's lasers, they actually consist of small bullets being fired along coloured lines. I didn't even know you COULD make straightlasers that deal damage to enemies. The other problem is that you're creating a laser every single frame while the player is shooting, but only delete the lasers once the player stops shooting. Assuming that your way of making a player laser even works[Its much different then the method I use], you should be able to fix the stacking laser problem by replacing the yield after the ascent loop with while(shooting){yield;}. I'm also not sure why the ascent loop makes two lasers, since they both end up occupying the exact same location. Either make only one laser or have the lasers be in different places.
I've see this way of laser at the Random Player Generator.
Now I see the problem, I was having it right at the beginning, but a sudden change in code made me think of taking it out.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1219 on: May 04, 2018, 04:33:05 PM »
Is there a function to get the ID of the nearest enemy of the player?

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1220 on: May 04, 2018, 06:33:17 PM »
I've got the ascent loops working how I want them to but I can't figure out how the bullets spin around Mokou.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1221 on: May 04, 2018, 08:04:52 PM »
Is there a function to get the ID of the nearest enemy of the player?

Use GetAllEnemyID and the Distance Formula.

I've got the ascent loops working how I want them to but I can't figure out how the bullets spin around Mokou.
Hint: increment the angle using the loop variable as a parameter :)

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1222 on: May 04, 2018, 10:27:41 PM »
My player doesn't change the focus shot when I change to unfocus, but changes the unfocus shot when I change to focus (this may be a little hard to understand).
Here is the code:
Code: [Select]
task ShotU1{
while(true){
let las = -1;
let las1 = -1;
if(Shooting){
ascent(i in 0..1){
las = ObjShot_Create(OBJ_STRAIGHT_LASER);
ObjShot_Regist(las);
ObjShot_SetAutoDelete(las, false);
ObjShot_SetGraphic(las, 1016);
ObjShot_SetDamage(las, 5);
ObjShot_SetPenetration(las, 3);
ObjLaser_SetLength(las, 512);
ObjLaser_SetRenderWidth(las,20);
ObjLaser_SetIntersectionWidth(las,20);
ObjStLaser_SetAngle(las,270);
KeepAtObj(las,playerID);
deleteinloop(las);
ObjStLaser_SetSource(las,false);
Obj_SetRenderPriorityI(las,79);
}
while(Shooting&&!isFocus){
let angleT= 270-(360/72)*2;
ascent(i in 0..72/16){
let obj = CreatePlayerShotA1(ObjRender_GetX(ObjOption),ObjRender_GetY(ObjOption),5,angleT,10,1,879);
let obj1 = CreatePlayerShotA1(ObjRender_GetX(ObjOption1),ObjRender_GetY(ObjOption1),5,angleT,10,1,879);
angleT+=360/72;
ObjRender_SetColor(obj,0,0,0);
ObjRender_SetColor(obj1,0,0,0);
}
wait(5);
}
if(Shooting&&isFocus){
ascent(i in 0..1){
las = ObjShot_Create(OBJ_STRAIGHT_LASER);
ObjShot_Regist(las);
ObjShot_SetAutoDelete(las, false);
ObjShot_SetGraphic(las, 1016);
ObjShot_SetDamage(las, 5);
ObjShot_SetPenetration(las, 3);
ObjLaser_SetLength(las, 512+256);
ObjLaser_SetRenderWidth(las,20);
ObjLaser_SetIntersectionWidth(las,20);
KeepAtObj(las,ObjOption);
deleteinloop(las);
ObjStLaser_SetSource(las,false);
Obj_SetRenderPriorityI(las,79);

las1 = ObjShot_Create(OBJ_STRAIGHT_LASER);
ObjShot_Regist(las1);
ObjShot_SetAutoDelete(las1, false);
ObjShot_SetGraphic(las1, 1016);
ObjShot_SetDamage(las1, 5);
ObjShot_SetPenetration(las1, 3);
ObjLaser_SetLength(las1, 512+256);
ObjLaser_SetRenderWidth(las1,20);
ObjLaser_SetIntersectionWidth(las1,20);
KeepAtObj(las1,ObjOption1);
deleteinloop(las1);
ObjStLaser_SetSource(las1,false);
Obj_SetRenderPriorityI(las1,79);
while(!Obj_IsDeleted(las)&&!Obj_IsDeleted(las1)){
let enemy = GetAllEnemyID;
let dist = [];
let nearestID = 0;
let distA2 = [0];
ascent(i in 0..length(enemy)){
let distV = [GetDistance(ObjMove_GetX(enemy[i]),ObjMove_GetY(enemy[i]),GetPlayerX,GetPlayerY)];
dist = dist ~ distV;
}
ascent(i in 0..length(dist)){
let distnrst = min(dist[i],dist[max(i-1,0)]);
let distnrstA = [distnrst];
distA2 = distA2 ~ distnrstA;
if(distA2[i] == distnrst){nearestID++;}
}
ObjStLaser_SetAngle(las,GetAngleToObj(las,enemy[nearestID]));
ObjStLaser_SetAngle(las1,GetAngleToObj(las1,enemy[nearestID]));
yield;
}
}
}
while(Shooting){yield;}
}
yield;
}
}

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1223 on: May 04, 2018, 11:25:57 PM »
Hello;

I have a question regarding Danmakufu's tasks - Is there a performance/processing cost connected to calling tasks recursively, as opposed to repeating said tasks with loops?

Thanks in advance.

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1224 on: May 04, 2018, 11:37:53 PM »
What's the best way to freeze the bonus on spells? Without putting the timer to 999.
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1225 on: May 05, 2018, 12:00:04 AM »
My player doesn't change the focus shot when I change to unfocus, but changes the unfocus shot when I change to focus (this may be a little hard to understand).
Here is the code:
Code: [Select]

A few things:
First, please pastebin large blobs of code
Second, you have no comments or anything within your code designating your intention or what you are trying to do
Finally, I have no idea where this is being called from, how you are setting variable such as Shooting or isFocus, etc. Please provide more context for your problem.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1226 on: May 05, 2018, 01:00:09 AM »
A few things:
First, please pastebin large blobs of code
Second, you have no comments or anything within your code designating your intention or what you are trying to do
Finally, I have no idea where this is being called from, how you are setting variable such as Shooting or isFocus, etc. Please provide more context for your problem.
1.I'm sorry, I didn't realize that it was so big.
2.Here is the code with a hell lot of comments.
3.It is in the comments above.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1227 on: May 05, 2018, 02:36:32 AM »
1.I'm sorry, I didn't realize that it was so big.
2.Here is the code with a hell lot of comments.
3.It is in the comments above.

Some brief notes that may help you with your code:
- I suggest using tasks for your lasers, as they all seem to behave similarly and you are duplicating a wall of code
- I suggest reviewing how while loops work, as you do not seem to understand how to properly use them. When you use a while loop, only the code inside the while loop will execute until the condition for the while loop is no longer met or you break; or return; out of the loop. Once again, I will suggest using tasks, as this will allow you to run multiple while loops in parallel.

From what I can see, your logic for determining how to fire is flawed, mainly due to your use of while loops and the way you are handling your code. Once you've moved your laser creating code to a task, it should be possible to view the entirety of your ShotU1 on your computer screen at once. I suggest stepping through your code - suppose the player is currently focusing/unfocusing, and see what loops would execute. Then see what happens when the player changes to the other/stops shooting/etc. You should be able to figure out where your problem is as long as you try out the situations that didn't work and see how your code resulted in the observed behavior.

PyuDi

  • daily touhou~
  • danmakufu!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1228 on: May 05, 2018, 02:50:54 AM »
How can I make bullets that orbit around the specified circle?
(Ex. https://m.youtube.com/watch?v=FqdWq4QNWto )

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1229 on: May 05, 2018, 07:35:30 AM »
In the future note you can append something like #t=5m25s to the end of a Youtube link to timestamp it. Otherwise we have to go through the whole video to find what you're referring to.

Any point around a circle can be described as being at a certain distance (or radius) from the center, and at a certain angle from the center.



Note here the point is radius R from the center and at angle A. Like the image shows, you can turn these into x,y coordinates with x = R*cos(A) and y = R*sin(A).

All you really need to do to have a thing orbit a point, then, is to have it at some radius, and have the angle increase or decrease over time. Look at the image and see that if A just keeps increasing while R stays the same, the point will travel along the circle.

This will usually look something like this in code:
Code: [Select]
let x0 = 192; // center x-position
let y0 = 224; // center y-position
let r = 50; // radius
let a = 0; // angle
while(!Obj_IsDeleted(obj)){ // some loop
  ObjMove_SetPosition(obj, x0 + r*cos(a), y0 + r*sin(a));
  a++;
  yield;
}

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