Found a possible script difference between NWN and NWN:EE
![Paphjort](https://forums.beamdog.com/applications/dashboard/design/images/defaulticon.png)
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
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
0
Comments
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.
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
Cheers!
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)