From 41dcb598ddd021ee70b320c96d30ba3706228655 Mon Sep 17 00:00:00 2001 From: Flugente Date: Tue, 26 Jul 2016 22:39:28 +0000 Subject: [PATCH] - New background property: alters snake defense chance - New sector property: sets maximum number of snakes per snake attack git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8277 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/XML_SectorNames.cpp | 12 ++++++++++++ Tactical/Interface.h | 1 + Tactical/Items.h | 1 + Tactical/Soldier Control.cpp | 2 ++ Tactical/XML_Background.cpp | 6 ++++++ TileEngine/environment.cpp | 7 ++++--- Utils/_ChineseText.cpp | 1 + Utils/_DutchText.cpp | 1 + Utils/_EnglishText.cpp | 1 + Utils/_FrenchText.cpp | 1 + Utils/_GermanText.cpp | 1 + Utils/_ItalianText.cpp | 1 + Utils/_PolishText.cpp | 1 + Utils/_RussianText.cpp | 1 + 14 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Strategic/XML_SectorNames.cpp b/Strategic/XML_SectorNames.cpp index f57231a2..6989fe89 100644 --- a/Strategic/XML_SectorNames.cpp +++ b/Strategic/XML_SectorNames.cpp @@ -98,6 +98,7 @@ SectorNameStartElementHandle(void *userData, const XML_Char *name, const char ** strcmp(name, "sandstormchance") == 0 || strcmp(name, "snowchance" ) == 0 || strcmp(name, "snakechance" ) == 0 || + strcmp(name, "numsnakes" ) == 0 || strcmp(name, "maxworkers" ) == 0 )) { pData->curElement = ELEMENT_PROPERTY; @@ -220,6 +221,11 @@ SectorNameEndElementHandle(void *userData, const XML_Char *name) SectorExternalData[ubSectorId][2].snakechance = 0; SectorExternalData[ubSectorId][3].snakechance = 0; + SectorExternalData[ubSectorId][0].numsnakes = pData->sectordata.numsnakes; + SectorExternalData[ubSectorId][1].numsnakes = 0; + SectorExternalData[ubSectorId][2].numsnakes = 0; + SectorExternalData[ubSectorId][3].numsnakes = 0; + SectorExternalData[ubSectorId][0].maxworkers = pData->sectordata.maxworkers; SectorExternalData[ubSectorId][1].maxworkers = 0; SectorExternalData[ubSectorId][2].maxworkers = 0; @@ -247,6 +253,7 @@ SectorNameEndElementHandle(void *userData, const XML_Char *name) pData->sectordata.sandstormchance = 0; pData->sectordata.snowchance = 0; pData->sectordata.snakechance = 0; + pData->sectordata.numsnakes = 0; pData->sectordata.maxworkers = 0; } else @@ -361,6 +368,11 @@ SectorNameEndElementHandle(void *userData, const XML_Char *name) pData->curElement = ELEMENT; pData->sectordata.snakechance = min( 100, (UINT8)atoi( pData->szCharData ) ); } + else if ( strcmp( name, "numsnakes" ) == 0 ) + { + pData->curElement = ELEMENT; + pData->sectordata.numsnakes = min( 20, (UINT8)atoi( pData->szCharData ) ); + } else if ( strcmp( name, "maxworkers" ) == 0 ) { pData->curElement = ELEMENT; diff --git a/Tactical/Interface.h b/Tactical/Interface.h index a2e51534..4472ffd2 100644 --- a/Tactical/Interface.h +++ b/Tactical/Interface.h @@ -192,6 +192,7 @@ enum { BG_PERC_DISEASE_TREAT, BG_TRACKER_ABILITY, BG_AMBUSH_RADIUS, + BG_SNAKEDEFENSE, BG_DISLIKEBG, // dislike any other background that has the negative of this value set BG_SMOKERTYPE, // 0: doesnt care about smoking 1: will consume cigarettes, dislikes non-smokers 2: will refuse to smoke, dislikes smokers diff --git a/Tactical/Items.h b/Tactical/Items.h index 5af95d19..e2a2d1e3 100644 --- a/Tactical/Items.h +++ b/Tactical/Items.h @@ -510,6 +510,7 @@ typedef struct UINT8 snowchance; // chance that it snows in this sector UINT8 snakechance; // if positive, snakes can attack in water, the higher the number, the more often it happens + UINT8 numsnakes; // how many snakes can be active at maximum UINT8 maxworkers; // maximum number of workers in this sector; diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index a60c3e34..2dda96f4 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -19145,6 +19145,8 @@ UINT8 SOLDIERTYPE::GetWaterSnakeDefenseChance() if ( gGameOptions.fNewTraitSystem ) val += gSkillTraitValues.usSVSnakeDefense * NUM_SKILL_TRAITS( this, SURVIVAL_NT ); + val += this->GetBackgroundValue( BG_SNAKEDEFENSE ); + // bonus if we have a knife, extra if it is in our hands INT8 invsize = (INT8)inv.size( ); // remember inventorysize, so we don't call size() repeatedly for ( INT8 bLoop = 0; bLoop < invsize; ++bLoop ) diff --git a/Tactical/XML_Background.cpp b/Tactical/XML_Background.cpp index 4d15f390..5c42b471 100644 --- a/Tactical/XML_Background.cpp +++ b/Tactical/XML_Background.cpp @@ -130,6 +130,7 @@ backgroundStartElementHandle(void *userData, const XML_Char *name, const XML_Cha strcmp(name, "disease_treatment" ) == 0 || strcmp(name, "tracker_ability" ) == 0 || strcmp(name, "ambush_radius" ) == 0 || + strcmp(name, "snake_defense" ) == 0 || strcmp(name, "dislikebackground" ) == 0 || strcmp(name, "smoker" ) == 0 || strcmp(name, "croucheddefense" ) == 0 || @@ -553,6 +554,11 @@ backgroundEndElementHandle(void *userData, const XML_Char *name) pData->curElement = ELEMENT; pData->curBackground.value[BG_AMBUSH_RADIUS] = min( 50, max( 0, (INT16)atol( pData->szCharData ) ) ); } + else if ( strcmp( name, "snake_defense" ) == 0 ) + { + pData->curElement = ELEMENT; + pData->curBackground.value[BG_SNAKEDEFENSE] = min( 100, max( -100, (INT16)atol( pData->szCharData ) ) ); + } else if ( strcmp( name, "dislikebackground" ) == 0 ) { pData->curElement = ELEMENT; diff --git a/TileEngine/environment.cpp b/TileEngine/environment.cpp index 0b86acff..7ede3f03 100644 --- a/TileEngine/environment.cpp +++ b/TileEngine/environment.cpp @@ -1106,7 +1106,7 @@ void AddSnakeAmim( INT32 sGridno, UINT8 usDirection ) ANITILE_PARAMS AniParams; memset( &AniParams, 0, sizeof(ANITILE_PARAMS) ); - + AniParams.sGridNo = sGridno; AniParams.ubLevelID = ANI_OBJECT_LEVEL; AniParams.sDelay = 100; @@ -1131,8 +1131,9 @@ void HandleEnvironmentHazard( ) if ( gGameExternalOptions.gfAllowSnakes && !gbWorldSectorZ && Chance( SectorExternalData[sector][0].snakechance ) ) { - // there can be up to 3 attacks at the same time - int actionstodo = 3; + // the number of snake attacks is randomized + int actionstodo = max(1, Random( SectorExternalData[sector][0].numsnakes ) ); + BOOLEAN soundplayed = FALSE; SOLDIERTYPE *pSoldier = NULL; diff --git a/Utils/_ChineseText.cpp b/Utils/_ChineseText.cpp index a3b06946..1d609a34 100644 --- a/Utils/_ChineseText.cpp +++ b/Utils/_ChineseText.cpp @@ -8946,6 +8946,7 @@ STR16 szBackgroundText_Value[]= L" %s%d%% 对人员治疗疾病的效率\n", //L" %s%d%% effectiveness at treating population against diseases\n", L"可以发现被跟踪的 %d 距离格数\n", //L"Can spot tracks up to %d tiles away\n", L" %s%d%% 被伏击时的初始距离\n", //L" %s%d%% initial distance to enemy in ambush\n", + L" %s%d%% chance to evade snake attacks\n", // TODO.Translate L" 对某些其他背景的厌恶\n", //L" dislikes some other backgrounds\n", L"吸烟者", //L"Smoker", diff --git a/Utils/_DutchText.cpp b/Utils/_DutchText.cpp index b5fe0275..cfd16d72 100644 --- a/Utils/_DutchText.cpp +++ b/Utils/_DutchText.cpp @@ -8963,6 +8963,7 @@ STR16 szBackgroundText_Value[]= L" %s%d%% effectiveness at treating population against diseases\n", L"Can spot tracks up to %d tiles away\n", L" %s%d%% initial distance to enemy in ambush\n", + L" %s%d%% chance to evade snake attacks\n", // TODO.Translate L" dislikes some other backgrounds\n", // TODO.Translate L"Smoker", diff --git a/Utils/_EnglishText.cpp b/Utils/_EnglishText.cpp index 0ed2ddb6..8abf2cc2 100644 --- a/Utils/_EnglishText.cpp +++ b/Utils/_EnglishText.cpp @@ -8944,6 +8944,7 @@ STR16 szBackgroundText_Value[]= L" %s%d%% effectiveness at treating population against diseases\n", L"Can spot tracks up to %d tiles away\n", L" %s%d%% initial distance to enemy in ambush\n", + L" %s%d%% chance to evade snake attacks\n", L" dislikes some other backgrounds\n", L"Smoker", diff --git a/Utils/_FrenchText.cpp b/Utils/_FrenchText.cpp index 031948ab..29d9903a 100644 --- a/Utils/_FrenchText.cpp +++ b/Utils/_FrenchText.cpp @@ -8945,6 +8945,7 @@ STR16 szBackgroundText_Value[]= L" %s%d%% effectiveness at treating population against diseases\n", L"Can spot tracks up to %d tiles away\n", L" %s%d%% initial distance to enemy in ambush\n", + L" %s%d%% chance to evade snake attacks\n", // TODO.Translate L" dislikes some other backgrounds\n", // TODO.Translate L"Smoker", diff --git a/Utils/_GermanText.cpp b/Utils/_GermanText.cpp index cc20bd6a..bc064779 100644 --- a/Utils/_GermanText.cpp +++ b/Utils/_GermanText.cpp @@ -8775,6 +8775,7 @@ STR16 szBackgroundText_Value[]= L" %s%d%% effectiveness at treating population against diseases\n", L"Can spot tracks up to %d tiles away\n", L" %s%d%% initial distance to enemy in ambush\n", + L" %s%d%% chance to evade snake attacks\n", // TODO.Translate L" dislikes some other backgrounds\n", // TODO.Translate L"Smoker", diff --git a/Utils/_ItalianText.cpp b/Utils/_ItalianText.cpp index b4254840..53f7c322 100644 --- a/Utils/_ItalianText.cpp +++ b/Utils/_ItalianText.cpp @@ -8954,6 +8954,7 @@ STR16 szBackgroundText_Value[]= L" %s%d%% effectiveness at treating population against diseases\n", L"Can spot tracks up to %d tiles away\n", L" %s%d%% initial distance to enemy in ambush\n", + L" %s%d%% chance to evade snake attacks\n", // TODO.Translate L" dislikes some other backgrounds\n", // TODO.Translate L"Smoker", diff --git a/Utils/_PolishText.cpp b/Utils/_PolishText.cpp index bef1a78c..efc1d971 100644 --- a/Utils/_PolishText.cpp +++ b/Utils/_PolishText.cpp @@ -8967,6 +8967,7 @@ STR16 szBackgroundText_Value[]= L" %s%d%% effectiveness at treating population against diseases\n", L"Can spot tracks up to %d tiles away\n", L" %s%d%% initial distance to enemy in ambush\n", + L" %s%d%% chance to evade snake attacks\n", // TODO.Translate L" dislikes some other backgrounds\n", // TODO.Translate L"Smoker", diff --git a/Utils/_RussianText.cpp b/Utils/_RussianText.cpp index f03b4bb2..20c03326 100644 --- a/Utils/_RussianText.cpp +++ b/Utils/_RussianText.cpp @@ -8944,6 +8944,7 @@ STR16 szBackgroundText_Value[]= L" %s%d%% эффективность в лечении населения от болезней\n", L"Замечает следы на расстоянии до %d метров\n", L" %s%d%% начальное расстояние до противника в засаде\n", + L" %s%d%% chance to evade snake attacks\n", // TODO.Translate L" dislikes some other backgrounds\n", // TODO.Translate L"Курит",