emoose / silent-hill-decomp

0.001%
8 stars 0 forks source link

Global structs / character data #1

Open emoose opened 6 months ago

emoose commented 6 months ago

Haven't really mapped out that many fields for those structs yet besides some loop-state-index stuff, but did find that SYS_W holds data related to characters, SysWork+0x4C / 0x800BA00C is where character data begins, data seems to be laid out like:

  CharacterData player_4C;
  PlayerCharExtra player_extra_174; // 0x28 bytes, unsure of purpose
  CharacterData other_char_1A0[6];

I'm not really sure what's up with that player_extra field, my first thought was maybe player chara was a different struct that inherits from CharacterData with some extra fields at the end, but seems there's a lot of code that fetches pointer to player_extra_174 specifically, so guess it must be its own struct instead.

(oddly the field types inside that PlayerCharExtra seem to match very closely to the first few fields inside CharacterData, maybe it's just some kind of backup data for some reason? not really sure though)

other_char seems to be used for both NPCs and enemies too afaik, one of the fields at the start of CharacterData likely says the type of the chara.

Very rough CharacterData struct:

struct CharacterData
{
  u_char field_0;
  char field_1;
  char field_2;
  char field_3;
  u_char field_4;
  char field_5;
  __int16 flags_6;
  int field_8;
  u_short field_C;
  __int16 field_E;
  int field_10[2];
  int pos_x_18;
  int pos_y_1C;
  int pos_z_20;
  __int16 rot_pitch_24;
  __int16 rot_yaw_26;
  __int16 rot_roll_28;
  u_char unk_2A[0x6];
  u_char unk_30[0xF8];
};

Interestingly that's starting to look similar to SH2's SubCharacter struct: https://github.com/Sparagas/Silent-Hill/blob/7734098689a67e2f041f9bbfb2f2a5a64cce4aaf/dwarf2cpp/Silent%20Hill%202%20(USA)%20(En%2CJa)%20(Beta)/SLUS_202_28/work/sh2(CVS%E5%85%A8%E5%8F%96%E5%BE%97)/src/MC/savedata.c#L88