ArcEmu: [lua-optional] Additemset - ArcEmu

Jump to content

Toggle shoutbox Lastest Announcements

dfighter  : (07 December 2014 - 12:06 PM) Arcemu is in hibernation mode, please read http://arcemu.org/fo...showtopic=26903
dfighter  : (01 January 2013 - 05:56 PM) Arcemu wishes you all a happy new year!
Hasbro  : (12 September 2012 - 10:01 AM) Please excuse our outage from the web! Our web host had a major malfunction!
dfighter  : (01 September 2012 - 04:05 PM) Since the spam bots just don't want to stop, I've enabled admin verification when registering.
dfighter  : (23 January 2012 - 09:56 PM) Please note that from now on you will need to confirm your email on the wiki in order to edit it!
Hasbro  : (31 December 2011 - 12:50 PM) Happy New Years all!
Navid  : (26 December 2011 - 04:09 AM) Merry Christmas !!!!!! Happy holidays all :)
WAmadeus  : (24 December 2011 - 03:54 PM) Merry Christmas to all!
dfighter  : (24 December 2011 - 11:05 AM) The Arcemu team wishes y'all a Merry Christmukkah!
Hasbro  : (05 October 2011 - 12:53 PM) Looking for web designers for upcoming web related project. If you're interested in designing user interfaces contact me
dfighter  : (02 September 2011 - 03:47 PM) So who here wants vehicles in Arcemu? :P http://arcemu.org/fo...showtopic=25440
Hasbro  : (14 August 2011 - 03:25 PM) Join us on irc, grab an irc client and connect to irc.freenode.net join channel #arcemu /server irc.freenode.net:6667 /join #arcemu
jackpoz  : (03 August 2011 - 05:33 AM) to all Lua Engine (old one) users: please check http://arcemu.org/fo...showtopic=25274
Hasbro  : (20 May 2011 - 05:27 PM) Looking for people experienced with CMake configuration and setup! Contact me asap
Hasbro  : (15 May 2011 - 05:03 PM) ArcEmu is recruiting C++ programmers, contact Hasbro if interested.
paroxysm  : (03 May 2011 - 06:26 PM) Updated luabridge gossip example to describe the whole gossip creation process rather than just how to create menu. Gossip tutorial
paroxysm  : (23 April 2011 - 11:35 AM) Lua writers can refer to the Luabridge Tutorials section in the Wiki to learn how to write gossip code correctly.
Hasbro  : (20 April 2011 - 05:22 PM) Thank you for your continuous contribution of bug reports, we are working on them.
Hasbro  : (17 April 2011 - 03:20 AM) Please consider donating to support our bills. Donations can be sent using PayPal to donations@arcemu.org - Thank you for your support.
paroxysm  : (10 April 2011 - 12:43 AM) Refer to the Luabridge Tutorials section in the Wiki to learn the new syntax of luabridge.
Resize Shouts Area

Read:

When submitting patches - READ: http://arcemu.org/fo...?showtopic=2355 -
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[lua-optional] Additemset player function to add an itemset

#1 User is offline   lilnate22 

  • Occasional Poster
  • PipPip
  • Group: Members
  • Posts: 135
  • Joined: 08-June 08

Posted 06 January 2011 - 12:10 PM

Really simple patch, that enables the use of AddItemSet in lua.
comes in handy when you want to add tier gear/arena etc.

Index: FunctionTables.h
===================================================================
--- FunctionTables.h	(revision 4015)
+++ FunctionTables.h	(working copy)
@@ -127,6 +127,7 @@
 	{ "GetRandomFriend", &luaUnit::GetRandomFriend },
 	{ "GetRandomEnemy", &luaUnit::GetRandomEnemy },
 	{ "AddItem", &luaUnit::AddItem },
+	{"AddItemSet", &luaUnit::AddItemSet },
 	{ "RemoveItem", &luaUnit::RemoveItem },
 	{ "CreateCustomWaypointMap", &luaUnit::CreateCustomWaypointMap },
 	{ "CreateWaypoint", &luaUnit::CreateWaypoint },
Index: UnitFunctions.h
===================================================================
--- UnitFunctions.h	(revision 4015)
+++ UnitFunctions.h	(working copy)
@@ -924,6 +924,43 @@
 		PUSH_ITEM(L,add);
 		return 1;
 	}
+
+	int AddItemSet(lua_State * L, Unit * ptr)
+	{
+		TEST_PLAYER()
+		int id = luaL_checkint(L,1);
+		Player * plr = TO_PLAYER(ptr);
+		ItemSetEntry *entry = dbcItemSet.LookupEntryForced(id);
+		std::list<ItemPrototype*>* l = objmgr.GetListForItemSet(id);
+		if(!entry || !l)
+		{
+			return 0;
+		}
+
+		for(std::list<ItemPrototype*>::iterator itr = l->begin(); itr != l->end(); ++itr)
+		{
+		Item *itm = objmgr.CreateItem((*itr)->ItemId, plr);
+		if(!itm) continue;
+		if(itm->GetProto()->Bonding == ITEM_BIND_ON_PICKUP)
+		{
+			if(itm->GetProto()->Flags & ITEM_FLAG_ACCOUNTBOUND)
+				itm->AccountBind();
+			else
+				itm->SoulBind();
+		}
+
+		if(!plr->GetItemInterface()->AddItemToFreeSlot(itm))
+		{
+			plr->BroadcastMessage("No free slots left!");
+			itm->DeleteMe();
+			return true;
+		} else {
+				SlotResult * le = plr->GetItemInterface()->LastSearchResult();
+			    plr->SendItemPushResult( false,true,false,true,le->ContainerSlot,le->Slot,1 , itm->GetEntry(), itm->GetItemRandomSuffixFactor(), itm->GetItemRandomPropertyId(), itm->GetStackCount()  );
+			}
+		}
+	}

FREE teamspeak servers Click here!
1

#2 User is offline   Shrexx 

  • Member
  • Pip
  • Group: Members
  • Posts: 37
  • Joined: 29-March 10
  • Gender:Male

Posted 27 August 2011 - 06:20 AM

Nice patch lilnate22!


This function should be applied to arc, it's very useful.
0

#3 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 27 August 2011 - 06:47 AM

View PostShrexx, on 27 August 2011 - 06:20 AM, said:

Nice patch lilnate22!


This function should be applied to arc, it's very useful.

For old sets yes, but WOTLK and later sets work very differently so not for those....
"The demand for free goods is infinite."
0

#4 User is offline   Shrexx 

  • Member
  • Pip
  • Group: Members
  • Posts: 37
  • Joined: 29-March 10
  • Gender:Male

Posted 27 August 2011 - 07:49 AM

View Postdfighter, on 27 August 2011 - 06:47 AM, said:

For old sets yes, but WOTLK and later sets work very differently so not for those....



Ohh :/

maybe you could implemt something similiar at any time? I know you have many different things to do first ;) It just would be very useful :-p instead of :

pPlayer:AddItem(1, 1)
pPlayer:AddItem(2, 1)

and so on...
0

#5 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 27 August 2011 - 07:54 AM

View PostShrexx, on 27 August 2011 - 07:49 AM, said:

Ohh :/

maybe you could implemt something similiar at any time? I know you have many different things to do first ;) It just would be very useful :-p instead of :

pPlayer:AddItem(1, 1)
pPlayer:AddItem(2, 1)

and so on...

It is possible to implement something similar, but I am not at all sure it's really is worth it.
"The demand for free goods is infinite."
0

#6 User is offline   Shrexx 

  • Member
  • Pip
  • Group: Members
  • Posts: 37
  • Joined: 29-March 10
  • Gender:Male

Posted 27 August 2011 - 09:12 AM

I don't know if its worth it.

But we should write our wishes :-P So here is one of mine ;P
0

#7 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 27 August 2011 - 10:40 AM

View PostShrexx, on 27 August 2011 - 09:12 AM, said:

I don't know if its worth it.

But we should write our wishes :-P So here is one of mine ;P

We have a suggestions section on the forums for that ;)

We could add some system for custom item sets, and then you could add from those sets.
However I don't see why you'd really need it.
Since you'd still have to add those numbers, and you might as well just copy&paste them every time you use it...
"The demand for free goods is infinite."
0

#8 User is offline   Shrexx 

  • Member
  • Pip
  • Group: Members
  • Posts: 37
  • Joined: 29-March 10
  • Gender:Male

Posted 27 August 2011 - 12:45 PM

I think its more comfortable ;)

When you want to make a npc, where you can for example select via gossip which Set you want, for examplee "Give me Tier 1 nao!!1" and you then want that the script give the char the set for the right class. Then the script can get very very big with all the "pPlayer:AddItem(1, 1)".

And it will need more resources, right?

To your idea, you could store the custom item sets in db, then you just have to do them once and then you can use them in different scripts.

And just want to know, why would such a function not work when there are is something similiar just as command... ".char additemset"?
0

#9 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 27 August 2011 - 01:16 PM

View PostShrexx, on 27 August 2011 - 12:45 PM, said:

I think its more comfortable ;)

When you want to make a npc, where you can for example select via gossip which Set you want, for examplee "Give me Tier 1 nao!!1" and you then want that the script give the char the set for the right class. Then the script can get very very big with all the "pPlayer:AddItem(1, 1)".

And it will need more resources, right?

To your idea, you could store the custom item sets in db, then you just have to do them once and then you can use them in different scripts.

It's the obvious way to do it.

View PostShrexx, on 27 August 2011 - 12:45 PM, said:

And just want to know, why would such a function not work when there are is something similiar just as command... ".char additemset"?

That doesn't work right with WOTLK sets either.
Basically since WOTLK there are more than 1 version of set per setid. With such methods all versions would be added to the player.
So if the set has 2 versions ( normal and heroic for example ), both sets would be added.
"The demand for free goods is infinite."
0

#10 User is offline   Shrexx 

  • Member
  • Pip
  • Group: Members
  • Posts: 37
  • Joined: 29-March 10
  • Gender:Male

Posted 27 August 2011 - 01:54 PM

yeah i know that with the different sets, like hero and non hero.. and also 10 player set and 25 player set will be added, you are right. Thats not very cool :/
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users