Jezuz man, talking with you is sometimes very hard, please dont be so bound to whats written on wiki and use more an imagination. I really sometimes don't know what are you trying to prove.
-> Yes I understood what you meant, afterall I read your research on wiki about cast spell order and item destruction and you are correct in that engine behavior and btw good job.
But as a scripter you have a full control over itemproperties. You not only can re-add them to fix the 0 charges issue, you can even controll their order. Now that thanks to you we know about this issue we can workaround it.
This function update item charges on item without need to player to rest to update cast spell itemproperties and without changing the cast spell item properties order.
void UpdateItemCharges(object oItem, int nCharges)
{
int charges = GetItemCharges(oItem);
SetItemCharges(oItem,nCharges);
if(charges > 0)
return;
itemproperty ip = GetFirstItemProperty(oItem);
float fDelay = 0.0;
while(GetIsItemPropertyValid(ip))
{
if(GetItemPropertyType(ip) == ITEM_PROPERTY_CAST_SPELL)
{
RemoveItemProperty(oItem,ip);
DelayCommand(fDelay,AddItemProperty(DURATION_TYPE_PERMANENT,ip,oItem));
fDelay+=0.01;
}
ip = GetNextItemProperty(oItem);
}
}
Easy and friendly on users end.
Modifié par ShaDoOoW, 13 décembre 2011 - 11:07 .