Mapbase VScript server/client expansions

This commit is contained in:
Blixibon
2020-05-22 20:26:31 -05:00
parent 2dbaa2c4a6
commit 4320ae71e7
44 changed files with 2252 additions and 3 deletions

View File

@@ -386,6 +386,44 @@ CAI_Schedule *CAI_BaseNPC::GetScheduleOfType( int scheduleType )
scheduleType = TranslateSchedule( scheduleType );
AI_PROFILE_SCOPE_END();
#ifdef MAPBASE_VSCRIPT
if ( m_ScriptScope.IsInitialized() )
{
// Some of this code should know if there's a function first, so look
// up the function beforehand instead of using CallScriptFunction()
HSCRIPT hFunc = m_ScriptScope.LookupFunction( "NPC_TranslateSchedule" );
if (hFunc)
{
int newSchedule = scheduleType;
if ( AI_IdIsLocal( newSchedule ) )
{
newSchedule = GetClassScheduleIdSpace()->ScheduleLocalToGlobal(newSchedule);
}
g_pScriptVM->SetValue( "schedule", GetSchedulingSymbols()->ScheduleIdToSymbol( newSchedule ) );
g_pScriptVM->SetValue( "schedule_id", newSchedule );
ScriptVariant_t functionReturn;
m_ScriptScope.Call( hFunc, &functionReturn );
if (functionReturn.m_type == FIELD_INTEGER)
{
newSchedule = functionReturn.m_int;
}
else
{
newSchedule = GetScheduleID( functionReturn.m_pszString );
}
if (newSchedule != scheduleType && newSchedule > -1)
scheduleType = newSchedule;
g_pScriptVM->ClearValue( "schedule" );
g_pScriptVM->ClearValue( "schedule_id" );
}
}
#endif
// Get a pointer to that schedule
CAI_Schedule *schedule = GetSchedule(scheduleType);