diff --git a/GameSettings.cpp b/GameSettings.cpp index 5e8d872b..fbf87519 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -1445,9 +1445,10 @@ void LoadGameExternalOptions() gGameExternalOptions.fFoodDecayInSectors = iniReader.ReadBoolean("Tactical Food Settings", "FOOD_DECAY_IN_SECTORS", TRUE); gGameExternalOptions.sFoodDecayModificator = iniReader.ReadFloat("Tactical Food Settings", "FOOD_DECAY_MODIFICATOR", 1.0f, 0.1f, 10.0f); - gGameExternalOptions.usFoodMaxPoisoning = iniReader.ReadInteger("Tactical Food Settings", "FOOD_MAX_POISONING", 5, 0, 100); - + gGameExternalOptions.fFoodEatingSounds = iniReader.ReadBoolean("Tactical Food Settings", "FOOD_EATING_SOUNDS", TRUE); + + //################# Strategic Gamestart Settings ################## //Lalien: Game starting time diff --git a/GameSettings.h b/GameSettings.h index b0819dd5..2392ed6b 100644 --- a/GameSettings.h +++ b/GameSettings.h @@ -420,6 +420,8 @@ typedef struct FLOAT sFoodDecayModificator; UINT8 usFoodMaxPoisoning; + + BOOLEAN fFoodEatingSounds; //Animation settings FLOAT giPlayerTurnSpeedUpFactor; diff --git a/Tactical/Food.cpp b/Tactical/Food.cpp index 27facfd7..81ff95d9 100644 --- a/Tactical/Food.cpp +++ b/Tactical/Food.cpp @@ -221,7 +221,7 @@ BOOLEAN ApplyFood( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject, BOOLEAN fForce, B DeductPoints( pSoldier, APBPConstants[type], sBPAdjustment ); // let it be known that we are eating - if ( pSoldier->bTeam == gbPlayerNum ) + if ( pSoldier->bTeam == gbPlayerNum && gGameExternalOptions.fFoodEatingSounds ) { if ( type == AP_EAT ) { diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index b35bc55b..fc2d343f 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -15441,6 +15441,8 @@ UINT32 SOLDIERTYPE::GetSurrenderStrength() value = (value * this->stats.bLife / this->stats.bLifeMax); + value = value * (5 + sqrt((double) max(1, this->aiData.bMorale))) / 15; + // adjust for type of soldier if ( this->ubSoldierClass == SOLDIER_CLASS_ELITE || this->ubSoldierClass == SOLDIER_CLASS_ELITE_MILITIA ) value *= 1.5f; diff --git a/Tactical/Soldier Create.cpp b/Tactical/Soldier Create.cpp index 9232408b..04e5f4bc 100644 --- a/Tactical/Soldier Create.cpp +++ b/Tactical/Soldier Create.cpp @@ -3170,6 +3170,41 @@ extern SECTOR_EXT_DATA SectorExternalData[256][4]; static UINT8 roomcnt = 0; +// For now, this is only used for prison cells +INT32 GetSittableGridNoInRoom(UINT16 usRoom, BOOLEAN fEnoughSpace) +{ + INT32 insertiongridno = NOWHERE; + + // get sector data and look fo a fitting room + UINT8 ubSectorId = SECTOR(gWorldSectorX, gWorldSectorY); + if ( ubSectorId >= 0 && ubSectorId < 256 ) + { + for ( UINT32 uiLoop = 0; uiLoop < WORLD_MAX; ++uiLoop ) + { + if ( (gusWorldRoomInfo[ uiLoop ] == usRoom) ) + { + if ( fEnoughSpace ) + { + // we have to make sure that the gridno is deep in the room, as otherwise the gridno might be corrected to be on the other side of a wall + if ( ( gusWorldRoomInfo[ NewGridNo( uiLoop, DirectionInc(NORTH) ) ] != usRoom ) + || ( gusWorldRoomInfo[ NewGridNo( uiLoop, DirectionInc(EAST) ) ] != usRoom ) + || ( gusWorldRoomInfo[ NewGridNo( uiLoop, DirectionInc(SOUTH) ) ] != usRoom ) + || ( gusWorldRoomInfo[ NewGridNo( uiLoop, DirectionInc(WEST) ) ] != usRoom ) ) + continue; + } + + // check wether this location is sittable + if ( IsLocationSittable( uiLoop, 0 ) ) + { + return uiLoop; + } + } + } + } + + return NOWHERE; +} + void CreatePrisonerOfWar() { INT32 insertiongridno = NOWHERE; @@ -3178,36 +3213,25 @@ void CreatePrisonerOfWar() UINT8 ubSectorId = SECTOR(gWorldSectorX, gWorldSectorY); if ( ubSectorId >= 0 && ubSectorId < 256 ) { + // We need to 'condense' the room numbers, as some might be empty in the xml + UINT16 realrooms[MAX_PRISON_ROOMS]; + UINT8 numrooms = 0; for(UINT8 i = 0; i < MAX_PRISON_ROOMS; ++i) + { if ( SectorExternalData[ubSectorId][0].usPrisonRoomNumber[i] > 0) - ++numrooms; + { + realrooms[numrooms++] = SectorExternalData[ubSectorId][0].usPrisonRoomNumber[i]; + } + } ++roomcnt; if ( roomcnt >= numrooms ) roomcnt = 0; - UINT16 room = SectorExternalData[ubSectorId][0].usPrisonRoomNumber[roomcnt]; + UINT16 room = realrooms[roomcnt]; - for ( UINT32 uiLoop = 0; uiLoop < WORLD_MAX; ++uiLoop ) - { - if ( (gusWorldRoomInfo[ uiLoop ] == room) ) - { - // we have to make sure that the gridno is deep in the room, as otherwise the gridno might be corrected to be on the other side of a wall - if ( gusWorldRoomInfo[ NewGridNo( uiLoop, DirectionInc(NORTH) ) ] == room ) - if ( gusWorldRoomInfo[ NewGridNo( uiLoop, DirectionInc(EAST) ) ] == room ) - if ( gusWorldRoomInfo[ NewGridNo( uiLoop, DirectionInc(SOUTH) ) ] == room ) - if ( gusWorldRoomInfo[ NewGridNo( uiLoop, DirectionInc(WEST) ) ] == room ) - { - // check wether this location is sittable - if ( IsLocationSittable( uiLoop, 0 ) ) - { - insertiongridno = uiLoop; - break; - } - } - } - } + insertiongridno = GetSittableGridNoInRoom(room, TRUE); // invalid gridno? Get out of here if ( TileIsOutOfBounds(insertiongridno) ) diff --git a/TileEngine/Explosion Control.cpp b/TileEngine/Explosion Control.cpp index 21e47483..40c7464c 100644 --- a/TileEngine/Explosion Control.cpp +++ b/TileEngine/Explosion Control.cpp @@ -273,7 +273,7 @@ void RecountExplosions( void ) } - +extern void HandleLoyaltyForDemolitionOfBuilding( SOLDIERTYPE *pSoldier, INT16 sPointsDmg ); // GENERATE EXPLOSION void InternalIgniteExplosion( UINT8 ubOwner, INT16 sX, INT16 sY, INT16 sZ, INT32 sGridNo, UINT16 usItem, BOOLEAN fLocate, INT8 bLevel, UINT8 ubDirection ) @@ -357,6 +357,12 @@ void InternalIgniteExplosion( UINT8 ubOwner, INT16 sX, INT16 sY, INT16 sZ, INT32 GenerateExplosion( &ExpParams ); + // Flugente: if the explosion occured in a building, this might lower loyalty in town + if ( Item[ usItem ].usItemClass & IC_EXPLOSV && ubOwner != NOBODY && ubOwner < 255 ) + { + HandleLoyaltyForDemolitionOfBuilding( MercPtrs[ubOwner], Explosive[ Item[ usItem ].ubClassIndex ].ubDamage ); + } + // HEADROCK HAM 5.1: Launch fragments from the explosion. if (Explosive[ Item[ usItem ].ubClassIndex ].usNumFragments > 0 ) {