Example #1
0
///////////////////////////////////////////////////////////////////////////////
// RunProcedure
//		Use this function to run a "Procedure" or "Function" - with arguments
///////////////////////////////////////////////////////////////////////////////
bool CScriptObject::RunProcedure(LPCTSTR szProcName, SAFEARRAY** saParameters, VARIANT* varRet)
{
	// required argument
	ASSERT( saParameters != NULL);
	ASSERT( varRet  != NULL);

	try {
		if (m_pScript != NULL)
		{
			ULONG ref = m_pScript->AddRef();
			bool  bResult = false;
			_bstr_t szFunc  = GetScriptFunction(szProcName);
			if (szFunc.length() > 0)
			{
				*varRet = m_pScript->Run(szFunc, saParameters);
				bResult = true;
			} 
			ref = m_pScript->Release();
			return bResult;
		}
	}
	catch(...)
	{
		// Just catch the exception, call GetErrorString()
		// to retreive last error
		ULONG ref = m_pScript->Release();
	}
	return false;
}
bool ScriptEngine::RunProcedure(LPCTSTR szProcName, SAFEARRAY** saParameters, VARIANT* varRet)
{
	// required argument
	//ASSERT(saParameters != NULL);
	//ASSERT(varRet != NULL);

	try {
		if (_ptr != NULL)
		{
			ULONG ref = _ptr->AddRef();
			bool  bResult = false;
			_bstr_t szFunc = GetScriptFunction(szProcName);
			if (szFunc.length() > 0)
			{
				*varRet = _ptr->Run(szFunc, saParameters);
				bResult = true;
			}
			ref = _ptr->Release();
			return bResult;
		}
	}
	catch (...)
	{
	}
	return false;
}
/*
=====================
idActor::Event_SetNextState
=====================
*/
void idActor::Event_SetNextState( const char* name )
{
	idealState = GetScriptFunction( name );
	if( idealState == state )
	{
		state = NULL;
	}
}
/*
=====================
idActor::Event_SetState
=====================
*/
void idActor::Event_SetState( const char* name )
{
	idealState = GetScriptFunction( name );
	if( idealState == state )
	{
		state = NULL;
	}
	scriptThread->DoneProcessing();
}
Example #5
0
void hhCenturion::Event_ScriptedArmChop() {
	const function_t* newstate = NULL;
	newstate = GetScriptFunction( "state_ScriptedArmChop" );
	if( newstate ) {
		SetState( newstate );
	}
	else {
		gameLocal.Warning( "Unable to find 'state_ScriptedArmChop' on centurion" );
	}
}