Warlord
Administrator
- 9 Temmuz 2025
- 16
- 0
- 1
![]() |
![]() |
C++:
void CUser::HandleMiningAttempt(Packet & pkt)
{
if (!isMining() || isFishing() || isTrading() || isMerchanting() || isSellingMerchantingPreparing())
return;
if (m_tLastMiningAttempt > UNIXTIME2)
return;
_ITEM_TABLE pGiveItem = _ITEM_TABLE();
std::vector<_MINING_FISHING_ITEM> pMiningList;
m_tLastMiningAttempt = UNIXTIME2 + MINING_DELAY;
MiningErrors bResult = MiningErrors::MiningResultError;
Packet result(WIZ_MINING, uint8(MiningAttempt));
_ITEM_DATA* pItem;
auto pTable = GetItemPrototype(RIGHTHAND, pItem);
if (pItem == nullptr || pTable.isnull()
|| (pTable.m_iNum != GOLDEN_MATTOCK && pTable.m_iNum != MATTOCK)
|| pItem->sDuration <= 0 || pItem->isDuplicate()
|| pItem->isRented() || pItem->isSealed() || !pTable.isPickaxe()) {
bResult = MiningErrors::MiningResultNotPickaxe;
goto fail_return;
}
if (!isInMoradon()) {
if (g_pMain->m_byBattleOpen == NATION_BATTLE && GetZoneID() != ZONE_KARUS && GetZoneID() != ZONE_ELMORAD)
goto fail_return;
if (g_pMain->m_byBattleOpen != NATION_BATTLE && (GetNation() == (uint8)Nation::ELMORAD && !isInElmoradCastle()) || (GetNation() == (uint8)Nation::KARUS && !isInLufersonCastle()))
goto fail_return;
}
pMiningList = MiningItemList(pTable);
if (pMiningList.empty())
goto fail_return;
uint32 bRandArray[10000], offset = 0; uint8 sItemSlot = 0;
memset(bRandArray, 0, sizeof(bRandArray));
foreach(itr, pMiningList) {
if (itr->isnull())
continue;
if (offset >= 9999)
break;
for (int i = 0; i < int(itr->SuccessRate); i++) {
if (i + offset >= 9999)
break;
bRandArray[offset + i] = itr->nGiveItemID;
}
offset += int(itr->SuccessRate);
}
if (offset > 9999) offset = 9999;
uint32 bRandSlot = myrand(0, offset);
uint32 nItemID = bRandArray[bRandSlot];
pGiveItem = g_pMain->GetItemPtr(nItemID);
if (pGiveItem.isnull() || m_sItemWeight + pGiveItem.m_sWeight > m_sMaxWeight)
return;
int SlotForItem = FindSlotForItem(pGiveItem.m_iNum, 1);
if (SlotForItem < 0)
goto fail_return;
uint16 sEffect = 0;
if (nItemID == ITEM_EXP) // DeaFSoft Maden, Golden ve Mattock Effect ve Exp Notice Eklendi. 22.02.2025
{
uint32 expcount = GetMiningExpCount();
if (expcount) ExpChange("Mining Exp",expcount);
sEffect = 13082; // EXP EFFECT
ShowEffect(490091); // Kar Mavi Paltama Effect Eklendi. 22.02.2025
Packet DeaFSoft; // DeaFSoft Public Chat Renk Sari Notice Eklendi 22.02.2025
std::string PubliChat_Notice = string_format("Nick : %s | Mining Exp : %d Aldin Tebrikler", GetName().c_str(), expcount);
DeaFSoft.clear();
ChatPacket::Construct(&DeaFSoft, ChatType:
UBLIC_CHAT, PubliChat_Notice.c_str(), "[Mining Exp Bilgi]", GetNation());
Send(&DeaFSoft);
}
else if (nItemID > 0) // DeaFSoft Maden, Golden ve Mattock Effect ve İtem Notice Eklendi. 22.02.2025
{
_ITEM_TABLE pTable = g_pMain->GetItemPtr(nItemID);
if (pTable.isnull())
return;
sItemSlot = GetEmptySlot() - SLOT_MAX;
GiveItem("Mining Item", nItemID, 1);
sEffect = 13081; // İTEM EFFECT
ShowEffect(490092); // Yılbaşi Yağiyor Effect Eklendi. 22.02.2025
Packet DeaFSoft; // DeaFSoft Public Chat Renk Kırmızı Notice Eklendi 22.02.2025
std::string PubliChat_Notice = string_format("Nick : %s | Mining İtem Name : %s Aldin Tebrikler", GetName().c_str(), pTable.m_sName.c_str());
DeaFSoft.clear();
ChatPacket::Construct(&DeaFSoft, ChatType::SHOUT_CHAT, PubliChat_Notice.c_str(), "[Mining İtem Bilgi]", GetNation());
Send(&DeaFSoft);
}
ItemWoreOut(ATTACK, 150);
result << uint16(MiningErrors::MiningResultSuccess) << GetSocketID() << sEffect;
SendToRegion(&result, nullptr, GetEventRoom());
return;
fail_return:
result << uint16(MiningErrors::MiningResultError);
Send(&result);
HandleMiningStop();
}
void CUser::HandleMiningAttempt(Packet & pkt)
{
if (!isMining() || isFishing() || isTrading() || isMerchanting() || isSellingMerchantingPreparing())
return;
if (m_tLastMiningAttempt > UNIXTIME2)
return;
_ITEM_TABLE pGiveItem = _ITEM_TABLE();
std::vector<_MINING_FISHING_ITEM> pMiningList;
m_tLastMiningAttempt = UNIXTIME2 + MINING_DELAY;
MiningErrors bResult = MiningErrors::MiningResultError;
Packet result(WIZ_MINING, uint8(MiningAttempt));
_ITEM_DATA* pItem;
auto pTable = GetItemPrototype(RIGHTHAND, pItem);
if (pItem == nullptr || pTable.isnull()
|| (pTable.m_iNum != GOLDEN_MATTOCK && pTable.m_iNum != MATTOCK)
|| pItem->sDuration <= 0 || pItem->isDuplicate()
|| pItem->isRented() || pItem->isSealed() || !pTable.isPickaxe()) {
bResult = MiningErrors::MiningResultNotPickaxe;
goto fail_return;
}
if (!isInMoradon()) {
if (g_pMain->m_byBattleOpen == NATION_BATTLE && GetZoneID() != ZONE_KARUS && GetZoneID() != ZONE_ELMORAD)
goto fail_return;
if (g_pMain->m_byBattleOpen != NATION_BATTLE && (GetNation() == (uint8)Nation::ELMORAD && !isInElmoradCastle()) || (GetNation() == (uint8)Nation::KARUS && !isInLufersonCastle()))
goto fail_return;
}
pMiningList = MiningItemList(pTable);
if (pMiningList.empty())
goto fail_return;
uint32 bRandArray[10000], offset = 0; uint8 sItemSlot = 0;
memset(bRandArray, 0, sizeof(bRandArray));
foreach(itr, pMiningList) {
if (itr->isnull())
continue;
if (offset >= 9999)
break;
for (int i = 0; i < int(itr->SuccessRate); i++) {
if (i + offset >= 9999)
break;
bRandArray[offset + i] = itr->nGiveItemID;
}
offset += int(itr->SuccessRate);
}
if (offset > 9999) offset = 9999;
uint32 bRandSlot = myrand(0, offset);
uint32 nItemID = bRandArray[bRandSlot];
pGiveItem = g_pMain->GetItemPtr(nItemID);
if (pGiveItem.isnull() || m_sItemWeight + pGiveItem.m_sWeight > m_sMaxWeight)
return;
int SlotForItem = FindSlotForItem(pGiveItem.m_iNum, 1);
if (SlotForItem < 0)
goto fail_return;
uint16 sEffect = 0;
if (nItemID == ITEM_EXP) // DeaFSoft Maden, Golden ve Mattock Effect ve Exp Notice Eklendi. 22.02.2025
{
uint32 expcount = GetMiningExpCount();
if (expcount) ExpChange("Mining Exp",expcount);
sEffect = 13082; // EXP EFFECT
ShowEffect(490091); // Kar Mavi Paltama Effect Eklendi. 22.02.2025
Packet DeaFSoft; // DeaFSoft Public Chat Renk Sari Notice Eklendi 22.02.2025
std::string PubliChat_Notice = string_format("Nick : %s | Mining Exp : %d Aldin Tebrikler", GetName().c_str(), expcount);
DeaFSoft.clear();
ChatPacket::Construct(&DeaFSoft, ChatType:

Send(&DeaFSoft);
}
else if (nItemID > 0) // DeaFSoft Maden, Golden ve Mattock Effect ve İtem Notice Eklendi. 22.02.2025
{
_ITEM_TABLE pTable = g_pMain->GetItemPtr(nItemID);
if (pTable.isnull())
return;
sItemSlot = GetEmptySlot() - SLOT_MAX;
GiveItem("Mining Item", nItemID, 1);
sEffect = 13081; // İTEM EFFECT
ShowEffect(490092); // Yılbaşi Yağiyor Effect Eklendi. 22.02.2025
Packet DeaFSoft; // DeaFSoft Public Chat Renk Kırmızı Notice Eklendi 22.02.2025
std::string PubliChat_Notice = string_format("Nick : %s | Mining İtem Name : %s Aldin Tebrikler", GetName().c_str(), pTable.m_sName.c_str());
DeaFSoft.clear();
ChatPacket::Construct(&DeaFSoft, ChatType::SHOUT_CHAT, PubliChat_Notice.c_str(), "[Mining İtem Bilgi]", GetNation());
Send(&DeaFSoft);
}
ItemWoreOut(ATTACK, 150);
result << uint16(MiningErrors::MiningResultSuccess) << GetSocketID() << sEffect;
SendToRegion(&result, nullptr, GetEventRoom());
return;
fail_return:
result << uint16(MiningErrors::MiningResultError);
Send(&result);
HandleMiningStop();
}