Run a script on item onEquip / onUnequip?
#1
Posté 09 février 2011 - 08:21
what i intend to do is apply an effect to the player when they equip an item, but only if they have the rest of the set equipped. then when any of the set is unequipped the effect would be dispelled.
in effect, creating an 'item set' similar to diablo or wow.
#2
Posté 09 février 2011 - 09:04
#3
Posté 09 février 2011 - 09:28
1) You have to enable tag based scripting in your module load script:
SetModuleSwitch(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE);
2) You have to name your file using the following convention:
i_{itemTag}_{eventAbbreviation}
Example item activation script: i_wickeditem_ac
Modifié par ç i p h é r, 09 février 2011 - 09:28 .
#4
Posté 09 février 2011 - 09:34
ç i p h é r wrote...
IIRC, it requires two things.
1) You have to enable tag based scripting in your module load script:
SetModuleSwitch(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE);
If you don't mess with the default module load script (x2_mod_def_load) it takes care of this for you.
// * Item Event Scripts: The game's default event scripts allow routing of all item related events
// * into a single file, based on the tag of that item. If an item's tag is "test", it will fire a
// * script called "test" when an item based event (equip, unequip, acquire, unacquire, activate,...)
// * is triggered. Check "x2_it_example.nss" for an example.
// * This feature is disabled by default.
SetModuleSwitch (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE);
// Enabling this causes tagbased scripting to use 7 different scripts for item events instead of
// having them packaged all in one.
// The scripts are postfixed with "_aq", "_ua", "_eq", "_ue", "_ac", "_ci", and "hc"
SetModuleSwitch (MODULE_SWITCH_ENABLE_SEPERATE_ITEM_SCRIPTS, TRUE);
if (GetModuleSwitchValue (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
{
// * If Tagbased scripts are enabled, and you are running a Local Vault Server
// * you should use the line below to add a layer of security to your server, preventing
// * people to execute script you don't want them to. If you use the feature below,
// * all called item scrips will be the prefix + the Tag of the item you want to execute, up to a
// * maximum of 16 chars, instead of the pure tag of the object.
// * i.e. without the line below a user activating an item with the tag "test",
// * will result in the execution of a script called "test". If you uncomment the line below
// * the script called will be "1_test.nss"
SetUserDefinedItemEventPrefix("i_");
}
Modifié par MasterChanger, 09 février 2011 - 09:35 .
#5
Posté 09 février 2011 - 10:44
AeitZean wrote...
what i intend to do is apply an effect to the player when they equip an item, but only if they have the rest of the set equipped. then when any of the set is unequipped the effect would be dispelled.
Download my fix for Nasher's Set from the vault here. It includes tag-based equip and unequip scripts for each of the four items and when all are equipped together as a set their powers are increased.
Or download my Elysande's set which is also a set of items that are enhanced when worn together.
Regards





Retour en haut






