Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Custom

Quests::Custom Custom Quests here

Thread Tools Display Modes
Old 03-16-2021, 04:14 AM
Join Date: Apr 2014
Posts: 235
Default Example: Spawn NPC on spell cast

I have seen a few people on Discord wondering how to execute code on a spell cast.

Here is an example of how you can spawn an NPC with the use of an already existing blank spell in the database (Claim Reward - ID: 7799)

Commented very extensively for maximum learning

#:: Written by Splose from EQEmpires as an example for M0hnay on Discord
#:: EQEmpires.com Discord: https://discord.gg/UvC88vK
#:: EQEmulator.org Discord: https://discord.gg/QHsm7CD
#:: How to Spawn NPC on spell cast
#:: This will spawn a Priest of Discord at the client's location or a static location after casting Claim Reward (ID: 7799)

	#my $Debug = " ";	#::	Remove to enable debug messages for GMs with status 100+
	my $SpawnOnClient = 1;
	my $npc_to_spawn = 29085;
	#:: Static Location
	#:: Only need to use these if SpawnOnClient = 0 and you want to spawn the mob in a static location
	my ($spawn_x, $spawn_y, $spawn_z, $spawn_h) = (0.00, 0.00, 0.00, 0.00); #:: x/y/z/h
	#:: END
	#:: If SpawnOnClient is greater than zero it will use the client's location, otherwise it will use the location entered on line 16
	my ($x, $y, $z, $h) = $SpawnOnClient > 0 ? ($client->GetX(), $client->GetY(), $client->GetZ(), $client->GetHeading()) : ($spawn_x, $spawn_y, $spawn_z, $spawn_h);

	#:: These debug messages will only fire if you remove the # from line 10 and your GM status is 200+
	$client->Message(15, "[Debug: Claim Reward (7799)] :: EVENT_SPELL_EFFECT_CLIENT was a success for (" . $client->GetCleanName() . ") Status: ($status)") if ($Debug && $status >= 200);
	$client->Message(15, "[Debug: Claim Reward (7799)] :: X: ($spawn_x / $x) Y: ($spawn_y / $y) Z: ($spawn_z / $z) H: ($h / $spawn_h)") if ($Debug && $status >= 200);
	quest::spawn2($npc_to_spawn, 0, 0, $x, $y, $z, $h);
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -4. The time now is 01:39 AM.


Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
Powered by vBulletin®, Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3