Log in

View Full Version : New EVENT_KILLED_MERIT event


Bulle
04-16-2008, 12:56 PM
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.

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;

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: {
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) :
# 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.

So_1337
04-16-2008, 01:04 PM
That's very useful, actually, and might help a lot when it comes time to try and create a functional LDoN expansion. Great work :)