Jump to content

Extend whodrops command to include map drops


Louis T Steinhil

Recommended Posts


  • Group:  Members
  • Topic Count:  38
  • Topics Per Day:  0.01
  • Content Count:  178
  • Reputation:   42
  • Joined:  06/22/13
  • Last Seen:  

This is a request from Extend whodrops command to include map drops #8017

I'm only enhancing @whodrops command. I've included map_drops.yml in the command

 


		extern MapDropDatabase map_drop_db;
		extern InstanceDatabase instance_db;

		sprintf(atcmd_output, "Map drops:");
		clif_displaymessage(fd, atcmd_output);

		std::map<std::pair<uint16, double>, std::vector<std::string>> map_drop_groups;
		bool found_map_drops = false;

		for (const auto& map_entry : map_drop_db) {
			std::shared_ptr<s_map_drops> mapdrops = map_entry.second;
			std::string map_name = map_mapid2mapname(map_entry.first);
			std::string display_name = map_name;

			if (map_name.find("@") != std::string::npos) {
				for (const auto& instance_entry : instance_db) {
					std::shared_ptr<s_instance_db> instance = instance_entry.second;
					if (strcmp(map_mapid2mapname(instance->enter.map), map_name.c_str()) == 0) {
						display_name = instance->name;
						break;
					}
					for (const auto& additional_map : instance->maplist) {
						if (strcmp(map_mapid2mapname(additional_map), map_name.c_str()) == 0) {
							display_name = instance->name;
							break;
						}
					}
					if (display_name != map_name) break;
				}
			}

			for (const auto& global_drop : mapdrops->globals) {
				if (global_drop.second->nameid == id->nameid) {
					double rate_percent = (global_drop.second->rate * 100.0) / 100000.0;
					std::pair<uint16, double> key = std::make_pair(0, rate_percent);
					map_drop_groups[key].push_back(display_name);
					found_map_drops = true;
				}
			}

			for (const auto& specific_entry : mapdrops->specific) {
				uint16 mob_id = specific_entry.first;
				for (const auto& drop : specific_entry.second) {
					if (drop.second->nameid == id->nameid) {
						double rate_percent = (drop.second->rate * 100.0) / 100000.0;
						std::pair<uint16, double> key = std::make_pair(mob_id, rate_percent);
						map_drop_groups[key].push_back(display_name);
						found_map_drops = true;
					}
				}
			}
		}

		if (!found_map_drops) {
			sprintf(atcmd_output, " - Item is not dropped by map-specific drops.");
			clif_displaymessage(fd, atcmd_output);
		} else {
			for (const auto& group : map_drop_groups) {
				uint16 mob_id = group.first.first;
				double rate = group.first.second;
				const std::vector<std::string>& maps = group.second;

				std::string map_list = "";
				for (size_t i = 0; i < maps.size(); ++i) {
					if (i > 0) map_list += ", ";
					map_list += maps[i];
				}

				if (mob_id == 0) {
					sprintf(atcmd_output, "- All monsters: %.2f%% - (%s)", rate, map_list.c_str());
				} else {
					std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
					if (mob) {
						sprintf(atcmd_output, "- %s (%d): %.2f%% - (%s)", mob->jname.c_str(), mob_id, rate, map_list.c_str());
					}
				} 
				clif_displaymessage(fd, atcmd_output);  
			}  
		}

 

Screenshot:

image.png.174561ee6af2732d431628ff6691f04c.pngimage.png.db0474092c349f9676a5dbe1394f520a.pngimage.png.e5f96801b691b3fc2d225e2a2bfacb9c.png

Extend whodrops command to include map drops (#8017).diff

  • Upvote 2
  • Love 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...