add collection item via loot box

EQ2Emulator Development forum.

Moderator: Team Members

Post Reply
User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

add collection item via loot box

Post by Ememjr » Thu Sep 14, 2017 2:29 pm

so the loot box appears with this funtion

Code: Select all

void Client::Loot(int32 total_coins, vector<Item*>* items, Entity* entity ){
	if(!entity){
		CloseLoot();
			return;
	}
	if(total_coins > 0){
		player->AddCoins(total_coins);
		//PlaySound("coin_cha_ching");
		string message = "";
		if(entity->GetHP() == 0){
			message = "You loot ";
			entity->SetLootCoins(0);
		}
		else
			message = "You receive ";
		message.append(GetCoinMessage(total_coins));
		if(entity->GetHP() == 0)
			message.append(" from the corpse of ").append(entity->GetName());
		int8 type = CHANNEL_COLOR_LOOT;
		if (GetVersion() >= 1208)
			type = CHANNEL_LOOT;
		else if(GetVersion() >= 973)
			type = CHANNEL_COLOR_NEW_LOOT;
		
		
		SimpleMessage(type, message.c_str());
	}
	if(!items || items->size() == 0)
		CloseLoot();
	vector<Item*>::iterator itr;
	for (itr = items->begin(); itr != items->end(); itr++){
		Item* item = 0;
		item = *itr;
		
		LogWrite(PLAYER__DEBUG, 1, "Robert Lore", "Checking for Lore:%i Result: %i", item->generic_info.item_flags, item->generic_info.item_flags & LORE);
		if ((item->generic_info.item_flags & LORE) >0){
			LogWrite(PLAYER__DEBUG, 1, "Robert Lore", "Found a Lore Item    Flag %i  result: %i", item->generic_info.item_flags, item->generic_info.item_flags & LORE );
			//code to remove item from the list
		}
	}
	PacketStruct* packet = configReader.getStruct("WS_UpdateLoot", GetVersion());
	if(packet){
		vector<Item*>::iterator itr;........continued
i would like to call loot fuction from the groundspawn.cpp

what i cant figure out is how to get this

Code: Select all

client->AddItem(item);
converted into this

Code: Select all

client->Loot(0, item* , client->GetPlayer());

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

Re: add collection item via loot box

Post by Jabantiz » Thu Sep 14, 2017 4:13 pm

You would need to make a vector and put the item into it then pass that vector to the loot function.

Code: Select all

vector<Item*> items;
items.push_back(item);
client->Loot(0, &items, client->GetPlayer());

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: add collection item via loot box

Post by Ememjr » Thu Sep 14, 2017 4:51 pm

aw thanks forgot about the pushback

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: add collection item via loot box

Post by Ememjr » Thu Sep 14, 2017 5:07 pm

ow well that was a fail, for now, gonna take more work than i thought, although that worked to get thecollection item in a loot box, instead of going straight to inventory, the ? groundspawn disappears as soon as you harvest it and cannot actually loot it, since the span is gone.
also since its not an npc spawn loot is not stored on the spawn.
A. so to get this to work i would expect to have a loot table on the spawn so when collecting from it it would be like killing the ? and having body (?) stay for 2 minutes then respawn.
or
B. just make the ? a static npc somehow and have the loot table on in just like an npc.
thoughts??

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

Re: add collection item via loot box

Post by Jabantiz » Fri Sep 15, 2017 12:00 am

It has been a long time since I looked at the loot code so not even sure how it all connects right now.

Ideally I would just add an int32 to groundspawn for the item id (can only have 1 item collected from ground spawns still?) and determine what item it gets when it spawns in the world, then just use that id for loot. You would have to disable the vanish on click behavior ground spawns currently have. I somehow doubt it will be that simple though...

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests