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

Quests::Custom Custom Quests here

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-12-2016, 03:46 AM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default EverQuest Mining

Originally written for Sanctuary (was Adus over there). Saw a version was shared when Secrets released the gardening code some time back, but that wasn't the "improved" version. The code isn't the prettiest damn thing and I have since placed mines in a table and had it control objects, but, for those that would rather not mess with MySQL (it and I aren't exactly friends) here is the Perl only version:

Code:
###################################################################################################
### FILE: /quests/global/items/script_8556.pl
### AUTHOR: Ghanja
### DATE MODIFIED: 01-07-2015
### DEPENDENCIES: None
### NOTE: 	Please do not distribute without consent (nothing top secret here, just a courtesy thing)
###			EverQuest Mining -- originally coded for Zerjz3 (Sanctuary)
###


$mineattempts = 12;

sub EVENT_ITEM_CLICK_CAST
{
	my $primaryitemid;
	my $itemgivenatmine;
	$primaryitemid = $client->GetItemIDAt(13);
	if ($primaryitemid == 35096) {
		$itemgivenatmine = inMiningArea();
		return if ($itemgivenatmine == 0);
		if(isDepleted()) {
			$client->Message(12, "This area looks mined out...");
			return;
		}
		else {
			quest::doanim(87);
			quest::summonitem($itemgivenatmine);
		}
		$client->Message(9, "Clink, clink, clink, there might be something here you think!");
		doMining();
	}
	else { 
	$client->Message(12, "That may work better if you place it in your primary hand!");
	}
}

### [BETA LOGIC] Toss all this shit in a table revisit

############################################################################################################
###  EDIT ONLY THIS PORTION OF THE SCRIPT -- CAREFUL!													 ###
############################################################################################################
###
### Hash key = zone #
### commonitem = most common item (is an array and can be only 1 itemid or many [more than you're likely to ever use]
### rareitem = rareitem rarer than common same applies as far as the array
### rarestitem = rarest item rarer than rare, oh oh almost had it!
### uberitem = like your chances to get this are shit but if you get it ohhh boy look out!

my %mine = (
	# zone 75 - Paineel
	75 => [
        # area (starts at) 0
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => 130,
            y => 808,
            z => 3
        },
        # area 1
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => 456,
            y => 623,
            z => -24
        },
		# area 2
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => 239,
            y => 808,
            z => 2
        },
		# area 3
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => 85,
            y => 781,
            z => 3
        },
		# area 4
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => 56,
            y => 831,
            z => 11
        },
		# area 5
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => 1,
            y => 854,
            z => 7
        },
		# area 6
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => -15,
            y => 903,
            z => 1
        },
		# area 7
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => -518,
            y => 1312,
            z => 29
        },
		# area 8
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => -795,
            y => 1351,
            z => 12
        },
		# area 9
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => -651,
            y => 865,
            z => 15
        },
		# area 10
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => -236,
            y => 770,
            z => 20
        },
		# area 11
        {
			commonitem => [34238,22125,16976,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017,34238,34238],
			uberitem => [10037],
			x => -388,
            y => 1038,
            z => 17
        },
		# area 12
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => -514,
            y => 1311,
            z => 31
        },
		# area 13
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => -623,
            y => 1523,
            z => 19
        },
		# area 14
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => -795,
            y => 1348,
            z => 11
        },
		# area 15
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => -746,
            y => 918,
            z => 15
        },
		# area 16
        {
			commonitem => [34238,22125,16976],
			rareitem => [34238,9180,2381],
			rarestitem => [34238,65599,10017],
			uberitem => [10037],
			x => -388,
            y => 1039,
            z => 19
        },
        # other areas
    ],
    # zone 24 - Erudnext
    24 => [
        # area 0
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => 80,
            y => -30,
            z => 19  
        },
        # area 1
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => 17,
            y => 302,
            z => 47
        },
        # area 2
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => 17,
            y => 47,
            z => 40
        },
        # area 3
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => 158,
            y => 17,
            z => 39
        },
        # area 4
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -112,
            y => 190,
            z => 19
        },
        # area 5
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -337,
            y => -896,
            z => 70
        },
        # area 6
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -15,
            y => -1183,
            z => 90
        },
        # area 7
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -496,
            y => -1213,
            z => 92
        },
        # area 8
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -369,
            y => -1205,
            z => 52
        },
        # area 9
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -494,
            y => -1136,
            z => 53
        },
        # area 10
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -110,
            y => -849,
            z => 51
        },
        # area 11
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -33,
            y => -1086,
            z => 67
        },
        # area 12
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => 61,
            y => 142,
            z => 13
        },
        # area 13
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -59,
            y => -766,
            z => 67
        },
        # area 14
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -398,
            y => -911,
            z => 67
        },
        # area 15
        {
			commonitem => [34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -186,
            y => -581,
            z => 77
        },
        # other areas
    ],
    224 => [
        # area 0
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -1061,
            y => -181,
            z => -41
        },
        # area 1
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -1063,
            y => -149,
            z => -41
        },
        # area 2
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -998,
            y => -311,
            z => 5
        },
        # area 3
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -1032,
            y => -440,
            z => 22
        },
        # area 4
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -1038,
            y => -473,
            z => 19
        },
        # area 5
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -1106,
            y => -540,
            z => 25
        },
        # area 6
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -1127,
            y => -573,
            z => 22
        },
        # area 7
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -1128,
            y => -800,
            z => 27
        },
        # area 8
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -1129,
            y => -762,
            z => 31
        },
        # area 9
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -1128,
            y => -978,
            z => 31
        },
        # area 10
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -1063,
            y => -1039,
            z => 19
        },
        # area 11
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -1026,
            y => -1123,
            z => 28
        },
        # area 12
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -997,
            y => -1130,
            z => 26
        },
        # area 13
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -313,
            y => -1102,
            z => 19
        },
        # area 14
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => 1,
            y => -1093,
            z => 24
        },
        # area 15
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => 77,
            y => -871,
            z => 45
        },
        # area 16
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => 225,
            y => -829,
            z => 82
        },
        # area 17
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => 222,
            y => -931,
            z => 92
        },
        # area 18
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => 324,
            y => -921,
            z => 101
        },
        # area 19
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => 16,
            y => -692,
            z => 27
        },
        # area 20
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => 18,
            y => -529,
            z => 25
        },
        # area 21
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -353,
            y => -425,
            z => 20
        },
        # area 22
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -477,
            y => -197,
            z => -35
        },
        # area 23
        {
			commonitem => [13198,34238,54078,16976],
			rareitem => [34238,65477,16903],
			rarestitem => [88162,16847,34238],
			uberitem => [10037],
            x => -308,
            y => -223,
            z => -28
        },
        # other areas
    ],
	# other zones
);
####################################################################################################
#  END OF MINES EDITABLES
####################################################################################################

sub inMiningArea {
    my $randomvalue = rand(99);
	my $fallbackvalue = rand(9);
	my $returnvalue;
    $area = undef if defined($area);
    return 0 if !exists($mine{$zoneid});
    foreach my $i (keys(@{$mine{$zoneid}})) { 
        my $loc = $mine{$zoneid}[$i];
        if(	int($client->GetX()) ~~ [$loc->{x}-15..$loc->{x}+15] &&
			int($client->GetY()) ~~ [$loc->{y}-15..$loc->{y}+15] &&
			int($client->GetZ()) ~~ [$loc->{z}-25..$loc->{z}+25]) {
			our $area = $i;
			if ($randomvalue > -1 && $randomvalue < 58) {
				my $sizearray = (scalar @{$loc->{commonitem}});
				my $randselection = int(rand($sizearray));
				$returnvalue = $loc->{commonitem}[$randselection];
			}
			elsif ($randomvalue > 57 && $randomvalue < 76) {
				if ($fallbackvalue >= 6) {
					my $sizearray = (scalar @{$loc->{commonitem}});
					my $randselection = int(rand($sizearray));
					$returnvalue = $loc->{commonitem}[$randselection];
				} else {
					$client->Message(9, "Clink, clank, clank.. Your miner's heart just sank!");
					quest::summonitem(47838);
					return 0;
				}
			}
			elsif ($randomvalue > 75 && $randomvalue < 90) {
				if ($fallbackvalue >= 5) {
					my $sizearray = (scalar @{$loc->{rareitem}});
					my $randselection = int(rand($sizearray));
					$returnvalue = $loc->{rareitem}[$randselection];
				} else {
					my $sizearray = (scalar @{$loc->{commonitem}});
					my $randselection = int(rand($sizearray));
					$returnvalue = $loc->{commonitem}[$randselection];
				}
			}
			elsif ($randomvalue > 89 && $randomvalue < 99 ) {
				if ($fallbackvalue >= 5) {
					my $sizearray = (scalar @{$loc->{rarestitem}});
					my $randselection = int(rand($sizearray));
					$returnvalue = $loc->{rarestitem}[$randselection];
				} else {
					my $sizearray = (scalar @{$loc->{rareitem}});
					my $randselection = int(rand($sizearray));
					$returnvalue = $loc->{rareitem}[$randselection];
				}
			}
			elsif ($randomvalue == 99) {
				if ($fallbackvalue >= 7) {
					my $sizearray = (scalar @{$loc->{uberitem}});
					my $randselection = int(rand($sizearray));
					$returnvalue = $loc->{uberitem}[$randselection];
				} else {
					my $sizearray = (scalar @{$loc->{rarestitem}});
					my $randselection = int(rand($sizearray));
					$returnvalue = $loc->{rarestitem}[$randselection];
				}
			}
			return $returnvalue;
		}
		$client->Message(12, "Your hands resonate, though this doesn't appear to be a mine!"); #Zone does have mines you just arent at one!
		return 0;
	}
}
	
sub isDepleted {
	return 1 if !defined($area);
    my $mine = "mine$area";
    return 1 if ((defined($qglobals{$mine})) && ($qglobals{$mine} >= $mineattempts));
    return 0;
}

sub doMining {
    return if !defined($area);
    my $mine = "mine$area";
    if (!defined($qglobals{$mine})) {
        quest::targlobal($mine, 1, "H1", 0, 0, $zoneid);
    } else {
		my $rm = 30 + int(rand(100));
		my $rh = int(rand(1));
		$rm = $rm + 60 if ($rh == 1);
		quest::setglobal($mine, ++$qglobals{$mine}, 3, "M".$rm);
    }
}
### EOF: /quests/global/items/script_8556.pl
I believe this was working without bugs, though I've untested this version in over a year.
 


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 03:00 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