void main() { if (GetInventoryDisturbType()!=INVENTORY_DISTURB_TYPE_ADDED) { return; } object oEmerald; object oCharging; object oCycle=GetFirstItemInInventory(); while (GetIsObjectValid(oCycle)) { if (GetTag(oCycle)=="jw_emerald"||GetTag(oCycle)=="NW_IT_GEM012") { oEmerald=oCycle; } else { oCharging=oCycle; } oCycle=GetNextItemInInventory(); } if (!GetIsObjectValid(oEmerald)) { //SpeakString("There is no emerald"); return; } if (!GetIsObjectValid(oCharging)) { //SpeakString("There is no item to charge"); return; } string sTag=GetTag(oCharging); if (GetStringLeft(sTag,3)=="Dye") { // cannot charge dye items return; } int nCharges=GetItemCharges(oCharging); //SpeakString(GetName(oCharging)+" has "+IntToString(nCharges)+ "charges"); nCharges++; SetItemCharges(oCharging, nCharges); int nStack=GetItemStackSize(oEmerald); if (nStack==1) { DestroyObject(oEmerald); } else { nStack=nStack-1; SetItemStackSize(oEmerald,nStack); } // do effects effect eVis=EffectVisualEffect(VFX_FNF_SCREEN_BUMP); eVis=EffectLinkEffects(EffectVisualEffect(VFX_IMP_LIGHTNING_M),eVis); ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eVis,GetLocation(OBJECT_SELF)); int nCounter=0; object oSanclight=GetObjectByTag("jw_sanclight",nCounter); while (GetIsObjectValid(oSanclight)) { ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eVis,GetLocation(oSanclight)); nCounter++; oSanclight=GetObjectByTag("jw_sanclight",nCounter); } }