void APlayerCharacter::EquipSlot2() //First Equip
{
	if (UnlockedEquips >= 1)
	{
		EquippedIndex = 2;
		Equip(Equips[0]);
	}
}
Beispiel #2
0
void AddItem(CPlayer* p, int item, float amount, float clip)
{
	if(amount <= 0.0f)
		return;
    
	CHold* hold;
	int added = -1;
    
	for(int i=0; i<p->items.size(); i++)
	{
		hold = &p->items[i];
        
		if(hold->type != item)
			continue;
        
		hold->amount += amount;
		added = i;
		break;
	}
    
	if(added < 0)
	{
		CHold h(item, amount, clip);
		p->items.push_back(h);
		added = p->items.size() - 1;
	}
    
	CItemType* t = &g_itemType[item];
    
	if(p->equipped < 0 && t->equip)
		Equip(p, added, t);
    
	if(&g_player[g_localP] != p)
		return;
    
    int equippable = 0;
    CItemType* hT;
    for(int i=0; i<p->items.size(); i++)
	{
		hold = &p->items[i];
        hT = &g_itemType[hold->type];
        if(hT->equip)
            equippable ++;
    }
    
    if(equippable > 1)
        OpenAnotherView("switch item");
    
    //g_viewmode = FIRSTPERSON;
    
	RedoAmmo();
    
	char msg[16];
	sprintf(msg, "+%d", (int)amount);
	ItemIcon(t->icon, msg);
}
void InventoryContainer::OnButtonEvent(std::string selection){
	if(selection == "Equip")
		Equip();
	else if(selection == "Drop")
		Drop();
	else if(selection == "Deposit")
		Deposit();
	else if(selection == "Barter")
		Barter();
};
Beispiel #4
0
void psCharAppearance::Equip( csString& slotname,
                              csString& mesh,
                              csString& part,
                              csString& subMesh,
                              csString& texture
                             )
{

    //Bracers must be managed separately as we have two slots in cal3d but only one slot here
    //To resolve the problem we call recursively this same function with the "corrected" slot names
    //which are rightarm leftarm
    
    if (slotname == "bracers")
    {
        for(unsigned int position = 0; position < bracersSlotCount; position++)
            Equip(BracersSlots[position], mesh, part, subMesh, texture);
        return;
    }

    if ( slotname == "helm" )
    {
        ShowHair(false);
    }

    // If it's a new mesh attach that mesh.
    if ( mesh.Length() )
    {
        if( texture.Length() && !subMesh.Length() )
            Attach(slotname, mesh, texture);
        else
            Attach(slotname, mesh);
    }

    // This is a subMesh on the model change so change the mesh for that part.
    if ( subMesh.Length() )
    {
        // Change the mesh on the part of the model.
        ChangeMesh(part, subMesh);

        // If there is also a new material ( texture ) then place that on as well.
        if ( texture.Length() )
        {
            ChangeMaterial( ParseStrings(part,subMesh), texture);
        }
    }
    else if ( part.Length() )
    {
        ChangeMaterial(part, texture);
    }
}
void InventoryContainer::OnClick(){
	if(isFull)
		Equip();
};
Beispiel #6
0
int InventoryManager::InventoryCommand(bool *keys)
{
    if (keys[VC_X] || keys[VK_ESC]) //inventory look
    {
        keys[VK_ESC] = false;
        keys[VC_X] = false;

        if (mState == eEquip || mState == eDrop)
        {
            ShowInventory(-1);
            mState = eDisplay;
            return 1;
        }
        else if (mState == eDisplay)
        {
            return 0;
        }
    }

    else if (mState == eEquip)
    {
        int ret = Equip(keys);
        if (ret)
            return ret;
    }

    else if (mState == eDrop)
    {
        int ret = Drop(keys);
        if (ret)
            return ret;
    }

    else if (keys[VK_U]) //equip/unequip
    {
        EquipMessage();
        mState = eEquip;
        keys[VK_U] = false;
    }

    else if (keys[VK_D]) //drop
    {
        DropMessage();
        mState = eDrop;
        keys[VK_D] = false;
    }

    else if (keys[VK_E]) //toggle keys
    {
        mShowEquip = true;
        mShowAll = mShowInv = false;

        ShowInventory(1);
        keys[VK_E] = false;
    }
    else if (keys[VK_I]) //toggle keys
    {
        mShowInv = true;
        mShowAll = mShowEquip = false;
        ShowInventory(0);
        keys[VK_E] = false;
    }
    else if (keys[VK_A]) //toggle keys
    {
        mShowAll = !mShowAll;
        ShowInventory(-1);
        keys[VK_E] = false;
    }

    return 1;
}
bool ZShopEquipInterface::Equip(void)
{
	static unsigned long int st_LastRequestTime = 0;	///< 막 누르는 것 방지
	unsigned long int nNowTime = timeGetTime();
	if ((nNowTime - st_LastRequestTime) < 1000) return false;

	st_LastRequestTime = nNowTime;

	ZShopEquipListItem* pListItem = GetListCurSelItem("EquipmentList");
	if (!pListItem) 
	{
		ZApplication::GetGameInterface()->ShowErrorMessage( MERR_NO_SELITEM );
		return false;
	}

	// 갬블 아이템
	if (ZSEIT_GAMBLE == pListItem->GetItemData()->GetType())
	{
		ZShopEquipItem_Gamble* pWrapperGItem = (ZShopEquipItem_Gamble*)pListItem->GetItemData();
		const ZGambleItemDefine* pGItemDesc = pWrapperGItem->GetDesc();
		if (pGItemDesc)
		{
			// 이번에 캐시용 겜블아이템 추가로 수정
			// 기존 일본 요청으로 퀘스트용 겜블아이템을 추가했었음 (1000100~1000199사이)
			// 퀘스트용 겜블아이템은 1000100에서 1000200로 제한한다
			if( ZGetGameClient()->GetServerMode() != MSM_TEST && 1000100 <= pGItemDesc->GetGambleItemID()  && pGItemDesc->GetGambleItemID() < 1000200)
			{
				ZApplication::GetGameInterface()->ShowErrorMessage( MERR_CANNOT_CAHNGE_THIS_ITEM );
			}
			else
			{
				if (!pWrapperGItem->GetHandleSell()) { _ASSERT(0); return false; }
				ZPostRequestGamble( pWrapperGItem->GetHandleSell()->GetItemUID() );
				ZPostRequestCharacterItemList( ZGetGameClient()->GetPlayerUID() );
			}
		}
	}

	// 일반 아이템
	if (ZSEIT_MATCH != pListItem->GetItemData()->GetType())
	{
		return false;
	}

	ZShopEquipItem_Match* pWrappedZItem = (ZShopEquipItem_Match*)pListItem->GetItemData();
	if (!pWrappedZItem->GetHandleSell()) { _ASSERT(0); return false; }

	MUID uidItem = pWrappedZItem->GetHandleSell()->GetItemUID();
	MMatchItemDesc* pItemDesc = MGetMatchItemDescMgr()->GetItemDesc(ZGetMyInfo()->GetItemList()->GetItemID(uidItem));
	if (!pItemDesc) return false;

	if (pItemDesc->m_nSlot == MMIST_NONE)
		return false;

	MMatchCharItemParts parts = RecommendEquipParts(pItemDesc->m_nSlot);
	if (parts == MMCIP_END)
		return false;

	WidgetHideDisableShow("Equip");
	WidgetHideDisableShow("SendAccountItemBtn");

	SetKindableItem( MMIST_NONE);

	return Equip(parts, uidItem);
}
Beispiel #8
0
void psCharAppearance::ApplyEquipment(const csString& equipment)
{
    if ( equipment.Length() == 0 )
    {
        return;
    }

    csRef<iDocument> doc = xmlparser->CreateDocument();

    const char* error = doc->Parse(equipment);
    if ( error )
    {
        Error2("Error in XML: %s", error );
        return;
    }
    
    csString BaseGroup = baseMesh->GetFactory()->QueryObject()->GetName();

    // Do the helm check.
    csRef<iDocumentNode> helmNode = doc->GetRoot()->GetNode("equiplist")->GetNode("helm");
    csString helmGroup(helmNode->GetContentsValue());
    if ( helmGroup.Length() == 0 )
        helmGroup = BaseGroup;
        
    // Do the bracer check.
    csRef<iDocumentNode> BracerNode = doc->GetRoot()->GetNode("equiplist")->GetNode("bracer");
    csString BracerGroup(BracerNode->GetContentsValue());
    if ( BracerGroup.Length() == 0 )
        BracerGroup = BaseGroup;
        
    // Do the belt check.
    csRef<iDocumentNode> BeltNode = doc->GetRoot()->GetNode("equiplist")->GetNode("belt");
    csString BeltGroup(BeltNode->GetContentsValue());
    if ( BeltGroup.Length() == 0 )
        BeltGroup = BaseGroup;

    // Do the cloak check.
    csRef<iDocumentNode> CloakNode = doc->GetRoot()->GetNode("equiplist")->GetNode("cloak");
    csString CloakGroup(CloakNode->GetContentsValue());
    if ( CloakGroup.Length() == 0 )
        CloakGroup = BaseGroup;

    csRef<iDocumentNodeIterator> equipIter = doc->GetRoot()->GetNode("equiplist")->GetNodes("equip");

    while (equipIter->HasNext())
    {
        csRef<iDocumentNode> equipNode = equipIter->Next();
        csString slot = equipNode->GetAttributeValue( "slot" );
        csString mesh = equipNode->GetAttributeValue( "mesh" );
        csString part = equipNode->GetAttributeValue( "part" );
        csString partMesh = equipNode->GetAttributeValue("partMesh");
        csString texture = equipNode->GetAttributeValue( "texture" );

        //If the mesh has a $H it means it's an helm so search for replacement
        mesh.ReplaceAll("$H",helmGroup);
        //If the mesh has a $B it means it's a bracer so search for replacement
        mesh.ReplaceAll("$B",BracerGroup);
        //If the mesh has a $E it means it's a belt so search for replacement
        mesh.ReplaceAll("$E", BeltGroup);
        //If the mesh has a $C it means it's a cloak so search for replacement
        mesh.ReplaceAll("$C", CloakGroup);

        Equip(slot, mesh, part, partMesh, texture);
    }

    return;
}