Aller au contenu

Photo

Need help with a script that should update a party's journal after killing a boss.


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

#1
Quilistan

Quilistan
  • Members
  • 111 messages
I have added a section to the default death script. Commented with "Custom Death Section".

My intent for this is when the party kills the boss: check the party, see if the members of the party are in the current area, and if they are check their journals individually. If a journal is at the correct point, then update it.

The problem I am having is it doesn't always seem to fire correctly for everyone? I am not sure if it is stopping on an invalid object or something?

I would love some help fixing it.

[nwscript]
#include "pqj_inc"
#include "x2_inc_compon"
#include "x0_i0_spawncond"
#include "spawn_functions"
#include "spawn_main"
void main()
{
 string sDeathScript = GetLocalString(OBJECT_SELF, "DeathScript");
 if (sDeathScript != "")
  ExecuteScript(sDeathScript, OBJECT_SELF);
 
    int nclass = GetLevelByclass(class_TYPE_COMMONER);
    int nAlign = GetAlignmentGoodEvil(OBJECT_SELF);
    object oKiller = GetLastKiller();
    // If we're a good/neutral commoner,
    // adjust the killer's alignment evil
    if(nclass > 0 && (nAlign == ALIGNMENT_GOOD || nAlign == ALIGNMENT_NEUTRAL))
    {
        AdjustAlignment(oKiller, ALIGNMENT_EVIL, 5);
    }
    // Call to allies to let them know we're dead
    SpeakString("NW_I_AM_DEAD", TALKVOLUME_SILENT_TALK);
    //Shout Attack my target, only works with the On Spawn In setup
    SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
    craft_drop_items(oKiller);

//Custom Death Section
//Section, Should check for party members in the area, check their journals and update where nesseccary.
object oPC = GetLastKiller();
  
 //If Last Killer was an animal companion or summon, set the master as oPC
  while (GetIsObjectValid(GetMaster(oPC)))
     {
      oPC=GetMaster(oPC);
    }
 
    object oPartyMember = GetFirstFactionMember(oPC, TRUE);
    object oArea = GetArea(oPC);
 
    while(GetIsObjectValid(oPartyMember) == TRUE)
    {
        int iNoGiveQuest = 0;
  int iJournal = GetJournalEntry("stonewater_keep_jrnl",oPartyMember);

  //If PC is "not a partymember", or not in the "proper area", or does not have their journal at the correct spot, Then don't update their quest.

  if (!GetIsPC(oPartyMember))
   {
    iNoGiveQuest = 1;
   }
  if (GetArea(oPartyMember) != oArea)
          {
    iNoGiveQuest = 1;
          }  
     if(iJournal != 14)
         {
    iNoGiveQuest = 1;
         }
   
  if (iNoGiveQuest == 0)
   {      
    AddPersistentJournalQuestEntry("stonewater_keep_jrnl", 15, oPartyMember, FALSE, FALSE, FALSE);
       
          oPartyMember = GetNextFactionMember(oPC, TRUE);
   }
  if (iNoGiveQuest == 1)
   {
    oPartyMember = GetNextFactionMember(oPC, TRUE);
         }              
 }
//End Custom Death Section
NESS_ProcessDeadCreature (OBJECT_SELF);
// safety mechanism in case creature kills itself
   if(GetLastKiller() == OBJECT_SELF) return;
  
 ExecuteScript("pwfxp",OBJECT_SELF);
 
 // resurrect & self kill to bypass bioware xp message
    ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), OBJECT_SELF);
    ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(10000, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_PLUS_TWENTY), OBJECT_SELF);
 
  
}
[/nwscript]

Modifié par Quilistan, 08 octobre 2010 - 03:41 .


#2
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
I tend to avoid altering the standard scripts if the script provides a way to execute another script. The standard death script will execute a script for you if you set the variable DeathScript on the creature dying to the name of the script you want to execute.

So what I do is set variables on the creature to indicate the journal entry that should be set, and set the DeathScript variable to bb_journal_update which executes this script:

// bb_journal_update
// by Brendan Bellina
// April 2007

// This is used to update a journal entry
// Useful as a DeathScript for a creature whose death is
//  related to a quest
// If the campaign Journal Sync setting is true then it should
// update all player journals, but otherwise it only updates
// the journal of the First PC.

// Requires variables:
// string JournalTag
// int JournalEntryID


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

In my campaigns I always set the Campaign Journal Sync setting to true so there is no need for this script to walk through all of the party members as you are attempting.

Regards

Modifié par Kaldor Silverwand, 08 octobre 2010 - 04:06 .


#3
Quilistan

Quilistan
  • Members
  • 111 messages
Thanks for your reply



I actually do NOT want their journals sync-ed in this case I want each member to accomplish each part of the quest. This is for a PW, and because of this quest's special reward I am trying to avoid exploits.



With the script I am atempting to check if the party members where actually present when the boss was killed, and also checking to see if they have each accomplished all the earlier steps of the quest. If these things pass, then I want it to update their journals.



To do this I have to check each party member seperately. Anyone tagging along for the ride and not completing everything will not get a free ride, and will have to go back and complete the earlier stages. Not all my quests are this way, but a few are special.



The script is actually an OnDeath script for the boss.



Again it just doesn't seem to be firing correctly all the time, and I am not sure why?

#4
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
First, I would simplify the section like this:
//Custom Death Section
//Section, Should check for party members in the area, check their journals and update where necessary.
 object oPC = GetLastKiller();
 object oArea = GetArea(oPC);
 
 //If Last Killer was an animal companion or summon, set the master as oPC
 if (GetIsObjectValid(GetMaster(oPC)))
 {
   oPC=GetMaster(oPC);
 }
 
 object oPartyMember = GetFirstFactionMember(oPC, TRUE); // limit to PCs
 string sJournalTag = "stonewater_keep_jrnl";
 
 while(GetIsObjectValid(oPartyMember))
 {
	int iJournal = GetJournalEntry(sJournalTag,oPartyMember);

	// If Party Member is in the area and their journal is at the correct spot, then update their quest.
	if ((GetArea(oPartyMember) == oArea && iJournal == 14))
	{
		AddPersistentJournalQuestEntry(sJournalTag, 15, oPartyMember, FALSE);
	}
	oPartyMember = GetNextFactionMember(oPC, TRUE);
  }
//End Custom Death Section

Regards

Modifié par Kaldor Silverwand, 08 octobre 2010 - 06:43 .


#5
Quilistan

Quilistan
  • Members
  • 111 messages
I made this change tonight, thanks for the advice! This is a tough high level quest so I am sure it will take sometime before it is fully tested.



Thanks again.