From 3346fddf09a3a8bf62129a5ef43fabd42a665418 Mon Sep 17 00:00:00 2001 From: silversurfer Date: Mon, 21 Oct 2013 07:13:15 +0000 Subject: [PATCH] - New behaviour for gas grenades: Gas grenades now don't cause direct damage on hit anymore. They will cause damage on start of turn or if you move inside a gas cloud. Of course gas mask still helps (except for creature gas and fire). Every tile moved inside a gas cloud deals a percentage of the normal damage (default 10%). This is set in Item_Settings.ini (DAMAGE_HEALTH_MOVE_EXPLOSIVE_MODIFIER, DAMAGE_BREATH_MOVE_EXPLOSIVE_MODIFIER). Tiles can now have multiple gas effects on them. Unfortunately this is not visualized (yet). Smoke doesn't make a character immune to other gas types anymore. The 25% chance of taking damage while moving through a gas cloud has been removed. Damage is now applied 100% of the time. - New modifiers for explosive damage in Item_Settings.ini (DAMAGE_HEALTH_EXPLOSIVE_MODIFIER, DAMAGE_BREATH_EXPLOSIVE_MODIFIER). These could fully replace EXPLOSIVES_DAMAGE_MODIFIER in Ja2_Options.ini but I left that general modifier untouched for now. - Some compiler warning fixes. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6517 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameSettings.cpp | 4 +++ GameSettings.h | 7 +++- Laptop/BobbyRGuns.cpp | 8 ++--- Laptop/mercs.cpp | 2 +- Tactical/Interface Enhanced.cpp | 4 +-- Tactical/Interface Items.cpp | 4 +-- Tactical/Items.cpp | 34 +++++++++++++------ Tactical/Items.h | 2 +- Tactical/Overhead.cpp | 43 ++++++++++++++--------- Tactical/Turn Based Input.cpp | 2 +- Tactical/Weapons.cpp | 2 +- TacticalAI/Attacks.cpp | 6 ++-- TacticalAI/DecideAction.cpp | 10 +++--- TileEngine/Explosion Control.cpp | 58 +++++++++++++++++++++++--------- TileEngine/SmokeEffects.cpp | 3 ++ TileEngine/lighting.cpp | 4 +-- TileEngine/overhead map.cpp | 6 ++-- TileEngine/tiledef.cpp | 8 ++--- TileEngine/worlddef.cpp | 10 +++--- Utils/XML_Items.cpp | 2 +- 20 files changed, 141 insertions(+), 78 deletions(-) diff --git a/GameSettings.cpp b/GameSettings.cpp index 2eb8e345..237b9772 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -2696,6 +2696,10 @@ void LoadItemSettings() // -------------- ARMOR MODIFIERS ---------------- // ------------ EXPLOSIVE MODIFIERS -------------- + gItemSettings.fDamageHealthModifierExplosive = iniReader.ReadFloat ("Explosives Settings","DAMAGE_HEALTH_EXPLOSIVE_MODIFIER", 1.0f, 0.1f, 5.0f); + gItemSettings.fDamageBreathModifierExplosive = iniReader.ReadFloat ("Explosives Settings","DAMAGE_BREATH_EXPLOSIVE_MODIFIER", 1.0f, 0.1f, 5.0f); + gItemSettings.fDamageHealthMoveModifierExplosive = iniReader.ReadFloat ("Explosives Settings","DAMAGE_HEALTH_MOVE_EXPLOSIVE_MODIFIER", 0.1f, 0.0f, 1.0f); + gItemSettings.fDamageBreathMoveModifierExplosive = iniReader.ReadFloat ("Explosives Settings","DAMAGE_BREATH_MOVE_EXPLOSIVE_MODIFIER", 0.1f, 0.0f, 1.0f); } diff --git a/GameSettings.h b/GameSettings.h index 27440391..2b6072b8 100644 --- a/GameSettings.h +++ b/GameSettings.h @@ -1253,7 +1253,7 @@ typedef struct UINT8 ubPrisonerProcessInfoDirectionChance; UINT8 ubPrisonerProcessRansomBaseChance; UINT16 ubPrisonerInterrogationPoints[4]; // points needed to interrogate a prisoner of a specific type - + // Flugente: sexism/racism/etc. INT8 sMoraleModAppearance; INT8 sMoraleModRefinement; @@ -1928,6 +1928,11 @@ typedef struct // -------------- ARMOR MODIFIERS ---------------- // ------------ EXPLOSIVE MODIFIERS -------------- + // Grenade Damage Modifiers + FLOAT fDamageHealthModifierExplosive; + FLOAT fDamageBreathModifierExplosive; + FLOAT fDamageHealthMoveModifierExplosive; // applies when character moves through gas cloud without a gas mask + FLOAT fDamageBreathMoveModifierExplosive; // applies when character moves through gas cloud without a gas mask }ITEM_SETTINGS; diff --git a/Laptop/BobbyRGuns.cpp b/Laptop/BobbyRGuns.cpp index e040c7a0..58d281b4 100644 --- a/Laptop/BobbyRGuns.cpp +++ b/Laptop/BobbyRGuns.cpp @@ -2258,7 +2258,7 @@ UINT16 DisplayExplosiveDamage(UINT16 usPosY, UINT16 usIndex, UINT16 usFontHeight DrawTextToScreen(BobbyRText[BOBBYR_GUNS_DAMAGE], BOBBYR_ITEM_WEIGHT_TEXT_X, (UINT16)usPosY, 0, BOBBYR_ITEM_DESC_TEXT_FONT, BOBBYR_STATIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED); - UINT16 explDamage = (UINT16) GetModifiedExplosiveDamage( Explosive[Item[ usIndex ].ubClassIndex].ubDamage ); + UINT16 explDamage = (UINT16) GetModifiedExplosiveDamage( Explosive[Item[ usIndex ].ubClassIndex].ubDamage, 0 ); swprintf(sTemp, L"%4d", explDamage); DrawTextToScreen(sTemp, BOBBYR_ITEM_WEIGHT_NUM_X, (UINT16)usPosY, BOBBYR_ITEM_WEIGHT_NUM_WIDTH, BOBBYR_ITEM_DESC_TEXT_FONT, BOBBYR_ITEM_DESC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); @@ -2272,7 +2272,7 @@ UINT16 DisplayExplosiveStunDamage(UINT16 usPosY, UINT16 usIndex, UINT16 usFontHe DrawTextToScreen(BobbyRText[BOBBYR_GUNS_STUN], BOBBYR_ITEM_WEIGHT_TEXT_X, (UINT16)usPosY, 0, BOBBYR_ITEM_DESC_TEXT_FONT, BOBBYR_STATIC_TEXT_COLOR, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED); - UINT16 explStunDamage = (UINT16) GetModifiedExplosiveDamage( Explosive[Item[ usIndex ].ubClassIndex].ubStunDamage ); + UINT16 explStunDamage = (UINT16) GetModifiedExplosiveDamage( Explosive[Item[ usIndex ].ubClassIndex].ubStunDamage, 1 ); swprintf(sTemp, L"%4d", explStunDamage); DrawTextToScreen(sTemp, BOBBYR_ITEM_WEIGHT_NUM_X, (UINT16)usPosY, BOBBYR_ITEM_WEIGHT_NUM_WIDTH, BOBBYR_ITEM_DESC_TEXT_FONT, BOBBYR_ITEM_DESC_TEXT_COLOR_ALT, FONT_MCOLOR_BLACK, FALSE, RIGHT_JUSTIFIED); @@ -4242,8 +4242,8 @@ void GetHelpTextForItemInLaptop( STR16 pzStr, UINT16 usItemNumber ) // HEADROCK HAM 3.6: Can now use negative modifier. //UINT16 explDamage = (UINT16)( Explosive[Item[ usItemNumber ].ubClassIndex].ubDamage + ( (double) Explosive[Item[ usItemNumber ].ubClassIndex].ubDamage / 100) * gGameExternalOptions.bExplosivesDamageModifier ); //UINT16 explStunDamage = (UINT16)( Explosive[Item[ usItemNumber ].ubClassIndex].ubStunDamage + ( (double) Explosive[Item[ usItemNumber ].ubClassIndex].ubStunDamage / 100) * gGameExternalOptions.ubExplosivesDamageMultiplier ); - UINT16 explDamage = (UINT16) GetModifiedExplosiveDamage( Explosive[Item[ usItemNumber ].ubClassIndex].ubDamage ); - UINT16 explStunDamage = (UINT16) GetModifiedExplosiveDamage( Explosive[Item[ usItemNumber ].ubClassIndex].ubStunDamage ); + UINT16 explDamage = (UINT16) GetModifiedExplosiveDamage( Explosive[Item[ usItemNumber ].ubClassIndex].ubDamage, 0 ); + UINT16 explStunDamage = (UINT16) GetModifiedExplosiveDamage( Explosive[Item[ usItemNumber ].ubClassIndex].ubStunDamage, 1 ); swprintf( pzStr, L"%s\n%s %d\n%s %d\n%s %1.1f %s", diff --git a/Laptop/mercs.cpp b/Laptop/mercs.cpp index 561cdf46..63828926 100644 --- a/Laptop/mercs.cpp +++ b/Laptop/mercs.cpp @@ -3076,7 +3076,7 @@ BOOLEAN AreAnyOfTheNewMercsAvailable() return( FALSE ); //for(i=(LARRY_NORMAL-BIFF); i<=LaptopSaveInfo.gubLastMercIndex; i++) - for(UINT16 i=0; i<=NUM_PROFILES; i++) + for(UINT8 i=0; i<=NUM_PROFILES; i++) { if ( gConditionsForMercAvailability[i].NewMercsAvailable == FALSE && gProfilesMERC[i].ProfilId != 0 ) { diff --git a/Tactical/Interface Enhanced.cpp b/Tactical/Interface Enhanced.cpp index 953945c9..a7aac630 100644 --- a/Tactical/Interface Enhanced.cpp +++ b/Tactical/Interface Enhanced.cpp @@ -8309,7 +8309,7 @@ void DrawExplosiveValues( OBJECTTYPE * gpItemDescObject ) sHeight = gItemDescGenRegions[ubNumLine][1].sBottom - sTop; // Get final damage - INT16 iFinalDamage = GetModifiedExplosiveDamage( Explosive[Item[ gpItemDescObject->usItem ].ubClassIndex ].ubDamage ); + INT16 iFinalDamage = GetModifiedExplosiveDamage( Explosive[Item[ gpItemDescObject->usItem ].ubClassIndex ].ubDamage, 0 ); // Get base damage INT16 iDamage = iFinalDamage; @@ -8350,7 +8350,7 @@ void DrawExplosiveValues( OBJECTTYPE * gpItemDescObject ) sHeight = gItemDescGenRegions[ubNumLine][1].sBottom - sTop; // Get final damage - INT16 iFinalStunDamage = GetModifiedExplosiveDamage( Explosive[Item[ gpItemDescObject->usItem ].ubClassIndex ].ubStunDamage); + INT16 iFinalStunDamage = GetModifiedExplosiveDamage( Explosive[Item[ gpItemDescObject->usItem ].ubClassIndex ].ubStunDamage, 1 ); // Get base damage INT16 iStunDamage = iFinalStunDamage; diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index 78955583..65b9664b 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -12023,8 +12023,8 @@ void GetHelpTextForItem( STR16 pzStr, OBJECTTYPE *pObject, SOLDIERTYPE *pSoldier // HEADROCK HAM 3.6: Can now use negative modifier. //UINT16 explDamage = (UINT16)( Explosive[Item[ usItem ].ubClassIndex].ubDamage + ( (double) Explosive[Item[ usItem ].ubClassIndex].ubDamage / 100) * gGameExternalOptions.ubExplosivesDamageMultiplier ); //UINT16 explStunDamage = (UINT16)( Explosive[Item[ usItem ].ubClassIndex].ubStunDamage + ( (double) Explosive[Item[ usItem ].ubClassIndex].ubStunDamage / 100) * gGameExternalOptions.ubExplosivesDamageMultiplier ); - UINT16 explDamage = (UINT16) GetModifiedExplosiveDamage( Explosive[Item[ usItem ].ubClassIndex].ubDamage ); - UINT16 explStunDamage = (UINT16) GetModifiedExplosiveDamage( Explosive[Item[ usItem ].ubClassIndex].ubStunDamage ); + UINT16 explDamage = (UINT16) GetModifiedExplosiveDamage( Explosive[Item[ usItem ].ubClassIndex].ubDamage, 0 ); + UINT16 explStunDamage = (UINT16) GetModifiedExplosiveDamage( Explosive[Item[ usItem ].ubClassIndex].ubStunDamage, 1 ); #ifdef CHINESE swprintf( pStr, ChineseSpecString5, diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index f46bb90d..c533aa66 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -5479,23 +5479,28 @@ std::vector GetItemSlots(OBJECTTYPE* pObj, UINT8 subObject, BOOLEAN fAtt UINT64 uiClass = (UINT64)pow((double)2, (int)sClass); UINT32 slotSize = tempItemSlots.size(); if(fItemSlots & uiClass){ //don't bother with this slot if it's not a valid class - for(UINT32 sCount = 1; sCount < MAXITEMS+1; sCount++){ + for(UINT32 sCount = 1; sCount < MAXITEMS+1; sCount++) + { if(AttachmentSlots[sCount].uiSlotIndex == 0) break; - if(AttachmentSlots[sCount].nasAttachmentClass & uiClass && AttachmentSlots[sCount].nasLayoutClass & fItemLayout){ //found a slot + if(AttachmentSlots[sCount].nasAttachmentClass & uiClass && AttachmentSlots[sCount].nasLayoutClass & fItemLayout) //found a slot + { if(magSize > 0 && AttachmentSlots[sCount].fMultiShot) magSize--; else if(AttachmentSlots[sCount].fMultiShot) continue; - if(Item[pObj->usItem].usItemClass == IC_LBEGEAR && AttachmentSlots[sCount].ubPocketMapping > 0){ - if(LoadBearingEquipment[Item[pObj->usItem].ubClassIndex].lbePocketsAvailable & (UINT16)pow((double)2, AttachmentSlots[sCount].ubPocketMapping - 1)){ - tempItemSlots.push_back(AttachmentSlots[sCount].uiSlotIndex); - } - }else{ + if(Item[pObj->usItem].usItemClass == IC_LBEGEAR && AttachmentSlots[sCount].ubPocketMapping > 0) + { + if(LoadBearingEquipment[Item[pObj->usItem].ubClassIndex].lbePocketsAvailable & (UINT16)pow((double)2, AttachmentSlots[sCount].ubPocketMapping - 1)) + { + tempItemSlots.push_back(AttachmentSlots[sCount].uiSlotIndex); + } + } + else + { tempItemSlots.push_back(AttachmentSlots[sCount].uiSlotIndex); - } - + } } } if(slotSize == tempItemSlots.size()){ //we didn't find a layout specific slot so try to find a default layout slot @@ -13840,14 +13845,21 @@ INT8 FindBackpackOnSoldier( SOLDIERTYPE * pSoldier ) } // HEADROCK HAM 3.6: This applies the INI modifier to explosives -UINT8 GetModifiedExplosiveDamage( UINT16 sDamage ) +UINT8 GetModifiedExplosiveDamage( UINT16 sDamage, UINT8 ubType ) { if (sDamage == 0) { return(0); } - sDamage = (INT16)(( sDamage * gGameExternalOptions.iExplosivesDamageModifier ) / 100); + // apply ini modifiers by type + if ( ubType == 0 ) // type 0 is health damage + sDamage = (FLOAT)(( sDamage * gGameExternalOptions.iExplosivesDamageModifier * gItemSettings.fDamageHealthModifierExplosive ) / 100); + else if ( ubType == 1 ) // type 1 is breath damage + sDamage = (FLOAT)(( sDamage * gGameExternalOptions.iExplosivesDamageModifier * gItemSettings.fDamageBreathModifierExplosive ) / 100); + else + return(0); // undefined type + sDamage = __max(1, sDamage); sDamage = __min(255, sDamage); diff --git a/Tactical/Items.h b/Tactical/Items.h index cce3479a..bb45433b 100644 --- a/Tactical/Items.h +++ b/Tactical/Items.h @@ -441,7 +441,7 @@ INT16 GetSnowCamoBonus( OBJECTTYPE * pObj ); INT8 FindBackpackOnSoldier( SOLDIERTYPE * pSoldier ); // HEADROCK HAM 3.6: Handler functions to get modified damage with INI parameter. -UINT8 GetModifiedExplosiveDamage( UINT16 ubDamage ); +UINT8 GetModifiedExplosiveDamage( UINT16 ubDamage, UINT8 ubType ); UINT8 GetModifiedMeleeDamage( UINT16 ubDamage ); UINT8 GetModifiedGunDamage( UINT16 ubDamage ); diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index 0c9b4e80..2275db06 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -2264,13 +2264,17 @@ BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLE { BOOLEAN fDontContinue = FALSE; - if ( pSoldier->pathing.usPathIndex > 0 ) - { + // silversurfer: Moved this further down. We will now check for gas at the starting point. + // Otherwise the soldier might just run out of the gas and take no damage when next tile has no gas. + // This change was necessary because we don't apply gas damage directly anymore when a gas grenade is tossed. +// if ( pSoldier->pathing.usPathIndex > 0 ) +// { // check for running into gas // note: this will have to use the minimum types of structures for tear/creature gas // since there isn't a way to retrieve the smoke effect structure - if ( (gpWorldLevelData[ pSoldier->sGridNo ].ubExtFlags[pSoldier->pathing.bLevel] & ANY_SMOKE_EFFECT && PreRandom( 4 ) == 0 ) || gpWorldLevelData[ pSoldier->sGridNo ].ubExtFlags[pSoldier->pathing.bLevel] & MAPELEMENT_EXT_BURNABLEGAS ) + // silversurfer: removed the randomness. Character is running through a gas cloud so make him suffer without a gas mask! + if ( (gpWorldLevelData[ pSoldier->sGridNo ].ubExtFlags[pSoldier->pathing.bLevel] & ANY_SMOKE_EFFECT /* && PreRandom( 4 ) == 0*/ ) || gpWorldLevelData[ pSoldier->sGridNo ].ubExtFlags[pSoldier->pathing.bLevel] & MAPELEMENT_EXT_BURNABLEGAS ) { EXPLOSIVETYPE * pExplosive = NULL; INT8 bPosOfMask; @@ -2287,12 +2291,15 @@ BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLE // since they only had one of each gas item?!?) // anyway, it means that we can only have one set of health/breath damage values for each gas type, until someone has time // to dig into this further and actually make it find the original item that caused the gas + // + // silversurfer: Changed the way the HitByGasFlags are handled. The old way allowed to run through a gas cloud and be immune to gas + // as long as you have been affected once. This is now handled by function DishOutGasDamage() that is used below. if ( !AM_A_ROBOT( pSoldier ) ) { if ( gpWorldLevelData[ pSoldier->sGridNo ].ubExtFlags[pSoldier->pathing.bLevel] & MAPELEMENT_EXT_SMOKE ) { - if ( bPosOfMask == NO_SLOT && !(pSoldier->flags.fHitByGasFlags & HIT_BY_SMOKEGAS) )//dnl ch40 200909 + if ( bPosOfMask == NO_SLOT ) //&& !(pSoldier->flags.fHitByGasFlags & HIT_BY_SMOKEGAS) )//dnl ch40 200909 { pExplosive = &( Explosive[ Item[ GetFirstExplosiveOfType(EXPLOSV_SMOKE) ].ubClassIndex ]); } @@ -2301,7 +2308,7 @@ BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLE //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Overhead pExplosive: %d", pExplosive->ubType ); if ( gpWorldLevelData[ pSoldier->sGridNo ].ubExtFlags[pSoldier->pathing.bLevel] & MAPELEMENT_EXT_TEARGAS ) { - if ( !(pSoldier->flags.fHitByGasFlags & HIT_BY_TEARGAS) && bPosOfMask == NO_SLOT ) + if ( bPosOfMask == NO_SLOT ) //&& !(pSoldier->flags.fHitByGasFlags & HIT_BY_TEARGAS) ) { pExplosive = &( Explosive[ Item[ GetFirstExplosiveOfType(EXPLOSV_TEARGAS) ].ubClassIndex ]); } @@ -2310,7 +2317,7 @@ BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLE //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Overhead pExplosive: %d", pExplosive->ubType ); if ( gpWorldLevelData[ pSoldier->sGridNo ].ubExtFlags[pSoldier->pathing.bLevel] & MAPELEMENT_EXT_MUSTARDGAS ) { - if ( !(pSoldier->flags.fHitByGasFlags & HIT_BY_MUSTARDGAS) && bPosOfMask == NO_SLOT ) + if ( bPosOfMask == NO_SLOT ) //&& !(pSoldier->flags.fHitByGasFlags & HIT_BY_MUSTARDGAS) ) { pExplosive = &(Explosive[ Item[ GetFirstExplosiveOfType(EXPLOSV_MUSTGAS) ].ubClassIndex ]); } @@ -2319,39 +2326,43 @@ BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLE //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Overhead pExplosive: %d", pExplosive->ubType ); if ( gpWorldLevelData[ pSoldier->sGridNo ].ubExtFlags[pSoldier->pathing.bLevel] & MAPELEMENT_EXT_CREATUREGAS ) { - if ( !(pSoldier->flags.fHitByGasFlags & HIT_BY_CREATUREGAS) ) // gas mask doesn't help vs creaturegas + //if ( !(pSoldier->flags.fHitByGasFlags & HIT_BY_CREATUREGAS) ) // gas mask doesn't help vs creaturegas { - pExplosive = &(Explosive[ Item[ GetFirstExplosiveOfType(EXPLOSV_CREATUREGAS) ].ubClassIndex ]); + pExplosive = &(Explosive[ Item[ GetFirstExplosiveOfType(EXPLOSV_CREATUREGAS) ].ubClassIndex ]); } } //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Overhead pExplosive: %d", pExplosive->ubType ); if ( gpWorldLevelData[ pSoldier->sGridNo ].ubExtFlags[pSoldier->pathing.bLevel] & MAPELEMENT_EXT_BURNABLEGAS ) { - if ( !(pSoldier->flags.fHitByGasFlags & HIT_BY_BURNABLEGAS) ) + //if ( !(pSoldier->flags.fHitByGasFlags & HIT_BY_BURNABLEGAS) ) // gas mask doesn't help vs fire damage { - pExplosive = &(Explosive[ Item[ GetFirstExplosiveOfType(EXPLOSV_BURNABLEGAS) ].ubClassIndex ]); + pExplosive = &(Explosive[ Item[ GetFirstExplosiveOfType(EXPLOSV_BURNABLEGAS) ].ubClassIndex ]); } } //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Overhead pSoldier->flags.fHitByGasFlags: %d", pSoldier->flags.fHitByGasFlags ); //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Overhead pExplosive: %d", pExplosive->ubType ); - if ( !(gpWorldLevelData[ pSoldier->sGridNo ].ubExtFlags[pSoldier->pathing.bLevel] & MAPELEMENT_EXT_SMOKE )) + // silversurfer: Why this? Smoke on a tile makes us immune to other damage types? I don't think so... + //if ( !(gpWorldLevelData[ pSoldier->sGridNo ].ubExtFlags[pSoldier->pathing.bLevel] & MAPELEMENT_EXT_SMOKE )) { if ( pExplosive ) { - pSoldier->EVENT_StopMerc( pSoldier->sGridNo, pSoldier->ubDirection ); - fDontContinue = TRUE; + // silversurfer: Don't stop the merc anymore. Let him run and suffer! + //pSoldier->EVENT_StopMerc( pSoldier->sGridNo, pSoldier->ubDirection ); + //fDontContinue = TRUE; + INT16 iGasHealthDamage = GetModifiedExplosiveDamage( pExplosive->ubDamage, 0 ) + (INT16)PreRandom( GetModifiedExplosiveDamage( pExplosive->ubDamage, 0 )); + INT16 iGasBreathDamage = ( 100 * ( GetModifiedExplosiveDamage( pExplosive->ubStunDamage, 1 ) + (INT16)PreRandom( ( GetModifiedExplosiveDamage( pExplosive->ubStunDamage, 1 ) / 2 ) ) ) ); - DishOutGasDamage( pSoldier, pExplosive, TRUE, FALSE, - (INT16) (pExplosive->ubDamage + (UINT8)PreRandom( pExplosive->ubDamage ) ), - (INT16) (100 * ( pExplosive->ubStunDamage + (INT16)PreRandom( ( pExplosive->ubStunDamage / 2 ) ) ) ), NOBODY ); + DishOutGasDamage( pSoldier, pExplosive, TRUE, FALSE, iGasHealthDamage, iGasBreathDamage, NOBODY ); } } } } + if ( pSoldier->pathing.usPathIndex > 0 ) + { if ( !fDontContinue ) { diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index 36874589..ef3beb49 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -7201,7 +7201,7 @@ void SwapMercPortraits ( SOLDIERTYPE *pSoldier, INT8 bDirection ) if ( gpCurrentTalkingFace != NULL ) return; - UINT8 ubSourceMerc = gusSelectedSoldier; + UINT8 ubSourceMerc = (UINT8)gusSelectedSoldier; UINT8 ubTargetMerc; UINT8 ubGroupID = pSoldier->ubGroupID; INT8 bOldPosition = GetTeamSlotFromPlayerID ( MercPtrs[ ubSourceMerc ]->ubID ); diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 8e4f64bd..0b4cd486 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -6111,7 +6111,7 @@ else } } // Make sure cap is within limits - uiCap = __max(uiCap, __max(0,(UINT32)iChance)); + uiCap = __max(uiCap, __max(0, iChance)); uiCap = __min(uiCap, gGameExternalOptions.ubMaximumCTH); // Now figure out the distance between the Base CTH and the CTH Cap. This is the distance we'll potentially diff --git a/TacticalAI/Attacks.cpp b/TacticalAI/Attacks.cpp index 36335940..6dfa3bfc 100644 --- a/TacticalAI/Attacks.cpp +++ b/TacticalAI/Attacks.cpp @@ -1405,7 +1405,7 @@ void CalcBestThrow(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestThrow) } else { - ubMaxPossibleAimTime = APBPConstants[AP_MIN_AIM_ATTACK];//dnl ch63 240813 + ubMaxPossibleAimTime = (UINT8)APBPConstants[AP_MIN_AIM_ATTACK];//dnl ch63 240813 // NB grenade launcher is NOT a direct fire weapon! ubRawAPCost = (UINT8) MinAPsToThrow( pSoldier, sGridNo, FALSE ); DebugMsg(TOPIC_JA2 , DBG_LEVEL_3 , String("Raw AP Cost = %d",ubRawAPCost )); @@ -2107,8 +2107,8 @@ INT32 EstimateThrowDamage( SOLDIERTYPE *pSoldier, UINT8 ubItemPos, SOLDIERTYPE * } - iExplosDamage = ( ( (INT32) Explosive[ ubExplosiveIndex ].ubDamage ) * 3) / 2; - iBreathDamage = ( ( (INT32) Explosive[ ubExplosiveIndex ].ubStunDamage ) * 5) / 4; + iExplosDamage = ( ( (INT32) GetModifiedExplosiveDamage( Explosive[ ubExplosiveIndex ].ubDamage, 0 ) ) * 3) / 2; + iBreathDamage = ( ( (INT32) GetModifiedExplosiveDamage( Explosive[ ubExplosiveIndex ].ubStunDamage, 1 ) ) * 5) / 4; if ( Explosive[ ubExplosiveIndex ].ubType == EXPLOSV_TEARGAS || Explosive[ ubExplosiveIndex ].ubType == EXPLOSV_MUSTGAS ) { diff --git a/TacticalAI/DecideAction.cpp b/TacticalAI/DecideAction.cpp index c50906c5..840c7ef5 100644 --- a/TacticalAI/DecideAction.cpp +++ b/TacticalAI/DecideAction.cpp @@ -5424,7 +5424,7 @@ L_NEWAIM: if (HAS_SKILL_TRAIT( pSoldier, MARTIAL_ARTS_NT) ) iChance += 30 * NUM_SKILL_TRAITS( pSoldier, MARTIAL_ARTS_NT); - if( PreRandom( 100 ) <= iChance ) + if( (INT32)PreRandom( 100 ) <= iChance ) { pSoldier->aiData.bAimTime = (gGameExternalOptions.fEnhancedCloseCombatSystem ? gSkillTraitValues.ubModifierForAPsAddedOnAimedPunches : 6); } @@ -5436,7 +5436,7 @@ L_NEWAIM: if (HAS_SKILL_TRAIT( pSoldier, MELEE_NT)) iChance += 30; - if( PreRandom( 100 ) <= iChance ) + if( (INT32)PreRandom( 100 ) <= iChance ) { pSoldier->aiData.bAimTime = (gGameExternalOptions.fEnhancedCloseCombatSystem ? gSkillTraitValues.ubModifierForAPsAddedOnAimedBladedAttackes : 6); } @@ -5584,7 +5584,7 @@ L_NEWAIM: // if yes, and we are facing it, jump // if no, go on, nothing to see here // determine direction of our target - UINT8 targetdirection = GetDirectionToGridNoFromGridNo(pSoldier->sGridNo, sClosestOpponent); + INT8 targetdirection = (INT8)GetDirectionToGridNoFromGridNo(pSoldier->sGridNo, sClosestOpponent); // determine if there is a jumpable window here, in the direction of our target // store old direction for this check @@ -5592,7 +5592,7 @@ L_NEWAIM: pSoldier->ubDirection = targetdirection; INT8 windowdirection = DIRECTION_IRRELEVANT; - if ( FindWindowJumpDirection(pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &windowdirection) && targetdirection == (UINT8)windowdirection ) + if ( FindWindowJumpDirection(pSoldier, pSoldier->sGridNo, pSoldier->ubDirection, &windowdirection) && targetdirection == windowdirection ) { pSoldier->ubDirection = tmpdirection; @@ -8074,7 +8074,7 @@ void DecideAlertStatus( SOLDIERTYPE *pSoldier ) // if yes, and we are facing it, jump // if no, go on, nothing to see here // determine direction of our target - INT8 targetdirection = GetDirectionToGridNoFromGridNo(pSoldier->sGridNo, sClosestOpponent); + INT8 targetdirection = (INT8)GetDirectionToGridNoFromGridNo(pSoldier->sGridNo, sClosestOpponent); // determine if there is a jumpable window here, in the direction of our target // store old direction for this check diff --git a/TileEngine/Explosion Control.cpp b/TileEngine/Explosion Control.cpp index 4ef77090..4dd5f8a9 100644 --- a/TileEngine/Explosion Control.cpp +++ b/TileEngine/Explosion Control.cpp @@ -1904,7 +1904,7 @@ BOOLEAN DamageSoldierFromBlast( UINT8 ubPerson, UINT8 ubOwner, INT32 sBombGridNo BOOLEAN DishOutGasDamage( SOLDIERTYPE * pSoldier, EXPLOSIVETYPE * pExplosive, INT16 sSubsequent, BOOLEAN fRecompileMovementCosts, INT16 sWoundAmt, INT16 sBreathAmt, UINT8 ubOwner , BOOL fFromRemoteClient ) { - // OJW - 20091028 + // OJW - 20091028 if (is_networked && is_client) { // only the owner of a merc may send damage (as this takes into account equipped gas mask) @@ -1925,6 +1925,8 @@ BOOLEAN DishOutGasDamage( SOLDIERTYPE * pSoldier, EXPLOSIVETYPE * pExplosive, IN #endif } + FLOAT fGasDamageModifier = 1.0; + FLOAT fGasBreathDamageModifier = 1.0; INT8 bPosOfMask = NO_SLOT; if (!pSoldier->bActive || !pSoldier->bInSector || !pSoldier->stats.bLife || AM_A_ROBOT( pSoldier ) ) @@ -1941,6 +1943,7 @@ BOOLEAN DishOutGasDamage( SOLDIERTYPE * pSoldier, EXPLOSIVETYPE * pExplosive, IN } } + // no gas mask helps from creature attacks and fire if ( pExplosive->ubType == EXPLOSV_CREATUREGAS || pExplosive->ubType == EXPLOSV_BURNABLEGAS) { if ( sSubsequent && pSoldier->flags.fHitByGasFlags & HIT_BY_CREATUREGAS ) @@ -1948,13 +1951,16 @@ BOOLEAN DishOutGasDamage( SOLDIERTYPE * pSoldier, EXPLOSIVETYPE * pExplosive, IN // already affected by creature gas this turn return( fRecompileMovementCosts ); } - if ( sSubsequent && pSoldier->flags.fHitByGasFlags & HIT_BY_BURNABLEGAS ) + // Who cares if he was affected already? Running through a gas cloud is not good for health so let him suffer! + if ( /*sSubsequent &&*/ pSoldier->flags.fHitByGasFlags & HIT_BY_BURNABLEGAS ) { - // already affected by BURNABLEGAS this turn - return( fRecompileMovementCosts ); + // Already affected by burnable gas this turn. Lower damage value by ini setting. + fGasDamageModifier = gItemSettings.fDamageHealthMoveModifierExplosive; + fGasBreathDamageModifier = gItemSettings.fDamageBreathMoveModifierExplosive; + //return( fRecompileMovementCosts ); } } - else // no gas mask help from creature attacks + else // // ATE/CJC: gas stuff { if ( pExplosive->ubType == EXPLOSV_TEARGAS ) @@ -1970,10 +1976,13 @@ BOOLEAN DishOutGasDamage( SOLDIERTYPE * pSoldier, EXPLOSIVETYPE * pExplosive, IN } // ignore whether subsequent or not if hit this turn + // Who cares if he was affected already? Running through a gas cloud is not good for health so let him suffer! if ( pSoldier->flags.fHitByGasFlags & HIT_BY_TEARGAS ) { - // already affected by creature gas this turn - return( fRecompileMovementCosts ); + // Already affected by tear gas this turn. Lower damage value by ini setting. + fGasDamageModifier = gItemSettings.fDamageHealthMoveModifierExplosive; + fGasBreathDamageModifier = gItemSettings.fDamageBreathMoveModifierExplosive; + //return( fRecompileMovementCosts ); } } else if ( pExplosive->ubType == EXPLOSV_MUSTGAS ) @@ -1988,20 +1997,36 @@ BOOLEAN DishOutGasDamage( SOLDIERTYPE * pSoldier, EXPLOSIVETYPE * pExplosive, IN return( fRecompileMovementCosts ); } - if ( sSubsequent && pSoldier->flags.fHitByGasFlags & HIT_BY_MUSTARDGAS ) + // Who cares if he was affected already? Running through a gas cloud is not good for health so let him suffer! + if ( /*sSubsequent &&*/ pSoldier->flags.fHitByGasFlags & HIT_BY_MUSTARDGAS ) { - // already affected by creature gas this turn - return( fRecompileMovementCosts ); + // Already affected by mustard gas this turn. Lower damage value by ini setting. + fGasDamageModifier = gItemSettings.fDamageHealthMoveModifierExplosive; + fGasBreathDamageModifier = gItemSettings.fDamageBreathMoveModifierExplosive; + //return( fRecompileMovementCosts ); } } else if(pExplosive->ubType == EXPLOSV_SMOKE)//dnl ch40 200909 { - // ignore whether subsequent or not if hit this turn - if(AM_A_ROBOT(pSoldier) || (pSoldier->flags.fHitByGasFlags & HIT_BY_SMOKEGAS)) + // robots are unaffected by smoke + if( AM_A_ROBOT(pSoldier) ) return(fRecompileMovementCosts); + + // Who cares if he was affected already? Running through a gas cloud is not good for health so let him suffer! + if ( pSoldier->flags.fHitByGasFlags & HIT_BY_SMOKEGAS ) + { + // Already affected by smoke this turn. Lower damage value by ini setting. + fGasDamageModifier = gItemSettings.fDamageHealthMoveModifierExplosive; + fGasBreathDamageModifier = gItemSettings.fDamageBreathMoveModifierExplosive; + //return( fRecompileMovementCosts ); + } } + // modify damage values + sWoundAmt *= fGasDamageModifier; + sBreathAmt *= fGasBreathDamageModifier; + bPosOfMask = FindGasMask(pSoldier); if(!DoesSoldierWearGasMask(pSoldier))//dnl ch40 200909 bPosOfMask = NO_SLOT; @@ -2212,7 +2237,7 @@ BOOLEAN ExpAffect( INT32 sBombGridNo, INT32 sGridNo, UINT32 uiDist, UINT16 usIte // Calculate wound amount // HEADROCK HAM 3.6: Can now use negative modifier. - INT16 newDamage = (INT16)GetModifiedExplosiveDamage( pExplosive->ubDamage ); + INT16 newDamage = (INT16)GetModifiedExplosiveDamage( pExplosive->ubDamage, 0 ); //INT16 newDamage = pExplosive->ubDamage + (INT16)(( pExplosive->ubDamage * gGameExternalOptions.ubExplosivesDamageMultiplier) / 100); //lal //DBrot: apply a modifier to confined explosions @@ -2222,7 +2247,7 @@ BOOLEAN ExpAffect( INT32 sBombGridNo, INT32 sGridNo, UINT32 uiDist, UINT16 usIte sWoundAmt = newDamage + (INT16) ( (newDamage * uiRoll) / 100 ); // Calculate breath amount ( if stun damage applicable ) - INT16 newBreath = (INT16)GetModifiedExplosiveDamage( pExplosive->ubStunDamage ); + INT16 newBreath = (INT16)GetModifiedExplosiveDamage( pExplosive->ubStunDamage, 1 ); //INT16 newBreath = pExplosive->ubStunDamage + (INT16)(( pExplosive->ubStunDamage * gGameExternalOptions.ubExplosivesDamageMultiplier) / 100); //lal if(InARoom(sBombGridNo, NULL)){ @@ -2416,7 +2441,10 @@ BOOLEAN ExpAffect( INT32 sBombGridNo, INT32 sGridNo, UINT32 uiDist, UINT16 usIte pSoldier = MercPtrs[ ubPerson ]; // someone is here, and they're gonna get hurt - fRecompileMovementCosts = DishOutGasDamage( pSoldier, pExplosive, sSubsequent, fRecompileMovementCosts, sWoundAmt, sBreathAmt, ubOwner ); + // silversurfer: Gas now only has an effect when the container had time to emit some. Initially it will do nothing. + // This prevents the problem that we have to suffer two times without a chance to react (1st when the grenade hits our position, 2nd when our turn starts) + if ( sSubsequent > 0 ) + fRecompileMovementCosts = DishOutGasDamage( pSoldier, pExplosive, sSubsequent, fRecompileMovementCosts, sWoundAmt, sBreathAmt, ubOwner ); /* if (!pSoldier->bActive || !pSoldier->bInSector || !pSoldier->stats.bLife || AM_A_ROBOT( pSoldier ) ) { diff --git a/TileEngine/SmokeEffects.cpp b/TileEngine/SmokeEffects.cpp index 74fd4a95..0444dde4 100644 --- a/TileEngine/SmokeEffects.cpp +++ b/TileEngine/SmokeEffects.cpp @@ -315,8 +315,11 @@ void AddSmokeEffectToTile( INT32 iSmokeEffectID, INT8 bType, INT32 sGridNo, INT8 // If smoke effect exists already.... stop + // silversurfer: Why? What if we throw another grenade of different type? Set at least the flag for the gas type... if ( gpWorldLevelData[ sGridNo ].ubExtFlags[ bLevel ] & ANY_SMOKE_EFFECT ) { + // Set world flags + gpWorldLevelData[ sGridNo ].ubExtFlags[ bLevel ] |= FromSmokeTypeToWorldFlags( bType ); return; } diff --git a/TileEngine/lighting.cpp b/TileEngine/lighting.cpp index af00ba65..04540323 100644 --- a/TileEngine/lighting.cpp +++ b/TileEngine/lighting.cpp @@ -841,7 +841,7 @@ BOOLEAN LightAddTile(UINT32 uiLightType, INT16 iSrcX, INT16 iSrcY, INT16 iX, INT { LEVELNODE *pLand, *pStruct, *pObject, *pMerc, *pRoof, *pOnRoof; UINT8 ubShadeAdd; -UINT32 uiTile; +INT32 uiTile; BOOLEAN fLitWall=FALSE; BOOLEAN fFake; @@ -983,7 +983,7 @@ BOOLEAN LightSubtractTile(UINT32 uiLightType, INT16 iSrcX, INT16 iSrcY, INT16 iX { LEVELNODE *pLand, *pStruct, *pObject, *pMerc, *pRoof, *pOnRoof; UINT8 ubShadeSubtract; -UINT32 uiTile; +INT32 uiTile; BOOLEAN fLitWall=FALSE; BOOLEAN fFake; // only passed in to land and roof layers; others get fed FALSE diff --git a/TileEngine/overhead map.cpp b/TileEngine/overhead map.cpp index a44c838e..e4331ac3 100644 --- a/TileEngine/overhead map.cpp +++ b/TileEngine/overhead map.cpp @@ -131,7 +131,7 @@ void InitNewOverheadDB( UINT8 ubTilesetID ) UINT32 dbSize = 0; - for (uiLoop = 0; uiLoop < giNumberOfTileTypes; uiLoop++) + for (uiLoop = 0; uiLoop < (UINT32)giNumberOfTileTypes; uiLoop++) { // Create video object @@ -189,7 +189,7 @@ void InitNewOverheadDB( UINT8 ubTilesetID ) } // NOW LOOP THROUGH AND CREATE DATABASE - for( cnt1 = 0; cnt1 < giNumberOfTileTypes; cnt1++ ) + for( cnt1 = 0; cnt1 < (UINT32)giNumberOfTileTypes; cnt1++ ) { // Get number of regions s = gSmTileSurf[ cnt1 ]; @@ -2051,7 +2051,7 @@ void CopyOverheadDBShadetablesFromTileset( ) // Loop through tileset - for (uiLoop = 0; uiLoop < giNumberOfTileTypes; uiLoop++) + for (uiLoop = 0; uiLoop < (UINT32)giNumberOfTileTypes; uiLoop++) { pTileSurf = ( gTileSurfaceArray[ uiLoop ] ); diff --git a/TileEngine/tiledef.cpp b/TileEngine/tiledef.cpp index f8fb9984..c1a5c976 100644 --- a/TileEngine/tiledef.cpp +++ b/TileEngine/tiledef.cpp @@ -648,7 +648,7 @@ void CreateTileDatabase( ) TILE_ELEMENT TileElement; // Loop through all surfaces and tiles and build database - for( cnt1 = 0; cnt1 < giNumberOfTileTypes; cnt1++ ) + for( cnt1 = 0; cnt1 < (UINT32)giNumberOfTileTypes; cnt1++ ) { // Get number of regions TileSurf = gTileSurfaceArray[ cnt1 ]; @@ -1013,7 +1013,7 @@ BOOLEAN GetTypeSubIndexFromTileIndex( UINT32 uiCheckType, UINT16 usIndex, UINT16 *pusSubIndex = 0xffff; - CHECKF ( uiCheckType < giNumberOfTileTypes ); + CHECKF ( uiCheckType < (UINT32)giNumberOfTileTypes ); *pusSubIndex = usIndex - gTileTypeStartIndex[ uiCheckType ] + 1; @@ -1026,7 +1026,7 @@ BOOLEAN GetTypeSubIndexFromTileIndexChar( UINT32 uiCheckType, UINT16 usIndex, UI // Tile database is zero-based, Type indecies are 1-based! - CHECKF ( uiCheckType < giNumberOfTileTypes ); + CHECKF ( uiCheckType < (UINT32)giNumberOfTileTypes ); *pubSubIndex = (UINT8)(usIndex - gTileTypeStartIndex[ uiCheckType ] + 1); @@ -1039,7 +1039,7 @@ BOOLEAN GetTileIndexFromTypeSubIndex( UINT32 uiCheckType, UINT16 usSubIndex, UIN *pusTileIndex = 0xffff; - CHECKF ( uiCheckType < giNumberOfTileTypes ); + CHECKF ( uiCheckType < (UINT32)giNumberOfTileTypes ); *pusTileIndex = usSubIndex + gTileTypeStartIndex[ uiCheckType ] - 1; diff --git a/TileEngine/worlddef.cpp b/TileEngine/worlddef.cpp index 9eed6346..bc80895f 100644 --- a/TileEngine/worlddef.cpp +++ b/TileEngine/worlddef.cpp @@ -398,7 +398,7 @@ BOOLEAN LoadTileSurfaces( char ppTileSurfaceFilenames[][32], UINT8 ubTilesetID ) } else { - for (uiLoop = 0; uiLoop < giNumberOfTileTypes; uiLoop++) + for (uiLoop = 0; uiLoop < (UINT32)giNumberOfTileTypes; uiLoop++) strcpy( TileSurfaceFilenames[uiLoop], ppTileSurfaceFilenames[uiLoop] );//(ppTileSurfaceFilenames + (65 * uiLoop)) ); } @@ -412,7 +412,7 @@ BOOLEAN LoadTileSurfaces( char ppTileSurfaceFilenames[][32], UINT8 ubTilesetID ) //uiFillColor = Get16BPPColor(FROMRGB( 100, 0, 0 )); // load the tile surfaces SetRelativeStartAndEndPercentage( 0, 1, 35, L"Tile Surfaces" ); - for (uiLoop = 0; uiLoop < giNumberOfTileTypes; uiLoop++) + for (uiLoop = 0; uiLoop < (UINT32)giNumberOfTileTypes; uiLoop++) { @@ -711,7 +711,7 @@ void BuildTileShadeTables( ) memset( gbNewTileSurfaceLoaded, 1, sizeof( gbNewTileSurfaceLoaded ) ); } - for (uiLoop = 0; uiLoop < giNumberOfTileTypes; uiLoop++) + for (uiLoop = 0; uiLoop < (UINT32)giNumberOfTileTypes; uiLoop++) { if ( gTileSurfaceArray[ uiLoop ] != NULL ) { @@ -757,7 +757,7 @@ void DestroyTileShadeTables( ) { UINT32 uiLoop; - for (uiLoop = 0; uiLoop < giNumberOfTileTypes; uiLoop++) + for (uiLoop = 0; uiLoop < (UINT32)giNumberOfTileTypes; uiLoop++) { if ( gTileSurfaceArray[ uiLoop ] != NULL ) { @@ -781,7 +781,7 @@ void DestroyTileSurfaces( ) { UINT32 uiLoop; - for (uiLoop = 0; uiLoop < giNumberOfTileTypes; uiLoop++) + for (uiLoop = 0; uiLoop < (UINT32)giNumberOfTileTypes; uiLoop++) { if ( gTileSurfaceArray[ uiLoop ] != NULL ) { diff --git a/Utils/XML_Items.cpp b/Utils/XML_Items.cpp index 1e2afe64..338a3090 100644 --- a/Utils/XML_Items.cpp +++ b/Utils/XML_Items.cpp @@ -1436,7 +1436,7 @@ itemEndElementHandle(void *userData, const XML_Char *name) else if(strcmp(name, "SleepModifier") == 0) { pData->curElement = ELEMENT; - pData->curItem.ubSleepModifier = (UINT16) atol(pData->szCharData); + pData->curItem.ubSleepModifier = (UINT8) atol(pData->szCharData); } pData->maxReadDepth--;