mirror of
https://github.com/1dot13/source.git
synced 2026-09-02 14:36:06 +02:00
New Feature: Additional Tile Properties (by anv)
- Feature can be completely disabled in .ini as COVER_SYSTEM_ADDITIONAL_TILE_PROPERTIES under Tactical Cover System Settings. - With Additional Tile Properties it's possible to supply all tiles with additional data, just like with .jsd files, except in XML. Files need to have same name as tile's .sti and .jsd files, and be put in \tilesets\AdditionalProperties\, or in specific \tilesets\xx\. - With additional properties it's possible to specify which camo type, and how effectively will work on any tile. Only snow camo will work on snow covered roofs, red carpet in palace won't perfectly cooperate with urban camo anymore, thick grass in the middle of the forest will provide better camouflage than sparse grass near the road. - It's now possible to specify footstep volume and stealth difficulty modifier of any tile. Carpets will absorb noise, tile floors amplify it, twigs laying on the tile will make sneaking harder. Choose your path carefully, taffer. - More infos: http://www.bears-pit.com/board/ubbthreads.php/topics/330942.html#Post330942 git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7001 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -121,6 +121,9 @@ TRAIT_DRAW_MODE gubDrawModeTrait = TRAIT_DRAW_OFF; // Flugente: mines display
|
||||
|
||||
CHAR16* GetTerrainName( const UINT8& ubTerrainType );
|
||||
|
||||
// anv: additional tile properties
|
||||
CHAR16* GetDetailedTerrainName( ADDITIONAL_TILE_PROPERTIES_VALUES zGivenTileProperties );
|
||||
|
||||
TileDefines GetTileCoverIndex( const INT8& bCover );
|
||||
|
||||
void AddCoverObjectToWorld( const INT32& sGridNo, const UINT16& usGraphic, const BOOLEAN& fRoof );
|
||||
@@ -235,6 +238,72 @@ CHAR16* GetTerrainName( const UINT8& ubTerrainType )
|
||||
}
|
||||
}
|
||||
|
||||
CHAR16* GetDetailedTerrainName( ADDITIONAL_TILE_PROPERTIES_VALUES zGivenTileProperties )
|
||||
{
|
||||
if(zGivenTileProperties.bWoodCamoAffinity >= 50)
|
||||
{
|
||||
if(zGivenTileProperties.bDesertCamoAffinity >= 50)
|
||||
{
|
||||
return gzDisplayCoverText[DC_TTI__WOOD_AND_DESERT];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(zGivenTileProperties.bUrbanCamoAffinity >= 50)
|
||||
{
|
||||
return gzDisplayCoverText[DC_TTI__WOOD_AND_URBAN];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(zGivenTileProperties.bSnowCamoAffinity >= 50)
|
||||
{
|
||||
return gzDisplayCoverText[DC_TTI__WOOD_AND_SNOW];
|
||||
}
|
||||
else
|
||||
{
|
||||
return gzDisplayCoverText[DC_TTI__WOOD];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(zGivenTileProperties.bDesertCamoAffinity >= 50)
|
||||
{
|
||||
if(zGivenTileProperties.bUrbanCamoAffinity >= 50)
|
||||
{
|
||||
return gzDisplayCoverText[DC_TTI__DESERT_AND_URBAN];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(zGivenTileProperties.bSnowCamoAffinity >= 50)
|
||||
{
|
||||
return gzDisplayCoverText[DC_TTI__DESERT_AND_SNOW];
|
||||
}
|
||||
else
|
||||
{
|
||||
return gzDisplayCoverText[DC_TTI__DESERT];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(zGivenTileProperties.bUrbanCamoAffinity >= 50)
|
||||
{
|
||||
if(zGivenTileProperties.bSnowCamoAffinity >= 50)
|
||||
{
|
||||
return gzDisplayCoverText[DC_TTI__URBAN_AND_SNOW];
|
||||
}
|
||||
else
|
||||
{
|
||||
return gzDisplayCoverText[DC_TTI__URBAN];
|
||||
}
|
||||
}
|
||||
else if(zGivenTileProperties.bSnowCamoAffinity >= 50)
|
||||
{
|
||||
return gzDisplayCoverText[DC_TTI__SNOW];
|
||||
}
|
||||
else
|
||||
{
|
||||
return gzDisplayCoverText[DC_TTI__UNKNOWN];
|
||||
}
|
||||
}
|
||||
|
||||
TileDefines GetTileCoverIndex( const INT8& bCover )
|
||||
{
|
||||
switch(bCover) {
|
||||
@@ -616,7 +685,20 @@ void DisplayRangeToTarget( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo )
|
||||
{
|
||||
UINT8 ubLightLevel = LightTrueLevel(sTargetGridNo, gsInterfaceLevel);
|
||||
UINT8 ubBrightness = 100 - 100 * (ubLightLevel-SHADE_MAX)/(SHADE_MIN-SHADE_MAX); // percentage
|
||||
INT8 ubTerrainType = GetTerrainTypeForGrid(sTargetGridNo, gsInterfaceLevel);
|
||||
|
||||
UINT8 ubTerrainType = NO_TERRAIN;
|
||||
|
||||
// anv: additional tile properties
|
||||
ADDITIONAL_TILE_PROPERTIES_VALUES zGivenTileProperties;
|
||||
memset(&zGivenTileProperties,0,sizeof(zGivenTileProperties));
|
||||
if(gGameExternalOptions.fAdditionalTileProperties)
|
||||
{
|
||||
zGivenTileProperties = GetAllAdditonalTilePropertiesForGrid(sTargetGridNo, gsInterfaceLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
ubTerrainType = GetTerrainTypeForGrid(sTargetGridNo, gsInterfaceLevel);
|
||||
}
|
||||
|
||||
INT8 ubCover = - GetSightAdjustment(pSoldier, sTargetGridNo, gsInterfaceLevel);
|
||||
|
||||
@@ -626,9 +708,18 @@ void DisplayRangeToTarget( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo )
|
||||
//Display the msg
|
||||
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, zOutputString );
|
||||
|
||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE,
|
||||
gzDisplayCoverText[DC_MSG__COVER_INFORMATION],
|
||||
ubCover, GetTerrainName(ubTerrainType), ubBrightness );
|
||||
if(gGameExternalOptions.fAdditionalTileProperties)
|
||||
{
|
||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE,
|
||||
gzDisplayCoverText[DC_MSG__COVER_INFORMATION],
|
||||
ubCover, GetDetailedTerrainName(zGivenTileProperties), ubBrightness );
|
||||
}
|
||||
else
|
||||
{
|
||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE,
|
||||
gzDisplayCoverText[DC_MSG__COVER_INFORMATION],
|
||||
ubCover, GetTerrainName(ubTerrainType), ubBrightness );
|
||||
}
|
||||
}
|
||||
|
||||
//Get the range to the target location
|
||||
|
||||
+147
-3
@@ -437,7 +437,16 @@ inline INT8 GetUrbanCamouflage( SOLDIERTYPE* pSoldier )
|
||||
|
||||
return MINMAX100N(pSoldier->urbanCamo + pSoldier->wornUrbanCamo);
|
||||
}
|
||||
|
||||
// anv: added this
|
||||
inline INT8 GetSnowCamouflage( SOLDIERTYPE* pSoldier )
|
||||
{
|
||||
// SANDRO - the Camouflage trait has been solved differently
|
||||
//if (HAS_SKILL_TRAIT( pSoldier, CAMOUFLAGED_URBAN )) {
|
||||
// return 100;
|
||||
//}
|
||||
|
||||
return MINMAX100N(pSoldier->snowCamo + pSoldier->wornSnowCamo);
|
||||
}
|
||||
// should be in lightning, 0-100 definition of brightness
|
||||
inline UINT8 GetBrightness(const UINT8& ubLightLevel)
|
||||
{
|
||||
@@ -500,6 +509,95 @@ INT8 GetTerrainTypeForGrid( const INT32& sGridNo, const INT16& bLevel )
|
||||
return gTileDatabase[ pNode->usIndex ].ubTerrainID;
|
||||
}
|
||||
|
||||
ADDITIONAL_TILE_PROPERTIES_VALUES GetAllAdditonalTilePropertiesForGrid( const INT32& sGridNo, const INT16& bLevel )
|
||||
{
|
||||
LEVELNODE* pNode;
|
||||
ADDITIONAL_TILE_PROPERTIES_VALUES ubAllTileProperties;
|
||||
INT16 iWoodCamoAffinity = 0;
|
||||
INT16 iDesertCamoAffinity = 0;
|
||||
INT16 iUrbanCamoAffinity = 0;
|
||||
INT16 iSnowCamoAffinity = 0;
|
||||
INT16 iCamoStanceModifer = 0;
|
||||
INT16 iSoundModifier = 0;
|
||||
INT16 iStealthDifficultyModifer = 0;
|
||||
UINT8 ubTerrainID = 0;
|
||||
BOOLEAN fFoundBottom = FALSE;
|
||||
|
||||
memset(&ubAllTileProperties,0,sizeof(ubAllTileProperties));
|
||||
for(UINT8 ubCnt=0; ubCnt<5 && !fFoundBottom; ubCnt++)
|
||||
{
|
||||
if (bLevel == I_ROOF_LEVEL)
|
||||
{
|
||||
switch(ubCnt)
|
||||
{
|
||||
case 0:
|
||||
pNode = gpWorldLevelData[ sGridNo ].pTopmostHead;
|
||||
break;
|
||||
case 1:
|
||||
pNode = gpWorldLevelData[ sGridNo ].pOnRoofHead;
|
||||
break;
|
||||
case 2:
|
||||
pNode = gpWorldLevelData[ sGridNo ].pRoofHead;
|
||||
break;
|
||||
default:
|
||||
pNode = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(ubCnt)
|
||||
{
|
||||
case 0:
|
||||
pNode = gpWorldLevelData[ sGridNo ].pShadowHead;
|
||||
break;
|
||||
case 1:
|
||||
pNode = gpWorldLevelData[ sGridNo ].pStructHead;
|
||||
break;
|
||||
case 2:
|
||||
pNode = gpWorldLevelData[ sGridNo ].pObjectHead;
|
||||
break;
|
||||
case 3:
|
||||
pNode = gpWorldLevelData[ sGridNo ].pLandHead;
|
||||
break;
|
||||
case 4:
|
||||
pNode = gpWorldLevelData[ sGridNo ].pLandStart;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( pNode!= NULL )
|
||||
{
|
||||
iWoodCamoAffinity += gTileDatabase[ pNode->usIndex ].bWoodCamoAffinity;
|
||||
iDesertCamoAffinity += gTileDatabase[ pNode->usIndex ].bDesertCamoAffinity;
|
||||
iUrbanCamoAffinity += gTileDatabase[ pNode->usIndex ].bUrbanCamoAffinity;
|
||||
iSnowCamoAffinity += gTileDatabase[ pNode->usIndex ].bSnowCamoAffinity;
|
||||
|
||||
iCamoStanceModifer += gTileDatabase[ pNode->usIndex ].bCamoStanceModifer;
|
||||
iSoundModifier += gTileDatabase[ pNode->usIndex ].bSoundModifier;
|
||||
iStealthDifficultyModifer += gTileDatabase[ pNode->usIndex ].bStealthDifficultyModifer;
|
||||
|
||||
ubTerrainID = gTileDatabase[ pNode->usIndex ].ubTerrainID;
|
||||
// going from the top, if any tile has terrain type, we're ignoring all tiles below it
|
||||
if(ubTerrainID != NO_TERRAIN)
|
||||
{
|
||||
fFoundBottom = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ubAllTileProperties.bWoodCamoAffinity = (INT8)iWoodCamoAffinity;
|
||||
ubAllTileProperties.bDesertCamoAffinity = (INT8)iDesertCamoAffinity;
|
||||
ubAllTileProperties.bUrbanCamoAffinity = (INT8)iUrbanCamoAffinity;
|
||||
ubAllTileProperties.bSnowCamoAffinity = (INT8)iSnowCamoAffinity;
|
||||
|
||||
ubAllTileProperties.bCamoStanceModifer = (INT8)iCamoStanceModifer;
|
||||
ubAllTileProperties.bSoundModifier = (INT8)iSoundModifier;
|
||||
ubAllTileProperties.bStealthDifficultyModifer = (INT8)iStealthDifficultyModifer;
|
||||
|
||||
return ubAllTileProperties;
|
||||
}
|
||||
|
||||
// the following functions should return percentage values which can be easily added/substracted from
|
||||
// the sight reduction variable inside the Soldier-sight-test.
|
||||
// This means we specify here how much each test counts towards the total.
|
||||
@@ -547,6 +645,32 @@ INT8 GetSightAdjustmentCamouflageOnTerrain( SOLDIERTYPE* pSoldier, const UINT8&
|
||||
}
|
||||
}
|
||||
|
||||
INT8 GetDetailedSightAdjustmentCamouflageOnTerrain( SOLDIERTYPE* pSoldier, const UINT8& ubStance, ADDITIONAL_TILE_PROPERTIES_VALUES zGivenTileProperties )
|
||||
{
|
||||
if (gGameExternalOptions.ubCamouflageEffectiveness == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
INT16 iResult = 0;
|
||||
|
||||
INT8 bStanceModifier = zGivenTileProperties.bCamoStanceModifer;
|
||||
|
||||
INT8 scaler = -(ANIM_STAND+1 - max(ANIM_PRONE, ubStance - bStanceModifier)); // stand = 7-6 => 10%, crouch = 7-3 => 66%, prone = 7-1 => 100%;
|
||||
|
||||
UINT8 effectiveness = gGameExternalOptions.ubCamouflageEffectiveness;
|
||||
|
||||
effectiveness += (UINT8)(pSoldier->GetBackgroundValue(BG_PERC_CAMO));
|
||||
|
||||
scaler = effectiveness * scaler / 6;
|
||||
|
||||
iResult += GetJungleCamouflage(pSoldier) * scaler / 100 * zGivenTileProperties.bWoodCamoAffinity / 100;
|
||||
iResult += GetDesertCamouflage(pSoldier) * scaler / 100 * zGivenTileProperties.bDesertCamoAffinity / 100;
|
||||
iResult += GetUrbanCamouflage(pSoldier) * scaler / 100 * zGivenTileProperties.bUrbanCamoAffinity / 100;
|
||||
iResult += GetSnowCamouflage(pSoldier) * scaler / 100 * zGivenTileProperties.bSnowCamoAffinity / 100;
|
||||
|
||||
return (INT8)min(100, max(0, iResult));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a percentage value to be added (or substracted) from sight. it's based on the movement of a soldier and the brightness level.
|
||||
* - this will be used to calculate the penalty (sight addition) which occurs on the soldier who is been spot-tested
|
||||
@@ -722,7 +846,19 @@ INT16 GetSightAdjustment( SOLDIERTYPE* pSoldier, INT32 sGridNo, INT16 bLevel, IN
|
||||
bStance = GetCurrentHeightOfSoldier( pSoldier );
|
||||
}
|
||||
|
||||
UINT8 ubTerrainType = GetTerrainTypeForGrid( sGridNo, bLevel );
|
||||
UINT8 ubTerrainType = NO_TERRAIN;
|
||||
// anv: additional tile properties
|
||||
ADDITIONAL_TILE_PROPERTIES_VALUES zGivenTileProperties;
|
||||
memset(&zGivenTileProperties,0,sizeof(zGivenTileProperties));
|
||||
if(gGameExternalOptions.fAdditionalTileProperties)
|
||||
{
|
||||
zGivenTileProperties = GetAllAdditonalTilePropertiesForGrid(sGridNo, bLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
ubTerrainType = GetTerrainTypeForGrid( sGridNo, bLevel );
|
||||
}
|
||||
|
||||
UINT8 ubLightLevel = LightTrueLevel( sGridNo, bLevel );
|
||||
|
||||
INT16 iSightAdjustment = 0;
|
||||
@@ -736,7 +872,15 @@ INT16 GetSightAdjustment( SOLDIERTYPE* pSoldier, INT32 sGridNo, INT16 bLevel, IN
|
||||
// context sensitive stuff with 2nd parameter (needs soldier for attributes but can be given a second parameter)
|
||||
iSightAdjustment += GetSightAdjustmentThroughMovement( pSoldier, pSoldier->bTilesMoved, ubLightLevel );
|
||||
iSightAdjustment += GetSightAdjustmentStealthAtLightLevel( pSoldier, ubLightLevel );
|
||||
iSightAdjustment += GetSightAdjustmentCamouflageOnTerrain( pSoldier, bStance, ubTerrainType );
|
||||
|
||||
if(gGameExternalOptions.fAdditionalTileProperties)
|
||||
{
|
||||
iSightAdjustment += GetDetailedSightAdjustmentCamouflageOnTerrain( pSoldier, bStance, zGivenTileProperties );
|
||||
}
|
||||
else
|
||||
{
|
||||
iSightAdjustment += GetSightAdjustmentCamouflageOnTerrain( pSoldier, bStance, ubTerrainType );
|
||||
}
|
||||
|
||||
return MINMAX100N(iSightAdjustment);
|
||||
}
|
||||
|
||||
@@ -185,6 +185,9 @@ void MoveBullet( INT32 iBullet );
|
||||
|
||||
INT8 GetTerrainTypeForGrid( const INT32& uGridNo, const INT16& bLevel );
|
||||
|
||||
// anv: additional tile properties
|
||||
ADDITIONAL_TILE_PROPERTIES_VALUES GetAllAdditonalTilePropertiesForGrid( const INT32& sGridNo, const INT16& bLevel );
|
||||
|
||||
// check the flat distance adjustment based on your stance
|
||||
// use this to test your view on your surroundings based on your stance
|
||||
INT8 GetSightAdjustmentThroughStance( const UINT8& ubStance );
|
||||
|
||||
@@ -1635,6 +1635,7 @@ UINT8 bHealthStrRanges[] =
|
||||
|
||||
INT16 gsTerrainTypeSpeedModifiers[] =
|
||||
{
|
||||
5, // NO_TERRAIN // anv: that one was missing
|
||||
5, // Flat ground
|
||||
5, // Floor
|
||||
5, // Paved road
|
||||
|
||||
@@ -25,9 +25,21 @@ BOOLEAN IsJumpableWindowPresentAtGridNo( INT32 sGridNo, INT8 direction2, BOOLEAN
|
||||
STRUCTURE * pStructure;
|
||||
|
||||
pStructure = FindStructure( sGridNo, STRUCTURE_WALLNWINDOW );
|
||||
|
||||
|
||||
if ( pStructure )
|
||||
{
|
||||
// anv: additional tile properties hook
|
||||
if(gGameExternalOptions.fAdditionalTileProperties)
|
||||
{
|
||||
LEVELNODE *pNode = FindLevelNodeBasedOnStructure( sGridNo, pStructure );
|
||||
if(pNode != NULL)
|
||||
{
|
||||
if( gTileDatabase[ pNode->usIndex ].uiAdditionalFlags & ADDITIONAL_TILE_FLAG_BLOCKED_WINDOW )
|
||||
// special tag disables jumping through specific windows (e.g. barred windows in Tixa)
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( direction2 == SOUTH || direction2 == NORTH ) && (pStructure->ubWallOrientation == OUTSIDE_TOP_LEFT || pStructure->ubWallOrientation == INSIDE_TOP_LEFT ) && pStructure->fFlags & STRUCTURE_WALLNWINDOW && !(pStructure->fFlags & STRUCTURE_SPECIAL) )
|
||||
{
|
||||
if ( fIntactWindowsAlso || ( pStructure->fFlags & STRUCTURE_OPEN ) )
|
||||
@@ -663,4 +675,4 @@ BOOLEAN SetOpenableStructureToClosed( INT32 sGridNo, UINT8 ubLevel )
|
||||
}
|
||||
// else leave it as is!
|
||||
return( TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1000,6 +1000,10 @@
|
||||
RelativePath=".\World Items.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\XML_AdditionalTileProperties.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\XML_AmmoStrings.cpp"
|
||||
>
|
||||
|
||||
@@ -1002,6 +1002,10 @@
|
||||
RelativePath="World Items.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\XML_AdditionalTileProperties.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="XML_AmmoStrings.cpp"
|
||||
>
|
||||
|
||||
@@ -239,6 +239,7 @@
|
||||
<ClCompile Include="XML_Sounds.cpp" />
|
||||
<ClCompile Include="XML_SpreadPatterns.cpp" />
|
||||
<ClCompile Include="XML_Taunts.cpp" />
|
||||
<ClCompile Include="XML_AdditionalTileProperties.cpp" />
|
||||
<ClCompile Include="XML_TonyInventory.cpp" />
|
||||
<ClCompile Include="XML_Vehicles.cpp" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -659,5 +659,8 @@
|
||||
<ClCompile Include="RandomMerc.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="XML_AdditionalTileProperties.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -239,6 +239,7 @@
|
||||
<ClCompile Include="XML_Sounds.cpp" />
|
||||
<ClCompile Include="XML_SpreadPatterns.cpp" />
|
||||
<ClCompile Include="XML_Taunts.cpp" />
|
||||
<ClCompile Include="XML_AdditionalTileProperties.cpp" />
|
||||
<ClCompile Include="XML_TonyInventory.cpp" />
|
||||
<ClCompile Include="XML_Vehicles.cpp" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -658,6 +658,9 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="RandomMerc.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="XML_AdditionalTileProperties.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -491,6 +491,10 @@ extern BOOLEAN WriteCampaignStatsEvents( STR fileName);
|
||||
extern BOOLEAN ReadInTaunts(STR fileName, BOOLEAN localizedVersion );
|
||||
extern BOOLEAN WriteTaunts( STR fileName );
|
||||
|
||||
// anv: detailed tileset terrain types
|
||||
extern BOOLEAN ReadInAdditionalTileProperties(STR fileName );
|
||||
extern BOOLEAN WriteAdditionalTileProperties( STR fileName );
|
||||
|
||||
//Enabled\Disabled profile sound by Jazz
|
||||
extern BOOLEAN ReadInSoundProfile( STR fileName );
|
||||
extern BOOLEAN WriteSoundProfile( STR fileName );
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
#ifdef PRECOMPILEDHEADERS
|
||||
#include "Tactical All.h"
|
||||
#else
|
||||
#include "sgp.h"
|
||||
#include "Debug Control.h"
|
||||
#include "expat.h"
|
||||
#include "XML.h"
|
||||
#include "Interface.h"
|
||||
#endif
|
||||
|
||||
#include "tiledef.h"
|
||||
|
||||
struct
|
||||
{
|
||||
PARSE_STAGE curElement;
|
||||
|
||||
CHAR8 szCharData[MAX_CHAR_DATA_LENGTH+1];
|
||||
|
||||
UINT32 currentDepth;
|
||||
UINT32 maxReadDepth;
|
||||
}
|
||||
typedef additionalTilePropertyParseData;
|
||||
|
||||
static void XMLCALL
|
||||
additionalTilePropertyStartElementHandle(void *userData, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
additionalTilePropertyParseData * pData = (additionalTilePropertyParseData *)userData;
|
||||
|
||||
if(pData->currentDepth <= pData->maxReadDepth) //are we reading this element?
|
||||
{
|
||||
if(strcmp(name, "ADDITIONALTILEPROPERTIES") == 0 && pData->curElement == ELEMENT_NONE)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
|
||||
memset(&zAdditionalTileProperties,0,sizeof(ADDITIONAL_TILE_PROPERTIES_VALUES));
|
||||
|
||||
pData->maxReadDepth++; //we are not skipping this element
|
||||
}
|
||||
else if(pData->curElement == ELEMENT &&
|
||||
(strcmp(name, "ubTerrainID") == 0 ||
|
||||
strcmp(name, "bWoodCamoAffinity") == 0 ||
|
||||
strcmp(name, "bDesertCamoAffinity") == 0 ||
|
||||
strcmp(name, "bUrbanCamoAffinity") == 0 ||
|
||||
strcmp(name, "bSnowCamoAffinity") == 0 ||
|
||||
strcmp(name, "bCamoStanceModifer") == 0 ||
|
||||
strcmp(name, "bSoundModifier") == 0 ||
|
||||
strcmp(name, "bStealthDifficultyModifer") == 0 ||
|
||||
strcmp(name, "fBlockedWindow") == 0
|
||||
))
|
||||
{
|
||||
pData->curElement = ELEMENT_PROPERTY;
|
||||
|
||||
pData->maxReadDepth++; //we are not skipping this element
|
||||
}
|
||||
|
||||
pData->szCharData[0] = '\0';
|
||||
}
|
||||
|
||||
pData->currentDepth++;
|
||||
}
|
||||
|
||||
static void XMLCALL
|
||||
additionalTilePropertyCharacterDataHandle(void *userData, const XML_Char *str, int len)
|
||||
{
|
||||
additionalTilePropertyParseData * pData = (additionalTilePropertyParseData *)userData;
|
||||
|
||||
if( (pData->currentDepth <= pData->maxReadDepth) &&
|
||||
(strlen(pData->szCharData) < MAX_CHAR_DATA_LENGTH)
|
||||
){
|
||||
strncat(pData->szCharData,str,__min((unsigned int)len,MAX_CHAR_DATA_LENGTH-strlen(pData->szCharData)));
|
||||
}
|
||||
}
|
||||
|
||||
static void XMLCALL
|
||||
additionalTilePropertyEndElementHandle(void *userData, const XML_Char *name)
|
||||
{
|
||||
additionalTilePropertyParseData * pData = (additionalTilePropertyParseData *)userData;
|
||||
|
||||
if(pData->currentDepth <= pData->maxReadDepth)
|
||||
{
|
||||
if(strcmp(name, "ADDITIONALTILEPROPERTIES") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
}
|
||||
else if(strcmp(name, "ubTerrainID") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
zAdditionalTileProperties.ubTerrainID = (UINT8) atol(pData->szCharData);
|
||||
}
|
||||
else if(strcmp(name, "bWoodCamoAffinity") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
zAdditionalTileProperties.bWoodCamoAffinity = (INT8) atol(pData->szCharData);
|
||||
}
|
||||
else if(strcmp(name, "bDesertCamoAffinity") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
zAdditionalTileProperties.bDesertCamoAffinity = (INT8) atol(pData->szCharData);
|
||||
}
|
||||
else if(strcmp(name, "bUrbanCamoAffinity") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
zAdditionalTileProperties.bUrbanCamoAffinity = (INT8) atol(pData->szCharData);
|
||||
}
|
||||
else if(strcmp(name, "bSnowCamoAffinity") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
zAdditionalTileProperties.bSnowCamoAffinity = (INT8) atol(pData->szCharData);
|
||||
}
|
||||
else if(strcmp(name, "bCamoStanceModifer") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
zAdditionalTileProperties.bCamoStanceModifer = (INT8) atol(pData->szCharData);
|
||||
}
|
||||
else if(strcmp(name, "bSoundModifier") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
zAdditionalTileProperties.bSoundModifier = (INT8) atol(pData->szCharData);
|
||||
}
|
||||
else if(strcmp(name, "bStealthDifficultyModifer") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
zAdditionalTileProperties.bStealthDifficultyModifer = (INT8) atol(pData->szCharData);
|
||||
}
|
||||
else if(strcmp(name, "fBlockedWindow") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
zAdditionalTileProperties.uiAdditionalFlags |= (UINT16) atol(pData->szCharData) ? ADDITIONAL_TILE_FLAG_BLOCKED_WINDOW: 0;
|
||||
}
|
||||
|
||||
pData->maxReadDepth--;
|
||||
}
|
||||
pData->currentDepth--;
|
||||
}
|
||||
|
||||
BOOLEAN ReadInAdditionalTileProperties(STR fileName)
|
||||
{
|
||||
HWFILE hFile;
|
||||
UINT32 uiBytesRead;
|
||||
UINT32 uiFSize;
|
||||
CHAR8 * lpcBuffer;
|
||||
XML_Parser parser = XML_ParserCreate(NULL);
|
||||
|
||||
additionalTilePropertyParseData pData;
|
||||
|
||||
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "Loading AdditionalTilePropertys.xml" );
|
||||
|
||||
// Open file
|
||||
hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE );
|
||||
if ( !hFile )
|
||||
return( FALSE );
|
||||
|
||||
uiFSize = FileGetSize(hFile);
|
||||
lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1);
|
||||
|
||||
//Read in block
|
||||
if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) )
|
||||
{
|
||||
MemFree(lpcBuffer);
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
lpcBuffer[uiFSize] = 0; //add a null terminator
|
||||
|
||||
FileClose( hFile );
|
||||
|
||||
XML_SetElementHandler(parser, additionalTilePropertyStartElementHandle, additionalTilePropertyEndElementHandle);
|
||||
XML_SetCharacterDataHandler(parser, additionalTilePropertyCharacterDataHandle);
|
||||
|
||||
memset(&pData,0,sizeof(pData));
|
||||
|
||||
XML_SetUserData(parser, &pData);
|
||||
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
|
||||
{
|
||||
CHAR8 errorBuf[511];
|
||||
|
||||
sprintf(errorBuf, "XML Parser Error in additionalTileProperty.xml: %s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
|
||||
LiveMessage(errorBuf);
|
||||
|
||||
MemFree(lpcBuffer);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
MemFree(lpcBuffer);
|
||||
|
||||
XML_ParserFree(parser);
|
||||
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN WriteAdditionalTileProperties( STR fileName)
|
||||
{
|
||||
HWFILE hFile;
|
||||
|
||||
//Debug code; make sure that what we got from the file is the same as what's there
|
||||
// Open a new file
|
||||
hFile = FileOpen( fileName, FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE );
|
||||
if ( !hFile )
|
||||
return( FALSE );
|
||||
|
||||
{
|
||||
UINT32 cnt;
|
||||
|
||||
FilePrintf(hFile,"<additionalTilePropertyS>\r\n");
|
||||
for(cnt = 0; cnt < NUM_TAUNT; ++cnt)
|
||||
{
|
||||
FilePrintf(hFile,"\t<TILESET>\r\n");
|
||||
FilePrintf(hFile,"\t\t<uiIndex>%d</uiIndex>\r\n", cnt);
|
||||
|
||||
FilePrintf(hFile,"\t</TILESET>\r\n");
|
||||
}
|
||||
FilePrintf(hFile,"</additionalTilePropertyS>\r\n");
|
||||
}
|
||||
FileClose( hFile );
|
||||
|
||||
return( TRUE );
|
||||
}
|
||||
+20
-4
@@ -5298,9 +5298,22 @@ UINT8 MovementNoise( SOLDIERTYPE *pSoldier )
|
||||
UINT8 ubMaxVolume, ubVolume, ubBandaged, ubEffLife;
|
||||
INT8 bInWater = FALSE;
|
||||
|
||||
// anv: additional tile properties
|
||||
// modify amount of noise and stealth difficulty depending on surface type
|
||||
|
||||
INT8 bGroundVolumeModifier = 0;
|
||||
INT8 bGroundStealthDifficultyModifier = 0;
|
||||
ADDITIONAL_TILE_PROPERTIES_VALUES zGivenTileProperties;
|
||||
memset(&zGivenTileProperties,0,sizeof(zGivenTileProperties));
|
||||
if(gGameExternalOptions.fAdditionalTileProperties)
|
||||
{
|
||||
zGivenTileProperties = GetAllAdditonalTilePropertiesForGrid( pSoldier->sGridNo, pSoldier->pathing.bLevel );
|
||||
bGroundVolumeModifier = zGivenTileProperties.bSoundModifier;
|
||||
bGroundStealthDifficultyModifier = zGivenTileProperties.bStealthDifficultyModifer;
|
||||
}
|
||||
if ( pSoldier->bTeam == ENEMY_TEAM )
|
||||
{
|
||||
return( (UINT8) (MAX_MOVEMENT_NOISE - PreRandom( 2 )) );
|
||||
return( (UINT8) (MAX_MOVEMENT_NOISE - PreRandom( 2 )) + bGroundVolumeModifier );
|
||||
}
|
||||
|
||||
// CHANGED BY SANDRO - LET'S MAKE THE STEALTH BASED ON AGILITY LIKE IT SHOULD BE
|
||||
@@ -5376,7 +5389,8 @@ UINT8 MovementNoise( SOLDIERTYPE *pSoldier )
|
||||
|
||||
if (!pSoldier->bStealthMode) // REGULAR movement
|
||||
{
|
||||
ubMaxVolume = MAX_MOVEMENT_NOISE - (iStealthSkill / 16); // 9 - (0 to 6) => 3 to 9
|
||||
//ubMaxVolume = MAX_MOVEMENT_NOISE - (iStealthSkill / 16); // 9 - (0 to 6) => 3 to 9
|
||||
ubMaxVolume = MAX_MOVEMENT_NOISE - (iStealthSkill / 16) + bGroundVolumeModifier; // 9 - (0 to 6) => 3 to 9
|
||||
|
||||
if (bInWater)
|
||||
{
|
||||
@@ -5406,11 +5420,13 @@ UINT8 MovementNoise( SOLDIERTYPE *pSoldier )
|
||||
}
|
||||
else // in STEALTH mode
|
||||
{
|
||||
iRoll = (INT32) PreRandom(100); // roll them bones!
|
||||
//iRoll = (INT32) PreRandom(100); // roll them bones!
|
||||
iRoll = (INT32) PreRandom(100) + bGroundStealthDifficultyModifier; // roll them bones!
|
||||
|
||||
if (iRoll >= iStealthSkill) // v1.13 modification: give a second chance!
|
||||
{
|
||||
iRoll = (INT32) PreRandom(100);
|
||||
//iRoll = (INT32) PreRandom(100);
|
||||
iRoll = (INT32) PreRandom(100) + bGroundStealthDifficultyModifier;
|
||||
}
|
||||
|
||||
if (iRoll < iStealthSkill)
|
||||
|
||||
Reference in New Issue
Block a user