From 8b53d273f90ba520ab52b08929f7897c5aafcf1d Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Thu, 27 Feb 2020 10:51:45 +0000 Subject: [PATCH] New tags in CivGroupNames.xml: Side, CustomSide allow setting custom side for civilian group. NewEye: fix possible bug. InitShopKeeperSubTitledText: correctly initialize data. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8764 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/LuaInitNPCs.cpp | 6 +- Tactical/Faces.cpp | 126 ++++++++++++++---------------- Tactical/Handle Doors.cpp | 2 +- Tactical/Interface Dialogue.cpp | 4 +- Tactical/Interface.h | 8 +- Tactical/Overhead.cpp | 37 +++++---- Tactical/Overhead.h | 2 +- Tactical/ShopKeeper Interface.cpp | 2 +- Tactical/Soldier Create.cpp | 9 +++ Tactical/XML_CivGroupNames.cpp | 16 +++- Tactical/opplist.cpp | 8 +- 11 files changed, 121 insertions(+), 99 deletions(-) diff --git a/Strategic/LuaInitNPCs.cpp b/Strategic/LuaInitNPCs.cpp index 56fe6a37..b36accf0 100644 --- a/Strategic/LuaInitNPCs.cpp +++ b/Strategic/LuaInitNPCs.cpp @@ -7635,7 +7635,7 @@ static int l_SetEnterCombatMode (lua_State *L) pGoon = MercPtrs[ ubLoop ]; if ( pGoon->ubCivilianGroup == group && pGoon->bActive && pGoon->bInSector && pGoon->stats.bLife >= OKLIFE && pGoon->aiData.bOppList[ ubID ] == SEEN_CURRENTLY ) { - MakeCivHostile( pGoon, 2 ); + MakeCivHostile(pGoon); if ( ! (gTacticalStatus.uiFlags & INCOMBAT) ) { EnterCombatMode( pGoon->bTeam ); @@ -7665,7 +7665,7 @@ static int l_MakeMercPtrsHostile (lua_State *L) { UINT8 ubID = lua_tointeger(L,1); - MakeCivHostile( MercPtrs[ ubID ], 2 ); + MakeCivHostile(MercPtrs[ ubID ]); } return 0; @@ -9805,7 +9805,7 @@ static int l_MakeHostile (lua_State *L) else { // make hostile - MakeCivHostile( pSoldier, 2 ); + MakeCivHostile(pSoldier); } DeleteTalkingMenu(); if ( ! ( gTacticalStatus.uiFlags & INCOMBAT ) ) diff --git a/Tactical/Faces.cpp b/Tactical/Faces.cpp index fca4ee1f..974f76c0 100644 --- a/Tactical/Faces.cpp +++ b/Tactical/Faces.cpp @@ -2638,80 +2638,70 @@ BOOLEAN ExternRenderFace( UINT32 uiBuffer, INT32 iFaceIndex, INT16 sX, INT16 sY void NewEye( FACETYPE *pFace ) { - - switch(pFace->sEyeFrame) - { - case 0 : //pFace->sEyeFrame = (INT16)Random(2); // normal - can blink or frown - if ( pFace->ubExpression == ANGRY ) - { - pFace->ubEyeWait = 0; - pFace->sEyeFrame = 3; - } - else if ( pFace->ubExpression == SURPRISED ) - { - pFace->ubEyeWait = 0; - pFace->sEyeFrame = 4; - } - else - //if (pFace->sEyeFrame && Talk.talking && Talk.expression != DYING) - /// pFace->sEyeFrame = 3; - //else - pFace->sEyeFrame = 1; - break; - case 1 : // starting to blink - has to finish unless dying - //if (Talk.expression == DYING) - // pFace->sEyeFrame = 1; - //else + switch (pFace->sEyeFrame) + { + case 0: //pFace->sEyeFrame = (INT16)Random(2); // normal - can blink or frown + if (pFace->ubExpression == ANGRY) + { + pFace->ubEyeWait = 0; + pFace->sEyeFrame = 3; + } + else if (pFace->ubExpression == SURPRISED) + { + pFace->ubEyeWait = 0; + pFace->sEyeFrame = 4; + } + else + pFace->sEyeFrame = 1; + //if (pFace->sEyeFrame && Talk.talking && Talk.expression != DYING) + /// pFace->sEyeFrame = 3; + //else + break; + case 1: // starting to blink - has to finish unless dying + //if (Talk.expression == DYING) + // pFace->sEyeFrame = 1; + //else pFace->sEyeFrame = 2; - break; - case 2 : //pFace->sEyeFrame = (INT16)Random(2); // finishing blink - can go normal or frown - //if (pFace->sEyeFrame && Talk.talking) - // pFace->sEyeFrame = 3; - //else - // if (Talk.expression == ANGRY) + break; + case 2: //pFace->sEyeFrame = (INT16)Random(2); // finishing blink - can go normal or frown + //if (pFace->sEyeFrame && Talk.talking) + // pFace->sEyeFrame = 3; + //else + // if (Talk.expression == ANGRY) // pFace->sEyeFrame = 3; - // else + // else pFace->sEyeFrame = 0; - break; - - case 3 : //pFace->sEyeFrame = 4; break; // frown - - pFace->ubEyeWait++; - - if ( pFace->ubEyeWait > 6 ) - { - pFace->sEyeFrame = 0; - } - break; - - case 4 : - - pFace->ubEyeWait++; - - if ( pFace->ubEyeWait > 6 ) - { - pFace->sEyeFrame = 0; - } - break; - - case 5 : pFace->sEyeFrame = 6; - + break; + case 3: //pFace->sEyeFrame = 4; break; // frown + pFace->ubEyeWait++; + if (pFace->ubEyeWait > 6) + { + pFace->sEyeFrame = 0; + } + break; + case 4: + pFace->ubEyeWait++; + if (pFace->ubEyeWait > 6) + { + pFace->sEyeFrame = 0; + } + break; + case 5: pFace->sEyeFrame = 6; pFace->sEyeFrame = 0; - break; - - case 6 : pFace->sEyeFrame = 7; break; - case 7 : pFace->sEyeFrame = (INT16)Random(2); // can stop frowning or continue - //if (pFace->sEyeFrame && Talk.expression != DYING) - // pFace->sEyeFrame = 8; - //else - // pFace->sEyeFrame = 0; - //break; - case 8 : pFace->sEyeFrame = 9; break; - case 9 : pFace->sEyeFrame = 10; break; + break; + case 6: pFace->sEyeFrame = 7; break; + case 7: pFace->sEyeFrame = (INT16)Random(2); // can stop frowning or continue + //if (pFace->sEyeFrame && Talk.expression != DYING) + // pFace->sEyeFrame = 8; + //else + // pFace->sEyeFrame = 0; + break; + case 8: pFace->sEyeFrame = 9; break; + case 9: pFace->sEyeFrame = 10; break; case 10: pFace->sEyeFrame = 11; break; case 11: pFace->sEyeFrame = 12; break; - case 12: pFace->sEyeFrame = 0; break; - } + case 12: pFace->sEyeFrame = 0; break; + } } diff --git a/Tactical/Handle Doors.cpp b/Tactical/Handle Doors.cpp index f3611ce1..7658f0f9 100644 --- a/Tactical/Handle Doors.cpp +++ b/Tactical/Handle Doors.cpp @@ -451,7 +451,7 @@ void ProcessImplicationsOfPCMessingWithDoor( SOLDIERTYPE * pSoldier ) pGoon = MercPtrs[ ubLoop ]; if ( pGoon->ubCivilianGroup == KINGPIN_CIV_GROUP && pGoon->bActive && pGoon->bInSector && pGoon->stats.bLife >= OKLIFE && pGoon->aiData.bOppList[ pSoldier->ubID ] == SEEN_CURRENTLY ) { - MakeCivHostile( pGoon, 2 ); + MakeCivHostile(pGoon); if ( ! (gTacticalStatus.uiFlags & INCOMBAT) ) { EnterCombatMode( pGoon->bTeam ); diff --git a/Tactical/Interface Dialogue.cpp b/Tactical/Interface Dialogue.cpp index ac89aecb..e92403ad 100644 --- a/Tactical/Interface Dialogue.cpp +++ b/Tactical/Interface Dialogue.cpp @@ -2129,7 +2129,7 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum } else { - //MakeCivHostile( pSoldier, 2 ); + //MakeCivHostile(pSoldier); } if ( ( pSoldier->ubProfile != NO_PROFILE || pSoldier->IsAssassin() ) && pSoldier->stats.bLife >= OKLIFE ) { @@ -2936,7 +2936,7 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum else { // make hostile - MakeCivHostile( pSoldier, 2 ); + MakeCivHostile(pSoldier); } DeleteTalkingMenu(); if ( ! ( gTacticalStatus.uiFlags & INCOMBAT ) ) diff --git a/Tactical/Interface.h b/Tactical/Interface.h index 62eeb5fb..6ecb6cbb 100644 --- a/Tactical/Interface.h +++ b/Tactical/Interface.h @@ -80,10 +80,12 @@ typedef struct { UINT16 uiIndex; // add BOOLEAN Enabled; //add - BOOLEAN Loyalty; - BOOLEAN AddToBattle; + BOOLEAN Loyalty; + BOOLEAN AddToBattle; BOOLEAN fCanBeCaptured; // Flugente: if TRUE, members of this faction can be captured - CHAR16 szCurGroup[MAX_ENEMY_NAMES_CHARS]; + INT8 bSide; // sevenfm: custom side for civ group + BOOLEAN fCustomSide; // sevenfm: use custom side + CHAR16 szCurGroup[MAX_ENEMY_NAMES_CHARS]; } CIV_NAMES_VALUES; diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index b4e499fb..b1d1450e 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -3086,7 +3086,7 @@ BOOLEAN HandleAtNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving ) CancelAIAction( pSoldier, TRUE ); // aaaaaaaaaaaaaaaaaaaaatttaaaack!!!! AddToShouldBecomeHostileOrSayQuoteList( pSoldier->ubID ); - //MakeCivHostile( pSoldier, 2 ); + //MakeCivHostile(pSoldier); //TriggerNPCWithIHateYouQuote( pSoldier->ubProfile ); } } @@ -4211,14 +4211,16 @@ void SetSoldierNeutral( SOLDIERTYPE * pSoldier ) } } } -void MakeCivHostile( SOLDIERTYPE *pSoldier, INT8 bNewSide ) +void MakeCivHostile(SOLDIERTYPE *pSoldier) { + INT8 bNewSide; + if ( pSoldier->ubBodyType == COW ) { return; } - // override passed-in value; default is hostile to player, allied to army + // default is hostile to player, allied to army bNewSide = 1; switch( pSoldier->ubProfile ) @@ -4256,6 +4258,15 @@ void MakeCivHostile( SOLDIERTYPE *pSoldier, INT8 bNewSide ) break; } + // sevenfm: if side is set in CivGroupNames.xml, use it instead of default value + if (pSoldier->bTeam == CIV_TEAM && + pSoldier->ubCivilianGroup != NON_CIV_GROUP && + zCivGroupName[pSoldier->ubCivilianGroup].fCustomSide && + zCivGroupName[pSoldier->ubCivilianGroup].bSide >= 0) + { + bNewSide = zCivGroupName[pSoldier->ubCivilianGroup].bSide; + } + if ( !pSoldier->aiData.bNeutral && bNewSide == pSoldier->bSide ) { // already hostile! @@ -4289,15 +4300,13 @@ void MakeCivHostile( SOLDIERTYPE *pSoldier, INT8 bNewSide ) // change orders pSoldier->aiData.bOrders = FARPATROL; } - if (bNewSide != -1) - { - pSoldier->bSide = bNewSide; - } + + pSoldier->bSide = bNewSide; + if ( pSoldier->aiData.bNeutral ) { // HEADROCK HAM 3.6: INI Setting decides whether non-combat civs can become hostile - if (gGameExternalOptions.fCanTrueCiviliansBecomeHostile || - !IS_CIV_BODY_TYPE(pSoldier)) + if (gGameExternalOptions.fCanTrueCiviliansBecomeHostile || !IS_CIV_BODY_TYPE(pSoldier)) { SetSoldierNonNeutral( pSoldier ); } @@ -4305,14 +4314,12 @@ void MakeCivHostile( SOLDIERTYPE *pSoldier, INT8 bNewSide ) } } - // If we are already in combat... if ( ( gTacticalStatus.uiFlags & INCOMBAT ) ) { CheckForPotentialAddToBattleIncrement( pSoldier ); } - //uses Lua PROFILLUA2_ubProfile = pSoldier->ubProfile; PROFILLUA2_sSectorX = pSoldier->sSectorX; @@ -4346,7 +4353,7 @@ UINT8 CivilianGroupMembersChangeSidesWithinProximity( SOLDIERTYPE * pAttacked ) || ( PythSpacesAway( pSoldier->sGridNo, pAttacked->sGridNo ) < pAttacked->GetMaxDistanceVisible(pSoldier->sGridNo, pSoldier->pathing.bLevel) ) || ( pAttacked->ubAttackerID != NOBODY && PythSpacesAway( pSoldier->sGridNo, MercPtrs[ pAttacked->ubAttackerID ]->sGridNo ) < pAttacked->GetMaxDistanceVisible(MercPtrs[ pAttacked->ubAttackerID ]->sGridNo, MercPtrs[ pAttacked->ubAttackerID ]->pathing.bLevel) ) ) { - MakeCivHostile( pSoldier, 2 ); + MakeCivHostile(pSoldier); if ( pSoldier->aiData.bOppCnt > 0 ) { AddToShouldBecomeHostileOrSayQuoteList( pSoldier->ubID ); @@ -4476,7 +4483,7 @@ void CivilianGroupChangesSides( UINT8 ubCivilianGroup ) { if ( pSoldier->ubCivilianGroup == ubCivilianGroup && pSoldier->ubBodyType != COW ) { - MakeCivHostile( pSoldier, 2 ); + MakeCivHostile(pSoldier); if ( pSoldier->aiData.bOppCnt > 0 ) { AddToShouldBecomeHostileOrSayQuoteList( pSoldier->ubID ); @@ -4538,7 +4545,7 @@ void MilitiaChangesSides( ) if (pSoldier->bActive && pSoldier->bInSector && pSoldier->stats.bLife) { if ( (gWorldSectorX == 0 && gWorldSectorY == 0) || !NumNonPlayerTeamMembersInSector( gWorldSectorX, gWorldSectorY, ENEMY_TEAM ) ) - MakeCivHostile( pSoldier, 2 ); + MakeCivHostile(pSoldier); RecalculateOppCntsDueToNoLongerNeutral( pSoldier ); } } @@ -9363,7 +9370,7 @@ SOLDIERTYPE *InternalReduceAttackBusyCount( ) { //ZEROTIMECOUNTER( pTeamSoldier->timeCounters.AICounter ); - //MakeCivHostile( pTeamSoldier, 2 ); + //MakeCivHostile(pTeamSoldier); HandleCrowFlyAway( pTeamSoldier ); diff --git a/Tactical/Overhead.h b/Tactical/Overhead.h index 7bde6d19..7498fe74 100644 --- a/Tactical/Overhead.h +++ b/Tactical/Overhead.h @@ -299,7 +299,7 @@ BOOLEAN CheckForEndOfBattle( BOOLEAN fAnEnemyRetreated ); void AddManToTeam( INT8 bTeam ); void RemoveManFromTeam( INT8 bTeam ); void RemoveSoldierFromTacticalSector( SOLDIERTYPE *pSoldier, BOOLEAN fAdjustSelected ); -void MakeCivHostile( SOLDIERTYPE *pSoldier, INT8 bNewSide ); +void MakeCivHostile(SOLDIERTYPE *pSoldier); #define REASON_NORMAL_ATTACK 1 #define REASON_EXPLOSION 2 diff --git a/Tactical/ShopKeeper Interface.cpp b/Tactical/ShopKeeper Interface.cpp index a5228a2c..d5fc38a0 100644 --- a/Tactical/ShopKeeper Interface.cpp +++ b/Tactical/ShopKeeper Interface.cpp @@ -5038,7 +5038,7 @@ BOOLEAN IsGunOrAmmoOfSameTypeSelected( OBJECTTYPE *pItemObject ) void InitShopKeeperSubTitledText( STR16 pString ) { //Clear the contents of the subtitle text - memset( gsShopKeeperTalkingText, 0, SKI_SUBTITLE_TEXT_SIZE ); + memset(gsShopKeeperTalkingText, 0, sizeof(CHAR16)* SKI_SUBTITLE_TEXT_SIZE); swprintf( gsShopKeeperTalkingText, L"\"%s\"", pString ); diff --git a/Tactical/Soldier Create.cpp b/Tactical/Soldier Create.cpp index bb499f33..b4ab3a56 100644 --- a/Tactical/Soldier Create.cpp +++ b/Tactical/Soldier Create.cpp @@ -815,6 +815,15 @@ SOLDIERTYPE* TacticalCreateSoldier( SOLDIERCREATE_STRUCT *pCreateStruct, UINT8 * Soldier.sInsertionGridNo = pCreateStruct->sInsertionGridNo; Soldier.bOldLife = Soldier.stats.bLifeMax; + // set custom side for civilian group + if (Soldier.bTeam == CIV_TEAM && + Soldier.ubCivilianGroup != NON_CIV_GROUP && + zCivGroupName[Soldier.ubCivilianGroup].fCustomSide && + zCivGroupName[Soldier.ubCivilianGroup].bSide >= 0) + { + Soldier.bSide = zCivGroupName[Soldier.ubCivilianGroup].bSide; + } + // Flugente: disease can affect a soldier's health // not for us, and not for individual militia (their health is affected by their hourly healing instead) if ( gGameExternalOptions.fDisease && gGameExternalOptions.fDiseaseStrategic && Soldier.bTeam != OUR_TEAM && Soldier.bTeam != CREATURE_TEAM && !ARMED_VEHICLE((&Soldier)) && diff --git a/Tactical/XML_CivGroupNames.cpp b/Tactical/XML_CivGroupNames.cpp index 1ba9a141..79a86081 100644 --- a/Tactical/XML_CivGroupNames.cpp +++ b/Tactical/XML_CivGroupNames.cpp @@ -50,6 +50,8 @@ civGroupNamesStartElementHandle(void *userData, const XML_Char *name, const XML_ strcmp(name, "Loyalty") == 0 || strcmp(name, "AddToBattle") == 0 || strcmp(name, "fCanBeCaptured" ) == 0 || + strcmp(name, "Side") == 0 || + strcmp(name, "CustomSide") == 0 || strcmp(name, "szGroup") == 0 )) { pData->curElement = ELEMENT_PROPERTY; @@ -100,6 +102,8 @@ civGroupNamesEndElementHandle(void *userData, const XML_Char *name) zCivGroupName[pData->curCivGroupNames.uiIndex].AddToBattle = pData->curCivGroupNames.AddToBattle; zCivGroupName[pData->curCivGroupNames.uiIndex].Loyalty = pData->curCivGroupNames.Loyalty; zCivGroupName[pData->curCivGroupNames.uiIndex].fCanBeCaptured = pData->curCivGroupNames.fCanBeCaptured; + zCivGroupName[pData->curCivGroupNames.uiIndex].bSide = pData->curCivGroupNames.bSide; + zCivGroupName[pData->curCivGroupNames.uiIndex].fCustomSide = pData->curCivGroupNames.fCustomSide; } else { @@ -132,6 +136,16 @@ civGroupNamesEndElementHandle(void *userData, const XML_Char *name) pData->curElement = ELEMENT; pData->curCivGroupNames.fCanBeCaptured = (BOOLEAN)atol( pData->szCharData ); } + else if (strcmp(name, "Side") == 0) + { + pData->curElement = ELEMENT; + pData->curCivGroupNames.bSide = (INT8)atol(pData->szCharData); + } + else if (strcmp(name, "CustomSide") == 0) + { + pData->curElement = ELEMENT; + pData->curCivGroupNames.fCustomSide = (BOOLEAN)atol(pData->szCharData); + } else if(strcmp(name, "szGroup") == 0 ) { pData->curElement = ELEMENT; @@ -209,4 +223,4 @@ BOOLEAN ReadInCivGroupNamesStats( STR fileName, BOOLEAN localizedVersion) return( TRUE ); -} +} diff --git a/Tactical/opplist.cpp b/Tactical/opplist.cpp index 6a49c4fd..acabfbce 100644 --- a/Tactical/opplist.cpp +++ b/Tactical/opplist.cpp @@ -761,7 +761,7 @@ void CheckHostileOrSayQuoteList( void ) pSoldier = MercPtrs[ gubShouldBecomeHostileOrSayQuote[ ubLoop ] ]; if ( pSoldier->aiData.bNeutral ) { - MakeCivHostile( pSoldier, 2 ); + MakeCivHostile(pSoldier); // make civ group, if any, hostile if ( pSoldier->bTeam == CIV_TEAM && pSoldier->ubCivilianGroup != NON_CIV_GROUP && gTacticalStatus.fCivGroupHostile[ pSoldier->ubCivilianGroup ] == CIV_GROUP_WILL_BECOME_HOSTILE ) { @@ -2410,7 +2410,7 @@ void ManSeesMan(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, INT32 sOppGridNo, // check to see if we are looking at Maria or unauthorized personnel in the brothel if (pOpponent->ubProfile == MARIA) { - MakeCivHostile( pSoldier, 2 ); + MakeCivHostile(pSoldier); if ( ! (gTacticalStatus.uiFlags & INCOMBAT) ) { EnterCombatMode( pSoldier->bTeam ); @@ -2428,7 +2428,7 @@ void ManSeesMan(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, INT32 sOppGridNo, if ( InARoom( pOpponent->sGridNo, &usRoom ) && IN_BROTHEL_GUARD_ROOM( usRoom ) ) { // unauthorized! - MakeCivHostile( pSoldier, 2 ); + MakeCivHostile(pSoldier); if ( ! (gTacticalStatus.uiFlags & INCOMBAT) ) { EnterCombatMode( pSoldier->bTeam ); @@ -2446,7 +2446,7 @@ void ManSeesMan(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, INT32 sOppGridNo, if ( uiTime < 365 || uiTime > 1320 ) { // get off our farm! - MakeCivHostile( pSoldier, 2 ); + MakeCivHostile(pSoldier); if ( ! (gTacticalStatus.uiFlags & INCOMBAT) ) { EnterCombatMode( pSoldier->bTeam );