Quick question about OnAcquire script… I want a journal entry to advance when the PC acquires an item, simple. Which OnAcquire script do I use (there are several) and where does the script get placed? On the object?
Thanks.
Quick question about OnAcquire script… I want a journal entry to advance when the PC acquires an item, simple. Which OnAcquire script do I use (there are several) and where does the script get placed? On the object?
Thanks.
Hi AYG,
There is only one On Acquire script that is used on a module. See module properties to see which one you are currently using.
If you check it out, it should have something like this at the top …
object oItem = GetModuleItemAcquired();
object oPC = GetModuleItemAcquiredBy();
From there, you should be able to work out which function to use to add the journal entry you refer to.
Cheers, Lance.
If you use the Power Bar plugin,
click to create a new script
pick a template OnAcquire
name your script it_itemtag_aq
In the script you will see a section which says “Your code goes here”. Simply add the function which updates the journal.
Uncomment some other section which says that the script should only fire once, and the one tha says that it should only fire for PCs. These of course depending on your needs…
Save script in the module where the item is picked, or in your campaign/hak
You’re good to go.
If you don’t use the Power Bar, there is a templates collumn in the script editor as well, next to the globals.
@Lance_Botelle, @andysks, thanks for the help and info! But I have to admit, I decided to cheat… I simply used Lilac Soul’s script generator to write the OnAcquire scripts I needed rather that do it by hand.
Lilac Soul’s Script Generator is great when you need to do something simple, or you need some code to get you started on a bit more advanced stuff.
Hi AYG,
I always found I needed to do more extreme scripting and so ended up learning. It’s not too bad once you grasp the basic concept. Anyway, glad you got it sorted.
Cheers, Lance.
Well, I aslo found I needed to do more extreme scripting, but I ended up not learning and got frustrated instead. because my brain obivously wasn’t made for scripting. I’m too irrational and weird, I guess.
Still, finally after two years, I at least know something thanks to overly patient teachers such as kevL_s, Lance Botelle, Aqvilinus, travus and many more.
a little goes a long way… i bet scripts don’t read like LinearA anymore
EDIT → here’s a fairly generic/common template for tag based item-acquired scripts
// 'i_itemtag_aq'
#include "ginc_item_script"
void main()
{
if (IsItemAcquiredByPartyMember())
{
object oItem = GetModuleItemAcquired();
if (!IsItemMarkedAsDone(oItem, SCRIPT_MODULE_ON_ACQUIRE_ITEM))
{
MarkItemAsDone(oItem, SCRIPT_MODULE_ON_ACQUIRE_ITEM);
// do acquire code here
}
}
}
Fortunately, I only needed some simple function like add a journal entry or give the PC some experience points, so it works well for these.
I gotta sympathize wit @andgalf, I know how you feel… I haven’t coded anything since Fortran back in the late 80’s. I can read some VB and HTML guys at work taught me, but couldn’t really code if I had to. I’ve picked up a few very minor skills, but certainly nothing advanced. And for some reason I find it much easier to read the code than to write it…
About as indecipherable as FORTH (well they both give me a headache anyway - rpn… the word… yech!)
Oh, I totally agree with this! It’s a lot easier to read and understand NWN2 code than it is to write it. Sometimes you know what needs to be done but can’t for the life you come up with what function you are searching for and what you need. Nowadays I have so many scripts already made to fall back on, so there are pretty few cases nowadays, comparing to when I started 2 years ago with this, that I need help to script. But as soon as the game doesn’t function the way I want to, very often due to timing problems, I’ve had to go deep into the code and get very specific help from Lance, 4760 and kevL_s to understand how to write things so that the game actually does the things you want it to do.
Many things are still way above my head. For my newly released module I had some custom spell effects that I needed (I needed objects to behave a certain way when the PC threw spells on them, one of them a custom spell even) and this I still cannot do. I got Aqvilinus’ help for this and that was some quite advanced stuff. I kind of understand when I read the code, but I know there was two scripts involved in this (why, I still don’t understand) to make it work.
And in the module I’m working on now I use Lance’s weather system in one area. I would never be able to come up with something as complex as that. Again he was kind enough to help me so that I could use his advanced system.