Assigning something to happen when an enemy or character dies is quite common in video games. Sometimes you may want to update a journal or mission, start a conversation, provide a reward, or any number of things. I've discovered there are a number of different ways to do this.
The most common one that is used is the OnDeath script. This is a script placed in the OnDeath tag of a single object. This fires when that object dies. It works well if you only have one enemy that is going to provide an update. If you have a number of combatants and assign the OnDeath to a single one and wish to start a conversation, it can be quite clumsy. Everquest 2 and World of Warcraft use this type of update more than any others.
A Body Count variable is a better way of doing an update with multiple objects. You would assign an OnDeath script that would fire a modifier to a variable of “iBodycount”, for example. If you had five combatants, you would assign an OnDeath on all of them that would add “1” to the “iBodycount” variable on that object's death. The object that is going to give the update would have an OnHeartbeat script that looks for the “iBodycount” variable to be at least “5”. Since the OnHeartbeat scripts fire every 6 seconds, there is going to be a delay of six seconds, at the most.
I discovered another way that I much prefer for multiple objects. It is called the Grouping script.
Here is the sample Grouping script that I tested:
#include “ginc_group”
void main()
{
AddNearestwithTagToGroup(“turds”, “turd”);
GroupOnDeathBeginConversation(“turds”, “jones”, “speak1”);
}
I took two zombie templates and placed them in a zone. I gave both of them the Tag “turd”. I then placed an umber hulk template down and gave him the Tag “jones”. I made a single conversation script and called it “speak1”.
This script fires when the player crosses a trigger on the ground. When it fires, it takes all the objects with the Tag of “turd” and places them in a group called “turds”. When all the objects in the group have been killed, “jones” starts up the conversation “speak1”.
Its pretty simple to use, but you have take note of all the groups you will be using in the module so you don't reuse them. Of course, you need to be sure that the object starting the conversation is set to Static FALSE, otherwise they won't do a goddamn thing, no matter how well you script.
Tuesday, September 09, 2008
Subscribe to:
Posts (Atom)