Aller au contenu

Photo

Scripting journal events help needed


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

#1
JammedSafety

JammedSafety
  • Members
  • 4 messages
Hello, Im doing a school project in the NWN2 Toolset. I have a script that will check for an item, and then If you have that item, advance to a secrtion in the journal log. Code below. I want to make it so that it checks that I am already on already on the quest, so If i pick up the item and I'm not on the quest, the Log advancement doesnt happen.


void main()
{
     // Get the object which was acquired
     object itemAcquired = GetModuleItemAcquired();

     if(itemAcquired != OBJECT_INVALID) {
          // Get the tag of the acquired item
          // If it is "my_item_tag" we got the right item
          if ( GetTag(itemAcquired) == "N2_ARHE001" && (CODE THAT CHECKS IF IM ON QUEST) {
               // Get the object (player) who now possess the item
               object oPC = GetItemPossessor(itemAcquired);
               // Add an appropriate journal entry to his journal
               AddJournalQuestEntry ("King", 40, oPC);
          }
     }
}

So basically I need to know the piece of code that goes where i put "code that checks if im on quest." I looked around a bit but couldn't din anything. Thanks in advance!

#2
MasterChanger

MasterChanger
  • Members
  • 686 messages
GetJournalEntry is the inverse of AddJournalQuestEntry. It returns an integer that represents the state of the quest (going by how it's numbered in the journal editor).

#3
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Code to check if on quest (this checks the journal and sees if it is at least at some current value):



if (GetLocalInt(oPC, "NW_JOURNAL_ENTRY" + sJournalTag) == nValue)



sJournalTag (string variable) is the quest's tag, nValue is the value you want to look for. You can change the == to other operators for less than, greater than, etc.

#4
JammedSafety

JammedSafety
  • Members
  • 4 messages
Thanks guys :D

#5
JammedSafety

JammedSafety
  • Members
  • 4 messages
One last thing, I'm having trouble on. Im trying to get my quest log to advance when i kill a certain monster. I have the following script in the onDeath script for the monster.



void main(string sCategoryTag, int nEntryID, int bAllPartyMembers, int bAllPlayers, int bAllowOverrideHigher)

{

object oPC = (GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());

AddJournalQuestEntry("King", 30, oPC, 1, 0, 0);

}



But nothing happens, when I kill this monster. Any Ideas?

#6
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Creature event scripts don't work exactly the same as conversation scripts, in particular they don't have parameters passed through their main function, and they can't properly use the GetPCSpeaker() function, since there is no PC speaking to anyone at the time of their death.



You need to use GetFirstPC() to get a hold of your player character instead.

#7
JammedSafety

JammedSafety
  • Members
  • 4 messages
thanks so much, I never would have found that out!

#8
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
My tutorial linked in sig below might be of some use to you, written for the novice scripter.

#9
Shallina

Shallina
  • Members
  • 1 011 messages
you can actually pass paramater on creature event script if you declare them propelly in the VAR field below the scripts panel.



Or you can store them in an OBJECT and get them from this OBJECT with a GetLocal, or GetGlobal function depending on how you stored it.

#10
MasterChanger

MasterChanger
  • Members
  • 686 messages
And if you're doing any event scripts, Pain's page on referencing objects in scripts could certainly come in handy. It notes the objects that are defined in various scripts (GetEnteringOjbect() in OnEnter, etc.).