Exemple #1
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 CStalkerActionDangerGrenadeTakeCover::execute							()
{
	inherited::execute		();
	if (!object().memory().danger().selected())
		return;

	const CCoverPoint		*point = object().agent_manager().member().member(&object()).cover();
	if (point) {
		object().movement().set_level_dest_vertex	(point->level_vertex_id());
		object().movement().set_desired_position	(&point->position());
	}	
	else
		object().movement().set_nearest_accessible_position	();

	EMentalState				temp;
	{
		if (!object().inventory().ActiveItem()) {
			object().CObjectHandler::set_goal			(eObjectActionIdle);
			temp										= eMentalStatePanic;
		}
		else {
			CWeapon					*weapon = smart_cast<CWeapon*>(&object().inventory().ActiveItem()->object());
			if (weapon && weapon->can_be_strapped() && object().best_weapon() && (object().best_weapon()->object().ID() == weapon->ID())) {
				object().CObjectHandler::set_goal			(eObjectActionStrapped,object().inventory().ActiveItem());
				if (weapon->strapped_mode())
					temp									= eMentalStatePanic;
				else
					temp									= eMentalStateDanger;
			}
			else {
				object().CObjectHandler::set_goal			(eObjectActionIdle);
				temp										= eMentalStateDanger;
			}
		}
	}

	if (!object().movement().path_completed()) {
		object().movement().set_body_state			(eBodyStateStand);
		if (object().movement().distance_to_destination_greater(2.f)) {
			object().movement().set_mental_state	(temp);
			object().sight().setup					(CSightAction(SightManager::eSightTypePathDirection,true,true));
		}
		else {
			object().movement().set_mental_state	(eMentalStateDanger);
			object().sight().setup					(CSightAction(SightManager::eSightTypeCover,true,true));
		}
		return;
	}

	set_property								(eWorldPropertyCoverReached,true);
}