I want to have a conversation with one of my henchmen after a battle. Here was my original code:
__________________________________________
void main()
{
object oPC = GetFirstPC();
object oSnil = GetObjectByTag("snil_gribblenad");
object oLil = GetObjectByTag("lil_gribblenad");
object oOolaf = GetObjectByTag("oolaf_kieglaaf");
object oTravelerLeader = GetObjectByTag("traveler_leader");
object oTraveler1 = GetObjectByTag("traveler1");
object oTraveler2 = GetObjectByTag("traveler2");
int iCheckSnil = GetIsDead(oSnil);
int iCheckLil = GetIsDead(oLil);
int iCheckOolaf = GetIsDead(oOolaf);
int iCheckTravelerLeader = GetIsDead(oTravelerLeader);
int iCheckTraveler1 = GetIsDead(oTraveler1);
int iCheckTraveler2 = GetIsDead(oTraveler2);
int iCheckAttackedPC = GetLocalInt(oTravelerLeader,"attacked_pc");
int nBanditsAreDead = 1;
int nMerchantsAreDead = 1;
if (((iCheckSnil == FALSE) || (iCheckLil == FALSE) || (iCheckOolaf == FALSE)))
{
return;
}
SetLocalInt(oPC, "south_road_bandits", 3);
SetLocalInt(oPC, "NW_JOURNAL_ENTRYsouth_road_bandits", 25);
AssignCommand(oTravelerLeader, ClearAllActions(TRUE));
AssignCommand(oPC,ClearAllActions(TRUE));
DelayCommand(3.0f,AssignCommand(oTravelerLeader,ActionStartConversation(oPC,"traveler_leader",FALSE,FALSE,TRUE)));
}
______________________________________
When one of my henchmen killed the last of the enemies, everything worked perfectly. When the PC killed the last of the enemies, the journal updated, but the conversation either did not fire or got interrupted at the first node. When I changed the code to the following, it worked fine.
_________________________________________
void main()
{
object oPC = GetFirstPC();
object oSnil = GetObjectByTag("snil_gribblenad");
object oLil = GetObjectByTag("lil_gribblenad");
object oOolaf = GetObjectByTag("oolaf_kieglaaf");
object oTravelerLeader = GetObjectByTag("traveler_leader");
object oTraveler1 = GetObjectByTag("traveler1");
object oTraveler2 = GetObjectByTag("traveler2");
int iCheckSnil = GetIsDead(oSnil);
int iCheckLil = GetIsDead(oLil);
int iCheckOolaf = GetIsDead(oOolaf);
int iCheckTravelerLeader = GetIsDead(oTravelerLeader);
int iCheckTraveler1 = GetIsDead(oTraveler1);
int iCheckTraveler2 = GetIsDead(oTraveler2);
int iCheckAttackedPC = GetLocalInt(oTravelerLeader,"attacked_pc");
int nBanditsAreDead = 1;
int nMerchantsAreDead = 1;
if (((iCheckSnil == FALSE) || (iCheckLil == FALSE) || (iCheckOolaf == FALSE)))
{
return;
}
RemoveHenchman(oPC,oTravelerLeader);
RemoveHenchman(oPC,oTraveler1);
RemoveHenchman(oPC,oTraveler2);
SetLocalInt(oPC, "south_road_bandits", 3);
SetLocalInt(oPC, "NW_JOURNAL_ENTRYsouth_road_bandits", 25);
AssignCommand(oTravelerLeader, ClearAllActions(TRUE));
AssignCommand(oPC,ClearAllActions(TRUE));
DelayCommand(3.0f,AssignCommand(oTravelerLeader,ActionStartConversation(oPC,"traveler_leader",FALSE,FALSE,TRUE)));
}
_____________________________________________
In the conversation, I removed the hencmen from my party. One of the hencmen was the owner of the conversation which was supposed to start.
My theory is that when I removed the owner of the conversation from my group, it triggered an event in the AI or elsewhere which interrupted the conversation.
Thoughts?
An interesting bug with removing henchmen and conversation interrupting
Débuté par
M. Rieder
, août 06 2010 01:18
#1
Posté 06 août 2010 - 01:18
#2
Posté 06 août 2010 - 02:32
So, originally, you had Remove henchman within the first node. The function states that it reverts that npc back to its' orginal faction, so changing faction within the convo might stop the convo.
May I ask where you have this script firing? I don't know if you intend to clean the script up, but there are ways to write it a little better.
May I ask where you have this script firing? I don't know if you intend to clean the script up, but there are ways to write it a little better.
#3
Posté 06 août 2010 - 05:01
Orion7486 wrote...
So, originally, you had Remove henchman within the first node. The function states that it reverts that npc back to its' orginal faction, so changing faction within the convo might stop the convo.
May I ask where you have this script firing? I don't know if you intend to clean the script up, but there are ways to write it a little better.
This script is placed in the "on death" event for three NPCs. The intent is that when one dies, if any of the others are still alive, then the function will return before the journal gets updated and the conversation starts.
The end result will be that as soon as the three NPCs are dead, one of your henchmen (not companion) will start a convo with you.
I would be very interested in a clearner way to write the script.
#4
Posté 07 août 2010 - 12:59
Well, first of all, you have many things defined but aren't called at all within the script, ie. ichecktravelleader.
I assume that Snil,Lil, Oolaf are your 3 bad guys. Rather than checking they are dead by checking if those ints are false, take a look at the script template custom group on death. What you would do here, is group the three into there own group. Could be done in the area's enter script. Then this group death script would be in each of their ondeath event. You wouldn't need to list all those iChecks GetIsDead ints.
There's also a function called FireandForgetConversation. It's under one of the ginc includes. If I remember correctly, it helps force a convo if anyone is too busy to talk, ie. right after combat. Being to busy to talk could be a reason why sometimes your convo didn't fire. I assume that is why you put in that delay to start convo.
I assume you have a particular need to have the speaker be removed from PC's party at that point? Or why not remove them at the end of the convo?
Is this convo something that must happen? If so, I assume you made it so travelleader isn't killed prior to this convo. If not, I think that fireandforgetconversation function raises the speaker if need be.
Hope this helps. Perhaps others better at scripting can help better.
I assume that Snil,Lil, Oolaf are your 3 bad guys. Rather than checking they are dead by checking if those ints are false, take a look at the script template custom group on death. What you would do here, is group the three into there own group. Could be done in the area's enter script. Then this group death script would be in each of their ondeath event. You wouldn't need to list all those iChecks GetIsDead ints.
There's also a function called FireandForgetConversation. It's under one of the ginc includes. If I remember correctly, it helps force a convo if anyone is too busy to talk, ie. right after combat. Being to busy to talk could be a reason why sometimes your convo didn't fire. I assume that is why you put in that delay to start convo.
I assume you have a particular need to have the speaker be removed from PC's party at that point? Or why not remove them at the end of the convo?
Is this convo something that must happen? If so, I assume you made it so travelleader isn't killed prior to this convo. If not, I think that fireandforgetconversation function raises the speaker if need be.
Hope this helps. Perhaps others better at scripting can help better.
#5
Posté 07 août 2010 - 04:44
Thank you for the suggestions. They are very helpful. I am new to scripting and when I scripted that part of my module I was <i>very</i> new to scripting. I am just now starting to learn how to use the ginc functions.
It sounds like the Fireandforgetconversation () will be very useful.
As far as removing the speaker from the party before the conversation fires, that was the thing I changed that made the script finally work consistently.
I will also be using the groupondeath() function in the future as well.
Just to be clear, could I define the group in the on death script? Or does it have to be defined in a separate script which fires before the on death script fires?
Some of the things which are defined but aren't called are leftovers from previous versions of the script which I have not gotten rid of yet. Thanks for pointing that out.
Matt
It sounds like the Fireandforgetconversation () will be very useful.
As far as removing the speaker from the party before the conversation fires, that was the thing I changed that made the script finally work consistently.
I will also be using the groupondeath() function in the future as well.
Just to be clear, could I define the group in the on death script? Or does it have to be defined in a separate script which fires before the on death script fires?
Some of the things which are defined but aren't called are leftovers from previous versions of the script which I have not gotten rid of yet. Thanks for pointing that out.
Matt
#6
Posté 07 août 2010 - 06:10
M. Rieder wrote...
I will also be using the groupondeath() function in the future as well.
Just to be clear, could I define the group in the on death script? Or does it have to be defined in a separate script which fires before the on death script fires?
Matt
I would add them to the group prior to their deaths. Here's the script I use for adding creatures to a group. This one goes OnSpawn of the NPC blueprint. Also, set a string variable on the blueprint named "Group" and set it's value to the name of your group you want them added to:
#include "ginc_group"
void main()
{
object oSelf = OBJECT_SELF;
string sGroup = GetLocalString(oSelf, "Group");
GroupAddMember(sGroup, oSelf, TRUE);
ExecuteScript("nw_c2_default9", oSelf);
}The advantage to doing it this way is that the same script can be used for many different creature blueprints instead of having to write a seperate script for each creature. But then again, it only works if the creature is being spawned in somehow and not pre-placed in the toolset.
Modifié par _Knightmare_, 07 août 2010 - 06:14 .
#7
Posté 08 août 2010 - 05:21
Very neat. I like it. I will be using that.





Retour en haut






