mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
- 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:
@@ -839,6 +839,8 @@ static int l_ProfilesStrategicInsertionData (lua_State *L);
|
||||
|
||||
static int l_ResetBoxers( lua_State *L );
|
||||
|
||||
static int l_AddVolunteers( lua_State *L );
|
||||
|
||||
using namespace std;
|
||||
|
||||
UINT16 idProfil;
|
||||
@@ -1686,7 +1688,8 @@ void IniFunction(lua_State *L, BOOLEAN bQuests )
|
||||
|
||||
lua_register(L,"EnvBeginRainStorm", l_EnvBeginRainStorm);
|
||||
lua_register(L,"EnvEndRainStorm", l_EnvEndRainStorm);
|
||||
|
||||
|
||||
lua_register( L, "AddVolunteers", l_AddVolunteers );
|
||||
}
|
||||
#ifdef NEWMUSIC
|
||||
BOOLEAN LetLuaMusicControl(UINT8 Init)
|
||||
@@ -2592,6 +2595,38 @@ BOOLEAN LuaHandleQuestCodeOnSector( INT16 sSectorX, INT16 sSectorY, INT8 bSector
|
||||
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)
|
||||
{
|
||||
const char* filename = "scripts\\GameInit.lua";
|
||||
@@ -12919,4 +12954,18 @@ static int l_SetStartingCashDifLevel (lua_State *L)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,10 @@ extern BOOLEAN LuaHandleNPCTeamMemberDeath(UINT8 ProfileId, UINT8 Init);
|
||||
extern BOOLEAN LuaCheckForKingpinsMoneyMissing( BOOLEAN fFirstCheck, UINT8 Init);
|
||||
extern BOOLEAN LuaHandleQuestCodeOnSector( 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 LetLuaHandleNPCSystemEvent( UINT32 uiEvent, UINT8 Init);
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "PopUpBox.h"
|
||||
#include "CampaignStats.h" // added by Flugente
|
||||
#include "Town Militia.h" // added by Flugente
|
||||
#include "LuaInitNPCs.h" // added by Flugente
|
||||
#endif
|
||||
|
||||
#include "postalservice.h"
|
||||
@@ -387,11 +388,6 @@ BOOLEAN SetThisSectorAsPlayerControlled( INT16 sMapX, INT16 sMapY, INT8 bMapZ, B
|
||||
// Flugente: campaign stats
|
||||
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 );
|
||||
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 )
|
||||
{
|
||||
SectorInfo[ SECTOR( sMapX, sMapY ) ].fSurfaceWasEverPlayerControlled = TRUE;
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include "strategicmap.h" // added by SANDRO
|
||||
#include "drugs and alcohol.h" // added by Flugente
|
||||
#include "Campaign.h"
|
||||
#include "LuaInitNPCs.h" // added by Flugente
|
||||
#endif
|
||||
|
||||
#include "aim.h"
|
||||
@@ -1984,6 +1985,10 @@ BOOLEAN RecruitRPC( UINT8 ubCharNum )
|
||||
//If this is a special NPC, play a quote from the team mates
|
||||
HandlePlayingQuoteWhenHiringNpc( pNewSoldier->ubProfile );
|
||||
#endif
|
||||
|
||||
// Flugente: external scripts might have extra functionality on recruiting someone
|
||||
LuaRecruitRPCAdditionalHandling( ubCharNum );
|
||||
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user