fix battle area number normalization and add more structs/enums

This commit is contained in:
Martin Michelsen
2024-01-30 21:10:50 -08:00
parent 340fbb8ca5
commit 4830f5a41e
12 changed files with 72 additions and 29 deletions
+30 -17
View File
@@ -4531,19 +4531,21 @@ struct G_DropItem_PC_V3_BB_6x5F : G_DropItem_DC_6x5F {
// 6x60: Request for item drop (handled by the server on BB)
struct G_StandardDropItemRequest_DC_6x60 {
G_UnusedHeader header;
uint8_t floor = 0;
uint8_t rt_index = 0;
le_uint16_t entity_id = 0;
le_float x = 0.0f;
le_float z = 0.0f;
le_uint16_t section = 0;
le_uint16_t ignore_def = 0;
/* 00 */ G_UnusedHeader header;
/* 04 */ uint8_t floor = 0;
/* 05 */ uint8_t rt_index = 0;
/* 06 */ le_uint16_t entity_id = 0;
/* 08 */ le_float x = 0.0f;
/* 0C */ le_float z = 0.0f;
/* 10 */ le_uint16_t section = 0;
/* 12 */ le_uint16_t ignore_def = 0;
/* 14 */
} __packed__;
struct G_StandardDropItemRequest_PC_V3_BB_6x60 : G_StandardDropItemRequest_DC_6x60 {
uint8_t effective_area = 0;
parray<uint8_t, 3> unused;
/* 14 */ uint8_t effective_area = 0;
/* 15 */ parray<uint8_t, 3> unused;
/* 18 */
} __packed__;
// 6x61: Activate MAG effect
@@ -5013,9 +5015,19 @@ struct G_SetChallengeModeData_6x7C {
struct G_SetBattleModeData_6x7D {
G_UnusedHeader header;
uint8_t unknown_a1 = 0; // Must be < 7; used in jump table
parray<uint8_t, 3> unused;
parray<le_uint32_t, 4> unknown_a2;
// Values for what (0-6; values 7 and above are not valid):
// 0 = Unknown (params[0] and [1] are used)
// 1 = Does nothing
// 2 = Unknown (no params are used)
// 3 = Set player meseta score (params[0] = client ID, [1] = score)
// 4 = Unknown (params[0] = client ID)
// 5 = Unknown (no params are used)
// 6 = Unknown (all params are used)
uint8_t what = 0;
uint8_t unknown_a1 = 0; // Only used when what == 0
uint8_t unused = 0;
uint8_t is_alive = 0; // Only used when what == 3
parray<le_uint32_t, 4> params;
} __packed__;
// 6x7E: Unknown (not valid on Episode 3)
@@ -5302,10 +5314,11 @@ struct G_Unknown_6xA1 {
// server on BB)
struct G_SpecializableItemDropRequest_6xA2 : G_StandardDropItemRequest_PC_V3_BB_6x60 {
le_float param3 = 0.0f;
le_uint32_t param4 = 0;
le_uint32_t param5 = 0;
le_uint32_t param6 = 0;
/* 18 */ le_float param3 = 0.0f;
/* 1C */ le_uint32_t param4 = 0;
/* 20 */ le_uint32_t param5 = 0;
/* 24 */ le_uint32_t param6 = 0;
/* 28 */
} __packed__;
// 6xA3: Olga Flow boss actions (not valid on pre-V3 or Episode 3)
+1 -1
View File
@@ -117,7 +117,7 @@ uint8_t ItemCreator::normalize_area_number(uint8_t area) const {
}
} else {
return this->restrictions->box_drop_area;
return this->restrictions->box_drop_area - 1;
}
}
+27 -1
View File
@@ -715,7 +715,7 @@ BattleRules::BattleRules(const JSON& json) {
this->tool_mode = json.get_enum("ToolMode", this->tool_mode);
this->trap_mode = json.get_enum("TrapMode", this->trap_mode);
this->unused_F817 = json.get_int("UnusedF817", this->unused_F817);
this->respawn_mode = json.get_int("RespawnMode", this->respawn_mode);
this->respawn_mode = json.get_enum("RespawnMode", this->respawn_mode);
this->replace_char = json.get_int("ReplaceChar", this->replace_char);
this->drop_weapon = json.get_int("DropWeapon", this->drop_weapon);
this->is_teams = json.get_int("IsTeams", this->is_teams);
@@ -917,6 +917,32 @@ BattleRules::MesetaMode enum_for_name<BattleRules::MesetaMode>(const char* name)
}
}
template <>
const char* name_for_enum<BattleRules::RespawnMode>(BattleRules::RespawnMode v) {
switch (v) {
case BattleRules::RespawnMode::ALLOW:
return "ALLOW";
case BattleRules::RespawnMode::FORBID:
return "FORBID";
case BattleRules::RespawnMode::LIMIT_LIVES:
return "LIMIT_LIVES";
default:
throw invalid_argument("invalid BattleRules::MesetaDropMode value");
}
}
template <>
BattleRules::RespawnMode enum_for_name<BattleRules::RespawnMode>(const char* name) {
if (!strcmp(name, "ALLOW")) {
return BattleRules::RespawnMode::ALLOW;
} else if (!strcmp(name, "FORBID")) {
return BattleRules::RespawnMode::FORBID;
} else if (!strcmp(name, "LIMIT_LIVES")) {
return BattleRules::RespawnMode::LIMIT_LIVES;
} else {
throw invalid_argument("invalid BattleRules::MesetaDropMode name");
}
}
static PlayerInventoryItem make_template_item(bool equipped, uint64_t first_data, uint64_t second_data) {
return PlayerInventoryItem(ItemData(first_data, second_data), equipped);
}
+6 -2
View File
@@ -577,6 +577,11 @@ struct BattleRules {
FORBID_ALL = 1,
CLEAR_AND_ALLOW = 2,
};
enum class RespawnMode : uint8_t {
ALLOW = 0,
FORBID = 1,
LIMIT_LIVES = 2,
};
// Set by quest opcode F812, but values are remapped.
// F812 00 => FORBID_ALL
@@ -608,8 +613,7 @@ struct BattleRules {
// F818 00 => 01
// F818 01 => 00
// F818 02 => 02
// TODO: Define an enum class for this field.
/* 06 */ uint8_t respawn_mode = 0;
/* 06 */ RespawnMode respawn_mode = RespawnMode::ALLOW;
// Set by quest opcode F819.
/* 07 */ uint8_t replace_char = 0;
// Set by quest opcode F81A, but value is inverted.
+1 -1
View File
@@ -10,7 +10,7 @@
"MagMode": "ALLOW",
"ToolMode": "ALLOW",
"TrapMode": "ALL_PLAYERS",
"RespawnMode": 0,
"RespawnMode": "ALLOW",
"ReplaceChar": 0,
"DropWeapon": 1,
"IsTeams": 1,
+1 -1
View File
@@ -5,7 +5,7 @@
"MagMode": "FORBID_ALL",
"ToolMode": "CLEAR_AND_ALLOW",
"TrapMode": "ALL_PLAYERS",
"RespawnMode": 0,
"RespawnMode": "ALLOW",
"ReplaceChar": 1,
"DropWeapon": 1,
"IsTeams": 0,
+1 -1
View File
@@ -5,7 +5,7 @@
"MagMode": "FORBID_ALL",
"ToolMode": "CLEAR_AND_ALLOW",
"TrapMode": "ALL_PLAYERS",
"RespawnMode": 2,
"RespawnMode": "LIMIT_LIVES",
"ReplaceChar": 1,
"DropWeapon": 0,
"IsTeams": 0,
+1 -1
View File
@@ -5,7 +5,7 @@
"MagMode": "FORBID_ALL",
"ToolMode": "CLEAR_AND_ALLOW",
"TrapMode": "ALL_PLAYERS",
"RespawnMode": 2,
"RespawnMode": "LIMIT_LIVES",
"ReplaceChar": 1,
"DropWeapon": 1,
"IsTeams": 0,
+1 -1
View File
@@ -5,7 +5,7 @@
"MagMode": "FORBID_ALL",
"ToolMode": "ALLOW",
"TrapMode": "ALL_PLAYERS",
"RespawnMode": 1,
"RespawnMode": "FORBID",
"ReplaceChar": 0,
"DropWeapon": 1,
"IsTeams": 1,
+1 -1
View File
@@ -5,7 +5,7 @@
"MagMode": "FORBID_ALL",
"ToolMode": "CLEAR_AND_ALLOW",
"TrapMode": "ALL_PLAYERS",
"RespawnMode": 2,
"RespawnMode": "LIMIT_LIVES",
"ReplaceChar": 1,
"DropWeapon": 1,
"IsTeams": 1,
+1 -1
View File
@@ -5,7 +5,7 @@
"MagMode": "FORBID_ALL",
"ToolMode": "CLEAR_AND_ALLOW",
"TrapMode": "ALL_PLAYERS",
"RespawnMode": 2,
"RespawnMode": "LIMIT_LIVES",
"ReplaceChar": 1,
"DropWeapon": 1,
"IsTeams": 0,
+1 -1
View File
@@ -5,7 +5,7 @@
"MagMode": "FORBID_ALL",
"ToolMode": "CLEAR_AND_ALLOW",
"TrapMode": "ALL_PLAYERS",
"RespawnMode": 2,
"RespawnMode": "LIMIT_LIVES",
"ReplaceChar": 1,
"DropWeapon": 0,
"IsTeams": 0,