- 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_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;
}