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, 12:56 PM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default New EVENT_KILLED_MERIT event

I have developed a new EVENT for use in quests, EVENT_KILLED_BY. It is similar to the EVENT_SLAY with regards to when it is triggered, but the effect (and usage) is really not the same. It triggers the EVENT_KILLED_BY sub in the slain NPC script, passing it the client (ie PCs) that is getting XP, or should be getting XP if the NPC would yield some and were not green, for killing this NPC. This event is sent once for each PC getting merit for the kill, which means once per PC in the group basically.

This event should allow implementing a very common quest type in many MMORPGs : the "go kill X orcs" quest. You then need to accumulate the amount of orcs in a global variable each time an orc is killed in this event. Each PC participating in the kill (ie, getting XP from it) will benefit from the progress.

Here is how I implemented it. Sorry no CVS diff right now they are a pain for me to make, I use SVN at home so I will provide an SVN diff for now. If you really need a CVS diff I can probably take a couple hours and do it this week-end. As you will see the change is quite minimal.

Code:
Index: zone/event_codes.h
===================================================================
--- zone/event_codes.h  (revision 132)
+++ zone/event_codes.h  (working copy)
@@ -22,6 +22,7 @@
        EVENT_LOOT,                     //pc only
        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

        _LargestEventID
 } QuestEventID;
Code:
Index: zone/embparser.cpp
===================================================================
--- zone/embparser.cpp  (revision 132)
+++ zone/embparser.cpp  (working copy)
@@ -56,7 +56,8 @@
        "EVENT_CLICKDOOR",
        "EVENT_LOOT",
        "EVENT_ZONE",
-       "EVENT_LEVEL_UP"
+       "EVENT_LEVEL_UP",
+       "EVENT_KILLED_MERIT"
 };

 PerlembParser::PerlembParser(void) : Parser()
@@ -503,6 +504,7 @@
                case EVENT_EXIT:
                case EVENT_ENTERZONE:
                case EVENT_LEVEL_UP:
+               case EVENT_KILLED_MERIT:
                        break;

                default: {
Code:
Index: zone/attack.cpp
===================================================================
--- zone/attack.cpp     (revision 132)
+++ zone/attack.cpp     (working copy)
@@ -1778,6 +1778,14 @@
                                                give_exp_client->SendAdventureFinish(1, AF.points,true);
                                }
                                kg->SplitExp((EXP_FORMULA), this);
+
+                               /* Send the EVENT_KILLED_MERIT event for all group members */
+                               for (int i = 0; i < MAX_GROUP_MEMBERS; i++) {
+                                   if (kg->members[i] != NULL && kg->members[i]->IsClient()) { // If Group Member is Client
+                                       Client *c = kg->members[i]->CastToClient();
+                                               parse->Event(EVENT_KILLED_MERIT, GetNPCTypeID(), "killed", this, c);
+                                         }
+                                 }
                        }
                        else
                        {
@@ -1786,6 +1794,9 @@
                                {
                                        give_exp_client->AddEXP((EXP_FORMULA), conlevel); // Pyro: Comment this if NPC death crashes zone
                                }
+
+                               /* Send the EVENT_KILLED_MERIT event */
+                               parse->Event(EVENT_KILLED_MERIT, GetNPCTypeID(), "killed", this, give_exp_client);
                        }
                }
        }
And now an example of using it (quests/akanon/a_defective_cleaner.pl) :
Code:
# a_defective_cleaner
sub EVENT_KILLED_MERIT
{ quest::say("couic !!! $name killed me");
  if(defined($DefectiveCleanersKilled))
  { quest::setglobal("DefectiveCleanersKilled", $DefectiveCleanersKilled + 1, 5, "F"); }
  else
  { quest::setglobal("DefectiveCleanersKilled", 1, 5, "F"); }
}

sub EVENT_ITEM
{
  plugin::return_items(\%itemcount);
}
I did not know whether this could be useful for "Live"-like quests so I put it here. If it is not relevant feel free to move it to the "Custom" forum.
Reply With Quote
  #2  
Old 04-16-2008, 01:04 PM
So_1337
Dragon
 
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
Default

That's very useful, actually, and might help a lot when it comes time to try and create a functional LDoN expansion. Great work
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 12:21 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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3