Priw8 / sht-webedit

a tool for editing .sht files used in various Touhou games
20 stars 5 forks source link

Unknown values #6

Open Priw8 opened 5 years ago

Priw8 commented 5 years ago

As of now, there are a lot of unknown values (especially in the newest games). They should be researched and documented. At the time of writing, I have already done some research:

Please answer this issue if you confirm/figure something out

Priw8 commented 5 years ago

It's also worth noting that unknown values in the header (main) aren't confirmed to be int32

Priw8 commented 5 years ago

unknown_0 might be related to amount of power you get for 1 power item (at least in SA)

Priw8 commented 5 years ago

unknown_0 confirmed to be a power gain divisor in SA (value is unused in other versions). f(unknown_0) = 100/unknown_0 = power_gain_per_item setting it to 0 crashes the game when it loads the shottype. It's worth to note that the game keeps track of the floating point resulting from the division. Basically with unknown_0 = 40 => power_gain_per_item = 2.5 the game alternates between giving 2 and 3 power every time a power item is collected.

Priw8 commented 5 years ago

unknown_sht_int16 confirmed to be sound effect ID when shooter fires a bullet for all games, -1 being no sound effect. Example IDs (from UFO):


0 - default amulet shot sfx
1 - slightly different than 0???? idk maybe I'm hearing things
2 - player death sound (pichuun~)
3 - fairy death sound
4 - same as 3????
5 - boss explosion
6 - UFO explosion
7 - menu selection/cursor move I'm honestly not sure
Priw8 commented 5 years ago

unknown_1 confirmed to be max damage dealt to a given entity on a single frame (exists since DDC... as it can easily be noticed, ZUN didn't make good use of it lmao). Bombs are also affected by this

Priw8 commented 5 years ago

theory: unknown_sht_byte doesn't exist and option is secretly int16

RUEEE commented 5 years ago

here are some thing about data in th15 your "flag0" in fact is not a flag,it's rate2 and delay2(1byte each). the rate2 and delay2 are used in the type of attack whose attack rate is bigger than 128 frame,like sanae's frog in th15 or summer sub in th16. the flags in shooter are not words instead,they are dwords,totally there are 12flags. when .sht file is read in game,the flags are replaced with specific functions(normally thiscall). and only the first 4 flags are used by 2un. the flag3 is replaced by function but I can't find anywhere it is called,maybe 2un just do not use this flag(in th15) Additionally the flags have different enums in different games. in th15: the first flag(the flag1&2) can be 1,2,3,4,5 the 2nd flag can be 1,2,3,4 the 3rd flag can be 1,2 the 4th flag can be 1,2,3,4,5,6

RUEEE commented 5 years ago

about laser of marisa: in th15,the laser is limited by option.normally one option matches one laser. For deep reason, the unknown byte after option is a flag for laser. when the byte is 2,the bullet is assigned to an option(it works in th15,but in th14,it's 3) In fact reimu A 's weapen(御币?) in th14 uses this flag.(it's num 2)

Priw8 commented 5 years ago

@RUEEE thanks, this explains a lot of things. I'll try to update the editor soon

ExpHP commented 4 years ago

Minor correction:

rate2/delay2 are specifically for fire rates that are not factors of 15 (and they should be chosen to be factors of 120). This is because the timer used for rate/delay gets reset to 0 every time it reaches 15. (basically, it is the same timer that the game uses to force the player to shoot in increments of 0.25s).

You can get a pretty vivid example of why the difference matters by trying rate = 6, delay = 5:

using rate1/delay1: 0 1 2 3 4 (5) 6 7 8 9 10 (11) 12 13 14 00 01 02 03 04 (05) 06 07 08 09 10 (11) 12 13 14 00 01... using rate2/delay2: 0 1 2 3 4 (5) 6 7 8 9 10 (11) 12 13 14 15 16 (17) 18 19 20 21 22 (23) 24 25 26 27 28 (29)...

image

Interestingly, th14 and th143 have space for rate2/delay2, but do not actually implement it. I think it's just padding from having an int32 after an int16.

I am fairly certain that the four functions are, in all games from th07 to th17:

I'll be submitting a PR once I finish checking everything. (I want to make sure PCB calls the latter two, and to check whether PoFV calls on_draw)

ExpHP commented 4 years ago

sighhhhhhhhh..... PCB is different.

Or at least, it stores them in a different order on the bullet. (PCB and IN copy them onto each bullet). In PCB, on_hit has an offset that is 0xc less than on_draw

...nope I just misread it.