Author Topic: Set variable and journal when all monsters cleared  (Read 375 times)

Legacy_simomate

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Set variable and journal when all monsters cleared
« on: October 01, 2010, 04:15:41 am »


               How do you achieve a variable "den_evil" being set to 10 and the journal entry for it being activated, once all of the monsters in the cave as been cleared.
               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Set variable and journal when all monsters cleared
« Reply #1 on: October 01, 2010, 05:17:14 am »


               There are a few ways, such as putting a counter on the creature's OnDeath script or check the area's heartbeat for creatures that still exist.

Area Heartbeat script

void main()
{
object oCreature = GetObjectByTag("TAG_OF_CREATURE");

if(!GetIsObjectValid(oCreature))
 {
 AddJournalQuestEntry("TAG_OF_JOURNAL_HERE", ##, GetFirstPC(), TRUE, FALSE, TRUE);
 SetLocalInt(GetModule(), "den_evil", 10);
 }
}


Creature's OnDeath script

void main()
{
int nNth = GetLocalInt(GetModule(), "den_evil");

nNth++;
SetLocalInt(GetModule(), "den_evil", nNth);

 if  (GetLocalInt(GetModule(), "den_evil") == 10)
 {
  AddJournalQuestEntry("TAG_OF_JOURNAL_HERE", ##, GetFirstPC(), TRUE, FALSE, TRUE);
 }
}


FP!
               
               

               


                     Modifié par Fester Pot, 01 octobre 2010 - 04:17 .
                     
                  


            

Legacy_simomate

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Set variable and journal when all monsters cleared
« Reply #2 on: October 24, 2010, 01:25:01 am »


               I did the area on heartbeat, and set all of the monsters in the den to the same tag. But when I cleared it out, the jounarl entry kept "updating" every second.



I wanted to set the variable so I could confirm to the NPC that it was done



(Text appears when)



However, apparntly this scripting didn't work :s
               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Set variable and journal when all monsters cleared
« Reply #3 on: October 24, 2010, 04:13:39 pm »


               For the heartbeat script,

add

if (GetLocalInt(GetModule(), "den_evil") == 10) return;


above

AddJournalQuestEntry("TAG_OF_JOURNAL_HERE", ##, GetFirstPC(), TRUE, FALSE, TRUE);


FP!
               
               

               


                     Modifié par Fester Pot, 24 octobre 2010 - 03:13 .
                     
                  


            

Legacy_simomate

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Set variable and journal when all monsters cleared
« Reply #4 on: October 25, 2010, 05:30:49 am »


               The edit fixed the journal problem. But when I speak to the PC (after clearing out the cave) I still don't get the "It's Done" text that only appears when the variable is set to 10

------------------------

This is on the heartbeat



void main()

{

object oCreature = GetObjectByTag("evilden");



if(!GetIsObjectValid(oCreature))





{

if (GetLocalInt(GetModule(), "den_evil") == 10) return;

AddJournalQuestEntry("den_evil", 2, GetFirstPC(), TRUE, FALSE, TRUE);

SetLocalInt(GetModule(), "den_evil", 10);

}

}



this is for "Text Appears When"



int StartingConditional()

{



   // Inspect local variables

   if(!(GetLocalInt(GetPCSpeaker(), "den_evil") == 10))

       return FALSE;



   return TRUE;

}

-------------------------------------------

I did suspect I might need to change if(!(GetLocalInt(GetPCSpeaker(), "den_evil") == 10))



to

if (GetLocalInt(GetModule(), "den_evil") == 10)



but that only resulted in the text appearing BEFORE the cave is cleared.



               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Set variable and journal when all monsters cleared
« Reply #5 on: October 25, 2010, 01:38:06 pm »


               Your conditional script must be -

int StartingConditional()
{

   // Inspect local variables
   if(!(GetLocalInt(GetModule(), "den_evil") == 10))
       return FALSE;

   return TRUE;
}


You must also have it placed in the proper order within the conversation itself for it to appear correctly.

Here's an example of the conversation tree -

1. Cleared monsters (den_evil == 10)
2. Asked to clear monsters
3. Met NPC before
4. First time meeting NPC


Also, after killing all the creatures, use the in-game debug commands to verify the value of den_evil and that it is set to 10 before speaking with the NPC.

FP!
               
               

               


                     Modifié par Fester Pot, 25 octobre 2010 - 12:58 .