Exemplo n.º 1
0
void CScriptGameObject::SetQueueSize(u32 queue_size)
{
	CWeaponMagazined		*weapon = smart_cast<CWeaponMagazined*>(&object());
	if (!weapon) {
		ai().script_engine().script_log	(ScriptStorage::eLuaMessageTypeError,"CWeaponMagazined : cannot access class member SetQueueSize!");
		return;
	}
	weapon->SetQueueSize	(queue_size);
}
CInventoryItem *weapon_to_kill(const CAI_Stalker *object)
{
	if (!object->inventory().m_slots[1].m_pIItem)
		return			(object->best_weapon());

	CWeaponMagazined	*temp = smart_cast<CWeaponMagazined*>(object->inventory().m_slots[1].m_pIItem);
	if (!temp)
		return			(object->best_weapon());

	if (!temp->can_kill())
		return			(object->best_weapon());

	return				(temp);
}
void CStalkerActionPostCombatWait::initialize		()
{
	inherited::initialize	();
	
	if (object().movement().current_params().cover())
		return;

	object().movement().set_movement_type	(eMovementTypeStand);
	
	EObjectAction			action = eObjectActionAimReady1;
	if (m_storage->property(eWorldPropertyKilledWounded))
		action				= eObjectActionIdle;

	if (object().inventory().ActiveItem() && object().best_weapon() && (object().inventory().ActiveItem()->object().ID() == object().best_weapon()->object().ID()))
		object().set_goal	(action,object().best_weapon());
	else {
		if (object().inventory().ItemFromSlot(INV_SLOT_2)) {
			CWeaponMagazined				*temp = smart_cast<CWeaponMagazined*>(object().inventory().ItemFromSlot(INV_SLOT_2));
			if (object().inventory().ActiveItem() && temp && (object().inventory().ActiveItem()->object().ID() == temp->ID()))
				object().set_goal			(action,object().inventory().ItemFromSlot(INV_SLOT_2));
		}
	}

	if (m_storage->property(eWorldPropertyKilledWounded))
		return;

	if (object().memory().enemy().last_enemy() && object().memory().visual().visible_now(object().memory().enemy().last_enemy()))
		object().sight().setup				(CSightAction(object().memory().enemy().last_enemy(),true,true));
}
Exemplo n.º 4
0
// ****************************** Update actor orientation according to camera orientation
void CActor::g_cl_Orientate	(u32 mstate_rl, float dt)
{
	// capture camera into torso (only for FirstEye & LookAt cameras)
	if (eacFreeLook!=cam_active)
	{
		r_torso.yaw		=	cam_Active()->GetWorldYaw	();
		r_torso.pitch	=	cam_Active()->GetWorldPitch	();
	}
	else
	{
		r_torso.yaw		=	cam_FirstEye()->GetWorldYaw	();
		r_torso.pitch	=	cam_FirstEye()->GetWorldPitch	();
	}

	unaffected_r_torso.yaw		= r_torso.yaw;
	unaffected_r_torso.pitch	= r_torso.pitch;
	unaffected_r_torso.roll		= r_torso.roll;

	CWeaponMagazined *pWM = smart_cast<CWeaponMagazined*>(inventory().GetActiveSlot() != NO_ACTIVE_SLOT ? 
		inventory().ItemFromSlot(inventory().GetActiveSlot())/*inventory().m_slots[inventory().GetActiveSlot()].m_pIItem*/ : NULL);
	if (pWM && pWM->GetCurrentFireMode() == 1 && eacFirstEye != cam_active)
	{
		Fvector dangle = weapon_recoil_last_delta();
		r_torso.yaw		=	unaffected_r_torso.yaw + dangle.y;
		r_torso.pitch	=	unaffected_r_torso.pitch + dangle.x;
	}
	
	// если есть движение - выровнять модель по камере
	if (mstate_rl&mcAnyMove)	{
		r_model_yaw		= angle_normalize(r_torso.yaw);
		mstate_real		&=~mcTurn;
	} else {
		// if camera rotated more than 45 degrees - align model with it
		float ty = angle_normalize(r_torso.yaw);
		if (_abs(r_model_yaw-ty)>PI_DIV_4)	{
			r_model_yaw_dest = ty;
			// 
			mstate_real	|= mcTurn;
		}
		if (_abs(r_model_yaw-r_model_yaw_dest)<EPS_L){
			mstate_real	&=~mcTurn;
		}
		if (mstate_rl&mcTurn){
			angle_lerp	(r_model_yaw,r_model_yaw_dest,PI_MUL_2,dt);
		}
	}
}
bool is_snipper( u16 weaponID )
{
	CObject* O = Level().Objects.net_Find( weaponID );
	if(!O)
		return false;
	CWeaponMagazined* WM = smart_cast<CWeaponMagazined*>( O );
	if(!WM )
		return false;
	if( !WM->IsZoomed() )
		return false;
	//if( !WM->SingleShotMode() )
		//return false;
	if( !WM->IsScopeAttached() )
		return false;
	
	return true;
}
Exemplo n.º 6
0
void CActor::g_sv_Orientate(u32 /**mstate_rl/**/, float /**dt/**/)
{
	r_model_yaw		= NET_Last.o_model;

	r_torso.yaw		=	unaffected_r_torso.yaw;
	r_torso.pitch	=	unaffected_r_torso.pitch;
	r_torso.roll	=	unaffected_r_torso.roll;

	CWeaponMagazined *pWM = smart_cast<CWeaponMagazined*>(inventory().GetActiveSlot() != NO_ACTIVE_SLOT ? 
		inventory().ItemFromSlot(inventory().GetActiveSlot()) : NULL);
	if (pWM && pWM->GetCurrentFireMode() == 1/* && eacFirstEye != cam_active*/)
	{
		Fvector dangle = weapon_recoil_last_delta();
		r_torso.yaw		+=	dangle.y;
		r_torso.pitch	+=	dangle.x;
		r_torso.roll	+=	dangle.z;
	}
}
Exemplo n.º 7
0
void CStalkerActionDead::initialize		()
{
    inherited::initialize				();

    if (object().getDestroy())
        return;

    if (!fire())
        return;

    object().inventory().Action			(kWPN_FIRE,CMD_START);

    int active_slot						= object().inventory().GetActiveSlot();
    if (active_slot == 2) {
        CInventoryItem*					item = object().inventory().m_slots[active_slot].m_pIItem;
        if (item) {
            CWeaponMagazined*			weapon = smart_cast<CWeaponMagazined*>(item);
            VERIFY						(weapon);
            weapon->SetQueueSize		(weapon->GetAmmoElapsed());
        }
    }

    typedef xr_vector<CInventorySlot>	SLOTS;

    SLOTS::iterator						I = object().inventory().m_slots.begin(), B = I;
    SLOTS::iterator						E = object().inventory().m_slots.end();
    for ( ; I != E; ++I) {
        if ((I - B) == (int)object().inventory().GetActiveSlot())
            continue;

        if (!(*I).m_pIItem)
            continue;

        if ((*I).m_pIItem->object().CLS_ID == CLSID_IITEM_BOLT)
            continue;

        object().inventory().Ruck		((*I).m_pIItem);
    }
}