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

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #990 on: February 04, 2018, 04:05:57 PM »
Can someone provide me with an example of how to implement History for spell cards? I've been trying to do it with Common data, but I just end up failing, the numbers are always incorrect and don't differ depending on the spell name.

How are you currently handling spell card attempt/capture history? Naturally, you will want to distinguish between each spell, so I assume you are trying some kind of standardized unique ID system with your Area Common Data.

The way I currently do it is as follows:
1. In @Initialize, call your cutin library with a unique ID for the spell card. For example, Spell # 125 uses the following:
CutIn(objBoss, "GEN", "Prob. S. \"Hypergeometric Waltz of the Forgotten Kitten (X)\"", 125, BossCutIn, 0, 1, 384, 384);
Where 125 is the unique spell ID.

In my Cutin library (based off of GTBot's), I do the following:
Code: [Select]
task CutIn(EnemyObject, CutType, CutSpellName, SpellID, CutSpellImage, CutX1, CutY1, CutX2, CutY2){
    yield;
    let SpellDataAttempt = IntToString(SpellID) ~ GetPlayerID ~ "Attempt"; //name of commondata
    let SpellDataGet = IntToString(SpellID) ~ GetPlayerID ~ "Get"; //name of commondata
    let SpellValueAttempt = GetAreaCommonData("SpellFunctions", SpellDataAttempt, 0);
    let SpellValueGet = GetAreaCommonData("SpellFunctions", SpellDataGet, 0);

    //misc code

    if(IsReplay == false){
        SpellValueAttempt++;
        SetAreaCommonData("SpellFunctions", SpellDataAttempt, SpellValueAttempt);
        SetAreaCommonData("SpellFunctions", SpellDataGet, SpellValueGet);
        SaveCommonDataAreaA1("SpellFunctions");
    }

    //etc.
}
By using a unique spell ID for each Single, I end up with unique common data names depending on the player, the spell ID, and whether it's attempt or capture.

Now, you mentioned earlier that 'the numbers are always incorrect and don't differ depending on the spell name'

In your current setup, I assume that you are either not passing some kind of unique ID or are passing the same spell name for multiple difficulties. Of course, without seeing your setup I can't provide a concrete answer, but I hope my example above is of use.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #991 on: February 04, 2018, 05:28:53 PM »
AreaCommonData is the key here indeed. Here are a few snippets from my game.


I save all data for spell cards in a AreaCommonData with the following structure. As you can see I keep separate tracking for Stage game play and Spell Practise.
Code: [Select]
// Spell practise core. Array for the spell cards to track value
// Structure [ state, captureStage, historyStage, capturePrac, historyPrac, scoreBorder, scoreMagic, scoreReimu, scoreYukari, scoreMarisa, scoreAlice ]
// State 0 = unseen/disabled. 1 = Seen. 2 = Captured.
// Number of captures and tries is as they are.

// 01 spell cards
SetAreaCommonData("core","pierre01hard",[0,0,0,0,0,0,0,0,0,0,0]);

I personally utilize the EVENT system of Danmakufu to detect a spell card start or capturing a spell card. All my spell cards utilize the EVENT section using custom user event:
Code: [Select]
@Event {
alternative(GetEventType())
case(EV_USER+9999) {
SetCommonData("spellcardID","pierre01hard");
}
}
pierre01hard is a unique value I have given for this spell card. It basically means "Pierre boss" - "Spell card #01" - "Hard mode"

This is inside my "system" script which is launched when the game starts and keeps running in the background. It listens to the default Danmakufu Events.
Code: [Select]
@Event {
case(EV_START_BOSS_SPELL) {
updateCardHistory();
}

case(EV_GAIN_SPELL) {
updateCardCapture();
}
}

The updateCardHistory and updateCardCapture are functions I wrote myself. It looks roughly like this:
Code: [Select]
task updateCardHistory() {
let spellScriptID = GetCommonData("spellScriptID", 0);
NotifyEvent(spellScriptID, EV_USER+9999, 0);
getResultCard = GetCommonData("spellcardID", "NULL");
let getCommonSpellCardData = [];
getCommonSpellCardData = GetAreaCommonData("core", getResultCard, [0,0,0,0,0,0,0,0,0,0,0]);

// Do stuff with the values and save it back to the AreaCommonData
}
History value is updated when the spell begins and the capture value is updated when the card is obviously captured. It is a bit code-duplication (ugly), but hey it works.

The flow would be:
- System script is launched and running + listening to events
- System script triggers event on spell card start and gain
- Update function is called which calls the EVENT from the Spell Card script
- Spell Card uniqueID is retrieved and stored
- Values are modified as pleased
- Modified values are saved back

Hope Sparen's and my method gives you some thing to work with.
« Last Edit: February 04, 2018, 05:32:18 PM by Helepolis »

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #992 on: February 04, 2018, 06:21:39 PM »
And yeah you can't redefine functions. I'm not really sure what's up there; does it happen with all scripts? Does it happen with a fresh DNH copy? Different computer, if you have access to one? There has to be a difference somewhere.

I just checked running a completely independent package and it's still locked at 60. I... have no idea what's causing this, but it isn't just in Danmakufu's directory.
Literally everything in this script will crash and burn.
1CC tracker

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #993 on: February 05, 2018, 06:29:42 AM »
The only progress I had is that I could change the scale of the mask, but after it reaches the certain point, it just copies itself(something you would see if you put SourceRect of the sprite to 512 when it's original size is 256). So, I would really appreciate the help on this topic, since I don't know anything about HLSL.
Sorry about that, did forget. Here's a thing I wrote to easily handle stuff like masks, along with an example to showcase.

https://gist.github.com/drakeirving/6694f73f5cb5cdb981a09e310e798250

Using a Shader object by itself and trying to apply it to a texture is not very useful for this kind of work for various reasons. You basically don't need to touch the provided HLSL. What you've been missing is that you need to use render targets to render what you want as a texture and then use that as the texture that the shader uses as a base. The shader then interacts with whatever layers you specify. This way you can handle masking multiple things at the same time as well as changing it over time instead of keeping it a static texture. The code I have written is much more than you need for a minimal working example, though.

In the example, I have an image of a white pixel I use for a canvas, and a 256x256 image of a white circle on black background. I stretch the white pixel to 1024x512 (the render target size), and then repeatedly add copies of the circle texture with subtract blending. So the render target becomes a texture that is mostly white with a bunch of random black circles. Meanwhile, some background is drawn on layers 26 to 28. The Shader object applies the masking shader technique, using the render target as the applied texture, to the layers 26 to 28, which results in the background appearing as though there are holes in it that scroll across the screen.

EDIT: Made some massive improvements to previous code for generalizability, and changed the example to be close to what's being requested.
« Last Edit: February 05, 2018, 09:45:38 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 #994 on: February 05, 2018, 02:22:36 PM »
Thanks everyone for the help. The history is now working, the way I was passing the ID for the spell was completely wrong, so now it's solved. Also, what are CutIns? Even thought I've heard of them, I don't know what they are.

As for the shaders, now I kinda get how it works, though there are parts that I still don't understand. For instance, the most troublesome part is that the shader cuts off a bit of bottom and right parts of the background, as if it's left top corner was placed at [0,0] coordinates of the screen, and I can't change that at all, is there any way to do so?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #995 on: February 05, 2018, 06:30:02 PM »
Also, what are CutIns? Even thought I've heard of them, I don't know what they are.

See gtbot's video:
https://www.youtube.com/watch?v=6o3X5QWzDus

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #996 on: February 05, 2018, 09:42:20 PM »
As for the shaders, now I kinda get how it works, though there are parts that I still don't understand. For instance, the most troublesome part is that the shader cuts off a bit of bottom and right parts of the background, as if it's left top corner was placed at [0,0] coordinates of the screen, and I can't change that at all, is there any way to do so?
They are placed at (0,0) firstly because when drawing to a render target, you are literally drawing a new 1024x512 texture so of course the top-left is (0,0), and secondly because past a certain drawing layer the origin is set to (0,0) relative to the window rather than (32,16) like with the STG frame (this applies to everything, it isn't a render target or shader thing).

So I'm guessing that the reason it's clipping for you is because you only draw 384x448 on the upper background layer. The bottom one looks sufficiently sized. You could also just move it to (32, 16) but really just make it bigger.
« Last Edit: February 05, 2018, 10:15:39 PM by Drake »

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

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #997 on: February 06, 2018, 01:32:23 AM »
I'm just starting to mess with stage scripts, and there's significant lag when starting a plural (even if it was already loaded), more depending on the number of singles. I haven't noticed this in other people's stage scripts, so presumably there's some way around it.

I've tried a little bit to figure out how to add more singles to an already-running plural, in order to just load the first single to begin with and load the rest while that one is going. Is that a reasonable way to go about this?

In the meantime, I'm looking at all the random crap I'm #including in every single (from an index file) and wondering how much of the lag is caused by that. My guess is most of it.
Literally everything in this script will crash and burn.
1CC tracker

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #998 on: February 06, 2018, 02:47:40 AM »
IIRC, you can fix the lag on starting a script by handling the loading in the @Loading of the "outside" script. The lag is still there, but its all front-loaded towards the very beginning of the script, which is fine.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #999 on: February 06, 2018, 03:41:40 PM »
They are placed at (0,0) firstly because when drawing to a render target, you are literally drawing a new 1024x512 texture so of course the top-left is (0,0), and secondly because past a certain drawing layer the origin is set to (0,0) relative to the window rather than (32,16) like with the STG frame (this applies to everything, it isn't a render target or shader thing).

So I'm guessing that the reason it's clipping for you is because you only draw 384x448 on the upper background layer. The bottom one looks sufficiently sized. You could also just move it to (32, 16) but really just make it bigger.
I tried changing scales and positions of litteraly everything, but it still clips, also tried changing the white circle picture a little bit (the circle remains the same size, but there's more black background and it's 512x512), but that didn't affect anything. I may be not noticing something really obvious, so please be patient.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1000 on: February 06, 2018, 06:11:10 PM »
Ooook this is my bad for forgetting to include something.

Like I said earlier, render targets are 1024x512 in size, probably so it's the closest power of 2 to the screen size, which is 640x480. In the HLSL code, by default at the top it declares constants SCREEN_WIDTH and SCREEN_HEIGHT to 640x480. However the reason for this is just because the texture the sample script uses for its mask is 640x480. In fact it's commented "screen size (mask texture size)" in Japanese. So what's happening is that when it gets to the pixel sampling code, it does In.vPos.x/SCREEN_WIDTH to get texture coordinates (which are ratios, from 0 to 1), so e.g. it would try to get texture x-coordinate 1024/640 = 1.6, which isn't valid. It will just clip after it reaches (640,480), and that result is of course squashed, ending up at (640/1024)*640 by (480/512)*480, or 400x450. You can actually notice that your circle isn't actually circular either; this is because the divisions aren't equal ratios: 480/512 > 640/1024.

The solution is simple, just change the constants in the HLSL to 1024 and 512. I also rename them to RENDER_WIDTH/HEIGHT instead for clarity.
« Last Edit: February 06, 2018, 06:16:20 PM by Drake »

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1001 on: February 06, 2018, 07:04:19 PM »
Ooook this is my bad for forgetting to include something.

Like I said earlier, render targets are 1024x512 in size, probably so it's the closest power of 2 to the screen size, which is 640x480. In the HLSL code, by default at the top it declares constants SCREEN_WIDTH and SCREEN_HEIGHT to 640x480. However the reason for this is just because the texture the sample script uses for its mask is 640x480. In fact it's commented "screen size (mask texture size)" in Japanese. So what's happening is that when it gets to the pixel sampling code, it does In.vPos.x/SCREEN_WIDTH to get texture coordinates (which are ratios, from 0 to 1), so e.g. it would try to get texture x-coordinate 1024/640 = 1.6, which isn't valid. It will just clip after it reaches (640,480), and that result is of course squashed, ending up at (640/1024)*640 by (480/512)*480, or 400x450. You can actually notice that your circle isn't actually circular either; this is because the divisions aren't equal ratios: 480/512 > 640/1024.

The solution is simple, just change the constants in the HLSL to 1024 and 512. I also rename them to RENDER_WIDTH/HEIGHT instead for clarity.
Thanks, that's exactly what I need, now the struggle is finaly over. Also, is there any tutorials on render targets, etc.? I didn't understand some parts of your code, and that may be useful for me in the future.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1002 on: February 07, 2018, 05:52:11 AM »
Render targets are sort of virtual canvases that you can draw things on. Rather than drawing something on the game window, you draw it onto the virtual space. Then you can use the render target itself as a texture for further work, just as though it was a texture you were loading from a file. If you test out how they work, and use the SaveRenderedTextureA1 function, you should be able to see what's happening.

You can draw onto a render target using either RenderToTextureA1, which takes a specified range of drawing layers and draws them onto the render target, or RenderToTextureB1, which draws specific objects onto the target. Both of these functions also have a "clear" argument, which if true will wipe whatever's currently on the render target. If you don't, whatever is on the render target will persist, even going into further frames. This is why in the code I wrote, each frame I use (i==0) to evaluate to true only when processing the first object to be drawn, because I want to clear what was drawn on the previous frame, but keep drawing the other objects without clearing. Additionally, I use Obj_SetVisible to draw the objects onto the render texture, but make them invisible afterward so that they aren't also drawn normally to the game window.

For a simple render target example, you can do something like

Code: [Select]
let obj1 = ObjPrim_Create(OBJ_SPRITE_2D);
// set up and position obj1
let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
// set up and position obj2
let obj3 = ObjPrim_Create(OBJ_SPRITE_2D);
// set up and position obj3

CreateRenderTarget("example_texture");
RenderToTextureB1("example_texture", obj1, false); Obj_Delete(obj1);
RenderToTextureB1("example_texture", obj2, false); Obj_Delete(obj2);
RenderToTextureB1("example_texture", obj3, false); Obj_Delete(obj3);
// "example_texture" now has three objects drawn on it, despite the objects being deleted now

let obj4 = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj4, "example_texture");     // use the render target as texture
ObjSprite2D_SetSourceRect(obj4, 0, 0, 256, 256); // for example
ObjSprite2D_SetDestRect(obj4, 0, 0, 256, 256);
ObjRender_SetPosition(obj4, 192, 224);
// spin it
let t = 0;
loop{
  ObjRender_SetAngleZ(obj4, t);
  t = (t+3) % 360;
}
« Last Edit: February 07, 2018, 05:57:00 AM by Drake »

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

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1003 on: February 08, 2018, 02:58:21 AM »
I've suddenly got a bunch of free time and thought to at least make something in Danmakufu, so I settled on a Mai and Satono fight.
That said, I've no idea how to go about spawning two bosses onscreen, since Danmakufu only allows one boss to be registered.
So, uh... how can I go about doing that?
Lunatic 1cc: EoSD, PCB, IN, MoF, TD, DDC, LoLK, HSiFS, WBaWC

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1004 on: February 08, 2018, 04:17:45 AM »
You can use a regular enemy for the second boss, and either have "shared life" by adding an extra ObjEnemy_SetIntersectionCircleToShot on the second boss coordinates, or have the two enemies have their own life counters as normal and add extra logic to your life checks to handle the cases where one enemy runs out of life before the other. Boss enemies are still just Enemy objects; creating them as OBJ_ENEMY_BOSS just connects them to the Boss Scene object and doesn't actually do a huge amount.
« Last Edit: February 08, 2018, 04:27:03 AM by Drake »

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

R. P. Genocraft

  • Craftsman of absolute unpredictability
  • Boundary of productive and lazy
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1005 on: February 09, 2018, 03:44:52 PM »
How do I make the player stop moving in a Sakuya-like timestop?

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1006 on: February 09, 2018, 04:54:15 PM »
How do I make the player stop moving in a Sakuya-like timestop?
There is no function to disable player control looking at the wiki. Never implemented this myself, but brainstorming here are few things you can try to experiment with:
- Drop player movement to 0 and restore it post time stop
- Lock and force X Y location of player and release post time stop

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1007 on: February 09, 2018, 05:08:36 PM »
There is no function to disable player control looking at the wiki. Never implemented this myself, but brainstorming here are few things you can try to experiment with:
- Drop player movement to 0 and restore it post time stop
- Lock and force X Y location of player and release post time stop

If you do the former, make sure to restore player movement in your Single Finalize task if the boss dies during the time stop. In the Artifact 3 contest, some people neglected to restore player movement, resulting in an inability to continue gameplay until the next time stop.

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1008 on: February 12, 2018, 11:17:43 PM »
How can I fix the cutin, the lifebar and the timer?
"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 #1009 on: February 13, 2018, 01:19:55 AM »
How can I fix the cutin, the lifebar and the timer?

What are you trying to do, what are you currently doing, and what code are you using?

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1010 on: February 13, 2018, 01:30:39 AM »
If you want to be using the whole screen width, then realize that whatever code you're using from other people isn't necessarily going to be adjusted for that. You need to get in there and change the positions or lengths as needed.

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

PyuDi

  • daily touhou~
  • danmakufu!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1011 on: February 13, 2018, 10:09:21 AM »
How can I make the danmakufu .exe file that runs only specified script? (As in touhou FFF - th_dnh_fff.exe)

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1012 on: February 13, 2018, 10:20:30 AM »
The th_dnh.def file is a config file that lets you run a specific package script. You must actually use a package script.
Code: [Select]
// Example th_dnh.def
package.script.main = script/path/to/package.dnh
window.title = some title
screen.width = 640

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

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1013 on: February 14, 2018, 12:01:06 AM »
I'm trying to do the following:
Code: [Select]
if(PlayerDying){
    dont;
}
That is, interrupt the player's rebirth frames, like if they'd counter-bombed.

What actually stops the player dying when they counter-bomb?

Also, I'm trying to do something weird where the player controls another thing and the actual player object stays in place. I've got the controlling it part handled, but I'm running into difficulties with giving it a hitbox, since ObjPlayer_AddIntersectionCircleA1 is meant to be set once rather than each frame.
« Last Edit: February 14, 2018, 01:39:38 AM by Andi »
Literally everything in this script will crash and burn.
1CC tracker

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1014 on: February 14, 2018, 12:01:34 AM »
What are you trying to do, what are you currently doing, and what code are you using?
  • I want the score/history to be all the way to the right(with the spell name),
  • the lifebar expand to the other side, almost touching the timer
I'm using gtBot cutin and the default system lifebar
« Last Edit: February 14, 2018, 01:55:50 AM by jao »
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1015 on: February 14, 2018, 04:04:51 AM »
I'm trying to do the following:
Code: [Select]
if(PlayerDying){
    dont;
}
That is, interrupt the player's rebirth frames, like if they'd counter-bombed.

What actually stops the player dying when they counter-bomb?
I have no idea. It seems like Danmakufu itself just seems to be hard-coded to stop the death process if a bomb is initiated (this can also be done with the CallSpell function). This basically means that forcing the player to bomb upon getting hit is the only way to keep them alive. Fortunately, all the system needs is to recognize that a bomb has been activated. It doesn't have to actually do anything. In order for it to accept it as a valid bomb, I believe you simply need to have to call SetScriptResult(true); in the EV_REQUEST_SPELL block to signal to the system that the bomb has been activated. Following that, I think you just need to call Obj_Delete(GetSpellManageObject); to make sure the bomb ends as soon as it activates so it's doesn't do anything but save you from death. You may need to add some invincibility frames though, just to make sure the player isn't immediately hit again.

Also, I'm trying to do something weird where the player controls another thing and the actual player object stays in place. I've got the controlling it part handled, but I'm running into difficulties with giving it a hitbox, since ObjPlayer_AddIntersectionCircleA1 is meant to be set once rather than each frame.
It looks like you can use ObjPlayer_AddIntersectionCircleA1 to add any number of player hitboxes, but the location of them seems to be forced to be relative to the player object's location and not independently controllable. You might have to do something hacky to make that work, like make the player's true object location be different from where it appears to be or to manually code an independent hitbox yourself.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1016 on: February 14, 2018, 07:32:34 AM »
If it's relative to the player location you can set it to (-player_x + hitbox_x, -player_y + hitbox_y) for an absolute position, if that's an issue. You can also start with ObjPlayer_ClearIntersection(player) followed by the hitbox additions to set them every frame, even though that's pretty janky.
« Last Edit: February 14, 2018, 07:44:56 AM by Drake »

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

Andi

  • World's Gayest Danmaku
  • PlaySE("./se/Nyaa.wav");
    • 2hu blog
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1017 on: February 14, 2018, 06:45:13 PM »
If it's relative to the player location you can set it to (-player_x + hitbox_x, -player_y + hitbox_y) for an absolute position, if that's an issue. You can also start with ObjPlayer_ClearIntersection(player) followed by the hitbox additions to set them every frame, even though that's pretty janky.
I tried it like this already, but somehow the hitbox just stays on the player. The old one gets cleared and replaced with the new one (based on size), but it's still in the same place.
Literally everything in this script will crash and burn.
1CC tracker

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1018 on: February 16, 2018, 09:35:14 AM »
I tested a very basic example and didn't have any problems, but when trying to implement this exactly I found what the problem here is. There is a bug when using ObjPlayer_AddIntersectionCircleA1 then ObjPlayer_ClearIntersection followed by another AddIntersection. No matter how many hitboxes you add initially, once you clear them, if you use AddIntersection again it will "ignore" the new hitbox you specify. Instead, it will recreate each hitbox that was previously set, one at a time. Following this, it will create the hitboxes specified after the clear, in order, even if it was "ignored" at first to put in one of the previous ones. Additionally, I found that if you use AddIntersectionCircleA2 to set only a grazebox, clear hitboxes, then add a hitbox, it will recreate the grazebox as a hitbox instead (with the hitbox size of the newly specified one), and this is where it gets really spicy.

I'd like to illustrate this better soon because I'm basically trying to reverse-engineer the behaviour through testing, but I don't quite yet have enough testing info to say what exactly is going on internally. The grazebox stuff is potentially useful information but gets really complicated once you start poking it.


But long story short you won't be able to do the shikigami-like behaviour this way. What I would suggest to do instead is to not use the Player object to draw the player sprite, but use a separate Sprite object that just follows the player position. But only conditionally, instead having the sprite stay put when the shikigami effect happens (and switching to another sprite on top of the player). No hitbox shenanigans.
« Last Edit: February 16, 2018, 09:53:04 AM by Drake »

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

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1019 on: February 17, 2018, 01:44:52 AM »
Is there a collection of useful functions in one txt/dnh file?
For me, useful funcs is:
  • Get the Center X and Y screen
  • Screenshake
  • Turn bullet and stop turning
  • Reflect bottom
  • Bullets that origins from a bullet
  • Make shapes(square, pentagon, star)
  • and etc.
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern