Event Subroutines

This is a listing of the Event Subroutines used in quest scripts. Each of these Events is triggered as an action occurs.

Please note that while every effort is made to keep this wiki up to date, some items may have been overlooked. A complete list can be found in GitHub at Server / zone / embparser.cpp.

ProTip: hit ctrl + f (Windows) or ⌘ + f (Mac) to FIND something on this page

EVENT_AGGRO

Trigger

  • When a mob aggros a client.

Often used for flavor text--just remember that every NPC_Type has an EmoteID that can often handle this behavior.

Example

  • In this example, the NPC will say "Time to die PlayerName." when the NPC is aggro'd by the player.

Perl
Lua
sub EVENT_AGGRO {
quest::say("Time to die!");
}
function event_aggro(e)
e.self:Say("Time to die!");
end

EVENT_AGGRO_SAY

Trigger

  • When a mob is targeted, the player types something, and NPC is in combat.

Exports

Name

Type

Usage

data

int

quest::say($data); # returns int

text

int

quest::say($text); # returns int

langid

int

quest::say($langid); # returns int

Example

  • In this example, the NPC, if in combat, would say the names of everyone on its hate list, and include both the amount of damage the entity has done, as well as the amount of hate the entity has generated.

Perl
Lua
sub EVENT_AGGRO_SAY {
#:: Match "fight", case insensitive, if the NPC aggro
if ($text=~/fight/i) {
quest::say("I am fighting!");
}
}
function event_aggro_say(e)
if (e.message:findi("fight")) then
e.self:Say("I am fighting!");
end
end

EVENT_ATTACK

Trigger

  • When the NPC is attacked.

Note the subtle difference from EVENT_AGGRO, which is triggered when the NPC is aggro'd (which could occur through bad faction, for instance).

Example

  • In this example, the NPC will say "Time to die PlayerName." when the NPC is attacked by the player.

Perl
Lua
sub EVENT_ATTACK {
quest::say("Time to die $name.");
}
function event_attack(e)
e.self:Say("Time to die!");
end

EVENT_AUGMENT_ITEM

Trigger

  • When a client augments an item.

You would likely use this event in your global player.pl file.

Example

  • In this example, a message in yellow text is displayed to the client when the player adds an augment to an item.

Perl
Lua
sub EVENT_AUGMENT_ITEM{
$client->Message(15, "Yay, it fit!");
}
function event_augment_item(e)
e.owner:Message(15, "Yay, it fit!");
end

EVENT_AUGMENT_INSERT

Trigger

  • When a client inserts an augment into an item.

You would likely use this event in your global player.pl file.

Example

  • In this example, a message in yellow text is displayed to the client when the player puts the augment into the augment slot of an item.

Perl
Lua
sub EVENT_AUGMENT_INSERT {
$client->Message(15, "Yay, it fit!");
}
function event_augment_insert(e)
e.owner:Message(15, "Yay, it fit!");
end

EVENT_AUGMENT_REMOVE

Trigger

  • When a client removes an augment from an item. You would likely use this event in your global player.pl file.

Example

  • In this example, a message in yellow text is displayed to the client when the player removes an augment from an item.

Perl
Lua
sub EVENT_AUGMENT_REMOVE {
$client->Message(15, "Yay, you pulled it out!");
}
function event_augment_remove(e)
e.owner:Message(15, "Yay, you pulled it out!");
end

EVENT_CAST

Trigger

  • When a client casts a spell.

Exports

Name

Type

Usage

spell_id

int

quest::say($spell_id); # returns int

Example

  • In this example, the player would emote upon a successful cast.

Perl
Lua
sub EVENT_CAST {
quest::me("regains his concentration and casts his spell.");
}
function event_cast(e)
e.self:Emote("regains his concentration and casts his spell.");
end

EVENT_CAST_BEGIN

Trigger

  • When a client begins to cast a spell.

Exports

Name

Type

Usage

spell_id

int

quest::say($spell_id); # returns int

Example

  • In this example, the player would emote if they begin casting the gate spell. You would likely place this particular snippet into your global player.pl file.

Perl
Lua
sub EVENT_CAST_BEGIN {
#:: Match if $spell_id is 36 - Gate
if ($spell_id == 36) {
quest::me("begins casting the Gate spell.");
}
}
function event_cast_begin(e)
--:: Match if spell_id is 36 - Hate
local spell_id = e.spell:GetID();
if (spell_id == 36) then
e.self:Emote("begins casting the Gate spell.");
end
end

EVENT_CAST_ON

Trigger

  • When a player casts a spell on a player or NPC.

Exports

Name

Type

Usage

spell_id

int

quest::say($spell_id); # returns int

Example

  • In this example, if the player casts Banish Summoned on an NPC with a Summoned body type, the NPC will be killed. If you were placing this snippet in an NPC's quest script, you likely wouldn't bother matching body type.

Perl
Lua
sub EVENT_CAST_ON {
#:: Match if $spell_id is 116 - Banish Summoned
if ($spell_id == 116) {
#:: Match if the NPC's body type is 28 - Summoned Creature
if ($mob->GetBodyType() == 28) {
$npc->Kill();
}
else {
$client->Message(13, "This spell only effects summoned creatures");
}
}
}
function event_cast_on(e)
--:: Match if spell_id is 116 - Banish Summoned
local spell_id = e.spell:GetID();
if (spell_id == 116) then
--:: Match if the NPC's body type is 28 - Summoned Creature
local body_type = e.self:GetBodyType();
if (body_type == 28) then
e.self:Kill();
else
if (e.self:IsClient()) then
e.self:Message(13, "This spell only effects summoned creatures.");
end
end
end
end

EVENT_CLICKDOOR

Trigger

  • When the client clicks on a door object.

Note that you would likely use this event in the zone player.pl file. Since doors have open types and destination fields stored in the database, most "simple" doors do not require a separate quest script. An example of a "simple" door would be any door that requires a single keyitem (by Item ID) to open, like the door to the basement in Befallen.

Exports

Name

Type

Usage

doorid

int

quest::say($doorid); # returns int

version

int

quest::say($version); # returns int

Example

  • In this example, a player who is part of a Deepest Guk Adventure would be teleported to Deepest Guk when they click the doorway found in the Hollow Log.

Perl
Lua
sub EVENT_CLICKDOOR {
#:: Match if doorID is 1 - the door found in the Hollow Log that leads to Deepest Guk Adventures
if ($doorid == 1) {
#:: Create a variable to store the player's adventure zone instance ID
$GukAInstance = quest::GetInstanceID("guka",50);
#:: Match if the player has an instance
if ($GukAInstance > 0) {
#:: Teleport the player to their instance in Deepest Guk at the safe spot
quest::MovePCInstance(229, $GukAInstance, 101, -841, 2.38);
}
else {
$client->Message(13, "You are not a part of a Deepest Guk adventure instance!");
}
}
}
function event_click_door(e)
--:: Match if doorID is 1 - the door found in the Hollow Log that leads to Deepest Guk Adventures
local door_id = e.door:GetDoorID();
if (door_id == 1) then
--:: Create a variable to store the player's adventure zone instance ID
local guka_instance = eq.get_instance_id("guka", 50);
--:: Match if the player has an instance
if (guka_instance > 0) then
--:: Teleport the player to their instance in Deepest Guk at the safe spot
e.self:MovePCInstance(229, guka_instance, 101, -841, 2.38);
else
e.self:Message(13, "You are not a part of a Deepest Guk adventure instance!");
end
end
end

EVENT_CLICK_OBJECT

Trigger

  • When the client clicks on an object.

Note the similarity between this event and Perl EVENT_CLICKDOOR, since it is easy to confuse a door object (like a Plane of Knowledge Book) with Objects (IE Pottery wheels, Brew Barrels, etc.). You would likely use this event in the zone player.pl (or global_player.pl) files.

Exports

Name

Type

Usage

objectid

int

quest::say($objectid); # returns int

clicker_id

int

quest::say($clicker_id); # returns int

Example

  • In this example, a message is displayed to a player when they open the Ogre Cultural Forge in Oggok.

Perl
Lua
sub EVENT_CLICK_OBJECT {
#:: Match to the ogre cultural forge in Oggok by object ID
if ($objectid == 1075) {
#:: Check to see if the player who clicked is a race other than Ogre
if ($race ne "Ogre") {
#:: Send the client a message in color 1 (gray)
$client->Message(1,"The foul stench of Ogre overwhelms you as you open the forge.");
} else {
$client->Message(1,"Mmmm--dis smells just like home.");
}
}
}
function event_click_object(e)
--:: Match to the ogre cultural forge in Oggok by object ID
local object_id = e.object:GetID();
if (object_id == 1075) then
--:: Check to see if the player who clicked is a race other than Ogre
local race_id = e.self:GetRace();
if (race_id != 10) then
--:: Send the client a message in color 1 (gray)
e.self:Message(1,"The foul stench of Ogre overwhelms you as you open the forge.");
else
e.self:Message(1,"Mmmm--dis smells just like home.");
end
end
end

EVENT_COMBAT

Trigger

  • When an NPC enters or leaves combat.

Exports

Name

Type

Usage

combat_state

int

quest::say($combat_state); # returns int

Example

  • In this example, the NPC will say some flavor text when entering combat.

Perl
Lua
sub EVENT_COMBAT {
#:: combat state 0 = False, 1 = True
if ($combat_state == 1) {
quest::say("Time to die!");
}
}
function event_combat(e)
--:: e.joined is true/false
if (e.joined) then
e.self:Say("Time to die!");
end
end

EVENT_COMBINE_FAILURE

Trigger

  • When a combine is unsuccessful. You would likely use this event in your global / player.pl file.

Exports

Name

Type

Usage

recipe_id

int

quest::say($recipe_id); # returns int

recipe_name

int

quest::say($recipe_name); # returns int

Example

  • In this example, we watch for a player failing the combine for a Hand Made Backpack and then tease them.

Perl
Lua
sub EVENT_COMBINE_FAILURE {
#:: Match Recipe 2686: "Hand Made Backpack" by ID
if ($recipe_id == 2686) {
#:: Send the client a message in color 15 (yellow)
$client->Message(15,"Awww...now where are you going to put all of your stuff?");
}
}
function event_combine_failure(e)
--:: Match Recipe 2686: "Hand Made Backpack" by ID
if (e.recipe_id == 2686) then
--:: Send the client a message in color 15 (yellow)
e.self:Message(15, "Awww...now where are you going to put all of your stuff?");
end
end

EVENT_COMBINE_SUCCESS

Trigger

  • When a combine is successful.

Exports

Name

Type

Usage

recipe_id

int

quest::say($recipe_id); # returns int

recipe_name

int

quest::say($recipe_name); # returns int

Example

  • In this example, we send the client a message when they successfully combine a Hand Made Backpack

Perl
Lua
sub EVENT_COMBINE_SUCCESS {
#:: Match Recipe 2686: "Hand Made Backpack" by ID
if ($recipe_id == 2686) {
#:: Send the client a message in color 15 (yellow)
$client->Message(15,"Yay, now you have a place to put all of your stuff!");
}
}
function event_combine_success(e)
--:: Match Recipe 2686: "Hand Made Backpack" by ID
if (e.recipe_id == 2686) then
--:: Send the client a message in color 15 (yellow)
e.self:Message(15, "Yay, now you have a place to put all of your stuff!");
end
end

EVENT_COMMAND

Trigger

  • When a player says anything like a command. Replaced/Synonymous with EVENT_SAY.

EVENT_CONNECT

Trigger

  • when a player connects to the world.

You would likely be using this event in your global_player.pl.

Example

  • In this example, veteran AAs are awarded based on accumulated play time.

Perl
Lua
sub EVENT_CONNECT {
my %vet_aa = (481 => [31536000, 1, 1],
482 => [63072000, 1, 1],
483 => [94608000, 1, 1],
484 => [126144000, 1, 1],
485 => [157680000, 1, 1],
486 => [189216000, 1, 1],
487 => [220752000, 1, 1],
511 => [252288000, 1, 1],
2000 => [283824000, 1, 1],
8081 => [315360000, 1, 1],
8130 => [346896000, 1, 1],
453 => [378432000, 1, 1],
182 => [409968000, 1, 1],
600 => [441504000, 1, 1]);
foreach my $key (keys %vet_aa) {
if ($vet_aa{$key}[2] && ($vet_aa{$key}[2] || $client->GetAccountAge() >= $vet_aa{$key}[0])) {
$client->GrantAlternateAdvancementAbility($key, 1);
}
}
}
--[[ the main key is the ID of the AA
-- the first set is the age required in seconds
-- the second is if to ignore the age and grant anyways live test server style
-- the third is enabled
--]]
vet_aa = {
[481] = { 31536000, true, true}, -- Lesson of the Devote 1 yr
[482] = { 63072000, true, true}, -- Infusion of the Faithful 2 yr
[483] = { 94608000, true, true}, -- Chaotic Jester 3 yr
[484] = {126144000, true, true}, -- Expedient Recovery 4 yr
[485] = {157680000, true, true}, -- Steadfast Servant 5 yr
[486] = {189216000, true, true}, -- Staunch Recovery 6 yr
[487] = {220752000, true, true}, -- Intensity of the Resolute 7 yr
[511] = {252288000, true, true}, -- Throne of Heroes 8 yr
[2000] = {283824000, true, true}, -- Armor of Experience 9 yr
[8081] = {315360000, true, true}, -- Summon Resupply Agent 10 yr
[8130] = {346896000, true, true}, -- Summon Clockwork Banker 11 yr
[453] = {378432000, true, true}, -- Summon Permutation Peddler 12 yr
[182] = {409968000, true, true}, -- Summon Personal Tribute Master 13 yr
[600] = {441504000, true, true}, -- Blessing of the Devoted 14 yr
}
function event_connect(e)
local age = e.self:GetAccountAge();
for aa, v in pairs(vet_aa) do
if v[3] and (v[2] or age >= v[1]) then
e.self:GrantAlternateAdvancementAbility(aa, 1)
end
end
end

EVENT_DEATH

Trigger

  • When the NPC dies. Fires before death finishes.

Exports

Name

Type

Details

client

client

client who killed mob

npc

npc

npc that was killed

killer_id

int

client ID of killer. (Does not seem castable to mob)

killer_damage

int

How much damage was dealt on killing blow

killer_spell

int

Spell ID used to kill mob

killer_skill

int

Skill ID used to kill mob

charid

int

Character ID who killed mob

class

string

Class Name who killed mob

faction

int

Faction comparison of killed mob vs killer

h

float

heading of mob during death

hpratio

float

percent health of mob after death (negative value)

mlevel

int

level of mob killed

mname

string

name of mob killed

mobid

int

id of mob killed

name

string

name of killer

race

string

race of killer

status

int

account status of killer

uguild_id

int

uguild of killer

ulevel

int

level of killer

userid

int

user id of killer

x

float

x position of killed mob

y

float

y position of killed mob

z

float

z position of killed mob

zonehour

int

hour of zone when mob died

zoneid

int

zone id where mob died

zoneln

string

long name of zone where mob died

zonemin

int

minimum level to enter zone where mob died

zonesn

string

short name of zone where mob died

zonetime

int

time of zone where mob died

zoneweather

int

EVENT_DEATH_COMPLETE

Trigger

  • When the NPC dies.

Often used to spawn adds or send signals upon the death of an NPC.

Exports

Name

Type

Usage

killer_id

int

quest::say($killer_id); # returns int

killer_damage

int

quest::say($killer_damage); # returns int

killer_spell

int

quest::say($killer_spell); # returns int

killer_skill

int

quest::say($killer_skill); # returns int

Example

  • In this example, we spawn a fire beetle after the death of our NPC at the NPC's location.

Perl
Lua
sub EVENT_DEATH_COMPLETE {
#:: Spawn a 2024 - a_fire_beetle by NPC Type ID, grid 0, guildwarset 0, current X, Y, Z, and heading
quest::spawn2(2024,0,0,$x,$y,$z,$h);
}
function event_death_complete(e)
--:: Spawn a 2024 - a_fire_beetle by NPC Type ID, grid 0, guildwarset 0, current X, Y, Z, and heading
eq.spawn2(2024, 0, 0, e.self:GetX(), e.self:GetY(), e.self:GetZ(), e.self:GetHeading());
end

EVENT_DEATH_ZONE

Trigger

  • When the NPC dies.

Used by the zone controller.

Exports

Name

Type

Usage

killer_id

int

quest::say($killer_id); # returns int

killer_damage

int

quest::say($killer_damage); # returns int

killer_spell

int

quest::say($killer_spell); # returns int

killer_skill

int

quest::say($killer_skill); # returns int

killer_npc_id

int

quest::say($killer_npc_id); # returns int

EVENT_DESTROY_ITEM

Trigger

  • When a client destroys an item.

Used mainly for logging purposes.

EVENT_DISCONNECT

Trigger

  • When a player disconnects from the world.

Used mainly for logging purposes.

EVENT_DISCOVER_ITEM

Trigger

  • When an item is discovered.

Used in conjunction with World Rule EnableDiscoveredItems.

Exports

Name

Type

Usage

itemid

int

quest::say($itemid); # returns int

Example

Perl
Lua
sub EVENT_DISCOVER_ITEM {
#:: Create a scalar variable to store the item link
$discovereditem = quest::varlink($itemid);
#:: Shout the discovery to all zones
quest::shout2("$name has discovered $discovereditem! Yay!");
}
function event_discover_item(e)
--:: Create a scalar variable to store the item link
local item_link = eq.item_link(e.item:GetID());
--:: Emote the discovery to all zones
eq.world_emote(335, "$name has discovered " .. item_link .. "! Yay!");
end

EVENT_DROP_ITEM

Trigger

  • When a client drops an item.

Mainly used for logging purposes.

Exports

Name

Type

Usage

quantity

int

quest::say($quantity); # returns int

itemname

int

quest::say($itemname); # returns int

itemid

int

quest::say($itemid); # returns int

spell_id

int

quest::say($spell_id); # returns int

slotid

int

quest::say($slotid); # returns int

EVENT_DUEL_LOSE

Trigger

  • When a client loses a duel.

You would use this event in the global global_player.pl file.

Example

  • In this example, we set a data bucket to keep track of a player's dueling failures.

Perl
Lua
sub EVENT_DUEL_LOSE {
my $bucket_name = $client->CharacterID() . "-losses";
my $bucket_value = (quest::get_data($bucket_name) + 1);
quest::set_data($bucket_name, $bucket_value);
}
function event_duel_lose(e)
local bucket_name = e.self:CharacterID() .. "-losses";
local bucket_value = (eq.get_data(bucket_name) + 1);
eq.set_data(bucket_name, bucket_value);
end

EVENT_DUEL_WIN

Trigger

  • when a client wins a duel.

You would use this event in the global global_player.pl file.

Example

  • In this example, we set a data bucket to keep track of a player's dueling wins.

Perl
Lua
sub EVENT_DUEL_WIN {
my $bucket_name = $client->CharacterID() . "-wins";
my $bucket_value = (quest::get_data($bucket_name) + 1);
quest::set_data($bucket_name, $bucket_value);
}
function event_duel_win(e)
local bucket_name = e.self:CharacterID() .. "-wins";
local bucket_value = (eq.get_data(bucket_name) + 1);
eq.set_data(bucket_name, bucket_value);
end

EVENT_ENTER

Trigger

  • When a client enters a mob's proximity (as defined by quest::set_proximity(min_x, max_x, min_y, max_y, min_z, max_z)).

Example

  • In this example, we first set the NPC's proximity; when a player enters the proximity, they become PVP (red).

Perl
Lua
sub EVENT_SPAWN {
#:: Create a proximity, 100 units across, 100 units tall, without proximity say
quest::set_proximity($x - 50, $x + 50, $y - 50, $y + 50, $z - 50, $z + 50, 0);
}
sub EVENT_ENTER {
#:: Turn pvp on
quest::pvp("on");
}
function event_spawn(e)
--:: Create a proximity, 100 units across, 100 units tall, without proximity say
local x = e.self:GetX();
local y = e.self:GetY();
local z = e.self:GetZ();
eq.set_proximity((x - 50), (x + 50), (y - 50), (y + 50), (z - 50), (z + 50), 0);
end
function event_enter(e)
--:: Turn pvp on
e.other:SetPVP("on");
end

EVENT_ENTER_AREA

Trigger

  • when a client enters the area of a mob.

EVENT_ENTERZONE

Trigger

  • When a player enters the zone. Likely you will add to the zone player.pl file.

Example

  • In this example we remove the LDON compass mark.

Perl
Lua
sub EVENT_ENTERZONE {
#:: Clear the LDON Compass mark
$client->ClearCompassMark();
}
function event_enterzone(e)
--:: Clear the LDON Compass mark
e.self:ClearCompassMark();
end
  • In this example we create a LDON compass mark

Perl
Lua
sub EVENT_ENTERZONE {
#:: Create a scalar for storing the instance ID
$RujDInstance = quest::GetInstanceID("rujd",50);
#:: If the instance ID exists, it should be greater than 0--mark the player's compass if it is
if ($RujDInstance > 0) {
#:: Create a line on the compass leading the player to X,Y,Z
$client->MarkCompassLoc(-157.09, 19.31, 100);
}
}
function event_enterzone(e)
--:: Create a variable for storing the instance ID
local rujd_instance = eq.get_instance_id("rujd", 50);
--:: If the instance ID exists, it should be greater than 0--mark the player's compass if it is
if (rujd_instance > 0) then
--:: Create a line on the compass leading the player to X,Y,Z
e.self:MarkCompassLoc(-157.09, 19.31, 100);
end
end

EVENT_ENVIRONMENTAL_DAMAGE

Trigger

  • When taking any sort of environmental damage.

Exports

Name

Type

Usage

env_damage

int

quest::say($env_damage); # returns int

env_damage_type

int

quest::say($env_damage_type); # returns int

env_final_damage

int

quest::say($env_final_damage); # returns int

EVENT_EQUIP_ITEM

Trigger

  • When a player equips an item.

EVENT_EXIT

Trigger

  • When a client leaves a mob's proximity (as defined by quest::set_proximity).

Example

  • In this example, we first set the NPC's proximity; when a player exits the proximity, they are no longer PVP (blue).

Example

Perl
Lua
sub EVENT_SPAWN {
#:: Create a proximity, 100 units across, 100 units tall, without proximity say
quest::set_proximity($x - 50, $x + 50, $y - 50, $y + 50, $z - 50, $z + 50, 0);
}
sub EVENT_EXIT {
#:: Turn pvp off
quest::pvp("off");
}
function event_spawn(e)
--:: Create a proximity, 100 units across, 100 units tall, without proximity say
local x = e.self:GetX();
local y = e.self:GetY();
local z = e.self:GetZ();
eq.set_proximity((x - 50), (x + 50), (y - 50), (y + 50), (z - 50), (z + 50), 0);
end
function event_exit(e)
--:: Turn pvp off
e.other:SetPVP("off");
end

EVENT_FEIGN_DEATH

Trigger

  • When a client feigns death.

Example

Perl
Lua
sub EVENT_FEIGN_DEATH {
#:: See if the player has a pet
if ($client->GetPetID()) {
#:: Identify the pet by ID and kill it
$pet_entity = $entity_list->GetMobByID($client->GetPetID());
$pet_entity->Kill();
}
}
function event_feign_death(e)
--:: See if the player has a pet
local pet_id = e.other:GetPet():GetID();
if (pet_id > 0) then
--:: Identify the pet by ID and kill it
local pet_entity = entity_list:GetMob(pet_id);
pet_entity:Kill();
end
end

EVENT_FISH_FAILURE

Trigger

  • When a client fails at fishing.

You would use this event in the zone player.pl file.

Example

  • In this example, we set a data bucket to keep track of a player's fishing failures.

  • You would use this event in the global global_player.pl file.

Perl
Lua
sub EVENT_FISH_FAILURE {
my $bucket_name = $client->CharacterID() . "-fish-fail";
my $bucket_value = (quest::get_data($bucket_name) + 1);
quest::set_data($bucket_name, $bucket_value);
$client->Message(1, "Maybe you're using the wrong bait!")
}
function event_fish_failure(e)
local bucket_name = e.self:CharacterID() .. "-fish-fail";
local bucket_value = (eq.get_data(bucket_name) + 1);
eq.set_data(bucket_name, bucket_value);
e.self:Message(1, "Maybe you're using the wrong bait!");
end

EVENT_FISH_START

Trigger

  • when a client starts fishing.

You would use this event in the zone player.pl file.

Example

  • In this example, a message is displayed by the client if they start fishing.

Perl
Lua
sub EVENT_FISH_START {
$client->Message(1, "You crack a beer and toss your line in.");
}
function event_fish_start(e)
e.self:Message(1, "You crack a beer and toss your line in.");
end

EVENT_FISH_SUCCESS

Trigger

  • when a client succeeds at fishing.

You would use this event in the zone player.pl file or the global global_player.pl file.

Exports

Name

Type

Usage

fished_item

int

quest::say($fished_item); # returns int

Example

  • In this example, we set a data bucket to keep track of a player's fishing successes.

  • You would use this event in the global global_player.pl file.

Perl
Lua
sub EVENT_FISH_SUCCESS {
my $bucket_name = $client->CharacterID() . "-fish-success";
my $bucket_value = (quest::get_data($bucket_name) + 1);
quest::set_data($bucket_name, $bucket_value);
}
function event_fish_success(e)
local bucket_name = e.self:CharacterID() .. "-fish-success";
local bucket_value = (eq.get_data(bucket_name) + 1);
eq.set_data(bucket_name, bucket_value);
e.self:Message(1, "You caught something!");
end

EVENT_FORAGE_FAILURE

Trigger

  • When a client fails at foraging.

You would use this event in the zone player.pl or global global_player.pl file.

Example

  • In this example, we set a data bucket to keep track of a player's foraging failures.

Perl
Lua
sub EVENT_FORAGE_FAILURE {
my $bucket_name = $client->CharacterID() . "-forage-fail";
my $bucket_value = (quest::get_data($bucket_name) + 1);
quest::set_data($bucket_name, $bucket_value);
$client->Message(1, "You didn't find anything!")
}
function event_forage_failure(e)
local bucket_name = e.self:CharacterID() .. "-forage-fail";
local bucket_value = (eq.get_data(bucket_name) + 1);
eq.set_data(bucket_name, bucket_value);
e.self:Message(1, "You didn't find anything!");
end

EVENT_FORAGE_SUCCESS

Trigger

  • when a client succeeds at foraging.

You would use this event in the zone player.pl file or the global global_player.pl file.

Exports

Name

Type

Usage

foraged_item

int

quest::say($foraged_item); # returns int

Example

  • In this example, we set a data bucket to keep track of a player's foraging successes.

Perl
Lua
sub EVENT_FORAGE_SUCCESS {
my $bucket_name = $client->CharacterID() . "-forage-success";
my $bucket_value = (quest::get_data($bucket_name) + 1);
quest::set_data($bucket_name, $bucket_value);
$client->Message(1, "You found something!")
}
function event_forage_success(e)
local bucket_name = e.self:CharacterID() .. "-forage-success";
local bucket_value = (eq.get_data(bucket_name) + 1);
eq.set_data(bucket_name, bucket_value);
e.self:Message(1, "You found something!");
end

EVENT_GROUP_CHANGE

Trigger

  • when a group change occurs.

EVENT_HATE_LIST

Trigger

  • When a mob's hate list is changed.

Exports

Name

Type

Usage

hate_state

int

quest::say($hate_state); # returns int

Example

In this example, some flavor text is added as a player is added and removed from the NPC's hate list.

Perl
Lua
sub EVENT_HATE_LIST {
if ($hate_state == 1) {
quest::say("You're gonna die!");
} else {
quest::say("You're no match for my might!");
}
}
function event_hate_list(e)
if (e.joined) then
e.self:Say("You're gonna die!");
else
e.self:Say("You're no match for my might!");
end
end

EVENT_HP

Trigger

  • When a mob's HP dropping below a threshold (as defined by quest::setnexthpevent()).

Exports

Name

Type

Usage

hpevent

int

quest::say($hpevent); # returns int

inchpevent

int

quest::say($inchpevent); # returns int--incoming HP event

Example

  • In this example, we set the HP event threshold, and then depop the mob when the threshold is reached.

Perl
Lua
sub EVENT_SPAWN {
#:: Set the HP event threshold for 50 percent health
quest::setnexthpevent(50);
}
sub EVENT_HP {
#:: Match when the threshold is met
if ($hpevent == 50) {
quest::depop();
}
}
function event_spawn(e)
--:: Set the HP event threshold for 50 percent health
eq.set_next_hp_event(50);
end
function event_hp(e)
--:: Match when the threshold is met
if (e.hp_event == 50) then
e.self:Depop();
end
end

EVENT_ITEM

Trigger

  • When an item or money is turned into the mob.

Example

  • In this example, we turn in 325 Platinum, a Ring of the Ancients, and a Shadowed Rapier in exchange for our Journeyman's Boots

Perl
Lua
sub EVENT_ITEM {
#:: Try to take 325 Platinum from the client
if ($client->TakeMoneyFromPP(325000, 1)) {
#:: Match turn for 12268 - Ring of the Ancients and 7100 - Shadowed Rapier
if (plugin::check_handin(\%itemcount, 12268 => 1, 7100 => 1)) {
quest::say("The time to trade has come!! I am now rich and you are now fast. Take the Journeyman Boots and run like the wind.");
#:: Give a 2300 - Journeyman's Boots
quest::summonitem(2300);
#:: Grant a small amount of experience
quest::exp(1250);
}
}
#:: Return unused items
plugin::return_items(\%itemcount);
}
function event_trade(e)
--:: Require items library.
local item_lib = require("items");
--:: Try to take 325 Platinum from the client
if (e.other:TakeMoneyFromPP(325000, 1)) then
--:: Match turn for 12268 - Ring of the Ancients and 7100 - Shadowed Rapier
if (item_lib.check_turn_in(e.self, e.trade, {item1 = 12268, item2 = 7100})) then
e.self:Say("The time to trade has come!! I am now rich and you are now fast. Take the Journeyman Boots and run like the wind.");
--:: Give a 2300 - Journeyman's Boots
e.other:SummonItem(2300);
--:: Grant a small amount of experience
e.other:AddEXP(1250);
end
end
--:: Return unused items
item_lib.return_items(e.self, e.other, e.trade);
end

EVENT_ITEM_CLICK

Trigger

  • When an item is clicked.

This is a useful script to put in the Global quest scripts directory, so that you can make an item click work anywhere in the world.

Exports

Name

Type

Usage

itemid

int

quest::say($itemid); # returns int

itemname

int

quest::say($itemname); # returns int

slotid

int

quest::say($slotid); # returns int

spell_id

int

quest::say($spell_id); # returns int

Example

  • This example is taken from the Evil Eye Costume Kit, which is part of the Halloween Costume illusion items.

  • Note that the scriptfileid field for the item is set to 30073 in the database.

  • Note that a corresponding quest file exists at global/items/script_30073.pl.

Perl
Lua
sub EVENT_ITEM_CLICK {
#:: Use == for numeric comparison to Item ID 54711 - Evil Eye Costume Kit
if ($itemid == 54711) {
#:: Change the player's race to 469 - Evil Eye
quest::playerrace(469);
}
}
function event_item_click(e)
--:: Use == for numeric comparison to Item ID 54711 - Evil Eye Costume Kit
local item_id = e.self:GetID();
if (item_id == 54711) then
--:: Change the player's race to 469 - Evil Eye
e.owner:ChangeRace(469);
end
end

EVENT_ITEM_CLICK_CAST

Trigger

  • When a client casts the click effect on an item.

Exports

Name

Type

Usage

itemid

int

quest::say($itemid); # returns int

itemname

int

quest::say($itemname); # returns int