From b39ec5547d677fce13a87c0450cac816562111db Mon Sep 17 00:00:00 2001 From: TurmoilToad Date: Sat, 17 Feb 2018 20:30:08 -0500 Subject: [PATCH] Updated Perl EVENT_PROXIMITY_SAY (markdown) --- Perl-EVENT_PROXIMITY_SAY.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Perl-EVENT_PROXIMITY_SAY.md b/Perl-EVENT_PROXIMITY_SAY.md index 3fd6b95..e7866a9 100755 --- a/Perl-EVENT_PROXIMITY_SAY.md +++ b/Perl-EVENT_PROXIMITY_SAY.md @@ -1,4 +1,5 @@ -EVENT_PROXIMITY_SAY +EVENT_PROXIMITY_SAY is triggered when a player uses say within proximity of the NPC, without needing to target the NPC. Proximity is defined by quest::set_proximity(min_x, max_x, min_y, max_y, min_z, max_z). Don't forget to enable proximity say using the quest::enable_proximity_say() function. + ### Exports **Name**|**Type**|**Description** :-----|:-----|:----- @@ -14,4 +15,33 @@ sub EVENT_PROXIMITY_SAY { } ``` +### Triggered + +* When a player uses say near an NPC with a defined proximity and proximity say enabled. +* It is not necessary to have the NPC targeted. + +### Example + +* In this example, if a player near the NPC says "hello?", the NPC will respond + +```perl +sub EVENT_SPAWN { + #:: Set the proximity bounds around the NPC on spawn, 15 unit radius + my $x; + my $y; + $x = $npc->GetX(); + $y = $npc->GetY(); + quest::set_proximity($x-15,$x+15,$y-15,$y+15); + #:: Enable the NPC to listen for say messages within the proximity + quest::enable_proximity_say(); +} + +sub EVENT_PROXIMITY_SAY { + #:: Match the say message like "hello", the "i" is for case-insensitive. + if ($text=~/hello/i) { + quest::say("Get over here and talk to me, $name!"); + } +} +``` + Generated On 2018-01-15T22:07:30-08:00 \ No newline at end of file