Thread: Artisan Titles
View Single Post
  #6  
Old 11-16-2015, 06:15 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

I figured KK was going to give you the condensed/efficient method, which is cool.

Though, drop this into Notepad++, in a very quick effort (have to run) to explain somewhat of what is happening. More technically correct terminology can be found throughout the internet. I used as many layman's terms as I could, however, I have to admit, I'm so used to those terms anymore, I may have done more harm than good trying the plain English approach. This is for anyone not just the OP, for those perhaps scratching their heads, wondering "what is that %h all about, seem em before but I still dont 'get it'":

Code:
sub EVENT_ENTERZONE {
    ## Build a Hash (%h) of key-value pairs
	my %h = (7 => 99,	## key 7 has value of 99
    8 => 199,			## key 8 has value of 199
    9 => 249,			## key 9 has value of 249
    10 => 299);			## key 10 has value of 299
    ## foreach goes through all the keys in the above hash placing that key into local variable $key
	foreach my $key (keys %h) {
	## first value of $key will be 7
        if (CheckSkills($client, $h{$key})) {
		## Comparison, calling subroutine CheckSkills exporting $client (the perl quest $client as used elsewhere in other quests)
		## and the value of $h{$key} where $h is just a scalar (single key "pull") of %h, which key defined by { }, specifically
		## $h{$key} whereas again $key is equal to 7 (on first foreach loop) so $h{7} <-- the key we're polling, which has a value of
		## 99 as shown in the hash above, so jump down to subroutine CheckSkills now before reading line below (as it's the order of steps the Perl script takes)
		## if this is anything but 0 (false) it will do the next line

			## Enable title 7 (which as specified in the dbase is "Apprentice Artisan")
			quest::enabletitle($key);
        }
    }
}

sub CheckSkills {
	## local $client equals to first parameter passed by the "if (CheckSkills($client, $h{$key}))" line above, which we established was object $client
	## shift in this case is a scalar (single) pull from the unblessed array made up of all parameters passed to a subroutine (in simple terms)
	## that once used, it moves onto the next parameter within the array
	my $client = shift;
	## shift used again, so its now the next parameter that was passed which we established above was equal to 99
    my $skill_level = shift;
    ## foreach here is going through 60, 61, 63 through 65, 68, 69  (it's entire contents being 60, 61, 63, 64, 65, 68, 69) placing
	## the current value into local $skill
	foreach my $skill (60, 61, 63..65, 68, 69) {
		## Compare, if $client's raw skill in "$skill" (which on the first loop is 60) so
		## if $client->GetRawSkill(60) is less than or equal to $skill_level which we established just above is 99
		## then "return" (or back out of the subroutine with errorlevel 0 which is false)
        if ($client->GetRawSkill($skill) <= $skill_level) {
            ## if comparison condition existed so we're backing out of this subroutine while passing an errorlevel of 0 (false)
			return 0;
        }
    }
    ## we'll get to this line of code only when the "if ($client->GetRawSkill($skill) <= $skill_level)" did not exist,
	## jumping out of the subroutine (CheckSkills) with an errorlevel of 1 (which in the world of 0 and 1, 1 is True)
	return 1;
}
I'm sure someone with time can clean up the explanation a bit, btu gotta go. (always get interrupted this time of day from kids, wife, etc.) Hope it at least helps someone even just a tad.
Reply With Quote