Aller au contenu

Photo

How to make an NPC start a conversation when dead?


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
Artfoundry

Artfoundry
  • Members
  • 62 messages
How do I make a companion start a conversation after "dying" in combat when the combat is done?  I have an altered OnDeath script on the NPC the PC and companion are fighting that checks to see if the companion has less than 1 health, and then tries to increase his health.  However, it's not working.  I'm probably using the wrong functions.
Here's the code (oCale is the companion):

        AssignCommand(oCale, ClearAllActions(TRUE));
        if (GetCurrentHitPoints(oCale) < 1)
        {
            EffectHealOnZeroHP(oCale, 10);
        }
        AssignCommand(oCale, ActionStartConversation(oPC, "conversation_cale_niledead", FALSE, FALSE, TRUE, FALSE));

So is this right?  By the way, the conversation DOES start if Cale isn't dead.  One thing I haven't tested yet is what happens if the PC is dead but Cale is alive when combat ends.  I'm guessing it'll have the same problem, so maybe I need to deal with that case as well?

On another unrelated note, is it just me or is there no longer a search function in these forums?  It was already hard to find before, but now I can't find it at all.  What's up with that?  I miss the old forums...

#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
I think you need to resurrection them first. Look at the respawn script to see the effects you need to apply to get a corpse moving again.

#3
Artfoundry

Artfoundry
  • Members
  • 62 messages
What respawn script?

#4
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
The default module respawn script, check your module properties.

#5
Shaun the Crazy One

Shaun the Crazy One
  • Members
  • 183 messages
I would actually recommend not letting the NPC die.  You can get the same effect by making the NPC "immortal" (by which I mean the check box under the Behavior heading in creature properties).  This will prevent your NPC from being dropped below 1 hp.  Then in the NPC's On Damaged Script include something like this:

    object oPC = GetFirstPC();
    if(GetCurrentHitPoints()<= 1)
    {
        ChangeToStandardFaction(OBJECT_SELF,STANDARD_FACTION_COMMONER);  //you don't want the NPC to be hostile durring the conversation
        ActionStartConversation(oPC);
    }

This is the technique typicaly used in the campaing.  If your going for a last words kind of deal, you can apply the sleep effect (or something similar) to the NPC in your On Damaged script, and then have a seperate script to kill the NPC that fires at the last node of the conversation (the one that says end dialog)(you'll need to use the SetImmortal function first to make the NPC killable)

Modifié par Shaun the Crazy One, 20 mars 2011 - 02:09 .


#6
Artfoundry

Artfoundry
  • Members
  • 62 messages
Thanks Lugaid - that worked! This was the code I needed:
	if (GetCurrentHitPoints(oCale) < 1)
	{
 		ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oCale);
 		ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oCale)), oCale);
 		RemoveEffects(oCale);
	}
	else if (GetCurrentHitPoints(oPC) < 1)
	{
 		ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPC);
 		ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oPC)), oPC);
 		RemoveEffects(oPC);
	}

Shaun, I think you misunderstood - I didn't want the NPC to start talking. I wanted the companion to get up and start talking (if he had died). The enemy NPC stays dead. Anyway, problem solved!