Author Topic: Problems with dying NPC's  (Read 361 times)

Legacy_Eva_hop

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +0/-0
Problems with dying NPC's
« on: October 30, 2010, 06:22:19 pm »


               Hello NWN-fans!

I have another problem in my module-making. I have two NPC's, both offer you something, and it's up to the PC who he decides to kill. One of the NPC's named Dantello is a mist dragon. He doesn't die in combat! He is not set to plot or immortal, has HP of 99 or something, but won't die. He'll just stick at "near death" for eternity. What could cause this? The other NPC, a succubus, does die.
I want a journal update to occur when the PC has killed one of the NPC's, it of course depends on the NPC what kind of journal update you get.
I made a script ondeath, but there are no journal updates. And since I have a TextAppearsWhen script in the NPC's for when one NPC is killed that checks for the journal update, the rest of the conversation "yay you killed bob" isn't firing.
I read something online about variable strings etc, but I don't get it.

Here is the ondeath script I made using Lilac Soul's system:

void main()
{


/*   Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.c...=4683&id=625    */

//Put this script OnDeath

object oPC = GetLastKiller();

while (GetIsObjectValid(GetMaster(oPC)))
   {
   oPC=GetMaster(oPC);
   }

if (!GetIsPC(oPC)) return;

int DoOnce = GetLocalInt(oPC, GetTag(OBJECT_SELF));

if (DoOnce==TRUE) return;

SetLocalInt(oPC, GetTag(OBJECT_SELF), TRUE);

AddJournalQuestEntry("Urdu", 10, oPC, TRUE, FALSE);
AddJournalQuestEntry("Dantello", 2, oPC, TRUE, FALSE);
}


Also, can I set the NPC's to be plot characters and change them to being non-plot in conversation?

Thanks for the help.
               
               

               


                     Modifié par Eva_hop, 30 octobre 2010 - 05:31 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Problems with dying NPC's
« Reply #1 on: October 30, 2010, 09:20:53 pm »


               Plot means they can't be damaged, and immortal means they can't be damaged below 1 hp. What you're describing is the immortal behavior, despite you saying he's not immortal. I would venture to guess that, if his immortal box isn't checked in his instance and/or palette resref, then SetImmortal is getting called on him from somewhere. Might want to search your scripts for it and see what comes up.



Funky
               
               

               
            

Legacy_Eva_hop

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +0/-0
Problems with dying NPC's
« Reply #2 on: October 30, 2010, 10:03:44 pm »


               Thanks Funky! I found it and that is fixed now. But I still need the other problems resolved...
               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Problems with dying NPC's
« Reply #3 on: October 31, 2010, 12:36:09 am »


               Make them both non plot.



Change the on death scripts for each npc



Each unique npc needs its own ondeath script to fire a journal entry #



Add the start conversation or floting text to the end of each unique script for the other npc to say something.
               
               

               
            

Legacy_Eva_hop

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +0/-0
Problems with dying NPC's
« Reply #4 on: October 31, 2010, 09:22:30 am »


               OH yeah I could do it that way too.
I already had unique ondeath scripts for both of them and both of them are nonplot. But can I script them to change from plot to non-plot?

Right now I had a script for both of them attached to the ondeath event of the creature.
Now I tried the following and it still doesn't give a journal update:

void main()
{
    string sJournalTag = GetLocalString(OBJECT_SELF, "Urdu");
    int nJournalEntryID = GetLocalInt(OBJECT_SELF, "9");
    object oPC = GetFirstPC();
    if (sJournalTag != "")
        AddJournalQuestEntry(sJournalTag, nJournalEntryID, oPC, TRUE, FALSE, FALSE);
}


I tried it out now with one journal update but actually I want there to be two journal updates.
I also put the variables to the same creature named "JournalTag (String)" and set it to 1,
and "JournalEntryID (int)" set to 1.

NGH I don't get it >.<
               
               

               


                     Modifié par Eva_hop, 31 octobre 2010 - 10:52 .
                     
                  


            

Legacy_Eva_hop

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +0/-0
Problems with dying NPC's
« Reply #5 on: October 31, 2010, 10:53:55 am »


               Update ^
               
               

               
            

Legacy_Eva_hop

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +0/-0
Problems with dying NPC's
« Reply #6 on: October 31, 2010, 08:46:30 pm »


               I've messed around a little bit more and got a little bit further. This is what I've done.
For each of the two creatures I created a different unique ondeath script:

dantello_death

void main()
{
object oPC = GetLastKiller();
while (GetIsObjectValid(GetMaster(oPC)))
  {
  oPC=GetMaster(oPC);
  }
if (!GetIsPC(oPC)) return;
//to set the conversation on/journal update
SetLocalString(oPC, "dantello_death", "6");
AddJournalQuestEntry("Dantello", 3, oPC, TRUE, FALSE);
}


and

hasheida_death

void main()
{
object oPC = GetLastKiller();
while (GetIsObjectValid(GetMaster(oPC)))
  {
  oPC=GetMaster(oPC);
  }
if (!GetIsPC(oPC)) return;
SetLocalString(oPC, "hasheida_death", "5");
AddJournalQuestEntry("Urdu", 10, oPC, TRUE, FALSE);
}



Then in the conversation of each creature I put a "text appears when" script:

dantello_convo3

int StartingConditional()
{
object oPC = GetPCSpeaker();
if (GetLocalInt(oPC, "hasheida_death") != 5) return FALSE;
return TRUE;
}

hasheida_convo3

int StartingConditional()
{
object oPC = GetPCSpeaker();
if (GetLocalInt(oPC, "dantello_death") != 6) return FALSE;
return TRUE;
}


The journal entries set on the ondeath scripts to update now once a PC has killed the creature, but when I talk to the remaining NPC, it doesn't start the right conversation string.
What am I doing wrong?
               
               

               


                     Modifié par Eva_hop, 31 octobre 2010 - 08:47 .
                     
                  


            

Legacy_Eva_hop

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +0/-0
Problems with dying NPC's
« Reply #7 on: November 02, 2010, 08:51:02 pm »


               No one?
               
               

               
            

Legacy_KenquinnTheInsaneOne

  • Newbie
  • *
  • Posts: 48
  • Karma: +0/-0
Problems with dying NPC's
« Reply #8 on: November 02, 2010, 09:06:59 pm »


               You used SetLocalString to store the variable, but you try and use GetLocalInt to retrieve it. I am guessing you see how to fix it now.
               
               

               


                     Modifié par KenquinnTheInsaneOne, 02 novembre 2010 - 09:07 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Problems with dying NPC's
« Reply #9 on: November 02, 2010, 09:14:59 pm »


               SetLocalString(oPC, "hasheida_death", "5");

Should be:

SetLocalInt(oPC, "hasheida_death", 5);

And

SetLocalString(oPC, "dantello_death", "6");

Should be:

SetLocalInt(oPC, "dantello_death", 6);

Or you could also change your conditionals.

if (GetLocalInt(oPC, "hasheida_death") != 5) return FALSE;

To:

if (GetLocalString(oPC, "hasheida_death") != "5") return FALSE;

And

if (GetLocalInt(oPC, "dantello_death") != 6) return FALSE;

To:

if (GetLocalString(oPC, "dantello_death") != "6") return FALSE;

               
               

               
            

Legacy_Eva_hop

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +0/-0
Problems with dying NPC's
« Reply #10 on: November 02, 2010, 11:14:05 pm »


               Ah how lame I didn't see that! Thanks so much!
               
               

               
            

Legacy_Eva_hop

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +0/-0
Problems with dying NPC's
« Reply #11 on: November 05, 2010, 12:03:34 pm »


               Well everything's functioning well now, except for one thing. I was testing the journal updates by killing one NPC, and the penguins (also NPC's) don't like that at all and start to mix into the battle. They don't really pose a big threat but there must be a way I can prevent this, right?

I set the penguins to faction Defender.
I made custom factions for the two NPC's Dantello and Hasheida (faction Dantello and Hasheida, both originate from Merchant).

How do I fix this?

EDIT: I fixed it (I think) by making the penguins Merchant as well.
               
               

               


                     Modifié par Eva_hop, 05 novembre 2010 - 12:10 .