//------------------------------------------------------------------------
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 #2
0
bool CScriptRMI::SerializeScript( TSerialize ser, IEntity * pEntity )
{
	SSerializeFunctionParams p( ser, pEntity );
	ScriptHandle hdl( &p );
	IScriptTable * pTable = pEntity->GetScriptTable();
	if (pTable)
	{
		SmartScriptTable serTable;
		SmartScriptTable synchedTable;
		pTable->GetValue( "synched", synchedTable );
		if (synchedTable.GetPtr())
		{
			synchedTable->GetValue( HIDDEN_FIELD, serTable );
			if (serTable.GetPtr())
			{
				IScriptSystem * pScriptSystem = pTable->GetScriptSystem();
				pScriptSystem->BeginCall( serTable.GetPtr(), SERIALIZE_FUNCTION );
				pScriptSystem->PushFuncParam( serTable );
				pScriptSystem->PushFuncParam( hdl );
				return pScriptSystem->EndCall();
			}
		}
	}
	return true;
}
//------------------------------------------------------------------------
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 #4
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 #5
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);
		}
	}
}
Example #6
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;
	}
}
Example #7
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 );
}
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;
}
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
//------------------------------------------------------------------------
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* damageTypeName = 0;
  hitTable->GetValue("type", damageTypeName);
  
	const int hitType = g_pGame->GetGameRules()->GetHitTypeId(damageTypeName);

  pItem->OnHit(damage, hitType);

  return pH->EndFunction();
}
void CDangerousRigidBody::Reset()
{
	IScriptTable*  pTable = GetEntity()->GetScriptTable();
	if (pTable != NULL)
	{
		SmartScriptTable propertiesTable;
		if (pTable->GetValue("Properties", propertiesTable))
		{
			propertiesTable->GetValue("bCurrentlyDealingDamage", m_dangerous);
			propertiesTable->GetValue("bDoesFriendlyFireDamage", m_friendlyFireEnabled);
			propertiesTable->GetValue("fDamageToDeal", m_damageDealt);
			propertiesTable->GetValue("fTimeBetweenHits", m_timeBetweenHits);
		}
	}
	m_activatorTeam = 0;
	m_lastHitTime = 0;
}
//------------------------------------------------------------------------
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 );
}
//------------------------------------------------------------------------
bool CShake::Init(IGameObject *pGameObject)
{
	SetGameObject(pGameObject);

	//Initialize default values before (in case ScriptTable fails)
	m_radius = 30.0f;
	m_shake = 0.05f;

	SmartScriptTable props;
	IScriptTable* pScriptTable = GetEntity()->GetScriptTable();
	if(!pScriptTable || !pScriptTable->GetValue("Properties", props))
		return false;

	props->GetValue("Radius", m_radius);
	props->GetValue("Shake", m_shake);

	return true;
}
Example #15
0
void CAutoAimManager::RegisterCharacterTargetInfo(const CActor& targetActor, const SAutoaimTargetRegisterParams& registerParams)
{
	SAutoaimTarget aimTarget;
	aimTarget.entityId = targetActor.GetEntityId();
	aimTarget.pActorWeak = targetActor.GetWeakPtr();
	aimTarget.fallbackOffset = registerParams.fallbackOffset;
	aimTarget.primaryBoneId = registerParams.primaryBoneId;
	aimTarget.physicsBoneId = registerParams.physicsBoneId;
	aimTarget.secondaryBoneId = registerParams.secondaryBoneId;
	aimTarget.innerRadius = registerParams.innerRadius;
	aimTarget.outerRadius = registerParams.outerRadius;
	aimTarget.snapRadius = registerParams.snapRadius;
	aimTarget.snapRadiusTagged = registerParams.snapRadiusTagged;

	if (!gEnv->bMultiplayer)
	{
		IEntity* pTargetEntity = targetActor.GetEntity();

		aimTarget.aiFaction = IFactionMap::InvalidFactionID;

		//Instance properties, other stuff could be added here easily (grab enemy, sliding hit, etc)
		SmartScriptTable props;
		SmartScriptTable propsPlayerInteractions;
		IScriptTable* pScriptTable = pTargetEntity->GetScriptTable();
		if (pScriptTable && pScriptTable->GetValue("Properties", props))
		{
			if (props->GetValue("PlayerInteractions", propsPlayerInteractions))
			{
				int stealhKill = 0;
				if (propsPlayerInteractions->GetValue("bStealthKill", stealhKill) && (stealhKill != 0))
				{
					aimTarget.SetFlag(eAATF_StealthKillable);
				}
				int canBeGrabbed = 0;
				if (propsPlayerInteractions->GetValue("bCanBeGrabbed", canBeGrabbed) && (canBeGrabbed != 0))
				{
					aimTarget.SetFlag(eAATF_CanBeGrabbed);
				}
			}
		}
	}

	m_autoaimTargets.push_back(aimTarget);
}
Example #16
0
bool CBaseGrabHandler::SetGrab(SmartScriptTable &rParams)
{
	ScriptHandle id;
	id.n = 0;

	rParams->GetValue("entityId",id);
	rParams->GetValue("holdPos",m_grabStats.lHoldPos);
	rParams->GetValue("followSpeed",m_grabStats.followSpeed);
	
	m_grabStats.collisionFlags = 0;
	rParams->GetValue("collisionFlags",m_grabStats.collisionFlags);

	m_grabStats.grabDelay = 0.0f;
	rParams->GetValue("grabDelay",m_grabStats.grabDelay);

	m_grabStats.throwDelay = 0.0f;
	m_grabStats.maxDelay = m_grabStats.grabDelay;

	m_grabStats.entityGrabSpot = Vec3 (0.0f, 0.0f, 0.0f);
	rParams->GetValue("entityGrabSpot",m_grabStats.entityGrabSpot);

	m_grabStats.boneGrabOffset = Vec3 (0.0f, 0.0f, 0.0f);
	rParams->GetValue("boneGrabOffset",m_grabStats.boneGrabOffset);

	// NOTE Dez 12, 2006: <pvl> the following code was formerly in CBaseGrabHandler::StartGrab().
	if (m_grabStats.grabId<1)
	{
		IEntity *pGrab = gEnv->pEntitySystem->GetEntity((EntityId)id.n);

		if (pGrab)
		{
			float heavyness(0.0f);
			float volume(0.0f);
			if (!m_pActor->CanPickUpObject(pGrab,heavyness, volume))
				return false;

			m_grabStats.grabId = (EntityId)id.n;
			m_grabStats.additionalRotation = (m_pActor->GetEntity()->GetRotation().GetInverted() * pGrab->GetRotation()).GetNormalized();
			
			//if there is still a link to remove
			if (m_grabStats.dropId>0)
			{
				// NOTE Dez 14, 2006: <pvl> switch collision detection back
				// on for the object to be dropped
				IgnoreCollision(m_grabStats.dropId,m_grabStats.collisionFlags,false);
				m_grabStats.dropId = 0;
			}

			IgnoreCollision(m_grabStats.grabId,m_grabStats.collisionFlags,true);

			return true;
		}
	} else {
		assert (0);
	}
	return false;
}
void CGeomEntity::Reset()
{
	SmartScriptTable propertiesTable;
	GetEntity()->GetScriptTable()->GetValue("Properties", propertiesTable);

	const char* geometryPath = "";
	if (propertiesTable->GetValue("object_Model", geometryPath))
	{
		GetEntity()->LoadGeometry(0, geometryPath);
	}
}
//------------------------------------------------------------------------
void CGameRulesKingOfTheHillObjective::OnNewHoldEntity(SHoldEntityDetails *pDetails, int index)
{
	CRY_ASSERT(index < HOLD_OBJECTIVE_MAX_ENTITIES);

	SKotHEntity *pKotHEntity = &m_additionalInfo[index];
	pKotHEntity->Reset();

	pDetails->m_pAdditionalData = pKotHEntity;

	if (gEnv->bServer)
	{
		g_pGame->GetGameRules()->SetTeam(0, pDetails->m_id);
	}

	if (gEnv->IsClient())
	{
		pKotHEntity->m_needsIconUpdate = true;		// Can't set icon straight away since the lua 'checkFunc' will give an incorrect result
		InitEntityAudio(pDetails);
	}

	OnInsideStateChanged(pDetails);

	// Cache radius pulse effect scale
	IEntity *pEntity = gEnv->pEntitySystem->GetEntity(pDetails->m_id);
	if (pEntity)
	{
		SmartScriptTable pScriptTable = pEntity->GetScriptTable();
		if (pScriptTable)
		{
			SmartScriptTable pPropertiesTable;
			if (pScriptTable->GetValue("Properties", pPropertiesTable))
			{
				float fRadiusEffectScale = 1.f;
				if (pPropertiesTable->GetValue("radiusEffectScale", fRadiusEffectScale))
				{
					pKotHEntity->m_radiusEffectScale = fRadiusEffectScale;
				}
			}
		}
	}
}
Example #19
0
void CBoundingContainer::SetupEntity()
{
	IEntity* pEntity = GetEntity();
	CRY_ASSERT(pEntity != NULL);

	IScriptTable* pScriptTable = pEntity->GetScriptTable();
	if (pScriptTable != NULL)
	{
		SmartScriptTable propertiesTable;
		if (pScriptTable->GetValue("Properties", propertiesTable))
		{
			Vec3 boundingDimensions(0.0f,0.0f,0.0f);
			propertiesTable->GetValue("DimX", boundingDimensions.x);
			propertiesTable->GetValue("DimY", boundingDimensions.y);
			propertiesTable->GetValue("DimZ", boundingDimensions.z);

			m_vBoundingMin = -boundingDimensions/2.0f;
			m_vBoundingMax = boundingDimensions/2.0f;
		}
	}
}
Example #20
0
void CFlock::OnBoidHit( EntityId nBoidId,SmartScriptTable &hit )
{
	int num = (int)m_boids.size();
	for (int i = 0; i < num; i++)
	{
		CBoidObject *boid = m_boids[i];
		if (boid->m_entity == nBoidId)
		{
			Vec3 pos = boid->m_pos;
			Vec3 force = Vec3(1,1,1);
			float damage = 1.0f;
			hit->GetValue("pos", pos);
			hit->GetValue("dir", force);
			hit->GetValue("damage", damage);

			boid->Kill( pos,force*damage );

			break;
		}
	}
}
Example #21
0
void CDeflectorShield::LoadScriptProperties()
{
	SmartScriptTable pScriptTable = GetEntity()->GetScriptTable();
	if (!pScriptTable)
		return;

	SmartScriptTable pProperties;
	if (!pScriptTable->GetValue("Properties", pProperties))
		return;

	const char* hitType = 0;
	const char* ammoType = 0;
	const char* particleFx = 0;
	float energyDelay;

	pProperties->GetValue("MinDamage", m_minDamage);
	pProperties->GetValue("MaxDamage", m_maxDamage);
	pProperties->GetValue("DropMinDistance", m_dropMinDistance);
	pProperties->GetValue("DropPerMeter", m_dropPerMeter);
	pProperties->GetValue("Spread", m_spread);
	pProperties->GetValue("EnergyRadius", m_energyRadius);
	pProperties->GetValue("EnergyDelay", energyDelay);
	pProperties->GetValue("HitType", hitType);
	pProperties->GetValue("AmmoType", ammoType);
	pProperties->GetValue("ParticleEffect", particleFx);

	if (hitType)
		m_hitTypeId = g_pGame->GetGameRules()->GetHitTypeId(hitType);
	if (ammoType)
		m_pAmmoClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(ammoType);
	if (particleFx)
		m_pDeflectedEffect = gEnv->p3DEngine->GetParticleManager()->FindEffect(particleFx);

	m_invEnergyDelay = 1.0f / (energyDelay + FLT_EPSILON);

	if (m_pAmmoClass)
		PreCacheAmmoResources();
	else
		CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "No ammo type specified for Deflector Shield '%s'", GetEntity()->GetName());
}
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 CMelee::IsMeleeFilteredOnEntity( const IEntity& targetEntity ) const
{
	static IEntityClass* s_pAnimObjectClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("AnimObject");

	if (targetEntity.GetClass() == s_pAnimObjectClass)
	{
		if (IScriptTable* pEntityScript = targetEntity.GetScriptTable())
		{
			SmartScriptTable properties;
			if (pEntityScript->GetValue("Properties", properties))
			{
				SmartScriptTable physicProperties;
				if (properties->GetValue("Physics", physicProperties))
				{
					bool bulletCollisionEnabled = true;
					return (physicProperties->GetValue("bBulletCollisionEnabled", bulletCollisionEnabled) && !bulletCollisionEnabled);
				}
			}
		}
	}

	return false;
}
Example #24
0
bool CBaseGrabHandler::SetDrop(SmartScriptTable &rParams)
{
	rParams->GetValue("throwVec",m_grabStats.throwVector);

	int throwImmediately(0);
	rParams->GetValue("throwImmediately",throwImmediately);

	//FIXME:
	if (throwImmediately)
	{
		StartDrop();
	}
	else if (m_grabStats.throwDelay<0.001f)
	{
		rParams->GetValue("throwDelay",m_grabStats.throwDelay);

		m_grabStats.grabDelay = 0.0f;
		m_grabStats.maxDelay = m_grabStats.throwDelay;

		StartDrop();
	}

	return true;
}
// ===========================================================================
//	Query if an entity is resurrectable.
//
//	In:		Pointer to the target entity (NULL will abort!)
//
//	Returns:	True if resurrectable; otherwise false.
//
bool MastermindModuleDeathListener::IsEntityResurrectable(const IEntity* entity) const
{
	// Do the cheap checks first.
	if (entity->IsHidden())
	{
		return false;
	}

	// And then the more expensive ones.
	IScriptTable* scriptTable = entity->GetScriptTable();
	if (scriptTable == NULL)
	{
		return false;
	}

	SmartScriptTable props;	
	if (!(scriptTable->GetValue("Properties", props)))
	{
		return false;
	}
	SmartScriptTable propsResurrection;
	if (!(props->GetValue("Resurrection", propsResurrection)))
	{
		return false;
	}	
	bool huskableByMastermind = false;
	if (propsResurrection->GetValue("bHuskableByMastermind", huskableByMastermind))
	{
		if (!huskableByMastermind)
		{
			return false;
		}
	}

	return true;
}
//------------------------------------------------------------------------
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;
}
//------------------------------------------------------------------------
bool CVehicleDamageBehaviorBlowTire::Init(IVehicle* pVehicle, const SmartScriptTable &table)
{
	m_pVehicle = pVehicle;  
	m_isActive = false;  
  m_aiImmobilizedTimer = -1;
  
	SmartScriptTable BlowTireParams;
	if (table->GetValue("BlowTire", BlowTireParams))
	{				
	}

  gEnv->p3DEngine->FindParticleEffect(TIRE_BLOW_EFFECT, "CVehicleDamageBehaviorBlowTire::Init");

	return true;
}
Example #28
0
	ILINE T GetProperty( SmartScriptTable pPropertiesTable, const char* propertyName, const T& defaultValue )
	{
		if ( ! pPropertiesTable )
		{
			return defaultValue;
		}

		T propertyValue = defaultValue;
		const bool hasProperty = pPropertiesTable->GetValue( propertyName, propertyValue );
		if ( ! hasProperty )
		{
			return defaultValue;
		}

		return propertyValue;
	}
Example #29
0
bool SLuaCache_ActorProperties::CacheFromTable(SmartScriptTable pEntityTable, SmartScriptTable pProperties)
{
	assert((bool)pEntityTable);

	if (!bIsCached)
	{
		bIsCached = CActor::LoadFileModelInfo(pEntityTable, pProperties, fileModelInfo);

		if (pProperties)
		{
			pProperties->GetValue("physicMassMult", fPhysicMassMult);
		}
	}

	return bIsCached;
}
Example #30
0
bool CTornado::Reset()
{
	//Initialize default values before (in case ScriptTable fails)
	m_wanderSpeed = 10.0f;
	m_cloudHeight = 376.0f;
	m_radius = 300.0f;

	m_spinImpulse = 9.0f;
	m_attractionImpulse = 13.0f;
	m_upImpulse = 18.0f;

	const char* funnelEffect = 0;

	SmartScriptTable props;
	IScriptTable* pScriptTable = GetEntity()->GetScriptTable();
	if(!pScriptTable || !pScriptTable->GetValue("Properties", props))
		return false;

	props->GetValue("fWanderSpeed", m_wanderSpeed);
	props->GetValue("fCloudHeight", m_cloudHeight);
	props->GetValue("Radius", m_radius);
		
	props->GetValue("fSpinImpulse", m_spinImpulse);
	props->GetValue("fAttractionImpulse", m_attractionImpulse);
	props->GetValue("fUpImpulse", m_upImpulse);
  
	props->GetValue("FunnelEffect", funnelEffect);
	if (!UseFunnelEffect(funnelEffect))
		return false;

	Matrix34 m = GetEntity()->GetWorldTM();
	m_wanderDir = m.GetColumn(1)*0.414214f;

	m_isOnWater = false;
	m_isInAir = false;

	m_nextEntitiesCheck = 0;

	Vec3 pos = GetEntity()->GetWorldPos();
	gEnv->pLog->Log("TORNADO INIT POS: %f %f %f", pos.x, pos.y, pos.z);
	m_points[0] = pos;
	m_points[1] = pos + Vec3(0,0,m_cloudHeight/8.0f);
	m_points[2] = pos + Vec3(0,0,m_cloudHeight/2.0f);
	m_points[3] = pos + Vec3(0,0,m_cloudHeight);
	for (int i=0; i<4; ++i)
		m_oldPoints[i] = m_points[i];

	m_currentPos = GetEntity()->GetWorldPos();
	CHANGED_NETWORK_STATE(this, POSITION_ASPECT);
	
	UpdateTornadoSpline();

	return true;
}