- Lua function HandleSectorLiberation(...) is called whenever we liberate a sector

- Lua function RecruitRPCAdditionalHandling(...) is called whenever we recruit a RPC

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7880 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2015-05-31 15:13:21 +00:00
parent 5c107cee7e
commit 7c69e12df8
4 changed files with 64 additions and 7 deletions
+51 -2
View File
@@ -839,6 +839,8 @@ static int l_ProfilesStrategicInsertionData (lua_State *L);
static int l_ResetBoxers( lua_State *L ); static int l_ResetBoxers( lua_State *L );
static int l_AddVolunteers( lua_State *L );
using namespace std; using namespace std;
UINT16 idProfil; UINT16 idProfil;
@@ -1686,7 +1688,8 @@ void IniFunction(lua_State *L, BOOLEAN bQuests )
lua_register(L,"EnvBeginRainStorm", l_EnvBeginRainStorm); lua_register(L,"EnvBeginRainStorm", l_EnvBeginRainStorm);
lua_register(L,"EnvEndRainStorm", l_EnvEndRainStorm); lua_register(L,"EnvEndRainStorm", l_EnvEndRainStorm);
lua_register( L, "AddVolunteers", l_AddVolunteers );
} }
#ifdef NEWMUSIC #ifdef NEWMUSIC
BOOLEAN LetLuaMusicControl(UINT8 Init) BOOLEAN LetLuaMusicControl(UINT8 Init)
@@ -2592,6 +2595,38 @@ BOOLEAN LuaHandleQuestCodeOnSector( INT16 sSectorX, INT16 sSectorY, INT8 bSector
return true; return true;
} }
void LuaHandleSectorLiberation( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, BOOLEAN fFirstTime )
{
const char* filename = "scripts\\strategicmap.lua";
LuaScopeState _LS( true );
lua_register( _LS.L( ), "CheckFact", l_CheckFact );
lua_register( _LS.L( ), "AddVolunteers", l_AddVolunteers );
IniFunction( _LS.L( ), TRUE );
IniGlobalGameSetting( _LS.L( ) );
SGP_THROW_IFFALSE( _LS.L.EvalFile( filename ), _BS( "Cannot open file: " ) << filename << _BS::cget );
LuaFunction( _LS.L, "HandleSectorLiberation" ).Param<int>( sSectorX ).Param<int>( sSectorY ).Param<int>( bSectorZ ).Param<bool>( fFirstTime ).Call( 4 );
}
void LuaRecruitRPCAdditionalHandling( UINT8 usProfile )
{
const char* filename = "scripts\\strategicmap.lua";
LuaScopeState _LS( true );
lua_register( _LS.L( ), "CheckFact", l_CheckFact );
lua_register( _LS.L( ), "AddVolunteers", l_AddVolunteers );
IniFunction( _LS.L( ), TRUE );
IniGlobalGameSetting( _LS.L( ) );
SGP_THROW_IFFALSE( _LS.L.EvalFile( filename ), _BS( "Cannot open file: " ) << filename << _BS::cget );
LuaFunction( _LS.L, "RecruitRPCAdditionalHandling" ).Param<int>( usProfile ).Call( 1 );
}
BOOLEAN LetLuaGameInit(UINT8 Init) BOOLEAN LetLuaGameInit(UINT8 Init)
{ {
const char* filename = "scripts\\GameInit.lua"; const char* filename = "scripts\\GameInit.lua";
@@ -12919,4 +12954,18 @@ static int l_SetStartingCashDifLevel (lua_State *L)
} }
return 0; return 0;
} }
// add volunteers
static int l_AddVolunteers( lua_State *L )
{
if ( lua_gettop( L ) )
{
FLOAT num = lua_tointeger( L, 1 );
AddVolunteers( num );
}
return 0;
}
+4
View File
@@ -58,6 +58,10 @@ extern BOOLEAN LuaHandleNPCTeamMemberDeath(UINT8 ProfileId, UINT8 Init);
extern BOOLEAN LuaCheckForKingpinsMoneyMissing( BOOLEAN fFirstCheck, UINT8 Init); extern BOOLEAN LuaCheckForKingpinsMoneyMissing( BOOLEAN fFirstCheck, UINT8 Init);
extern BOOLEAN LuaHandleQuestCodeOnSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 Init); extern BOOLEAN LuaHandleQuestCodeOnSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 Init);
//extern BOOLEAN LuaHandleQuestCodeOnSectorEntry( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 Init); //extern BOOLEAN LuaHandleQuestCodeOnSectorEntry( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 Init);
void LuaHandleSectorLiberation( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, BOOLEAN fFirstTime );
void LuaRecruitRPCAdditionalHandling( UINT8 usProfile );
extern BOOLEAN LuaHandleDelayedItemsArrival( UINT32 uiReason, UINT8 Init); extern BOOLEAN LuaHandleDelayedItemsArrival( UINT32 uiReason, UINT8 Init);
extern BOOLEAN LetLuaHandleNPCSystemEvent( UINT32 uiEvent, UINT8 Init); extern BOOLEAN LetLuaHandleNPCSystemEvent( UINT32 uiEvent, UINT8 Init);
+4 -5
View File
@@ -29,6 +29,7 @@
#include "PopUpBox.h" #include "PopUpBox.h"
#include "CampaignStats.h" // added by Flugente #include "CampaignStats.h" // added by Flugente
#include "Town Militia.h" // added by Flugente #include "Town Militia.h" // added by Flugente
#include "LuaInitNPCs.h" // added by Flugente
#endif #endif
#include "postalservice.h" #include "postalservice.h"
@@ -387,11 +388,6 @@ BOOLEAN SetThisSectorAsPlayerControlled( INT16 sMapX, INT16 sMapY, INT8 bMapZ, B
// Flugente: campaign stats // Flugente: campaign stats
if ( !SectorInfo[ SECTOR( sMapX, sMapY ) ].fSurfaceWasEverPlayerControlled ) if ( !SectorInfo[ SECTOR( sMapX, sMapY ) ].fSurfaceWasEverPlayerControlled )
{ {
//UINT8 ubSector = (UINT8)SECTOR( sMapX, sMapY );
//UINT8 ubTraverseType = SectorInfo[ ubSector ].ubTraversability[ 4 ];
//if ( ubTraverseType == )
UINT8 townid = GetTownIdForSector( sMapX, sMapY ); UINT8 townid = GetTownIdForSector( sMapX, sMapY );
if ( townid != BLANK_SECTOR ) if ( townid != BLANK_SECTOR )
{ {
@@ -407,6 +403,9 @@ BOOLEAN SetThisSectorAsPlayerControlled( INT16 sMapX, INT16 sMapY, INT8 bMapZ, B
} }
} }
// Flugente: if we take the surface sector for the first time, script-defined actions might happen
LuaHandleSectorLiberation( sMapX, sMapY, bMapZ, !SectorInfo[SECTOR( sMapX, sMapY )].fSurfaceWasEverPlayerControlled );
if ( bMapZ == 0 ) if ( bMapZ == 0 )
{ {
SectorInfo[ SECTOR( sMapX, sMapY ) ].fSurfaceWasEverPlayerControlled = TRUE; SectorInfo[ SECTOR( sMapX, sMapY ) ].fSurfaceWasEverPlayerControlled = TRUE;
+5
View File
@@ -51,6 +51,7 @@
#include "strategicmap.h" // added by SANDRO #include "strategicmap.h" // added by SANDRO
#include "drugs and alcohol.h" // added by Flugente #include "drugs and alcohol.h" // added by Flugente
#include "Campaign.h" #include "Campaign.h"
#include "LuaInitNPCs.h" // added by Flugente
#endif #endif
#include "aim.h" #include "aim.h"
@@ -1984,6 +1985,10 @@ BOOLEAN RecruitRPC( UINT8 ubCharNum )
//If this is a special NPC, play a quote from the team mates //If this is a special NPC, play a quote from the team mates
HandlePlayingQuoteWhenHiringNpc( pNewSoldier->ubProfile ); HandlePlayingQuoteWhenHiringNpc( pNewSoldier->ubProfile );
#endif #endif
// Flugente: external scripts might have extra functionality on recruiting someone
LuaRecruitRPCAdditionalHandling( ubCharNum );
return( TRUE ); return( TRUE );
} }