Thread: Porters
View Single Post
  #12  
Old 04-25-2015, 12:43 AM
markusdabrave's Avatar
markusdabrave
Sarnak
 
Join Date: Jan 2012
Location: Plano, TX
Posts: 70
Default

Thanks to everyone for their help on this. Admittedly, I feel that ghanja did a lot of the heavy lifting here so I'd be remiss to not give credit where credit is due. I mainly built upon his suggestions. Big thanks for all your patience.

Here's the finished product, but first - some notes:

1. This requires the NPC be either a druid or a wizard class. In my case, I added druid NPCs to druid rings and wizard NPCs to wizard spires using this method and slapped this script on them.

2. This ports to old world maps. More specifically, Vanilla EQ original maps (except Lavastorm - working on that). With minor tweaking of the zone ID# and x,y,z,h locations in the %porthash(es) or adding additional zones, it could easily be made to work with other zones. Though if you wanted to, you could add them anywhere you wanted to stick a porter.

3. It automatically casts invis on whoever is being ported (this is to allow evil races to use them with minimal risk of druids eating them).

4. It has spell effects and a small delay for aesthetics.


Code:
###########################################################
# Druid/Wizard NPC Porter Script

sub EVENT_SAY {
	# Druid Ports
	if ($npc->GetClass() == 6) {
		our %porthash = (
			"surefall" => ["Surefall Glade", 3, -391, -209, 4.75, 0],
			"butcher" => ["Butcherblock Mountains",68, 1984, -2135, 0],
			"feerrott" => ["The Feerrott",47, -1885, 367, 13.57, 0],
			"northkarana" => ["North Karana",13, -1494, -2706, -7.5, 0],
			"lavastorm" => ["Lavastorm Mountains",27, 460, 460, -84.88, 0],
			"misty" => ["Misty Thicket",33, -1896, -490, 120.34, 0],
			"sro" => ["South Ro",35, 317, -2034, -22.64, 0],
			"steamfont" => ["Steamfont Mountains",56, 1668, -1779, -108.07, 0],
			"commons" => ["West Commonlands", 21, 1427, 479, -51, 0],
			"toxxulia" => ["Toxxulia Forest", 38, -357, 1099, -57.93, 0],
		);
	}
	# Wizard Ports
	elsif ($npc->GetClass() == 12) {
		our %porthash = (
			"toxxulia" => ["Toxxulia Forest", 38, -916, -1510, -37, 0],
			"northkarana" => ["North Karana", 13, 1209, -3685, -8.38, 0],
			"gfaydark" => ["Greater Faydark", 54, -441, -2023, 0, 0],
			"commons" => ["West Commonlands", 21, 1840, -3.85, -15.42, 0],
			"nektulos" => ["Nektulos Forest", 25, -768, 432, 33,0],
			"nro" => ["North Ro", 34, 823, 1377, 10 ,0],
			"cazicthule" => ["Cazic-Thule", 48, -466, 253, 20, 0],
			"karana" => ["West Karana", 12, -14815, -3569, 36, 0],
		);
	}
	if ($text=~/Hail/i) {
		plugin::Whisper("Hail! Where would you like to go? ");
		foreach my $key (keys %porthash) {
			$client->Message(315, "[".quest::saylink($key, 1, $porthash{$key}[0])."]");
		}
	}	
	elsif (defined $porthash{$text}) {
		if ($client->IsGrouped()) {
			quest::doanim(43);
			foreach my $group_member (ClientCloseEnoughGroupMembers($client)) {
				$group_member->SpellEffect(43,10);
				if (!$group_member->FindBuff(34)) {
					$npc->SpellFinished(34, $group_member);
				}
			}	
			castdelay(5);
			foreach my $group_member (ClientCloseEnoughGroupMembers($client)) {
				$group_member->Message (315, "".$npc->GetCleanName()." whispers, 'Off to ".$porthash{$text}[0]." you go!");
				$group_member->MovePC($porthash{$text}[1],$porthash{$text}[2],$porthash{$text}[3],$porthash{$text}[4],$porthash{$text}[5]);
			}
		}	
		else {
			quest::doanim(43);
			$client->SpellEffect(43,10);
			castdelay(5);
			if (!$client->FindBuff(34)) {
				$npc->SpellFinished(34, $client);
			}
			quest::movepc($porthash{$text}[1],$porthash{$text}[2],$porthash{$text}[3],$porthash{$text}[4],$porthash{$text}[5]);
		}
	}	
}

sub ClientCloseEnoughGroupMembers {
	my @return_group;
	my $entire_group = $entity_list->GetGroupByClient(shift);
	if ($entire_group) {
		for ($count = 0; $count < 6; $count++) {
			my $group_member = $entire_group->GetMember ($count);
			if ($group_member) {
				if ($group_member->IsClient()) {
					if ($group_member->CalculateDistance($x,$y,$z) <= 30) {
						push (@return_group, $group_member);
					}
				}
			}
		}
	return @return_group;
	}
}

sub castdelay{
	$delayOver = (time + $_[0]);
	while (time < $delayOver){}
	1;
}
If you want your porters to broadcast/shout they are porting, adding the below code will make them shout every 2-3 1/2 minutes. The only thing is you might want to change the Surefall glade NPC's verbiage as it's not really a druid ring (so to speak).

Code:
sub EVENT_SPAWN {
	quest::settimer("portershout", int(rand(120))+90);
}

sub EVENT_TIMER {
	if($timer eq "portershout") {
		quest::stoptimer("portershout");
		if ($npc->GetClass() == 6) {
		quest::shout("Porting to all druid locations! Hail me near druid ring!");
		}
		elsif($npc->GetClass() == 12){
		quest::shout("Porting to all wizard locations! Hail me at wizard spire!");
		}
		quest::settimer("portershout", int(rand(120))+90);
	}
}
Reply With Quote