Page 1 of 1

coding question

Posted: Sun Mar 17, 2019 12:11 pm
by Ememjr
i want to create a vector of items i am using the very common one

Code: Select all

vector<Item*>* items
what i do not know is how to add a single item to the list (because i want to use the same loot code and it uses a vector)
when i know what the item is and it is here as master_item

Code: Select all

master_item = master_item_list.GetItem(item_harvested);
and it will be used here

Code: Select all

void Client::Loot(int32 total_coins, vector<Item*>* items, Entity* entity, bool collection){
	if(!entity && !collection){
		CloseLoot();
			return;
	}

Re: coding question

Posted: Sun Mar 17, 2019 4:32 pm
by Jabantiz
So you just want to add an item to the vector? That is just

Code: Select all

 items.push_back(item_to_add)
master_item_list will just get a pointer to an item in the master list, this item should not be modified at all or given to the player. If you need an item to be modified or given to the player it would be

Code: Select all

Item* new_item = new Item(master_item_list.Get(ItemID));