Пример #1
0
bool CGrenade::Action(u16 cmd, u32 flags) 
{
	if(inherited::Action(cmd, flags)) return true;

	switch(cmd) 
	{
	//переключение типа гранаты
	case kWPN_NEXT:
		{
            if(flags&CMD_START) 
			{
				if(m_pInventory)
				{
					TIItemContainer::iterator it = m_pInventory->m_ruck.begin();
					TIItemContainer::iterator it_e = m_pInventory->m_ruck.end();
					for(;it!=it_e;++it) 
					{
						CGrenade *pGrenade = smart_cast<CGrenade*>(*it);
						if(pGrenade && xr_strcmp(pGrenade->cNameSect(), cNameSect())) 
						{
							m_pInventory->Ruck			(this);
							m_pInventory->SetActiveSlot	(NO_ACTIVE_SLOT);
							m_pInventory->Slot			(pGrenade->BaseSlot(),pGrenade);
							return						true;
						}
					}
					return true;
				}
			}
			return true;
		};
	}
	return false;
}
Пример #2
0
void CGrenade::PutNextToSlot()
{
	if (OnClient()) return;

	VERIFY									(!getDestroy());
	//выкинуть гранату из инвентар¤
	NET_Packet						P;
	if (m_pInventory)
	{
		m_pInventory->Ruck					(this);

		this->u_EventGen				(P, GEG_PLAYER_ITEM2RUCK, this->H_Parent()->ID());
		P.w_u16							(this->ID());
		this->u_EventSend				(P);
	}
	else
		Msg ("! PutNextToSlot : m_pInventory = NULL [%d][%d]", ID(), Device.dwFrame);	

	if (smart_cast<CInventoryOwner*>(H_Parent()) && m_pInventory)
	{
		CGrenade *pNext						= smart_cast<CGrenade*>(	m_pInventory->Same(this,true)		);
		if(!pNext) pNext					= smart_cast<CGrenade*>(	m_pInventory->SameSlot(GRENADE_SLOT, this, true)	);

		VERIFY								(pNext != this);

		if(pNext && m_pInventory->Slot(pNext->BaseSlot(),pNext) )
		{
			pNext->u_EventGen				(P, GEG_PLAYER_ITEM2SLOT, pNext->H_Parent()->ID());
			P.w_u16							(pNext->ID());
			P.w_u16							(pNext->BaseSlot());
			pNext->u_EventSend				(P);
			m_pInventory->SetActiveSlot		(pNext->BaseSlot());
		}else
		{
			CActor* pActor = smart_cast<CActor*>( m_pInventory->GetOwner());
			
			if(pActor)
				pActor->OnPrevWeaponSlot();
		}

		m_thrown				= false;
	}
}