Hi. I wrote a quick script that's meant to apply visual effects on weapons, but the custom (the most important, too) part refuses to work.
I'll be grateful for any help with debugging that part.
#include "x2_inc_itemprop"
void main(string sWeaponVisual){
object oDM = OBJECT_SELF;
object oPC = GetPlayerCurrentTarget(oDM);
object oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
if (!GetIsObjectValid(oItem)) return;
itemproperty ipLoop=GetFirstItemProperty(oItem);
SendMessageToPC(oDM, "ItemPropertyValid?");
while (GetIsItemPropertyValid(ipLoop))
{
SendMessageToPC(oDM, "Checking if the effect is visual");
if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_VISUALEFFECT)
{
RemoveItemProperty(oItem, ipLoop);
SendMessageToPC(oDM, "Removing the effect");
}
ipLoop=GetNextItemProperty(oItem);
}
if (sWeaponVisual =="clear")
return;
if (sWeaponVisual == "0"
|| sWeaponVisual == "1"
|| sWeaponVisual == "2"
|| sWeaponVisual == "3"
|| sWeaponVisual == "4"
|| sWeaponVisual == "5"
|| sWeaponVisual == "6"
|| sWeaponVisual == "7")
{
int nStockWeaponVisual = StringToInt(sWeaponVisual);
itemproperty ipAdd = ItemPropertyVisualEffect(nStockWeaponVisual);
IPSafeAddItemProperty(oItem, ipAdd);
SendMessageToPC(oDM, "Base visual effect applied");
}
else {
SendMessageToPC(oDM, "Attempting to apply a custom effect: "+sWeaponVisual);
effect eEffect = EffectNWN2SpecialEffectFile(sWeaponVisual, oItem);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oItem);
}
return;
}





Retour en haut






