Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Ascent [Issue] .additem <itemID> spawns items without "of blah blah"

Newbie Spellweaver
Joined
Jun 5, 2008
Messages
77
Reaction score
0
recently I spawned a green item that should have had "of intellect" but instead it spawns a item with no stats... I posted the bug on the forum for arcemu with no answer so I dug into the src finding in "level1.cpp" the gm command handler to which I fiddled with and got working said issue here is the resulting edited code for anyone else curious or wanting it fixed also. this "fix" doesn't apply the stats based on the chance listed in the database instead it does it by a random pick of the possible outcomes if anyone wants to update the code I'd be willing to work with them.

Code:
bool ChatHandler::HandleAddInvItemCommand(const char *args, WorldSession *m_session)
{
	uint32 itemid, count=1;
	int32 randomprop=0;
	string tempholder="";

	if(strlen(args) < 1)
	{
		return false;
	}

	if(sscanf(args, "%u %u %d", &itemid, &count, &randomprop) < 1)
		return false;

	Player * chr = getSelectedChar( m_session, false );
	if ( chr == NULL )
		chr = m_session->GetPlayer();
	
	ItemPrototype * it = ItemPrototypeStorage.LookupEntry(itemid);
	if(it)
	{
		sGMLog.writefromsession(m_session, "used add item command, item id %u [%s] to %s", it->ItemId, it->Name1, chr->GetName());
		Item *item;
		item = objmgr.CreateItem( itemid, chr);
		item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, ((count > it->MaxCount) ? it->MaxCount : count));
		
		std::string my_query99 = "SELECT randomprop FROM items WHERE entry = " + MyConvertIntToString(itemid);
		QueryResult *spawnResult99 = WorldDatabase.Query(my_query99.c_str()); //gets the randomprop id from database
		if(spawnResult99!=NULL)
		{
			Field *fields = spawnResult99->Fetch();
			randomprop = fields[0].GetUInt32();
			//RedSystemMessage(m_session, "I'm inside?");

			delete spawnResult99;

			std::string my_query98 = "SELECT * FROM item_randomprop_groups WHERE entry_id = " + MyConvertIntToString(randomprop);
			QueryResult *spawnResult98 = WorldDatabase.Query(my_query98.c_str()); //gets the randomprop group from database
			uint32 total =(uint32) spawnResult98->GetRowCount();
			int i;
			int picked = rand() % total + 1;
			for(i= 0; i < picked; i++)
				spawnResult98->NextRow();

			Field *f3 = spawnResult98->Fetch();
			randomprop = f3[1].GetUInt32(); //sets the propID so itemrandomproperties.dbc knows what stats/suffix to set
		}
		//RedSystemMessage(m_session, "ItemID = %d!", itemid);
		//RedSystemMessage(m_session, "RandomProp = %d!", randomprop);

		if(it->Bonding==ITEM_BIND_ON_PICKUP)
			item->SoulBind();
		if(randomprop!=0)
		{
			if(randomprop<0)
				item->SetRandomSuffix(abs(int(randomprop)));
			else
				item->SetRandomProperty(randomprop);

			item->ApplyRandomProperties(true);
		}
	  
		if(!chr->GetItemInterface()->AddItemToFreeSlot(item))
		{
			m_session->SendNotification("No free slots were found in your inventory!");
			ItemPool.PooledDelete( item );
			return true;
		}

		char messagetext[512];
		snprintf(messagetext, 512, "Adding item %s (id: %d) to %s's inventory.", GetItemLinkByProto(it, m_session->language), (unsigned int)it->ItemId, chr->GetName());
		SystemMessage(m_session, messagetext);
		snprintf(messagetext, 128, "%s added item %d (%s) to your inventory.", m_session->GetPlayer()->GetName(), (unsigned int)itemid, it->Name1);
		snprintf(messagetext, 512, "%s added item %s to your inventory.", m_session->GetPlayer()->GetName(), GetItemLinkByProto(it, chr->GetSession()->language));
		
		SystemMessageToPlr(chr,  messagetext);

		SlotResult *lr = chr->GetItemInterface()->LastSearchResult();
		chr->GetSession()->SendItemPushResult(item,false,true,false,true,lr->ContainerSlot,lr->Slot,count);

		return true;
	} else {
		RedSystemMessage(m_session, "Item %d is not a valid item!", itemid);
		return true;
	}
}
 
Last edited:
Newbie Spellweaver
Joined
May 27, 2007
Messages
25
Reaction score
0
dude i tell u.. noone tells about fixing issues.. i posted an issue on 6 forums and still n oanswer.. w/e
 
www.Warforge.Online
Joined
Jun 25, 2008
Messages
534
Reaction score
0
Hmm sounds like everyone will be using Aspire xD
 
Newbie Spellweaver
Joined
Jun 5, 2008
Messages
77
Reaction score
0
if I didn't need to fix anything I wouldn't have any reason to play with/break/fix it again so I'd never learn anything new *shrugs*

what was your issue oceeman?
 
Newbie Spellweaver
Joined
Mar 7, 2008
Messages
95
Reaction score
0
hm thats a wwierd problem, bump this topic please.
 
Junior Spellweaver
Joined
Jun 30, 2007
Messages
195
Reaction score
0
use .char additem (ID) thats the new additem command.
 
Back
Top