View Single Post
  #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