1 /*! \file 2 * \brief Pilot structure handling. 3 * \details Functions and structs for reading, writing and modifying OMF:2097 pilot data structures. 4 * \copyright MIT license. 5 * \date 2013-2014 6 * \author Andrew Thompson 7 * \author Tuomas Virtanen 8 */ 9 10 #ifndef _SD_PILOT_H 11 #define _SD_PILOT_H 12 13 #include <stdint.h> 14 #include "shadowdive/palette.h" 15 #ifdef SD_USE_INTERNAL 16 #include "shadowdive/internal/reader.h" 17 #include "shadowdive/internal/memreader.h" 18 #include "shadowdive/internal/writer.h" 19 #include "shadowdive/internal/memwriter.h" 20 #endif 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 /*! \brief PIC pilot information 27 * 28 * Contains a pilot information. Current upgrades, powers, tournament, etc. 29 */ 30 typedef struct { 31 uint32_t unknown_a; ///< Unknown 32 char name[18]; ///< Pilot name 33 uint16_t wins; ///< Matches won by this pilot 34 uint16_t losses; ///< Matches lost by this pilot 35 uint8_t rank; ///< Rank 36 uint8_t har_id; ///< Har Identifier (255 = random) 37 uint8_t arm_power; ///< HAR Arm power (0-9). 38 uint8_t leg_power; ///< HAR Leg power (0-9). 39 uint8_t arm_speed; ///< HAR Arm speed (0-9). 40 uint8_t leg_speed; ///< HAR Leg speed (0-9). 41 uint8_t armor; ///< Har armor (0-9). 42 uint8_t stun_resistance; ///< Har stun resistance (0-9). 43 uint8_t power; ///< Pilot power (1-25). 44 uint8_t agility; ///< Pilot agility (1-25). 45 uint8_t endurance; ///< Pilot endurance (1-25). 46 uint16_t offense; ///< Offense preference value (100 high, should be under 200). 47 uint16_t defense; ///< Defense preference value (100 high, should be under 200). 48 uint32_t money; ///< Amount of money the pilot currently has 49 uint8_t color_1; ///< Color 1 field for the HAR (0-15). 255 means random. 50 uint8_t color_2; ///< Color 2 field for the HAR (0-15). 255 means random. 51 uint8_t color_3; ///< Color 3 field for the HAR (0-15). 255 means random. 52 char trn_name[13]; ///< Tournament file 53 char trn_desc[31]; ///< Tournament description 54 char trn_image[13]; ///< Tournament image file 55 float unk_f_c; ///< Unknown 56 float unk_f_d; ///< Unknown 57 uint8_t pilot_id; ///< Pilot ID 58 uint8_t unknown_k; ///< Unknown 59 uint16_t force_arena; ///< Tells if this pilot needs to play on a certain arena 60 uint8_t difficulty; ///< Difficulty setting 61 char unk_block_b[2]; ///< Unknown 62 uint8_t movement; ///< Pilot can move in rankings 63 uint16_t unk_block_c[3]; ///< Unknown 64 char enhancements[11]; ///< Har enchancements. A field for each HAR. 65 66 uint8_t secret; ///< This character is a secret character, and only comes out when requirements match 67 uint8_t only_fight_once; ///< This character can only be fought once per tournament 68 uint8_t req_enemy; ///< Required defeated enemy for this character to appear (Value 0 if not set, otherwise character id + 1) 69 uint8_t req_difficulty; ///< Required difficulty level for this character to appear 70 uint8_t req_rank; ///< Required minimum ranking for this character to appear 71 uint8_t req_vitality; ///< Required vitality for this character to appear 72 uint8_t req_fighter; ///< Required fighter for this character to appear 73 uint8_t req_accuracy; ///< Required accuracy for this character to appear 74 uint8_t req_avg_dmg; ///< Required average damage for this character to appear 75 uint8_t req_max_rank; ///< When you reach this ranking, this character appears. 76 uint8_t req_scrap; ///< Must have scrapped an enemy for this character to appear 77 uint8_t req_destroy; ///< Must have destroyed an enemy for this character to appear 78 79 uint8_t att_normal; ///< Standard fighting method 80 uint8_t att_hyper; ///< More aggressive 81 uint8_t att_jump; ///< Jumps more often 82 uint8_t att_def; ///< More defensive 83 uint8_t att_sniper; ///< Tries to sneak in quick hits 84 85 uint16_t unk_block_d[3]; ///< Unknown 86 int16_t ap_throw; ///< AI Preference for throw moves. Accepted value range (-400, 400). 87 int16_t ap_special; ///< AI Preference for special moves. Accepted value range (-400, 400). 88 int16_t ap_jump; ///< AI Preference for jump moves. Accepted value range (-400, 400). 89 int16_t ap_high; ///< AI Preference for high moves. Accepted value range (-400, 400). 90 int16_t ap_low; ///< AI Preference for low moves. Accepted value range (-400, 400). 91 int16_t ap_middle; ///< AI Preference for middle moves. Accepted value range (-400, 400). 92 int16_t pref_jump; ///< AI Preference for jump movement. Accepted value range (-400, 400). 93 int16_t pref_fwd; ///< AI Preference for forwards movement. Accepted value range (-400, 400). 94 int16_t pref_back; ///< AI Preference for backwards movement. Accepted value range (-400, 400). 95 uint32_t unknown_e; ///< Unknown 96 float learning; ///< How actively this pilot learns your combat tactics. Accepted value range (0-15). 97 float forget; ///< How quickly this pilot forgets your combat tactics. Accepted value range (0-3). 98 char unk_block_f[14]; ///< Unknown. Probably pointers and scratch variables 99 uint16_t enemies_inc_unranked; ///< Enemies in current tournament, including unranked opponents 100 uint16_t enemies_ex_unranked; ///< Same as above, excluding unranked opponents. 101 102 uint16_t unk_d_a; ///< Unknown. 103 uint32_t unk_d_b; ///< Unknown. Possible a bitmask ? 104 105 uint32_t winnings; ///< Money made by winning opponents 106 uint32_t total_value; ///< Total value for the pilot 107 float unk_f_a; ///< Unknown 108 float unk_f_b; ///< Unknown 109 sd_palette palette; ///< Palette for photo ? 110 uint16_t unk_block_i; ///< Unknown 111 uint16_t photo_id; ///< Which face photo this pilot uses 112 113 char *quotes[10]; ///< Pilot quotes for each supported language 114 } sd_pilot; 115 116 /*! \brief Initialize pilot struct 117 * 118 * Initializes the pilot structure with empty values. 119 * 120 * \retval SD_INVALID_INPUT Pilot struct pointer was NULL 121 * \retval SD_SUCCESS Success. 122 * 123 * \param pilot Allocated pilot struct pointer. 124 */ 125 int sd_pilot_create(sd_pilot *pilot); 126 127 /*! \brief Free pilot structure 128 * 129 * Frees up all memory reserved by the pilot structure. 130 * All contents will be freed, all pointers to contents will be invalid. 131 * 132 * \param pilot Pilot struct pointer. 133 */ 134 void sd_pilot_free(sd_pilot *pilot); 135 136 #ifdef SD_USE_INTERNAL 137 void sd_pilot_load_player_from_mem(sd_mreader *mreader, sd_pilot *pilot); 138 void sd_pilot_load_from_mem(sd_mreader *mreader, sd_pilot *pilot); 139 int sd_pilot_load(sd_reader *reader, sd_pilot *pilot); 140 void sd_pilot_save_player_to_mem(sd_mwriter *mwriter, const sd_pilot *pilot); 141 void sd_pilot_save_to_mem(sd_mwriter *mwriter, const sd_pilot *pilot); 142 int sd_pilot_save(sd_writer *writer, const sd_pilot *pilot); 143 #endif 144 145 #ifdef __cplusplus 146 } 147 #endif 148 149 #endif // _SD_PILOT_H