I'm only a beginner so I could be wrong, but for triggering a conversation when a group of enemies dies here's how they did it for the very fist encounter on the endar spire:
In the OnSpawn script for the two sith the local boolean SW_FLAG_EVENT_ON_DEATH is set to true. What this does is trigger the OnUserDefined event when OnDeath is triggered. This is because of a conditional in the default OnDeath script, k_def_death01.nss I think. Actually, each default event script has a corresponding SW_FLAG_EVENT_ON_* boolean that triggers OnUserDefined.
So once each of the sith die their OnUserDefined script activates and that script first checks if a global number representing the amount of dead enemies (in this case it's called END_ROOM3_DEAD) is greater than or equal to 1 and if so the conversation occurs. If you haven't killed all the enemies yet then the global number is incremented. In this case there are 2 sith you have to kill which leads me to believe that all global numbers are initialized as -1. Someone please correct me if I'm wrong.
Now if you wanna make your own script then what you gotta do is go into globalcat.2da where all the global numbers/booleans are stored and add a new global number to represent the amount of dead enemies. Then add a line in the OnSpawn script that sets SW_FLAG_EVENT_ON_DEATH to true
SetLocalBoolean(OBJECT_SELF, SW_FLAG_EVENT_ON_DEATH, TRUE);
Then make a custom OnUserDefined script or add to the existing one. Here is the decompiled OnUserDefined script of those sith:
void main() {
int int1 = GetUserDefinedEventNumber();
if ((int1 == 1001)) {
}
else {
if ((int1 == 1002)) {
}
else {
if ((int1 == 1003)) {
}
else {
if ((int1 == 1004)) {
}
else {
if ((int1 == 1005)) {
}
else {
if ((int1 == 1006)) {
}
else {
if ((int1 == 1007)) {
int nGlobal = GetGlobalNumber("END_ROOM3_DEAD");
object object1 = sub1();
object oPC = GetFirstPC();
int nCurHP = GetCurrentHitPoints(oPC);
int nMaxHP = GetMaxHitPoints(oPC);
int int9 = GetCurrentHitPoints(object1);
int int11 = GetMaxHitPoints(object1);
if ((nGlobal >= 1)) {
sub2(intGLOB_163); // TRASK_ROOM3_DONE
SetLocked(GetObjectByTag("end_door05", 0), 0);
if (((int9 < int11) || (nCurHP < nMaxHP))) {
CancelCombat(sub1());
CancelCombat(GetFirstPC());
DelayCommand(1.0, sub3());
}
}
SetGlobalNumber("END_ROOM3_DEAD", (nGlobal + 1));
}
else {
if ((int1 == 1008)) {
}
else {
if ((int1 == 1009)) {
}
else {
if ((int1 == 1010)) {
}
else {
if ((int1 == intGLOB_21)) {
sub4("wp_homebase");
}
}
}
}
}
}
}
}
}
}
}
}
Each default OnEvent script has its own OnUserDefinedEventNumber() that can be used in a script like this to determine which event is triggering OnUserDefined. In this case the OnDeath event number is 1007. Actually this script is decompiled they probably used a switch statement in the original source code instead of these nested if statements. You can also just delete the nested if statements if you want and just check if the event number is 1007.
Then just do what they did and check if (nGlobal >= number_of_dead_enemies) then trigger the conversation but make sure to cancel combat like they did:
CancelCombat(sub1());
CancelCombat(GetFirstPC());
DelayCommand(1.0, sub3());
sub1() returns Trask and sub3() I'm assuming is ActionStartConversation().