Exemplo n.º 1
0
void APlayerCharacter::Use_Implementation()
{
	AInventoryItem* Isusable = GetUsableItemInView();
	if(Isusable)
	{
		if (ItemInventoryStructure.Num() < 5)
		{
			if (!ItemInventoryStructure.Contains(Isusable->ItemInfo))
			{
				GiveItem(Isusable->ItemInfo); // Add the item to our inventory
								  //Isusable->ItemUsed(this);
				Isusable->Destroy(); // Destroy the physical version of the item
			}
			else
			{
				printMSG(TEXT("You Already Have This Item!"), 2.0);
				//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("You already have this item.")));
			}
		}else
		{
			printMSG(TEXT("Your Inventory Is Full"), 2.0);
		}
	}
	
}
// Presumably received item data back from Aujard.
void CUser::RecvStoreClose(Packet & pkt)
{
	Packet result(WIZ_SHOPPING_MALL, uint8(STORE_CLOSE));
	uint8 bResult = pkt.read<uint8>();

	// If it was succesful, i.e. it loaded data, give it to us
	if (bResult)
	{
		uint16 count = pkt.read<uint16>();
		for (int i = 0; i < count; i++)
		{
			uint32 nItemID; uint16 sCount;
			pkt >> nItemID >> sCount;

			// reuse the GiveItem() method for giving them the item, just don't send that particular packet.
			GiveItem(nItemID, sCount, false); 
		}

		SendItemWeight();
	}

	for (int i = 0; i < INVENTORY_TOTAL; i++)
	{
		result	<< m_sItemArray[i].nNum
				<< m_sItemArray[i].sDuration
				<< m_sItemArray[i].sCount
				<< uint8(0) // item type flag (e.g. rented)
				<< uint16(0) // remaining time
				<< uint32(0) // unknown
				<< uint32(0); // expiration date
	}

	Send(&result);
}
Exemplo n.º 3
0
void APlayerCharacter::PerformUsedAction()
{
	if (bIsWithinItemRange && FocusedItem != nullptr) // If we are within the pickup range of an item and we are focused on a item
	{
		GiveItem(FocusedItem->ItemInfo); // Add the item to our inventory
		FocusedItem->Destroy(); // Destroy the physical version of the item
		bIsWithinItemRange = false;
		FocusedItem = nullptr;
	}
}
Exemplo n.º 4
0
	//******** EVERYTHING LOOKS GOOD********* //
	//*****SO WE GIVE THE DONATION REWARD ****//
	void giving_proccess(Creature *_Creature,Player *player, uint32 templateid, uint32 cartid)
	{
		QueryResult pResult = WorldDatabase.PQuery("SELECT type,givemoney FROM `store`.store_template WHERE store_templateID = '%u'", templateid);
		if(pResult)
		{
			Field* field = pResult->Fetch();
			uint32 flagbinary = field[0].GetInt32();
			if(flagbinary >= 16) // other = 8
			{
				GiveItemSet(_Creature, player, cartid,1);
				flagbinary -= 16;
			}		
			if(flagbinary >= 8) // other = 8
			{
				GiveProfessionSkillOrLevel(player, _Creature, templateid);
				flagbinary -= 8;
			}
			
			if(flagbinary >= 4)					//money
			{	
				_Creature->MonsterWhisper("Money", player->GetGUID());
				player->ModifyMoney(field[1].GetInt32());
				flagbinary -= 4;
			}
			
			if(flagbinary >= 2 || flagbinary >= 1 )					//itemset = 1 and items
			{	
				GiveItemSet(_Creature, player, templateid,0);
				//GiveItem(_Creature, player, templateid);  
				//flagbinary -= 2;
			}	

				//Normal Items is last because its the lowest number
			if(flagbinary >= 1)
			{ 
				GiveItem(_Creature, player, templateid);  
			}
		}
	}
// Presumably received item data back from Aujard.
void CUser::RecvStoreClose(char *pData)
{
	char send_buff[2048];
	int index = 0, send_index = 0;
	BYTE result = GetByte(pData, index);

	// If it was succesful, i.e. it loaded data, give it to us
	if (result)
	{
		short count = GetShort(pData, index);
		for (int i = 0; i < count; i++)
		{
			int nItemID = GetDWORD(pData, index);
			short sCount = GetShort(pData, index);

			// reuse the GiveItem() method for giving them the item, just don't send that particular packet.
			GiveItem(nItemID, sCount, false); 
		}
	}
	
	SetByte(send_buff, WIZ_SHOPPING_MALL, send_index);
	SetByte(send_buff, STORE_CLOSE, send_index);

	// not sure if this limit's correct
	for (int i = 0; i < HAVE_MAX + SLOT_MAX + COSP_MAX + MBAG_MAX; i++)
	{
		SetDWORD(send_buff, m_pUserData->m_sItemArray[i].nNum, send_index);
		SetShort(send_buff, m_pUserData->m_sItemArray[i].sDuration, send_index);
		SetShort(send_buff, m_pUserData->m_sItemArray[i].sCount, send_index);
		SetByte(send_buff, 0, send_index);  // item type flag (e.g. rented)
		SetShort(send_buff, 0, send_index); // remaining time
		SetDWORD(send_buff, 0, send_index); // unknown
		SetDWORD(send_buff, 0, send_index); // expiration date
	}

	Send(send_buff, send_index);
}
Exemplo n.º 6
0
BOOL CUser::RunEvent(EVENT_DATA *pEventData)
{
	EXEC* pExec = NULL;
	list<EXEC*>::iterator	Iter;

	for( Iter = pEventData->m_arExec.begin(); Iter != pEventData->m_arExec.end(); Iter++ ) 
	{
		pExec = (*Iter);
		if( !pExec ) break;

		switch(pExec->m_Exec){
			case EXEC_SAY:
				SendNpcSay( pExec );
				break;

			case	EXEC_SELECT_MSG:
				SelectMsg( pExec );
				break;

			case	EXEC_RUN_EVENT:
				{
					EVENT* pEvent = NULL;
					EVENT_DATA* pEventData = NULL;				

					pEvent = m_pMain->m_Event.GetData(m_pUserData->m_bZone);
					if(!pEvent)	break;

					pEventData = pEvent->m_arEvent.GetData(pExec->m_ExecInt[0]);
					if(!pEventData) break;

					if( !CheckEventLogic(pEventData) )	break;

					if( !RunEvent(pEventData) ){
						return FALSE;
					}
				}
				break;

			case	EXEC_GIVE_ITEM:
				if ( !GiveItem(pExec->m_ExecInt[0], pExec->m_ExecInt[1]) )
					return FALSE;
				break;

			case	EXEC_ROB_ITEM:
				if ( !RobItem(pExec->m_ExecInt[0], pExec->m_ExecInt[1]) )
					return FALSE;
				break;

			case	EXEC_GIVE_NOAH:
				GoldGain(pExec->m_ExecInt[0]);
				break;

			case	EXEC_SAVE_COM_EVENT:
				SaveComEvent(pExec->m_ExecInt[0]);
				break;

			case	EXEC_ROB_NOAH:
				GoldLose(pExec->m_ExecInt[0]);
				break;
//
			case	EXEC_RETURN:
				return FALSE;
				break;

/*
			case EXEC_SAY:		
				break;

			case EXEC_SELECT_MSG:
				SelectMsg( pExec );
				break;

			case EXEC_RUN_EVENT:
				{								
					EVENT* pEvent = NULL;
					pEvent = m_pMain->m_Quest.GetData(m_pUserData->m_bZone);
					if(!pEvent)	break;

					EVENT_DATA* pEventData = NULL;
					pEventData = pEvent->m_arEvent.GetData(pExec->m_ExecInt[0]);
					if(!pEventData) break;

					if( !CheckEventLogic(pEventData) )	break;

					if( !RunEvent(pEventData) ) {
						return FALSE;
					}
				}
				break;

			case EXEC_ROB_NOAH:
				break;

			case EXEC_GIVE_QUEST:
				break;

			case EXEC_QUEST_END:		
				break;

			case EXEC_QUEST_SAVE:
				break;

			case EXEC_RETURN:
				return FALSE;
/////// These events are for the test quest. ///////
			case EXEC_ROB_ITEM:
				if (!RobItem(pExec->m_ExecInt[0], pExec->m_ExecInt[1])) {
					return FALSE;	
				}
				break;

			case EXEC_GIVE_ITEM:
				if (!GiveItem(pExec->m_ExecInt[0], pExec->m_ExecInt[1])) {
					return FALSE;
				}
				break;
*/

			default:
				break;
		}
	}

	return TRUE;
}
Exemplo n.º 7
0
bool CUser::RunExchange(int nExchangeID)
{
	_ITEM_EXCHANGE * pExchange = g_pMain->m_ItemExchangeArray.GetData(nExchangeID);

	// Does the exchange exist?
	if (pExchange == nullptr
		// Is it a valid exchange (do we have room?)
		|| !CheckExchange(nExchangeID)
		// We handle flags from 0-101 only. Anything else is broken.
		|| pExchange->bRandomFlag > 101
		// Do we have all of the required items?
		|| !CheckExistItemAnd(
			pExchange->nOriginItemNum[0], pExchange->sOriginItemCount[0], 
			pExchange->nOriginItemNum[1], pExchange->sOriginItemCount[1], 
			pExchange->nOriginItemNum[2], pExchange->sOriginItemCount[2], 
			pExchange->nOriginItemNum[3], pExchange->sOriginItemCount[3], 
			pExchange->nOriginItemNum[4], pExchange->sOriginItemCount[4])
		// These checks are a little pointless, but remove the required items as well.
		|| !RobItem(pExchange->nOriginItemNum[0], pExchange->sOriginItemCount[0])
		|| !RobItem(pExchange->nOriginItemNum[1], pExchange->sOriginItemCount[1])
		|| !RobItem(pExchange->nOriginItemNum[2], pExchange->sOriginItemCount[2])
		|| !RobItem(pExchange->nOriginItemNum[3], pExchange->sOriginItemCount[3])
		|| !RobItem(pExchange->nOriginItemNum[4], pExchange->sOriginItemCount[4]))
		return false;
		
	// No random element? We're just exchanging x items for y items.
	if (!pExchange->bRandomFlag)
	{
		for (int i = 0; i < ITEMS_IN_EXCHANGE_GROUP; i++)
		    GiveItem(pExchange->nExchangeItemNum[i], pExchange->sExchangeItemCount[i]);
	}
	// For these items the rate set by bRandomFlag.
	else if (pExchange->bRandomFlag <= 100)
	{
		int rand = myrand(0, 1000 * pExchange->bRandomFlag) / 1000;
		if (rand == 5)
			rand = 4;

		if (rand <= 4)
			GiveItem(pExchange->nExchangeItemNum[rand], pExchange->sExchangeItemCount[rand]);
	}
	// For 101, the rates are determined by sExchangeItemCount.
	else if (pExchange->bRandomFlag == 101)
	{
		uint32 nTotalPercent = 0;
		for (int i = 0; i < ITEMS_IN_EXCHANGE_GROUP; i++)
			nTotalPercent += pExchange->sExchangeItemCount[i];

		// If they add up to more than 100%, 
		if (nTotalPercent > 10000)
		{
			TRACE("Exchange %d is invalid. Rates add up to more than 100%% (%d%%)", nExchangeID, nTotalPercent / 100);
			return false;
		}

		// Holy stack batman! We're just going ahead and copying official for now.
		// NOTE: Officially they even use 2 bytes per element. Yikes.
		uint8 bRandArray[10000];
		memset(&bRandArray, 0, sizeof(bRandArray)); // default to 0 in case it's lower than 100% (in which case, first item's rate increases)

		// Copy the counts, as we're going to adjust them locally.
		uint16 sExchangeCount[ITEMS_IN_EXCHANGE_GROUP];

		memcpy(&sExchangeCount, &pExchange->sExchangeItemCount, sizeof(pExchange->sExchangeItemCount));

		// Build array of exchange item slots (0-4)
		int offset = 0;
		for (int n = 0, i = 0; n < 5; n++)
		{
			if (sExchangeCount[n] > 0)
			{
				memset(&bRandArray[offset], n, sExchangeCount[n]);
				offset += sExchangeCount[n];
			}
		}

		// Pull our exchange item slot out of our hat (the array we generated).
		uint8 bRandSlot = bRandArray[myrand(0, 9999)];
		uint32 nItemID = pExchange->nExchangeItemNum[bRandSlot];

		// Finally, give our item.
		GiveItem(nItemID, 1);
	}

	return true;
}
Exemplo n.º 8
0
//---------------------------------------------------------------------------------
// Purpose: Level has initialised
//---------------------------------------------------------------------------------
void		ManiWarmupTimer::PlayerSpawn(player_t *player_ptr)
{
	if (war_mode) return;
	if (mani_warmup_timer.GetInt() == 0) return;
	if (!check_timer) return;
	if (!gpManiGameType->IsValidActiveTeam(player_ptr->team)) return;
	if (fire_restart == false) return;

	respawn_list[player_ptr->index - 1].needs_respawn = false;

	if (player_ptr->is_bot)
	{
		if (mani_warmup_timer_knives_only.GetInt() == 1)
		{
			// Set cash to zero and strip weapons
			Prop_SetVal(player_ptr->entity, MANI_PROP_ACCOUNT, 0);
			CBaseEntity *pPlayer = player_ptr->entity->GetUnknown()->GetBaseEntity();
			CBaseCombatCharacter *pCombat = CBaseEntity_MyCombatCharacterPointer(pPlayer);

			CBaseCombatWeapon *pWeapon1 = CBaseCombatCharacter_Weapon_GetSlot(pCombat, 0);
			CBaseCombatWeapon *pWeapon2 = CBaseCombatCharacter_Weapon_GetSlot(pCombat, 1);
			CBasePlayer *pBase = (CBasePlayer*) pPlayer;
			if (pWeapon1)
			{
				CBasePlayer_RemovePlayerItem(pBase, pWeapon1);
			}

			if (pWeapon2)
			{
				CBasePlayer_RemovePlayerItem(pBase, pWeapon2);
			}

			CBaseCombatWeapon *pWeapon = CBaseCombatCharacter_Weapon_GetSlot(pCombat, 2);
			if (pWeapon)
			{
				CBaseCombatCharacter_Weapon_Switch(pCombat, pWeapon, 0);
			}

			CBaseEntity *weaponc4 = (CBaseEntity*)CGlobalEntityList_FindEntityByClassname(NULL, "weapon_c4");
			if (weaponc4)
			{
				CCSUTILRemove(weaponc4);
			}
		}
	}

	// Unlimited grenades
	if (mani_warmup_timer_unlimited_grenades.GetInt() == 1 && (gpManiGameType->IsGameType(MANI_GAME_CSS) || gpManiGameType->IsGameType(MANI_GAME_CSGO)))
	{
		GiveItem(player_ptr->entity, "weapon_hegrenade");
	}

	for (int i = 0; i < 5; i ++)
	{
		if (item_name[i][0] != '\0')
		{
			// Ignore assault suit if not CSS
			if (i == 0 && 
				(!gpManiGameType->IsGameType(MANI_GAME_CSS) && !gpManiGameType->IsGameType(MANI_GAME_CSGO)) &&
				strcmp(item_name[i], "item_assaultsuit") == 0)
			{
				continue;
			}

			GiveItem(player_ptr->entity, item_name[i]);
		}
	}
}
Exemplo n.º 9
0
LRESULT CALLBACK Fq4EditorWindow::OnCommand( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    int wmId = LOWORD( wParam );
    switch ( wmId )
    {
    case IDM_KINGS:
        {
            int count = GiveTeam( m_kingDatas );
            std::wstring&& message = LogTeamResult( count, m_kingDatas.size() );
            MessageBox( hWnd, message.c_str(), L"國王們", MB_OK );
        }
        break;

    case IDM_FOREST:
        {
            int count = GiveTeam( m_forestDatas );
            std::wstring&& message = LogTeamResult( count, m_forestDatas.size() );
            MessageBox( hWnd, message.c_str(), L"森林國 雷斯達", MB_OK );
        }
        break;

    case IDM_ELF:
        {
            int count = GiveTeam( m_elfDatas );
            std::wstring&& message = LogTeamResult( count, m_elfDatas.size() );
            MessageBox( hWnd, message.c_str(), L"精靈國 薩內多", MB_OK );
        }
        break;

    case IDM_MINE:
        {
            int count = GiveTeam( m_mineDatas );
            std::wstring&& message = LogTeamResult( count, m_mineDatas.size() );
            MessageBox( hWnd, message.c_str(), L"礦山國 格林斯", MB_OK );
        }
        break;

    case IDM_SEA:
        {
            int count = GiveTeam( m_seaDatas );
            std::wstring&& message = LogTeamResult( count, m_seaDatas.size() );
            MessageBox( hWnd, message.c_str(), L"海盜國 慕尼頓", MB_OK );
        }
        break;

    case IDM_PLAIN_MAGICIAN:
        {
           int count = GiveTeam( m_plainMagicianDatas );
           std::wstring&& message = LogTeamResult( count, m_plainMagicianDatas.size() );
           MessageBox( hWnd, message.c_str(), L" 平原國 休利亞(魔法軍團)", MB_OK );
        }
        break;

    case IDM_PLAIN_KNIGHT:
        {
            int count = GiveTeam( m_plainKnightDatas );
            std::wstring&& message = LogTeamResult( count, m_plainKnightDatas.size() );
            MessageBox( hWnd, message.c_str(), L"平原國 休利亞(騎士軍團)", MB_OK );
        }
        break;

    case IDM_ITEM:
        {
            GiveItem();
            MessageBox( hWnd, L"所有道具 +10", L"ITEM", MB_OK );
        }
        break;

    case IDM_MONEY:
        {
            GiveMoney();
            MessageBox( hWnd, L"獲得 $10000", L"MONEY", MB_OK );
        }
        break;

    case IDM_TIRED:
        {
            ReleaseFatigue();
        }
    break;

    default:
        return EditorWindow::OnCommand( hWnd, message, wParam, lParam );
    }

    return 0;
}