Skip to content

Found a possible script difference between NWN and NWN:EE

PaphjortPaphjort Member Posts: 25
edited December 2017 in Builders - Scripting
Hi
In a module I'm making I've noticed a difference in scripting between old NWN and NWN:EE

The following works fine in NWN 1.69 :
(from a script called via tag-based scripting, when a players activates a unique power of a weapon on an enemy)

case X2_ITEM_EVENT_ACTIVATE:
// * This code runs when the Unique Power property of the item is used
// * Note that this event fires for PCs only

oPC = GetItemActivator(); // The player who activated the item
oItem = GetItemActivated(); // The item that was activated
oSpellTarget = GetItemActivatedTarget(); // The target Creature
lSpellLocation = GetItemActivatedTargetLocation(); // The target location

// Your code goes here
if (oSpellTarget == oPC) // If the player targets himself, nothing happens and he gets the charge back.
{
nRand = 99;
ItemSpeak(nRand, oPC, PL_REF);
int MaxCharges = GetLocalInt(oItem,"maxcharges");
int charges = GetItemCharges(oItem);
if(charges < MaxCharges)
{
RestoreCharges(oItem);
}

break;
}

// Choose what to do, if he targets an enemy
nRand = 7+ Random(2); // Line 7-10

if (nRand == 7 && GetIsEnemy(oSpellTarget)) // Charge!
{

effect eDur = EffectVisualEffect(VFX_DUR_AURA_PULSE_MAGENTA_RED);
effect eDur2 = EffectACIncrease(5);
effect eDur3 = EffectHaste();
effect eLink = EffectLinkEffects(eDur2, eDur);
eLink = EffectLinkEffects(eLink, eDur3);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oPC, 18.0);
AssignCommand(oPC,ClearAllActions());
AssignCommand(oPC,ActionAttack(oSpellTarget));
// AssignCommand(oPC,ActionDoCommand(SetCommandable(TRUE,oPC)));
DelayCommand(0.2,SetCommandable(FALSE,oPC));
DelayCommand(18.0,SetCommandable(TRUE,oPC));

}
// the script continues with more possiblities depending on what nRand is

This works in NWN 1.69, but doesn't fire in NWN:EE

In NWN:EE I need to change this line:
if (nRand == 7 && GetIsEnemy(oSpellTarget)) // Charge!

to this for it to work:
if (nRand == 7 && GetIsEnemy(oSpellTarget,oPC)) // Charge!

and then it works perfectly!

I imagine this could break other modules?

/Paphjort
Post edited by Paphjort on

Comments

  • ProlericProleric Member Posts: 1,281
    According to the Lexicon, OBJECT_SELF in the OnActivateItem event is the module, not the player. That makes sense, because it is a module event.

    Your original script has an implicit OBJECT_SELF in GetIsEnemy. The module is not an enemy, so I'm not sure why it would work before.
  • PaphjortPaphjort Member Posts: 25
    edited December 2017
    That's makes sense Proleric, but then, as you say, I don't know why it worked before?
    Same exact script worked fine in 1.69, I saved the module with the new toolset, played it and it didn't work until I opened it again and added oPC (after testing the mod with AssignCommand(oSpellTarget,SpeakString("I am oSpellTarget")); etc. to see who was who....
    I still have the old version and it still works in 1.69. Go figure.

    But in the end it's better that my old mod has crazy behavior, than this being a bug/change in NWN:EE that needs fixing :smiley: and it works now with oPC, so all is well
    Cheers!
  • FinalStandFinalStand Member Posts: 87
    edited February 2018
    This is offtopic, but I'm curious on how your RestoreCharges(oItem); function works.

    When I try 'SetItemCharges(oItem, 1)', it doesn't reset. Player is forced to rest for item to get back it's charge (even though GetItemCharges reports 1)
    Post edited by FinalStand on
Sign In or Register to comment.