I am currently using
object oLeader = GetFactionLeader(GetLastKiller());
In death scripts to identify the party leader (the PC) for starting conversations after killing bad guys and for raising the
PC if necessary. I just had a script fail on me and I'm wondering if I am not using the best object identification for the PC.
The conversation fired and the killer did the conversation, but the PC did not resurrect.
Here's the script:
void main()
{
object oArea = GetObjectByTag("tgs_goblin_caverns");
object oTarget = GetFirstObjectInArea(oArea);
object oKiller = GetLastKiller();
object oLeader = GetFactionLeader(oKiller);
object oSpeaker;
int nCheck;
effect eResurrect = EffectResurrection();
//loop to check for creatures with integer to see if the entire chief group is dead.
while (GetIsObjectValid(oTarget))
{
nCheck = GetLocalInt(oTarget,"nChiefGroup");
if (nCheck==1)
{
if (!GetIsDead(oTarget))
{
//return if one of the members of the chief's entourage is still alive.
return;
}
}
oTarget = GetNextObjectInArea(oArea);
}
ApplyEffectToObject(DURATION_TYPE_INSTANT,eResurrect,GetFirstPC());
if (!GetIsDead(oLeader))
{
oSpeaker = oLeader;
}
else
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,eResurrect,oLeader);
}
AssignCommand(oSpeaker,ClearAllActions(TRUE));
DelayCommand(3.0,AssignCommand(oSpeaker,ActionStartConversation(oSpeaker,"tgs_gob_caves_chief_dead",FALSE,FALSE,TRUE)));
}
Has anyone had problems with GetFactionLeader()?
Débuté par
M. Rieder
, sept. 11 2011 01:40
#1
Posté 11 septembre 2011 - 01:40
#2
Posté 11 septembre 2011 - 05:24
I'm surprised that the line in which you resurrect GetFirstPC isn't sufficient. In single player I believe that GetFirstPC should return the first PC that joined the game, which would also be the faction leader. So checking for the faction leader doesn't really seem necessary. However I would think that either should work. Strange.
#3
Posté 11 septembre 2011 - 05:53
try to send you the name of oLeader after your line , and see if you got the proper char. From what I read I don't think that the problem is there.
also
else
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,eResurrect,oLeader);
}
isn't enought, you are missing a line.
else
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,eResurrect,oLeader);
oSpeaker = oLeader;
}
An other error
if (!GetIsDead(oTarget))
{
//return if one of the members of the chief's entourage is still alive.
return;
}
}
oTarget = GetNextObjectInArea(oArea);
}
The Player party is in the area. Basically, if someone isn't dead in your team, you'll always exit and nevers go to the end of the script.
if (!GetIsDead(oTarget)&&GetIsEnemy(oTarget)) {
I'd say.
That's what I see for now. there is probably more
also
else
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,eResurrect,oLeader);
}
isn't enought, you are missing a line.
else
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,eResurrect,oLeader);
oSpeaker = oLeader;
}
An other error
if (!GetIsDead(oTarget))
{
//return if one of the members of the chief's entourage is still alive.
return;
}
}
oTarget = GetNextObjectInArea(oArea);
}
The Player party is in the area. Basically, if someone isn't dead in your team, you'll always exit and nevers go to the end of the script.
if (!GetIsDead(oTarget)&&GetIsEnemy(oTarget)) {
I'd say.
That's what I see for now. there is probably more
Modifié par Shallina, 11 septembre 2011 - 06:02 .
#4
Posté 11 septembre 2011 - 01:32
I've tested it several ways and I think the problem is not in my script. Right now I'm working on the community mod and when the PC dies, the respawn/reload GUI appears. If I just leave it up there and let my party members continue the fight, none of the scripts seem to apply to the PC. I think somehow the GUI is interfering with NWScript being able to make things happen to the PC.
#5
Posté 16 septembre 2011 - 05:57
Hi Matt,
The script looks a little cumbersome to me.
Try breaking the script into various self-made sub-functions to make it easier to see working and test. i.e. (Assuming a SP game) 1) Are end conditions met, 2) Get the leader of the party, check if dead and raise if required, 3) then start the conversation.
Raising scripts and special condition conversations are tricky when dealt with and may require more work than this initially appears and is why I am not trying to diagnose any specific problem just yet.
I know my own scripts are quite involved surrounding this kind of thing. If I sort out some of my current issues (and you still need help), I may try taking a closer look.
Lance.
The script looks a little cumbersome to me.
Try breaking the script into various self-made sub-functions to make it easier to see working and test. i.e. (Assuming a SP game) 1) Are end conditions met, 2) Get the leader of the party, check if dead and raise if required, 3) then start the conversation.
Raising scripts and special condition conversations are tricky when dealt with and may require more work than this initially appears and is why I am not trying to diagnose any specific problem just yet.
I know my own scripts are quite involved surrounding this kind of thing. If I sort out some of my current issues (and you still need help), I may try taking a closer look.
Lance.
#6
Posté 16 septembre 2011 - 07:15
Hi Matt,
Try this and get back to me ... Lance.
// SPEECH FUNCTION BY LANCE BOTELLE
void CompConv(object oPC)
{
AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, ActionStartConversation(oPC, "tgs_gob_caves_chief_dead", FALSE, FALSE, TRUE));
}
void main()
{
// IS GROUP CHIEFTAIN DEAD (USING GETNEARESTCREATURE WOULD PROBABLY BE BETTER HERE)
object oArea = GetObjectByTag("tgs_goblin_caverns");
object oTarget = GetFirstObjectInArea(oArea);
while (GetIsObjectValid(oTarget))
{
int nCheck = GetLocalInt(oTarget,"nChiefGroup");
if (nCheck==1 && !GetIsDead(oTarget)){return;}
oTarget = GetNextObjectInArea(oArea);
}
// RAISE MAIN PC IF REQUIRED
object oPC = GetFirstPC(TRUE);
if(GetIsDead(oPC)){ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPC);}
// START CONVERSATION WITH MAIN PC (TEST DELAY WORKS WITH RAISE - INCREASE SLIGHTLY IF NEED BE)
DelayCommand(0.1, CompConv(oPC));
}
Try this and get back to me ... Lance.
// SPEECH FUNCTION BY LANCE BOTELLE
void CompConv(object oPC)
{
AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, ActionStartConversation(oPC, "tgs_gob_caves_chief_dead", FALSE, FALSE, TRUE));
}
void main()
{
// IS GROUP CHIEFTAIN DEAD (USING GETNEARESTCREATURE WOULD PROBABLY BE BETTER HERE)
object oArea = GetObjectByTag("tgs_goblin_caverns");
object oTarget = GetFirstObjectInArea(oArea);
while (GetIsObjectValid(oTarget))
{
int nCheck = GetLocalInt(oTarget,"nChiefGroup");
if (nCheck==1 && !GetIsDead(oTarget)){return;}
oTarget = GetNextObjectInArea(oArea);
}
// RAISE MAIN PC IF REQUIRED
object oPC = GetFirstPC(TRUE);
if(GetIsDead(oPC)){ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPC);}
// START CONVERSATION WITH MAIN PC (TEST DELAY WORKS WITH RAISE - INCREASE SLIGHTLY IF NEED BE)
DelayCommand(0.1, CompConv(oPC));
}
#7
Posté 18 septembre 2011 - 07:42
M. Rieder wrote...
I've tested it several ways and I think the problem is not in my script. Right now I'm working on the community mod and when the PC dies, the respawn/reload GUI appears. If I just leave it up there and let my party members continue the fight, none of the scripts seem to apply to the PC. I think somehow the GUI is interfering with NWScript being able to make things happen to the PC.
Hi Matt,
Just reread this post .... Yes, you have to rewrite the death system that you use before you can use the other script. (I thought you had already done this bit.) It gets quite involved. I had to rewrite a number of scripts to have something similar to what you want work. It can be done though, as I have something akin to what you are trying to do in my own module. All the PCs can continue to fight until the last PC dies. Then there are a number of options that become available subject to certain conditions.
Lance.
#8
Posté 18 septembre 2011 - 07:51
I re-wrote it for The Wizard's Apprentice 2, but this script is for the community mod. Thanks for your reply. Re-writing the on death behavior is not an option fo the community mod, so I guess the bug stays. It won't affect many people because not many people keep playing after the death screen appears.





Retour en haut






