...
Copy the line below and append it to the bottom of your spreadsheet:
| Code Block |
|---|
324 <new_vfx_label_here> D 0 <new_vfx_filename_here> **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** 1 |
Note the ID number given here is 324. Replace that with whatever your new line ID would be. (tip: in Notepad++ usually equals line number minus 4)
...
That switch can be enabled by setting a module INT of name "X2_SWITCH_ENABLE_TAGBASED_SCRIPTS" to 1, or by calling one of the following on module load:
| Code Block |
|---|
SetLocalInt (GetModule(), "X2_SWITCH_ENABLE_TAGBASED_SCRIPTS", 1); |
...
SetLocalInt (GetModule(), MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, 1); |
...
SetModuleSwitch("X2_SWITCH_ENABLE_TAGBASED_SCRIPTS", TRUE); |
...
SetModuleSwitch(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE); |
If you are using the default module OnModuleLoad script "x2_mod_def_load", you'll notice that on line 89, tag-based scripts are already enabled by default, so none of the above would be needed.
...
In your event-handling tag-based script, you might use a script like this, which stores an effect tag on the effect and in a "slot" variable on the PC.
| Code Block |
|---|
#include "x2_inc_switches" |
...
// This script runs when a pc activates an item with the tag IT_HAT01 |
...
// The script toggles the visual effect IT_HAT01 on the activator |
...
//Applies the specified Fashion VFX to oTarget in slot sEffectSlotName, and tags the effect with sEffectTag |
...
void ApplyFashionEffectToObject(object oTarget, int nEffectID, string sEffectSlotName, string sEffectTag); |
...
void ApplyFashionEffectToObject(object oTarget, int nEffectID, string sEffectSlotName, string sEffectTag) |
...
{ effect eEffect = EffectVisualEffect(nEffectID); |
...
eEffect = SupernaturalEffect(eEffect); |
...
eEffect = TagEffect(eEffect, sEffectTag); |
...
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget); |
...
SetLocalString(oTarget, sEffectSlotName, sEffectTag); |
...
} |
...
//Removes all visual effects from oTarget having tag equal to sEffectTag |
...
void RemoveFashionEffectFromObjectByTag(object oTarget, string sEffectTag); |
...
void RemoveFashionEffectFromObjectByTag(object oTarget, string sEffectTag) |
...
{ |
...
if (sEffectTag != "") |
...
{ |
...
effect eLoop = GetFirstEffect(oTarget); |
...
while (GetIsEffectValid(eLoop)) { |
...
if (GetEffectType(eLoop) == EFFECT_TYPE_VISUALEFFECT) |
...
if (GetEffectTag(eLoop) == sEffectTag) |
...
RemoveEffect(oTarget, eLoop); |
...
eLoop = GetNextEffect(oTarget); |
...
} |
...
} |
...
} |
...
//Removes all visual effects from oTarget having the tag associated with the |
...
//Fashion VFX applied in slot sEffectSlotName on oTarget |
...
void RemoveFashionEffectFromObjectBySlot(object oTarget, string sEffectSlotName); |
...
void RemoveFashionEffectFromObjectBySlot(object oTarget, string sEffectSlotName) |
...
{ |
...
string sEffectTag = GetLocalString(oTarget, sEffectSlotName); |
...
RemoveFashionEffectFromObjectByTag(oTarget, sEffectTag); |
...
} |
...
//Removes all visual effects from oTarget having the specified tag sEffectTag, |
...
//or the tag associated with the Fashion VFX applied in slot sEffectSlotName on oTarget, |
...
//then applies the specified Fashion VFX nEffectID to oTarget in slot sEffectSlotName, |
...
//and tags the effect with sEffectTag |
...
void SafeApplyFashionEffectToObject(object oTarget, int nEffectID, string sEffectSlotName, string sEffectTag); |
...
void SafeApplyFashionEffectToObject(object oTarget, int nEffectID, string sEffectSlotName, string sEffectTag) |
...
{ RemoveFashionEffectFromObjectBySlot(oTarget, sEffectSlotName); |
...
RemoveFashionEffectFromObjectByTag(oTarget, sEffectTag); |
...
ApplyFashionEffectToObject(oTarget, nEffectID, sEffectSlotName, sEffectTag); |
...
} |
...
void main() |
...
{ int nEvent = GetUserDefinedItemEventNumber(); |
...
object oPC; |
...
object oItem; |
...
if (nEvent == X2_ITEM_EVENT_ACTIVATE) { |
...
oPC = GetItemActivator(); |
...
oItem = GetItemActivated(); |
...
string sTag = GetTag(oItem); |
...
int nEffectID = 324; //modify this to reflect your new visualeffect line number |
...
string sEffectSlotName = "FASHION_SLOT_HEAD"; //customize this to fit your needs |
...
...
SafeApplyFashionEffectToObject(oPC, nEffectID, sEffectSlotName, sTag); |
...
} |
...
} |
Conclusion
A script like this could be used to designate many Fashion VFX slots, such as eyes, horns, or even beard.
...