Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Custom

Quests::Custom Custom Quests here

Reply
 
Thread Tools Display Modes
  #1  
Old 07-09-2015, 05:23 PM
Asylum
Sarnak
 
Join Date: Jun 2013
Posts: 81
Default Clarification on Perl loop

Code:
sub EVENT_ITEM {
	if (plugin::check_handin(\%itemcount,8161=>1)) {
		quest::say("You have won! Take this as a reward. Defeat the Skeletal Lord within an hour for one of five random item rewards.");
		quest::summonitem(7967); #2h reward
	}
	if (plugin::check_handin(\%itemcount,8162=>3)) {
		quest::say("You have defeated the Skeletal Lord! Take this as a reward. Defeat the Skeletal Lord within half an hour for a powerful permanent version of the Soul-Caged Rapier.");
		for (1..2) {
			my $reward = quest::ChooseRandom(68752,68754,68756,68758,68768); #1h reward list
			redo if (plugin::check_hasitem($client, $reward)); #check ownership of chosen lore reward
			quest::summonitem($reward);
			last;
		}
	}
	if (plugin::check_handin(\%itemcount,8163=>3)) {
		quest::say("You are quite efficient at defeating the Lord of Undeath. Take this as a reward.");
		quest::summonitem(8164); #30m reward
	}
	else {
		plugin::return_items(\%itemcount);
	}
}
The code works fine in checking if the client turning in the 3 gems has the randomly selected reward and chooses another... until you have all 5 and attempt the turnin, which causes everything to pause. I guess I'm using the last; command incorrectly? or is it the for (1..2) ?
Reply With Quote
  #2  
Old 07-09-2015, 05:26 PM
Asylum
Sarnak
 
Join Date: Jun 2013
Posts: 81
Default

I understand the logic of it making an infinite loop if you have all 5 items, but how do I use the last; command to prevent this?
Reply With Quote
  #3  
Old 07-09-2015, 05:37 PM
Asylum
Sarnak
 
Join Date: Jun 2013
Posts: 81
Default

Code:
sub EVENT_ITEM {
	if (plugin::check_handin(\%itemcount,8161=>1)) {
		quest::say("You have won! Take this as a reward. Defeat the Skeletal Lord within an hour for one of five random item rewards.");
		quest::summonitem(7967); #2h reward
	}
	if (plugin::check_handin(\%itemcount,8162=>3)) {
		if (plugin::check_hasitem($client, 68752) && plugin::check_hasitem($client, 68752) && plugin::check_hasitem($client, 68752) && plugin::check_hasitem($client, 68752) && plugin::check_hasitem($client, 68752)) { #check ownership of all 5 rewards
			quest::say("You possess all 5 possible rewards for the 1-hour event.");
		}
		else {
			quest::say("You have defeated the Skeletal Lord! Take this as a reward. Defeat the Skeletal Lord within half an hour for a powerful permanent version of the Soul-Caged Rapier.");
			for (1..2) {
				my $reward = quest::ChooseRandom(68752,68754,68756,68758,68768); #1h reward list
				redo if (plugin::check_hasitem($client, $reward)); #check ownership of chosen lore reward
				quest::summonitem($reward);
				last;
			}
		}
	}
	if (plugin::check_handin(\%itemcount,8163=>3)) {
		quest::say("You are quite efficient at defeating the Lord of Undeath. Take this as a reward.");
		quest::summonitem(8164); #30m reward
	}
	else {
		plugin::return_items(\%itemcount);
	}
}
This is the solution I've come up with, putting a pre-loop check for possession of all 5 possible rewards, but perhaps someone more experienced in Perl can construct something more efficient and/or concise.
Reply With Quote
  #4  
Old 07-09-2015, 06:05 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,595
Default

Your check is the same item 5 times:
Code:
if (plugin::check_hasitem($client, 68752) && plugin::check_hasitem($client, 68752) && plugin::check_hasitem($client, 68752) && plugin::check_hasitem($client, 68752) && plugin::check_hasitem($client, 68752))
EDIT: Check your inbox for my revised version.
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 06:13 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