Aller au contenu

Photo

Trying to auto start conversation after NPC death


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

#1
Artfoundry

Artfoundry
  • Members
  • 62 messages
Hi
I'm trying to get a conversation to automatically start with NPC 2 after the death of NPC 1 (in a fight with the PC), but nothing's happening.

I added this code to the default OnDeath script for NPC 1 (saved a new version so I didn't overwrite the original and changed the script setting in the NPC properties):

    object oNPC = StringToObject("n_stepmother");
    object oPC = GetFirstPC();
    object oCale = StringToObject("c_human_cale");
    
    if (GetIsObjectValid(oNPC)) //if NPC2 is still alive
        if (GetFactionAverageReputation(oNPC, oPC) > 0) //and she's still friendly
        {
            ActionStartConversation(oCale, "conversation_cale_finloralive", FALSE, FALSE, FALSE, FALSE);
        }
    else
    {    
        ActionStartConversation(oCale, "conversation_cale_niledead", FALSE, FALSE, FALSE, FALSE);
    }

Is the 2nd if statement wrong?  Or do I need to do something else with this script - is simply adding this code in there not a good way of doing it?

#2
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
You can't use stringtoobject to get an object. Use GetNearestObjectByTag.



Regards

#3
Artfoundry

Artfoundry
  • Members
  • 62 messages
ahh ok, thanks. I thought I'd used that before successfully... but maybe not.

#4
Artfoundry

Artfoundry
  • Members
  • 62 messages
It's still not working. I think it may be the ActionStartConversation line, because I tried substituting that function for BeginConversation, and that partially worked - it made the NPC shout the first line of the conv. as if it was a one-liner (though it's not - it has one line followed by an End Dialog node).

#5
Guest_Chaos Wielder_*

Guest_Chaos Wielder_*
  • Guests
Where is this death script located? If it's on the NPC who dies, then you'll need to use the AssignCommand function. Basically, something like:



object NPCTALKER=GetNearestObjectByTag("YOURTAGHERE");

object oPC = GetFirstPC();



AssignCommand(NPCTALKER, ClearAllActions(TRUE));

AssignCommand(NPCTALKER, ActionStartConversation(oPC, "CONVERSATIONNAME"));



I think that should work.

#6
Artfoundry

Artfoundry
  • Members
  • 62 messages
i've seen that before - what's the difference between using AssignCommand and just using the command directly?

I tried it, but it still doesn't work.  Here's the new script:
    object oPC = GetFirstPC();
    object oNPC = GetNearestObjectByTag("n_stepmother", oPC, 1);
    object oCale = GetNearestObjectByTag("c_human_cale", oPC, 1);
    
    if (GetIsObjectValid(oNPC)) //if Lorvinda is still alive
        if (GetFactionAverageReputation(oNPC, oPC) > 0)   //and she's still friendly
        {
            AssignCommand(oCale, ClearAllActions(TRUE));
            AssignCommand(oCale, ActionStartConversation(oCale, "conversation_cale_finloralive", FALSE, FALSE, FALSE, FALSE));
        }
    else
    {    
        AssignCommand(oCale, ClearAllActions(TRUE));
        AssignCommand(oCale, ActionStartConversation(oCale, "conversation_cale_niledead", FALSE, FALSE, FALSE, FALSE));
    }

Modifié par Artfoundry, 05 février 2011 - 06:09 .


#7
MasterChanger

MasterChanger
  • Members
  • 686 messages

Artfoundry wrote...

i've seen that before - what's the difference between using AssignCommand and just using the command directly?


If you don't use AssignCommand, the command assumes that you want OBJECT_SELF to perform it. Depending what fires the script, this may or may not be what you want in this case.

    if (GetIsObjectValid(oNPC)) //if Lorvinda is still alive


Although GetIsObjectValid is generally a good function to call, you may also want to check !GetIsDead(oNPC) as well.

#8
Shaughn78

Shaughn78
  • Members
  • 637 messages
Depending on the death system you are using and if you have companions you may also want to put a check to make sure the player has at least 1 hitpoint and raise and heal them if needed,



Just another small thing, with death scripts don't replace the default script. The default script will check a string on the object "DeathScript" and if you write the name of your death script there it will fire that script inaddition to the default.

#9
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
You have a mix of using braces and not using braces. I suggest you be consistent and always use them. Also you have it set to care about the starting distance. I would set that to TRUE so that starting distance is ignored. Try this. If it doesn't work, it at least improves readability.

void main()
{
    object oPC = GetFirstPC();
    object oNPC = GetNearestObjectByTag("n_stepmother", oPC, 1);
    object oCale = GetNearestObjectByTag("c_human_cale", oPC, 1);

    if (GetIsObjectValid(oNPC)) //if Lorvinda is still alive
    {
        if (GetFactionAverageReputation(oNPC, oPC) > 0)   //and she's still friendly
        {
            AssignCommand(oCale, ClearAllActions(TRUE));
            AssignCommand(oCale, ActionStartConversation(oCale, "conversation_cale_finloralive", FALSE, FALSE, TRUE, FALSE));
        }
   }
   else // Lorvinda is dead
   {    
        AssignCommand(oCale, ClearAllActions(TRUE));
        AssignCommand(oCale, ActionStartConversation(oCale, "conversation_cale_niledead", FALSE, FALSE, TRUE, FALSE));
    }
}

Modifié par Kaldor Silverwand, 05 février 2011 - 06:03 .


#10
Artfoundry

Artfoundry
  • Members
  • 62 messages
Ok, I got it working - I had forgotten to set oPC as the target for ActionStartConversation. Heh, so basically I was telling Cale to have a conversation with himself. :P