mirror of
https://github.com/1dot13/source.git
synced 2026-08-19 14:20:30 +02:00
New feature: additional dialogue allows modders to play additional dialogue on man occasions, including reactions to other people speaking
For more info, see http://thepit.ja-galaxy-forum.com/index.php?t=tree&goto=351982&#msg_351982 and for a demonstration http://thepit.ja-galaxy-forum.com/index.php?t=tree&goto=351981&#msg_351981 Requires GameDir >= r2400 git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8516 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -869,6 +869,9 @@ static int l_GetSamSiteHackStatus( lua_State *L );
|
||||
static int l_SetMiniGameType( lua_State *L );
|
||||
static int l_SoldierSpendMoney( lua_State *L );
|
||||
|
||||
static int l_SetAdditionalDialogue( lua_State *L );
|
||||
static int l_PlaySound( lua_State *L );
|
||||
|
||||
using namespace std;
|
||||
|
||||
UINT16 idProfil;
|
||||
@@ -1744,6 +1747,9 @@ void IniFunction(lua_State *L, BOOLEAN bQuests )
|
||||
|
||||
lua_register( L, "SetMiniGameType", l_SetMiniGameType );
|
||||
lua_register( L, "SoldierSpendMoney", l_SoldierSpendMoney );
|
||||
|
||||
lua_register( L, "SetAdditionalDialogue", l_SetAdditionalDialogue );
|
||||
lua_register( L, "PlaySound", l_PlaySound );
|
||||
}
|
||||
#ifdef NEWMUSIC
|
||||
BOOLEAN LetLuaMusicControl(UINT8 Init)
|
||||
@@ -7208,6 +7214,9 @@ static int l_ACTION_ITEM_SEX (lua_State *L)
|
||||
DoorCloser[0]->data.misc.bActionValue = ACTION_ITEM_CLOSE_DOOR;
|
||||
PerformItemAction( sDoorSpot, &DoorCloser );
|
||||
|
||||
// Flugente: additional dialogue
|
||||
AdditionalTacticalCharacterDialogue_CallsLua( MercPtrs[ubID], ADE_SEX );
|
||||
|
||||
// have sex
|
||||
HandleNPCDoAction( 0, NPC_ACTION_SEX, 0 );
|
||||
|
||||
@@ -10574,7 +10583,6 @@ static int l_CheckCharacterSectorX (lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
//SetPendingNewScreen( SEX_SCREEN );
|
||||
static int l_SetPendingNewScreenSEXSCREEN (lua_State *L)
|
||||
{
|
||||
UINT8 n = lua_gettop(L);
|
||||
@@ -13360,3 +13368,67 @@ static int l_SoldierSpendMoney( lua_State *L )
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern BOOLEAN LuaCallsToDoDialogueStuff( UINT8 ubProfile, INT32 iFaceIndex, const char* azSoundString );
|
||||
|
||||
extern void SetQuoteStr( STR16 aStr );
|
||||
|
||||
static int l_SetAdditionalDialogue( lua_State *L )
|
||||
{
|
||||
if ( lua_gettop( L ) >= 4 )
|
||||
{
|
||||
UINT8 profile = lua_tointeger( L, 1 );
|
||||
INT32 faceindex = lua_tointeger( L, 2 );
|
||||
|
||||
size_t len = 0;
|
||||
const char* str = lua_tolstring( L, 3, &len );
|
||||
|
||||
{
|
||||
size_t len = 0;
|
||||
const char* str = lua_tolstring( L, 4, &len );
|
||||
|
||||
CHAR16 quote_str[1000];
|
||||
|
||||
MultiByteToWideChar( CP_UTF8, 0, str, -1, quote_str, sizeof( quote_str ) / sizeof( quote_str[0] ) );
|
||||
quote_str[sizeof( quote_str ) / sizeof( quote_str[0] ) - 1] = '\0';
|
||||
|
||||
SetQuoteStr( quote_str );
|
||||
}
|
||||
|
||||
LuaCallsToDoDialogueStuff( profile, faceindex, str );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_PlaySound( lua_State *L )
|
||||
{
|
||||
if ( lua_gettop( L ) >= 1 )
|
||||
{
|
||||
size_t len = 0;
|
||||
const char* str = lua_tolstring( L, 1, &len );
|
||||
|
||||
UINT32 volume = min( lua_tointeger( L, 2 ), HIGHVOLUME );
|
||||
if ( !volume )
|
||||
volume = MIDVOLUME;
|
||||
|
||||
PlayJA2SampleFromFile( (char*)str, RATE_11025, volume, 1, MIDDLEPAN );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LuaHandleAdditionalDialogue( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 ubProfile, INT32 iFaceIndex, UINT16 usEventNr, UINT32 aData1, UINT32 aData2, UINT32 aData3 )
|
||||
{
|
||||
const char* filename = "scripts\\Overhead.lua";
|
||||
|
||||
LuaScopeState _LS( true );
|
||||
|
||||
lua_register( _LS.L(), "CheckFact", l_CheckFact );
|
||||
IniFunction( _LS.L(), TRUE );
|
||||
IniGlobalGameSetting( _LS.L() );
|
||||
|
||||
SGP_THROW_IFFALSE( _LS.L.EvalFile( filename ), _BS( "Cannot open file: " ) << filename << _BS::cget );
|
||||
|
||||
LuaFunction( _LS.L, "HandleAdditionalDialogue" ).Param<int>( sSectorX ).Param<int>( sSectorY ).Param<int>( bSectorZ ).Param<int>( ubProfile ).Param<int>( iFaceIndex ).Param<int>( usEventNr ).Param<int>( aData1 ).Param<int>( aData2 ).Param<int>( aData3 ).Call( 9 );
|
||||
}
|
||||
|
||||
@@ -91,4 +91,6 @@ extern BOOLEAN LuaIntro(UINT8 Init, UINT32 uiCurrentVideo, INT8 bIntroType, UINT
|
||||
extern BOOLEAN LuaIDScripts(UINT8 Init, UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum);
|
||||
|
||||
extern BOOLEAN LetLuaMusicControl(UINT8 Init);
|
||||
|
||||
void LuaHandleAdditionalDialogue( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 ubProfile, INT32 iFaceIndex, UINT16 usEventNr, UINT32 aData1, UINT32 aData2, UINT32 aData3 );
|
||||
#endif
|
||||
|
||||
+40
-26
@@ -2106,43 +2106,57 @@ void HandleRPCDescriptionOfSector( INT16 sSectorX, INT16 sSectorY, INT16 sSector
|
||||
|
||||
// Default to false
|
||||
gTacticalStatus.fCountingDownForGuideDescription = FALSE;
|
||||
|
||||
|
||||
|
||||
// OK, if the first time in...
|
||||
if ( GetSectorFlagStatus( sSectorX, sSectorY, (UINT8)sSectorZ, SF_HAVE_USED_GUIDE_QUOTE ) != TRUE )
|
||||
{
|
||||
if ( sSectorZ != 0 )
|
||||
// guide quotes only happen on the surface
|
||||
if ( sSectorZ == 0 )
|
||||
{
|
||||
return;
|
||||
// OK, check if we are in a good sector....
|
||||
for ( cnt = 0; cnt < 33; ++cnt )
|
||||
{
|
||||
if ( sSectorX == ubSectorDescription[cnt][1] && sSectorY == ubSectorDescription[cnt][0] )
|
||||
{
|
||||
if ( cnt == 3 && ( gGameOptions.ubGameStyle == STYLE_REALISTIC || !gGameExternalOptions.fEnableCrepitus ) )
|
||||
continue;
|
||||
|
||||
/*
|
||||
// If we're not scifi, skip some
|
||||
if ( !(gGameOptions.ubGameStyle == STYLE_SCIFI && gGameExternalOptions.fEnableCrepitus) && cnt == 3 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
|
||||
gTacticalStatus.fCountingDownForGuideDescription = TRUE;
|
||||
gTacticalStatus.bGuideDescriptionCountDown = (INT8)( 4 + Random( 5 ) ); // 4 to 8 tactical turns...
|
||||
gTacticalStatus.ubGuideDescriptionToUse = ubSectorDescription[cnt][2];
|
||||
gTacticalStatus.bGuideDescriptionSectorX = (INT8)sSectorX;
|
||||
gTacticalStatus.bGuideDescriptionSectorY = (INT8)sSectorY;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// OK, check if we are in a good sector....
|
||||
for ( cnt = 0; cnt < 33; cnt++ )
|
||||
// Flugente: We abuse this mechanic to also set up lua-based comments. We only play those if there are no normal comments
|
||||
if ( !gTacticalStatus.fCountingDownForGuideDescription )
|
||||
{
|
||||
if ( sSectorX == ubSectorDescription[cnt][1] && sSectorY == ubSectorDescription[cnt][0] )
|
||||
{
|
||||
if ( (gGameOptions.ubGameStyle == STYLE_REALISTIC || !gGameExternalOptions.fEnableCrepitus) && cnt == 3 )
|
||||
continue;
|
||||
gTacticalStatus.fCountingDownForGuideDescription = TRUE;
|
||||
gTacticalStatus.bGuideDescriptionCountDown = (INT8)( 2 + Random( 3 ) );
|
||||
|
||||
/*
|
||||
// If we're not scifi, skip some
|
||||
if ( !(gGameOptions.ubGameStyle == STYLE_SCIFI && gGameExternalOptions.fEnableCrepitus) && cnt == 3 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
|
||||
SetSectorFlag( sSectorX, sSectorY, (UINT8)sSectorZ, SF_HAVE_USED_GUIDE_QUOTE );
|
||||
|
||||
gTacticalStatus.fCountingDownForGuideDescription = TRUE;
|
||||
gTacticalStatus.bGuideDescriptionCountDown = (INT8)(4 + Random( 5 )); // 4 to 8 tactical turns...
|
||||
gTacticalStatus.ubGuideDescriptionToUse = ubSectorDescription[cnt][2];
|
||||
gTacticalStatus.bGuideDescriptionSectorX = (INT8)sSectorX;
|
||||
gTacticalStatus.bGuideDescriptionSectorY = (INT8)sSectorY;
|
||||
}
|
||||
// this value isn't used for the normal guide quotes - this way we know this is meant for lua only
|
||||
gTacticalStatus.ubGuideDescriptionToUse = 100;
|
||||
|
||||
gTacticalStatus.bGuideDescriptionSectorX = (INT8)sSectorX;
|
||||
gTacticalStatus.bGuideDescriptionSectorY = (INT8)sSectorY;
|
||||
}
|
||||
}
|
||||
|
||||
// Flugente: set this flag in any case
|
||||
SetSectorFlag( sSectorX, sSectorY, (UINT8)sSectorZ, SF_HAVE_USED_GUIDE_QUOTE );
|
||||
|
||||
// Handle guide description ( will be needed if a SAM one )
|
||||
#ifdef JA2UB
|
||||
//UB
|
||||
|
||||
Reference in New Issue
Block a user