예제 #1
0
void CAI_Trader::g_WeaponBones	(int &L, int &R1, int &R2)
{
	CKinematics *V	= smart_cast<CKinematics*>(Visual());
	R1				= V->LL_BoneID("bip01_r_hand");
	R2				= V->LL_BoneID("bip01_r_finger2");
	L				= V->LL_BoneID("bip01_l_finger1");
}
예제 #2
0
void CObjectHandler::reinit			(CAI_Stalker *object)
{
	inherited::reinit			();
	m_hammer_is_clutched		= false;
	planner().setup				(object);
	CKinematics					*kinematics = smart_cast<CKinematics*>(planner().m_object->Visual());
	m_r_hand					= kinematics->LL_BoneID(pSettings->r_string(*planner().m_object->cNameSect(),"weapon_bone0"));
	m_l_finger1					= kinematics->LL_BoneID(pSettings->r_string(*planner().m_object->cNameSect(),"weapon_bone1"));
	m_r_finger2					= kinematics->LL_BoneID(pSettings->r_string(*planner().m_object->cNameSect(),"weapon_bone2"));
	m_strap_object_id			= ALife::_OBJECT_ID(-1);
	m_strap_bone0				= -1;
	m_strap_bone1				= -1;
	m_clutched_hammer_enabled	= false;
}
예제 #3
0
void CObjectHandler::weapon_bones	(int &b0, int &b1, int &b2) const
{
	CWeapon						*weapon = smart_cast<CWeapon*>(inventory().ActiveItem());
	if (!weapon || !planner().m_storage.property(ObjectHandlerSpace::eWorldPropertyStrapped)) {
		if (weapon)
			weapon->strapped_mode	(false);
		b0						= m_r_hand;
		b1						= m_r_finger2;
		b2						= m_l_finger1;
		return;
	}

	THROW3						(weapon->can_be_strapped(),"Cannot strap weapon",*weapon->cName());

	if (weapon->ID() != m_strap_object_id) {
		CKinematics				*kinematics = smart_cast<CKinematics*>(planner().m_object->Visual());
		m_strap_bone0			= kinematics->LL_BoneID(weapon->strap_bone0());
		m_strap_bone1			= kinematics->LL_BoneID(weapon->strap_bone1());
		m_strap_object_id		= weapon->ID();
	}

	weapon->strapped_mode		(true);
	b0							= m_strap_bone0;
	b1							= m_strap_bone1;
	b2							= b1;
}
void CStalkerAnimationManager::assign_bone_callbacks	()
{
	CKinematics						*kinematics = smart_cast<CKinematicsAnimated*>(m_visual);
	VERIFY							(kinematics);

	LPCSTR							section = *object().cNameSect();
	
	int								head_bone = kinematics->LL_BoneID(pSettings->r_string(section,"bone_head"));
	kinematics->LL_GetBoneInstance	(u16(head_bone)).set_callback(bctCustom,&head::callback,&object());

	int								shoulder_bone = kinematics->LL_BoneID(pSettings->r_string(section,"bone_shoulder"));
	kinematics->LL_GetBoneInstance	(u16(shoulder_bone)).set_callback(bctCustom,&shoulder::callback,&object());

	int								spin_bone = kinematics->LL_BoneID(pSettings->r_string(section,"bone_spin"));
	kinematics->LL_GetBoneInstance	(u16(spin_bone)).set_callback(bctCustom,&spine::callback,&object());
}
예제 #5
0
void CDamageManager::load_section(LPCSTR section,CInifile* ini)
{
	string32				buffer;
	CKinematics				*kinematics = smart_cast<CKinematics*>(m_object->Visual());
	CInifile::Sect			&damages = ini->r_section(section);
	for (CInifile::SectCIt i=damages.Data.begin(); damages.Data.end() != i; ++i) {
		if (xr_strcmp(*(*i).first,"default")) { // read all except default line
			VERIFY					(m_object);
			int						bone = kinematics->LL_BoneID(i->first);
			R_ASSERT2				(BI_NONE != bone, *(*i).first);
			CBoneInstance			&bone_instance = kinematics->LL_GetBoneInstance(u16(bone));
			bone_instance.set_param	(0,(float)atof(_GetItem(*(*i).second,0,buffer)));
			bone_instance.set_param	(1,(float)atoi(_GetItem(*(*i).second,1,buffer)));
			bone_instance.set_param	(2,(float)atof(_GetItem(*(*i).second,2,buffer)));
			if (_GetItemCount(*(*i).second) < 4)
			{
				bone_instance.set_param	(3,(float)atof(_GetItem(*(*i).second,0,buffer)));
			}
			else
			{
				bone_instance.set_param	(3,(float)atof(_GetItem(*(*i).second,3,buffer)));
			}
			if(0==bone && (fis_zero(bone_instance.get_param(0)) || fis_zero(bone_instance.get_param(2)) ) ){
				string256 error_str;
				sprintf_s(error_str,"hit_scale and wound_scale for root bone cannot be zero. see section [%s]",section);
				R_ASSERT2(0,error_str);
			}
		}
	}
}
예제 #6
0
CCarWeapon::CCarWeapon(CPhysicsShellHolder* obj)
{
	m_bActive	= false;
	m_bAutoFire	= false;
	m_object	= obj;
	m_Ammo		= xr_new<CCartridge>();

	CKinematics* K			= smart_cast<CKinematics*>(m_object->Visual());
	CInifile* pUserData		= K->LL_UserData(); 

	m_rotate_x_bone			= K->LL_BoneID	(pUserData->r_string("mounted_weapon_definition","rotate_x_bone"));
	m_rotate_y_bone			= K->LL_BoneID	(pUserData->r_string("mounted_weapon_definition","rotate_y_bone"));
	m_fire_bone				= K->LL_BoneID	(pUserData->r_string("mounted_weapon_definition","fire_bone"));
	m_min_gun_speed			= pUserData->r_float("mounted_weapon_definition","min_gun_speed");
	m_max_gun_speed			= pUserData->r_float("mounted_weapon_definition","max_gun_speed");
	CBoneData& bdX			= K->LL_GetData(m_rotate_x_bone); //VERIFY(bdX.IK_data.type==jtJoint);
	m_lim_x_rot.set			(bdX.IK_data.limits[0].limit.x,bdX.IK_data.limits[0].limit.y);
	CBoneData& bdY			= K->LL_GetData(m_rotate_y_bone); //VERIFY(bdY.IK_data.type==jtJoint);
	m_lim_y_rot.set			(bdY.IK_data.limits[1].limit.x,bdY.IK_data.limits[1].limit.y);
	

	xr_vector<Fmatrix>					matrices;
	K->LL_GetBindTransform				(matrices);
	m_i_bind_x_xform.invert				(matrices[m_rotate_x_bone]);
	m_i_bind_y_xform.invert				(matrices[m_rotate_y_bone]);
	m_bind_x_rot						= matrices[m_rotate_x_bone].k.getP();
	m_bind_y_rot						= matrices[m_rotate_y_bone].k.getH();
	m_bind_x.set						(matrices[m_rotate_x_bone].c);
	m_bind_y.set						(matrices[m_rotate_y_bone].c);

	m_cur_x_rot							= m_bind_x_rot;
	m_cur_y_rot							= m_bind_y_rot;
	m_destEnemyDir.setHP				(m_bind_y_rot,m_bind_x_rot);
	m_object->XFORM().transform_dir		(m_destEnemyDir);


	inheritedShooting::Light_Create		();
	Load								(pUserData->r_string("mounted_weapon_definition","wpn_section"));
	SetBoneCallbacks					();
	m_object->processing_activate		();

	m_weapon_h							= matrices[m_rotate_y_bone].c.y;
	m_fire_norm.set						(0,1,0);
	m_fire_dir.set						(0,0,1);
	m_fire_pos.set						(0,0,0);
}
예제 #7
0
CPhysicsShell*				P_build_Shell			(CGameObject* obj,bool not_active_state,LPCSTR	fixed_bones)
{
	U16Vec f_bones;
	if(fixed_bones){
		CKinematics* K		= smart_cast<CKinematics*>(obj->Visual());
		int count =			_GetItemCount(fixed_bones);
		for (int i=0 ;i<count; ++i){
			string64		fixed_bone;
			_GetItem		(fixed_bones,i,fixed_bone);
			f_bones.push_back(K->LL_BoneID(fixed_bone));
			R_ASSERT2(BI_NONE!=f_bones.back(),"wrong fixed bone")			;
		}
	}
	return P_build_Shell	(obj,not_active_state,f_bones);
}
예제 #8
0
void CHelicopter::DieHelicopter()
{
	if ( state() == CHelicopter::eDead )
		return;
	CEntity::Die(NULL);

	m_engineSound.stop				();

	m_brokenSound.create			(pSettings->r_string(*cNameSect(), "broken_snd"),st_Effect,sg_SourceType);
	m_brokenSound.play_at_pos		(0,XFORM().c,sm_Looped);


	CKinematics* K		= smart_cast<CKinematics*>(Visual());
	if(true /*!PPhysicsShell()*/){
		string256						I;
		LPCSTR bone;
		
		u16 bone_id;
		for (u32 i=0, n=_GetItemCount(*m_death_bones_to_hide); i<n; ++i){
			bone = _GetItem(*m_death_bones_to_hide,i,I);
			bone_id		= K->LL_BoneID	(bone);
			K->LL_SetBoneVisible(bone_id,FALSE,TRUE);
		}

		///PPhysicsShell()=P_build_Shell	(this,false);
		PPhysicsShell()->EnabledCallbacks(TRUE);
		PPhysicsShell()->set_ObjectContactCallback(CollisionCallbackDead);
		PPhysicsShell()->set_ContactCallback(ContactShotMark);
	}
	Fvector lin_vel;

	Fvector prev_pos				= PositionStack.front().vPosition;
	lin_vel.sub						(XFORM().c,prev_pos);

	if(Device.dwTimeGlobal != PositionStack.front().dwTime)
		lin_vel.div((Device.dwTimeGlobal-PositionStack.front().dwTime)/1000.0f);
	
	lin_vel.mul						(m_death_lin_vel_k);
	PPhysicsShell()->set_LinearVel	(lin_vel);
	PPhysicsShell()->set_AngularVel	(m_death_ang_vel);
	PPhysicsShell()->Enable			();
	K->CalculateBones_Invalidate	();
	K->CalculateBones				();
	setState						(CHelicopter::eDead);
	m_engineSound.stop				();
	processing_deactivate			();
	m_dead							= true;
}
예제 #9
0
void	fix_bones(LPCSTR	fixed_bones,CPhysicsShell* shell )
{
		VERIFY(fixed_bones);
		VERIFY(shell);
		CKinematics	*pKinematics = shell->PKinematics();
		VERIFY(pKinematics);
		int count =					_GetItemCount(fixed_bones);
		for (int i=0 ;i<count; ++i) 
		{
			string64					fixed_bone							;
			_GetItem					(fixed_bones,i,fixed_bone)			;
			u16 fixed_bone_id=pKinematics->LL_BoneID(fixed_bone)			;
			R_ASSERT2(BI_NONE!=fixed_bone_id,"wrong fixed bone")			;
			CPhysicsElement* E = shell->get_Element(fixed_bone_id)			;
			if(E)
				E->Fix();
		}
}
예제 #10
0
void CArtefact::OnH_A_Chield() 
{
	inherited::OnH_A_Chield		();

	StopLights();
	if (GameID() == GAME_SINGLE)
	{
		if (*m_sParticlesName) 
		{	
			CParticlesPlayer::StopParticles(m_sParticlesName, BI_NONE, true);
		}
	}
	else
	{
		CKinematics* K	= smart_cast<CKinematics*>(H_Parent()->Visual());
		if (K)
			m_CarringBoneID			= K->LL_BoneID("bip01_head");
		else
			m_CarringBoneID = u16(-1);
	}
}
예제 #11
0
void CScriptGameObject::Hit(CScriptHit *tpLuaHit)
{
	CScriptHit		&tLuaHit = *tpLuaHit;
	NET_Packet		P;
	SHit			HS;
	HS.GenHeader(GE_HIT,object().ID());										//	object().u_EventGen(P,GE_HIT,object().ID());
	THROW2			(tLuaHit.m_tpDraftsman,"Where is hit initiator??!");	//	THROW2			(tLuaHit.m_tpDraftsman,"Where is hit initiator??!");
	HS.whoID  = u16(tLuaHit.m_tpDraftsman->ID());							//	P.w_u16			(u16(tLuaHit.m_tpDraftsman->ID()));
	HS.weaponID = 0;														//	P.w_u16			(0);
	HS.dir = tLuaHit.m_tDirection;											//	P.w_dir			(tLuaHit.m_tDirection);
	HS.power = tLuaHit.m_fPower;											//	P.w_float		(tLuaHit.m_fPower);
	CKinematics		*V = smart_cast<CKinematics*>(object().Visual());		//	CKinematics		*V = smart_cast<CKinematics*>(object().Visual());
	VERIFY			(V);													//	VERIFY			(V);
	if (xr_strlen	(tLuaHit.m_caBoneName))									//	if (xr_strlen	(tLuaHit.m_caBoneName))
		HS.boneID = 		(V->LL_BoneID(tLuaHit.m_caBoneName));			//		P.w_s16		(V->LL_BoneID(tLuaHit.m_caBoneName));
	else																	//	else
		HS.boneID = 		(s16(0));										//		P.w_s16		(s16(0));
	HS.p_in_bone_space = Fvector().set(0,0,0);								//	P.w_vec3		(Fvector().set(0,0,0));
	HS.impulse = tLuaHit.m_fImpulse;										//	P.w_float		(tLuaHit.m_fImpulse);
	HS.hit_type = (ALife::EHitType)(tLuaHit.m_tHitType);					//	P.w_u16			(u16(tLuaHit.m_tHitType));
	HS.Write_Packet(P);						

	object().u_EventSend(P);
}
예제 #12
0
BOOL CHangingLamp::net_Spawn(CSE_Abstract* DC)
{
	CSE_Abstract			*e		= (CSE_Abstract*)(DC);
	CSE_ALifeObjectHangingLamp	*lamp	= smart_cast<CSE_ALifeObjectHangingLamp*>(e);
	R_ASSERT				(lamp);
	inherited::net_Spawn	(DC);
	Fcolor					clr;

	// set bone id
//	CInifile* pUserData		= K->LL_UserData(); 
//	R_ASSERT3				(pUserData,"Empty HangingLamp user data!",lamp->get_visual());
	xr_delete(collidable.model);
	if (Visual()){
		CKinematics* K		= smart_cast<CKinematics*>(Visual());
		R_ASSERT			(Visual()&&smart_cast<CKinematics*>(Visual()));
		light_bone			= K->LL_BoneID	(*lamp->light_main_bone);	VERIFY(light_bone!=BI_NONE);
		ambient_bone		= K->LL_BoneID	(*lamp->light_ambient_bone);VERIFY(ambient_bone!=BI_NONE);
		collidable.model	= xr_new<CCF_Skeleton>				(this);
		// alpet: загрузка иммунитетов из спавн-конфига
		CInifile* ini=K->LL_UserData();
		if(ini && ini->section_exist("immunities"))		CHitImmunity::LoadImmunities("immunities",ini);
	}
	fBrightness				= lamp->brightness;
	clr.set					(lamp->color);						clr.a = 1.f;
	clr.mul_rgb				(fBrightness);

	light_render			= ::Render->light_create();
	light_render->set_shadow(!!lamp->flags.is(CSE_ALifeObjectHangingLamp::flCastShadow));
	light_render->set_type	(lamp->flags.is(CSE_ALifeObjectHangingLamp::flTypeSpot)?IRender_Light::SPOT:IRender_Light::POINT);
	light_render->set_range	(lamp->range);
	light_render->set_color	(clr);
	light_render->set_cone	(lamp->spot_cone_angle);
	light_render->set_texture(*lamp->light_texture);
	light_render->set_virtual_size(lamp->m_virtual_size);

	if (lamp->glow_texture.size())	{
		glow_render				= ::Render->glow_create();
		glow_render->set_texture(*lamp->glow_texture);
		glow_render->set_color	(clr);
		glow_render->set_radius	(lamp->glow_radius);
	}

	if (lamp->flags.is(CSE_ALifeObjectHangingLamp::flPointAmbient)){
		ambient_power			= lamp->m_ambient_power;
		light_ambient			= ::Render->light_create();
		light_ambient->set_type	(IRender_Light::POINT);
		light_ambient->set_shadow(false);
		clr.mul_rgb				(ambient_power);
		light_ambient->set_range(lamp->m_ambient_radius);
		light_ambient->set_color(clr);
		light_ambient->set_texture(*lamp->m_ambient_texture);
		light_ambient->set_virtual_size(lamp->m_virtual_size);
	}

	fHealth					= lamp->m_health;

	lanim					= LALib.FindItem(*lamp->color_animator);

	CPHSkeleton::Spawn(e);
	if (smart_cast<CKinematicsAnimated*>(Visual()))	smart_cast<CKinematicsAnimated*>	(Visual())->PlayCycle("idle");
	if (smart_cast<CKinematics*>(Visual())){
		smart_cast<CKinematics*>			(Visual())->CalculateBones_Invalidate	();
		smart_cast<CKinematics*>			(Visual())->CalculateBones();
		//.intepolate_pos
	}
	if (lamp->flags.is(CSE_ALifeObjectHangingLamp::flPhysic)&&!Visual())
		Msg("! WARNING: lamp, obj name [%s],flag physics set, but has no visual",*cName());
//.	if (lamp->flags.is(CSE_ALifeObjectHangingLamp::flPhysic)&&Visual()&&!guid_physic_bone)	fHealth=0.f;
	if (Alive())			TurnOn	();
	else{
		processing_activate		();	// temporal enable
		TurnOff					();	// -> and here is disable :)
	}
	
	setVisible					((BOOL)!!Visual());
	setEnabled					((BOOL)!!collidable.model);

	return						(TRUE);
}