- cmd_general.cpp :
- Add :
- ACMD (do_sort_items)
- {
- if (ch->IsDead() || ch->GetExchange() || ch->IsShop() || ch->IsOpenSafebox() || ch->IsCubeOpen())
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't sort your inventory with those windows open."));
- return;
- }
- int lastSortInventoryPulse = ch->GetSortInventoryPulse();
- int currentPulse = thecore_pulse();
- if (lastSortInventoryPulse > currentPulse) {
- int deltaInSeconds = ((lastSortInventoryPulse / PASSES_PER_SEC(1)) - (currentPulse / PASSES_PER_SEC(1)));
- int minutes = deltaInSeconds / 60;
- int seconds = (deltaInSeconds - (minutes * 60));
- return;
- }
- for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item = ch->GetInventoryItem(i);
- if(!item)
- continue;
- if(item->isLocked())
- continue;
- if(item->GetCount() == 200)
- continue;
- if (item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
- {
- for (int j = i; j < INVENTORY_MAX_NUM; ++j)
- {
- LPITEM item2 = ch->GetInventoryItem(j);
- if(!item2)
- continue;
- if(item2->isLocked())
- continue;
- if (item2->GetVnum() == item->GetVnum())
- {
- bool bStopSockets = false;
- for (int k = 0; k < ITEM_SOCKET_MAX_NUM; ++k)
- {
- if (item2->GetSocket(k) != item->GetSocket(k))
- {
- bStopSockets = true;
- break;
- }
- }
- if(bStopSockets)
- continue;
- BYTE bAddCount = MIN(200 - item->GetCount(), item2->GetCount());
- item->SetCount(item->GetCount() + bAddCount);
- item2->SetCount(item2->GetCount() - bAddCount);
- continue;
- }
- }
- }
- }
- }
- _________________________________________
- ACMD (do_sort_special_storage)
- {
- if (ch->IsDead() || ch->GetExchange() || ch->IsShop() || ch->IsOpenSafebox() || ch->IsCubeOpen())
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't sort your inventory with those windows open."));
- return;
- }
- int lastSortSpecialStoragePulse = ch->GetSortSpecialStoragePulse();
- int currentPulse = thecore_pulse();
- if (lastSortSpecialStoragePulse > currentPulse) {
- int deltaInSeconds = ((lastSortSpecialStoragePulse / PASSES_PER_SEC(1)) - (currentPulse / PASSES_PER_SEC(1)));
- int minutes = deltaInSeconds / 60;
- int seconds = (deltaInSeconds - (minutes * 60));
- // ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can sort your inventory again in %02d seconds.", seconds));
- return;
- }
- for (int m = 0; m < 3; m++)
- {
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item;
- switch(m)
- {
- case 0:
- item = ch->GetUpgradeInventoryItem(i);
- break;
- case 1:
- item = ch->GetBookInventoryItem(i);
- break;
- case 2:
- item = ch->GetStoneInventoryItem(i);
- break;
- default:
- item = ch->GetUpgradeInventoryItem(i);
- break;
- }
- if(!item)
- continue;
- if(item->isLocked())
- continue;
- if(item->GetCount() == g_bItemCountLimit)
- continue;
- if (item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
- {
- for (int j = i; j < SPECIAL_INVENTORY_MAX_NUM; ++j)
- {
- LPITEM item2;
- switch(m)
- {
- case 0:
- item2 = ch->GetUpgradeInventoryItem(j);
- break;
- case 1:
- item2 = ch->GetBookInventoryItem(j);
- break;
- case 2:
- item2 = ch->GetStoneInventoryItem(j);
- break;
- default:
- item2 = ch->GetUpgradeInventoryItem(j);
- break;
- }
- if(!item2)
- continue;
- if(item2->isLocked())
- continue;
- if (item2->GetVnum() == item->GetVnum())
- {
- bool bStopSockets = false;
- for (int k = 0; k < ITEM_SOCKET_MAX_NUM; ++k)
- {
- if (item2->GetSocket(k) != item->GetSocket(k))
- {
- bStopSockets = true;
- break;
- }
- }
- if(bStopSockets)
- continue;
- BYTE bAddCount = MIN(g_bItemCountLimit - item->GetCount(), item2->GetCount());
- item->SetCount(item->GetCount() + bAddCount);
- item2->SetCount(item2->GetCount() - bAddCount);
- continue;
- }
- }
- }
- }
- }
- ch->SetNextSortSpecialStoragePulse(thecore_pulse() + PASSES_PER_SEC(60));
- }
- cmd.cpp :
- Add :
- ACMD(do_sort_items);
- ACMD(do_sort_special_storage);
- And :
- { "click_sort_items", do_sort_items, 0, POS_DEAD, GM_PLAYER },
- { "click_sort_special_storage", do_sort_special_storage, 0, POS_DEAD, GM_PLAYER },