Merged revision(s) 7166-7177 from branches/ja2_source_official_2014:

- Flagmasks are unsigned, and should be called and treated as such
- Fix: experience gain from interrogation was too high
- Fix: chance of a prisoner becoming militia was calculated wrong
- default weight maximum for MOVE ITEM assignment increased from 30 to 40 kg
- Fix: snitches report the same event multiple times
- Fix: snitches treat vehicles as persons
- Fix: selection of launchables is inefficient, an does not take into account wether items are depending on day/night cycle
- new key combination: in strategic, pressing [CTRL] + [E] wile both a merc's inventory and the sector inventory are open will fill the merc's inventory with sector items
- trivial code cleanup
- if prisoners are taken in a sector that houses a prison, that prison can also be selected to house them
- Fix: distributing newly taken prisoners in a prison sector no longer redistributes all prisoners, only the new ones
- GetClosestFlaggedSoldierID can also be called without evaluation of sight
- Fix: Covert Ops: throwing/lobbing items or shooting rockets is deemed suspicious behaviour
- Fix: boxing was broken by loading a savegame
- Fix: campaign history rarely recorded kills in autoresolve
- There is no reason why the IDs that boxers are reset to before they are reinitialised would ever need to be altered by a modder. Required script change in stable GameDir r2024.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7178 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2014-04-30 21:36:18 +00:00
parent 8b494003fd
commit 30060f0595
46 changed files with 759 additions and 711 deletions
+16 -16
View File
@@ -6674,9 +6674,9 @@ void HandlePrisonerProcessingInSector( INT16 sMapX, INT16 sMapY, INT8 bZ )
if ( result < gGameExternalOptions.ubPrisonerProcessDefectChance )
{
// troops are converted to militia, but there is a chance that they will be demoted in the process
if ( i < interrogatedprisoners[PRISONER_ELITE] && Chance(80) )
if ( i >= interrogatedprisoners[PRISONER_ADMIN] + interrogatedprisoners[PRISONER_REGULAR] && Chance( 80 ) )
++turnedmilitia_elite;
else if ( i < interrogatedprisoners[PRISONER_ELITE] + interrogatedprisoners[PRISONER_REGULAR] && Chance(80) )
else if ( i >= interrogatedprisoners[PRISONER_ADMIN] && Chance( 80 ) )
++turnedmilitia_regular;
else
++turnedmilitia_admin;
@@ -6768,7 +6768,7 @@ void HandlePrisonerProcessingInSector( INT16 sMapX, INT16 sMapY, INT8 bZ )
if ( !oldinterrogationpoints )
return;
FLOAT totalexp = (FLOAT) (100 * prisonersinterrogated);
FLOAT totalexp = (FLOAT) (1 * prisonersinterrogated);
FLOAT expratio = totalexp / (oldinterrogationpoints * 33); // TODO
// award experience
@@ -6979,8 +6979,8 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
if ( distance == 0 )
continue;
// each soldier can carry 30 items, and needs 10 minutes (two way walk) per sector distance, thereby 6 / distance runs possible
UINT16 maxitems = 30 * (*it).second * 6 / distance;
// each soldier can carry 40 items or 40 kg, and needs 10 minutes (two way walk) per sector distance, thereby 6 / distance runs possible per hour
UINT16 maxitems = 40 * (*it).second * 6 / distance;
UINT16 maxweight = 400 * (*it).second * 6 / distance;
// open the inventory of the sector we are taking stuff from
@@ -6988,7 +6988,7 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
UINT32 uiTotalNumberOfRealItems_Target = 0;
// use the new map
pWorldItem_Target.clear();//dnl ch75 021113
pWorldItem_Target.clear();//dnl ch75 021113
if( ( gWorldSectorX == targetX )&&( gWorldSectorY == targetY ) && (gbWorldSectorZ == bZ ) )
{
@@ -11448,9 +11448,9 @@ void SnitchToggleMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason )
}
else if( iValue == SNITCH_MENU_TOGGLE_ON )
{
if ( pSoldier->bSoldierFlagMask2 & SOLDIER_SNITCHING_OFF )
if ( pSoldier->usSoldierFlagMask2 & SOLDIER_SNITCHING_OFF )
{
pSoldier->bSoldierFlagMask2 &= ~SOLDIER_SNITCHING_OFF;
pSoldier->usSoldierFlagMask2 &= ~SOLDIER_SNITCHING_OFF;
fShowSnitchToggleMenu = FALSE;
fShowSnitchMenu = FALSE;
fShowAssignmentMenu = FALSE;
@@ -11459,9 +11459,9 @@ void SnitchToggleMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason )
}
else if( iValue == SNITCH_MENU_TOGGLE_OFF )
{
if ( !(pSoldier->bSoldierFlagMask2 & SOLDIER_SNITCHING_OFF) )
if ( !(pSoldier->usSoldierFlagMask2 & SOLDIER_SNITCHING_OFF) )
{
pSoldier->bSoldierFlagMask2 |= SOLDIER_SNITCHING_OFF;
pSoldier->usSoldierFlagMask2 |= SOLDIER_SNITCHING_OFF;
fShowSnitchToggleMenu = FALSE;
fShowSnitchMenu = FALSE;
fShowAssignmentMenu = FALSE;
@@ -11471,9 +11471,9 @@ void SnitchToggleMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason )
}
else if( iValue == SNITCH_MENU_MISBEHAVIOUR_ON )
{
if ( pSoldier->bSoldierFlagMask2 & SOLDIER_PREVENT_MISBEHAVIOUR_OFF )
if ( pSoldier->usSoldierFlagMask2 & SOLDIER_PREVENT_MISBEHAVIOUR_OFF )
{
pSoldier->bSoldierFlagMask2 &= ~SOLDIER_PREVENT_MISBEHAVIOUR_OFF;
pSoldier->usSoldierFlagMask2 &= ~SOLDIER_PREVENT_MISBEHAVIOUR_OFF;
fShowSnitchToggleMenu = FALSE;
fShowSnitchMenu = FALSE;
fShowAssignmentMenu = FALSE;
@@ -11482,9 +11482,9 @@ void SnitchToggleMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason )
}
else if( iValue == SNITCH_MENU_MISBEHAVIOUR_OFF)
{
if ( !(pSoldier->bSoldierFlagMask2 & SOLDIER_PREVENT_MISBEHAVIOUR_OFF) )
if ( !(pSoldier->usSoldierFlagMask2 & SOLDIER_PREVENT_MISBEHAVIOUR_OFF) )
{
pSoldier->bSoldierFlagMask2 |= SOLDIER_PREVENT_MISBEHAVIOUR_OFF;
pSoldier->usSoldierFlagMask2 |= SOLDIER_PREVENT_MISBEHAVIOUR_OFF;
fShowSnitchToggleMenu = FALSE;
fShowSnitchMenu = FALSE;
fShowAssignmentMenu = FALSE;
@@ -15176,7 +15176,7 @@ void HandleShadingOfLinesForSnitchToggleMenu( void )
pSoldier = GetSelectedAssignSoldier( FALSE );
if( pSoldier->bSoldierFlagMask2 & SOLDIER_SNITCHING_OFF )
if( pSoldier->usSoldierFlagMask2 & SOLDIER_SNITCHING_OFF )
{
UnShadeStringInBox( ghSnitchToggleBox, SNITCH_MENU_TOGGLE_ON );
ShadeStringInBox( ghSnitchToggleBox, SNITCH_MENU_TOGGLE_OFF );
@@ -15187,7 +15187,7 @@ void HandleShadingOfLinesForSnitchToggleMenu( void )
UnShadeStringInBox( ghSnitchToggleBox, SNITCH_MENU_TOGGLE_OFF );
}
if( pSoldier->bSoldierFlagMask2 & SOLDIER_PREVENT_MISBEHAVIOUR_OFF )
if( pSoldier->usSoldierFlagMask2 & SOLDIER_PREVENT_MISBEHAVIOUR_OFF )
{
UnShadeStringInBox( ghSnitchToggleBox, SNITCH_MENU_MISBEHAVIOUR_ON );
ShadeStringInBox( ghSnitchToggleBox, SNITCH_MENU_MISBEHAVIOUR_OFF );
+5 -4
View File
@@ -4792,7 +4792,11 @@ void TargetHitCallback( SOLDIERCELL *pTarget, INT32 index )
pTarget->uiFlags &= ~CELL_RETREATING;
}
if( iNewLife <= 0 )
{ //soldier has been killed
{
// Flugente: campaign stats
gCurrentIncident.AddStat( pTarget->pSoldier, CAMPAIGNHISTORY_TYPE_KILL );
//soldier has been killed
if( pTarget->pAttacker[ index ]->uiFlags & CELL_PLAYER )
{ //Player killed the enemy soldier -- update his stats as well as any assisters.
SOLDIERCELL *pKiller;
@@ -4810,9 +4814,6 @@ void TargetHitCallback( SOLDIERCELL *pTarget, INT32 index )
{
if( pKiller->uiFlags & CELL_MERC )
{
// Flugente: campaign stats
gCurrentIncident.AddStat( pTarget->pSoldier, CAMPAIGNHISTORY_TYPE_KILL );
/////////////////////////////////////////////////////////////////////////////////////
// SANDRO - new mercs' records
switch(pTarget->pSoldier->ubSoldierClass)
+2 -2
View File
@@ -422,7 +422,7 @@ void HourlyLarryUpdate()
// note - snitches stop others, but can get wasted themselves (if they have drug use specifically set in background...)
if( pOtherSoldier && !pOtherSoldier->flags.fBetweenSectors && pOtherSoldier->bActive && pOtherSoldier->bInSector && !pOtherSoldier->flags.fMercAsleep && pSoldier->ubProfile != pOtherSoldier->ubProfile )
{
if ( ProfileHasSkillTrait( pOtherSoldier->ubProfile, SNITCH_NT ) && !( pSoldier->bSoldierFlagMask2 & SOLDIER_PREVENT_MISBEHAVIOUR_OFF ) )
if ( ProfileHasSkillTrait( pOtherSoldier->ubProfile, SNITCH_NT ) && !( pSoldier->usSoldierFlagMask2 & SOLDIER_PREVENT_MISBEHAVIOUR_OFF ) )
{
if( pSoldier->sSectorX == pOtherSoldier->sSectorX && pSoldier->sSectorY == pOtherSoldier->sSectorY && pSoldier->bSectorZ == pOtherSoldier->bSectorZ )
{
@@ -551,7 +551,7 @@ void HourlyStealUpdate()
// note - snitches stop others, but can scrounge themselves (if they have scrounging specifically set in background...)
if( pOtherSoldier && !pOtherSoldier->flags.fBetweenSectors && pOtherSoldier->bActive && pOtherSoldier->bInSector && !pOtherSoldier->flags.fMercAsleep && pSoldier->ubProfile != pOtherSoldier->ubProfile )
{
if ( ProfileHasSkillTrait( pOtherSoldier->ubProfile, SNITCH_NT ) && !( pSoldier->bSoldierFlagMask2 & SOLDIER_PREVENT_MISBEHAVIOUR_OFF ) )
if ( ProfileHasSkillTrait( pOtherSoldier->ubProfile, SNITCH_NT ) && !( pSoldier->usSoldierFlagMask2 & SOLDIER_PREVENT_MISBEHAVIOUR_OFF ) )
{
if( pSoldier->sSectorX == pOtherSoldier->sSectorX && pSoldier->sSectorY == pOtherSoldier->sSectorY && pSoldier->bSectorZ == pOtherSoldier->bSectorZ )
{
+21 -11
View File
@@ -838,6 +838,8 @@ static int l_EnvEndRainStorm (lua_State *L);
static int l_ProfilesStrategicInsertionData (lua_State *L);
static int l_ResetBoxers( lua_State *L );
using namespace std;
UINT16 idProfil;
@@ -1123,7 +1125,8 @@ void IniFunction(lua_State *L, BOOLEAN bQuests )
lua_register(L, "GetNPCBalance", l_GetiBalance);
lua_register(L, "GetCharacterSectorZ", l_GetCharacterSectorZ);
lua_register(L, "GetCharacterSectorX", l_GetCharacterSectorX);
lua_register(L, "GetCharacterSectorY", l_GetCharacterSectorY);
lua_register(L, "GetCharacterSectorY", l_GetCharacterSectorY);
lua_register(L, "ResetBoxers", l_ResetBoxers );
//Tactical merc
lua_register(L, "CheckCivGroupHostile", l_fCivGroupHostile);
@@ -10588,19 +10591,26 @@ static int l_GetCharacterSectorX (lua_State *L)
//Set charcter to sector Z
static int l_SetCharacterSectorZ (lua_State *L)
{
UINT8 n = lua_gettop(L);
int i = 0;
UINT8 id = 0;
UINT8 SectorZ = 0;
for (i= 1; i<=n; i++ )
if ( lua_gettop( L ) >= 2 )
{
if (i == 1 ) id = lua_tointeger(L,i);
if (i == 2 ) SectorZ = lua_tointeger(L,i);
UINT8 id = lua_tointeger( L, 1 );
UINT8 SectorZ = lua_tointeger( L, 2 );
gMercProfiles[id].bSectorZ = SectorZ;
}
return 0;
}
// set boxer ids back to NOBODY, so they can be reinitialised
static int l_ResetBoxers( lua_State *L )
{
for ( UINT8 i = 0; i < NUM_BOXERS; ++i )
{
gubBoxerID[i] = NOBODY;
gfBoxerFought[i] = FALSE;
}
gMercProfiles[ id ].bSectorZ = SectorZ;
return 0;
}
+1 -1
View File
@@ -1695,7 +1695,7 @@ UINT8 MoveAllInHelicopterToFootMovementGroup( INT8 bNewSquad )
}
// Flugente: we are leaving the helicopter and instantly deploy into combat - this must be an airdrop
pSoldier->bSoldierFlagMask |= (SOLDIER_AIRDROP_TURN|SOLDIER_AIRDROP);
pSoldier->usSoldierFlagMask |= (SOLDIER_AIRDROP_TURN|SOLDIER_AIRDROP);
}
}
+1 -1
View File
@@ -1899,7 +1899,7 @@ void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ub
pSoldier->bActionPoints = 0;
// Flugente: due to a fix, also note here that the reinforcements get no APs.
pSoldier->bSoldierFlagMask |= SOLDIER_NO_AP;
pSoldier->usSoldierFlagMask |= SOLDIER_NO_AP;
// Flugente: campaign stats
if ( IsOurSoldier(pSoldier) )
+16 -33
View File
@@ -93,9 +93,7 @@ void ModifyPlayerReputation(INT8 bRepChange)
BOOLEAN MercThinksDeathRateTooHigh( UINT8 ubProfileID )
{
INT8 bDeathRateTolerance;
bDeathRateTolerance = gMercProfiles[ ubProfileID ].bDeathRate;
INT8 bDeathRateTolerance = gMercProfiles[ubProfileID].bDeathRate;
// if he couldn't care less what it is
if (bDeathRateTolerance == 101)
@@ -109,19 +107,15 @@ BOOLEAN MercThinksDeathRateTooHigh( UINT8 ubProfileID )
// too high - sorry
return(TRUE);
}
else
{
// within tolerance
return(FALSE);
}
// within tolerance
return(FALSE);
}
BOOLEAN MercThinksBadReputationTooHigh( UINT8 ubProfileID )
{
INT8 bRepTolerance;
bRepTolerance = gMercProfiles[ ubProfileID ].bReputationTolerance;
INT8 bRepTolerance = gMercProfiles[ ubProfileID ].bReputationTolerance;
// if he couldn't care less what it is
if (bRepTolerance == 101)
@@ -135,11 +129,9 @@ BOOLEAN MercThinksBadReputationTooHigh( UINT8 ubProfileID )
// too high - sorry
return(TRUE);
}
else
{
// within tolerance
return(FALSE);
}
// within tolerance
return(FALSE);
}
@@ -157,8 +149,7 @@ BOOLEAN MercThinksHisMoraleIsTooLow( SOLDIERTYPE *pSoldier )
// that obviously it CAN'T be too low...
return(FALSE);
}
// morale tolerance is based directly upon reputation tolerance
// above 50, morale is GOOD, never below tolerance then
bMoraleTolerance = (100 - bRepTolerance) / 2;
@@ -168,11 +159,9 @@ BOOLEAN MercThinksHisMoraleIsTooLow( SOLDIERTYPE *pSoldier )
// too low - sorry
return(TRUE);
}
else
{
// within tolerance
return(FALSE);
}
// within tolerance
return(FALSE);
}
BOOLEAN MercIsOwedTooMuchMoney( UINT8 ubProfileID )
@@ -188,8 +177,7 @@ BOOLEAN MercIsOwedTooMuchMoney( UINT8 ubProfileID )
BOOLEAN MercThinksPlayerIsInactiveTooLong( UINT8 ubProfileID )
{
UINT8 ubTolerance;
ubTolerance = gMoraleSettings.bValues[MORALE_PLAYER_INACTIVE_DAYS];
UINT8 ubTolerance = gMoraleSettings.bValues[MORALE_PLAYER_INACTIVE_DAYS];
if( gMercProfiles[ubProfileID].bCharacterTrait == CHAR_TRAIT_PACIFIST )
{
ubTolerance = max(0, ubTolerance + gMoraleSettings.bValues[MORALE_PLAYER_INACTIVE_DAYS_PACIFIST_BONUS]);
@@ -206,10 +194,8 @@ BOOLEAN MercThinksPlayerIsInactiveTooLong( UINT8 ubProfileID )
{
return(TRUE);
}
else
{
return(FALSE);
}
return(FALSE);
}
void UpdateLastDayOfPlayerActivity( UINT16 usDay )
@@ -228,11 +214,8 @@ UINT8 LackOfProgressTolerance( void )
// give an EXTRA day over normal
return( 7 - DIF_LEVEL_MEDIUM + gStrategicStatus.ubHighestProgress / 42 );
}
else
{
return( 6 - gGameOptions.ubDifficultyLevel + gStrategicStatus.ubHighestProgress / 42 );
}
return( 6 - gGameOptions.ubDifficultyLevel + gStrategicStatus.ubHighestProgress / 42 );
}
-6
View File
@@ -333,7 +333,6 @@ void DecrementTownLoyalty( INT8 bTownId, UINT32 uiLoyaltyDecrease )
UINT32 uiRemainingDecrement;
INT16 sThisDecrement;
Assert( ( bTownId >= FIRST_TOWN ) && ( bTownId < NUM_TOWNS ) );
// doesn't affect towns where player hasn't established a "presence" yet
@@ -363,8 +362,6 @@ void DecrementTownLoyalty( INT8 bTownId, UINT32 uiLoyaltyDecrease )
uiRemainingDecrement -= sThisDecrement;
}
return;
}
@@ -376,7 +373,6 @@ void UpdateTownLoyaltyRating( INT8 bTownId )
INT16 sRatingChange = 0;
UINT8 ubMaxLoyalty = 0;
Assert( ( bTownId >= FIRST_TOWN ) && ( bTownId < NUM_TOWNS ) );
// remember previous loyalty value
@@ -437,8 +433,6 @@ void UpdateTownLoyaltyRating( INT8 bTownId )
{
fMapPanelDirty = TRUE;
}
return;
}
+65 -22
View File
@@ -7558,36 +7558,79 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent )
}
if( fCtrl )
{
//CHRISL: pickup all items to vehicle
if ( UsingNewInventorySystem() == true && fShowInventoryFlag && fShowMapInventoryPool && !(gTacticalStatus.fEnemyInSector) && gGameExternalOptions.fVehicleInventory && (pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE))
if ( UsingNewInventorySystem() && fShowInventoryFlag && fShowMapInventoryPool && !gTacticalStatus.fEnemyInSector)
{
for(unsigned int i = 0; i<pInventoryPoolList.size(); i++)
//CHRISL: pickup all items to vehicle
if ( pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE )
{
if(pInventoryPoolList[i].fExists == TRUE && (pInventoryPoolList[i].usFlags & WORLD_ITEM_REACHABLE))
if (gGameExternalOptions.fVehicleInventory)
{
for(int x = 0; x<NUM_INV_SLOTS; x++)
for (unsigned int i = 0; i < pInventoryPoolList.size(); i++)
{
if(vehicleInv[x] == FALSE)
continue;
if(pSoldier->inv[x].exists() == true)
if (pInventoryPoolList[i].fExists == TRUE && (pInventoryPoolList[i].usFlags & WORLD_ITEM_REACHABLE))
{
if(pSoldier->inv[x].usItem != pInventoryPoolList[i].object.usItem)
continue;
else
pInventoryPoolList[i].object.AddObjectsToStack(pSoldier->inv[x], -1, pSoldier, x);
}
else
pInventoryPoolList[i].object.MoveThisObjectTo(pSoldier->inv[x], -1, pSoldier, x);
if(pInventoryPoolList[i].object.ubNumberOfObjects < 0)
{
//RemoveItemFromWorld(i);
break;
for (int x = 0; x < NUM_INV_SLOTS; x++)
{
if (vehicleInv[x] == FALSE)
continue;
if (pSoldier->inv[x].exists() == true)
{
if (pSoldier->inv[x].usItem != pInventoryPoolList[i].object.usItem)
continue;
else
pInventoryPoolList[i].object.AddObjectsToStack(pSoldier->inv[x], -1, pSoldier, x);
}
else
pInventoryPoolList[i].object.MoveThisObjectTo(pSoldier->inv[x], -1, pSoldier, x);
if (pInventoryPoolList[i].object.ubNumberOfObjects < 0)
{
//RemoveItemFromWorld(i);
break;
}
}
}
fTeamPanelDirty = TRUE;
fMapPanelDirty = TRUE;
fInterfacePanelDirty = DIRTYLEVEL2;
}
}
fTeamPanelDirty = TRUE;
fMapPanelDirty = TRUE;
fInterfacePanelDirty = DIRTYLEVEL2;
}
// Flugente: also allow mercs to qickly pick up items this way (but not EPCs)
else if ( !AM_AN_EPC(pSoldier) )
{
for (unsigned int i = 0; i < pInventoryPoolList.size(); ++i)
{
if (pInventoryPoolList[i].fExists == TRUE && (pInventoryPoolList[i].usFlags & WORLD_ITEM_REACHABLE))
{
INT8 invsize = (INT8)pSoldier->inv.size(); // remember inventorysize, so we don't call size() repeatedly
for (INT8 bLoop = 0; bLoop < invsize; ++bLoop)
{
if ( CanItemFitInPosition( pSoldier, &pInventoryPoolList[i].object, bLoop, FALSE ) )
{
// TODO: do not add LBE if we would then have to move existing items
if (pSoldier->inv[bLoop].exists())
{
if (pSoldier->inv[bLoop].usItem != pInventoryPoolList[i].object.usItem)
continue;
else
pInventoryPoolList[i].object.AddObjectsToStack(pSoldier->inv[bLoop], -1, pSoldier, bLoop, 0, FALSE);
}
else
pInventoryPoolList[i].object.MoveThisObjectTo(pSoldier->inv[bLoop], -1, pSoldier, bLoop);
if (pInventoryPoolList[i].object.ubNumberOfObjects < 0)
{
//RemoveItemFromWorld(i);
break;
}
}
}
}
fTeamPanelDirty = TRUE;
fMapPanelDirty = TRUE;
fInterfacePanelDirty = DIRTYLEVEL2;
}
}
}
}
+1 -1
View File
@@ -1890,7 +1890,7 @@ UINT8 GetTownSectorsUnderControl( INT8 bTownId )
( StrategicMap[ usSector ].fEnemyControlled == FALSE ) &&
( NumEnemiesInSector( ( INT16 )iCounterA, ( INT16 )iCounterB ) == 0 ) )
{
ubSectorsControlled++;
++ubSectorsControlled;
}
}
}