Author Topic: more pqj questions...  (Read 1022 times)

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
more pqj questions...
« on: September 06, 2010, 12:48:47 am »


               I think his might actually be an OnDeath of NPC issue, but i am using the PQJ (Persistant Quest Journal) system and I love it, but..... I am no scripter and so far have muddled my way through using it, but somethings I have questions on. First, When a players summon creature or familiar killes a NPC that is meant to be killed as part of a quest the journal does not update for the player as the player didnt make the killing shot. can this be fixed.? I will post below my ondeath script. I dried using the Script gen. to create a new script but it gives me the exact script I am using. I need the script to update the journal and give the item to the player even if the player wasnt the killer of the NPC.

 #include "pqj_inc"

//Put this script OnDeath
void main()
{


object oPC = GetLastKiller();

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

if (!GetIsPC(oPC)) return;

CreateItemOnObject("geo_cleagehead", oPC);
 {
   if(RetrieveQuestState("CLEAGE",oPC) == 1) // quest started
   {
     AddPersistentJournalQuestEntry("CLEAGE",2, oPC,FALSE);
     }
   else
   {
     // player has not started the quest yet, return item to chest
//      CreateItemOnObject(GetResRef(oItem));
//      DestroyObject(oItem);
     SendMessageToPC(oPC,"You haven't started this quest yet...");
   }
 }
}
               
               

               
            

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
more pqj questions...
« Reply #1 on: September 06, 2010, 01:44:48 am »


               Nope actually i guess the script works fine... but if anyone has any ideas on how to make it so no matter who kills the NPC in the party (Player or otherwise), the player working on the quest gets the journal update and the quest item...
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
more pqj questions...
« Reply #2 on: September 06, 2010, 03:48:07 am »


               This should do, as long as the PC is in the same party and can see the NPC killed.

Note: Untested.

#include "pqj_inc"
//Put this script OnDeath
void main()
{

    object oPC = GetLastKiller();
    while (GetIsObjectValid(GetMaster(oPC)))
    {
        oPC=GetMaster(oPC);
    }
    if (!GetIsPC(oPC)) return;
    CreateItemOnObject("geo_cleagehead", oPC);
    if (RetrieveQuestState("CLEAGE",oPC) != 1)
    {
       object oTest= GetFirstFactionMember(oPC);
       while (GetIsObjectValid(oTest))
       {
           if((RetrieveQuestState("CLEAGE",oTest) == 1) && GetObjectSeen(OBJECT_SELF,oTest))
           {
               oPC = oTest;
               break;
           }
           GetNextFactionMember(oPC);
       }
    }
    if(RetrieveQuestState("CLEAGE",oPC) == 1) // quest started
    {
           AddPersistentJournalQuestEntry("CLEAGE",2, oPC,FALSE);
    }
    else
    {
          // player has not started the quest yet, return item to chest
          // CreateItemOnObject(GetResRef(oItem));
          // DestroyObject(oItem);
         SendMessageToPC(oPC,"You haven't started this quest yet...");
    }
}


EDIT: corrected endless loop.
               
               

               


                     Modifié par Lightfoot8, 06 septembre 2010 - 02:50 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
more pqj questions...
« Reply #3 on: September 06, 2010, 03:49:00 am »


               I have, you must loop to party.

#include "pqj_inc"

//Put this script OnDeath
void main()
{
object oPC = GetLastKiller();
object oArea = GetArea(oPC);

object oPartyMember = GetFirstFactionMember(oPC,TRUE);
 while(oPartyMember != OBJECT_INVALID)
 {
  if(GetArea(oPartyMember) == oArea && GetDistanceBetween(oPC,oPartyMember) < 35.0)
  {
  CreateItemOnObject("geo_cleagehead", oPartyMember);
   if(RetrieveQuestState("CLEAGE",oPartyMember) == 1) // quest started
   {
   AddPersistentJournalQuestEntry("CLEAGE",2, oPartyMember,FALSE);
   }
   else
   {
   // player has not started the quest yet, return item to chest
   //      CreateItemOnObject(GetResRef(oItem));
   //      DestroyObject(oItem);
   SendMessageToPC(oPartyMember,"You haven't started this quest yet...");
   }
  }
oPartyMember = GetNextFactionMember(oPC,TRUE);
 }
}

This way, head will be given to all players doing the quest (hmm I would consider this) and they get update too.

EDIT: LightFoot8 you outrunned me again, but you didn't made exactly what I at least, so it had sense.
               
               

               


                     Modifié par ShaDoOoW, 06 septembre 2010 - 03:01 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
more pqj questions...
« Reply #4 on: September 06, 2010, 03:57:39 am »


               Yes, I was barly ahead. just to not differances for the OP. My script will only update for and give the item to one PC in the party. Shadows will Give it to all the PC's that are doing the quest in the same party.

The one thing you did miss though shadow is if the server is of the type where everyone like to party up to talk. A PC in a far off corner of the world,has Started the quest, they will get updated for the quest when they are no where around.

Edit: Shadows script is however better written. You may just want to add the dead guy seen to the check. 
               
               

               


                     Modifié par Lightfoot8, 06 septembre 2010 - 02:59 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
more pqj questions...
« Reply #5 on: September 06, 2010, 04:02:17 am »


               

Lightfoot8 wrote...

The one thing you did miss though shadow is if the server is of the type where everyone like to party up to talk.  A PC in a far off corner of the world,has Started the quest, they will get updated for the quest when they are no where around.

Yes, you are right, thanks fot catching this, I updated my script to check area and distance from killer.

EDIT: checking for GetObjectSeen might be really better, but I have not experiences with it, so I keep it this way.
               
               

               


                     Modifié par ShaDoOoW, 06 septembre 2010 - 03:04 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
more pqj questions...
« Reply #6 on: September 06, 2010, 04:23:13 am »


               

ShaDoOoW wrote...

EDIT: checking for GetObjectSeen might be really better, but I have not experiences with it, so I keep it this way.


lol,  Yes,  that is why I put my untested disclaimer on it.  I do not know if it will return correctly for the dying NPC.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
more pqj questions...
« Reply #7 on: September 06, 2010, 04:31:30 am »


               Now as far as multiple head concerned...

This was quite issue at The Three Towns server, in past you get only one head for party (in loot), so if whole party want to fulfill the quest they must have wait in area for respawn of the boss - this was pardon me, but very stupid. Now they giving into loot multiple heads.

But giving head to each player might not be very logical and "rp". I can suggest you, not to require the head in your quest in order to finish it, but rather the quest variable - so if the quest variable will be 1000 (finish) or any other number you desire, allow PC to finish the quest, then if he got head, destroy it, if not, nevermind. If you would go this way, then it would look like this:

#include "pqj_inc"

//Put this script OnDeath
void main()
{
CreateItemOnObject("geo_cleagehead",OBJECT_SELF); // only one head will appear in loot remains
object oPC = GetLastKiller();
object oArea = GetArea(oPC);

object oPartyMember = GetFirstFactionMember(oPC,TRUE);
 while(oPartyMember != OBJECT_INVALID)
 {
  if(GetArea(oPartyMember) == oArea && GetDistanceBetween(oPC,oPartyMember) < 35.0)
  {
     if(RetrieveQuestState("CLEAGE",oPartyMember) == 1) // quest started
     {
     AddPersistentJournalQuestEntry("CLEAGE",2, oPartyMember,FALSE);
     }
     else
     {
     // player has not started the quest yet, return item to chest
     // CreateItemOnObject(GetResRef(oItem));
     // DestroyObject(oItem);
     SendMessageToPC(oPartyMember,"You haven't started this quest yet...");
     }
   }
 oPartyMember = GetNextFactionMember(oPC,TRUE);
 }
}


EDIT: also, just giving the quest variable does not tell the player whats going on. You need to add journal update, and best some message to!
               
               

               


                     Modifié par ShaDoOoW, 06 septembre 2010 - 03:35 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
more pqj questions...
« Reply #8 on: September 06, 2010, 04:44:02 am »


               AddPersistentJournalQuestEntry("CLEAGE",2, oPartyMember,FALSE);



Is a wrapper around JournalQuestEntry  So the journal does get updated.
               
               

               
            

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
more pqj questions...
« Reply #9 on: September 06, 2010, 04:53:50 am »


               hhhmmm... not sure I understand ShaDoOoW I do not know anything about variables. what will happen in the script...?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
more pqj questions...
« Reply #10 on: September 06, 2010, 05:01:14 am »


               Basicly he is saying.  When a PC goes to compleat the quest do not use the head for the test of having compleated it.  Instead use  



if(RetrieveQuestState("CLEAGE",oPC) == 2)



as the test and dont worry to much about them having the head or not.
               
               

               
            

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
more pqj questions...
« Reply #11 on: September 06, 2010, 05:04:06 am »


               im not sure I understand still, the script he provided is still creating "geo_cleagehead" on the player. What should the script look like if it doesnt give the head? and will the journal update no matter who kills Cleage in the party?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
more pqj questions...
« Reply #12 on: September 06, 2010, 05:10:41 am »


               Yes It will update for all players who are in the same area and within 35m who have taken the quest.   The diffrence in his last script is that it will give only one head and not a head per PC.
               
               

               
            

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
more pqj questions...
« Reply #13 on: September 06, 2010, 05:12:01 am »


               so what should the script look like if I dont want it to give the head at all but instead just update the journal to show that part of the quest is done?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
more pqj questions...
« Reply #14 on: September 06, 2010, 05:18:23 am »


               Just remove the one line that gives the Head.  



CreateItemOnObject("geo_cleagehead",OBJECT_SELF); // only one head will appear in loot remains