My first guess is that your forgot to compile the script after making the edits - if you don't have autocompile with save turned on, that is. I'm a little surprised no one told you WHY your script was doing this.
The first two lines of your script:
int nEvent =GetUserDefinedItemEventNumber();
if (!nEvent == X2_ITEM_EVENT_ACTIVATE) return;
The typical code would normally look as Baragg posted, but WHY? The point of this code is to abort the script execution for events other than item activation, but that isn't what your code does. Whoever altered it apparently thought that (!x == y) is logically identical to (x != y) - it isn't. != means 'does not equal', and will return TRUE if the two expressions it is comparing aren't identical, FALSE if they are identical - it's the exact opposite of ==, which returns TRUE if they expressions are identical, FALSE if they aren't.
! placed in front of an expression, however, changes it from TRUE to FALSE and vice versa - !TRUE means the same thing as FALSE, and !FALSE is TRUE.
The last piece of the puzzle is the value of the expression you're reversing with ! - it isn't intended to be used as a simple TRUE or FALSE value, but an int with multiple TRUE values (any value, positive or negative, that isn't 0, is TRUE, and 0 is FALSE). Here, the GetUserDefinedItemEventNumber returns this range of values (taken from the bioware include x2_inc_switches):
//------------------------------------------------------------------------------
// These constants define item messages that are routed to script files with
// the item tag's through the default XP2 module scripts.
//------------------------------------------------------------------------------
const int X2_ITEM_EVENT_ACTIVATE = 0;
const int X2_ITEM_EVENT_EQUIP = 1;
const int X2_ITEM_EVENT_UNEQUIP = 2;
const int X2_ITEM_EVENT_ONHITCAST = 3;
const int X2_ITEM_EVENT_ACQUIRE = 4;
const int X2_ITEM_EVENT_UNACQUIRE = 5;
const int X2_ITEM_EVENT_SPELLCAST_AT = 6;
What the normal function of this does is to return if the Event function returns anything but a 0, for Activate. What you're having it do with if (!nEvent == X2_ITEM_EVENT_ACTIVATE) is to take the value of nEvent, from 0-6, and flip the truth value. The net result is that it is firing on every event BUT activate. To see why, look what happens:
X2_ITEM_EVENT_ACTIVATE: 0 = FALSE, !0 = TRUE, !Event = TRUE, TRUE doesn't equal X2_ITEM_EVENT_ACTIVATE (which is 0, or FALSE), no fire
X2_ITEM_EVENT_EQUIP: 1 = TRUE, !1 = FALSE, !Event = FALSE, FALSE does equal X2_ITEM_EVENT_ACTIVATE (which is 0, or FALSE), script fires
The same happens with every other event whose const is greater than 0, as happens with EQUIP.
Normally, you'd be comparing event numbers to see if one equalled 0, the const for ACTIVATE, but instead you're simply checking to see if the event number is greater than 0. Whups.
Anyway, lmk if a compile doesn't solve it, now that you've made Baragg's edit.
Funky
Modifié par FunkySwerve, 18 octobre 2010 - 11:45 .