Files
source/Tactical/Civ Quotes.cpp
T
Wanne e64d5a2fa6 MERGED source code from development trunk revision 4545 up to latest current revision 4882
Development Trunk: https://ja2svn.dyndns.org/source/ja2/branches/Wanne/JA2%201.13%20MP
A detailed list of all the features (changes) is visible in the history log of the development trunk:

INFO: The source code for the official 2011 release (4870) has been branched here:
https://ja2svn.dyndns.org/source/ja2/branches/JA2_rev.4870_2011

This commit contains the following features:

*** Externalized Vehicles ***
o Now with this feature we can add/remove vehicles
o New XML File: TableData\Vehicles.xml
o Added a new function parameter to lua file Scripts\Overhead lua to set up the helicopter in method: SetUpHelicopterForPlayer()
o Added example mini (Docs\Externalized Vehicles Example.zip) mod which adds 2 additional vehicles (hummer and ice-cream truck to sector A9)

*** Up to 255 save slots ***
- There is a "Next" and "Prev" button where you can scroll through the save slots
- It is now possible to load the automatic save (SAVE_EVERY_N_HOURS) from the load screen. This is the first slot after the quickload slot
- Added the 2 alternate players end turn saves (which can be enabled/disabled in option screen) to the save/load game form

*** New Feature: Externalized emails from Emails.edt to XML***
o This feature can be enabled/disabled in the Source:
--> See email.cpp: If "ReadXMLEmail" == FALSE, then normal way (read from Email.edt) otherwise read from XML files
o 2 new XML files: TableData\Email\EmailMercAvailable.xml and EmailMercLevelUp.xml
o Renamed SenderNamesList.xml to EmailSenderNamesList.xml and moved from TableData folder to TableData\Email folder
o Names for mercenaries are get from the file MercProfiles.xml and different names get from the file EmailSenderNamesList.xml

*** Externalized Hidden Towns (Tixa, Orta) ***
o Now it is possible to add new hidden towns (locations)
o See file: TableData/Map/Cities.xml
o New variable in TableData/Map/Cities.xml
- hiddenTown:   0 = show on strategy map, 1 = Hide on strategy map
- townIcon:     1 = on, 0 = off (This is the icon you see on the strategy map)
- szIconFile:   The path to the sti icon file (eg: interface\prison.sti, interface\my_icon.sti)
- iconPosition: The x,y position of the icon on the strategy map

*** Encyclopedia and Briefing Room, reachable from the laptop ***
o 2 new ja2_options.ini properties: BRIEFING_ROOM, ENCYCLOPEDIA
o demonstration video: http://www.youtube.com/watch?v=7CIXdXWLrAo
o Added Example usage of the Briefing Room
- Extract it in your JA2 1.13 folder and use the latest development executable
- The briefing room can be reached from the laptop. Enter SN5631 for the code and then click the "Exit" button
- See "Info_BriefingRoom.txt" and "BriefingRoom_Mission1.png"

*** Improved interrupt system (IIS) ***
o This system changes the way interrupts work. See: http://www.ja-galaxy-forum.com/board/ubbthreads.php?ubb=showflat&Number=290787#Post290787
o Option system (see ja2_options.ini: IMPROVED_INTERRUPT_SYSTEM)
o A few more settings for the interrupt system in ja2_options.ini
o INFO: Multiplayer games always use the "old" interrupt system, not matter what the user selects in the ja2_options.ini

*** Walking and sidestepping with weapon raised ***
o Enable/disable the walking/sidestepping with raised weapon in ja2_options.ini: ALLOW_WALKING_WITH_WEAPON_RAISED
o You can set an AP/BP modifier when walking/sidestepping with weapon raised in APBPConstants.ini: AP_MODIFIER_WEAPON_READY
o The following feature apply when you walk/sidestep with weapon raised:
-> limited angle of view, but you can see more farther when the weapon has a scope
-> better change for interrupts if you see an enemy
-> less APs and BPs when shooting, because the weapon is already raised
-> It should cost more APs when walking. Maybe you can export the additional AP and BP modifier to the APBPConstants.ini

*** Increase squad size to 8 (800x600) and 8 and 10 (1024x768) ***
o Squad sizes (dependend on the screen resolution) can be selected in the start new game screen
o In a multiplayer game, the squad size will always be 6, because it does not work with more soldiers/squad

*** Added UB-1.13 source code ***
o Merged the UB-1.13 source code (Revision: 4721) from svn: http://subversion.assembla.com/svn/ub-source113
o If you want to build UB-EXE or UB-MapEditor, just enable the 2 defines (JA2UB and JA2UBMAPS) in "builddefines.h"
o The UB-Verion reads from "ja2_UB.ini" instead of "ja2.ini"
o There are 2 new XML files
- Layout\LayoutMainMenu.xml
- MapAction\ActionItems.xml
o There are 2 new LUA-Script files
- Scripts\ExplosionControl.lua
- Scripts\InterfaceDialogue.lua

*** Hide enemy health text / enemy hit count ***
o ja2_options.ini: HIDE_ENEMY_HEALTH_TEXT, HIDE_ENEMY_HIT_COUNT
o both new settings only have effect in a singleplayer game
o see: http://www.ja-galaxy-forum.com/board/ubbthreads.php?ubb=showflat&Number=128840&page=1


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4885 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2012-01-18 11:19:01 +00:00

1157 lines
25 KiB
C++

#ifdef PRECOMPILEDHEADERS
#include "Tactical All.h"
#else
#include "builddefines.h"
#include <stdio.h>
#include "Types.h"
#include "civ quotes.h"
#include "mousesystem.h"
#include "strategicmap.h"
#include "WCheck.h"
#include "FileMan.h"
#include "encrypted file.h"
#include "MessageBoxScreen.h"
#include "Queen Command.h"
#include "Overhead.h"
#include "render dirty.h"
#include "merctextbox.h"
#include "ai.h"
#include "Text.h"
#include "screenids.h"
#include "Animation Data.h"
#include "Video.h"
#include "Font Control.h"
#include "message.h"
#include "local.h"
#include "renderworld.h"
#include "Interface.h"
#include "cursors.h"
#include "Dialogue Control.h"
#include "Quests.h"
#include "Strategic Town Loyalty.h"
#include "NPC.h"
#include "Strategic Mines.h"
#include "Random.h"
#endif
#include "connect.h"
#define DIALOGUE_DEFAULT_WIDTH 200
#define EXTREAMLY_LOW_TOWN_LOYALTY 20
#define HIGH_TOWN_LOYALTY 80
#define CIV_QUOTE_HINT 99
extern void CaptureTimerCallback( void );
BOOLEAN gfSurrendered = FALSE;
//--------------------------------------------------------------
//Not used
typedef struct
{
UINT16 ubNumEntries;
UINT16 ubUnusedCurrentEntry; //Unused
} CIV_QUOTE;
CIV_QUOTE gCivQuotes[ NUM_CIV_QUOTES]; //Not used
UINT16 gubNumEntries[ NUM_CIV_QUOTES ] = // Not used
{
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
5,
5,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
2,
15,
15,
10,
10,
5,
3,
10,
3,
3,
3,
3,
3,
3,
3,
3,
3,
3
};
//--------------------------------------------------------------
typedef struct
{
BOOLEAN bActive;
MOUSE_REGION MouseRegion;
INT32 iVideoOverlay;
INT32 iDialogueBox;
UINT32 uiTimeOfCreation;
UINT32 uiDelayTime;
SOLDIERTYPE * pCiv;
} QUOTE_SYSTEM_STRUCT;
QUOTE_SYSTEM_STRUCT gCivQuoteData;
CHAR16 gzCivQuote[ 320 ];
UINT16 gusCivQuoteBoxWidth;
UINT16 gusCivQuoteBoxHeight;
//--------------------------------------------------------------
void CopyNumEntriesIntoQuoteStruct( ) // Not used
{
INT32 cnt;
for ( cnt = 0; cnt < NUM_CIV_QUOTES; cnt++ )
{
if (cnt <= 50)
gCivQuotes[ cnt ].ubNumEntries = gubNumEntries[ cnt ];
else
gCivQuotes[ cnt ].ubNumEntries = 15;
}
}
//--------------------------------------------------------------
BOOLEAN GetCivQuoteText(UINT16 ubCivQuoteID, UINT16 ubEntryID, STR16 zQuote )
{
CHAR8 zFileName[164];
// Build filename....
if ( ubCivQuoteID == CIV_QUOTE_HINT )
{
if ( gbWorldSectorZ > 0 )
{
//sprintf( zFileName, "NPCData\\miners.edt" );
sprintf( zFileName,"NPCDATA\\CIV%02d.edt", CIV_QUOTE_MINERS_NOT_FOR_PLAYER );
}
else
{
sprintf( zFileName, "NPCData\\%c%d.edt", 'A' + (gWorldSectorY - 1) , gWorldSectorX );
}
}
else
{
if (ubCivQuoteID <= 9)
sprintf( zFileName,"NPCDATA\\CIV%02d.edt",ubCivQuoteID );
else
sprintf( zFileName,"NPCDATA\\CIV%d.edt",ubCivQuoteID );
}
CHECKF( FileExists( zFileName ) );
// Get data...
LoadEncryptedDataFromFile( zFileName, zQuote, ubEntryID * 320, 320 );
if( zQuote[0] == 0 )
{
return( FALSE );
}
return( TRUE );
}
void SurrenderMessageBoxCallBack( UINT8 ubExitValue )
{
SOLDIERTYPE *pTeamSoldier;
INT32 cnt = 0;
if ( ubExitValue == MSG_BOX_RETURN_YES )
{
// CJC Dec 1 2002: fix multiple captures
BeginCaptureSquence();
// Do capture....
cnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID;
for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; cnt++,pTeamSoldier++)
{
// Are we active and in sector.....
if ( pTeamSoldier->bActive && pTeamSoldier->bInSector )
{
if ( pTeamSoldier->stats.bLife != 0 )
{
EnemyCapturesPlayerSoldier( pTeamSoldier );
RemoveSoldierFromTacticalSector( pTeamSoldier, TRUE );
}
}
}
EndCaptureSequence( );
gfSurrendered = TRUE;
SetCustomizableTimerCallbackAndDelay( 3000, CaptureTimerCallback, FALSE );
ActionDone( gCivQuoteData.pCiv );
}
else
{
ActionDone( gCivQuoteData.pCiv );
}
}
void ShutDownQuoteBox( BOOLEAN fForce )
{
if ( !gCivQuoteData.bActive )
{
return;
}
// Check for min time....
if ( ( GetJA2Clock( ) - gCivQuoteData.uiTimeOfCreation ) > 300 || fForce )
{
RemoveVideoOverlay( gCivQuoteData.iVideoOverlay );
// Remove mouse region...
MSYS_RemoveRegion( &(gCivQuoteData.MouseRegion) );
RemoveMercPopupBoxFromIndex( gCivQuoteData.iDialogueBox );
gCivQuoteData.iDialogueBox = -1;
gCivQuoteData.bActive = FALSE;
#ifdef JA2UB
// no UB
#else
// do we need to do anything at the end of the civ quote?
if ( gCivQuoteData.pCiv && gCivQuoteData.pCiv->aiData.bAction == AI_ACTION_OFFER_SURRENDER )
{
// Haydent
if(!is_networked)
{
DoMessageBox( MSG_BOX_BASIC_STYLE, Message[ STR_SURRENDER ], GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, SurrenderMessageBoxCallBack, NULL );
}
else
{
ScreenMsg( FONT_LTGREEN, MSG_MPSYSTEM, MPClientMessage[39] );
ActionDone( gCivQuoteData.pCiv );
}
}
#endif
}
}
BOOLEAN ShutDownQuoteBoxIfActive( )
{
if ( gCivQuoteData.bActive )
{
ShutDownQuoteBox( TRUE );
return( TRUE );
}
return( FALSE );
}
INT8 GetCivType( SOLDIERTYPE *pCiv )
{
if ( pCiv->ubProfile != NO_PROFILE )
{
return( CIV_TYPE_NA );
}
// ATE: Check if this person is married.....
// 1 ) check sector....
if ( gWorldSectorX == 10 && gWorldSectorY == 6 && gbWorldSectorZ == 0 )
{
// 2 ) the only female....
if ( pCiv->ubCivilianGroup == 0 && pCiv->bTeam != gbPlayerNum && pCiv->ubBodyType == REGFEMALE )
{
// She's a ho!
return( CIV_TYPE_MARRIED_PC );
}
}
// OK, look for enemy type - MUST be on enemy team, merc bodytype
if ( pCiv->bTeam == ENEMY_TEAM && IS_MERC_BODY_TYPE( pCiv ) )
{
return( CIV_TYPE_ENEMY );
}
if ( pCiv->bTeam != CIV_TEAM && pCiv->bTeam != MILITIA_TEAM )
{
return( CIV_TYPE_NA );
}
switch( pCiv->ubBodyType )
{
case REGMALE:
case BIGMALE:
case STOCKYMALE:
case REGFEMALE:
case FATCIV:
case MANCIV:
case MINICIV:
case DRESSCIV:
case CRIPPLECIV:
return( CIV_TYPE_ADULT );
break;
case ADULTFEMALEMONSTER:
case AM_MONSTER:
case YAF_MONSTER:
case YAM_MONSTER:
case LARVAE_MONSTER:
case INFANT_MONSTER:
case QUEENMONSTER:
return( CIV_TYPE_NA );
case HATKIDCIV:
case KIDCIV:
return( CIV_TYPE_KID );
default:
return( CIV_TYPE_NA );
}
//return( CIV_TYPE_NA ); // not needed when there is a default! (jonathanl)
}
void RenderCivQuoteBoxOverlay( VIDEO_OVERLAY *pBlitter )
{
if ( gCivQuoteData.iVideoOverlay != -1 )
{
RenderMercPopUpBoxFromIndex( gCivQuoteData.iDialogueBox, pBlitter->sX, pBlitter->sY, pBlitter->uiDestBuff );
InvalidateRegion( pBlitter->sX, pBlitter->sY, pBlitter->sX + gusCivQuoteBoxWidth, pBlitter->sY + gusCivQuoteBoxHeight );
}
}
void QuoteOverlayClickCallback( MOUSE_REGION * pRegion, INT32 iReason )
{
static BOOLEAN fLButtonDown = FALSE;
if (iReason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
{
fLButtonDown = TRUE;
}
if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP && fLButtonDown )
{
// Shutdown quote box....
ShutDownQuoteBox( FALSE );
}
else if (iReason & MSYS_CALLBACK_REASON_LOST_MOUSE )
{
fLButtonDown = FALSE;
}
}
void BeginCivQuote( SOLDIERTYPE *pCiv, UINT16 ubCivQuoteID, UINT16 ubEntryID, INT16 sX, INT16 sY )
{
VIDEO_OVERLAY_DESC VideoOverlayDesc;
CHAR16 zQuote[ 320 ];
// OK, do we have another on?
if ( gCivQuoteData.bActive )
{
// Delete?
ShutDownQuoteBox( TRUE );
}
// get text
if ( !GetCivQuoteText( ubCivQuoteID, ubEntryID, zQuote ) )
{
return;
}
#ifdef TAIWANESE
swprintf( gzCivQuote, L"%s", zQuote );
#else
swprintf( gzCivQuote, L"\"%s\"", zQuote );
#endif
if ( ubCivQuoteID == CIV_QUOTE_HINT )
{
MapScreenMessage( FONT_MCOLOR_WHITE, MSG_DIALOG, L"%s", gzCivQuote );
}
// Create video oeverlay....
memset( &VideoOverlayDesc, 0, sizeof( VIDEO_OVERLAY_DESC ) );
//never use it anymore
//SET_USE_WINFONTS( TRUE );
//SET_WINFONT( giSubTitleWinFont );
// Prepare text box
gCivQuoteData.iDialogueBox = PrepareMercPopupBox( gCivQuoteData.iDialogueBox , BASIC_MERC_POPUP_BACKGROUND, BASIC_MERC_POPUP_BORDER, gzCivQuote, DIALOGUE_DEFAULT_WIDTH, 0, 0, 0, &gusCivQuoteBoxWidth, &gusCivQuoteBoxHeight );
//SET_USE_WINFONTS( FALSE );
// OK, find center for box......
sX = sX - ( gusCivQuoteBoxWidth / 2 );
sY = sY - ( gusCivQuoteBoxHeight / 2 );
// OK, limit to screen......
{
if ( sX < 0 )
{
sX = 0;
}
// CHECK FOR LEFT/RIGHT
if ( ( sX + gusCivQuoteBoxWidth ) > SCREEN_WIDTH )
{
sX = SCREEN_WIDTH - gusCivQuoteBoxWidth;
}
// Now check for top
if ( sY < gsVIEWPORT_WINDOW_START_Y )
{
sY = gsVIEWPORT_WINDOW_START_Y;
}
// Check for bottom
if ( ( sY + gusCivQuoteBoxHeight ) > (SCREEN_HEIGHT - INV_INTERFACE_HEIGHT))
{
sY = (SCREEN_HEIGHT - INV_INTERFACE_HEIGHT) - gusCivQuoteBoxHeight;
}
}
VideoOverlayDesc.sLeft = sX;
VideoOverlayDesc.sTop = sY;
VideoOverlayDesc.sRight = VideoOverlayDesc.sLeft + gusCivQuoteBoxWidth;
VideoOverlayDesc.sBottom = VideoOverlayDesc.sTop + gusCivQuoteBoxHeight;
VideoOverlayDesc.sX = VideoOverlayDesc.sLeft;
VideoOverlayDesc.sY = VideoOverlayDesc.sTop;
VideoOverlayDesc.BltCallback = RenderCivQuoteBoxOverlay;
gCivQuoteData.iVideoOverlay = RegisterVideoOverlay( 0, &VideoOverlayDesc );
//Define main region
MSYS_DefineRegion( &(gCivQuoteData.MouseRegion), VideoOverlayDesc.sLeft, VideoOverlayDesc.sTop, VideoOverlayDesc.sRight, VideoOverlayDesc.sBottom, MSYS_PRIORITY_HIGHEST,
CURSOR_NORMAL, MSYS_NO_CALLBACK, QuoteOverlayClickCallback );
// Add region
MSYS_AddRegion( &(gCivQuoteData.MouseRegion) );
gCivQuoteData.bActive = TRUE;
gCivQuoteData.uiTimeOfCreation = GetJA2Clock( );
gCivQuoteData.uiDelayTime = FindDelayForString( gzCivQuote ) + 500;
gCivQuoteData.pCiv = pCiv;
}
UINT16 DetermineCivQuoteEntry( SOLDIERTYPE *pCiv, UINT16 *pubCivHintToUse, BOOLEAN fCanUseHints )
{
UINT8 ubCivType;
#ifdef JA2UB
#else
INT8 bTownId;
INT8 bCivHint;
INT8 bMineId;
#endif
BOOLEAN bCivLowLoyalty = FALSE;
BOOLEAN bCivHighLoyalty = FALSE;
BOOLEAN bMiners = FALSE;
UINT16 iCounter2;
UINT16 FileEDTQUoteID;
(*pubCivHintToUse) = 0;
ubCivType = GetCivType( pCiv );
for( iCounter2 = NON_CIV_GROUP; iCounter2 < NUM_CIV_GROUPS; iCounter2++ )
{
#ifdef JA2UB
if (pCiv->ubCivilianGroup > UNNAMED_CIV_GROUP_19 && pCiv->ubCivilianGroup == iCounter2)
#else
if (pCiv->ubCivilianGroup > QUEENS_CIV_GROUP && pCiv->ubCivilianGroup == iCounter2)
#endif
{
if ( pCiv->aiData.bNeutral )
{
return( FileEDTQUoteID = iCounter2*2 +10);
}
else
{
return( FileEDTQUoteID = iCounter2*2 + 11);
}
}
}
#ifdef JA2UB
if( ubCivType != CIV_TYPE_ENEMY )
{
//if the civ is not an enemy
if ( pCiv->aiData.bNeutral )
{
return( CIV_QUOTE__CIV_NOT_ENEMY ); //43
}
else
{
//
//the civ is an enemy
//
//if the civ can fight
if( pCiv->ubBodyType == REGMALE || pCiv->ubBodyType == REGFEMALE || pCiv->ubBodyType == BIGMALE )
{
return( CIV_QUOTE__CIV_ENEMY_CAN_FIGHT); //40
}
else if( pCiv->stats.bLife < pCiv->stats.bLifeMax )
{
return( CIV_QUOTE__CIV_HURT ); //42
}
else
{
return( CIV_QUOTE__CIV_ENEMY_GENERIC ); //41
}
}
}
if( ubCivType == CIV_TYPE_ENEMY )
{
// Determine what type of quote to say...
// Are are we going to attack?
if ( pCiv->aiData.bAction == AI_ACTION_TOSS_PROJECTILE || pCiv->aiData.bAction == AI_ACTION_FIRE_GUN ||
pCiv->aiData.bAction == AI_ACTION_FIRE_GUN || pCiv->aiData.bAction == AI_ACTION_KNIFE_MOVE )
{
return( CIV_QUOTE_ENEMY_THREAT );
}
// Hurt?
else if ( pCiv->stats.bLife < 30 )
{
return( CIV_QUOTE_ENEMY_HURT );
}
// elite?
else if ( pCiv->ubSoldierClass == SOLDIER_CLASS_ELITE )
{
return( CIV_QUOTE_ENEMY_ELITE );
}
else
{
return( CIV_QUOTE_ENEMY_ADMIN );
}
}
return( 255 );
#else
if ( ubCivType == CIV_TYPE_ENEMY )
{
// Determine what type of quote to say...
// Are are we going to attack?
if ( pCiv->aiData.bAction == AI_ACTION_TOSS_PROJECTILE || pCiv->aiData.bAction == AI_ACTION_FIRE_GUN ||
pCiv->aiData.bAction == AI_ACTION_FIRE_GUN || pCiv->aiData.bAction == AI_ACTION_KNIFE_MOVE )
{
return( CIV_QUOTE_ENEMY_THREAT );
}
else if ( pCiv->aiData.bAction == AI_ACTION_OFFER_SURRENDER )
{
return( CIV_QUOTE_ENEMY_OFFER_SURRENDER );
}
// Hurt?
else if ( pCiv->stats.bLife < 30 )
{
return( CIV_QUOTE_ENEMY_HURT );
}
// elite?
else if ( pCiv->ubSoldierClass == SOLDIER_CLASS_ELITE )
{
return( CIV_QUOTE_ENEMY_ELITE );
}
else
{
return( CIV_QUOTE_ENEMY_ADMIN );
}
}
// Are we in a town sector?
// get town id
bTownId = GetTownIdForSector( gWorldSectorX, gWorldSectorY );
// If a married PC...
if ( ubCivType == CIV_TYPE_MARRIED_PC )
{
return( CIV_QUOTE_PC_MARRIED );
}
// CIV GROUPS FIRST!
// Hicks.....
if ( pCiv->ubCivilianGroup == HICKS_CIV_GROUP )
{
// Are they friendly?
//if ( gTacticalStatus.fCivGroupHostile[ HICKS_CIV_GROUP ] < CIV_GROUP_WILL_BECOME_HOSTILE )
if ( pCiv->aiData.bNeutral )
{
return( CIV_QUOTE_HICKS_FRIENDLY );
}
else
{
return( CIV_QUOTE_HICKS_ENEMIES );
}
}
// Goons.....
if ( pCiv->ubCivilianGroup == KINGPIN_CIV_GROUP )
{
// Are they friendly?
//if ( gTacticalStatus.fCivGroupHostile[ KINGPIN_CIV_GROUP ] < CIV_GROUP_WILL_BECOME_HOSTILE )
if ( pCiv->aiData.bNeutral )
{
return( CIV_QUOTE_GOONS_FRIENDLY );
}
else
{
return( CIV_QUOTE_GOONS_ENEMIES );
}
}
// ATE: Cowering people take precedence....
if ( ( pCiv->flags.uiStatusFlags & SOLDIER_COWERING ) || ( pCiv->bTeam == CIV_TEAM && ( gTacticalStatus.uiFlags & INCOMBAT ) ) )
{
if ( ubCivType == CIV_TYPE_ADULT )
{
return( CIV_QUOTE_ADULTS_COWER );
}
else
{
return( CIV_QUOTE_KIDS_COWER );
}
}
// Kid slaves...
if ( pCiv->ubCivilianGroup == FACTORY_KIDS_GROUP )
{
// Check fact.....
if ( CheckFact( FACT_DOREEN_HAD_CHANGE_OF_HEART, 0 ) || !CheckFact( FACT_DOREEN_ALIVE, 0 ) )
{
return( CIV_QUOTE_KID_SLAVES_FREE );
}
else
{
return( CIV_QUOTE_KID_SLAVES );
}
}
// BEGGERS
if ( pCiv->ubCivilianGroup == BEGGARS_CIV_GROUP )
{
// Check if we are in a town...
if( bTownId != BLANK_SECTOR && gbWorldSectorZ == 0 )
{
if ( bTownId == SAN_MONA && ubCivType == CIV_TYPE_ADULT )
{
return( CIV_QUOTE_SAN_MONA_BEGGERS );
}
}
// DO normal beggers...
if ( ubCivType == CIV_TYPE_ADULT )
{
return( CIV_QUOTE_ADULTS_BEGGING );
}
else
{
return( CIV_QUOTE_KIDS_BEGGING );
}
}
// REBELS
if ( pCiv->ubCivilianGroup == REBEL_CIV_GROUP )
{
// DO normal beggers...
if ( ubCivType == CIV_TYPE_ADULT )
{
return( CIV_QUOTE_ADULTS_REBELS );
}
else
{
return( CIV_QUOTE_KIDS_REBELS );
}
}
// Do miltitia...
if ( pCiv->bTeam == MILITIA_TEAM )
{
// Different types....
if ( pCiv->ubSoldierClass == SOLDIER_CLASS_GREEN_MILITIA )
{
return( CIV_QUOTE_GREEN_MILITIA );
}
if ( pCiv->ubSoldierClass == SOLDIER_CLASS_REG_MILITIA )
{
return( CIV_QUOTE_MEDIUM_MILITIA );
}
if ( pCiv->ubSoldierClass == SOLDIER_CLASS_ELITE_MILITIA )
{
return( CIV_QUOTE_ELITE_MILITIA );
}
}
// If we are in medunna, and queen is dead, use these...
if ( bTownId == MEDUNA && CheckFact( FACT_QUEEN_DEAD, 0 ) )
{
return( CIV_QUOTE_DEIDRANNA_DEAD );
}
// if in a town
if( ( bTownId != BLANK_SECTOR ) && ( gbWorldSectorZ == 0 ) && gfTownUsesLoyalty[ bTownId ] )
{
// Check loyalty special quotes.....
// EXTREMELY LOW TOWN LOYALTY...
if ( gTownLoyalty[ bTownId ].ubRating < EXTREAMLY_LOW_TOWN_LOYALTY )
{
bCivLowLoyalty = TRUE;
}
// HIGH TOWN LOYALTY...
if ( gTownLoyalty[ bTownId ].ubRating >= HIGH_TOWN_LOYALTY )
{
bCivHighLoyalty = TRUE;
}
}
// ATE: OK, check if we should look for a civ hint....
if ( fCanUseHints )
{
bCivHint = ConsiderCivilianQuotes( gWorldSectorX, gWorldSectorY, gbWorldSectorZ, FALSE );
}
else
{
bCivHint = -1;
}
// ATE: check miners......
if ( pCiv->ubSoldierClass == SOLDIER_CLASS_MINER )
{
bMiners = TRUE;
// If not a civ hint available...
if ( bCivHint == -1 )
{
// Check if they are under our control...
// Should I go talk to miner?
// Not done yet.
// Are they working for us?
bMineId = GetIdOfMineForSector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ );
if ( PlayerControlsMine( bMineId ) )
{
return( CIV_QUOTE_MINERS_FOR_PLAYER );
}
else
{
return( CIV_QUOTE_MINERS_NOT_FOR_PLAYER );
}
}
}
// Is one availible?
// If we are to say low loyalty, do chance
if ( bCivHint != -1 && bCivLowLoyalty && !bMiners )
{
if ( Random( 100 ) < 25 )
{
// Get rid of hint...
bCivHint = -1;
}
}
// Say hint if availible...
if ( bCivHint != -1 )
{
if ( ubCivType == CIV_TYPE_ADULT )
{
(*pubCivHintToUse) = bCivHint;
// Set quote as used...
ConsiderCivilianQuotes( gWorldSectorX, gWorldSectorY, gbWorldSectorZ, TRUE );
// retrun value....
return( CIV_QUOTE_HINT );
}
}
if ( bCivLowLoyalty )
{
if ( ubCivType == CIV_TYPE_ADULT )
{
return( CIV_QUOTE_ADULTS_EXTREMLY_LOW_LOYALTY );
}
else
{
return( CIV_QUOTE_KIDS_EXTREMLY_LOW_LOYALTY );
}
}
if ( bCivHighLoyalty )
{
if ( ubCivType == CIV_TYPE_ADULT )
{
return( CIV_QUOTE_ADULTS_HIGH_LOYALTY );
}
else
{
return( CIV_QUOTE_KIDS_HIGH_LOYALTY );
}
}
// All purpose quote here....
if ( ubCivType == CIV_TYPE_ADULT )
{
return( CIV_QUOTE_ADULTS_ALL_PURPOSE );
}
else
{
return( CIV_QUOTE_KIDS_ALL_PURPOSE );
}
#endif
}
void HandleCivQuote( )
{
if ( gCivQuoteData.bActive )
{
// Check for min time....
if ( ( GetJA2Clock( ) - gCivQuoteData.uiTimeOfCreation ) > gCivQuoteData.uiDelayTime )
{
// Stop!
ShutDownQuoteBox( TRUE );
}
}
}
void StartCivQuote( SOLDIERTYPE *pCiv )
{
UINT16 ubCivQuoteID;
INT16 sX, sY;
UINT16 ubEntryID = 0;
INT16 sScreenX, sScreenY;
UINT16 ubCivHintToUse;
UINT16 CivQuoteDelta = 0;
UINT16 ubCivQuoteID2;
UINT16 RandomVal;
// ATE: Check for old quote.....
// This could have been stored on last attempt...
if ( pCiv->bCurrentCivQuote == CIV_QUOTE_HINT )
{
// Determine which quote to say.....
// CAN'T USE HINTS, since we just did one...
pCiv->bCurrentCivQuote = -1;
pCiv->bCurrentCivQuoteDelta = 0;
ubCivQuoteID = DetermineCivQuoteEntry( pCiv, &ubCivHintToUse, FALSE );
}
else
{
// Determine which quote to say.....
ubCivQuoteID = DetermineCivQuoteEntry( pCiv, &ubCivHintToUse, TRUE );
}
if (ubCivQuoteID == CIV_QUOTE_ADULTS_REBELS || ubCivQuoteID == CIV_QUOTE_KIDS_REBELS || ubCivQuoteID == CIV_QUOTE_ENEMY_OFFER_SURRENDER )
{
RandomVal = 5;
}
else if (ubCivQuoteID == CIV_QUOTE_PC_MARRIED)
{
RandomVal = 2;
}
else if (ubCivQuoteID == CIV_QUOTE_HICKS_SEE_US_AT_NIGHT)
{
RandomVal = 3;
}
else
RandomVal = 15;
#ifdef JA2UB
if( ubCivQuoteID == 255 )
{
return;
}
#endif
// Determine entry id
// ATE: Try and get entry from soldier pointer....
if ( ubCivQuoteID != CIV_QUOTE_HINT )
{
if ( pCiv->bCurrentCivQuote == -1 )
{
// Pick random one
//pCiv->bCurrentCivQuote = (INT8)Random( gCivQuotes[ ubCivQuoteID ].ubNumEntries - 2 );
ubCivQuoteID2 = Random(RandomVal-2);
pCiv->bCurrentCivQuoteDelta = 0;
}
//ubEntryID = pCiv->bCurrentCivQuote + pCiv->bCurrentCivQuoteDelta;
ubEntryID = ubCivQuoteID2 + pCiv->bCurrentCivQuoteDelta;
}
else
{
ubEntryID =ubCivHintToUse;
// ATE: set value for quote ID.....
//pCiv->bCurrentCivQuote = ubCivQuoteID;
ubCivQuoteID2 = ubCivQuoteID;
CivQuoteDelta = ubEntryID;
//pCiv->bCurrentCivQuoteDelta = ubEntryID;
}
// Determine location...
// Get location of civ on screen.....
GetSoldierScreenPos( pCiv, &sScreenX, &sScreenY );
sX = sScreenX;
sY = sScreenY;
// begin quote
BeginCivQuote( pCiv, ubCivQuoteID, ubEntryID, sX, sY );
// Increment use
if ( ubCivQuoteID != CIV_QUOTE_HINT )
{
//pCiv->bCurrentCivQuoteDelta++;
CivQuoteDelta++;
/*
if ( pCiv->bCurrentCivQuoteDelta == 2 )
{
pCiv->bCurrentCivQuoteDelta = 0;
}
*/
if ( CivQuoteDelta == 2 )
{
CivQuoteDelta = 0;
}
}
}
void InitCivQuoteSystem( )
{
memset( &gCivQuotes, 0, sizeof( gCivQuotes ) ); //Not used
memset( &gCivQuoteData, 0, sizeof( gCivQuoteData ) );
gCivQuoteData.bActive = FALSE;
gCivQuoteData.iVideoOverlay = -1;
gCivQuoteData.iDialogueBox = -1;
}
//--------------------------------------------------------------
//is allowed remove. Not used and remove from SaveLoadGame.cpp.
BOOLEAN SaveCivQuotesToSaveGameFile( HWFILE hFile )
{
UINT32 uiNumBytesWritten;
FileWrite( hFile, &gCivQuotes, sizeof( gCivQuotes), &uiNumBytesWritten );
if( uiNumBytesWritten != sizeof( gCivQuotes ) )
{
return( FALSE );
}
return( TRUE );
}
//is allowed remove. Not used and remove from SaveLoadGame.cpp.
BOOLEAN LoadCivQuotesFromLoadGameFile( HWFILE hFile )
{
UINT32 uiNumBytesRead;
FileRead( hFile, &gCivQuotes, sizeof( gCivQuotes ), &uiNumBytesRead );
if( uiNumBytesRead != sizeof( gCivQuotes ) )
{
return( FALSE );
}
CopyNumEntriesIntoQuoteStruct( ); //Not used
return( TRUE );
}
//--------------------------------------------------------------
// SANDRO - soldier taunts
void StartEnemyTaunt( SOLDIERTYPE *pCiv, INT8 iTauntType )
{
INT16 sX, sY;
UINT8 ubEntryID = 0;
INT16 sScreenX, sScreenY;
UINT16 iTauntNumber;
STR16 sTauntText;
VIDEO_OVERLAY_DESC VideoOverlayDesc;
CHAR16 gzTauntQuote[ 320 ];
// if we have a different quote on, return, this one is not important
if ( gCivQuoteData.bActive )
{
return;
}
switch(iTauntType)
{
case TAUNT_FIRE_GUN:
iTauntNumber = Random(15);
sTauntText = sEnemyTauntsFireGun[iTauntNumber];
break;
case TAUNT_FIRE_LAUNCHER:
iTauntNumber = Random(4);
sTauntText = sEnemyTauntsFireLauncher[iTauntNumber];
break;
case TAUNT_THROW:
iTauntNumber = Random(7);
sTauntText = sEnemyTauntsThrow[iTauntNumber];
break;
case TAUNT_CHARGE_KNIFE:
iTauntNumber = Random(5);
sTauntText = sEnemyTauntsChargeKnife[iTauntNumber];
break;
case TAUNT_RUN_AWAY:
iTauntNumber = Random(7);
sTauntText = sEnemyTauntsRunAway[iTauntNumber];
break;
case TAUNT_SEEK_NOISE:
iTauntNumber = Random(4);
sTauntText = sEnemyTauntsSeekNoise[iTauntNumber];
break;
case TAUNT_ALERT:
iTauntNumber = Random(3);
sTauntText = sEnemyTauntsAlert[iTauntNumber];
break;
case TAUNT_GOT_HIT:
iTauntNumber = Random(7);
sTauntText = sEnemyTauntsGotHit[iTauntNumber];
break;
default:
return;
break;
}
// Determine location...
// Get location of civ on screen.....
GetSoldierScreenPos( pCiv, &sScreenX, &sScreenY );
sX = sScreenX;
sY = sScreenY;
#ifdef TAIWANESE
swprintf( gzTauntQuote, L"%s", sTauntText );
#else
swprintf( gzTauntQuote, L"\"%s\"", sTauntText );
#endif
// Create video oeverlay....
memset( &VideoOverlayDesc, 0, sizeof( VIDEO_OVERLAY_DESC ) );
// Prepare text box
gCivQuoteData.iDialogueBox = PrepareMercPopupBox( gCivQuoteData.iDialogueBox , BASIC_MERC_POPUP_BACKGROUND, BASIC_MERC_POPUP_BORDER, gzTauntQuote, DIALOGUE_DEFAULT_WIDTH, 0, 0, 0, &gusCivQuoteBoxWidth, &gusCivQuoteBoxHeight );
// OK, find center for box......
sX = sX - ( gusCivQuoteBoxWidth / 2 );
sY = sY - ( gusCivQuoteBoxHeight / 2 );
// OK, limit to screen......
{
if ( sX < 0 )
{
sX = 0;
}
// CHECK FOR LEFT/RIGHT
if ( ( sX + gusCivQuoteBoxWidth ) > SCREEN_WIDTH )
{
sX = SCREEN_WIDTH - gusCivQuoteBoxWidth;
}
// Now check for top
if ( sY < gsVIEWPORT_WINDOW_START_Y )
{
sY = gsVIEWPORT_WINDOW_START_Y;
}
// Check for bottom
if ( ( sY + gusCivQuoteBoxHeight ) > (SCREEN_HEIGHT - INV_INTERFACE_HEIGHT))
{
sY = (SCREEN_HEIGHT - INV_INTERFACE_HEIGHT) - gusCivQuoteBoxHeight;
}
}
VideoOverlayDesc.sLeft = sX;
VideoOverlayDesc.sTop = sY;
VideoOverlayDesc.sRight = VideoOverlayDesc.sLeft + gusCivQuoteBoxWidth;
VideoOverlayDesc.sBottom = VideoOverlayDesc.sTop + gusCivQuoteBoxHeight;
VideoOverlayDesc.sX = VideoOverlayDesc.sLeft;
VideoOverlayDesc.sY = VideoOverlayDesc.sTop;
VideoOverlayDesc.BltCallback = RenderCivQuoteBoxOverlay;
gCivQuoteData.iVideoOverlay = RegisterVideoOverlay( 0, &VideoOverlayDesc );
//Define main region
MSYS_DefineRegion( &(gCivQuoteData.MouseRegion), VideoOverlayDesc.sLeft, VideoOverlayDesc.sTop, VideoOverlayDesc.sRight, VideoOverlayDesc.sBottom, MSYS_PRIORITY_HIGHEST,
CURSOR_NORMAL, MSYS_NO_CALLBACK, QuoteOverlayClickCallback );
// Add region
MSYS_AddRegion( &(gCivQuoteData.MouseRegion) );
gCivQuoteData.bActive = TRUE;
gCivQuoteData.uiTimeOfCreation = GetJA2Clock( );
gCivQuoteData.uiDelayTime = FindDelayForString( gzCivQuote ) + 1500;
gCivQuoteData.pCiv = pCiv;
}