Thread: Porters
View Single Post
  #39  
Old 04-21-2015, 02:09 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Crude as hell, but, hopefully you gain something from it:

Code:
sub EVENT_SPAWN {
	quest::settimer("portershout",90);
}

sub EVENT_TIMER {
	if($timer eq "portershout") {
		quest::stoptimer("portershout");
		quest::shout("Porting to all druid locations! Hail me near tunnel to Qeynos Hills!");
		quest::settimer("portershout", int(rand(100))+30);
	}
}

sub EVENT_SAY {
my %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", 56, -357, 1099, -57.93, 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);
				$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);
			quest::selfcast(34);
			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;
}
Reply With Quote