Constants not as constant as I hoped?

Hello! Sorry to bother you. Crone here.

I’m having an issue with tag-based scripting (because it should be easy and therefore is ruining my life. Apparently, my constants are all messed up.

I don’t know how or why. I just know that X2_ITEM_EVENT_ACQUIRE == 0 in my case, whereas in the toolset, it claims to be equal to 4. Basically, X2_ITEM_EVENT_ACQUIRE fires as though it were X2_ITEM_EVENT_ACTIVATE.

Why might that be so? I feel like it’s an overriding script thing, but after throwing out my override folder, there was no change to the (very odd) constant values. Creating a blank, non-custom-content module does not change this result, either.

I don’t have much expertise, so I would very much appreciate any and all leads you might have.

Here’s some lousy code to look at:

//* Script for the dagger potentially acquired in
//* besieged00. Minor storyline implications(?)!

#include "x2_inc_switches"

void main()
    int nEvent = GetUserDefinedEventNumber();

    object oPC;
    object oItem;
    int nHP;
    effect eDeath;

    int nResult = X2_EXECUTE_SCRIPT_END;

    switch(nEvent) {
        case X2_ITEM_EVENT_ACQUIRE:
            oPC = GetModuleItemAcquiredBy();
            oItem = GetModuleItemAcquired();

            if(!GetLocalInt(oPC, "acq_dagger")) {
                AssignCommand(oPC, ClearAllActions(TRUE));
                SendMessageToPC(oPC, "dagger: get");
                /*AssignCommand(oPC, ActionStartConversation(oPC, "dag_princess00",
                    FALSE, FALSE));*/
        case X2_ITEM_EVENT_ACTIVATE:
            oPC = GetItemActivator();
            oItem = GetItemActivated();

            nHP = GetCurrentHitPoints(oPC);
            eDeath = EffectDamage(nHP, DAMAGE_TYPE_SLASHING,

            ApplyEffectToObject(DURATION_TYPE_INSTANT, eDeath, oPC, -1.0f);
        default: break;


Thanks for any and all aid!

(Don’t mind the Sudden Death event. Literally just made in order to see if tag-based scripts were working as intended. Spoiler: they were not.)

Edited due to code updates

Have you made any changes to the module scripts for acquire and activate? Those should contain code that sets the userdefined event number before making the call to run tag based scripts.

1 Like

Thanks for answering, meaglyn! Hmm, I just opened the toolset to take a look at module events. Looks like they’re running the standard x2_mod_def_*.

I’ve also taken the liberty of glancing through x2_inc_switches. All of the switches look like they’re matching up with records on the NWN Lexicon.

Additional information: I am running EE. I have no clue as to whether that would add to the confusion or clarify, or even do nothing at all.

Edit/side-note: I am realizing that there is an entire sub-board devoted to EE. Yikes!

Edit/side-note 2: I noticed a glaring flaw in my code that I am currently testing out. Hilarious and explains a little, but not everything.

Okay, update, and a testament to the fact that I cannot read (read: don’t notice mistakes when I “know I’m right”).

X2_ITEM_EVENT_ACTIVATE is working just fine. In fact, I’m fairly certain all of the constants are working just fine, and that it’s my own shoddy scripting that’s to blame. To my credit, it was late in the evening after a long day when I was working on it, but that’s no excuse. :stuck_out_tongue:

Now it’s simply an exercise in getting X2_ITEM_EVENT_ACQUIRE to fire. Weirdly, it fires on 0 but not on 4. I’ll keep working on it and, should the answer arise, I will provide it.

Please excuse my silliness! I could have sworn I accounted for everything, but… :wink: Feeling pretty sheepish now!

Okay, apologies for multiple double-posts (2 double-posts? 1 triple-post?) on this thread.

I added a little spot to the dag_princess00 script that would report the GetUserDefinedEventNumber() (otherwise known as nEvent) to the player and it always reads 0. I ask myself, “Now how can that be?”

int nEvent = GetUserDefinedEventNumber();

That is how. Not “GetUserDefinedItemEventNumber()”. Testing now to double-check that’s the answer. I apologize for wasting your time, @meaglyn, but I do appreciate your help! Thankfully I was encouraged to look again at the scripts, and not jump to blame my loadout or the engine. :smile:

Edit: It lives!

Heh, I didn’t read that right in your code either :slight_smile:

Isn’t it funky how our brains supply what would be the right answer, even when we’re reading it wrong? I actually couldn’t see my mistakes until I was reading it in the forum (i.e., critically!).

Thank you again! :smile: