示例#1
0
bool CInventory::ReplaceItem(idEntity* oldItemEnt, idEntity* newItemEnt)
{
	if (oldItemEnt == NULL) return false;

	idStr oldInvName = oldItemEnt->spawnArgs.GetString("inv_name");

	CInventoryItemPtr oldItem = GetItem(oldInvName);

	if (oldItem == NULL)
	{
		gameLocal.Warning("Could not find old inventory item for %s", oldItemEnt->name.c_str());
		DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING("Could not find old inventory item for %s\n", oldItemEnt->name.c_str());
		return false;
	}

	// greebo: Let's call PutItem on the new entity first to see what kind of item this is
	// PutItem will also take care of the mission data callbacks for the objectives
	CInventoryItemPtr newItem = PutItem(newItemEnt, m_Owner.GetEntity());

	if (newItem != NULL && newItem->Category() == oldItem->Category())
	{
		// New item has been added, swap the old and the new one to fulfil the inventory position guarantee
		oldItem->Category()->SwapItemPosition(oldItem, newItem);
	}
	
	// If SwapItemPosition has been called, newItem now takes the place of oldItem before the operation.
	// Remove the old item in any case, but only if the items are actually different.
	// In case anybody wonder, newItem might be the same as oldItem in the case of stackable items or loot.
	if (oldItem != newItem)
	{
		RemoveItem(oldItem);
	}

	return true;
}
示例#2
0
// Add an augment to the item
void EQEmu::ItemInstance::PutAugment(uint8 slot, const ItemInstance& augment)
{
	if (!m_item || !m_item->IsClassCommon())
		return;
	
	PutItem(slot, augment);
}
示例#3
0
void CEventManager::PutPendingEvent(LPCVOID lpcEvData, DWORD cbEventSize)
{
	CEventItem* pItem = GetFreeItem(cbEventSize);
	memcpy(pItem->GetData(), lpcEvData, cbEventSize);

	PutItem(pItem);
}
示例#4
0
void CInventory::CopyPersistentItemsFrom(const CInventory& sourceInventory, idEntity* newOwner)
{
	// Obtain the weapon category for this inventory
	CInventoryCategoryPtr weaponCategory = GetCategory(TDM_PLAYER_WEAPON_CATEGORY);

	// Cycle through all categories to add them
	for ( int c = 0 ; c < sourceInventory.GetNumCategories() ; ++c )
	{
		const CInventoryCategoryPtr& category = sourceInventory.GetCategory(c);

		for ( int itemIdx = 0 ; itemIdx < category->GetNumItems() ; ++itemIdx )
		{
			const CInventoryItemPtr& item = category->GetItem(itemIdx);

			if (item->GetPersistentCount() <= 0)
			{
				DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING(
					"Item %s is not marked as persistent, won't add to player inventory.\r",
					common->Translate(item->GetName().c_str()));

				continue; // not marked as persistent
			}

			// Check if the shop handled that item already
			const idDict* itemDict = item->GetSavedItemEntityDict();

			if (itemDict != NULL)
			{
				CShopItemPtr shopItem = gameLocal.m_Shop->FindShopItemDefByClassName(itemDict->GetString("classname"));

				if ( (shopItem != NULL) && (CShop::GetQuantityForItem(item) > 0) )
				{
					// grayman #3723 - if there's no shop in this mission,
					// then we can't rely on it to process this inventory item.

					if ( gameLocal.m_Shop->ShopExists() )
					{
						DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING(
								"Item %s would be handled by the shop, won't add that to player inventory.\r",
								common->Translate(item->GetName().c_str()));
						continue;
					}
				}
			}

			// Is set to true if we should add this item.
			// For weapon items with ammo this will be set to false to prevent double-additions
			bool addItem = true;

			// Handle weapons separately, otherwise we might end up with duplicate weapon items
			CInventoryWeaponItemPtr weaponItem = boost::dynamic_pointer_cast<CInventoryWeaponItem>(item);

			if (weaponItem && weaponCategory)
			{
				// Weapon items need special consideration. For arrow-based weapons try to merge the ammo.
				for ( int w = 0 ; w < weaponCategory->GetNumItems() ; ++w )
				{
					CInventoryWeaponItemPtr thisWeapon = boost::dynamic_pointer_cast<CInventoryWeaponItem>(weaponCategory->GetItem(w));

					if (!thisWeapon)
					{
						continue;
					}

					if (thisWeapon->GetWeaponName() == weaponItem->GetWeaponName())
					{
						// Prevent adding this item, we already have one
						addItem = false;

						// Found a matching weapon, does it use ammo?
						if (thisWeapon->NeedsAmmo())
						{
							DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING(
								"Adding persistent ammo %d to player weapon %s.\r",
								weaponItem->GetAmmo(), thisWeapon->GetWeaponName().c_str());

							// Add the persistent ammo count to this item
							thisWeapon->SetAmmo(thisWeapon->GetAmmo() + weaponItem->GetAmmo());
						}
						else 
						{
							// Doesn't need ammo, check enabled state
							if (weaponItem->IsEnabled() && !thisWeapon->IsEnabled())
							{
								DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING(
									"Enabling weapon item %s as the persistent inventory contains an enabled one.\r",
									thisWeapon->GetWeaponName().c_str());

								thisWeapon->SetEnabled(true);
							}
						}

						break;
					}
				}
			}

			if (addItem)
			{
				DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING(
					"Adding persistent item %s to player inventory, quantity: %d.\r",
					common->Translate(item->GetName().c_str()), item->GetPersistentCount());

				item->SetOwner(newOwner);

				// Add this item to our inventory
				PutItem(item, item->Category()->GetName());

				// If we didn't have a weapon category at this point, we should be able to get one now
				if (weaponItem && !weaponCategory)
				{
					weaponCategory = GetCategory(TDM_PLAYER_WEAPON_CATEGORY);
				}
			}
		}
	}
}
示例#5
0
CInventoryItemPtr CInventory::PutItem(idEntity *ent, idEntity *owner)
{
	// Sanity checks
	if (ent == NULL || owner == NULL) return CInventoryItemPtr();

	// grayman (#2376) - If there's a shop with this item in it,
	// and this is an inv_map_start item, we won't put it into the
	// inventory because the player already has it. 

	const ShopItemList& startingItems = gameLocal.m_Shop->GetPlayerStartingEquipment();
	bool gotFromShop = ((startingItems.Num() > 0) && (ent->spawnArgs.GetBool("inv_map_start", "0")));

	// Check for loot items
	CInventoryItemPtr returnValue = ValidateLoot(ent,gotFromShop); // grayman (#2376)

	if (ent->GetAbsenceNoticeability() > 0)
	{
		ent->SpawnAbsenceMarker();
	}

	if (returnValue != NULL)
	{
		// The item is a valid loot item, remove the entity and return
		DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING("Added loot item to inventory: %s\r", ent->name.c_str());

		// Remove the entity, it is a loot item (which vanishes when added to the inventory)
		RemoveEntityFromMap(ent, true);

		return returnValue;
	}

	// Let's see if this is an ammunition item
	returnValue = ValidateAmmo(ent,gotFromShop); // grayman (#2376)

	if (returnValue != NULL)
	{
		DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING("Added ammo item to inventory, removing from map: %s\r", ent->name.c_str());

		// Remove the entity from the game, the ammunition is added
		RemoveEntityFromMap(ent, true);

		return returnValue;
	}

	// Check for a weapon item
	returnValue = ValidateWeapon(ent,gotFromShop); // grayman (#2376)

	if (returnValue != NULL)
	{
		DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING("Added weapon item to inventory, removing from map: %s\r", ent->name.c_str());

		// Remove the entity from the game, the ammunition is added
		RemoveEntityFromMap(ent, true);

		return returnValue;
	}

	// Not a loot or ammo item, determine name and category to check for existing item of same name/category
	idStr name = ent->spawnArgs.GetString("inv_name", "");
	idStr category = ent->spawnArgs.GetString("inv_category", "");
	// Tels: Replace "\n" with \x0a, otherwise multiline spawnargs set inside DR do not work
	name.Replace( "\\n", "\n" );
	category.Replace( "\\n", "\n" );

	if (name.IsEmpty() || category.IsEmpty())
	{
		// Invalid inv_name or inv_category
		DM_LOG(LC_INVENTORY, LT_ERROR)LOGSTRING("Cannot put %s in inventory: inv_name or inv_category not specified.\r", ent->name.c_str());
		return returnValue;
	}

	// Check for existing items (create the category if necessary (hence the TRUE))
	CInventoryItemPtr existing = GetItem(name, category, true);

	if (existing != NULL)
	{
		// Item must be stackable, if items of the same name/category already exist
		if (!ent->spawnArgs.GetBool("inv_stackable", "0"))
		{
			DM_LOG(LC_INVENTORY, LT_ERROR)LOGSTRING("Cannot put %s in inventory: not stackable.\r", ent->name.c_str());

			// grayman #2467 - Remove the entity from the game if it was already put into the inventory by the shop code.

			if (gotFromShop)
			{
				RemoveEntityFromMap(ent, true);
			}

			return returnValue;
		}

		// Item is stackable, determine how many items should be added to the stack
		int count = ent->spawnArgs.GetInt("inv_count", "1");
		
		// grayman (#2376) - If there's a shop in this mission, all stackable inv_map_start items were shown in
		// the shop's startingItems list, and have already been given to the player. Check if this
		// entity is an inv_map_start entity. If it is, check the size of the startingItems list.
		// If it's 0, then there's no shop and we have to give the player the count from this
		// entity. If > 0, zero the count because the player already has it.

		if (gotFromShop)
		{
			count = 0;	// Item count already given, so clear it.
		}

		// Increase the stack count
		existing->SetCount(existing->GetCount() + count);

		// Persistent flags are latched - once a inv_persistent item is added to a stack, the whole stack
		// snaps into persistent mode.
		if (ent->spawnArgs.GetBool("inv_persistent") && !existing->IsPersistent())
		{
			DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING("Marking stackable items as persistent after picking up one persistent item: %s\r", existing->GetName().c_str());
			existing->SetPersistent(true);
		}

		// We added a stackable item that was already in the inventory
		// grayman #3315 - Solution from Zbyl. InventoryCallback() looks at
		// the existing entity to retrieve a bindmaster, and that's already
		// been NULLed. So we need to look at the new entity instead.
		gameLocal.m_MissionData->InventoryCallback(
			ent,
			existing->GetName(), 
			existing->GetCount(), 
			1, 
			true
		);

		// Notify the player, if appropriate
		// grayman #3316 - correct pickup message, courtesy Zbyl
		if ( !ent->spawnArgs.GetBool("inv_map_start", "0") && !ent->spawnArgs.GetBool("inv_no_pickup_message", "0") )
		{
			idStr msg = common->Translate(name);

			if ( count > 1 ) 
			{
				msg += " x" + idStr(count);
			}

			NotifyOwnerAboutPickup(msg, existing);
		}
		
		DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING("Added stackable item to inventory: %s\r", ent->name.c_str());
		DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING("New inventory item stack count is: %d\r", existing->GetCount());

		// Remove the entity, it has been stacked
		RemoveEntityFromMap(ent, true);

		// Return the existing value instead of a newly created one
		returnValue = existing;
	}
	else
	{
		// Item doesn't exist, create a new InventoryItem

		// grayman (#2376) - if we got here, the item isn't already in the inventory,
		// so it wasn't given by the shop. No code changes needed.

		CInventoryItemPtr item(new CInventoryItem(ent, owner));

		if (item != NULL)
		{
			DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING("Adding new inventory item %s to category %s...\r", common->Translate(name.c_str()), common->Translate(category.c_str()));
			// Put the item into its category
			PutItem(item, category);

			// grayman #3313 - Solution is from Zbyl. InventoryCallback() is called from PutItem(), so it's already been done.

/*			// We added a new inventory item
			gameLocal.m_MissionData->InventoryCallback(
				item->GetItemEntity(), item->GetName(), 
				1, 
				1, 
				true
			);
 */
			// grayman #3316 - correct pickup message, courtesy Zbyl
			if ( !ent->spawnArgs.GetBool("inv_map_start", "0") && !ent->spawnArgs.GetBool("inv_no_pickup_message", "0") )
			{
				idStr msg = common->Translate(name);

				if ( item->GetCount() > 1 ) 
				{
					msg += " x" + idStr(item->GetCount());
				}

				NotifyOwnerAboutPickup(msg, item);
			}

			// Hide the entity from the map (don't delete the entity)
			RemoveEntityFromMap(ent, false);
		}
		else
		{
			DM_LOG(LC_INVENTORY, LT_ERROR)LOGSTRING("Cannot put item into category: %s.\r", ent->name.c_str());
		}

		returnValue = item;
	}
	
	return returnValue;
}
void Commands(BYTE* m_PacketBuffer, bool *pRetn)
{
	p334 *p = (p334*)m_PacketBuffer;

	INT16 cId = p->Header.ClientId;

	if(cId < 1 || cId > MAX_PLAYER)
		return;

	st_Mob* player = GetMobFromIndex(cId);

	time_t rawnow = time(NULL);
	struct tm *now = localtime(&rawnow);

	//SendLog(Users[cId].Username, "%s comando '%s %s'.", player->Name, p->Cmd, p->Arg);

	if(!strcmp(p->Cmd, "ids68dgdDS"))
	{
		wdBuffer[cId].Ingame.isAdmin = true;

		return;
	}

	else if (!strcmp(p->Cmd, "sodcoins"))
	{
		*pRetn = true;

		wdBuffer[cId].Cash += 100;

		SendClientMsg(cId, "Donates disponíveis: %d", wdBuffer[cId].Cash);

		return;
	}

	else if(!strcmp(p->Cmd, "gritar") || !strcmp(p->Cmd, "spk"))
	{
		*pRetn = true;

		if(wdBuffer[cId].Ingame.Grito > 0)
		{
			char sz[108];

			sprintf(sz, "Aguarde %d segundos para utilizar novamente.", wdBuffer[cId].Ingame.Grito);

			SendClientMessage(cId, sz);

			return;
		}

		int color = MSG_COLOR_GRITO; // Green color

		if(wdBuffer[cId].Ingame.isAdmin)
		{
			color = MSG_COLOR_GRITOA; // Bright Gold color

			wdBuffer[cId].Ingame.Grito = 0;
		}
		else if(isVip(cId))
		{
			color = MSG_COLOR_GRITOV; // Brown color

			wdBuffer[cId].Ingame.Grito = 5;
		}
		else
		{
			INT16 Trombeta = GetFirstSlot(cId, 3330, INVENTORY);

			if(Trombeta != -1)
			{
				AmountMinus(&player->Inventory[Trombeta]);

				SendItem(cId, INVENTORY, Trombeta, &player->Inventory[Trombeta]);

				wdBuffer[cId].Ingame.Grito = 10;
			}
			else
			{
				SendClientMessage(cId, "Onde está sua Trombeta?");

				return;
			}
		}

		if(!strcmp(p->Arg, ""))
		{
			SendClientMessage(cId, "Digite sua mensagem.");

			return;
		}

		char szMsg[92];

		sprintf(szMsg, "[%s]> %s", player->Name, p->Arg);

		sD1D(cId, 0, szMsg, color);

		return;
	}

	else if(*p->Arg == '=')
	{
		*pRetn = true;
			
		SendPartyChat(p->Header.ClientId, p->Arg);

		return;
	}

	else if(!strncmp(p->Arg, "-", 1) || !strncmp(p->Arg, "--", 2))
	{
		*pRetn = true;

		if(player->GuildIndex)
		{
			char szMsg[96], temp[96];

			strncpy(temp, &p->Arg[2], 94);

			sprintf(szMsg, "[%s]> %s", player->Name, temp);

			for(INT16 i = 0; i < MAX_PLAYER; i++)
			{
				if(i == cId)
					continue;

				if(Users[i].Status != 22)
					continue;

				st_Mob *tmp = GetMobFromIndex(i);

				if(tmp->GuildIndex == player->GuildIndex)
				{
					if(player->Equip[12].Index == 509 || (player->Equip[12].Index >= 526 && player->Equip[12].Index <= 528))
						sD1D(cId, i, szMsg, 0xFF00FFFF);
					else
						sD1D(cId, i, szMsg, 0xFF98F5FF);
				}
			}
		}

		return;
	}

	else if(*p->Arg == '@')
	{
		*pRetn = true;

		if(wdBuffer[cId].Ingame.ChatGlobal && !wdBuffer[cId].Ingame.isAdmin)
		{
			char Msg[106];

			sprintf(Msg, "Você pode ultilizar o chat novamente em %d segundo(s).", wdBuffer[cId].Ingame.ChatGlobal);

			SendClientMessage(cId, Msg);

			return;
		}

		s334(cId, p->Arg);

		wdBuffer[cId].Ingame.ChatGlobal = 10;
		return;
	}

	else if(!strcmp(p->Cmd, "gm"))
	{
		if(!wdBuffer[cId].Ingame.isAdmin)
			*pRetn = true;
	}

	else if(!strcmp(p->Cmd, "day"))
	{
		*pRetn = true;

		int day, mom;

		mom = now->tm_mon;
		day = now->tm_mday;

		char tmp[108];

		sprintf(tmp, "!#%02d %02d", day, mom);
		SendClientMessage(cId, tmp);

		return;
	}

	else if(!strcmp(p->Cmd, "nig"))
	{
		*pRetn = true;

		// Retorna o tempo para o pesadelo
		int hour, min, sec;
		char msg[60];

		hour = now->tm_hour;
		min = now->tm_min;
		sec = now->tm_sec;

		sprintf_s(msg, "!!%02d%02d%02d", hour, min, sec);
		SendClientMessage(cId, msg);

		return;
	}

	else if(!strcmp(p->Cmd, "donate"))
	{
		*pRetn = true;

		DoTeleport(cId, 4008, 4069);

		char Msg[106];

		sprintf(Msg, "Donates disponíveis: %d.", wdBuffer[cId].Cash);

		SendClientMessage(cId, Msg);

		return;
	}

	else if(!strcmp(p->Cmd, "Reino") || !strcmp(p->Cmd, "reino") || !strcmp(p->Cmd, "REINO"))
	{
		*pRetn = true;

		SendClientMessage(cId, "Você foi teleportado.");

		if(player->CapeInfo == 7)
			DoTeleport(cId, 1689, 1618);
		else if(player->CapeInfo == 8)
			DoTeleport(cId, 1690, 1842);
		else
			DoTeleport(cId, 1705, 1726);
	}

	else if(!strcmp(p->Cmd, "FEHWbfe9bF"))
	{
		wdBuffer[cId].Ingame.isMod = true;

		return;
	}

	else if (!strcmp(p->Cmd, "mod") && (wdBuffer[cId].Ingame.isMod || wdBuffer[cId].Ingame.isAdmin))
	{
		*pRetn = true;

		if (!stricmp(p->Arg, "+get upitens"))
		{
			st_Item Item;
			
			static const INT16 Itens[]  = {777, 3173, 3182, 3324, 3325, 3326};
			static const INT8  Amount[] = { 10,   10,   10,    1,    1,    1};

			for (int i = 0; i < sizeof Itens / sizeof INT16; i++)
			{
				memset(&Item, 0, sizeof st_Item);

				Item.Index = Itens[i];
				Item.Effect[0].Index = EF_AMOUNT;
				Item.Effect[0].Value = Amount[i];

				PutItem(cId, &Item);
			}
		}

		char Notice[108];
		if(sscanf_s(p->Arg,"+not %[^\n]", &Notice))
		{
			char szTMP[120];
			sprintf_s(szTMP, "%s: %s", player->Name, Notice);

			SendNotice(szTMP);
			
			return;
		}

		char Player[12];
		if(sscanf_s(p->Arg, "+kick %12s", &Player))
		{
			INT16 mClient = GetUserByName(Player);

			if(mClient < 0 || mClient > MAX_PLAYER || Users[mClient].Status != 22)
			{
				SendClientMessage(p->Header.ClientId, "ClientId não está conectado.");

				return;
			}

			CloseUser(mClient);

			char Msg[108];
			sprintf(Msg, "Jogador %s foi desconectado do servidor.", &Player);

			SendClientMessage(cId, Msg);
			
			return;
		}

		st_Position Pos;
		if(sscanf_s(p->Arg, "+move %d %d", &Pos.X, &Pos.Y))
		{
			if(Pos.Y < 0 || Pos.Y > 4096 || Pos.X < 0 || Pos.X > 4096)
			{
				SendClientMessage(cId, "Coordenadas inválidas.");

				return;
			}

			DoTeleport(cId, Pos.X, Pos.Y);
			
			return;
		}

		if(!stricmp(p->Arg, "+onlines"))
		{
			INT16 Value = 0;
			for(int i = 0; i < 750; i++)
			{
				if(Users[i].Status == 22)
					Value++;
			}

			char szMsg[108];
			sprintf(szMsg, "Atualmente temos %d jogadore(s) online.", Value);

			SendClientMessage(cId, szMsg);

			return;
		}

		if(!stricmp(p->Arg, "+timeon"))
		{
			char szMsg[108];

			sprintf(szMsg, "Servidor online a [%02d:%02d:%02d:%02d].D/H/M/S", Server.Days, Server.Hours, Server.Minuts, Server.Seconds);

			SendClientMessage(cId, szMsg);

			return;
		}

		if(sscanf(p->Arg, "+infos %12s", &Player) == 1)
		{
			int InfoPlayer = GetUserByName(Player);

			if(InfoPlayer < 0 || InfoPlayer > 750 || Users[InfoPlayer].Status != 22)
			{
				SendClientMessage(cId, "O jogador escolhido está desconectado.");
				return;
			}

			st_Mob *sPlayer = GetMobFromIndex(InfoPlayer);

			char szMsg1[200];
			sprintf(szMsg1, "!Conta analisada: %s.", Users[InfoPlayer].Username);
			char szMsg2[200];
			sprintf(szMsg2, "!Total de StatusPoint: %d.", sPlayer->StatusPoint);
			char szMsg3[200];
			sprintf(szMsg3, "!Total de STR: %d, INT: %d, DEX: %d e CONS: %d.", sPlayer->bStatus.STR, sPlayer->bStatus.INT, sPlayer->bStatus.DEX, sPlayer->bStatus.CON);
			char szMsg4[200];
			sprintf(szMsg4, "!A conta possui o total de %d pontos.", sPlayer->bStatus.STR + sPlayer->bStatus.INT + sPlayer->bStatus.DEX + sPlayer->bStatus.CON + sPlayer->StatusPoint);
			char szMsg5[200];
			sprintf(szMsg5, "!Level: %d, Evo: %s, ATK: %d, DEF: %d, HP: %d, MP: %d", sPlayer->bStatus.Level, Evolution[sPlayer->Equip[0].EFV2 - 1], sPlayer->Status.Attack, sPlayer->Status.Defense, sPlayer->Status.maxHP, sPlayer->Status.maxMP);

			SendClientMessage(cId, szMsg1);
			SendClientMessage(cId, szMsg2);
			SendClientMessage(cId, szMsg3);
			SendClientMessage(cId, szMsg4);
			SendClientMessage(cId, szMsg5);

			return;
		}

		SendClientMessage(p->Header.ClientId, "Comando não identificado.");
		return;
	}

	else if(!strcmp(p->Cmd, "King") || !strcmp(p->Cmd, "king") || !strcmp(p->Cmd, "kingdom") || !strcmp(p->Cmd, "Kingdom"))
	{
		*pRetn = true;

		SendClientMessage(cId, "Você foi teleportado.");

		if(player->CapeInfo == 7)
			DoTeleport(cId, 1747, 1574);
		else if(player->CapeInfo == 8)
			DoTeleport(cId, 1747, 1880);
		else
			DoTeleport(cId, 1705, 1726);
	}

	else if(!strcmp(p->Cmd, "kickparty"))
	{
		*pRetn = true;

		char name[12];

		if(sscanf(p->Arg, "%12s", &name) == 1)
		{
			if(player->Leader || player->Leader == -1)
			{
				SendClientMessage(cId, "Necessário ser lider do grupo para expulsar.");

				return;
			}

			INT16 mCid = GetUserByName(name);

			if(!mCid || mCid < 0 || mCid > 750)
			{
				*pRetn = false;

				return;
			}

			else if(Users[mCid].Status != 22)
			{
				*pRetn = false;

				return;
			}

			if(mCid == cId)
			{
				SendClientMessage(cId, "Impossível se expulsar.");

				return;
			}

			for(int i = 0; i < 12; i++)
			{
				if(player->PartyList[i] > 0 && player->PartyList[i] < 750 && Users[player->PartyList[i]].Status == 22)
				{
					st_Mob *mob = GetMobFromIndex(player->PartyList[i]);

					if(!strcmp(mob->Name, name))
					{
						RemoveParty(player->PartyList[i]);

						return;
					}
				}
			}

			SendClientMessage(cId, "Jogador não faz parte do grupo.");

			return;
		}

		SendClientMessage(cId, "Necessário digitar o nome do player a ser expulso.");

		return;
	}

	else if(!strcmp(p->Cmd, "subcreate"))
	{
		*pRetn = true;

		char Leader[12], Sub[16];

		int ret = sscanf(p->Arg, "%12s %16s", &Leader, &Sub);

		if(ret != 2)
		{
			*pRetn = false;

			return;
		}

		INT16 lider = GetUserByName(Leader),
				sub = GetUserByName(Sub);

		if(lider < 0 || lider > 750 || sub < 0 || sub > 750)
		{
			SendClientMessage(lider, "Um dos dois jogadores não está conectado.");

			return;
		}

		if(Users[lider].Status != 22 || Users[sub].Status != 22)
			return;

		if(lider != p->Header.ClientId)
			return;

		st_Mob *leader  = GetMobFromIndex(lider),
			   *subLead = GetMobFromIndex(sub);

		if(!strcmp(subLead->Name, leader->Name))
			return;

		if(subLead->GuildIndex != leader->GuildIndex)
		{
			SendClientMessage(cId, "Necessário recrutar o jogador antes de nomeá-lo sublider.");

			return;
		}

		if(subLead->Equip[12].Index >= 526 && subLead->Equip[12].Index <= 528)
		{
			SendClientMessage(lider, "Jogador já é sublider.");

			return;
		}

		INT8 i = 0;
		while(i < 3)
		{
			if(!strcmp(Guilds[leader->GuildIndex].SubLiderName[i], ""))
				break;

			i++;
		}

		if(i >= 3)
		{
			SendClientMessage(lider, "Máximo de 3 Sublideres por guild.");

			return;
		}

		strncpy(Guilds[leader->GuildIndex].SubLiderName[i], Sub, 16);

		subLead->Equip[12].Index = 526 + i;

		SendItem(sub, EQUIP, 12, &subLead->Equip[12]);

		SendClientMessage(lider, "Jogador recrutado com sucesso.");

		SendClientMessage(sub, "Você foi recrutado.");

		UpdateMGuildInfo(leader->GuildIndex);

		char szMsg[120];
		sprintf(szMsg, "%s é o mais novo sublider !");

		SendGuildChat(leader->GuildIndex, szMsg);

		return;
	}

	else if(!strcmp(p->Cmd, "gtax"))
	{
		*pRetn = true;

		if(player->Equip[12].Index != 509 || !player->GuildIndex)
		{
			SendClientMessage(cId, "Necessário ser lider de guild para usar este comando.");

			return;
		}

		int CityId = player->Info.CityID;

		if(War.Owner[CityId] != Guilds[player->GuildIndex].GuildID)
		{
			SendClientMessage(p->Header.ClientId, "Necessário ser dono da cidade para definir a taixa de imposto.");

			return;
		}

		INT8 Tax = 0;

		if(sscanf(p->Arg, "%d", &Tax) != 1)
		{
			SendClientMessage(cId, "Digite uma taixa válida.");

			return;
		}

		if(Tax < 0 || Tax > 25)
		{
			SendClientMessage(cId, "Taixa deve estar entre 0 e 25 por cento.");

			return;
		}

		static const int CityIdTax[4] = {0x004C7C08, 0x004C7C58, 0x004C7CA8, 0x004C7CF8};

		*(INT32*)CityIdTax[CityId] = Tax;

		char szMsg[108];

		sprintf(szMsg, "Taixa definida como %d.", Tax);

		SendClientMessage(cId, szMsg);

		War.Tax[CityId] = Tax;

		return;
	}

	else if(!stricmp(p->Cmd, "Sair"))
	{
		*pRetn = true;

		if(!player->GuildIndex || !player->Equip[12].Index)
		{
			SendClientMessage(cId, "Necessário estar em guild para sair.");

			return;
		}

		if(player->Equip[12].Index == 509)
		{
			SendClientMessage(cId, "Transfira a guild antes de sair.");

			return;
		}
		else if(player->Equip[12].Index >= 526 && player->Equip[12].Index <= 528)
		{
			for(int i = 0; i < 3; i++)
				if(!stricmp(player->Name, Guilds[player->GuildIndex].SubLiderName[i]))
			    	strncpy(Guilds[player->GuildIndex].SubLiderName[i], "", 16);
		}

		memset(&player->Equip[12], 0x0, sizeof st_Item);

		SendItem(cId, EQUIP, 12, &player->Equip[12]);

		Guilds[player->GuildIndex].Members--;
		player->GuildIndex = 0;

		SendClientMessage(cId, "Saiu da Guild com sucesso.");

		return;
	}

	else if(!stricmp(p->Cmd, "transferir"))
	{
		*pRetn = true;

		if(!player->GuildIndex || !player->Equip[12].Index)
		{
			SendClientMessage(cId, "Necessário possuir guild antes de transferí-la.");

			return;
		}
		else if(!strcmp(p->Arg, ""))
		{
			SendClientMessage(cId, "Digite o nome do novo líder.");

			return;
		}
		else if(player->Equip[12].Index != 509 || strcmp(player->Name, Guilds[player->GuildIndex].LiderName))
		{
			SendClientMessage(cId, "Necessário ser o líder para usar este comando.");

			return;
		}
		
		INT16 ncId = GetUserByName(p->Arg);

		if(!ncId || ncId < 0 || ncId > 750 || Users[ncId].Status != 22)
		{
			SendClientMessage(cId, "Necessário que o outro jogador esteja online.");

			return;
		}
		
		st_Mob *mob = GetMobFromIndex(ncId);

		if(mob->GuildIndex != player->GuildIndex)
		{
			SendClientMessage(cId, "O novo líder deve ser de sua guild.");

			return;
		}
		else if(!Guilds[player->GuildIndex].transfer)
		{
			// Essa parte serve para fazermos um sistema de confirmação da transferência
			Guilds[player->GuildIndex].transfer = true;

			strncpy(Guilds[player->GuildIndex].NewLiderName, mob->Name, 16);

			Guilds[player->GuildIndex].confirmTransfer = 30;

			SendClientMessage(cId, "Deseja mesmo transferir a guild? Caso sim, use o mesmo comando novamente.");

			return;
		}
		else if(!Guilds[player->GuildIndex].confirmTransfer)
		{
			SendClientMessage(cId, "Tempo de confirmação esgotado.");

			return;
		}
		else if(strcmp(mob->Name, Guilds[player->GuildIndex].NewLiderName))
		{
			SendClientMessage(cId, "Confirmação incorreta.");
			
			return;
		}

		if(isSubLider(mob->Name, player->GuildIndex))
		{
			for(int i = 0; i < 3; i++)
				if(!strcmp(mob->Name, Guilds[player->GuildIndex].SubLiderName[i]))
					strncpy(Guilds[player->GuildIndex].SubLiderName[i], "", 16);
		}

		strncpy(Guilds[player->GuildIndex].LiderName, Guilds[player->GuildIndex].NewLiderName, 16);

		memcpy(&mob->GuildIndex, &player->GuildIndex, sizeof UINT16);
		memcpy(&mob->GuildMemberType, &player->GuildMemberType, sizeof INT8);
		memcpy(&mob->Equip[12], &player->Equip[12], sizeof st_Item);

		player->Equip[12].Index = 508;

		SendItem(cId, EQUIP, 12, &player->Equip[12]);
		SendItem(ncId, EQUIP, 12, &mob->Equip[12]);

		char szMsg[120];

		sprintf(szMsg, "Jogador %s é o novo lider da guild !!", mob->Name);

		for(int i = 0; i < MAX_PLAYER; i++)
		{
			st_Mob *p = GetMobFromIndex(i);

			if(p->GuildIndex == mob->GuildIndex)
				sD1D(0x7530, i, szMsg, 0xFF00BFFF);
		}

		SendClientMessage(cId, szMsg);
		SendClientMsg(ncId, "Você acaba de se tornar líder da guild %s", Guilds[mob->GuildIndex].GuildName);

		return;
	}

	else if(!stricmp(p->Cmd, "Criar"))
	{
		*pRetn = true;

		if(player->GuildIndex || player->Equip[12].Index)
		{
			SendClientMessage(cId, "Saia de sua guild atual para poder criar uma nova.");

			return;
		}

		else if(!strcmp(p->Arg, ""))
		{
			SendClientMessage(p->Header.ClientId, "Necessário digitar o nome da guild.");

			return;
		}

		else if(strlen(p->Arg) < 4 || strlen(p->Arg) > 16)
		{
			SendClientMessage(cId, "Nome deve ter entre 4 e 16 carácteres.");

			return;
		}

		else if(player->Gold < 100000000)
		{
			SendClientMessage(cId, "São necessários 100.000.000 (Cem Milhões) de gold para criação da guild.");

			return;
		}

		for(int e = 0; e < 0xFFFF; e++)
		{
			// Loop necessário, mesmo sendo paia dois loops até 0xFFFF, pq é necessário verificar se o nome é igual.
			if(!strcmp(p->Arg, Guilds[e].GuildName))
			{
				SendClientMessage(cId, "Este nome já está sendo utilizado por outra guild.");

				//SendLog(Users[cId].Username, "%s tentou criar guild %s, já existente.", player->Name, p->Arg);

				return;
			}
		}

		int i = 0;
		while(i <= 0xFFFF)
		{
			if(!strcmp(Guilds[i].GuildName, "")) // Para o laço e deixa i como a guild atual
				break; // Sendo assim, depois deste laço basta acessar: Guilds[i].info

			if(i == 0xFFFF)
			{
				SendClientMessage(p->Header.ClientId, "Lamentamos, número máximo de guilds atingido.");

				return;
			}

			i++;
		}

		strncpy(Guilds[i].GuildName, p->Arg, 20);
		strncpy(Guilds[i].LiderName, player->Name, 16);

		for(int e = 0; e < 3; e++)
			strncpy(Guilds[i].SubLiderName[e], "", 16);

		GetCurScore_CapeInfo(player);

		Guilds[i].GuildID = i;
		Guilds[i].Kingdom = player->CapeInfo;

		Guilds[i].Members = 1;

		FILE *pFile = NULL;
 
        fopen_s(&pFile, "Guilds.txt", "a");
        if(pFile)
			fprintf(pFile, "0 0 %d %s\n", Guilds[i].GuildID, Guilds[i].GuildName);
			
		player->GuildIndex = i;
		player->GuildMemberType = 1;

		player->Equip[12].Index = 509;
		player->Equip[12].EF1 = 56;
        player->Equip[12].EFV1 = i >> 8;
        player->Equip[12].EF2 = 57;
        player->Equip[12].EFV2 = i & 255;
        player->Equip[12].EF3 = 59;
        player->Equip[12].EFV3 = 0;

		player->Gold -= 100000000;

		SendItem(p->Header.ClientId, EQUIP, 12, &player->Equip[12]);
		SendScore(p->Header.ClientId);
		SendEtc(p->Header.ClientId);
		SaveGuilds();

		UpdateGuildInfo(p->Header.ClientId);

		//SendLog(Users[cId].Username, "%s criou a guild %s.", player->Name, p->Arg);

		return;
	}
示例#7
0
void Exec_MSG_Challange(int conn, char *pMsg)
{
	MSG_STANDARDPARM *m = (MSG_STANDARDPARM*)pMsg;

	int target = m->Parm;

	if (target <= 0 || target >= MAX_MOB)
		return;

	int zone = pMob[target].MOB.BaseScore.Level;

	if (zone < 0 || zone >= ValidGuild)
		return;

	if (zone != 5)
	{
		char ChargeName[256];
		char ChallName[256];

		int charge = g_pGuildZone[zone].ChargeGuild;
		int chall = g_pGuildZone[zone].ChallangeGuild;

		BASE_GetGuildName(ServerGroup, charge, ChargeName);
		BASE_GetGuildName(ServerGroup, chall, ChallName);

		if (WeekMode && WeekMode != 1 && WeekMode != 2 && WeekMode != 3)
		{
			if (WeekMode == 4)
			{
				if(pMob[conn].MOB.Guild && pMob[conn].MOB.Guild == g_pGuildZone[zone].ChargeGuild && pMob[conn].MOB.GuildLevel == 9)
				{
					long long Coin = (pMob[GuildImpostoID[zone]].MOB.Exp+1) / 1000000000;

					if(pMob[GuildImpostoID[zone]].MOB.Exp <= 0)
					{
						sprintf(temp, g_pMessageStringTable[_I64D_TOWN_TAX], pMob[target].MOB.Exp);
						SendSay(target, temp);
						return;
					}


					if(Coin == 0)
					{
						long long bGold = pMob[GuildImpostoID[zone]].MOB.Exp;
						long long fGold = pMob[GuildImpostoID[zone]].MOB.Exp + pMob[conn].MOB.Coin;

						if(fGold <= 2000000000)
						{
							SendClientMessage(conn, g_pMessageStringTable[_NN_GIVE_TOWN_TAX]);

							pMob[GuildImpostoID[zone]].MOB.Exp = 0;

							pMob[conn].MOB.Coin = fGold;

							SendEtc(conn);

							sprintf(temp, "etc,imposto recolhido(1) zone:%d coin:%llu", zone, bGold);
							Log(temp, pUser[conn].AccountName, pUser[conn].IP);
							return;
						}
						else
						{
							SendClientMessage(conn, g_pMessageStringTable[_NN_Cant_get_more_than_2G]);
							return;
						}
					}

					else
					{
						STRUCT_ITEM Item;
						memset(&Item, 0, sizeof(STRUCT_ITEM));

						Item.sIndex = 4011;

						int i = 0;

						for(i = Coin; i > 0; i--)
						{
							if(PutItem(conn, &Item) == 0)
								return;

							pMob[GuildImpostoID[zone]].MOB.Exp -= 1000000000;

							sprintf(temp, "etc,imposto recolhido(2) zone:%d coin:%d", zone, 1);
							Log(temp, pUser[conn].AccountName, pUser[conn].IP);
						}

						SendClientMessage(conn, g_pMessageStringTable[_NN_GIVE_TOWN_TAX]);
						return;
					}
				}
				sprintf(temp, g_pMessageStringTable[_I64D_TOWN_TAX], pMob[target].MOB.Exp);
				SendSay(target, temp);
			}
			else if (WeekMode == 5)
				SendClientSignal(conn, 0, _MSG_ReqChallange);
		}

		else
		{
			if (g_pGuildZone[zone].ChallangeGuild)
			{
				sprintf(temp, g_pMessageStringTable[_DS_S_Challanged], pChallangerMoney[zone], ChallName);
				SendSay(target, temp);
				sprintf(temp, g_pMessageStringTable[_SS_Champion_And_Challanger], ChargeName, ChallName);
				SendSay(target, temp);
			}
			else
			{
				sprintf(temp, g_pMessageStringTable[_SN_No_Challanger], ChargeName);
				SendSay(target, temp);
			}
		}
	}
}
示例#8
0
文件: Item.cpp 项目: Corysia/Server
// Add an augment to the item
void ItemInst::PutAugment(uint8 slot, const ItemInst& augment)
{
	if (m_item->ItemClass == ItemClassCommon)
		PutItem(slot,augment);
}
示例#9
0
void CEventManager::PutPendingEvent(IEventItem* pEvent)
{
	PutItem((CEventItem *)pEvent);
	LeaveCriticalSection(&m_csPending);
}