nipkownix / re4_tweaks

Fixes and tweaks for the "UHD" port of Resident Evil 4
zlib License
342 stars 32 forks source link

Randomized Puzzles #398

Open pas-de-2 opened 1 year ago

pas-de-2 commented 1 year ago

Describe the feature you'd like to see added

It took me way too long to realize the puzzles in this game aren't randomized. The r20e slide puzzle, r209 portrait puzzle, and r117 church light puzzle would all lend themselves well to having their init values randomized. Need to be careful to only generate solvable slide puzzles, though, and also maybe the same disclaimer for the gallery.

DarthxVoid commented 1 year ago

It would be very interesting to be able to randomize the game's puzzles, it would give a new gameplay, and it would be more interesting even for us modders to customize the puzzles

pas-de-2 commented 1 year ago

@emoose, any idea what might be going on with this c9puzzle_20e struct? IDB says it should be size 0x205, but it's asserting as 0x208, and trying to compile I get a warning about 'c9puzzle_20e': Alignment specifier is less than actual alignment (4), and will be ignored. Something to do with the __unaligned keyword, maybe?

struct c9puzzle_20e_innerStruct10
{
    uint32_t field_0;
    uint8_t unk_4[4];
    cObj* objPtr_8;
    Vec field_C;
    uint8_t unk_18[16];
};
assert_size(c9puzzle_20e_innerStruct10, 0x28);

struct __declspec(align(1)) c9puzzle_20e
{
    int field_0; // highlighted tile x index
    int field_4; // highlighted tile y index
    uint32_t field_8; // final tile index (8)
    cObj* ObjPtr_C; // highlight cursor ptr
    c9puzzle_20e_innerStruct10 innerStruct_10[8];
    uint8_t unk_150[4];
    uint8_t field_154;
    uint8_t unk_155[3];
    uint32_t field_158;
    uint8_t unk_15C[28];
    Vec field_178;  // index 1? coords
    uint8_t field_184;  // index 1? current tileNum
    uint8_t unk_185[3];
    Vec field_188; // index 2? coords
    uint8_t field_194; // ...
    uint8_t unk_195[3];
    Vec field_198;
    uint8_t field_1A4;
    uint8_t unk_1A5[3];
    Vec field_1A8;
    uint8_t field_1B4;
    uint8_t unk_1B5[3];
    Vec field_1B8;
    uint8_t field_1C4;
    uint8_t unk_1C5[3];
    Vec field_1C8;
    uint8_t field_1D4;
    uint8_t unk_1D5[3];
    Vec field_1D8;
    uint8_t field_1E4;
    uint8_t unk_1E5[3];
    Vec field_1E8;
    uint8_t field_1F4;
    uint8_t unk_1F5[3];
    Vec field_1F8;
    uint8_t field_204;
};
assert_size(c9puzzle_20e, 0x205);
emoose commented 1 year ago

It might be fine to leave VS align it to 4 and make it 0x208 bytes, seems game itself might be aligning it that way inside R20E_WORK_mb anyway:

image

Alternately you might be able to use

#pragma pack(push, 1)
struct xxx...
#pragma pack(pop)

I usually found pragma pack works better than __declspec(align) at least.

pas-de-2 commented 1 year ago

Pragma pack got it to compile without complaining, but couldn't get the struct to align right either way 😢