1 #ifndef _SOLDIER_CREATE_H 2 #define _SOLDIER_CREATE_H 3 4 #include "JA2Types.h" 5 #include "Observable.h" 6 #include "Overhead_Types.h" 7 #include "Item_Types.h" 8 #include "Soldier_Control.h" 9 10 #include <string_theory/string> 11 12 13 //Kris: SERIALIZING INFORMATION 14 //All maps must have: 15 // - MAPCREATE_STRUCT 16 // MAPCREATE_STRUCT.ubNumIndividuals determines how many BASIC_SOLDIERCREATE_STRUCTs there are 17 // - The BASIC_SOLDIERCREATE_STRUCTS are saved contiguously, but if any of them 18 // fDetailedPlacement set, then there is a SOLDIERCREATE_STRUCT saved immediately after. 19 20 //These are the placement slots used by the editor to define where characters are in a map, what 21 //they are, what team they are on, personality traits, etc. The Merc section of the editor is 22 //what is used to define these values. 23 struct BASIC_SOLDIERCREATE_STRUCT 24 { 25 UINT16 usStartingGridNo; //Where the placement position is. 26 BOOLEAN fDetailedPlacement; //Specialized information. Has a counterpart containing all info. 27 INT8 bTeam; //The team this individual is part of. 28 INT8 bRelativeAttributeLevel; 29 INT8 bRelativeEquipmentLevel; 30 INT8 bDirection; //1 of 8 values (always mandatory) 31 INT8 bOrders; 32 INT8 bAttitude; 33 INT8 bBodyType; //up to 128 body types, -1 means random 34 INT16 sPatrolGrid[ MAXPATROLGRIDS ]; //possible locations to visit, patrol, etc. 35 INT8 bPatrolCnt; 36 BOOLEAN fOnRoof; 37 UINT8 ubSoldierClass; //army, administrator, elite 38 UINT8 ubCivilianGroup; 39 BOOLEAN fPriorityExistance; //These slots are used first 40 BOOLEAN fHasKeys; 41 }; 42 43 struct SOLDIERCREATE_STRUCT 44 { 45 //Bulletproofing so static detailed placements aren't used to tactically create soldiers. 46 //Used by editor for validation purposes. 47 BOOLEAN fStatic; 48 49 //Profile information used for special NPCs and player mercs. 50 UINT8 ubProfile; 51 BOOLEAN fCopyProfileItemsOver; 52 53 //Location information 54 INT16 sSectorX; 55 INT16 sSectorY; 56 INT8 bDirection; 57 INT16 sInsertionGridNo; 58 59 // Can force a team, but needs flag set 60 INT8 bTeam; 61 INT8 bBodyType; 62 63 //Orders and attitude settings 64 INT8 bAttitude; 65 INT8 bOrders; 66 67 //Attributes 68 INT8 bLifeMax; 69 INT8 bLife; 70 INT8 bAgility; 71 INT8 bDexterity; 72 INT8 bExpLevel; 73 INT8 bMarksmanship; 74 INT8 bMedical; 75 INT8 bMechanical; 76 INT8 bExplosive; 77 INT8 bLeadership; 78 INT8 bStrength; 79 INT8 bWisdom; 80 INT8 bMorale; 81 INT8 bAIMorale; 82 83 //Inventory 84 OBJECTTYPE Inv[ NUM_INV_SLOTS ]; 85 86 //Palette information for soldiers. 87 ST::string HeadPal; 88 ST::string PantsPal; 89 ST::string VestPal; 90 ST::string SkinPal; 91 92 //Waypoint information for patrolling 93 INT16 sPatrolGrid[ MAXPATROLGRIDS ]; 94 INT8 bPatrolCnt; 95 96 //Kris: Additions November 16, 1997 (padding down to 129 from 150) 97 BOOLEAN fVisible; 98 ST::string name; 99 100 UINT8 ubSoldierClass; //army, administrator, elite 101 102 BOOLEAN fOnRoof; 103 104 INT8 bSectorZ; 105 106 UINT8 ubCivilianGroup; 107 108 UINT8 ubScheduleID; 109 110 BOOLEAN fUseGivenVehicle; 111 INT8 bUseGivenVehicleID; 112 BOOLEAN fHasKeys; 113 }; 114 115 extern Observable<SOLDIERTYPE*> OnCreateSoldier; 116 117 //Original functions currently used throughout the game. 118 void TacticalRemoveSoldier(SOLDIERTYPE&); 119 120 INT8 CalcDifficultyModifier( UINT8 ubSoldierClass ); 121 122 void RandomizeNewSoldierStats( SOLDIERCREATE_STRUCT *pCreateStruct ); 123 124 //Kris: 125 //Modified return type from BOOLEAN to SOLDIERTYPE* 126 SOLDIERTYPE* TacticalCreateSoldier(SOLDIERCREATE_STRUCT const&); 127 SOLDIERTYPE* TacticalCreateSoldierFromExisting(const SOLDIERTYPE*); 128 129 //Randomly generated enemies used by strategic AI. 130 SOLDIERTYPE* TacticalCreateEnemySoldier(SoldierClass); 131 SOLDIERTYPE* TacticalCreateMilitia( UINT8 ubMilitiaClass ); 132 SOLDIERTYPE* TacticalCreateCreature( INT8 bCreatureBodyType ); 133 134 // randomly generates a relative level rating (attributes or equipment) 135 void RandomizeRelativeLevel( INT8 *pbRelLevel, UINT8 ubSoldierClass ); 136 137 // get the pythag. distance from the passed sector to the palace.. 138 UINT8 GetPythDistanceFromPalace( INT16 sSectorX, INT16 sSectorY ); 139 140 141 //These following functions are currently used exclusively by the editor. 142 //Now, this will be useful for the strategic AI. 143 //Definitions: 144 //Soldier (s): Currently in the game, but subject to modifications. The editor has the capability to 145 // modify soldier attributes on the fly for testing purposes. 146 //BasicPlacement (bp): A BASIC_SOLDIERCREATE_STRUCT that contains compact, very general, information about 147 // a soldier. The BasicPlacement is then used to generate a DetailedPlacement before creating a soldier. 148 // Most of the soldiers saved in the maps will be saved in this manner. 149 //DetailedPlacement (pp): A SOLDIERCREATE_STRUCT ready to be passed to TacticalCreateSoldier to generate 150 // and add a new soldier to the world. The DetailedPlacement contains all of the necessary information 151 // to do this. This information won't be saved in maps. In most cases, only very few attributes are static, 152 // and the rest are generated at runtime. Because of this situation, saved detailed placements must be in a 153 // different format. 154 //StaticDetailedPlacement (spp): A hybrid version of the DetailedPlacement. This is the information saved in 155 // the map via the editor. When loaded, this information is converted to a normal detailed placement, but 156 // must also use the BasicPlacement information to complete this properly. Once the conversion is complete, 157 // the static information is lost. This gives us complete flexibility. The basic placements contain relative 158 // values that work in conjunction with the strategic AI's relative values to generate soldiers. In no 159 // circumstances will static detailed placements be used outside of the editor. Note, that this hybrid version 160 // uses the identical structure as detailed placements. All non-static values are set to -1. 161 162 //Used to generate a detailed placement from a basic placement. This assumes that the detailed placement 163 //doesn't exist, meaning there are no static attributes. This is called when you wish to convert a basic 164 //placement into a detailed placement just before creating a soldier. 165 void CreateDetailedPlacementGivenBasicPlacementInfo( SOLDIERCREATE_STRUCT *pp, BASIC_SOLDIERCREATE_STRUCT *bp ); 166 167 //Used exclusively by the editor when the user wishes to change a basic placement into a detailed placement. 168 //Because the intention is to make some of the attributes static, all of the information that can be generated 169 //are defaulted to -1. When an attribute is made to be static, that value in replaced by the new static value. 170 //This information is NOT compatible with TacticalCreateSoldier. Before doing so, you must first convert the 171 //static detailed placement to a regular detailed placement. 172 void CreateStaticDetailedPlacementGivenBasicPlacementInfo( SOLDIERCREATE_STRUCT *spp, BASIC_SOLDIERCREATE_STRUCT *bp ); 173 174 //When you are ready to generate a soldier with a static detailed placement slot, this function will generate 175 //the proper priority placement slot given the static detailed placement and it's accompanying basic placment. 176 //For the purposes of merc editing, the static detailed placement is preserved. 177 void CreateDetailedPlacementGivenStaticDetailedPlacementAndBasicPlacementInfo( 178 SOLDIERCREATE_STRUCT *pp, SOLDIERCREATE_STRUCT *spp, BASIC_SOLDIERCREATE_STRUCT *bp); 179 180 //Used to update a existing soldier's attributes with the new static detailed placement info. This is used 181 //by the editor upon exiting the editor into the game, to update the existing soldiers with new information. 182 //This gives flexibility of testing mercs. Upon entering the editor again, this call will reset all the 183 //mercs to their original states. 184 void UpdateSoldierWithStaticDetailedInformation( SOLDIERTYPE *s, SOLDIERCREATE_STRUCT *spp ); 185 186 //When the editor modifies the soldier's relative attribute level, 187 //this function is called to update that information. 188 void ModifySoldierAttributesWithNewRelativeLevel( SOLDIERTYPE *s, INT8 bLevel ); 189 190 // Force the soldier to be a different ID 191 void ForceSoldierProfileID( SOLDIERTYPE *pSoldier, UINT8 ubProfileID ); 192 193 void QuickCreateProfileMerc( INT8 bTeam, UINT8 ubProfileID ); 194 195 void InternalTacticalRemoveSoldier(SOLDIERTYPE&, BOOLEAN fRemoveVehicle); 196 197 //SPECIAL! Certain events in the game can cause profiled NPCs to become enemies. The two cases are 198 //adding Mike and Iggy. We will only add one NPC in any given combat and the conditions for setting 199 //the associated facts are done elsewhere. The function will set the profile for the SOLDIERCREATE_STRUCT 200 //and the rest will be handled automatically so long the ubProfile field doesn't get changed. 201 //NOTE: We don't want to add Mike or Iggy if this is being called from autoresolve! 202 void OkayToUpgradeEliteToSpecialProfiledEnemy( SOLDIERCREATE_STRUCT *pp ); 203 extern BOOLEAN gfProfiledEnemyAdded; //needs to be saved (used by the above function) 204 205 void TrashAllSoldiers(void); 206 207 #endif 208