PDA

View Full Version : Proximity quests example


fathernitwit
11-10-2004, 10:37 AM
Heres an example of how you might use the new proximity quests.
Proximity quests are quest events that are triggered by a player entering or leaving a defined area.
note: they do not behave properly if you log/zone into a proximity yet.

important functions:
quest::set_proximity(minx, maxx, miny, maxy); - enable a proximity
quest::clear_proximity(); - clear our proximity

for now, an NPC can only have 1 proximity, but it can be anywhere in the zone. It makes sense to set it up in the EVENT_SPAWN unless it is only triggered by certain events.

Another note: proximities use server resources... while it is not a lot, if you have 100+ proximities in a zone, your prolly going to be able to notice the increased load if theres many players in the zone.

This example employs the new proximity quest, as well as some XS classes stuff.

Race quest, kinda dumb, oh well:

sub EVENT_SPAWN {
$x = $npc->GetX();
$y = $npc->GetY();
quest::set_proximity($x - 20, $x + 20, $y - 20, $y + 20);
}

sub EVENT_ENTER {
my $n = $client->GetName();
quest::say("Congratulations $n, you have won the race!");
$winner = $client->GetID();
quest::clear_proximity();
}

sub EVENT_EXIT {
$n = $client->GetName();
$client->Message(0, "Bye $n!");
}

sub EVENT_SAY {
if($text=~/Hail/i) {
if($winner == $client->GetID()) {
quest::say("Hello ".$client->GetName().", good work on winning the race.");
quest::summonitem(10037, 1);
$winner = -1;
} else {
quest::say("You did not win the race, go away.");
}
} elsif($text =~ /reset/i) {
$x = $npc->GetX();
$y = $npc->GetY();
quest::set_proximity($x - 20, $x + 20, $y - 20, $y + 20);
quest::say("The race has been reset");
}
}

Scorpx725
11-11-2004, 04:07 AM
Thanks alot for this, FNW. This opens up alot of new ideas.

Keep going with this new quest system, at first I didnt like it but now, it seems nice.