- New feature: sector fortification allows to construct structures in sectors in a much easier way than by using amerc to build 'by hand'. Fortification nodes are in a subfolder in Profiles and can easily be altered and exchanged, even in an ongoing game.

Fully savegame compatible.
GameDir >= r2296 is recommended, but not required.
- Cleaned up cover display functions.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8094 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2016-03-06 12:44:57 +00:00
parent 7e7476a4ea
commit 12ae810316
36 changed files with 5175 additions and 3307 deletions
+158 -1
View File
@@ -472,6 +472,9 @@ void HandleRadioScanInSector( INT16 sMapX, INT16 sMapY, INT8 bZ );
void HandleDiseaseDiagnosis();
void HandleDiseaseSectorTreatment( );
// Flugente: fortification
void HandleFortification();
// reset scan flags in all sectors
void ClearSectorScanResults();
@@ -935,6 +938,28 @@ BOOLEAN CanCharacterTreatSectorDisease( SOLDIERTYPE *pSoldier )
return FALSE;
}
BOOLEAN CanCharacterFortify( SOLDIERTYPE *pSoldier )
{
if ( pSoldier->bSectorZ )
{
UNDERGROUND_SECTORINFO *pSectorInfo;
pSectorInfo = FindUnderGroundSector( pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ );
if ( pSectorInfo && pSectorInfo->dFortification_MaxPossible > pSectorInfo->dFortification_UnappliedProgress )
return TRUE;
}
else
{
SECTORINFO *pSectorInfo;
pSectorInfo = &SectorInfo[SECTOR( pSoldier->sSectorX, pSoldier->sSectorY )];
if ( pSectorInfo && pSectorInfo->dFortification_MaxPossible > pSectorInfo->dFortification_UnappliedProgress )
return TRUE;
}
return FALSE;
}
BOOLEAN IsAnythingAroundForSoldierToRepair( SOLDIERTYPE * pSoldier )
{
AssertNotNIL(pSoldier);
@@ -2536,6 +2561,9 @@ void UpdateAssignments()
// Flugente: PMC recruits new personnel
HourlyUpdatePMC();
// handle fortification
HandleFortification();
// check to see if anyone is done healing?
UpdatePatientsWhoAreDoneHealing( );
@@ -7374,6 +7402,51 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
}
}
// Flugente: fortification
void HandleFortification()
{
SOLDIERTYPE* pSoldier = NULL;
UINT16 uiCnt = 0;
for ( uiCnt = 0, pSoldier = MercPtrs[uiCnt]; uiCnt <= gTacticalStatus.Team[gbPlayerNum].bLastID; ++uiCnt, ++pSoldier )
{
if ( pSoldier->bActive && !pSoldier->flags.fMercAsleep && EnoughTimeOnAssignment( pSoldier ) )
{
if ( (pSoldier->bAssignment == FORTIFICATION) && CanCharacterFortify( pSoldier ) )
{
if ( pSoldier->bSectorZ )
{
UNDERGROUND_SECTORINFO *pSectorInfo;
pSectorInfo = FindUnderGroundSector( pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ );
if ( pSectorInfo )
{
pSectorInfo->dFortification_UnappliedProgress = min( pSectorInfo->dFortification_UnappliedProgress + pSoldier->GetConstructionPoints( ), pSectorInfo->dFortification_MaxPossible );
}
}
else
{
SECTORINFO *pSectorInfo;
pSectorInfo = &SectorInfo[SECTOR( pSoldier->sSectorX, pSoldier->sSectorY )];
if ( pSectorInfo )
{
pSectorInfo->dFortification_UnappliedProgress = min( pSectorInfo->dFortification_UnappliedProgress + pSoldier->GetConstructionPoints( ), pSectorInfo->dFortification_MaxPossible );
}
}
StatChange( pSoldier, STRAMT, 6, TRUE );
// if we cannot fortify any longer, this means we're finished - tell us so
if ( !CanCharacterFortify( pSoldier ) )
AssignmentDone( pSoldier, TRUE, TRUE );
}
}
}
HandleFortificationUpdate( );
}
INT16 GetTownTrainPtsForCharacter( SOLDIERTYPE *pTrainer, UINT16 *pusMaxPts )
{
INT16 sTotalTrainingPts = 0;
@@ -7593,7 +7666,7 @@ void AssignmentDone( SOLDIERTYPE *pSoldier, BOOLEAN fSayQuote, BOOLEAN fMeToo )
if ( fSayQuote )
{
if (IS_DOCTOR( pSoldier->bAssignment ) || IS_REPAIR( pSoldier->bAssignment ) ||
IS_PATIENT( pSoldier->bAssignment ) || (pSoldier->bAssignment == ASSIGNMENT_HOSPITAL))
IS_PATIENT( pSoldier->bAssignment ) || pSoldier->bAssignment == ASSIGNMENT_HOSPITAL || pSoldier->bAssignment == FORTIFICATION )
{
TacticalCharacterDialogue( pSoldier, QUOTE_ASSIGNMENT_COMPLETE );
}
@@ -9057,6 +9130,18 @@ void HandleShadingOfLinesForAssignmentMenus( void )
// shade line
ShadeStringInBox( ghAssignmentBox, ASSIGN_MENU_SNITCH );
}
// fortify
if ( CanCharacterFortify( pSoldier ) )
{
// unshade patient line
UnShadeStringInBox( ghAssignmentBox, ASSIGN_MENU_FORTIFY );
}
else
{
// shade patient line
ShadeStringInBox( ghAssignmentBox, ASSIGN_MENU_FORTIFY );
}
}
}
@@ -12502,6 +12587,42 @@ void AssignmentMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason )
}
break;
case ASSIGN_MENU_FORTIFY:
if ( CanCharacterFortify(pSoldier) )
{
// stop showing menu
fShowAssignmentMenu = FALSE;
giAssignHighLine = -1;
pSoldier->bOldAssignment = pSoldier->bAssignment;
if ( (pSoldier->bAssignment != FORTIFICATION) )
{
SetTimeOfAssignmentChangeForMerc( pSoldier );
}
// remove from squad
if ( pSoldier->bOldAssignment == VEHICLE )
{
TakeSoldierOutOfVehicle( pSoldier );
}
RemoveCharacterFromSquads( pSoldier );
ChangeSoldiersAssignment( pSoldier, FORTIFICATION );
AssignMercToAMovementGroup( pSoldier );
MakeSoldiersTacticalAnimationReflectAssignment( pSoldier );
// set dirty flag
fTeamPanelDirty = TRUE;
fMapScreenBottomDirty = TRUE;
// set assignment for group
SetAssignmentForList( (INT8)FORTIFICATION, 0 );
}
break;
// HEADROCK HAM 3.6: New assignments for Facility operation.
case( ASSIGN_MENU_FACILITY ):
if ( BasicCanCharacterFacility( pSoldier ) )
@@ -15268,6 +15389,30 @@ void SetSoldierAssignment( SOLDIERTYPE *pSoldier, INT8 bAssignment, INT32 iParam
}
break;
case FORTIFICATION:
if ( CanCharacterFortify( pSoldier ) )
{
pSoldier->bOldAssignment = pSoldier->bAssignment;
// remove from squad
RemoveCharacterFromSquads( pSoldier );
// remove from any vehicle
if ( pSoldier->bOldAssignment == VEHICLE )
{
TakeSoldierOutOfVehicle( pSoldier );
}
if ( pSoldier->bAssignment != bAssignment )
{
SetTimeOfAssignmentChangeForMerc( pSoldier );
}
ChangeSoldiersAssignment( pSoldier, bAssignment );
AssignMercToAMovementGroup( pSoldier );
}
break;
case( VEHICLE ):
if( CanCharacterVehicle( pSoldier ) && IsThisVehicleAccessibleToSoldier( pSoldier, iParam1 ) )
{
@@ -16558,6 +16703,10 @@ void ReEvaluateEveryonesNothingToDo()
fNothingToDo = !CanCharacterTreatSectorDisease( pSoldier );
break;
case FORTIFICATION:
fNothingToDo = !CanCharacterFortify( pSoldier );
break;
case VEHICLE:
default: // squads
fNothingToDo = FALSE;
@@ -16867,6 +17016,14 @@ void SetAssignmentForList( INT8 bAssignment, INT8 bParam )
fItWorked = TRUE;
}
break;
case FORTIFICATION:
if ( CanCharacterFortify( pSoldier ) )
{
pSoldier->bOldAssignment = pSoldier->bAssignment;
SetSoldierAssignment( pSoldier, FORTIFICATION, bParam, 0, 0 );
fItWorked = TRUE;
}
break;
case( SQUAD_1 ):
case( SQUAD_2 ):
case( SQUAD_3 ):
+3
View File
@@ -84,6 +84,7 @@ enum
FACILITY_DOCTOR,
FACILITY_PATIENT,
FACILITY_REPAIR,
FORTIFICATION, // Flugente: sectors can be fortified according to external layout plans
NUM_ASSIGNMENTS,
};
@@ -166,6 +167,8 @@ BOOLEAN CanCharacterDiagnoseDisease( SOLDIERTYPE *pSoldier );
// can this character treat diseases of the population (NOT mercs)?
BOOLEAN CanCharacterTreatSectorDisease( SOLDIERTYPE *pSoldier );
BOOLEAN CanCharacterFortify( SOLDIERTYPE *pSoldier );
// can this character be assigned as a repairman?
BOOLEAN CanCharacterRepair( SOLDIERTYPE *pCharacter );
+10 -3
View File
@@ -522,10 +522,13 @@ typedef struct SECTORINFO
UINT16 usInfected; // how many people (civilians + enemy + militia) are infected in this sector? Does NOT count our mercs
FLOAT fInfectionSeverity; // mean infection rate of those infected (percentage)
UINT8 usDiseaseDoctoringDelay; // AI doctoring in this sector is delayed due to player interference
UINT8 usInfectionFlag;
UINT8 usInfectionFlag;
// Flugente: fortification
FLOAT dFortification_MaxPossible; // the amount of fortification that can still be done in this sector, given the current layout plans. Is updated every time we unload a sector
FLOAT dFortification_UnappliedProgress; // progress done via assignment work. As we cannot update unloaded sectors, update happens once sector is loaded
INT8 bPadding[ 12 ];
INT8 bPadding[ 4 ];
}SECTORINFO;
@@ -567,7 +570,11 @@ typedef struct UNDERGROUND_SECTORINFO
UINT8 ubNumTanks;
UINT8 ubTanksInBattle;
INT8 bPadding[26];
// Flugente: fortification
FLOAT dFortification_MaxPossible; // the amount of fortification that can still be done in this sector, given the current layout plans. Is updated every time we unload a sector
FLOAT dFortification_UnappliedProgress; // progress done via assignment work. As we cannot update unloaded sectors, update happens once sector is loaded
INT8 bPadding[16];
//no padding left!
}UNDERGROUND_SECTORINFO;
+37
View File
@@ -846,6 +846,9 @@ static int l_AddVolunteers( lua_State *L );
static int l_CreateArmedCivilain( lua_State *L );
static int l_BuildFortification( lua_State *L );
static int l_RemoveFortification( lua_State *L );
static int l_GetFact( lua_State *L );
static int l_SetFact( lua_State *L );
@@ -1703,6 +1706,9 @@ void IniFunction(lua_State *L, BOOLEAN bQuests )
lua_register( L, "AddVolunteers", l_AddVolunteers );
lua_register(L, "CreateArmedCivilain", l_CreateArmedCivilain );
lua_register( L, "BuildFortification", l_BuildFortification );
lua_register( L, "RemoveFortification", l_RemoveFortification );
lua_register(L, "GetFact", l_GetFact );
lua_register(L, "SetFact", l_SetFact );
@@ -2595,6 +2601,8 @@ BOOLEAN LuaHandleQuestCodeOnSector( INT16 sSectorX, INT16 sSectorY, INT8 bSector
lua_register(_LS.L(), "CheckForKingpinsMoneyMissing", l_FunctionCheckForKingpinsMoneyMissing);
lua_register(_LS.L(), "SetProfileStrategicInsertionData", l_ProfilesStrategicInsertionData );
lua_register(_LS.L(), "CreateArmedCivilain", l_CreateArmedCivilain );
lua_register(_LS.L(), "BuildFortification", l_BuildFortification );
lua_register(_LS.L(), "RemoveFortification", l_RemoveFortification );
IniFunction( _LS.L(), TRUE );
IniGlobalGameSetting( _LS.L() );
@@ -13066,6 +13074,35 @@ static int l_CreateArmedCivilain( lua_State *L )
return 0;
}
static int l_BuildFortification( lua_State *L )
{
if ( lua_gettop( L ) )
{
INT32 sGridNo = lua_tointeger( L, 1 );
INT8 sLevel = lua_tointeger( L, 2 );
UINT8 usIndex = lua_tointeger( L, 3 );
UINT8 usStructureIndex = lua_tointeger( L, 4 );
BuildFortification( sGridNo, sLevel, usIndex, usStructureIndex );
}
return 0;
}
static int l_RemoveFortification( lua_State *L )
{
if ( lua_gettop( L ) )
{
INT32 sGridNo = lua_tointeger( L, 1 );
INT8 sLevel = lua_tointeger( L, 2 );
UINT8 usStructureIndex = lua_tointeger( L, 3 );
RemoveFortification( sGridNo, sLevel, usStructureIndex );
}
return 0;
}
static int l_GetFact( lua_State *L )
{
UINT8 val = 0;
+1
View File
@@ -130,6 +130,7 @@ enum {
ASSIGN_MENU_SNITCH,
ASSIGN_MENU_TRAIN,
ASSIGN_MENU_MOVE_ITEMS, // added by Flugente
ASSIGN_MENU_FORTIFY, // added by Flugente
ASSIGN_MENU_FACILITY, // HEAROCK HAM 3.6: Facility List menu
ASSIGN_MENU_CANCEL,
MAX_ASSIGN_STRING_COUNT,
+2912 -2905
View File
File diff suppressed because it is too large Load Diff