Author Topic: NWNX2 Issue  (Read 1253 times)

Legacy_Demkey

  • Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
NWNX2 Issue
« on: June 08, 2014, 04:47:40 pm »


               

I implemented the NWNX2 scripting to a new module that I've been putting together and it has addressed the issues I had with making it a PW module. However, after testing I've discovered that the OnAquire scripts that I created (i.e. aq_xxxxxxx) are no longer working.


 


Can someone shed some light as to why this is happening, and hopefully how to fix it? I have a total of about 3 dozen aq_xxxxxx files that are currently affected.



               
               

               
            

Legacy_BelowTheBelt

  • Hero Member
  • *****
  • Posts: 699
  • Karma: +0/-0
NWNX2 Issue
« Reply #1 on: June 08, 2014, 05:08:43 pm »


               What errors are you getting?  Have you tried debugging to see where the issue is (I.e to make sure it is firing and that all data is being captured)?  Are those scripts using any of the nwnx functions?  


I presume those were working before you installed nwnx?  What plugins are you running?
               
               

               
            

Legacy_Demkey

  • Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
NWNX2 Issue
« Reply #2 on: June 08, 2014, 05:30:49 pm »


               

I’m not getting any in-game errors being broadcast, nor am I seeing any errors in the server log. They simply aren’t doing their job.


 


Very briefly, every encounter has a Soul Stone in its inventory, when the player loots that Soul Stone the scripts do three basic things, give out bonus XP/Gold, they run a random item creator that places an item in the players inventory, then the script deletes the Soul Stone.  And yes the scripts were running fine just prior to installing NWNX2. They were created prior to me even discovering that NWNX2 was out there, so if there is any special NWNX2 OnAquire functions, then no I'm not using them.


 


All I’m running is the Core NWNX2 program with the ODBC add-on.



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
NWNX2 Issue
« Reply #3 on: June 08, 2014, 06:55:37 pm »


               NWNX2.exe itself doesn't directly affect any onAcquire scripts - to knowledge.

Have you tried placing a line such as

AssignCommand(GetModuleItemAcquiredBy(),SpeakString("I have acquired an item"));

in your onAcquire script, to verify if the script is firing.
Try placing the message/debug statement at various points within your script to identify the location the script fails/breaks etc.
Also remember to recompile the script before re-testing. Sometimes saving the module isn't enough, an actual compile / build scripts solves problems like this.
               
               

               
            

Legacy_Demkey

  • Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
NWNX2 Issue
« Reply #4 on: June 08, 2014, 07:38:52 pm »


               

The very first thing the script does is to give XP & gold to the party, and that's not happening, so it seems to be failing right away. Here is what the beginning of the script does. I'm only including the beginning of it since it's a somewhat lengthy script.


 


#include "nw_i0_tool"

void main()

{


object oPC = GetModuleItemAcquiredBy();

int nStackSize = 50;

object oItem;

oItem = GetModuleItemAcquired();

if (!GetIsPC(oPC)) return;

RewardPartyXP(50, oPC, TRUE);

RewardPartyGP(80, oPC, TRUE);


.....script continues


 


I did do a rebuild on the module after I added NWNX2.



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
NWNX2 Issue
« Reply #5 on: June 08, 2014, 09:10:19 pm »


               The only thing I can think of is that for some reason oPC is not coming back as true in the GetIsPC check.
Have you tried debug statements before that if statement?

NWNX shouldnt be overriding any scripts unless you have nwnx_resman in use - and even then, it will only override if it detects an external version of that script to replace it with.
               
               

               
            

Legacy_Demkey

  • Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
NWNX2 Issue
« Reply #6 on: June 08, 2014, 09:29:38 pm »


               

No I haven't tried any debugging. I'm not a programmer/scripter so I'm not sure how to go about doing that. My only experience with scripting is using Lilac. Is there a short piece of coding I can insert in it to do that?



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
NWNX2 Issue
« Reply #7 on: June 08, 2014, 09:44:59 pm »


               Place this line

AssignCommand(GetModuleItemAcquiredBy(),SpeakString("I have acquired an item"));

above the line that reads

if (!GetIsPC(oPC)) return;


When you pick up an item, if you speak "I have acquired an item" then we know your script is firing, but for some reason its not getting past the if statement.
               
               

               
            

Legacy_Demkey

  • Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
NWNX2 Issue
« Reply #8 on: June 08, 2014, 11:05:12 pm »


               

It didn't come back and say "I have acquired an item". So that means the script isn't firing off at all???



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
NWNX2 Issue
« Reply #9 on: June 08, 2014, 11:10:00 pm »


               It would suggest that it isnt.
The script is definitely attached to the modules onAcquire event?

And also - are any haks being used?
               
               

               
            

Legacy_Demkey

  • Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
NWNX2 Issue
« Reply #10 on: June 08, 2014, 11:19:59 pm »


               

According to Lilac I have to use the below coding and name the script the same as the Resref of the object that I'm placing in the encounter's inventory as the drop (which would be soulstone50). Then I'm suppose to create a second file that contains the above script with the same name but with a leading aq_ so it would be aq_soulstone50. Like I mentioned earlier the script was running fine up until yesterday when I installed NWNX2.


 


Here is what I have in the soulstone50 file:


 


#include "x2_inc_switches"

void main()

{

int nEvent =GetUserDefinedItemEventNumber();

switch (nEvent)

   {

   case X2_ITEM_EVENT_ACTIVATE:

ExecuteScript("ac_"+GetTag(GetItemActivated()),

OBJECT_SELF); break;

   case X2_ITEM_EVENT_EQUIP:

ExecuteScript("eq_"+GetTag(GetPCItemLastEquipped()),

OBJECT_SELF); break;

   case X2_ITEM_EVENT_UNEQUIP:

ExecuteScript("ue_"+GetTag(GetPCItemLastUnequipped())

, OBJECT_SELF); break;

   case X2_ITEM_EVENT_ACQUIRE:

ExecuteScript("aq_"+GetTag(GetModuleItemAcquired()),

OBJECT_SELF); break;

   case X2_ITEM_EVENT_UNACQUIRE:

ExecuteScript("ua_"+GetTag(GetModuleItemLost()),

OBJECT_SELF); break;

   case X2_ITEM_EVENT_SPELLCAST_AT:

ExecuteScript("sp_"+GetTag(GetModuleItemLost()),

OBJECT_SELF); break;

   case X2_ITEM_EVENT_ONHITCAST:

ExecuteScript("on_"+GetTag(GetSpellCastItem()),

OBJECT_SELF); break;

   }

}



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
NWNX2 Issue
« Reply #11 on: June 08, 2014, 11:48:21 pm »


               Am I correct in assuming that you have this script running from the UserDefined event on the module?

If thats the case then you should be naming your script the same as whatever the tag of the item is, and not the resref.

You are using gettag in the above switch statement, which means you should put aq_soulstone50 as your tag name for the soul stone.

The above script would need to be in the user defined script event I believe.
               
               

               
            

Legacy_Demkey

  • Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
NWNX2 Issue
« Reply #12 on: June 09, 2014, 12:14:13 am »


               

I made the tag name and ResRef the same on these soul stones.



               
               

               
            

Legacy_BelowTheBelt

  • Hero Member
  • *****
  • Posts: 699
  • Karma: +0/-0
NWNX2 Issue
« Reply #13 on: June 09, 2014, 02:00:52 am »


               

From the Lexicon,  GetModuleItemAcquired returns the item from an OnAcquiredItem event.  If this script is run from a User Defined event, would that run into issues?  Or, is the UD Acquire still considered an OnAcquired event?


 


To expand on debuggings, update your scripts with the following some debug code:


void main()
{
SendMessageToPC(GetFirstPC(), "DEBUG:  User Defined script Firing.");


int nEvent =GetUserDefinedItemEventNumber();
SendMessageToPC(GetFirstPC(), "DEBUG:  User Defined Event = "+IntToString(nEvent));


switch (nEvent)
   {
   case X2_ITEM_EVENT_ACTIVATE:
ExecuteScript("ac_"+GetTag(GetItemActivated()),
OBJECT_SELF); break;
   case X2_ITEM_EVENT_EQUIP:
ExecuteScript("eq_"+GetTag(GetPCItemLastEquipped()),
OBJECT_SELF); break;
   case X2_ITEM_EVENT_UNEQUIP:
ExecuteScript("ue_"+GetTag(GetPCItemLastUnequipped())
, OBJECT_SELF); break;


case X2_ITEM_EVENT_ACQUIRE:


{
SendMessageToPC(GetFirstPC(), "DEBUG:  Acquire event firing.  Item tag= "+GetTag(GetModuleItemAcquired()));


ExecuteScript("aq_"+GetTag(GetModuleItemAcquired()),
OBJECT_SELF);


}


break;


...rest of your script...


 


 


In your first script, 


void main()

{


SendMessageToPC(oPC, "DEBUG:  Script Firing.");


object oPC = GetModuleItemAcquiredBy();


SendMessageToPC(GetFirstPC(), "DEBUG:  oPC = "+GetName(oPC));


int nStackSize = 50;

object oItem;

oItem = GetModuleItemAcquired();


SendMessageToPC(GetFirstPC(), "DEBUG:  oItem = "+GetName(oItem)+" with tag "+GetTag(oItem));

if (!GetIsPC(oPC)) return;

RewardPartyXP(50, oPC, TRUE);

RewardPartyGP(80, oPC, TRUE);


 


See what messages you get, if any.



               
               

               
            

Legacy_Demkey

  • Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
NWNX2 Issue
« Reply #14 on: June 09, 2014, 02:54:22 am »


               

I'm getting the below message when I trying saving the script in toolset on the first line you gave me to add to the script, SendMessageToPC(oPC, "DEBUG:  Script Firing.");


 


aq_soulstone50.nss(10): ERROR: VARIABLE DEFINED WITHOUT TYPE