Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #16  
Old 10-19-2016, 02:03 PM
lordnivek1
Sarnak
 
Join Date: Feb 2013
Posts: 65
Default

Well thank you both for the help. I cant wait to get home from work and try some of this out.
Reply With Quote
  #17  
Old 10-19-2016, 02:20 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Quote:
Originally Posted by lordnivek1 View Post
Well thank you both for the help. I cant wait to get home from work and try some of this out.
Not entirely sure of the "modified" behavior you're looking for, since you've found it's almost surely not possible (at this time) to add an augmented item without source changes.

However, I would use quest::ChooseRandom in place of Perl's rand. Also, know, that rand(4) would produce fractions (i.e. 0.43456, 1.2235, etc.) so that conditional, while it -could- some year be true as you have it written, if you are insistent on using rand(), then:

Code:
my $random = int(rand(3));
Is what you'd be after. Why only 3? Because a pointer to an array element begins at 0, not 1. You have four elements listed, so, 0, 1, 2 and 3 would be valid pointers.

Here is an example of something (without iterating through the %itemcount hash for simplicity, as I'm not sure your comfort level of hashes) utilizing an EVENT_ITEM (i.e. trade) event:

Code:
sub EVENT_ITEM {
	@eligibleitemidarray = (100,200,300,400);
	if (($item1 ~~ @eligibleitemidarray) || 
	($item2 ~~ @eligibleitemidarray) || 
	($item3 ~~ @eligibleitemidarray) || 
	($item4 ~~ @eligibleitemidarray)) {
		my @add_aug1 = ('1000', '1001', '1005', '1007');
		my @add_aug2 = ('5000', '5001', '5005', '5007');
		my $random = quest::ChooseRandom(0..3);
		$client->SummonItem(XXX, 0, 1, $add_aug1[$random], $add_aug2[$random])
	}
	else {
		plugin::return_items(\%itemcount);
	}	
}
Reply With Quote
  #18  
Old 10-19-2016, 02:54 PM
lordnivek1
Sarnak
 
Join Date: Feb 2013
Posts: 65
Default

all my knowledge and familiarity with any of this comes from the wiki introduction to perl scripting, ulitmate perl reference and what I can copy and past from code I find searching the forums/quest folder haha.
Reply With Quote
  #19  
Old 10-19-2016, 03:29 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

I'm going a little beyond my comfort level without having at least Perl installed on this PC, but this may do the trick:

Code:
sub EVENT_LOOT {
	if (quest::ChooseRandom(1..10) < 10) { 
		my %h = (
			1 => [[69,72,81],[69,72,81],[69,72,81],[69,72,81],[91,94,96],[100,142,214]],
			4 => [[45,75,81],[45,75,81],[45,75,81],[45,75,81],[45,75,81],[100,142,214]]
		);
		if ($itemid ~~ keys %h) {
			@augments;
			$unaugmenteditemslot;
			@slots_to_check = (0..30,251..340);
			foreach my $a_s (0..4) {
				$augments[$a_s] = ($h{$itemid}[$a_s][quest::ChooseRandom(0..((scalar @{$h{$itemid}}[$a_s]) - 1 ))]);
			}
			foreach my $slot_check ($slots_to_check) {
				$dupe_check = 0;
				$slot_item_id = $client->GetItemIDAt($slot_check);
				if ($itemid == $slot_item_id) {
					for ($augment_check = 0; $augment_check < 5; $augment_check++) {
						$augment_item_id = $client->GetAugmentIDAt($slot_item_id, $augment_check);
						$unaugmenteditemslot = $slot_check if ($augment_item_id = 0);
						++$dupe_check if ($augment_item_id == $augments[$augment_check]);
					}
				}
			}
			$client->RemoveItem($itemid, 1, $unaugmentedslot);
			if ($dupe_check = 5) {
				$client->Message(7, "That item has poofed into the abyss as you already have one just like it!");
			} else {
				$client->SummonItem($itemid,0,1,$augments[0],$augments[1],$augments[2],$augments[3],$augments[4],$unaugmentedslot);
			}
		}
	}
}
It will need to be checked for logic (heading out of town so no time). It appears sound.

I -think- it will function as closely as what you were after. I used the augment item ID's of what you originally provided for reference of what is going on in the hash of arrays. The key values (ie. 1 and 4) are the item ID's of the main item you're dealing with.

Gotta run, good luck.
Reply With Quote
  #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
  #21  
Old 10-19-2016, 11:03 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Quote:
Originally Posted by Darkscis View Post
$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.


Disclaimer: I have not actually used it in this way so experiment at your own peril
Appreciate that bud, I didn't have access to the source where I was at the time, so that's definitely useful information (because, even though I can view it now, I didn't bother to, my bad).

(*ninja edit) Updated so that the SummonItem places the newly augmented item where it found the unaugmented (freshly looted) one.
Reply With Quote
  #22  
Old 10-19-2016, 11:05 PM
Darkscis
Sarnak
 
Join Date: Mar 2015
Posts: 62
Default

Sorry for double post - but I also looked into quest::addloot and it *looks* like a fairly simple code change if you are comfortable modifying source. If not, use SummonItem.

Code:
void NPC::AddLootDrop(const EQEmu::ItemData *item2, ItemList* itemlist, int16 charges, uint8 minlevel, uint8 maxlevel, bool equipit, bool wearchange) {

...

item->item_id = item2->ID;
item->charges = charges;
item->aug_1 = 0;
item->aug_2 = 0;
item->aug_3 = 0;
item->aug_4 = 0;
item->aug_5 = 0;
item->aug_6 = 0;
item->attuned = 0;
item->min_level = minlevel;
item->max_level = maxlevel;

...
So quest::addloot eventually calls NPC::AddItem which in turn calls NPC::AddLootDrop. The above is a snippet of AddLootDrop which shows that it does set the item augs, it just defaults them to 0 and doesn't allow any input from anywhere. Without further investigation I don't know if this is specifically to prevent a bug or something but you could try modifying it so it accepts augment arguments, then modify the questmanager calls and Perl parser respectively. That would be more advanced than you may like though...
Reply With Quote
  #23  
Old 10-19-2016, 11:12 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

I'm finalizing packing before heading out of state. I have NPC::AddLootDrop open now (as a result of revisiting this thread due to your initial post) and, yeah, I see that as well. Actually not much involved, append parameters to the function's existing parameters, if null/undef default to 0 as they are now already so it doesn't break anything, then as you said modify the questmanager calls and Perl/LUA parser.

If this preparing doesn't take too much longer, I'll have a dig at it, otherwise, I'm sure someone else may jump in (which is fine, I need to get back to what I was doing but ADD kicked in, actually it was getting monotonous).
Reply With Quote
  #24  
Old 10-19-2016, 11:15 PM
Darkscis
Sarnak
 
Join Date: Mar 2015
Posts: 62
Default

Quote:
Originally Posted by ghanja View Post
I'm finalizing packing before heading out of state. I have NPC::AddLootDrop open now (as a result of revisiting this thread due to your initial post) and, yeah, I see that as well. Actually not much involved, append parameters to the function's existing parameters, if null/undef default to 0 as they are now already so it doesn't break anything, then as you said modify the questmanager calls and Perl/LUA parser.

If this preparing doesn't take too much longer, I'll have a dig at it, otherwise, I'm sure someone else may jump in (which is fine, I need to get back to what I was doing but ADD kicked in, actually it was getting monotonous).
My only concern would be if it was intentionally left that way as adding augments breaks something further down the line. Doesn't hurt to give it a go though, easily reversible.

EDIT: Also I love your script. Do you mind if I shamelessly copy a chunk of it to use for finding empty inventory slots for my NPC barter system? At the moment I just summon all the items traded to cursor and let the client handle placing them but with your slot finder section I could find empty slots and summon to those instead.
Reply With Quote
  #25  
Old 10-20-2016, 10:38 AM
lordnivek1
Sarnak
 
Join Date: Feb 2013
Posts: 65
Default

Thanks to everyone that replied to this. this is all great stuff.
Reply With Quote
  #26  
Old 10-20-2016, 08:57 PM
lordnivek1
Sarnak
 
Join Date: Feb 2013
Posts: 65
Default

So I finally got some time to play around with this and here is what I have. I went with having a NPC identifing the item as it fits my server even better then the item just dropping plus by adding a fee it adds a small money sink. And its not hard to just make a dummy (unidentified) item for each item. One thing I could not get to work was aug6. I could only ever get it to work up to aug5. It would leave the slot blank and then eventually just stop working. I also found if i didnt set up a random for each aug it would pick the same number for all 5.

Code:
sub EVENT_ITEM{
  if(plugin::check_handin(\%itemcount, 5001 => 1)) {
        my @add_aug1 = ('1', '9', '25', '33', '41', '49', '65', '81', '89', '97', '105' ,'113', '121', '129', '137');
	my $random1 = quest::ChooseRandom(0..14);
	my @add_aug2 = ('1', '9', '25', '33', '41', '49', '65', '81', '89', '97', '105' ,'113', '121', '129', '137');
	my $random2 = quest::ChooseRandom(0..14);
	my @add_aug3 = ('1', '9', '25', '33', '41', '49', '65', '81', '89', '97', '105' ,'113', '121', '129', '137');
	my $random3 = quest::ChooseRandom(0..14);
	my @add_aug4 = ('1', '9', '25', '33', '41', '49', '65', '81', '89', '97', '105' ,'113', '121', '129', '137');
	my $random4 = quest::ChooseRandom(0..14);
	my @add_aug5 = ('1', '9', '25', '33', '41', '49', '65', '81', '89', '97', '105' ,'113', '121', '129', '137');
	my $random5 = quest::ChooseRandom(0..14);
	$client->SummonItem(5000, 0, 1, $add_aug1[$random1], $add_aug2[$random2], $add_aug3[$random3], $add_aug4[$random4], $add_aug5[$random5])
  }
  plugin::return_items(\%itemcount); 
}

Thanks again for all the input. This works great.
Reply With Quote
  #27  
Old 10-20-2016, 09:17 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,595
Default

I added augment support to $npc->AddItem() and quest::addloo0,, I never thought of something like this, so I'm glad you brought this up. Hopefully you can make use of it, but you'll have to wait until this pull request is merged so you can pull the code down and use augments in these functions.
Reply With Quote
  #28  
Old 10-20-2016, 09:19 PM
Uleat's Avatar
Uleat
Developer
 
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
Default

"Usage: Client::SummonItem(THIS, item_id, charges=0, attune=0, aug1=0, aug2=0, aug3=0, aug4=0, aug5=0, slot_id=30)"

The perl api isn't coded to handle the extra aug slot.

Not easy to change since it would break any pre-existing scripts based on the 5-augment code.
__________________
Uleat of Bertoxxulous

Compilin' Dirty
Reply With Quote
  #29  
Old 10-24-2016, 12:52 PM
Maze_EQ
Demi-God
 
Join Date: Mar 2012
Posts: 1,103
Default

Kinglay Karab for duh wein
__________________
"No, thanks, man. I don't want you fucking up my life, too."

Skype:
Comerian1
Reply With Quote
  #30  
Old 10-27-2016, 09:09 PM
Darkscis
Sarnak
 
Join Date: Mar 2015
Posts: 62
Default

Not quite the original intended purpose but I can confirm $client->SummonItem works great when supplying a slot id. I used ghanja's code to iterate through inventory slots and then summon items direct to a free one in my trading system. Kind of moot now that KK has fixed the loot ones, but good to know nevertheless!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 02:51 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3