SetItemCharges when zero?
#1
Posté 12 décembre 2011 - 12:23
Maybe I'm doing it wrong? I ran an item down to zero charges and while the recharge seemed to work before it got to zero, now it doesn't?
I suppose I could set it to "unlimited charges" and script it's charges, but it's so darned *convenient* for the players to see the number of charges on the item in their quickbar...
#2
Posté 12 décembre 2011 - 12:28
DragonTayl wrote...
Back again, thanks for such amazing, rapid help the other day. My question this time is if I am attempting to set charges on-the-fly, it appears when an item has reached zero charges, you cannot increase the charges to 1? How do you recharge an item that has reached zero?
Maybe I'm doing it wrong? I ran an item down to zero charges and while the recharge seemed to work before it got to zero, now it doesn't?
I suppose I could set it to "unlimited charges" and script it's charges, but it's so darned *convenient* for the players to see the number of charges on the item in their quickbar...
You can set charges when at 0, you just can't use them until you rest.
#3
Posté 12 décembre 2011 - 01:46
#4
Posté 12 décembre 2011 - 05:58
Re-adding the itemproperty with cast spell/charge does work much better than resting.Lightfoot8 wrote...
Cool, That is good to know. I had been destroying the items and recreating them in order to get the charges back. lol...
#5
Posté 12 décembre 2011 - 06:44
ShaDoOoW wrote...
Re-adding the itemproperty with cast spell/charge does work much better than resting.Lightfoot8 wrote...
Cool, That is good to know. I had been destroying the items and recreating them in order to get the charges back. lol...
Perhaps, but it can mess up the item property order which if the object is non-plot could cause its later destruction. Also in-game, you can rest, but you won't necessarily have access to scripts to reset the charges for you if there is a bug. But yes, you can get a working model by stripping all item properties and adding them back sequentially.
Modifié par WhiZard, 12 décembre 2011 - 06:45 .
#6
Posté 12 décembre 2011 - 08:12
this isnt general but scripting forum, none of your points is valid in scripting terms, not mention that player might not have to be able to rest in some scenarios - anyway what player might or might not is not relevant in scripting forum - scripter can make it work via script without any issues - thats imo better than relying on player restingWhiZard wrote...
ShaDoOoW wrote...
Re-adding the itemproperty with cast spell/charge does work much better than resting.Lightfoot8 wrote...
Cool, That is good to know. I had been destroying the items and recreating them in order to get the charges back. lol...
Perhaps, but it can mess up the item property order which if the object is non-plot could cause its later destruction. Also in-game, you can rest, but you won't necessarily have access to scripts to reset the charges for you if there is a bug. But yes, you can get a working model by stripping all item properties and adding them back sequentially.
Modifié par ShaDoOoW, 12 décembre 2011 - 08:14 .
#7
Posté 12 décembre 2011 - 08:55
ShaDoOoW wrote...
this isnt general but scripting forum, none of your points is valid in scripting terms, not mention that player might not have to be able to rest in some scenarios - anyway what player might or might not is not relevant in scripting forum - scripter can make it work via script without any issues - thats imo better than relying on player resting
I assume that you didn't understand a thing I said by this response. Order for cast spell properties on a non-plot item matter when it comes to item destruction. Take the staff of the magi for example when you use up the charges on it the staff will not be destroyed. Let's say I then set the charges to fifty and remove and regive the lightning bolt, invisibility, and ice storm cast spell properties. Now the item functionally acts the same as before, but when I use up the charges again the item is destroyed.
#8
Posté 13 décembre 2011 - 08:04
-> 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.
Easy and friendly on users end.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);
}
}
Modifié par ShaDoOoW, 13 décembre 2011 - 11:07 .





Retour en haut






