Page 1 of 1

getting the number of loot items available

Posted: Sun Apr 09, 2017 1:38 pm
by Ememjr
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;
					}
				}

Re: getting the number of loot items available

Posted: Sun Apr 09, 2017 3:11 pm
by Jabantiz
It should just be

Code: Select all

int size = loot_drops->size();