OK, generally if you want to add something to a module script, you want it to handle a different type of event.
If you've copied one of the chargen examples to make your module script, it should look something like this:
#include "events_h"
#include "global_objects_h"
#include "sys_chargen_h"
void main()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev); //extract event type from current event
int nEventHandled = FALSE; //keep track of whether the event has been handled
switch(nEventType)
{
case EVENT_TYPE_MODULE_START:
{
PreloadCharGen(); //preloads resources needed for character generation
StartCharGen(GetHero(),0); //initiates character generation
break;
}
}
if (!nEventHandled) //If this event wasn't handled by this script, let the core script try
{
HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
}
}
See the
switch(nEventType) ? Thats the bit where the script says "OK, I've got an event, what sort of events do you care about and what do you want to do with them?"
Most of the time when you edit a module script, you'll be adding in extra case blocks inside the {} for that switch, like so:
case EVENT_TYPE_WHATEVER:
{
DoSomething();
DoSomethingElse();
break;
}
The EVENT_TYPE_* are constants, you can find them by clicking the green C button in the scripting pane to the right when you open a script, and typing EVENT_TYPE into the filter. You'll need to have #include utility_h" to see them.
You can add as many of those case blocks into that switch statement as you like.
For example, let's say we were doing the advanced version of my tutorial, now we want to intercept the follower joining or leaving the party. That's two extra case blocks, like so:
#include "events_h"
#include "global_objects_h"
#include "sys_chargen_h"
#include "utility_h" //Remember to add any new includes your case blocks need.
#include "wrappers_h"
#include "plt_bc_create_party" //Including any plots you're using!
void main() {
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev); //extract event type from current event
int nEventHandled = FALSE; //keep track of whether the event has been handled
switch(nEventType) {
case EVENT_TYPE_MODULE_START:
{
PreloadCharGen(); //preloads resources needed for character generation
StartCharGen(GetHero(),0); //initiates character generation
break;
}
case EVENT_TYPE_PARTYMEMBER_ADDED: //This is my first new case block
{
object oFollower = GetEventObject(ev, 0);
SetLocalInt(oFollower, CREATURE_REWARD_FLAGS, 0);
SetFollowerState(oFollower, FOLLOWER_STATE_ACTIVE);
if (GetTag(oFollower) == "bc_party_miera") {
WR_SetPlotFlag(PLT_BC_CREATE_PARTY, PARTY_MIERA_IN_PARTY, TRUE);
}
break;
}
case EVENT_TYPE_PARTYMEMBER_DROPPED: //This is my second
{
object oFollower = GetEventObject(ev, 0);
if (GetTag(oFollower) == "bc_party_miera") {
WR_SetPlotFlag(PLT_BC_CREATE_PARTY, PARTY_MIERA_IN_PARTY, FALSE);
}
break;
}
}
if (!nEventHandled) //If this event wasn't handled by this script, let the core script try
{
HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
}
}
I hope that helps, I know script doesn't display clearly here
Modifié par Mengtzu, 08 janvier 2010 - 12:26 .