Aller au contenu

Photo

Unique OnUse


  • Veuillez vous connecter pour répondre
8 réponses à ce sujet

#1
Artevere

Artevere
  • Members
  • 36 messages
 Back in NWN 1, we could add a property called Unique OnUse or OnUse Self, then write a script that fired when the item was used.

I've searched high and low, but cannot find any property, setting, check box, or drop menu that has this option for items.

What am I missing? I noticed that online modules have items that fire custom scripts when used, so I know it's possible. :?

#2
FergusM

FergusM
  • Members
  • 460 messages
In the item editor, you want to pick an 'activated ability'. It is right near the top. This selects an ability from the ABI_base 2DA with abilitytype 4 (which is item abilities). You can add a new item ability (look into 2DA editing on the wiki) and set the spellscript column to the script you would like to run. This script will get called multiple times with different events when the ability is used. Take a look at some of the other ability spellscripts (for example, item_singletarget.nss) for an example of how the system works.

#3
Artevere

Artevere
  • Members
  • 36 messages
Hmm. Should be able to create a generic entry that just fires off a script with the same tag as the item then, similar to NWN 1

#4
Proleric

Proleric
  • Members
  • 2 350 messages
If you set the item's Activated Ability to ITEM_ABILITY_UNIQUE_POWER_SINGLE_USE or ...UNLIMITED_USE, you can intercept usage in the module event script. For example

[dascript]
case EVENT_TYPE_UNIQUE_POWER:
{
int nAbility = GetEventInteger(ev, 0);
object oItem = GetEventObject(ev, 0);
object oCaster = GetEventObject(ev, 1);
object oTarget = GetEventObject(ev, 2);
string sItem = GetTag(oItem);

if (sItem == "cocim_test") zTest();

if (sItem == "cocpt_cod_bks_khasi") zTeleportHeartOfDarkness();
}
[/dascript]

Here I am using tag-based scripting to call a function for each item. It would be a trivial change to call a script with the same name as the item tag.

#5
Artevere

Artevere
  • Members
  • 36 messages

FergusM wrote...

In the item editor, you want to pick an 'activated ability'. It is right near the top. This selects an ability from the ABI_base 2DA with abilitytype 4 (which is item abilities). You can add a new item ability (look into 2DA editing on the wiki) and set the spellscript column to the script you would like to run. This script will get called multiple times with different events when the ability is used. Take a look at some of the other ability spellscripts (for example, item_singletarget.nss) for an example of how the system works.


Well, at the top it just has appearance, basics etc. Only thing in that category I can see is "Item Property Activation Preference" and my only choices are Active When Equipped, Active When Equipped or in Repository, and Active Only In repository.

#6
0x30A88

0x30A88
  • Members
  • 1 081 messages
EDIT: Misunderstood question.

Modifié par Gisle Aune, 08 décembre 2010 - 03:07 .


#7
Proleric

Proleric
  • Members
  • 2 350 messages

Artevere wrote...

FergusM wrote...

In the item editor, you want to pick an 'activated ability'. It is right near the top. This selects an ability from the ABI_base 2DA with abilitytype 4 (which is item abilities). You can add a new item ability (look into 2DA editing on the wiki) and set the spellscript column to the script you would like to run. This script will get called multiple times with different events when the ability is used. Take a look at some of the other ability spellscripts (for example, item_singletarget.nss) for an example of how the system works.


Well, at the top it just has appearance, basics etc. Only thing in that category I can see is "Item Property Activation Preference" and my only choices are Active When Equipped, Active When Equipped or in Repository, and Active Only In repository.


That doesn't sound like Object Inspector for a Dragon Age item! The first field on that screen is Activated Ability.

@Gisle Aune - I think the OP was about items, not placeables?

#8
0x30A88

0x30A88
  • Members
  • 1 081 messages
OK, then I must have misunderstood...

#9
Artevere

Artevere
  • Members
  • 36 messages
You know what, I'm a moron, I clicked on the wrong forum section. I needed to post this in NWN 2 Scripting, Not Dragon Age scripting. Gaff.