Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 04-16-2008, 01:43 PM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default New EVENT_CASTED_ON event

I have implemented this event to be able to create quests like "go heal this NPC", "go buff this NPC", potentially it could be used to implement a special spell or proc harming an NPC (if the spell is cast on this specific NPC, then some harm is done). This event is received by an NPC each time a spell is cast on him, and it is passed the identity of the caster (usually a PC) and the ID of the casted spell in variable "$spell_id".
Note that it is triggered before any resist or invulnerability is checked. The spell hits the NPC, that is it.

BE CAREFUL : it means an event is fired each tme a spell is cast on an NPC. I have no idea how much CPU overload this can cause. If this proves useless for "Live".like servers and a performance-hog may be this post should be moved to the "Custom" section.

Here is how it is implemented (as an SVN diff from version 1102) :

Code:
Index: hero-emulator/zone/event_codes.h
===================================================================
--- hero-emulator/zone/event_codes.h    (revision 135)
+++ hero-emulator/zone/event_codes.h    (working copy)
@@ -23,6 +23,7 @@
        EVENT_ZONE,                     //pc only
        EVENT_LEVEL_UP,         //pc only
        EVENT_KILLED_MERIT,     //received by an NPC once for every PC having merit (would receive XP if mob were not green) to kill the NPC -
basically all the group
+       EVENT_CASTED_ON,        //received by an NPC when a spell is cast on him (whether it sticks, is invuln'd etc or not, when the spell hit
s)

        _LargestEventID
 } QuestEventID;
Code:
Index: hero-emulator/zone/embparser.cpp
===================================================================
--- hero-emulator/zone/embparser.cpp    (revision 135)
+++ hero-emulator/zone/embparser.cpp    (working copy)
@@ -57,7 +57,8 @@
        "EVENT_LOOT",
        "EVENT_ZONE",
        "EVENT_LEVEL_UP",
-       "EVENT_KILLED_MERIT"
+       "EVENT_KILLED_MERIT",
+       "EVENT_CASTED_ON"
 };

 PerlembParser::PerlembParser(void) : Parser()
@@ -494,6 +495,11 @@
                        break;
                }

+               case EVENT_CASTED_ON:{
+                       ExportVar(packagename.c_str(), "spell_id", data);
+                       break;
+               }
+
                //nothing special about these events
                case EVENT_DEATH:
                case EVENT_SPAWN:
Code:
Index: hero-emulator/zone/spells.cpp
===================================================================
--- hero-emulator/zone/spells.cpp       (revision 132)
+++ hero-emulator/zone/spells.cpp       (working copy)
@@ -2259,6 +2259,13 @@
 // end of action packet


+       /* Send the EVENT_CASTED_ON event */
+       if(spelltar->IsNPC())
+       {       char temp1[100];
+               sprintf(temp1, "%d", spell_id);
+               parse->Event(EVENT_CASTED_ON, spelltar->GetNPCTypeID(), temp1, spelltar->CastToNPC(), this);
+       }
+
        // solar: now check if the spell is allowed to land

        // invuln mobs can't be affected by any spells, good or bad
Finally an example on how to use it :
Code:
# a_defective_cleaner
sub EVENT_CASTED_ON
{ if($spell_id == 202)
  { quest::setglobal("DefectiveCleanersBuffed", 1, 5, "F"); }
}

sub EVENT_ITEM
{ plugin::return_items(\%itemcount);
}
Reply With Quote
  #2  
Old 04-17-2008, 12:57 AM
Knightly
Accomplished Programmer
 
Join Date: Nov 2006
Location: Honolulu, HI
Posts: 91
Default

I don't want this to sound trite or anything, but if it's going into the source the past tense of "cast" is just "cast"
Reply With Quote
  #3  
Old 04-17-2008, 02:35 AM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default

Very true.As you can see English is not my native language. Thank you for pointing it out.
Reply With Quote
  #4  
Old 04-17-2008, 04:16 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

We all know Bulle's native language is C or some other code lol.

Sounds interesting. I am all about having more options! Making unique events is one of the goals I work towards on my server. Nothing spectacular yet, but I am always trying to think up new stuff.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #5  
Old 04-19-2008, 11:26 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

I actually had this and the other thing you posted in when I first did player quests but took them out. The merit one makes a lot more sense on npcs heh, anyway I'll be putting this in soon enough.
Reply With Quote
  #6  
Old 04-20-2008, 05:05 PM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default

This is great news KLS, thanks. I have been using these two events since I have written them and have had no problem yet. I leave it up to you whether to rename the CASTED by CAST or not, I am a bit puzzled about my English there : you can find reference to both words in many places on the web or in EQEmu.
Reply With Quote
Reply


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 05:23 PM.


 

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