getting the number of loot items available

General support forum. If you require assistance and your problem doesnt fall in any of the other categories, this is the forum for you!

Moderator: Team Members

Forum rules
READ THE FORUM STICKY THREADS BEFORE ASKING FOR HELP!
Most information can be found there, and if not, the posts will help you determine the information required to get assistance from the development team.
Incomplete Help Requests will be locked or deleted.
Post Reply
User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

getting the number of loot items available

Post by Ememjr » Sun Apr 09, 2017 1:38 pm

i am trying out some different things on the looting, in the following snippet of code how to i get the number of loot items from loot_drops so i know the count before the for loop(you can ignore all the logwrites, just trying to gather some info)

Code: Select all

if(loot_drops){
					LootDrop* drop = 0;
					int16 count = 0;
					int16 IC = 0;
					for(loot_drop_itr = loot_drops->begin(); loot_drop_itr != loot_drops->end(); loot_drop_itr++){
						drop = *loot_drop_itr;
						//chancedrop = rand()%100;
						chancedrop = static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / 100));
						//LogWrite(PLAYER__DEBUG, 0, "Player", "Loot drop: '%i'     Chance: %f    Prob:  %f", loot_list_itr, chance2, drop->probability);
						if(drop->probability >= chancedrop){
						//	LogWrite(PLAYER__DEBUG, 0, "Player", "Loot drop: '%i'     Chance: %f    Prob:  %f  We have a loot drop winner", loot_list_itr, chance2, drop->probability);
							count++;
							npc->AddLootItem(drop->item_id, drop->item_charges);
							//LogWrite(PLAYER__DEBUG, 0, "Player", "loot Count: '%i'",count);
							//LogWrite(MISC__TODO, 1, "TODO", "Auto-Equip new looted items\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
							//if(drop->equip_item) 

						}
						if(table->maxlootitems > 0 && count >= table->maxlootitems)
							break;
					}
				}

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: getting the number of loot items available

Post by Jabantiz » Sun Apr 09, 2017 3:11 pm

It should just be

Code: Select all

int size = loot_drops->size();

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests