예제 #1
0
파일: ai_rat_feel.cpp 프로젝트: 2asoft/xray
void CAI_Rat::feel_sound_new(CObject* who, int eType, CSound_UserDataPtr user_data, const Fvector &Position, float power)
{
	if (!g_Alive())
		return;

	if ((eType & SOUND_TYPE_WEAPON_SHOOTING) == SOUND_TYPE_WEAPON_SHOOTING)
		power = 1.f;

	if (power >= m_fSoundThreshold) {
		if ((this != who) && ((m_tLastSound.dwTime <= m_dwLastUpdateTime) || (m_tLastSound.fPower <= power))) {
			m_tLastSound.eSoundType		= ESoundTypes(eType);
			m_tLastSound.dwTime			= Device.dwTimeGlobal;
			m_tLastSound.fPower			= power;
			m_tLastSound.tSavedPosition = Position;
			m_tLastSound.tpEntity		= smart_cast<CEntityAlive*>(who);
			if ((eType & SOUND_TYPE_MONSTER_DYING) == SOUND_TYPE_MONSTER_DYING)
				m_fMorale += m_fMoraleDeathQuant;
			else
				if (((eType & SOUND_TYPE_WEAPON_SHOOTING) == SOUND_TYPE_WEAPON_SHOOTING) && !memory().enemy().selected())
					m_fMorale += m_fMoraleFearQuant;///fDistance;
				else
					if ((eType & SOUND_TYPE_MONSTER_ATTACKING) == SOUND_TYPE_MONSTER_ATTACKING)
						m_fMorale += m_fMoraleSuccessAttackQuant;///fDistance;
		}
	}

	inherited::feel_sound_new	(who,eType,user_data,Position,power);
}
예제 #2
0
//void CEntity::Hit			(float perc, Fvector &dir, CObject* who, s16 element,Fvector position_in_object_space, float impulse, ALife::EHitType hit_type) 
void	CEntity::Hit		(SHit* pHDS)
{

//	if (bDebug)				Log("Process HIT: ", *cName());

	// *** process hit calculations
	// Calc impulse
	Fvector					vLocalDir;
	float					m = pHDS->dir.magnitude();
	VERIFY					(m>EPS);
	
	// convert impulse into local coordinate system
	Fmatrix					mInvXForm;
	mInvXForm.invert		(XFORM());
	mInvXForm.transform_dir	(vLocalDir,pHDS->dir);
	vLocalDir.invert		();

	// hit impulse
	if(pHDS->impulse) HitImpulse				(pHDS->impulse,pHDS->dir,vLocalDir); // @@@: WT
	
	// Calc amount (correct only on local player)
	float lost_health = CalcCondition(pHDS->damage());

	// Signal hit
	if(BI_NONE!=pHDS->bone())	HitSignal(lost_health,vLocalDir,pHDS->who,pHDS->boneID);

	// If Local() - perform some logic
	if (Local() && !g_Alive() && !AlreadyDie() && (m_killer_id == ALife::_OBJECT_ID(-1))) {
		KillEntity	(pHDS->whoID);
	}
	//must be last!!! @slipch
	inherited::Hit(pHDS);
}
예제 #3
0
void CCustomMonster::shedule_Update	( u32 DT )
{
	VERIFY				(!g_Alive() || processing_enabled());
	// Queue shrink
	VERIFY				(_valid(Position()));
	u32	dwTimeCL		= Level().timeServer()-NET_Latency;
	VERIFY				(!NET.empty());
	while ((NET.size()>2) && (NET[1].dwTimeStamp<dwTimeCL)) NET.pop_front();

	float dt			= float(DT)/1000.f;
	// *** general stuff
	if (g_Alive()) {
		if ( false && g_mt_config.test(mtAiVision) )
#ifndef DEBUG
			Device.seqParallel.push_back	(fastdelegate::FastDelegate0<>(this,&CCustomMonster::Exec_Visibility));
#else // DEBUG
		{
			if (!psAI_Flags.test(aiStalker) || !!smart_cast<CActor*>(Level().CurrentEntity()))
				Device.seqParallel.push_back(fastdelegate::FastDelegate0<>(this,&CCustomMonster::Exec_Visibility));
			else
				Exec_Visibility				();
		}
#endif // DEBUG
		else
			Exec_Visibility					();
		memory().update						(dt);
	}
예제 #4
0
void CBaseMonster::update_eyes_visibility ()
{
	if ( !m_left_eye_bone_name )
	{
		return;
	}

	IKinematics* const skeleton	=	smart_cast<IKinematics*>(Visual());
	if ( !skeleton )
	{
		return;
	}

	u16 const left_eye_bone_id	=	skeleton->LL_BoneID(m_left_eye_bone_name);
	u16 const right_eye_bone_id	=	skeleton->LL_BoneID(m_right_eye_bone_name);

	R_ASSERT						(left_eye_bone_id != u16(-1) && right_eye_bone_id != u16(-1));

	bool eyes_visible			=	!g_Alive() || get_screen_space_coverage_diagonal() > 0.05f;

	bool const was_visible		=	!!skeleton->LL_GetBoneVisible	(left_eye_bone_id);
	skeleton->LL_SetBoneVisible		(left_eye_bone_id, eyes_visible, true);
	skeleton->LL_SetBoneVisible		(right_eye_bone_id, eyes_visible, true);

	if ( !was_visible && eyes_visible )
	{
		skeleton->CalculateBones_Invalidate();
		skeleton->CalculateBones		();
	}
}
예제 #5
0
void CBaseMonster::Hit(SHit* pHDS)
{
	if(ignore_collision_hit && (pHDS->hit_type == ALife::eHitTypeStrike)) 
		return;
	
	if(invulnerable())
		return;

	if(g_Alive())
		if(!critically_wounded()) 
			update_critical_wounded(pHDS->boneID,pHDS->power);
	
	if(pHDS->hit_type == ALife::eHitTypeFireWound)
	{
		float &hit_power = pHDS->power;
		float ap = pHDS->armor_piercing;
		// пуля пробила шкуру
		if(!fis_zero(m_fSkinArmor, EPS) && ap > m_fSkinArmor)
		{
			float d_hit_power = (ap - m_fSkinArmor) / ap;
			if(d_hit_power < m_fHitFracMonster)
				d_hit_power = m_fHitFracMonster;

			hit_power *= d_hit_power;
			VERIFY(hit_power>=0.0f);
		}
		// пуля НЕ пробила шкуру
		else
		{
			hit_power *= m_fHitFracMonster;
			pHDS->add_wound = false; 	//раны нет
		}
	}
	inherited::Hit(pHDS);
}
예제 #6
0
void CBaseMonster::UpdateCL()
{
#ifdef DEBUG
	if ( Level().CurrentEntity() == this )
	{
		DBG().get_text_tree().clear();
		add_debug_info(DBG().get_text_tree());
	}
	if ( is_paused () )
	{
		return;
	}
#endif

	if ( EatedCorpse && !CorpseMemory.is_valid_corpse(EatedCorpse) )
	{
		EatedCorpse = NULL;
	}

	inherited::UpdateCL();
	
	if ( g_Alive() ) 
	{
		update_enemy_accessible_and_at_home_info();
		CStepManager::update(false);

		update_pos_by_grouping_behaviour();
	}

	control().update_frame();

	m_pPhysics_support->in_UpdateCL();
}
void CActorMP::postprocess_packet	(net_update_A &N_A)
{

	if (!NET.empty())
		N_A.dwTimeStamp		= NET.back().dwTimeStamp;
	else
		N_A.dwTimeStamp		= Level().timeServer();

	N_A.State.previous_position	= N_A.State.position;
	N_A.State.previous_quaternion = N_A.State.quaternion;

	if (Local() && OnClient() || !g_Alive()) return;

	{
		//-----------------------------------------------
		if (!NET_A.empty() && N_A.dwTimeStamp < NET_A.back().dwTimeStamp) return;
		if (!NET_A.empty() && N_A.dwTimeStamp == NET_A.back().dwTimeStamp)
		{
			NET_A.back() = N_A;
		}
		else
		{
			VERIFY(valid_pos(N_A.State.position));
			NET_A.push_back			(N_A);
			if (NET_A.size()>5) NET_A.pop_front();
		};

		if (!NET_A.empty()) m_bInterpolate = true;
	};

	Level().AddObject_To_Objects4CrPr	(this);
	CrPr_SetActivated					(false);
	CrPr_SetActivationStep				(0);
}
예제 #8
0
void CActor::IR_OnKeyboardRelease(int cmd)
{
	if (m_blocked_actions.find((EGameActions)cmd) != m_blocked_actions.end() ) return; // Real Wolf. 14.10.2014

	if (Remote())		return;

//	if (conditions().IsSleeping())	return;
	if (m_input_external_handler && !m_input_external_handler->authorized(cmd))	return;

	if (g_Alive())	
	{
		if (cmd == kUSE) 
			PickupModeOff();

		if(m_holder)
		{
			m_holder->OnKeyboardRelease(cmd);
			
			if(m_holder->allowWeapon() && inventory().Action(cmd, CMD_STOP))		return;
			return;
		}else
			if(inventory().Action(cmd, CMD_STOP))		return;



		switch(cmd)
		{
		case kJUMP:		mstate_wishful &=~mcJump;		break;
		case kDROP:		if(GAME_PHASE_INPROGRESS == Game().Phase()) g_PerformDrop();				break;
		case kCROUCH:	g_bAutoClearCrouch = true;
		}
	}
}
bool CSE_ALifeMonsterAbstract::redundant				() const
{
	if (g_Alive())
		return					(false);

	if (m_bOnline)
		return					(false);

	if (m_story_id != INVALID_STORY_ID)
		return					(false);

	if (!m_game_death_time)
		return					(false);

	ALife::_TIME_ID				current_time = alife().time_manager().game_time();
	VERIFY2						(
		m_game_death_time <= current_time,
		make_string(
			"incorrect death time for monster %s[death time = %I64d][current time = %I64d]",
			name_replace(),
			m_game_death_time,
			current_time
		)
	);
	if ((m_game_death_time + m_stay_after_death_time_interval) > current_time)
		return					(false);

	return						(true);
}
예제 #10
0
void CActor::IR_OnKeyboardRelease(int cmd)
{
	if(hud_adj_mode && pInput->iGetAsyncKeyState(DIK_LSHIFT))	return;

	if (Remote())	return;

	if (m_input_external_handler && !m_input_external_handler->authorized(cmd))	return;

	if (g_Alive())	
	{
		if(m_holder)
		{
			m_holder->OnKeyboardRelease(cmd);
			
			if(m_holder->allowWeapon() && inventory().Action((u16)cmd, CMD_STOP))		return;
			return;
		}else
			if(inventory().Action((u16)cmd, CMD_STOP))		return;



		switch(cmd)
		{
		case kJUMP:		mstate_wishful &=~mcJump;		break;
		case kDROP:		if(GAME_PHASE_INPROGRESS == Game().Phase()) g_PerformDrop();				break;
		}
	}
}
예제 #11
0
파일: Actor.cpp 프로젝트: OLR-xray/XRay-NEW
ALife::_TIME_ID	 CActor::TimePassedAfterDeath()	const
{
	if(!g_Alive())
		return Level().timeServer() - GetLevelDeathTime();
	else
		return 0;
}
예제 #12
0
파일: Actor.cpp 프로젝트: OLR-xray/XRay-NEW
void CActor::HitSignal(float perc, Fvector& vLocalDir, CObject* who, s16 element)
{
	if (g_Alive()) 
	{

		// stop-motion
		if (character_physics_support()->movement()->Environment()==CPHMovementControl::peOnGround || character_physics_support()->movement()->Environment()==CPHMovementControl::peAtWall)
		{
			Fvector zeroV;
			zeroV.set			(0,0,0);
			character_physics_support()->movement()->SetVelocity(zeroV);
		}
		
		// check damage bone
		Fvector D;
		XFORM().transform_dir(D,vLocalDir);

		float	yaw, pitch;
		D.getHP(yaw,pitch);
		CKinematicsAnimated *tpKinematics = smart_cast<CKinematicsAnimated*>(Visual());
		VERIFY(tpKinematics);
#pragma todo("Dima to Dima : forward-back bone impulse direction has been determined incorrectly!")
		MotionID motion_ID = m_anims->m_normal.m_damage[iFloor(tpKinematics->LL_GetBoneInstance(element).get_param(1) + (angle_difference(r_model_yaw + r_model_yaw_delta,yaw) <= PI_DIV_2 ? 0 : 1))];
		float power_factor = perc/100.f; clamp(power_factor,0.f,1.f);
		VERIFY(motion_ID.valid());
		tpKinematics->PlayFX(motion_ID,power_factor);
	}
}
예제 #13
0
bool CAI_Stalker::AllowItemToTrade 					(CInventoryItem const * item, EItemPlace place) const
{
	if (!g_Alive())
		return				(trade_parameters().enabled(CTradeParameters::action_show(0),item->object().cNameSect()));

	return					(const_cast<CAI_Stalker*>(this)->can_sell(item));
}
예제 #14
0
파일: Actor.cpp 프로젝트: OLR-xray/XRay-NEW
void CActor::g_Physics			(Fvector& _accel, float jump, float dt)
{
	// Correct accel
	Fvector		accel;
	accel.set					(_accel);
	hit_slowmo					-=	dt;
	if (hit_slowmo<0)			hit_slowmo = 0.f;

	accel.mul					(1.f-hit_slowmo);
	
	if(g_Alive())
	{
	if(mstate_real&mcClimb&&!cameras[eacFirstEye]->bClampYaw)accel.set(0.f,0.f,0.f);
	character_physics_support()->movement()->Calculate			(accel,cameras[cam_active]->vDirection,0,jump,dt,false);
	bool new_border_state=character_physics_support()->movement()->isOutBorder();
	if(m_bOutBorder!=new_border_state && Level().CurrentControlEntity() == this)
	{
		SwitchOutBorder(new_border_state);
	}
	character_physics_support()->movement()->GetPosition		(Position());
	character_physics_support()->movement()->bSleep				=false;
	}

	if (Local() && g_Alive()) {
		if (character_physics_support()->movement()->gcontact_Was)
			Cameras().AddCamEffector		(xr_new<CEffectorFall> (character_physics_support()->movement()->gcontact_Power));
		if (!fis_zero(character_physics_support()->movement()->gcontact_HealthLost))	{
			const ICollisionDamageInfo* di=character_physics_support()->movement()->CollisionDamageInfo();
			Fvector hdir;di->HitDir(hdir);
			SetHitInfo(this, NULL, 0, Fvector().set(0, 0, 0), hdir);
			//				Hit	(m_PhysicMovementControl->gcontact_HealthLost,hdir,di->DamageInitiator(),m_PhysicMovementControl->ContactBone(),di->HitPos(),0.f,ALife::eHitTypeStrike);//s16(6 + 2*::Random.randI(0,2))
			if (Level().CurrentControlEntity() == this)
			{
				SHit HDS = SHit(character_physics_support()->movement()->gcontact_HealthLost,hdir,di->DamageInitiator(),character_physics_support()->movement()->ContactBone(),di->HitPos(),0.f,di->HitType());
//				Hit(&HDS);

				NET_Packet	l_P;
				HDS.GenHeader(GE_HIT, ID());
				HDS.whoID = di->DamageInitiator()->ID();
				HDS.weaponID = di->DamageInitiator()->ID();
				HDS.Write_Packet(l_P);

				u_EventSend	(l_P);
			}
		}
	}
}
예제 #15
0
bool CAI_Rat::get_alife()
{
	if (!g_Alive()) {
		m_fSpeed = m_fSafeSpeed = 0;
		return false;
	}
	return true;
}
예제 #16
0
파일: Actor.cpp 프로젝트: OLR-xray/XRay-NEW
void CActor::ForceTransform(const Fmatrix& m)
{
	if(!g_Alive())				return;
	XFORM().set					(m);
	if(character_physics_support()->movement()->CharacterExist()) character_physics_support()->movement()->EnableCharacter	();
	character_physics_support()->movement()->SetPosition		(m.c);
	character_physics_support()->movement()->SetVelocity		(0,0,0);
}
예제 #17
0
void CAI_Rat::SelectAnimation(const Fvector& /**_view/**/, const Fvector& /**_move/**/, float /**speed/**/)
{
	IKinematicsAnimated	*tpVisualObject = smart_cast<IKinematicsAnimated*>(Visual());
	MotionID			tpGlobalAnimation;

	if (!g_Alive()) {
		for (int i=0 ;i<2; ++i) {
			if (m_tRatAnimations.tNormal.tGlobal.tpaDeath[i] == m_tpCurrentGlobalAnimation) {
				tpGlobalAnimation = m_tpCurrentGlobalAnimation;
				break;
			}
		}
		if (!tpGlobalAnimation) {
			if (m_tpCurrentGlobalAnimation == m_tRatAnimations.tNormal.tGlobal.tpaIdle[1])
				tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaDeath[0];
			else
				tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaDeath[::Random.randI(0,2)];
		}
	}
	else {
		if (m_bFiring)
			tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaAttack[2];
		else
			if (angle_difference(movement().m_body.target.yaw,movement().m_body.current.yaw) <= MIN_TURN_ANGLE)
				if (m_fSpeed < 0.2f) {
					if (m_bStanding)
						tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaIdle[1];
					else
						tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaIdle[0];
				}
				else
					if (_abs(m_fSpeed - m_fAttackSpeed) < EPS_L)
						tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tRunAttack;
					else
						if (_abs(m_fSpeed - m_fMaxSpeed) < EPS_L)
							tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tRun.fwd;
						else
							tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tWalk.fwd;
			else {
				if (left_angle(-movement().m_body.target.yaw,-movement().m_body.current.yaw))
//					tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaIdle[0];
					tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpTurnLeft;
				else
//					tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaIdle[0];
					tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpTurnRight;
			}
	}

	if (tpGlobalAnimation != m_tpCurrentGlobalAnimation)
		m_tpCurrentGlobalBlend = tpVisualObject->PlayCycle(m_tpCurrentGlobalAnimation = tpGlobalAnimation);

#ifdef DEBUG
	if (psAI_Flags.is(aiAnimation)) {
		IKinematicsAnimated	*skeleton_animated = smart_cast<IKinematicsAnimated*>(Visual());
		Msg					("%6d %s animation : %s (%f,%f)",Device.dwTimeGlobal,"Global",skeleton_animated->LL_MotionDefName_dbg(m_tpCurrentGlobalAnimation),movement().m_body.current.yaw,movement().m_body.target.yaw);
	}
#endif
}
예제 #18
0
u16 CCar::Initiator()
{
	if(g_Alive() && Owner())
	{
		return Owner()->ID();
	}
	//else if(CExplosive::Initiator()!=u16(-1))return CExplosive::Initiator();
	else return ID()	;
}
예제 #19
0
파일: phantom.cpp 프로젝트: 2asoft/xray
//---------------------------------------------------------------------
//void CPhantom::Hit	(float P, Fvector &dir, CObject* who, s16 element,Fvector p_in_object_space, float impulse, ALife::EHitType hit_type)
void	CPhantom::Hit							(SHit* pHDS)
{
	if (m_TgtState==stFly)	SwitchToState(stShoot);
	if (g_Alive()){
		SetfHealth		(-1.f);
//		inherited::Hit	(P,dir,who,element,p_in_object_space,impulse/100.f, hit_type);
		inherited::Hit	(pHDS);
	}
}
예제 #20
0
void CActorMP::net_Export	(NET_Packet &packet)
{
	if (OnClient())
	{
		R_ASSERT						(g_Alive());
		R_ASSERT						(PHGetSyncItemsNumber() == 1);
	}
	m_state_holder.write			(packet);
}
예제 #21
0
//обновление состояния
float CEntity::CalcCondition(float hit)
{

	// If Local() - perform some logic
	if (Local() && g_Alive()) {
		SetfHealth			(GetfHealth()-hit);
		SetfHealth			((GetfHealth()<-1000)?-1000:GetfHealth());
	}
	return hit;
}
예제 #22
0
void CCar::ChangeCondition	(float fDeltaCondition)	
{
	
	CEntity::CalcCondition(-fDeltaCondition);
	CDamagableItem::HitEffect();
	if (Local() && !g_Alive() && !AlreadyDie())
		KillEntity	(Initiator());
//	if(Owner()&&Owner()->ID()==Level().CurrentEntity()->ID())
//		CurrentGameUI()->UIMainIngameWnd->CarPanel().SetCarHealth(GetfHealth());
}
예제 #23
0
BOOL CAI_Stalker::feel_vision_isRelevant(CObject* O)
{
	if (!g_Alive())
		return		FALSE;
	CEntityAlive*	E = smart_cast<CEntityAlive*>		(O);
	CInventoryItem*	I = smart_cast<CInventoryItem*>	(O);
	if (!E && !I)	return	(FALSE);
//	if (E && (E->g_Team() == g_Team()))			return FALSE;
	return(TRUE);
}
예제 #24
0
void CBaseMonster::ChangeTeam(int team, int squad, int group)
{
	if ((team == g_Team()) && (squad == g_Squad()) && (group == g_Group())) return;

#ifdef DEBUG
	if (!g_Alive()) {
		ai().script_engine().print_stack	();
		VERIFY2								(g_Alive(),"you are trying to change team of a dead entity");
	}
#endif // DEBUG

	// remove from current team
	monster_squad().remove_member	((u8)g_Team(),(u8)g_Squad(),(u8)g_Group(),this);
	inherited::ChangeTeam			(team,squad,group);
	monster_squad().register_member	((u8)g_Team(),(u8)g_Squad(),(u8)g_Group(), this);

	if ( m_grouping_behaviour )
	{
		m_grouping_behaviour->set_squad( monster_squad().get_squad(this) );
	}	
}
예제 #25
0
void	CHelicopter::SpawnInitPhysics	(CSE_Abstract	*D)
{

    PPhysicsShell()=P_build_Shell	(this,false);
    if(g_Alive())
    {
        PPhysicsShell()->EnabledCallbacks				(FALSE);
        PPhysicsShell()->set_ObjectContactCallback		(CollisionCallbackAlife);
        PPhysicsShell()->set_ContactCallback			(ContactCallbackAlife);
        PPhysicsShell()->Disable						();
    }
}
예제 #26
0
void CActorMP::fill_state	(actor_mp_state &state)
{
	if (OnClient())
	{
		R_ASSERT						(g_Alive());
		R_ASSERT2						(PHGetSyncItemsNumber() == 1,make_string("PHGetSyncItemsNumber() returned %d, health = %.2f",PHGetSyncItemsNumber(),GetfHealth()));
	}

	SPHNetState						State;
	PHGetSyncItem(0)->get_State		(State);

//	static test = false;
//	if (test) {
#if 0
		Msg							("Frame [%d], object [%d]",Device.dwFrame,ID());
//		Msg							("quaternion   : [%f][%f][%f][%f]",State.quaternion.x,State.quaternion.y,State.quaternion.z,State.quaternion.w);
//		Msg							("angular      : [%f][%f][%f]",State.angular_vel.x,State.angular_vel.y,State.angular_vel.z);
		Msg							("linear       : [%f][%f][%f]",State.linear_vel.x,State.linear_vel.y,State.linear_vel.z);
//		Msg							("force        : [%f][%f][%f]",State.force.x,State.force.y,State.force.z);
//		Msg							("torque       : [%f][%f][%f]",State.torque.x,State.torque.y,State.torque.z);
//		Msg							("acceleration : [%f][%f][%f]",NET_SavedAccel.x,NET_SavedAccel.y,NET_SavedAccel.z);
		Msg							("model_yaw    : [%f]",angle_normalize(r_model_yaw));
		Msg							("camera_yaw   : [%f]",angle_normalize(unaffected_r_torso.yaw));
//		Msg							("camera_pitch : [%f]",angle_normalize(unaffected_r_torso.pitch));
//		Msg							("camera_roll  : [%f]",angle_normalize(unaffected_r_torso.roll));
//	}
#endif // 0

	state.physics_quaternion		= State.quaternion;
	state.physics_angular_velocity	= State.angular_vel;
	state.physics_linear_velocity	= State.linear_vel;
	state.physics_force				= State.force;
	state.physics_torque			= State.torque;
	state.physics_position			= State.position;

	state.position					= Position();

	state.logic_acceleration		= NET_SavedAccel;

	state.model_yaw					= angle_normalize(r_model_yaw);
	state.camera_yaw				= angle_normalize(unaffected_r_torso.yaw);
	state.camera_pitch				= angle_normalize(unaffected_r_torso.pitch);
	state.camera_roll				= angle_normalize(unaffected_r_torso.roll);

	state.time						= Level().timeServer();

	state.inventory_active_slot		= inventory().GetActiveSlot();
	state.body_state_flags			= mstate_real & 0x0000ffff;
	state.health					= GetfHealth();
	state.radiation					= g_Radiation()/100.0f;
	state.physics_state_enabled		= State.enabled ? 1 : 0;
}
예제 #27
0
void CEntity::shedule_Update	(u32 dt)
{
	inherited::shedule_Update	(dt);
	if (!getDestroy() && !g_Alive() && (m_killer_id != u16(-1))) {
		if (Device.dwTimeGlobal > m_level_death_time + FORGET_KILLER_TIME) {
			m_killer_id			= u16(-1);
			NET_Packet			P;
			u_EventGen			(P,GE_ASSIGN_KILLER,ID());
			P.w_u16				(u16(-1));
			if (IsGameTypeSingle())	u_EventSend			(P);
		}
	}
}
예제 #28
0
void CBaseMonster::HitSignal(float amount, Fvector& vLocalDir, CObject* who, s16 element)
{
	if (!g_Alive()) return;
	
	feel_sound_new(who,SOUND_TYPE_WEAPON_SHOOTING,0,who->Position(),1.f);
	if (g_Alive()) sound().play(MonsterSound::eMonsterSoundTakeDamage);

	if (element < 0) return;

	// Определить направление хита (перед || зад || лево || право)
	float yaw,pitch;
	vLocalDir.getHP(yaw,pitch);
	
	yaw = angle_normalize(yaw);
	
	EHitSide hit_side = eSideFront;
	if ((yaw >= PI_DIV_4) && (yaw <= 3*PI_DIV_4)) hit_side = eSideLeft;
	else if ((yaw >= 3 * PI_DIV_4) && (yaw <= 5*PI_DIV_4)) hit_side = eSideBack;
	else if ((yaw >= 5 * PI_DIV_4) && (yaw <= 7*PI_DIV_4)) hit_side = eSideRight;

	anim().FX_Play	(hit_side, 1.0f);

	HitMemory.add_hit	(who,hit_side);

	Morale.on_hit		();

	callback(GameObject::eHit)(
		lua_game_object(), 
		amount,
		vLocalDir,
		smart_cast<const CGameObject*>(who)->lua_game_object(),
		element
	);

	// если нейтрал - добавить как врага
	CEntityAlive	*obj = smart_cast<CEntityAlive*>(who);
	if (obj && (tfGetRelationType(obj) == ALife::eRelationTypeNeutral)) EnemyMan.add_enemy(obj);
}
예제 #29
0
void CAI_Stalker::renderable_Render	()
{
	inherited::renderable_Render		();

	if (!already_dead())
		CInventoryOwner::renderable_Render	();

#ifdef DEBUG
	if (g_Alive()) {
		if (psAI_Flags.test(aiAnimationStats))
			animation().add_animation_stats	();
	}
#endif // DEBUG
}
예제 #30
0
void CActor::IR_OnKeyboardHold(int cmd)
{
	if(hud_adj_mode && pInput->iGetAsyncKeyState(DIK_LSHIFT))	return;

	if (Remote() || !g_Alive())					return;
	if (m_input_external_handler && !m_input_external_handler->authorized(cmd))	return;
	if (IsTalking())							return;

	if(m_holder)
	{
		m_holder->OnKeyboardHold(cmd);
		return;
	}

#ifdef DEBUG
	if(psActorFlags.test(AF_NO_CLIP) && (cmd==kFWD || cmd==kBACK || cmd==kL_STRAFE || cmd==kR_STRAFE 
		|| cmd==kJUMP || cmd==kCROUCH))
	{
		NoClipFly(cmd);
		return;
	}
#endif //DEBUG
	float LookFactor = GetLookFactor();
	switch(cmd)
	{
	case kUP:
	case kDOWN: 
		cam_Active()->Move( (cmd==kUP) ? kDOWN : kUP, 0, LookFactor);									break;
	case kCAM_ZOOM_IN: 
	case kCAM_ZOOM_OUT: 
		cam_Active()->Move(cmd);												break;
	case kLEFT:
	case kRIGHT:
		if (eacFreeLook!=cam_active) cam_Active()->Move(cmd, 0, LookFactor);	break;

	case kACCEL:	mstate_wishful |= mcAccel;									break;
	case kL_STRAFE:	mstate_wishful |= mcLStrafe;								break;
	case kR_STRAFE:	mstate_wishful |= mcRStrafe;								break;
	case kL_LOOKOUT:mstate_wishful |= mcLLookout;								break;
	case kR_LOOKOUT:mstate_wishful |= mcRLookout;								break;
	case kFWD:		mstate_wishful |= mcFwd;									break;
	case kBACK:		mstate_wishful |= mcBack;									break;
	case kCROUCH:
		{
			if( !psActorFlags.test(AF_CROUCH_TOGGLE) )
					mstate_wishful |= mcCrouch;

		}break;
	}
}