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

Quests::Custom Custom Quests here

Reply
 
Thread Tools Display Modes
  #1  
Old 03-16-2021, 04:14 AM
Splose
Banned
 
Join Date: Apr 2014
Posts: 279
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


C:\EQEmu\quests\global\spells\7799.pl
Code:
#:: 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)

sub EVENT_SPELL_EFFECT_CLIENT {
	#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
Reply

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 06:36 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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3