View Single Post
  #20  
Old 10-19-2016, 10:47 PM
Darkscis
Sarnak
 
Join Date: Mar 2015
Posts: 62
Default

$client->SummonItem technically can be passed a slot_id, it's just unlisted on the Perl Ultimate reference page and defaults to 30 (cursor). What you would have to do in the case of a "right click auto loot" instead of a left click on cursor is determine what slot the loot landed in, and then Nuke->SummonItem.

Code:
XS(XS_Client_SummonItem)
{
	dXSARGS;
	if (items < 2 || items > 10)
		Perl_croak(aTHX_ "Usage: Client::SummonItem(THIS, item_id, charges=0, attune=0, aug1=0, aug2=0, aug3=0, aug4=0, aug5=0, slot_id=30)");
	{
		Client *		THIS;
		uint32		item_id = (uint32)SvUV(ST(1));
		int16		charges = -1;
		bool		attune = false;
		uint32		aug1 = 0;
		uint32		aug2 = 0;
		uint32		aug3 = 0;
		uint32		aug4 = 0;
		uint32		aug5 = 0;
		uint16		slot_id = 30;

		if (sv_derived_from(ST(0), "Client")) {
			IV tmp = SvIV((SV*)SvRV(ST(0)));
			THIS = INT2PTR(Client *,tmp);
		}
		else
			Perl_croak(aTHX_ "THIS is not of type Client");
		if(THIS == nullptr)
			Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");

		if (items > 2) {
			charges = (int16)SvIV(ST(2));
		}
		if (items > 3) {
			attune = (bool)SvTRUE(ST(3));
		}
		if (items > 4) {
			aug1 = (uint32)SvUV(ST(4));
		}
		if (items > 5) {
			aug2 = (uint32)SvUV(ST(5));
		}
		if (items > 6) {
			aug3 = (uint32)SvUV(ST(6));
		}
		if (items > 7) {
			aug4 = (uint32)SvUV(ST(7));
		}
		if (items > 8) {
			aug5 = (uint32)SvUV(ST(8));
		}
		if (items > 9) {
			slot_id = (uint16)SvUV(ST(9));
		}

		THIS->SummonItem(item_id, charges, aug1, aug2, aug3, aug4, aug5, 0, attune, slot_id);
	}
	XSRETURN_EMPTY;
}
Disclaimer: I have not actually used it in this way so experiment at your own peril
Reply With Quote