No Description

battle_structs.h 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. #ifndef BATTLE_STRUCT_H_
  2. #define BATTLE_STRUCT_H_
  3. #include <types.h>
  4. struct side_affecting_hword{
  5. u16 reflect_on : 1;
  6. u16 light_screen_on : 1;
  7. u16 unkown1 : 2;
  8. u16 spikes_on : 1;
  9. u16 safeguard_on : 1;
  10. u16 unkown2 : 2;
  11. u16 mist_on : 1;
  12. u16 spikes_damage_done : 1;
  13. };
  14. extern struct side_affecting_hword side_affecting_halfword[2];
  15. struct status_main{
  16. u32 sleep : 3;
  17. u32 poison : 1;
  18. u32 burn : 1;
  19. u32 freeze : 1;
  20. u32 paralysis: 1;
  21. u32 toxic_poison : 1;
  22. u32 poison_counter : 4;
  23. };
  24. union main_status{
  25. u32 int_status;
  26. struct status_main flags;
  27. };
  28. struct protect_struct{
  29. u8 flag0_protect : 1;
  30. u8 flag0_endure : 1;
  31. u8 flag0_onlystruggle : 1;
  32. u8 flag0_helpinghand : 1;
  33. u8 flag0_bouncemove : 1;
  34. u8 flag0_stealmove : 1;
  35. u8 flag0_unknown: 1;
  36. u8 flag0_prlz_immobility: 1;
  37. u8 flag1_confusion_self_damage: 1;
  38. u8 flag1_noteffective: 1;
  39. u8 flag1_chargingturn: 1; //dive, dig etc.
  40. u8 flag1_smokeballflee: 1;
  41. u8 flag1_runaway_flee: 1;
  42. u8 flag1_used_imprisoned_move: 1;
  43. u8 flag1_love_immobility: 1;
  44. u8 flag1_used_disabled_move: 1;
  45. u8 flag2_used_taunted_move: 1;
  46. u8 flag2_unknown: 1;
  47. u8 flag2_flinch_immobility : 1;
  48. u8 flag2_notfirststrike : 1;
  49. u8 flag2_free: 4;
  50. u8 field3;
  51. u32 physical_damage;
  52. u32 special_damage;
  53. u8 counter_target;
  54. u8 mirrorcoat_target;
  55. u16 fieldE;
  56. };
  57. extern struct protect_struct battle_protect[4];
  58. #define STATUS_SLEEP 0x7
  59. #define STATUS_POISON 0x8
  60. #define STATUS_BURN 0x10
  61. #define STATUS_FREEZE 0x20
  62. #define STATUS_PARALYSIS 0x40
  63. #define STATUS_TOXIC_POISON 0x80
  64. struct flags2{
  65. u32 confusion : 3;
  66. u32 flinched : 1;
  67. u32 uproar : 3;
  68. u32 flag_x80 : 1;
  69. u32 bide : 2;
  70. u32 locked_and_confuse : 2;
  71. u32 multiple_turn_move : 1;
  72. u32 trapped_in_wrap : 3;
  73. u32 in_love : 4;
  74. u32 focus_energy : 1;
  75. u32 transformed : 1;
  76. u32 recharge : 1;
  77. u32 raged : 1;
  78. u32 substitute : 1;
  79. u32 destinny_bond : 1;
  80. u32 cant_escape : 1;
  81. u32 nightmare : 1;
  82. u32 cursed : 1;
  83. u32 foresight : 1;
  84. u32 defense_curled : 1;
  85. u32 tormented : 1;
  86. };
  87. struct iv_set
  88. {
  89. u32 iv_hp: 5;
  90. u32 iv_atk: 5;
  91. u32 iv_def: 5;
  92. u32 iv_spd: 5;
  93. u32 iv_sp_atk: 5;
  94. u32 iv_sp_def: 5;
  95. };
  96. struct pokemon{
  97. u32 PID;
  98. u32 OTID;
  99. char name[10];
  100. u16 language;
  101. u8 OT_name[7];
  102. u8 markings;
  103. u16 checksum;
  104. u16 padding_maybe;
  105. u8 data[48];
  106. u32 ailment;
  107. u8 level;
  108. u8 pokerus;
  109. u16 current_hp;
  110. u16 total_hp;
  111. u16 attack;
  112. u16 defense;
  113. u16 speed;
  114. u16 sp_attack;
  115. u16 sp_defense;
  116. };
  117. extern struct pokemon party_opponent[6];
  118. extern struct pokemon party_player[6];
  119. struct battle_participant {
  120. u16 poke_species;
  121. u16 atk;
  122. u16 def;
  123. u16 spd;
  124. u16 sp_atk;
  125. u16 sp_def;
  126. u16 moves[4];
  127. struct iv_set ivs;
  128. u8 hp_buff;
  129. u8 atk_buff;
  130. u8 def_buff;
  131. u8 spd_buff;
  132. u8 sp_atk_buff;
  133. u8 sp_def_buff;
  134. u8 acc_buff;
  135. u8 evasion_buff;
  136. u8 ability_id;
  137. u8 type1;
  138. u8 type2;
  139. u8 padd;
  140. u8 current_pp[4];
  141. u16 current_hp;
  142. u8 level;
  143. u8 happiness;
  144. u16 max_hp;
  145. u16 held_item;
  146. u8 poke_name[12];
  147. u8 trainer_name[8];
  148. u32 padd2;
  149. u32 pid;
  150. union main_status status;
  151. struct flags2 status2;
  152. u32 otid;
  153. };
  154. extern struct battle_participant battle_participants[4];
  155. struct side_timer{
  156. u8 reflect_timer;
  157. u8 reflect_bank;
  158. u8 lightscreen_timer;
  159. u8 lightscreen_bank;
  160. u8 mist_timer;
  161. u8 mist_bank;
  162. u8 safeguard_timer;
  163. u8 safeguard_bank;
  164. u8 followme_timer;
  165. u8 followme_target;
  166. u8 spikes_amount;
  167. u8 fieldB;
  168. };
  169. extern struct side_timer battle_side_timers[2];
  170. struct in_battle_weather{
  171. u32 rain : 1;
  172. u32 downpour : 1;
  173. u32 permament_rain : 1;
  174. u32 sandstorm : 1;
  175. u32 permament_sandstorm : 1;
  176. u32 sun : 1;
  177. u32 permament_sun : 1;
  178. u32 hail : 1;
  179. //custom flags
  180. u32 permament_hail : 1;
  181. u32 fog : 1;
  182. u32 permament_fog : 1;
  183. u32 harsh_sun : 1;
  184. u32 heavy_rain : 1;
  185. u32 air_current : 1;
  186. };
  187. struct status_3{
  188. u32 leech_seed_hp_receiver : 2; // 2 bits
  189. u32 leech_seed : 1; //4
  190. u32 always_hits : 2; //x8 | x10
  191. u32 perish_song : 1; //x20
  192. u32 on_air : 1; //x40
  193. u32 underground : 1;//80
  194. u32 minimized : 1; //x100
  195. u32 charged_up : 1; //x200
  196. u32 rooted : 1; //x400
  197. u32 yawn : 2; //x800 || x1000
  198. u32 imprision : 1; //x2000
  199. u32 grudge : 1; //x4000
  200. u32 unkown_no_crit : 1; //x8000
  201. u32 mud_sport : 1; //x10 000
  202. u32 watersport : 1; //x20 000
  203. u32 underwater : 1; //x40 000
  204. u32 switchinlock : 1; //x80 000
  205. u32 unburden : 1; //x100 000 (previously trace)
  206. u32 phantomforce : 1; //x200 000
  207. };
  208. extern struct status_3 battle_status_3[4];
  209. union battle_weather{
  210. u32 int_bw;
  211. struct in_battle_weather flags;
  212. };
  213. extern union battle_weather battle_weather;
  214. struct mirror_move_set_per_bank
  215. {
  216. u16 moves_per_target[4];
  217. };
  218. struct battle_stuff{
  219. u8 end_turn_statetracker1; //0x0
  220. u8 end_turn_checked_bank; //0x1
  221. u8 field_2; //0x2
  222. u8 end_turn_statetracker2; //0x3
  223. u16 trapped_move[4]; //0x4 - 0xB
  224. u8 move_target[4]; //0xC - 0xF
  225. u8 field_10; //0x10
  226. u8 field_11; //0x11
  227. u8 field_12; //0x12
  228. u8 dynamic_move_type; //0x13
  229. u8 trapper[4];//0x14-0x17
  230. u8 field_18[48]; //0x18-0x47
  231. u8 pre_attacks_bank_counter; //0x48
  232. u8 field_49; //0x49
  233. u8 money_multiplier; //0x4A
  234. u8 field_4B; //0x4B
  235. u8 switch_in_ability_bank_counter; //0x4C
  236. u8 field_4D[7]; //0x4D-0x53
  237. u8 field_54; //0x54
  238. u8 field_55; //0x55
  239. u8 field_56; //0x56
  240. u8 field_57; //0x57
  241. u8 field_58[4];
  242. u8 field_5C[35];
  243. u8 castform_switch_form; //0x7F
  244. u8 chosen_move_position[4]; //0x80
  245. u8 field_84[13]; //0x84-0x90
  246. u8 absent_bank_flags_prev_turn; //0x91
  247. u8 field_92[6]; //0x92-0x97
  248. u16 mirror_moves_pbs[4]; //0x98-0x9F
  249. u8 field_A0[18]; //0xA0-0xB1
  250. u8 synchronize_effect_chooser; //0xB2
  251. u8 field_B3[5];
  252. u16 used_held_items[4]; //0xB8-0xBF
  253. u8 field_C0[8]; //0xC0-0xC7
  254. u16 choiced_move[4]; //0xC8-0xCF (checked in cmd49)
  255. u16 changed_held_items[4]; //0xD0-0xD8 (later written to battlestruct in cmd49)
  256. u8 intimidate_user; //0xD8
  257. u8 switch_in_item_bank_counter; //0xD9
  258. u8 field_DA; //0xDA
  259. u8 field_DB; //0xDB
  260. u8 field_DC; //0xDC
  261. u8 field_DD; //0xDD
  262. u8 field_DE; //0xDE
  263. u8 field_DF; //0xDF
  264. struct mirror_move_set_per_bank mirror_move_set_pbs[4]; //0xE0-0xFF
  265. u8 field_100[162]; //0x100-0x1A1
  266. u8 battle_load_weather_from_map_flag; //0x1A2
  267. u8 atk_canceller_state_tracker; //0x1A3
  268. u8 field_1A4[240]; //0x1A4-0x293
  269. u8 switchout_index[4]; //0x294-0x297
  270. u8 field_298[11];
  271. u8 field_2A3;
  272. };
  273. struct battle_stuff_struct{
  274. struct battle_stuff *ptr;
  275. };
  276. extern struct battle_stuff_struct battle_stuff_ptr;
  277. struct prop_flags{
  278. u8 makes_contact : 1;//1
  279. u8 affected_by_protect : 1;//2
  280. u8 affected_by_magic_coat : 1;//4
  281. u8 affected_by_snatch : 1;//8
  282. u8 affected_by_mirrormove :1;//x10
  283. u8 affected_by_kingsrock :1;//x20
  284. u8 raised_crit_ratio :1;//x40
  285. u8 unused_bit : 1;//x80
  286. };
  287. union move_flags{
  288. u8 int_flag;
  289. struct prop_flags flags;
  290. };
  291. struct move_info{
  292. u8 script_id;
  293. u8 base_power;
  294. u8 type;
  295. u8 accuracy;
  296. u8 pp;
  297. u8 effect_chance;
  298. u8 target;
  299. s8 priority;
  300. union move_flags move_flags;
  301. u8 arg1;
  302. u8 split;
  303. u8 arg2;
  304. };
  305. struct b_enigma_berry{
  306. u8 field0[7];
  307. u8 battle_effect_x12;
  308. u8 field8[18];
  309. u8 quality;
  310. u8 field1B;
  311. };
  312. extern struct b_enigma_berry battle_enigma_berry[4];
  313. // trainerbattle stuff
  314. extern u16 trainerbattle_flag_id;
  315. extern struct {
  316. u8 battle_double : 1; // 1
  317. u8 battle_link : 1; // 2
  318. u8 battle_wild : 1; // 4
  319. u8 battle_trainer : 1; // 8
  320. u8 battle_oak_comments : 1; //0x10
  321. u8 _battle_unk_1 : 1; //0x20
  322. u8 battle_double_2 : 1; //0x40
  323. u8 battle_safari : 1; //0x80
  324. u8 battle_trainer_tower : 1;//0x100
  325. u8 _battle_unk_2 : 1; //0x200
  326. u8 battle_old_man : 1; //0x400
  327. u8 battle_trainer_tower_2 : 1;//0x800
  328. u8 _battle_unk_3 : 1; //0x1000
  329. u8 _battle_unk_4 : 1; //0x2000
  330. u8 _battle_unk_5 : 1; //0x4000
  331. u8 battle_ghost : 1; //0x8000
  332. u8 battle_poke_dude : 1; //0x10000
  333. u8 _battle_unk_6 : 1; //0x20000
  334. u8 battle_secret_base : 1; //0x40000
  335. } battle_type_flags;
  336. _Static_assert(sizeof(battle_type_flags) <= 4, "Invalid struct size for battle_type_flags");
  337. struct trainer_table_entry {
  338. u8 _unk_1;
  339. u8 trainer_class;
  340. u8 encounter_music;
  341. u8 _unk_2;
  342. u8 _unk_3[16];
  343. u8 _unk_4[16];
  344. u32 _unk; // probably pokemon data
  345. };
  346. _Static_assert(sizeof(struct trainer_table_entry) == 0x28, "Invalid struct size for trainer_table_entry");
  347. extern struct trainer_table_entry trainer_data[];
  348. #endif