Aller au contenu

Photo

Adding journal entry when items acquired


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

#1
maglalosus

maglalosus
  • Members
  • 51 messages
I have this so far...

void main()
{
object oPC = GetModuleItemAcquiredBy();
object oItem;
oItem = GetModuleItemAcquired();
if (!GetIsPC(oPC)) return;
if (GetLocalInt(GetModule(), "ac_"+GetTag(oItem))) return;
SetLocalInt(GetModule(), "ac_"+GetTag(oItem), TRUE);
AddJournalQuestEntry("journal_entry", 20, oPC, FALSE, FALSE);
}


But now i need to add...

There needs to be eight of the item acquired in the PC's inventory, before journal entry fires.
And where do i put the item's Tag?

Thanks for any help... M

#2
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Hi Maglalosus,

This can be accomplished very easily through the use of tag-based scripting.

Okay, I was going to put in a link, but I can't find it, which is odd because I know there are tutorials on it all over the internet. I'll give you a quick synopsis, but I recommend you look up Tag-Based scripting for NWN2 on google.

Tag based scripting links a script to an action done on an object. Off the top of my head they are:

on item acquire (this is the one you want)
on item activate
on item unaquire
on item equip
on item unequip

uh.....

There are more, but I can't think of them now. Again, look up a tutorial.


the script has to be named like this:

i_(the tag of the item here)_(appropriate suffix)

The appropriate suffix is determined by what action you want. The action you want is on acquire, so you want "aq" as your suffix.

if the name of your item was "secret_plans"

then your script woud be named:

i_secret_plans_aq

Now, whenever an item with the tag "secret plans" is aquired, then the script "i_secret_plans_aq" will fire.

#3
The Fred

The Fred
  • Members
  • 2 516 messages
Then you'll probably want to check to see if the player owns either of the items before doing anything. You *could* keep track of how many times the script fires, but then you need to handle what happens when a player puts an item back down again - otherwise they could pick up the same one eight times. That's easy enough to do, but it's probably easier just to run a check whenever an item is picked up to see if the player now has eight of them. I think there's a GetNumItems() function in nw_i0_plot you can use, IIRC - you will need to include this like so:

#include "nw_i0_plot"
void main()
{
    //Your script here
}

As a side note, tag-based scripting is far from necessary (you can just stick everything in the event script), but it's widely regarded as being better, since you have lots of little nice scripts for individual items rather than one super-massive humungous one (there are times when I think tagbased scripting is not appropriate, but this isn't one of those).

Modifié par The Fred, 01 mai 2011 - 07:47 .


#4
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
If you download my Silverwand Sample Campaign I have scripts provided there that do many of the things needed for campaigns. Including scripts to update journal entries when they are acquired (the three stooges send you on a quest).

Regards

#5
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
If you do go that route, here's the link for Tag-based scripting:
http://www.noobscorn...cs.htm#TBS_nwn2

Modifié par _Knightmare_, 01 mai 2011 - 08:56 .