View Single Post
  #37  
Old 10-19-2009, 11:20 PM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,450
Default

I hacked up the tribute code and came up with this.

tribute.cpp, replaced the entire function

Code:
void Client::DoTributeUpdate() {
	
	const Item_Struct* myitem = database.GetItem(1001);
	Item_Struct* item = (Item_Struct*) malloc(sizeof(Item_Struct));
	memcpy(item, myitem, sizeof(Item_Struct));

	if(GetLevel() >= 76 && this->GetClientVersion() == EQClientSoF)
	{
		item->HP += (CalcBaseHP() - 5);
		item->Mana += (CalcMaxMana() - 5);
		item->Endur += (this->max_end - 5);
	}


	const Item_Struct* item2 = item;
	ItemInst* myinst = database.CreateBaseItem(item2);
	SendFakeItem(400, myinst, ItemPacketTributeItem);
			return;
			
}
inventory.cpp, new function

Code:
void Client::SendFakeItem(sint16 slot_id, ItemInst* inst, ItemPacketType packet_type)
{

	if (!inst) 
		return;
	
	// Serialize item into |-delimited string
	string packet = inst->Serialize(slot_id);
	
	EmuOpcode opcode = OP_Unknown;
	EQApplicationPacket* outapp = NULL;
	ItemPacket_Struct* itempacket = NULL;
	
	// Construct packet
	opcode = (packet_type==ItemPacketViewLink) ? OP_ItemLinkResponse : OP_ItemPacket;
	outapp = new EQApplicationPacket(opcode, packet.length()+sizeof(ItemPacket_Struct));
	itempacket = (ItemPacket_Struct*)outapp->pBuffer;
	memcpy(itempacket->SerializedItem, packet.c_str(), packet.length());
	itempacket->PacketType = packet_type;
	
#if EQDEBUG >= 9
		DumpPacket(outapp);
#endif
	//DumpPacket(outapp);
	FastQueuePacket(&outapp);

}
and the corresponding header function in Client.h

Code:
void	SendFakeItem(sint16 slot_id, ItemInst* inst, ItemPacketType packet_type);
and lastly, make it so every time a player gains a level that it recalculates tributes & sends a new item, effectively granting the player a new stat, exp.cpp:

Code:
		DoTributeUpdate();
near

Code:
 CalcBonuses();
        if(!RuleB(Character, HealOnLevel))
        {
                int mhp = CalcMaxHP();
                if(GetHP() > mhp)
                        SetHP(mhp);
        }
        else
        {
                SetHP(CalcMaxHP());             // Why not, lets give them a free heal
        }
		DoTributeUpdate();
        SendHPUpdate();
        SetMana(CalcMaxMana());
        UpdateWho();
        Save();
that should do it. most of the hard work is done.

Also, I would change 1001 to a blank item, or use a non-used ID like 10 for the item. That will resolve adding AC to the client.

Other than that, it works.
Reply With Quote