You don't need a script for each individual item. Rather, you need something like the following in your OnPlayerEquipItem script (disclaimer: I'm doing this in a text editor since I'm at work and cannot guarantee it will compile):
object oItem = GetPCItemLastEquipped();
// If the equipped item has the Haste property...
if (GetItemHasItemProperty(oItem, ITEM_PROPERTY_HASTE))
{
object oPC = GetPCItemLastEquippedBy();
int nItems = GetLocalInt(oPC, "HastedItems");
// Slow him if he hasn't been slowed by another hasted item.
if (!nItems)
{
effect eSlow = EffectMovementSpeedDecrease(30);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eSlow, oPC);
}
// Increment a counter for hasted items in case the PC has more than one
SetLocalInt(oPC, "HastedItems", nItems + 1);
}
...and something like this in your OnPlayerUnEquipItem script:
object oItem = GetPCItemLastUnequipped();
// If the unequipped item has the Haste property...
if (GetItemHasItemProperty(oItem, ITEM_PROPERTY_HASTE))
{
object oPC = GetPCItemLastUnequippedBy();
int nItems = GetLocalInt(oPC, "HastedItems");
// Remove the slow effect if he has no more hasted items.
if (nItems == 1)
{
object oCreator = GetModule();
effect eEffect = GetFirstEffect(oPC);
while (GetIsEffectValid(eEffect))
{
if (GetEffectType(eEffect) == EFFECT_TYPE_MOVEMENT_SPEED_DECREASE &&
GetEffectCreator(eEffect) == oCreator) // Don't remove slow effects from other sources
RemoveEffect(oPC, eEffect);
eEffect = GetNextEffect(oPC);
}
}
// Decrement a counter for hasted items in case the PC has more than one
SetLocalInt(oPC, "HastedItems", nItems - 1);
}
Note: I'm not sure if equipped items that are destroyed with DestroyObject() are still valid when the OnPlayerUnequipItem event is fired. If not, you'd need to loop through all currently equipped items to see if a now-invalid item had the Haste property.
Modifié par Squatting Monk, 24 janvier 2014 - 02:54 .