Hey guys, I need to know how to make it so that when you kill 4 guards a convo will activate. Here is the scene, you are in a cantina talking to a hutt and his guards attack you, how do i make it so that when all of them die he talks to you?
Here's one way: User-defined on-death script for each of them. The script looks to see if there are any living guards left. If not, ActionStartConversation is fired on the Hutt.
so uh, how would that look like? in code i mean
See this (
http://www.lucasforums.com/showthread.php?s=&postid=1522866#post1522866) thread starting at DeathDisco's request for implementing an OnUserDefine script for the OnDeath event.
Assuming the NPCs have different tags, the OnDeath code would go something like this:
void main () {
if (
GetIsDead(GetObjectByTag("NPC1_tag")) &&
GetIsDead(GetObjectByTag("NPC2_tag")) &&
GetIsDead(GetObjectByTag("NPC3_tag")) &&
GetIsDead(GetObjectByTag("NPC4_tag"))
) {
AssignCommand(
GetObjectByTag("Hutt_tag"),
ActionDoCommand( ActionStartConversation(GetFirstPC(),"The_2nd_dialog_name"))
);
}
}
TK, Is there any reason why this script would not work consistently? I found that it does not work often unless the fight is real short. IE: All the enemies(three of them, script adjusted accordingly) VP is set to 10. :confused: I have more details if need be.
Maybe the enemies are disappearing (body fading) before the fight is over? In that case the GetObjectByTag function would be returning OBJECT_INVALID. To circumvent this, you could toss in the following line of code before the if statement:
SetIsDestroyable(FALSE);
No they don't disappear, I tried it anyway but got the same results. Could it be a goofy savegame I'm working from?
Strange. Maybe this would work:
void main () {
SetLocalBoolean(OBJECT_SELF,3,TRUE);
if (
GetLocalBoolean(GetObjectByTag("NPC1_tag"),3) &&
GetLocalBoolean(GetObjectByTag("NPC2_tag"),3) &&
GetLocalBoolean(GetObjectByTag("NPC3_tag"),3) &&
GetLocalBoolean(GetObjectByTag("NPC4_tag"),3)
) {
AssignCommand(
GetObjectByTag("Hutt_tag"),
ActionDoCommand( ActionStartConversation(GetFirstPC(),"The_2nd_dialog_name"))
);
}
}
Doesn't work:( The last set of && are unnesessary correct?
(I removed the erroneous &&)
I guess it's time to try the SendMessageToPC function to see whether or not the scripts are being fired.
Insert this before the SetLocalBoolean function.
SendMessageToPC(GetFirstPC(),"OnDeath Script Fired for "+GetTag(OBJECT_SELF));
Maybe we should take this to PM land.
Hey guys sorry to bring this dinosaur up but i am having a similar situation in the mod. I have it where there are 17 guys on a ship you have to kill, and when they are all dead, a script will fire that has dialog with ace playing. Can I jsut set it to one tag or do i have to do ALL of them unique and set it up here, because there are 17 of them. Is there a script that will chekc to see if there are enemies in the area?
Originally posted by Gsccc
I have it where there are 17 guys on a ship you have to kill, and when they are all dead, a script will fire that has dialog with ace playing. Can I jsut set it to one tag or do i have to do ALL of them unique and set it up here, because there are 17 of them.
A custom OnDeath script like this one would probably work if set on the 17 enemies if they all have the same tag.
I would use the OnDeath event script directly rather than a UserDefined script for this since the OnDeath UserDefined was somewhat unreliable in Neverwinter Nights (didn't always fire) and I am unsure if they fixed that problem for KotOR.
// OnDeath Event Script
#include "k_inc_switch"
void main()
{
string sTag = GetTag(OBJECT_SELF);
int nCount = 0;
int i = 0;
object oTalker = GetObjectByTag("speaker_tag");
object oGuard = GetObjectByTag(sTag, i);
while (GetIsObjectValid(oGuard)) {
if ((oGuard != OBJECT_SELF) && !GetIsDead(oGuard)) {
nCount++;
break;
}
oGuard = GetObjectByTag(sTag, ++i);
}
if ((nCount == 0) && !GetIsInConversation(oTalker)) {
AssignCommand(oTalker, ClearAllActions());
AssignCommand(oTalker, ActionStartConversation(GetFirstPC(), "alldead_dialog"));
}
ExecuteScript("k_ai_master", OBJECT_SELF, KOTOR_DEFAULT_EVENT_ON_DEATH);
}
Or, if you wish to check for any hostile creature in the area and not just a defined group, this would probably work as well:
// OnDeath Event Script
#include "k_inc_switch"
void main() {
int nCount = 0;
object oTalker = GetObjectByTag("speaker_tag");
object oCreature = GetFirstObjectInArea();
while (GetIsObjectValid(oCreature)) {
if (((GetStandardFaction(oCreature) == STANDARD_FACTION_HOSTILE_1)
|| (GetStandardFaction(oCreature) == STANDARD_FACTION_HOSTILE_2))
&& (oCreature != OBJECT_SELF)
&& !GetIsDead(oCreature))
{
nCount++;
break;
}
oCreature = GetNextObjectInArea();
}
if ((nCount == 0) && !GetIsInConversation(oTalker)) {
AssignCommand(oTalker, ClearAllActions());
AssignCommand(oTalker, ActionStartConversation(GetFirstPC(), "alldead_dialog"));
}
ExecuteScript("k_ai_master", OBJECT_SELF, KOTOR_DEFAULT_EVENT_ON_DEATH);
}
Just wanted to add that GetIsObjectValid( GetNearestCreature( CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY, OBJECT_SELF, 1 ) ) would probably return an accurate indication of whether or not there are any enemies left in the module. The script c_foeinsight contains a variant of the above snippet with a perception check.
Also, have you checked out the code for the Sith boarding party sequence after the Peragus turret game in 005EBO? It does mostly what the people in this thread describe (OnDeath script), with the only exception being that it uses a global number to keep track of how many troopers you still have to kill.