You are correct in your assumtions.
Now it is time for my assunptions. I assume that you are creating an effect to do the damage from the spell.
All code from scripts in NWN run on an object. When an effect kills a creature the object that created the effect is given credit for the kill. The Effect creator is object the code was running on when the effect was created.
Let me use a TagBasedScript as an example; Now this first script is the wrong way to do it.
This script is flawed and gives no xp to the PC if they kill the NPC. #include "x2_inc_switches"
void main()
{
object oPC;
object oItem;
object oTarget;
effect eEffect;
int nEvent = GetUserDefinedItemEventNumber();
switch (nEvent)
{
case X2_ITEM_EVENT_ACTIVATE:
oPC = GetItemActivator();
oItem = GetItemActivated();
oTarget =GetItemActivatedTarget();
eEffect = EffectDamage(50);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oTarget);
break;
}
}
The script look good and does what you would expect it to do. When used by the PC it does 50 points of damage to the target. However since the code that created the effect was running on the module, the module is the creator of the effect and will get the credit for anything the effect kills. in order for the PC to get the credit for the kill the code need to be running on them when the effect is created that can be done this way.
#include "x2_inc_switches"
void main()
{
object oPC;
object oItem;
object oTarget;
int nEvent = GetUserDefinedItemEventNumber();
switch (nEvent)
{
case X2_ITEM_EVENT_ACTIVATE:
oPC = GetItemActivator();
oItem = GetItemActivated();
oTarget =GetItemActivatedTarget();
AssignCommand(oPC,ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDamage(50),oTarget));
break;
}
}
In this script the PC will get the credit for the kill. Even though the script is still running on the module. The code that creates the effect is not ran untill after it is assigned to the PC.