Active+ Member m2Ciaran 396 Posted March 5 Active+ Member Share Posted March 5 (edited) ! I've only used it on my test server ! This is the hidden content, please Sign In or Sign Up Set item id under "high_item" event flag to highlight the item name with different color (/e high_item IDOFITEM) Usage: /drop_simul IDOFMOB AMOUNT Result: Edited March 5 by m2Ciaran typo 56 12 1 2 22 Link to comment Share on other sites More sharing options...
ScottAhriman1313 1 Posted March 8 Share Posted March 8 Wow, thanks! Link to comment Share on other sites More sharing options...
Deso 721 Posted March 8 Share Posted March 8 (edited) Add above: if (loopCount > 1) This: if (!pkAttacker) return; Edited March 8 by Deso Link to comment Share on other sites More sharing options...
ScottAhriman1313 1 Posted March 8 Share Posted March 8 (edited) Hello, it works fine, but the names of the objects are in English (I speak Spanish). I have multilanguage. Thank you. Edited March 8 by ScottAhriman1313 error Link to comment Share on other sites More sharing options...
ScottAhriman1313 1 Posted March 9 Share Posted March 9 10 hours ago, ScottAhriman1313 said: Hello, it works fine, but the names of the objects are in English (I speak Spanish). I have multilanguage. Thank you. Already solved Link to comment Share on other sites More sharing options...
Active+ Member Chitra 320 Posted March 11 Active+ Member Share Posted March 11 Hello, Thank you for the code posted. I encountered a few issues with it, including a memory leak, so I've optimized and fixed it. Example: Code: ACMD(do_drop) { char arg1[256], arg2[256]; two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2)); if (!*arg1 || !*arg2) { ch->ChatPacket(CHAT_TYPE_INFO, "Syntax: drop_simul <mob vnum> <count>"); return; } DWORD vnum = 0, loopCount = 0; str_to_number(vnum, arg1); str_to_number(loopCount, arg2); std::unordered_map<DWORD, long long> givenItems; LPCHARACTER pkAttacker = CHARACTER_MANAGER::instance().SpawnMobRandomPosition(vnum, ch->GetMapIndex()); if (!pkAttacker) return; for (DWORD count = 0; count < loopCount; ++count) { std::vector<LPITEM> vecItems; if (ITEM_MANAGER::instance().CreateDropItem(pkAttacker, ch, vecItems)) { for (LPITEM item : vecItems) { if (!item) { sys_err("item null in vector"); continue; } givenItems[item->GetVnum()] += item->GetCount(); sys_log(0, "DROP_ITEM_SIMULATE: %s by %s", item->GetName(), ch->GetName()); } } } ch->ChatPacket(CHAT_TYPE_PARTY, "############### |cFF6d8cf2|H|h%dx %s|h|r DROP SIMULATION ###############", loopCount, pkAttacker->GetName()); for (const auto& info : givenItems) { DWORD dwItemVnum = info.first; long long itemCount = info.second; LPITEM pItem = ITEM_MANAGER::instance().CreateItem(dwItemVnum, itemCount, 0, true); if (pItem) { const char* color = (pItem->GetVnum() == quest::CQuestManager::instance().GetEventFlag("high_item")) ? "|cFFf77f77" : "|cFFf5ef78"; ch->ChatPacket(CHAT_TYPE_PARTY, "Simulated item %s|H|h%s|h|r, %d pieces", color, pItem->GetName(), itemCount); M2_DESTROY_ITEM(pItem); } } M2_DESTROY_CHARACTER(pkAttacker); } 1 Link to comment Share on other sites More sharing options...
Active Member Larry Watterson 230 Posted March 12 Active Member Share Posted March 12 On 3/11/2024 at 4:05 PM, Chitra said: Hello, Thank you for the code posted. I encountered a few issues with it, including a memory leak, so I've optimized and fixed it. Example: Code: ACMD(do_drop) { char arg1[256], arg2[256]; two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2)); if (!*arg1 || !*arg2) { ch->ChatPacket(CHAT_TYPE_INFO, "Syntax: drop_simul <mob vnum> <count>"); return; } DWORD vnum = 0, loopCount = 0; str_to_number(vnum, arg1); str_to_number(loopCount, arg2); std::unordered_map<DWORD, long long> givenItems; LPCHARACTER pkAttacker = CHARACTER_MANAGER::instance().SpawnMobRandomPosition(vnum, ch->GetMapIndex()); if (!pkAttacker) return; for (DWORD count = 0; count < loopCount; ++count) { std::vector<LPITEM> vecItems; if (ITEM_MANAGER::instance().CreateDropItem(pkAttacker, ch, vecItems)) { for (LPITEM item : vecItems) { if (!item) { sys_err("item null in vector"); continue; } givenItems[item->GetVnum()] += item->GetCount(); sys_log(0, "DROP_ITEM_SIMULATE: %s by %s", item->GetName(), ch->GetName()); } } } ch->ChatPacket(CHAT_TYPE_PARTY, "############### |cFF6d8cf2|H|h%dx %s|h|r DROP SIMULATION ###############", loopCount, pkAttacker->GetName()); for (const auto& info : givenItems) { DWORD dwItemVnum = info.first; long long itemCount = info.second; LPITEM pItem = ITEM_MANAGER::instance().CreateItem(dwItemVnum, itemCount, 0, true); if (pItem) { const char* color = (pItem->GetVnum() == quest::CQuestManager::instance().GetEventFlag("high_item")) ? "|cFFf77f77" : "|cFFf5ef78"; ch->ChatPacket(CHAT_TYPE_PARTY, "Simulated item %s|H|h%s|h|r, %d pieces", color, pItem->GetName(), itemCount); M2_DESTROY_ITEM(pItem); } } M2_DESTROY_CHARACTER(pkAttacker); } Still have memory leak. Check "CreateDropItem" function definition. Link to comment Share on other sites More sharing options...
Active+ Member m2Ciaran 396 Posted March 12 Author Active+ Member Share Posted March 12 The purpose is to use it on your test server before you introduce drop changes on your main server Link to comment Share on other sites More sharing options...
Active Member Larry Watterson 230 Posted March 12 Active Member Share Posted March 12 I think it's better, thanks for idea. Best regards. https://raw.githubusercontent.com/LarryWatterson/drop-simulation/main/src/cmd_general.cpp Link to comment Share on other sites More sharing options...
Erexo 0 Posted March 12 Share Posted March 12 1 hour ago, Larry Watterson said: I think it's better, thanks for idea. Best regards. https://raw.githubusercontent.com/LarryWatterson/drop-simulation/main/src/cmd_general.cpp CreateMobDropVec missing. Link to comment Share on other sites More sharing options...
Shaggyxdd 3 Posted April 1 Share Posted April 1 2000 IQ, thank you for share! Link to comment Share on other sites More sharing options...
Recommended Posts