Example #1
0
//------------------------------------------------------------------------
int CScriptBind_Actor::CheckVirtualInventoryRestrictions(IFunctionHandler *pH, SmartScriptTable inventory, const char *itemClassName)
{
	CActor *pActor = GetActor(pH);
	if (!pActor)
		return pH->EndFunction();

	static std::vector<string> virtualInventory;
	virtualInventory.reserve(inventory->Count());

	IScriptTable::Iterator it=inventory->BeginIteration();
	while(inventory->MoveNext(it))
	{
		const char *itemClass=0;
		it.value.CopyTo(itemClass);

		if (itemClass && itemClass[0])
			virtualInventory.push_back(itemClass);
	}

	inventory->EndIteration(it);

	bool result=pActor->CheckVirtualInventoryRestrictions(virtualInventory, itemClassName);
	virtualInventory.resize(0);

	if (result)
		return pH->EndFunction(1);

	return pH->EndFunction();
}
//------------------------------------------------------------------------
void CGameRulesMPDamageHandling::DelegateServerHit(IScriptTable* victimScript, const HitInfo& hit, CActor* pVictimActor)
{
	SmartScriptTable victimServerScript;
	if (victimScript->GetValue("Server", victimServerScript))
	{
		HSCRIPTFUNCTION pfnOnHit = 0;
		if (victimServerScript->GetValue("OnHit", pfnOnHit))
		{
			bool diedAfterHit = false;
			m_pGameRules->CreateScriptHitInfo(m_scriptHitInfo, hit);
			if (Script::CallReturn(gEnv->pScriptSystem, pfnOnHit, victimScript, m_scriptHitInfo, diedAfterHit))
			{
				if (diedAfterHit)
				{
					// Hit was deadly
					if (pVictimActor)
					{
						ProcessDeath(hit, *pVictimActor);
					}
					else
					{
						m_pGameRules->OnEntityKilled(hit);
					}
				}

				if (g_pGameCVars->g_debugHits > 0)
				{
					LogHit(hit, (g_pGameCVars->g_debugHits > 1), diedAfterHit);
				}
			}

			gEnv->pScriptSystem->ReleaseFunc(pfnOnHit);
		}
	}
}
Example #3
0
// NOTE Mrz 21, 2007: <pvl> might need to handle the params the way SetGrab()
// does (separate param table for each of the grabbed objects).
// UPDATE Mrz 26, 2007: <pvl> done
bool CMultipleGrabHandler::SetDrop(SmartScriptTable &rParams)
{
	SmartScriptTable dropParamsTable;
	if (rParams->GetValue("params",dropParamsTable))
	{
		bool result = true;

		IScriptTable::Iterator iter = dropParamsTable->BeginIteration();
		int numGrabHandlers = m_handlers.size();

		for (int i=0; dropParamsTable->MoveNext(iter) && i < numGrabHandlers; ++i)
		{
			SmartScriptTable params;
			iter.value.CopyTo (params);
			result = m_handlers[i]->SetDrop(params) & result;
		}

		dropParamsTable->EndIteration(iter);

		return result;
	}
	else
	{
		bool result = true;

		std::vector <CAnimatedGrabHandler*>::iterator it = m_handlers.begin();
		std::vector <CAnimatedGrabHandler*>::iterator end = m_handlers.end();
		for ( ; it != end; ++it)
			result = (*it)->SetDrop(rParams) & result;

		return result;
	}
}
const char *CAnimatedCharacterSample::GetCharacterModelNameFromScriptTable() const
{
	IEntity *pEntity = GetEntity();

	IScriptTable *pScriptTable = pEntity->GetScriptTable();

	if(pScriptTable == NULL)
	{
		return NULL;
	}

	SmartScriptTable propertiesTable;
	const bool hasPropertiesTable = pScriptTable->GetValue("Properties", propertiesTable);

	if(! hasPropertiesTable)
	{
		return NULL;
	}

	const char *modelName = NULL;
	const bool hasModelName = propertiesTable->GetValue("objModel", modelName);

	if(! hasModelName)
	{
		return NULL;
	}

	return modelName;
}
Example #5
0
int CScriptRMI::SynchedNewIndexFunction( IFunctionHandler* pH )
{
	if (!m_pThis->m_pParent)
	{
		pH->GetIScriptSystem()->RaiseError( "Trying to set a synchronized variable with no game started... failing" );
		return pH->EndFunction();
	}

	SmartScriptTable table;
	SmartScriptTable hidden;
	const char * key;
	ScriptAnyValue value;

	if (!pH->GetParam( 1, table ))
		return pH->EndFunction(false);

	ScriptHandle id;
	if (!table->GetValue( ID_FIELD, id ))
		return pH->EndFunction(false);
	if (!table->GetValue( HIDDEN_FIELD, hidden ))
		return pH->EndFunction(false);

	if (!pH->GetParam( 2, key ))
		return pH->EndFunction(false);
	if (!pH->GetParamAny( 3, value ))
		return pH->EndFunction(false);

	hidden->SetValueAny( key, value );

	m_pThis->m_pParent->ChangedScript((EntityId) id.n );

	return pH->EndFunction( true );
}
//------------------------------------------------------------------------
bool CVehicleActionEntityAttachment::Init(IVehicle* pVehicle, const SmartScriptTable &table)
{
	m_pVehicle = pVehicle;

	SmartScriptTable entityAttachmentTable;
	if (!table->GetValue("EntityAttachment", entityAttachmentTable))
		return false;

	char* pHelperName;
	if (entityAttachmentTable->GetValue("helper", pHelperName))
		m_pHelper = m_pVehicle->GetHelper(pHelperName);

	char* pEntityClassName;
	if (entityAttachmentTable->GetValue("class", pEntityClassName))
	{
		IEntityClassRegistry* pClassRegistry = gEnv->pEntitySystem->GetClassRegistry();
		assert(pClassRegistry);

		if (IEntityClass* pEntityClass = pClassRegistry->FindClass(pEntityClassName))
		{
			m_entityClassName = pEntityClassName;

			SpawnEntity();

			return true;
		}
	}

	return false;
}
Example #7
0
int CScriptRMI::SerializeFunction( IFunctionHandler * pH, void * pBuffer, int nSize )
{
	SmartScriptTable serTable;
	ScriptHandle hdl;
	pH->GetParam( 1, serTable );
	pH->GetParam( 2, hdl );
	SSerializeFunctionParams * p = (SSerializeFunctionParams *) hdl.ptr;

	SSynchedPropertyInfo * pInfo = (SSynchedPropertyInfo *) pBuffer;
	int nProperties = nSize / sizeof(SSynchedPropertyInfo);

	if (p->ser.IsReading())
	{
		for (int i=0; i < nProperties; i++)
			if (!m_pThis->ReadValue( pInfo[i].name, pInfo[i].type, p->ser, serTable.GetPtr() ))
				return pH->EndFunction(false);
	}
	else
	{
		for (int i=0; i < nProperties; i++)
			if (!m_pThis->WriteValue( pInfo[i].name, pInfo[i].type, p->ser, serTable.GetPtr() ))
				return pH->EndFunction(false);
	}
	return pH->EndFunction(true);
}
//------------------------------------------------------------------------
bool CVehicleMovementWarrior::Init(IVehicle* pVehicle, const SmartScriptTable &table)
{
  SmartScriptTable hovercraftTable;
  if (!table->GetValue("Hovercraft", hovercraftTable))
    return false;

  if (!CVehicleMovementHovercraft::Init(pVehicle, hovercraftTable))
    return false;

  table->GetValue("maxThrustersDamaged", m_maxThrustersDamaged);
  table->GetValue("collapsedFeetAngle", m_collapsedFeetAngle);
  table->GetValue("collapsedLegAngle", m_collapsedLegAngle);
  table->GetValue("recoverTime", m_recoverTime);

  // save original thruster values
  m_thrustersInit.reserve(m_vecThrusters.size());

  for (TThrusters::iterator it=m_vecThrusters.begin(); it!=m_vecThrusters.end(); ++it)
  {
    m_thrustersInit.push_back( new SThruster(**it) );
  }

  m_pTurret = m_pVehicle->GetPart("turret1");
  m_pCannon = m_pVehicle->GetPart("cannon");
  m_pWing   = m_pVehicle->GetPart("generator");

	m_pPlatformPos = m_pVehicle->GetHelper("platform_pos");
  
  return true;
}
static bool GetTeamRadioTable(CGameRules *gr, const string &team_name, SmartScriptTable &out_table)
{
	if(!gr)
	{
		return false;
	}

	IScriptTable *pTable = gr->GetEntity()->GetScriptTable();

	if(!pTable)
	{
		return false;
	}

	SmartScriptTable pTeamRadio;

	if(!pTable->GetValue("teamRadio", pTeamRadio))
	{
		return false;
	}

	if(!pTeamRadio->GetValue(team_name, out_table))
	{
		return false;
	}

	return true;
}
Example #10
0
//-----------------------------------------------------------------------
void CItem::PatchInitialSetup()
{
	const char *temp = NULL;
	// check if the initial setup accessories has been overridden in the level
	SmartScriptTable props;

	if(GetEntity()->GetScriptTable() && GetEntity()->GetScriptTable()->GetValue("Properties", props))
	{
		if(props->GetValue("initialSetup",temp) && temp !=NULL && temp[0]!=0)
		{
			m_properties.initialSetup = temp;
		}
	}

	//Replace initial setup from weapon xml, with initial setup defined for the entity (if neccesary)
	if(!m_properties.initialSetup.empty())
	{
		m_initialSetup["default"].resize(0);

		//Different accessory names are separated by ","

		string::size_type lastPos = m_properties.initialSetup.find_first_not_of(",", 0);
		string::size_type pos = m_properties.initialSetup.find_first_of(",", lastPos);

		while(string::npos != pos || string::npos != lastPos)
		{
			//Add to initial setup
			const char *name = m_properties.initialSetup.substr(lastPos, pos - lastPos).c_str();
			m_initialSetup["default"].push_back(name);

			lastPos = m_properties.initialSetup.find_first_not_of(",", pos);
			pos = m_properties.initialSetup.find_first_of(",", lastPos);
		}
	}
}
//------------------------------------------------------------------------
void CNetworkedPhysicsEntity::ReadPhysicsParams()
{
	SmartScriptTable pScriptTable = GetEntity()->GetScriptTable();
	if (pScriptTable)
	{
		SmartScriptTable pProperties;
		if (pScriptTable->GetValue("Properties", pProperties))
		{
			SmartScriptTable pPhysicsParams;
			if (pProperties->GetValue("Physics", pPhysicsParams))
			{
				CScriptSetGetChain chain(pPhysicsParams);
				chain.GetValue( "mass", m_physicsParams.mass );
				chain.GetValue( "density", m_physicsParams.density );
				chain.GetValue( "flags", m_physicsParams.nFlagsOR );
				chain.GetValue( "partid", m_physicsParams.nAttachToPart );
				chain.GetValue( "stiffness_scale", m_physicsParams.fStiffnessScale );
				chain.GetValue( "lod", m_physicsParams.nLod );

				if(!m_physicsParams.pBuoyancy)
				{
					m_physicsParams.pBuoyancy = new pe_params_buoyancy();
				}
				chain.GetValue( "water_damping", m_physicsParams.pBuoyancy->waterDamping );
				chain.GetValue( "water_resistance", m_physicsParams.pBuoyancy->waterResistance );
				chain.GetValue( "water_density", m_physicsParams.pBuoyancy->waterDensity );

				m_physicsParams.type = PE_RIGID;

				return;
			}
		}
	}
	CRY_ASSERT(!"Failed to read physics params from script for NetworkedPhysicsEntity");
}
//------------------------------------------------------------------------
bool CVehicleActionDeployRope::Init(IVehicle* pVehicle, TVehicleSeatId seatId, const SmartScriptTable &table)
{
	m_pVehicle = pVehicle;
	m_seatId = seatId;

	SmartScriptTable deployRopeTable;
	if (!table->GetValue("DeployRope", deployRopeTable))
		return false;

	char* pHelperName;
	if (deployRopeTable->GetValue("helper", pHelperName))
		m_pRopeHelper = m_pVehicle->GetHelper(pHelperName);

	char* pAnimName;
	if (deployRopeTable->GetValue("animation", pAnimName))
	{
		m_pDeployAnim = m_pVehicle->GetAnimation(pAnimName);

		if (m_pDeployAnim)
		{
			m_deployAnimOpenedId = m_pDeployAnim->GetStateId("opened");
			m_deployAnimClosedId = m_pDeployAnim->GetStateId("closed");

			if (m_deployAnimOpenedId == InvalidVehicleAnimStateId 
				|| m_deployAnimClosedId == InvalidVehicleAnimStateId)
			{
				m_pDeployAnim = NULL;
			}
		}
	}

	return m_pRopeHelper != NULL;
}
Example #13
0
bool CMultipleGrabHandler::SetGrab(SmartScriptTable &rParams)
{
	// NOTE Mrz 20, 2007: <pvl> if we don't find 'params' param in the table,
	// we assume that this is an old-style grab param table that's not aware of
	// the possibility of multiple objects grabbed simultaneously.  

	SmartScriptTable grabParamsTable;
	if (rParams->GetValue("params",grabParamsTable))
	{
		bool result = true;

		IScriptTable::Iterator iter = grabParamsTable->BeginIteration();

		while(grabParamsTable->MoveNext(iter))
		{
			CAnimatedGrabHandler * handler = new CAnimatedGrabHandler (m_pActor);
			SmartScriptTable params;
			iter.value.CopyTo (params);
			result = handler->SetGrab(params) & result;
			m_handlers.push_back (handler);
		}

		grabParamsTable->EndIteration(iter);

		return result;
	}
	else
	{
		CAnimatedGrabHandler * handler = new CAnimatedGrabHandler (m_pActor);
		m_handlers.push_back (handler);
		return handler->SetGrab(rParams);
	}
}
Example #14
0
// add a synch proxy table to an entity
void CScriptRMI::AddSynchedTable( IScriptTable * pEntityTable, 
																  ScriptHandle id,
																  const char * name, SmartScriptTable dispatchTable )
{
	SmartScriptTable synchedTable( pEntityTable->GetScriptSystem() );
	SmartScriptTable hiddenTable( pEntityTable->GetScriptSystem() );
	SmartScriptTable origTable;
	pEntityTable->GetValue( name, origTable );

	hiddenTable->Clone( dispatchTable );
	hiddenTable->SetValue( "__index", hiddenTable );

	IScriptTable::Iterator iter = origTable->BeginIteration();
	while (origTable->MoveNext(iter))
	{
		if (iter.sKey)
		{
			if (hiddenTable->GetValueType( iter.sKey ) != svtNull)
				GameWarning( "Replacing non-null value %s", iter.sKey );

			ScriptAnyValue value;
			origTable->GetValueAny( iter.sKey, value );
			hiddenTable->SetValueAny( iter.sKey, value );
		}
	}
	origTable->EndIteration(iter);

	synchedTable->Delegate( hiddenTable );
	synchedTable->SetValue( ID_FIELD, id );
	synchedTable->SetValue( HIDDEN_FIELD, hiddenTable );
	pEntityTable->SetValue( name, synchedTable );
}
Example #15
0
	bool Prologue( EntityId objID, bool bClient, uint8 funcID )
	{
		if (!InitGameMembers(objID))
			return false;

		SmartScriptTable dispatchTable;
		if (!m_pScriptTable->GetValue( bClient? CLIENT_DISPATCH_FIELD : SERVER_DISPATCH_FIELD, dispatchTable))
			return false;

		const char * funcData;
		if (!dispatchTable->GetAt( funcID+1, funcData ))
		{
			GameWarning( "No such function dispatch index %d on entity %s (class %s)", funcID,
				m_pEntity->GetName(), m_pEntity->GetClass()->GetName() );
			return false;
		}

		const char * colon = strchr(funcData, ':');
		if (colon == NULL)
			return false;
		if (colon - funcData > BUFFER)
			return false;
		memcpy( m_function, funcData, colon-funcData );
		m_function[colon-funcData] = 0;
		m_format = colon + 1;
		return true;
	}
//------------------------------------------------------------------------
int CScriptBind_MatchMaking::StartSearch( IFunctionHandler *pH, int freeSlotsRequired, int maxResults, SmartScriptTable searchParams )
{
	if( CMatchMakingHandler* pMatchMaking = m_pLobbyManager->GetMatchMakingHandler() )
	{
		int dataIndex = 0;
		SCrySessionSearchData data[ FIND_GAMES_SEARCH_NUM_DATA ];
		//for every type of data we can search on
		for( uint32 iKey = 0; iKey < numSearchIdTypes; iKey++ )
		{
			//see if there is a key for it in search params table
			SmartScriptTable entry;
			if( searchParams->GetValue( idLookup[ iKey ].key, entry ) )
			{
				//if there is read the value and operator
				ScriptAnyValue valueVal;
				int operatorVal;

				if( entry->GetValueAny( "val", valueVal ) )
				{
					if( entry->GetValue( "operator", operatorVal ) )
					{	
						//and set them into the search data
						data[ dataIndex ].m_data.m_id = idLookup[ iKey ].id;
					
						switch( valueVal.type )
						{
						case ANY_TNUMBER:
							data[ dataIndex ].m_data.m_type = eCLUDT_Int32;
							data[ dataIndex ].m_data.m_int32 = (int32)valueVal.number;
							break;

						case ANY_TBOOLEAN:
							data[ dataIndex ].m_data.m_type = eCLUDT_Int32;
							data[ dataIndex ].m_data.m_int32 = (int32)valueVal.b;
							break;

						case ANY_THANDLE:
							data[ dataIndex ].m_data.m_type = eCLUDT_Int32;
							data[ dataIndex ].m_data.m_int32 = (int32)(TRUNCATE_PTR)valueVal.ptr;
							break;

						default:
							MMLog( pH, "MMLua: Unsupported type in search data", true );
						}
						
						//CryLog( "MMLua: Search Session Parameter, id %d, value %d, operator %d", data[ dataIndex ].m_data.m_id, data[ dataIndex ].m_data.m_int32, operatorVal );
						data[ dataIndex ].m_operator = static_cast<ECrySessionSearchOperator>(operatorVal);
						dataIndex++;
					}
				}
			}
		}
	
		//pass the final search on to the handler
		pMatchMaking->Search( freeSlotsRequired, maxResults, data, dataIndex );
	}

	return pH->EndFunction( true );
}
Example #17
0
IWriteXMLSourcePtr CXmlScriptSaver::BeginArray( const char * name, size_t * numElems, const XmlNodeRef& definition )
{
	SmartScriptTable childTable;
	if (!CurTable()->GetValue(name, childTable))
		return NULL;
	*numElems = childTable->Count();
	m_tables.push( childTable );
	return this;
}
void CGeomEntity::Reset()
{
	SmartScriptTable propertiesTable;
	GetEntity()->GetScriptTable()->GetValue("Properties", propertiesTable);

	const char* geometryPath = "";
	if (propertiesTable->GetValue("object_Model", geometryPath))
	{
		GetEntity()->LoadGeometry(0, geometryPath);
	}
}
bool CRadio::UpdatePendingGroup()
{
	// key used in menu request was already consumed by sub level,
	// or the menu is open, but sub level have not yet got a change to update.
	if (m_inputEventConsumedKey ||
			((m_currentGroup != -1) && m_waitForInputEvents))
	{
		m_inputEventConsumedKey = false;
		m_requestedGroup = -1;
		return false;
	}

	if (m_requestedGroup == -1)
	{
		return false;
	}

	if (m_requestedGroup == m_currentGroup)
	{
		CloseRadioMenu();
		m_currentGroup = -1;
		m_requestedGroup = -1;
		return true;
	}

	m_currentGroup = m_requestedGroup;
	m_requestedGroup = -1;
	m_menuOpenTime = gEnv->pTimer->GetCurrTime();
	PlaySound("Sounds/interface:menu:pop_up");

	if (gEnv->pInput)
	{
		gEnv->pInput->AddEventListener(this);
	}

	g_pGameActions->FilterMPRadio()->Enable(true);
	SmartScriptTable radioTable;

	if(!GetTeamRadioTable(m_pGameRules, m_TeamName, radioTable))
	{
		return false;
	}

	SmartScriptTable groupTable;

	if(!radioTable->GetAt(m_currentGroup + 1, groupTable))
	{
		return false;
	}

	return true;
}
CPlayer *CScriptBind_HitDeathReactions::GetAssociatedActor(IFunctionHandler *pH) const
{
	SmartScriptTable selfTable;
	pH->GetSelf(selfTable);
	CRY_ASSERT(selfTable->HaveValue("__actor"));
	ScriptHandle actorEntityId;
	selfTable->GetValue("__actor", actorEntityId);
	IActor *pActor = m_pGameFW->GetIActorSystem()->GetActor(static_cast<EntityId>(actorEntityId.n));
	// [*DavidR | 13/Nov/2009] WARNING: This downcast could be dangerous if CHitDeathReactions is moved to
	// CActor classes
	CRY_ASSERT(pActor && (pActor->GetActorClass() == CPlayer::GetActorClassType()));
	return static_cast<CPlayer *>(pActor);
}
bool CSmartMine::ShouldStartTrackingEntity( const EntityId entityId ) const
{
	// Always track player...
	if (entityId == g_pGame->GetIGameFramework()->GetClientActorId())
	{
		return true;
	}

	// ... or any AI
	const SAutoaimTarget* pTargetInfo = g_pGame->GetAutoAimManager().GetTargetInfo( entityId );
	if(pTargetInfo != NULL)
	{
		return (pTargetInfo->pActorWeak.lock() != NULL);
	}

	// Also track kickable and pickable objects
	IEntity* pEntity = gEnv->pEntitySystem->GetEntity( entityId );
	IScriptTable* pScriptTable = (pEntity != NULL) ? pEntity->GetScriptTable() : NULL;
	if(pScriptTable != NULL)
	{
		SmartScriptTable propertiesTable;
		if(pScriptTable->GetValue("Properties", propertiesTable))
		{
			int pickable = 0, kickable = 0;
			propertiesTable->GetValue("bPickable", pickable);
			propertiesTable->GetValue("bInteractLargeObject", kickable);

			if(pickable)
			{
				// Filter out items/weapons
				pickable = (g_pGame->GetIGameFramework()->GetIItemSystem()->GetItem(entityId) == NULL);
			}

			if (pickable || kickable)
			{
				//Check if object is moving
				IPhysicalEntity* pEntityPhysics = pEntity->GetPhysics();
				if(pEntityPhysics != NULL)
				{
					pe_status_dynamics entityDynamics;
					if(pEntityPhysics->GetStatus(&entityDynamics))
					{
						return (entityDynamics.v.len2() > 0.1f);
					}
				}
			}
		}
	}

	return false;
}
//------------------------------------------------------------------------
bool CVehicleDamageBehaviorBurn::Init(IVehicle* pVehicle, const SmartScriptTable &table)
{
	m_pVehicle = pVehicle;
	m_isActive = false;
  m_damageRatioMin = 1.f;
  m_timerId = -1;

	m_shooterId = 0;

  table->GetValue("damageRatioMin", m_damageRatioMin);

	SmartScriptTable burnParams;
	if (table->GetValue("Burn", burnParams))
	{
		burnParams->GetValue("damage", m_damage);
    burnParams->GetValue("selfDamage", m_selfDamage);
		burnParams->GetValue("interval", m_interval);
		burnParams->GetValue("radius", m_radius);

		m_pHelper = NULL;

		char* pHelperName = NULL;
		if (burnParams->GetValue("helper", pHelperName))
			m_pHelper = m_pVehicle->GetHelper(pHelperName);

		return true;
	}

	return false;
}
void CVicinityDependentObjectMover::SetupEntity()
{
	const char* szModelName = VICINITYDEPENDENTOBJECTMOVER_MODEL_NORMAL;
	float fMoveToDistance = 10.0f;
	float fAreaTriggerRange = 10.0f;
	float fBackAreaTriggerRange = 10.0f;
	float fForceMoveCompleteDistance = 1.0f;

	IEntity* pEntity = GetEntity();
	CRY_ASSERT( pEntity != NULL );

	IScriptTable* pScriptTable = pEntity->GetScriptTable();
	if ( pScriptTable != NULL )
	{
		SmartScriptTable propertiesTable;
		if ( pScriptTable->GetValue( "Properties", propertiesTable) )
		{
			propertiesTable->GetValue( "objModel", szModelName );
			propertiesTable->GetValue( "fMoveToDistance", fMoveToDistance );
			propertiesTable->GetValue( "fMoveToSpeed", m_fMoveToSpeed );
			propertiesTable->GetValue( "fMoveBackSpeed", m_fMoveBackSpeed );
			propertiesTable->GetValue( "fAreaTriggerRange", fAreaTriggerRange );
			propertiesTable->GetValue( "fBackAreaTriggerRange", fBackAreaTriggerRange );
			propertiesTable->GetValue( "fForceMoveCompleteDistance", fForceMoveCompleteDistance );
			propertiesTable->GetValue( "bUseAreaTrigger", m_bUseAreaTrigger );
			propertiesTable->GetValue( "bDisableAreaTriggerOnMoveComplete", m_bDisableAreaTriggerOnMoveComplete );
		}
	}

	m_fMoveToDistance = fMoveToDistance;
	m_fMoveToDistanceSq = fMoveToDistance*fMoveToDistance;
	m_fAreaTriggerRange = fAreaTriggerRange;
	m_fAreaTriggerRangeSq = fAreaTriggerRange*fAreaTriggerRange;
	m_fBackAreaTriggerRange = fBackAreaTriggerRange;
	m_fBackAreaTriggerRangeSq = fBackAreaTriggerRange*fBackAreaTriggerRange;
	m_fForceMoveCompleteDistanceSq = fForceMoveCompleteDistance*fForceMoveCompleteDistance;

	// Load model
	pEntity->LoadGeometry( VICINITYDEPENDENTOBJECTMOVER_MODEL_NORMAL_SLOT, szModelName );

	// Draw slot and physicalize it
	DrawSlot( VICINITYDEPENDENTOBJECTMOVER_MODEL_NORMAL_SLOT, true );

	SEntityPhysicalizeParams physicalizeParams;
	physicalizeParams.nSlot = VICINITYDEPENDENTOBJECTMOVER_MODEL_NORMAL_SLOT;
	physicalizeParams.type = PE_RIGID;
	physicalizeParams.mass = 0;

	GetEntity()->Physicalize( physicalizeParams );
}
Example #24
0
//------------------------------------------------------------------------
bool SUIToLuaConversationHelper::LuaTableToUIArgs(SmartScriptTable table, SUIArguments &args)
{
	for (int i = 0; i <= table->Count(); ++i)
	{
		if (i == 0 && table->GetAtType(0) == svtNull)
			continue; // if passing {arg1, arg2, arg3} to scriptbind first entry will be nil

		TUIData val;
		if (!SUIConvHelperTmpl::LuaArgToUIArgImpl(table, i, val))
			return false;
		args.AddArgument( val );
	}
	return true;
}
CLipSyncProvider_TransitionQueue::CLipSyncProvider_TransitionQueue(EntityId entityId)
	: m_entityId(entityId)
	, m_nCharacterSlot(-1)
	, m_nAnimLayer(-1)
	, m_state(eS_Init)
	, m_isSynchronized(false)
	, m_requestedAnimId(-1)
	, m_nCurrentAnimationToken(0)
	, m_soundId(INVALID_AUDIO_CONTROL_ID)
{
	// read settings from script
	if (IEntity* pEntity = GetEntity())
	{
		if (SmartScriptTable pScriptTable = pEntity->GetScriptTable())
		{
			SmartScriptTable pPropertiesTable;
			if (pScriptTable->GetValue("Properties", pPropertiesTable))
			{
				SmartScriptTable pLipSyncTable;
				if (pPropertiesTable->GetValue("LipSync", pLipSyncTable))
				{
					SmartScriptTable pSettingsTable;
					if (pLipSyncTable->GetValue("TransitionQueueSettings", pSettingsTable))
					{
						pSettingsTable->GetValue("nCharacterSlot", m_nCharacterSlot);
						pSettingsTable->GetValue("nAnimLayer", m_nAnimLayer);
						pSettingsTable->GetValue("sDefaultAnimName", m_sDefaultAnimName);
					}
				}
			}
		}
	}
}
//------------------------------------------------------------------------
CVehicle *CScriptBind_Vehicle::GetVehicle(IFunctionHandler *pH)
{
  ScriptHandle handle;  
  SmartScriptTable table;  
  
  if (pH->GetSelf(table))
  {
    if (table->GetValue("vehicleId", handle))
    { 
      return (CVehicle*)m_pVehicleSystem->GetVehicle((EntityId)handle.n);
    }
  }

	return 0;
}
Example #27
0
//------------------------------------------------------------------------
int CScriptBind_Item::OnHit(IFunctionHandler *pH, SmartScriptTable hitTable)
{
  CItem *pItem = GetItem(pH);
  if (!pItem)
    return pH->EndFunction();

  float damage = 0.f;
  hitTable->GetValue("damage", damage);
  char* damageType = 0;
  hitTable->GetValue("type",damageType);
  
  pItem->OnHit(damage,damageType);

  return pH->EndFunction();
}
//------------------------------------------------------------------------
int CScriptBind_MaterialEffects::ExecuteEffect(IFunctionHandler* pH, int effectId, SmartScriptTable paramsTable)
{
  if (effectId == InvalidEffectId)
    return pH->EndFunction(false);

  // minimalistic implementation.. extend if you need it  
  SMFXRunTimeEffectParams params;
  paramsTable->GetValue("pos", params.pos);  
  paramsTable->GetValue("normal", params.normal);
  paramsTable->GetValue("scale", params.scale);
  paramsTable->GetValue("angle", params.angle);
  
  bool res = m_pMFX->ExecuteEffect(effectId, params);

  return pH->EndFunction(res);
}
Example #29
0
//------------------------------------------------------------------------
int CScriptBind_UIAction::EndAction( IFunctionHandler *pH, SmartScriptTable pTable, bool disable, SmartScriptTable arguments )
{
	if (!pTable)
	{
		UIACTION_WARNING( "LUA: EndAction received non-valid script table!");
		return pH->EndFunction( false );
	}

	const char* actionName;
	if (pTable->GetValue("__ui_action_name", actionName))
	{
		IUIAction* pAction = GetAction( actionName );
		if ( pAction )
		{
			SUIArguments args;
			if (SUIToLuaConversationHelper::LuaTableToUIArgs(arguments, args))
			{
				gEnv->pFlashUI->GetUIActionManager()->EndAction( pAction, args );
				if (disable)
					gEnv->pFlashUI->GetUIActionManager()->EnableAction( pAction, false );
				return pH->EndFunction( true );
			}
			UIACTION_WARNING( "LUA: Failed to end UIAction %s: Invalid arguments", actionName );
			return pH->EndFunction( false );
		}
	}
	UIACTION_WARNING( "LUA: Failed to end UIAction: Called from different script than UIAction lua script!" );
	return pH->EndFunction( false );
}
int CScriptBind_MatchMaking::CreateServer( IFunctionHandler *pH, SmartScriptTable sessionParams )
{
	if( CMatchMakingHandler* pMatchMaking = m_pLobbyManager->GetMatchMakingHandler() )
	{
		//get rid of any stale settings
		pMatchMaking->ClearSessionParameters();

		//process the parameters

		//for every type of data sessions can broadcast
		for( uint32 iKey = 0; iKey < numSearchIdTypes; iKey++ )
		{
			//see if there is a key for it in session params table
			ScriptAnyValue valueVal;
			if( sessionParams->GetValueAny( idLookup[ iKey ].key, valueVal ) )
			{
				if( valueVal.type != ANY_TNIL )
				{
					//if there is add it to our parameters
					pMatchMaking->NewSessionParameter( idLookup[ iKey ].id, valueVal );
				}
			}
		}
	}

	//ask the networking to create a session
	if( CGameLobby* pLobby = m_pLobbyManager->GetGameLobby() )
	{
		pLobby->FindGameCreateGame();
	}

	return pH->EndFunction();
}